Skip to content

fix: register MySQL UDFs once per database - #469

Merged
weicao merged 1 commit into
mainfrom
fix/mysql-rand-registration
Aug 22, 2026
Merged

fix: register MySQL UDFs once per database#469
weicao merged 1 commit into
mainfrom
fix/mysql-rand-registration

Conversation

@weicao

@weicao weicao commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • register the mysql_rand and mysql_random_bytes DuckDB scalar UDFs once per shared database catalog instead of once per pooled physical connection
  • reset the one-time registration state when the connection pool switches to a fresh DuckDB connector
  • cover multiple physical connections, connection churn, pool reset, both UDFs, and the first MySQL query after a real server start

Reproduction

On exact main 9767800a, the new multi-connection regression failed on the second physical connection with:

register mysql_rand: database/sql/driver: API error: could not create scalar UDF

Verification

  • go test -race ./catalog -run '^TestConnectionPoolRegistersMySQLUDFsOnce$' -count=1 -v
  • go test ./catalog -count=1
  • first-query regression repeated three times
  • go test ./pgserver -run '^TestIssue280RepeatedConnectMySQLDatabase$' -count=1
  • go test ./pgserver -run '^TestIssue341PgAuthRejectsWrongPassword$' -count=1
  • go test ./backend ./transpiler -count=1
  • go test ./charset ./harness ./flightsqltest -count=1
  • go vet ./catalog
  • go build ./...

@weicao
weicao requested a review from leon-ape August 22, 2026 03:47

@leon-ape leon-ape left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent source review of exact signed head 1babe03 (parent 9767800, tree d29c8bf7c003aa9876b3ab4ca62603d60477218c): no findings. The per-pool sync.Once matches DuckDB catalog-level UDF lifetime, Reset reinitializes the state for a fresh connector, and regression coverage exercises multiple physical connections, churn, reset, both UDFs, and the first real MySQL query.

@weicao
weicao merged commit 8021432 into main Aug 22, 2026
5 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants