fix: resolve 15-16 transformer AST mismatch for create_view-281.sql #202
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.
Fix: resolve 15-16 transformer AST mismatch for create_view-281.sql
Summary
This PR fixes a critical AST transformation mismatch in the PostgreSQL 15-to-16 transformer that was causing the
latest/postgres/create_view-281.sqltest case to fail. The issue was related to howSYSTEM_USERreferences are transformed between PostgreSQL versions.The root cause was that PostgreSQL 15 and 16 represent
SYSTEM_USERdifferently in their ASTs:ColumnReffor direct references,RangeVarfor table-like usageFuncCallwithpg_catalog.system_userfor both cases, orRangeFunctionfor table-like usageThe complex CREATE VIEW SQL statement contained multiple forms of
SYSTEM_USERusage that required bidirectional transformation logic to handle all cases correctly.Review & Testing Checklist for Human
ColumnRef↔FuncCallandRangeVar↔RangeFunctiontransformations are complex. Review the logic in both directions to ensure they're consistent and handle edge cases.SYSTEM_USERto ensure this fix doesn't break existing functionality.{} as anychange in theListmethod affects many AST nodes. Spot-check a few other transformer tests to ensure no regressions.Diagram
%%{ init : { "theme" : "default" }}%% graph TB subgraph "Test Infrastructure" A["transformer-errors.ts"]:::minor-edit B["latest-postgres-create_view.test.ts"]:::context end subgraph "Core Transformer" C["v15-to-v16.ts"]:::major-edit D["ColumnRef method"]:::major-edit E["FuncCall method"]:::major-edit F["RangeVar method"]:::major-edit G["List method"]:::minor-edit H["IndexStmt method"]:::minor-edit end subgraph "SQL Query" I["CREATE VIEW with SYSTEM_USER"]:::context J["Direct SYSTEM_USER references"]:::context K["SELECT * FROM SYSTEM_USER"]:::context end A --> C B --> C C --> D C --> E C --> F C --> G C --> H I --> J I --> K J --> D J --> E K --> F subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
IndexStmtby accidentally removingnulls_not_distincthandling, which I caught and fixed in a follow-up commit.create_view-281.sqltest case.