Repository navigation
PG18: tolerate new libpg_query location fields and deparse record declaration defaults - #395
Conversation
…AST comparisons libpg_query 18-latest (Normalize: take constant locations from the parser) adds DefElem.arg_location, NotifyStmt.payload_location and CreateSubscriptionStmt/AlterSubscriptionStmt.conninfo_location. They are source offsets like location, so round-trip comparisons must strip them.
… declarations PG18 libpg_query serializes PLpgSQL_rec with isconst/notnull/default_val/datatype (record, composite and unresolved custom types). Emit them like PLpgSQL_var and walk PLpgSQL_rec datatype/default_val in walkPlpgsqlAst.
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. No issues found — approved ✅. The change extends the volatile-key cleaning used by round-trip validation and fixes
Two low-severity observations stayed below the reporting threshold: the Reviewed commit: 725b65a |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Summary
Prepares pgsql-parser for the next libpg_query PG 18 bump (constructive-io/libpg_query#15 core sync + constructive-io/libpg_query#16 patch series). With a WASM built from #16, 221 tests failed (81 deparser, 127 transform-ast, 6 plpgsql-parser, 6 transform, 1 plpgsql-deparser). None of them came from a parse bug. They came from two AST additions:
18-latest, "Normalize: Take constant locations from the parser"):DefElem.arg_location,NotifyStmt.payload_location,Create/AlterSubscriptionStmt.conninfo_location. A diff of all 304 kitchen-sink fixtures, published WASM vs. new WASM, shows these three keys are the only differences. Round-trip comparisons strippedlocationbut not these fields, so every functionAS/LANGUAGEoption mismatched after deparse. These are now added to everycleanTree/ volatile-key set (deparser, transform-ast, transformCLEAN_TREE_VOLATILE_KEYS, plpgsql-deparser, plpgsql-parser tests).PLpgSQL_recnow carries declaration properties (when we upgrade to PG 12/13, add these test cases #16 record-datatype patch):isconst,notnull,default_val,datatype. Unresolved custom types (int_nn,booltrue, compositetest1) andrecordbecomePLpgSQL_rec.deparseRecdropped:= row(1,2,3)/NOT NULL/CONSTANT. It now emits them likedeparseVar.walkPlpgsqlAstalso walksPLpgSQL_rec.datatypeanddefault_val.Both changes are backward compatible: the published
libpg-queryWASM omits these fields.Testing:
pnpm -r testpasses fully with both the published WASM (CI) and a locally built WASM from libpg_query#16. Added unit tests use hand-built ASTs for record declarations and the traverse walk, so they don't depend on the WASM version.Not included: the
18-latest.proto/ generated types refresh (new fieldsarg_location,payload_location,payload_param,conninfo_location,CreateStatsStmt.owner) and deparsingNOTIFY chan, $1(payload_param). These belong with the libpg-query version bump.Implemented in session Combine PG 18 patch branches into one PR
Review with Devin · Open in Devin Desktop
Summary by CodeRabbit
CONSTANT,NOT NULL, declared types, and default expressions. Declarations without a type useRECORD.