fix: use ad.adrelid instead of pg_attrdef OID in pg_get_expr#325
Open
simPod wants to merge 1 commit intonette:v3.2from
Open
fix: use ad.adrelid instead of pg_attrdef OID in pg_get_expr#325simPod wants to merge 1 commit intonette:v3.2from
simPod wants to merge 1 commit intonette:v3.2from
Conversation
Fixes: SQLSTATE[XX000]: Internal error: 7 ERROR: invalid attnum 9 for relation "pg_attrdef" pg_get_expr requires the OID of the relation that owns the expression as its second argument. Using 'pg_catalog.pg_attrdef'::regclass passes the OID of the catalog table itself, which causes "invalid attnum" errors when tables have GENERATED ALWAYS AS stored columns. The correct relation OID is ad.adrelid (the table the default/generated expression belongs to). The autoincrement detection on the same line already uses ad.adrelid correctly — this aligns the other two calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pg_get_expr requires the OID of the relation that owns the expression as its second argument. Using 'pg_catalog.pg_attrdef'::regclass passes the OID of the catalog table itself, which causes "invalid attnum" errors when tables have GENERATED ALWAYS AS stored columns.
The correct relation OID is ad.adrelid (the table the default/generated expression belongs to). Line 152 already uses ad.adrelid correctly for the same function — this aligns lines 151 and 155.