-
-
Notifications
You must be signed in to change notification settings - Fork 46
Description
Description
Running a migration file containing multiple CREATE TABLE statements via SQLx (which uses the PostgreSQL extended query protocol) causes a nil pointer dereference panic. The same SQL executes successfully via psql (simple query protocol).
This is likely related to #2299 (ENUM default crash) since the stack trace is identical — the migration file contains tables with ENUM column defaults. However, even after removing the ENUM defaults, SQLx's sqlx migrate run still fails with the same panic when processing large migration files, suggesting there may be an additional issue with the extended query protocol handling.
Reproduction
Create a migration file with 25+ CREATE TABLE statements (including ENUMs, FKs, triggers) and run via SQLx:
sqlx migrate run
# error: while executing migration 1: error returned from database: runtime error: invalid memory address or nil pointer dereferenceThe same SQL file works via psql:
psql -U postgres -d mydb -f migrations/001_initial_schema.sql
# Success (after removing ENUM defaults per #2299)Stack trace
Same as #2299:
server/types/type.go:495 (*DoltgresType).IoInput
server/functions/framework/cast.go:330 UnknownLiteralCast
server/expression/assignment_cast.go:66 (*AssignmentCast).Eval
sql/columndefault.go:229 (*ColumnDefaultValue).CheckType
server/analyzer/validate_column_defaults.go:167 validateColumnDefault
Workaround
Apply schema via psql (simple query protocol) through docker-entrypoint-initdb.d init scripts instead of using SQLx migrations.
Environment
- DoltgreSQL version: 0.54.10
- Docker image:
dolthub/doltgresql:latest - Client: SQLx 0.8 (Rust) via extended query protocol