@pgsql/transform 17.6.3 → 17.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/13/enum-to-int.d.ts +7 -0
- package/13/enum-to-int.js +2165 -0
- package/13/enum-to-str.d.ts +7 -0
- package/13/enum-to-str.js +2165 -0
- package/13/enums.d.ts +14 -21
- package/13/runtime-schema.d.ts +17 -0
- package/13/runtime-schema.js +8419 -0
- package/13/types.d.ts +1078 -1303
- package/14/enum-to-int.d.ts +7 -0
- package/14/enum-to-int.js +2205 -0
- package/14/enum-to-str.d.ts +7 -0
- package/14/enum-to-str.js +2205 -0
- package/14/enums.d.ts +62 -0
- package/14/enums.js +2 -0
- package/14/runtime-schema.d.ts +17 -0
- package/14/runtime-schema.js +8695 -0
- package/14/types.d.ts +2164 -0
- package/14/types.js +2 -0
- package/15/enum-to-int.d.ts +7 -0
- package/15/enum-to-int.js +2255 -0
- package/15/enum-to-str.d.ts +7 -0
- package/15/enum-to-str.js +2255 -0
- package/15/enums.d.ts +64 -0
- package/15/enums.js +2 -0
- package/15/runtime-schema.d.ts +17 -0
- package/15/runtime-schema.js +8955 -0
- package/15/types.d.ts +2222 -0
- package/15/types.js +2 -0
- package/16/enum-to-int.d.ts +7 -0
- package/16/enum-to-int.js +2344 -0
- package/16/enum-to-str.d.ts +7 -0
- package/16/enum-to-str.js +2344 -0
- package/16/enums.d.ts +69 -0
- package/16/enums.js +2 -0
- package/16/runtime-schema.d.ts +17 -0
- package/16/runtime-schema.js +9339 -0
- package/16/types.d.ts +2328 -0
- package/16/types.js +2 -0
- package/17/enum-to-int.d.ts +7 -0
- package/17/enum-to-int.js +2501 -0
- package/17/enum-to-str.d.ts +7 -0
- package/17/enum-to-str.js +2501 -0
- package/17/runtime-schema.d.ts +17 -0
- package/17/runtime-schema.js +10010 -0
- package/esm/13/enum-to-int.js +2161 -0
- package/esm/13/enum-to-str.js +2161 -0
- package/esm/13/runtime-schema.js +8416 -0
- package/esm/14/enum-to-int.js +2201 -0
- package/esm/14/enum-to-str.js +2201 -0
- package/esm/14/enums.js +1 -0
- package/esm/14/runtime-schema.js +8692 -0
- package/esm/14/types.js +1 -0
- package/esm/15/enum-to-int.js +2251 -0
- package/esm/15/enum-to-str.js +2251 -0
- package/esm/15/enums.js +1 -0
- package/esm/15/runtime-schema.js +8952 -0
- package/esm/15/types.js +1 -0
- package/esm/16/enum-to-int.js +2340 -0
- package/esm/16/enum-to-str.js +2340 -0
- package/esm/16/enums.js +1 -0
- package/esm/16/runtime-schema.js +9336 -0
- package/esm/16/types.js +1 -0
- package/esm/17/enum-to-int.js +2497 -0
- package/esm/17/enum-to-str.js +2497 -0
- package/esm/17/runtime-schema.js +10007 -0
- package/esm/index.js +15 -1309
- package/esm/multi-version-transformer.js +60 -0
- package/esm/transformers/context.js +1 -0
- package/esm/transformers/v13-to-v14.js +2745 -0
- package/esm/transformers/v14-to-v15.js +1215 -0
- package/esm/transformers/v15-to-v16.js +2876 -0
- package/esm/transformers/v16-to-v17.js +1483 -0
- package/esm/transformers-direct/index.js +8 -0
- package/esm/transformers-direct/v13-to-v17/index.js +74 -0
- package/esm/transformers-direct/v14-to-v17/index.js +63 -0
- package/esm/transformers-direct/v15-to-v17/index.js +53 -0
- package/esm/transformers-direct/v16-to-v17/index.js +40 -0
- package/index.d.ts +18 -5
- package/index.js +29 -1311
- package/multi-version-transformer.d.ts +9 -0
- package/multi-version-transformer.js +64 -0
- package/package.json +8 -4
- package/transformers/context.d.ts +4 -0
- package/transformers/context.js +2 -0
- package/transformers/v13-to-v14.d.ts +252 -0
- package/transformers/v13-to-v14.js +2749 -0
- package/transformers/v14-to-v15.d.ts +615 -0
- package/transformers/v14-to-v15.js +1219 -0
- package/transformers/v15-to-v16.d.ts +626 -0
- package/transformers/v15-to-v16.js +2880 -0
- package/transformers/v16-to-v17.d.ts +637 -0
- package/transformers/v16-to-v17.js +1487 -0
- package/transformers-direct/index.d.ts +8 -0
- package/transformers-direct/index.js +15 -0
- package/transformers-direct/v13-to-v17/index.d.ts +27 -0
- package/transformers-direct/v13-to-v17/index.js +78 -0
- package/transformers-direct/v14-to-v17/index.d.ts +26 -0
- package/transformers-direct/v14-to-v17/index.js +67 -0
- package/transformers-direct/v15-to-v17/index.d.ts +25 -0
- package/transformers-direct/v15-to-v17/index.js +57 -0
- package/transformers-direct/v16-to-v17/index.d.ts +24 -0
- package/transformers-direct/v16-to-v17/index.js +44 -0
|
@@ -0,0 +1,1487 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.V16ToV17Transformer = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* V16 to V17 AST Transformer
|
|
6
|
+
* Transforms PostgreSQL v16 AST nodes to v17 format
|
|
7
|
+
*/
|
|
8
|
+
class V16ToV17Transformer {
|
|
9
|
+
transform(node, context = { parentNodeTypes: [] }) {
|
|
10
|
+
if (node == null) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (typeof node === 'number' || node instanceof Number) {
|
|
14
|
+
return node;
|
|
15
|
+
}
|
|
16
|
+
if (typeof node === 'string') {
|
|
17
|
+
return node;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return this.visit(node, context);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const nodeType = Object.keys(node)[0];
|
|
24
|
+
throw new Error(`Error transforming ${nodeType}: ${error.message}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
visit(node, context = { parentNodeTypes: [] }) {
|
|
28
|
+
const nodeType = this.getNodeType(node);
|
|
29
|
+
// Handle empty objects
|
|
30
|
+
if (!nodeType) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
const nodeData = this.getNodeData(node);
|
|
34
|
+
const methodName = nodeType;
|
|
35
|
+
if (typeof this[methodName] === 'function') {
|
|
36
|
+
const childContext = {
|
|
37
|
+
...context,
|
|
38
|
+
parentNodeTypes: [...context.parentNodeTypes, nodeType]
|
|
39
|
+
};
|
|
40
|
+
const result = this[methodName](nodeData, childContext);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
// If no specific method, return the node as-is
|
|
44
|
+
return node;
|
|
45
|
+
}
|
|
46
|
+
getNodeType(node) {
|
|
47
|
+
return Object.keys(node)[0];
|
|
48
|
+
}
|
|
49
|
+
getNodeData(node) {
|
|
50
|
+
const keys = Object.keys(node);
|
|
51
|
+
if (keys.length === 1 && typeof node[keys[0]] === 'object') {
|
|
52
|
+
return node[keys[0]];
|
|
53
|
+
}
|
|
54
|
+
return node;
|
|
55
|
+
}
|
|
56
|
+
ParseResult(node, context) {
|
|
57
|
+
if (node && typeof node === 'object' && 'version' in node && 'stmts' in node) {
|
|
58
|
+
return {
|
|
59
|
+
version: 170004, // PG17 version
|
|
60
|
+
stmts: node.stmts.map((stmt) => {
|
|
61
|
+
if (stmt && typeof stmt === 'object' && 'stmt' in stmt) {
|
|
62
|
+
return {
|
|
63
|
+
...stmt,
|
|
64
|
+
stmt: this.transform(stmt.stmt, context)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return this.transform(stmt, context);
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return node;
|
|
72
|
+
}
|
|
73
|
+
RawStmt(node, context) {
|
|
74
|
+
const result = {};
|
|
75
|
+
if (node.stmt !== undefined) {
|
|
76
|
+
result.stmt = this.transform(node.stmt, context);
|
|
77
|
+
}
|
|
78
|
+
if (node.stmt_location !== undefined) {
|
|
79
|
+
result.stmt_location = node.stmt_location;
|
|
80
|
+
}
|
|
81
|
+
if (node.stmt_len !== undefined) {
|
|
82
|
+
result.stmt_len = node.stmt_len;
|
|
83
|
+
}
|
|
84
|
+
return { RawStmt: result };
|
|
85
|
+
}
|
|
86
|
+
SelectStmt(node, context) {
|
|
87
|
+
const result = {};
|
|
88
|
+
if (node.distinctClause !== undefined) {
|
|
89
|
+
result.distinctClause = Array.isArray(node.distinctClause)
|
|
90
|
+
? node.distinctClause.map(item => this.transform(item, context))
|
|
91
|
+
: this.transform(node.distinctClause, context);
|
|
92
|
+
}
|
|
93
|
+
if (node.intoClause !== undefined) {
|
|
94
|
+
result.intoClause = this.transform(node.intoClause, context);
|
|
95
|
+
}
|
|
96
|
+
if (node.targetList !== undefined) {
|
|
97
|
+
result.targetList = Array.isArray(node.targetList)
|
|
98
|
+
? node.targetList.map(item => this.transform(item, context))
|
|
99
|
+
: this.transform(node.targetList, context);
|
|
100
|
+
}
|
|
101
|
+
if (node.fromClause !== undefined) {
|
|
102
|
+
result.fromClause = Array.isArray(node.fromClause)
|
|
103
|
+
? node.fromClause.map(item => this.transform(item, context))
|
|
104
|
+
: this.transform(node.fromClause, context);
|
|
105
|
+
}
|
|
106
|
+
if (node.whereClause !== undefined) {
|
|
107
|
+
result.whereClause = this.transform(node.whereClause, context);
|
|
108
|
+
}
|
|
109
|
+
if (node.groupClause !== undefined) {
|
|
110
|
+
result.groupClause = Array.isArray(node.groupClause)
|
|
111
|
+
? node.groupClause.map(item => this.transform(item, context))
|
|
112
|
+
: this.transform(node.groupClause, context);
|
|
113
|
+
}
|
|
114
|
+
if (node.groupDistinct !== undefined) {
|
|
115
|
+
result.groupDistinct = node.groupDistinct;
|
|
116
|
+
}
|
|
117
|
+
if (node.havingClause !== undefined) {
|
|
118
|
+
result.havingClause = this.transform(node.havingClause, context);
|
|
119
|
+
}
|
|
120
|
+
if (node.windowClause !== undefined) {
|
|
121
|
+
result.windowClause = Array.isArray(node.windowClause)
|
|
122
|
+
? node.windowClause.map(item => this.transform(item, context))
|
|
123
|
+
: this.transform(node.windowClause, context);
|
|
124
|
+
}
|
|
125
|
+
if (node.valuesLists !== undefined) {
|
|
126
|
+
const valuesContext = {
|
|
127
|
+
...context,
|
|
128
|
+
inValuesClause: true
|
|
129
|
+
};
|
|
130
|
+
result.valuesLists = Array.isArray(node.valuesLists)
|
|
131
|
+
? node.valuesLists.map(item => Array.isArray(item)
|
|
132
|
+
? item.map(subItem => this.transform(subItem, valuesContext))
|
|
133
|
+
: this.transform(item, valuesContext))
|
|
134
|
+
: this.transform(node.valuesLists, valuesContext);
|
|
135
|
+
}
|
|
136
|
+
if (node.sortClause !== undefined) {
|
|
137
|
+
result.sortClause = Array.isArray(node.sortClause)
|
|
138
|
+
? node.sortClause.map(item => this.transform(item, context))
|
|
139
|
+
: this.transform(node.sortClause, context);
|
|
140
|
+
}
|
|
141
|
+
if (node.limitOffset !== undefined) {
|
|
142
|
+
result.limitOffset = this.transform(node.limitOffset, context);
|
|
143
|
+
}
|
|
144
|
+
if (node.limitCount !== undefined) {
|
|
145
|
+
result.limitCount = this.transform(node.limitCount, context);
|
|
146
|
+
}
|
|
147
|
+
if (node.limitOption !== undefined) {
|
|
148
|
+
result.limitOption = node.limitOption;
|
|
149
|
+
}
|
|
150
|
+
if (node.lockingClause !== undefined) {
|
|
151
|
+
result.lockingClause = Array.isArray(node.lockingClause)
|
|
152
|
+
? node.lockingClause.map(item => this.transform(item, context))
|
|
153
|
+
: this.transform(node.lockingClause, context);
|
|
154
|
+
}
|
|
155
|
+
if (node.withClause !== undefined) {
|
|
156
|
+
result.withClause = this.transform(node.withClause, context);
|
|
157
|
+
}
|
|
158
|
+
if (node.op !== undefined) {
|
|
159
|
+
result.op = node.op;
|
|
160
|
+
}
|
|
161
|
+
if (node.all !== undefined) {
|
|
162
|
+
result.all = node.all;
|
|
163
|
+
}
|
|
164
|
+
if (node.larg !== undefined) {
|
|
165
|
+
result.larg = this.transform(node.larg, context);
|
|
166
|
+
}
|
|
167
|
+
if (node.rarg !== undefined) {
|
|
168
|
+
result.rarg = this.transform(node.rarg, context);
|
|
169
|
+
}
|
|
170
|
+
return { SelectStmt: result };
|
|
171
|
+
}
|
|
172
|
+
A_Expr(node, context) {
|
|
173
|
+
const result = {};
|
|
174
|
+
if (node.kind !== undefined) {
|
|
175
|
+
result.kind = node.kind;
|
|
176
|
+
}
|
|
177
|
+
if (node.name !== undefined) {
|
|
178
|
+
result.name = Array.isArray(node.name)
|
|
179
|
+
? node.name.map(item => this.transform(item, context))
|
|
180
|
+
: this.transform(node.name, context);
|
|
181
|
+
}
|
|
182
|
+
if (node.lexpr !== undefined) {
|
|
183
|
+
result.lexpr = this.transform(node.lexpr, context);
|
|
184
|
+
}
|
|
185
|
+
if (node.rexpr !== undefined) {
|
|
186
|
+
result.rexpr = this.transform(node.rexpr, context);
|
|
187
|
+
}
|
|
188
|
+
if (node.location !== undefined) {
|
|
189
|
+
result.location = node.location;
|
|
190
|
+
}
|
|
191
|
+
return { A_Expr: result };
|
|
192
|
+
}
|
|
193
|
+
InsertStmt(node, context) {
|
|
194
|
+
const result = {};
|
|
195
|
+
if (node.relation !== undefined) {
|
|
196
|
+
result.relation = this.transform(node.relation, context);
|
|
197
|
+
}
|
|
198
|
+
if (node.cols !== undefined) {
|
|
199
|
+
result.cols = Array.isArray(node.cols)
|
|
200
|
+
? node.cols.map(item => this.transform(item, context))
|
|
201
|
+
: this.transform(node.cols, context);
|
|
202
|
+
}
|
|
203
|
+
if (node.selectStmt !== undefined) {
|
|
204
|
+
result.selectStmt = this.transform(node.selectStmt, context);
|
|
205
|
+
}
|
|
206
|
+
if (node.onConflictClause !== undefined) {
|
|
207
|
+
result.onConflictClause = this.transform(node.onConflictClause, context);
|
|
208
|
+
}
|
|
209
|
+
if (node.returningList !== undefined) {
|
|
210
|
+
result.returningList = Array.isArray(node.returningList)
|
|
211
|
+
? node.returningList.map(item => this.transform(item, context))
|
|
212
|
+
: this.transform(node.returningList, context);
|
|
213
|
+
}
|
|
214
|
+
if (node.withClause !== undefined) {
|
|
215
|
+
result.withClause = this.transform(node.withClause, context);
|
|
216
|
+
}
|
|
217
|
+
if (node.override !== undefined) {
|
|
218
|
+
result.override = node.override;
|
|
219
|
+
}
|
|
220
|
+
return { InsertStmt: result };
|
|
221
|
+
}
|
|
222
|
+
UpdateStmt(node, context) {
|
|
223
|
+
const result = {};
|
|
224
|
+
if (node.relation !== undefined) {
|
|
225
|
+
result.relation = this.transform(node.relation, context);
|
|
226
|
+
}
|
|
227
|
+
if (node.targetList !== undefined) {
|
|
228
|
+
result.targetList = Array.isArray(node.targetList)
|
|
229
|
+
? node.targetList.map(item => this.transform(item, context))
|
|
230
|
+
: this.transform(node.targetList, context);
|
|
231
|
+
}
|
|
232
|
+
if (node.whereClause !== undefined) {
|
|
233
|
+
result.whereClause = this.transform(node.whereClause, context);
|
|
234
|
+
}
|
|
235
|
+
if (node.fromClause !== undefined) {
|
|
236
|
+
result.fromClause = Array.isArray(node.fromClause)
|
|
237
|
+
? node.fromClause.map(item => this.transform(item, context))
|
|
238
|
+
: this.transform(node.fromClause, context);
|
|
239
|
+
}
|
|
240
|
+
if (node.returningList !== undefined) {
|
|
241
|
+
result.returningList = Array.isArray(node.returningList)
|
|
242
|
+
? node.returningList.map(item => this.transform(item, context))
|
|
243
|
+
: this.transform(node.returningList, context);
|
|
244
|
+
}
|
|
245
|
+
if (node.withClause !== undefined) {
|
|
246
|
+
result.withClause = this.transform(node.withClause, context);
|
|
247
|
+
}
|
|
248
|
+
return { UpdateStmt: result };
|
|
249
|
+
}
|
|
250
|
+
DeleteStmt(node, context) {
|
|
251
|
+
const result = {};
|
|
252
|
+
if (node.relation !== undefined) {
|
|
253
|
+
result.relation = this.transform(node.relation, context);
|
|
254
|
+
}
|
|
255
|
+
if (node.usingClause !== undefined) {
|
|
256
|
+
result.usingClause = Array.isArray(node.usingClause)
|
|
257
|
+
? node.usingClause.map(item => this.transform(item, context))
|
|
258
|
+
: this.transform(node.usingClause, context);
|
|
259
|
+
}
|
|
260
|
+
if (node.whereClause !== undefined) {
|
|
261
|
+
result.whereClause = this.transform(node.whereClause, context);
|
|
262
|
+
}
|
|
263
|
+
if (node.returningList !== undefined) {
|
|
264
|
+
result.returningList = Array.isArray(node.returningList)
|
|
265
|
+
? node.returningList.map(item => this.transform(item, context))
|
|
266
|
+
: this.transform(node.returningList, context);
|
|
267
|
+
}
|
|
268
|
+
if (node.withClause !== undefined) {
|
|
269
|
+
result.withClause = this.transform(node.withClause, context);
|
|
270
|
+
}
|
|
271
|
+
return { DeleteStmt: result };
|
|
272
|
+
}
|
|
273
|
+
WithClause(node, context) {
|
|
274
|
+
const result = {};
|
|
275
|
+
if (node.ctes !== undefined) {
|
|
276
|
+
const cteContext = { ...context, inCTE: true };
|
|
277
|
+
result.ctes = Array.isArray(node.ctes)
|
|
278
|
+
? node.ctes.map(item => this.transform(item, cteContext))
|
|
279
|
+
: this.transform(node.ctes, cteContext);
|
|
280
|
+
}
|
|
281
|
+
if (node.recursive !== undefined) {
|
|
282
|
+
result.recursive = node.recursive;
|
|
283
|
+
}
|
|
284
|
+
if (node.location !== undefined) {
|
|
285
|
+
result.location = node.location;
|
|
286
|
+
}
|
|
287
|
+
return { WithClause: result };
|
|
288
|
+
}
|
|
289
|
+
ResTarget(node, context) {
|
|
290
|
+
const result = {};
|
|
291
|
+
if (node.name !== undefined) {
|
|
292
|
+
result.name = node.name;
|
|
293
|
+
}
|
|
294
|
+
if (node.indirection !== undefined) {
|
|
295
|
+
result.indirection = Array.isArray(node.indirection)
|
|
296
|
+
? node.indirection.map(item => this.transform(item, context))
|
|
297
|
+
: this.transform(node.indirection, context);
|
|
298
|
+
}
|
|
299
|
+
if (node.val !== undefined) {
|
|
300
|
+
result.val = this.transform(node.val, context);
|
|
301
|
+
}
|
|
302
|
+
if (node.location !== undefined) {
|
|
303
|
+
result.location = node.location;
|
|
304
|
+
}
|
|
305
|
+
return { ResTarget: result };
|
|
306
|
+
}
|
|
307
|
+
BoolExpr(node, context) {
|
|
308
|
+
const result = {};
|
|
309
|
+
if (node.boolop !== undefined) {
|
|
310
|
+
result.boolop = node.boolop;
|
|
311
|
+
}
|
|
312
|
+
if (node.args !== undefined) {
|
|
313
|
+
result.args = Array.isArray(node.args)
|
|
314
|
+
? node.args.map(item => this.transform(item, context))
|
|
315
|
+
: this.transform(node.args, context);
|
|
316
|
+
}
|
|
317
|
+
if (node.location !== undefined) {
|
|
318
|
+
result.location = node.location;
|
|
319
|
+
}
|
|
320
|
+
return { BoolExpr: result };
|
|
321
|
+
}
|
|
322
|
+
FuncCall(node, context) {
|
|
323
|
+
const result = {};
|
|
324
|
+
if (node.funcname !== undefined) {
|
|
325
|
+
result.funcname = Array.isArray(node.funcname)
|
|
326
|
+
? node.funcname.map(item => this.transform(item, context))
|
|
327
|
+
: this.transform(node.funcname, context);
|
|
328
|
+
}
|
|
329
|
+
if (node.args !== undefined) {
|
|
330
|
+
result.args = Array.isArray(node.args)
|
|
331
|
+
? node.args.map(item => this.transform(item, context))
|
|
332
|
+
: this.transform(node.args, context);
|
|
333
|
+
}
|
|
334
|
+
if (node.agg_order !== undefined) {
|
|
335
|
+
result.agg_order = Array.isArray(node.agg_order)
|
|
336
|
+
? node.agg_order.map(item => this.transform(item, context))
|
|
337
|
+
: this.transform(node.agg_order, context);
|
|
338
|
+
}
|
|
339
|
+
if (node.agg_filter !== undefined) {
|
|
340
|
+
result.agg_filter = this.transform(node.agg_filter, context);
|
|
341
|
+
}
|
|
342
|
+
if (node.agg_within_group !== undefined) {
|
|
343
|
+
result.agg_within_group = node.agg_within_group;
|
|
344
|
+
}
|
|
345
|
+
if (node.agg_star !== undefined) {
|
|
346
|
+
result.agg_star = node.agg_star;
|
|
347
|
+
}
|
|
348
|
+
if (node.agg_distinct !== undefined) {
|
|
349
|
+
result.agg_distinct = node.agg_distinct;
|
|
350
|
+
}
|
|
351
|
+
if (node.func_variadic !== undefined) {
|
|
352
|
+
result.func_variadic = node.func_variadic;
|
|
353
|
+
}
|
|
354
|
+
if (node.over !== undefined) {
|
|
355
|
+
result.over = this.transform(node.over, context);
|
|
356
|
+
}
|
|
357
|
+
if (node.location !== undefined) {
|
|
358
|
+
result.location = node.location;
|
|
359
|
+
}
|
|
360
|
+
const funcformatValue = this.getFuncformatValue(node, result.funcname, context);
|
|
361
|
+
result.funcformat = funcformatValue;
|
|
362
|
+
return { FuncCall: result };
|
|
363
|
+
}
|
|
364
|
+
FuncExpr(node, context) {
|
|
365
|
+
return { FuncExpr: node };
|
|
366
|
+
}
|
|
367
|
+
A_Const(node, context) {
|
|
368
|
+
return { A_Const: node };
|
|
369
|
+
}
|
|
370
|
+
ColumnRef(node, context) {
|
|
371
|
+
return { ColumnRef: node };
|
|
372
|
+
}
|
|
373
|
+
isInCreateDomainContext(context) {
|
|
374
|
+
return context.parentNodeTypes.includes('CreateDomainStmt');
|
|
375
|
+
}
|
|
376
|
+
isInTypeCastContext(context) {
|
|
377
|
+
return context.parentNodeTypes.includes('TypeCast');
|
|
378
|
+
}
|
|
379
|
+
isInCreateTableContext(context) {
|
|
380
|
+
return context.parentNodeTypes.includes('ColumnDef');
|
|
381
|
+
}
|
|
382
|
+
isInValuesContext(context) {
|
|
383
|
+
return context.inValuesClause === true;
|
|
384
|
+
}
|
|
385
|
+
isInSimpleSelectTypeCastContext(context) {
|
|
386
|
+
return context.parentNodeTypes.includes('TypeCast') &&
|
|
387
|
+
context.parentNodeTypes.includes('ResTarget') &&
|
|
388
|
+
!this.isInValuesContext(context);
|
|
389
|
+
}
|
|
390
|
+
shouldAddPgCatalogPrefix(context) {
|
|
391
|
+
const hasSelectStmt = context.parentNodeTypes.includes('SelectStmt');
|
|
392
|
+
const hasWithClause = context.parentNodeTypes.includes('WithClause');
|
|
393
|
+
const hasCommonTableExpr = context.parentNodeTypes.includes('CommonTableExpr');
|
|
394
|
+
return hasSelectStmt && !hasWithClause && !hasCommonTableExpr;
|
|
395
|
+
}
|
|
396
|
+
TypeName(node, context) {
|
|
397
|
+
const result = {};
|
|
398
|
+
if (node.names !== undefined) {
|
|
399
|
+
let names = Array.isArray(node.names)
|
|
400
|
+
? node.names.map(item => this.transform(item, context))
|
|
401
|
+
: this.transform(node.names, context);
|
|
402
|
+
// Add pg_catalog prefix for JSON types in CREATE TABLE contexts
|
|
403
|
+
if (Array.isArray(names) && names.length === 1) {
|
|
404
|
+
const firstElement = names[0];
|
|
405
|
+
if (firstElement && typeof firstElement === 'object' && 'String' in firstElement) {
|
|
406
|
+
const typeNameStr = firstElement.String.str || firstElement.String.sval;
|
|
407
|
+
if (typeNameStr === 'json') {
|
|
408
|
+
const hasCreateStmt = context.parentNodeTypes.includes('CreateStmt');
|
|
409
|
+
const hasCompositeTypeStmt = context.parentNodeTypes.includes('CompositeTypeStmt');
|
|
410
|
+
const hasRangeFunction = context.parentNodeTypes.includes('RangeFunction');
|
|
411
|
+
const hasCreateDomainStmt = context.parentNodeTypes.includes('CreateDomainStmt');
|
|
412
|
+
const hasColumnDef = context.parentNodeTypes.includes('ColumnDef');
|
|
413
|
+
if ((hasCreateStmt || hasCompositeTypeStmt || hasRangeFunction) && hasColumnDef) {
|
|
414
|
+
const pgCatalogElement = {
|
|
415
|
+
String: {
|
|
416
|
+
sval: 'pg_catalog'
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
names = [pgCatalogElement, firstElement];
|
|
420
|
+
}
|
|
421
|
+
else if (hasCreateDomainStmt) {
|
|
422
|
+
const pgCatalogElement = {
|
|
423
|
+
String: {
|
|
424
|
+
sval: 'pg_catalog'
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
names = [pgCatalogElement, firstElement];
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
result.names = names;
|
|
433
|
+
}
|
|
434
|
+
if (node.typeOid !== undefined) {
|
|
435
|
+
result.typeOid = node.typeOid;
|
|
436
|
+
}
|
|
437
|
+
if (node.setof !== undefined) {
|
|
438
|
+
result.setof = node.setof;
|
|
439
|
+
}
|
|
440
|
+
if (node.pct_type !== undefined) {
|
|
441
|
+
result.pct_type = node.pct_type;
|
|
442
|
+
}
|
|
443
|
+
if (node.typmods !== undefined) {
|
|
444
|
+
result.typmods = Array.isArray(node.typmods)
|
|
445
|
+
? node.typmods.map(item => this.transform(item, context))
|
|
446
|
+
: this.transform(node.typmods, context);
|
|
447
|
+
}
|
|
448
|
+
if (node.typemod !== undefined) {
|
|
449
|
+
result.typemod = node.typemod;
|
|
450
|
+
}
|
|
451
|
+
if (node.arrayBounds !== undefined) {
|
|
452
|
+
result.arrayBounds = Array.isArray(node.arrayBounds)
|
|
453
|
+
? node.arrayBounds.map(item => this.transform(item, context))
|
|
454
|
+
: this.transform(node.arrayBounds, context);
|
|
455
|
+
}
|
|
456
|
+
if (node.location !== undefined) {
|
|
457
|
+
result.location = node.location;
|
|
458
|
+
}
|
|
459
|
+
return { TypeName: result };
|
|
460
|
+
}
|
|
461
|
+
Alias(node, context) {
|
|
462
|
+
return { Alias: node };
|
|
463
|
+
}
|
|
464
|
+
RangeVar(node, context) {
|
|
465
|
+
const result = {};
|
|
466
|
+
if (node.catalogname !== undefined) {
|
|
467
|
+
result.catalogname = node.catalogname;
|
|
468
|
+
}
|
|
469
|
+
if (node.schemaname !== undefined) {
|
|
470
|
+
result.schemaname = node.schemaname;
|
|
471
|
+
}
|
|
472
|
+
if (node.relname !== undefined) {
|
|
473
|
+
result.relname = node.relname;
|
|
474
|
+
}
|
|
475
|
+
if (node.inh !== undefined) {
|
|
476
|
+
result.inh = node.inh;
|
|
477
|
+
}
|
|
478
|
+
if (node.relpersistence !== undefined) {
|
|
479
|
+
result.relpersistence = node.relpersistence;
|
|
480
|
+
}
|
|
481
|
+
if (node.alias !== undefined) {
|
|
482
|
+
result.alias = this.transform(node.alias, context);
|
|
483
|
+
}
|
|
484
|
+
if (node.location !== undefined) {
|
|
485
|
+
result.location = node.location;
|
|
486
|
+
}
|
|
487
|
+
return { RangeVar: result };
|
|
488
|
+
}
|
|
489
|
+
A_ArrayExpr(node, context) {
|
|
490
|
+
return { A_ArrayExpr: node };
|
|
491
|
+
}
|
|
492
|
+
A_Indices(node, context) {
|
|
493
|
+
return { A_Indices: node };
|
|
494
|
+
}
|
|
495
|
+
A_Indirection(node, context) {
|
|
496
|
+
return { A_Indirection: node };
|
|
497
|
+
}
|
|
498
|
+
A_Star(node, context) {
|
|
499
|
+
return { A_Star: node };
|
|
500
|
+
}
|
|
501
|
+
CaseExpr(node, context) {
|
|
502
|
+
return { CaseExpr: node };
|
|
503
|
+
}
|
|
504
|
+
CoalesceExpr(node, context) {
|
|
505
|
+
return { CoalesceExpr: node };
|
|
506
|
+
}
|
|
507
|
+
TypeCast(node, context) {
|
|
508
|
+
const result = {};
|
|
509
|
+
if (node.arg !== undefined) {
|
|
510
|
+
result.arg = this.transform(node.arg, context);
|
|
511
|
+
}
|
|
512
|
+
if (node.typeName !== undefined) {
|
|
513
|
+
let typeName = this.transform(node.typeName, context);
|
|
514
|
+
// Add pg_catalog prefix for JSON types in simple SELECT contexts, but NOT in WITH clauses
|
|
515
|
+
if (typeName && typeName.names && Array.isArray(typeName.names) && typeName.names.length === 1) {
|
|
516
|
+
const firstElement = typeName.names[0];
|
|
517
|
+
if (firstElement && typeof firstElement === 'object' && 'String' in firstElement) {
|
|
518
|
+
const typeNameStr = firstElement.String.str || firstElement.String.sval;
|
|
519
|
+
if (typeNameStr === 'json') {
|
|
520
|
+
const hasSelectStmt = context.parentNodeTypes.includes('SelectStmt');
|
|
521
|
+
const hasResTarget = context.parentNodeTypes.includes('ResTarget');
|
|
522
|
+
const hasList = context.parentNodeTypes.includes('List');
|
|
523
|
+
const hasA_Expr = context.parentNodeTypes.includes('A_Expr');
|
|
524
|
+
const hasWithClause = context.parentNodeTypes.includes('WithClause');
|
|
525
|
+
const hasCommonTableExpr = context.parentNodeTypes.includes('CommonTableExpr');
|
|
526
|
+
if (((hasSelectStmt && hasResTarget) || (hasSelectStmt && hasList) || hasA_Expr) && !hasWithClause && !hasCommonTableExpr) {
|
|
527
|
+
const pgCatalogElement = {
|
|
528
|
+
String: {
|
|
529
|
+
sval: 'pg_catalog'
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
typeName.names = [pgCatalogElement, firstElement];
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
result.typeName = typeName;
|
|
538
|
+
}
|
|
539
|
+
if (node.location !== undefined) {
|
|
540
|
+
result.location = node.location;
|
|
541
|
+
}
|
|
542
|
+
return { TypeCast: result };
|
|
543
|
+
}
|
|
544
|
+
CollateClause(node, context) {
|
|
545
|
+
return { CollateClause: node };
|
|
546
|
+
}
|
|
547
|
+
BooleanTest(node, context) {
|
|
548
|
+
return { BooleanTest: node };
|
|
549
|
+
}
|
|
550
|
+
NullTest(node, context) {
|
|
551
|
+
return { NullTest: node };
|
|
552
|
+
}
|
|
553
|
+
String(node, context) {
|
|
554
|
+
return { String: node };
|
|
555
|
+
}
|
|
556
|
+
Integer(node, context) {
|
|
557
|
+
return { Integer: node };
|
|
558
|
+
}
|
|
559
|
+
Float(node, context) {
|
|
560
|
+
return { Float: node };
|
|
561
|
+
}
|
|
562
|
+
Boolean(node, context) {
|
|
563
|
+
return { Boolean: node };
|
|
564
|
+
}
|
|
565
|
+
BitString(node, context) {
|
|
566
|
+
return { BitString: node };
|
|
567
|
+
}
|
|
568
|
+
// NOTE: there is no Null type in PG17
|
|
569
|
+
Null(node, context) {
|
|
570
|
+
return { Null: node };
|
|
571
|
+
}
|
|
572
|
+
List(node, context) {
|
|
573
|
+
const result = {};
|
|
574
|
+
if (node.items !== undefined) {
|
|
575
|
+
result.items = Array.isArray(node.items)
|
|
576
|
+
? node.items.map(item => this.transform(item, context))
|
|
577
|
+
: this.transform(node.items, context);
|
|
578
|
+
}
|
|
579
|
+
return { List: result };
|
|
580
|
+
}
|
|
581
|
+
CreateStmt(node, context) {
|
|
582
|
+
const result = {};
|
|
583
|
+
if (node.relation !== undefined) {
|
|
584
|
+
result.relation = this.transform(node.relation, context);
|
|
585
|
+
}
|
|
586
|
+
if (node.tableElts !== undefined) {
|
|
587
|
+
result.tableElts = Array.isArray(node.tableElts)
|
|
588
|
+
? node.tableElts.map(item => this.transform(item, context))
|
|
589
|
+
: this.transform(node.tableElts, context);
|
|
590
|
+
}
|
|
591
|
+
if (node.inhRelations !== undefined) {
|
|
592
|
+
result.inhRelations = Array.isArray(node.inhRelations)
|
|
593
|
+
? node.inhRelations.map(item => this.transform(item, context))
|
|
594
|
+
: this.transform(node.inhRelations, context);
|
|
595
|
+
}
|
|
596
|
+
if (node.partbound !== undefined) {
|
|
597
|
+
result.partbound = this.transform(node.partbound, context);
|
|
598
|
+
}
|
|
599
|
+
if (node.partspec !== undefined) {
|
|
600
|
+
result.partspec = this.transform(node.partspec, context);
|
|
601
|
+
}
|
|
602
|
+
if (node.ofTypename !== undefined) {
|
|
603
|
+
result.ofTypename = this.transform(node.ofTypename, context);
|
|
604
|
+
}
|
|
605
|
+
if (node.constraints !== undefined) {
|
|
606
|
+
result.constraints = Array.isArray(node.constraints)
|
|
607
|
+
? node.constraints.map(item => this.transform(item, context))
|
|
608
|
+
: this.transform(node.constraints, context);
|
|
609
|
+
}
|
|
610
|
+
if (node.options !== undefined) {
|
|
611
|
+
result.options = Array.isArray(node.options)
|
|
612
|
+
? node.options.map(item => this.transform(item, context))
|
|
613
|
+
: this.transform(node.options, context);
|
|
614
|
+
}
|
|
615
|
+
if (node.oncommit !== undefined) {
|
|
616
|
+
result.oncommit = node.oncommit;
|
|
617
|
+
}
|
|
618
|
+
if (node.tablespacename !== undefined) {
|
|
619
|
+
result.tablespacename = node.tablespacename;
|
|
620
|
+
}
|
|
621
|
+
if (node.accessMethod !== undefined) {
|
|
622
|
+
result.accessMethod = node.accessMethod;
|
|
623
|
+
}
|
|
624
|
+
if (node.if_not_exists !== undefined) {
|
|
625
|
+
result.if_not_exists = node.if_not_exists;
|
|
626
|
+
}
|
|
627
|
+
return { CreateStmt: result };
|
|
628
|
+
}
|
|
629
|
+
ColumnDef(node, context) {
|
|
630
|
+
const result = {};
|
|
631
|
+
if (node.colname !== undefined) {
|
|
632
|
+
result.colname = node.colname;
|
|
633
|
+
}
|
|
634
|
+
if (node.typeName !== undefined) {
|
|
635
|
+
const transformedTypeName = this.TypeName(node.typeName, context);
|
|
636
|
+
result.typeName = transformedTypeName.TypeName;
|
|
637
|
+
}
|
|
638
|
+
if (node.inhcount !== undefined) {
|
|
639
|
+
result.inhcount = node.inhcount;
|
|
640
|
+
}
|
|
641
|
+
if (node.is_local !== undefined) {
|
|
642
|
+
result.is_local = node.is_local;
|
|
643
|
+
}
|
|
644
|
+
if (node.is_not_null !== undefined) {
|
|
645
|
+
result.is_not_null = node.is_not_null;
|
|
646
|
+
}
|
|
647
|
+
if (node.is_from_type !== undefined) {
|
|
648
|
+
result.is_from_type = node.is_from_type;
|
|
649
|
+
}
|
|
650
|
+
if (node.storage !== undefined) {
|
|
651
|
+
result.storage = node.storage;
|
|
652
|
+
}
|
|
653
|
+
if (node.raw_default !== undefined) {
|
|
654
|
+
result.raw_default = this.transform(node.raw_default, context);
|
|
655
|
+
}
|
|
656
|
+
if (node.cooked_default !== undefined) {
|
|
657
|
+
result.cooked_default = this.transform(node.cooked_default, context);
|
|
658
|
+
}
|
|
659
|
+
if (node.identity !== undefined) {
|
|
660
|
+
result.identity = node.identity;
|
|
661
|
+
}
|
|
662
|
+
if (node.identitySequence !== undefined) {
|
|
663
|
+
result.identitySequence = this.transform(node.identitySequence, context);
|
|
664
|
+
}
|
|
665
|
+
if (node.generated !== undefined) {
|
|
666
|
+
result.generated = node.generated;
|
|
667
|
+
}
|
|
668
|
+
if (node.collClause !== undefined) {
|
|
669
|
+
result.collClause = this.transform(node.collClause, context);
|
|
670
|
+
}
|
|
671
|
+
if (node.collOid !== undefined) {
|
|
672
|
+
result.collOid = node.collOid;
|
|
673
|
+
}
|
|
674
|
+
if (node.constraints !== undefined) {
|
|
675
|
+
result.constraints = Array.isArray(node.constraints)
|
|
676
|
+
? node.constraints.map(item => this.transform(item, context))
|
|
677
|
+
: this.transform(node.constraints, context);
|
|
678
|
+
}
|
|
679
|
+
if (node.fdwoptions !== undefined) {
|
|
680
|
+
result.fdwoptions = Array.isArray(node.fdwoptions)
|
|
681
|
+
? node.fdwoptions.map(item => this.transform(item, context))
|
|
682
|
+
: this.transform(node.fdwoptions, context);
|
|
683
|
+
}
|
|
684
|
+
if (node.location !== undefined) {
|
|
685
|
+
result.location = node.location;
|
|
686
|
+
}
|
|
687
|
+
return { ColumnDef: result };
|
|
688
|
+
}
|
|
689
|
+
Constraint(node, context) {
|
|
690
|
+
return { Constraint: node };
|
|
691
|
+
}
|
|
692
|
+
SubLink(node, context) {
|
|
693
|
+
return { SubLink: node };
|
|
694
|
+
}
|
|
695
|
+
CaseWhen(node, context) {
|
|
696
|
+
return { CaseWhen: node };
|
|
697
|
+
}
|
|
698
|
+
WindowDef(node, context) {
|
|
699
|
+
return { WindowDef: node };
|
|
700
|
+
}
|
|
701
|
+
SortBy(node, context) {
|
|
702
|
+
return { SortBy: node };
|
|
703
|
+
}
|
|
704
|
+
GroupingSet(node, context) {
|
|
705
|
+
return { GroupingSet: node };
|
|
706
|
+
}
|
|
707
|
+
CommonTableExpr(node, context) {
|
|
708
|
+
const result = {};
|
|
709
|
+
if (node.ctename !== undefined) {
|
|
710
|
+
result.ctename = node.ctename;
|
|
711
|
+
}
|
|
712
|
+
if (node.aliascolnames !== undefined) {
|
|
713
|
+
result.aliascolnames = Array.isArray(node.aliascolnames)
|
|
714
|
+
? node.aliascolnames.map(item => this.transform(item, context))
|
|
715
|
+
: this.transform(node.aliascolnames, context);
|
|
716
|
+
}
|
|
717
|
+
if (node.ctematerialized !== undefined) {
|
|
718
|
+
result.ctematerialized = node.ctematerialized;
|
|
719
|
+
}
|
|
720
|
+
if (node.ctequery !== undefined) {
|
|
721
|
+
result.ctequery = this.transform(node.ctequery, context);
|
|
722
|
+
}
|
|
723
|
+
if (node.search_clause !== undefined) {
|
|
724
|
+
result.search_clause = this.transform(node.search_clause, context);
|
|
725
|
+
}
|
|
726
|
+
if (node.cycle_clause !== undefined) {
|
|
727
|
+
result.cycle_clause = this.transform(node.cycle_clause, context);
|
|
728
|
+
}
|
|
729
|
+
if (node.location !== undefined) {
|
|
730
|
+
result.location = node.location;
|
|
731
|
+
}
|
|
732
|
+
return { CommonTableExpr: result };
|
|
733
|
+
}
|
|
734
|
+
ParamRef(node, context) {
|
|
735
|
+
return { ParamRef: node };
|
|
736
|
+
}
|
|
737
|
+
LockingClause(node, context) {
|
|
738
|
+
return { LockingClause: node };
|
|
739
|
+
}
|
|
740
|
+
MinMaxExpr(node, context) {
|
|
741
|
+
return { MinMaxExpr: node };
|
|
742
|
+
}
|
|
743
|
+
RowExpr(node, context) {
|
|
744
|
+
return { RowExpr: node };
|
|
745
|
+
}
|
|
746
|
+
OpExpr(node, context) {
|
|
747
|
+
return { OpExpr: node };
|
|
748
|
+
}
|
|
749
|
+
DistinctExpr(node, context) {
|
|
750
|
+
return { DistinctExpr: node };
|
|
751
|
+
}
|
|
752
|
+
NullIfExpr(node, context) {
|
|
753
|
+
return { NullIfExpr: node };
|
|
754
|
+
}
|
|
755
|
+
ScalarArrayOpExpr(node, context) {
|
|
756
|
+
return { ScalarArrayOpExpr: node };
|
|
757
|
+
}
|
|
758
|
+
Aggref(node, context) {
|
|
759
|
+
return { Aggref: node };
|
|
760
|
+
}
|
|
761
|
+
WindowFunc(node, context) {
|
|
762
|
+
return { WindowFunc: node };
|
|
763
|
+
}
|
|
764
|
+
FieldSelect(node, context) {
|
|
765
|
+
return { FieldSelect: node };
|
|
766
|
+
}
|
|
767
|
+
RelabelType(node, context) {
|
|
768
|
+
return { RelabelType: node };
|
|
769
|
+
}
|
|
770
|
+
CoerceViaIO(node, context) {
|
|
771
|
+
return { CoerceViaIO: node };
|
|
772
|
+
}
|
|
773
|
+
ArrayCoerceExpr(node, context) {
|
|
774
|
+
return { ArrayCoerceExpr: node };
|
|
775
|
+
}
|
|
776
|
+
ConvertRowtypeExpr(node, context) {
|
|
777
|
+
return { ConvertRowtypeExpr: node };
|
|
778
|
+
}
|
|
779
|
+
NamedArgExpr(node, context) {
|
|
780
|
+
return { NamedArgExpr: node };
|
|
781
|
+
}
|
|
782
|
+
ViewStmt(node, context) {
|
|
783
|
+
return { ViewStmt: node };
|
|
784
|
+
}
|
|
785
|
+
IndexStmt(node, context) {
|
|
786
|
+
return { IndexStmt: node };
|
|
787
|
+
}
|
|
788
|
+
IndexElem(node, context) {
|
|
789
|
+
return { IndexElem: node };
|
|
790
|
+
}
|
|
791
|
+
PartitionElem(node, context) {
|
|
792
|
+
return { PartitionElem: node };
|
|
793
|
+
}
|
|
794
|
+
PartitionCmd(node, context) {
|
|
795
|
+
return { PartitionCmd: node };
|
|
796
|
+
}
|
|
797
|
+
JoinExpr(node, context) {
|
|
798
|
+
return { JoinExpr: node };
|
|
799
|
+
}
|
|
800
|
+
FromExpr(node, context) {
|
|
801
|
+
return { FromExpr: node };
|
|
802
|
+
}
|
|
803
|
+
TransactionStmt(node, context) {
|
|
804
|
+
return { TransactionStmt: node };
|
|
805
|
+
}
|
|
806
|
+
VariableSetStmt(node, context) {
|
|
807
|
+
return { VariableSetStmt: node };
|
|
808
|
+
}
|
|
809
|
+
VariableShowStmt(node, context) {
|
|
810
|
+
return { VariableShowStmt: node };
|
|
811
|
+
}
|
|
812
|
+
CreateSchemaStmt(node, context) {
|
|
813
|
+
return { CreateSchemaStmt: node };
|
|
814
|
+
}
|
|
815
|
+
RoleSpec(node, context) {
|
|
816
|
+
return { RoleSpec: node };
|
|
817
|
+
}
|
|
818
|
+
DropStmt(node, context) {
|
|
819
|
+
return { DropStmt: node };
|
|
820
|
+
}
|
|
821
|
+
TruncateStmt(node, context) {
|
|
822
|
+
return { TruncateStmt: node };
|
|
823
|
+
}
|
|
824
|
+
ReturnStmt(node, context) {
|
|
825
|
+
return { ReturnStmt: node };
|
|
826
|
+
}
|
|
827
|
+
PLAssignStmt(node, context) {
|
|
828
|
+
return { PLAssignStmt: node };
|
|
829
|
+
}
|
|
830
|
+
CopyStmt(node, context) {
|
|
831
|
+
return { CopyStmt: node };
|
|
832
|
+
}
|
|
833
|
+
AlterTableStmt(node, context) {
|
|
834
|
+
return { AlterTableStmt: node };
|
|
835
|
+
}
|
|
836
|
+
AlterTableCmd(node, context) {
|
|
837
|
+
return { AlterTableCmd: node };
|
|
838
|
+
}
|
|
839
|
+
CreateFunctionStmt(node, context) {
|
|
840
|
+
return { CreateFunctionStmt: node };
|
|
841
|
+
}
|
|
842
|
+
FunctionParameter(node, context) {
|
|
843
|
+
return { FunctionParameter: node };
|
|
844
|
+
}
|
|
845
|
+
CreateEnumStmt(node, context) {
|
|
846
|
+
return { CreateEnumStmt: node };
|
|
847
|
+
}
|
|
848
|
+
CreateDomainStmt(node, context) {
|
|
849
|
+
const result = {};
|
|
850
|
+
if (node.domainname !== undefined) {
|
|
851
|
+
result.domainname = Array.isArray(node.domainname)
|
|
852
|
+
? node.domainname.map(item => this.transform(item, context))
|
|
853
|
+
: this.transform(node.domainname, context);
|
|
854
|
+
}
|
|
855
|
+
if (node.typeName !== undefined) {
|
|
856
|
+
const transformedTypeName = this.TypeName(node.typeName, context);
|
|
857
|
+
result.typeName = transformedTypeName.TypeName;
|
|
858
|
+
}
|
|
859
|
+
if (node.collClause !== undefined) {
|
|
860
|
+
result.collClause = this.transform(node.collClause, context);
|
|
861
|
+
}
|
|
862
|
+
if (node.constraints !== undefined) {
|
|
863
|
+
result.constraints = Array.isArray(node.constraints)
|
|
864
|
+
? node.constraints.map(item => this.transform(item, context))
|
|
865
|
+
: this.transform(node.constraints, context);
|
|
866
|
+
}
|
|
867
|
+
return { CreateDomainStmt: result };
|
|
868
|
+
}
|
|
869
|
+
CreateRoleStmt(node, context) {
|
|
870
|
+
return { CreateRoleStmt: node };
|
|
871
|
+
}
|
|
872
|
+
DefElem(node, context) {
|
|
873
|
+
return { DefElem: node };
|
|
874
|
+
}
|
|
875
|
+
CreateTableSpaceStmt(node, context) {
|
|
876
|
+
return { CreateTableSpaceStmt: node };
|
|
877
|
+
}
|
|
878
|
+
DropTableSpaceStmt(node, context) {
|
|
879
|
+
return { DropTableSpaceStmt: node };
|
|
880
|
+
}
|
|
881
|
+
AlterTableSpaceOptionsStmt(node, context) {
|
|
882
|
+
return { AlterTableSpaceOptionsStmt: node };
|
|
883
|
+
}
|
|
884
|
+
CreateExtensionStmt(node, context) {
|
|
885
|
+
return { CreateExtensionStmt: node };
|
|
886
|
+
}
|
|
887
|
+
AlterExtensionStmt(node, context) {
|
|
888
|
+
return { AlterExtensionStmt: node };
|
|
889
|
+
}
|
|
890
|
+
CreateFdwStmt(node, context) {
|
|
891
|
+
return { CreateFdwStmt: node };
|
|
892
|
+
}
|
|
893
|
+
SetOperationStmt(node, context) {
|
|
894
|
+
return { SetOperationStmt: node };
|
|
895
|
+
}
|
|
896
|
+
ReplicaIdentityStmt(node, context) {
|
|
897
|
+
return { ReplicaIdentityStmt: node };
|
|
898
|
+
}
|
|
899
|
+
AlterCollationStmt(node, context) {
|
|
900
|
+
return { AlterCollationStmt: node };
|
|
901
|
+
}
|
|
902
|
+
AlterDomainStmt(node, context) {
|
|
903
|
+
return { AlterDomainStmt: node };
|
|
904
|
+
}
|
|
905
|
+
PrepareStmt(node, context) {
|
|
906
|
+
return { PrepareStmt: node };
|
|
907
|
+
}
|
|
908
|
+
ExecuteStmt(node, context) {
|
|
909
|
+
return { ExecuteStmt: node };
|
|
910
|
+
}
|
|
911
|
+
DeallocateStmt(node, context) {
|
|
912
|
+
const result = {};
|
|
913
|
+
if (node.name !== undefined) {
|
|
914
|
+
result.name = node.name;
|
|
915
|
+
}
|
|
916
|
+
if (node.name === undefined || node.name === null) {
|
|
917
|
+
result.isall = true;
|
|
918
|
+
}
|
|
919
|
+
return { DeallocateStmt: result };
|
|
920
|
+
}
|
|
921
|
+
NotifyStmt(node, context) {
|
|
922
|
+
return { NotifyStmt: node };
|
|
923
|
+
}
|
|
924
|
+
ListenStmt(node, context) {
|
|
925
|
+
return { ListenStmt: node };
|
|
926
|
+
}
|
|
927
|
+
UnlistenStmt(node, context) {
|
|
928
|
+
return { UnlistenStmt: node };
|
|
929
|
+
}
|
|
930
|
+
CheckPointStmt(node, context) {
|
|
931
|
+
return { CheckPointStmt: node };
|
|
932
|
+
}
|
|
933
|
+
LoadStmt(node, context) {
|
|
934
|
+
return { LoadStmt: node };
|
|
935
|
+
}
|
|
936
|
+
DiscardStmt(node, context) {
|
|
937
|
+
return { DiscardStmt: node };
|
|
938
|
+
}
|
|
939
|
+
CommentStmt(node, context) {
|
|
940
|
+
return { CommentStmt: node };
|
|
941
|
+
}
|
|
942
|
+
LockStmt(node, context) {
|
|
943
|
+
return { LockStmt: node };
|
|
944
|
+
}
|
|
945
|
+
CreatePolicyStmt(node, context) {
|
|
946
|
+
return { CreatePolicyStmt: node };
|
|
947
|
+
}
|
|
948
|
+
AlterPolicyStmt(node, context) {
|
|
949
|
+
return { AlterPolicyStmt: node };
|
|
950
|
+
}
|
|
951
|
+
CreateUserMappingStmt(node, context) {
|
|
952
|
+
return { CreateUserMappingStmt: node };
|
|
953
|
+
}
|
|
954
|
+
CreateStatsStmt(node, context) {
|
|
955
|
+
return { CreateStatsStmt: node };
|
|
956
|
+
}
|
|
957
|
+
StatsElem(node, context) {
|
|
958
|
+
return { StatsElem: node };
|
|
959
|
+
}
|
|
960
|
+
CreatePublicationStmt(node, context) {
|
|
961
|
+
return { CreatePublicationStmt: node };
|
|
962
|
+
}
|
|
963
|
+
CreateSubscriptionStmt(node, context) {
|
|
964
|
+
return { CreateSubscriptionStmt: node };
|
|
965
|
+
}
|
|
966
|
+
AlterPublicationStmt(node, context) {
|
|
967
|
+
return { AlterPublicationStmt: node };
|
|
968
|
+
}
|
|
969
|
+
AlterSubscriptionStmt(node, context) {
|
|
970
|
+
return { AlterSubscriptionStmt: node };
|
|
971
|
+
}
|
|
972
|
+
DropSubscriptionStmt(node, context) {
|
|
973
|
+
return { DropSubscriptionStmt: node };
|
|
974
|
+
}
|
|
975
|
+
DoStmt(node, context) {
|
|
976
|
+
return { DoStmt: node };
|
|
977
|
+
}
|
|
978
|
+
InlineCodeBlock(node, context) {
|
|
979
|
+
return { InlineCodeBlock: node };
|
|
980
|
+
}
|
|
981
|
+
CallContext(node, context) {
|
|
982
|
+
return { CallContext: node };
|
|
983
|
+
}
|
|
984
|
+
ConstraintsSetStmt(node, context) {
|
|
985
|
+
return { ConstraintsSetStmt: node };
|
|
986
|
+
}
|
|
987
|
+
AlterSystemStmt(node, context) {
|
|
988
|
+
return { AlterSystemStmt: node };
|
|
989
|
+
}
|
|
990
|
+
VacuumRelation(node, context) {
|
|
991
|
+
return { VacuumRelation: node };
|
|
992
|
+
}
|
|
993
|
+
DropOwnedStmt(node, context) {
|
|
994
|
+
return { DropOwnedStmt: node };
|
|
995
|
+
}
|
|
996
|
+
ReassignOwnedStmt(node, context) {
|
|
997
|
+
return { ReassignOwnedStmt: node };
|
|
998
|
+
}
|
|
999
|
+
AlterTSDictionaryStmt(node, context) {
|
|
1000
|
+
return { AlterTSDictionaryStmt: node };
|
|
1001
|
+
}
|
|
1002
|
+
AlterTSConfigurationStmt(node, context) {
|
|
1003
|
+
return { AlterTSConfigurationStmt: node };
|
|
1004
|
+
}
|
|
1005
|
+
ClosePortalStmt(node, context) {
|
|
1006
|
+
return { ClosePortalStmt: node };
|
|
1007
|
+
}
|
|
1008
|
+
FetchStmt(node, context) {
|
|
1009
|
+
return { FetchStmt: node };
|
|
1010
|
+
}
|
|
1011
|
+
AlterStatsStmt(node, context) {
|
|
1012
|
+
return { AlterStatsStmt: node };
|
|
1013
|
+
}
|
|
1014
|
+
ObjectWithArgs(node, context) {
|
|
1015
|
+
return { ObjectWithArgs: node };
|
|
1016
|
+
}
|
|
1017
|
+
AlterOperatorStmt(node, context) {
|
|
1018
|
+
return { AlterOperatorStmt: node };
|
|
1019
|
+
}
|
|
1020
|
+
AlterFdwStmt(node, context) {
|
|
1021
|
+
return { AlterFdwStmt: node };
|
|
1022
|
+
}
|
|
1023
|
+
CreateForeignServerStmt(node, context) {
|
|
1024
|
+
return { CreateForeignServerStmt: node };
|
|
1025
|
+
}
|
|
1026
|
+
AlterForeignServerStmt(node, context) {
|
|
1027
|
+
return { AlterForeignServerStmt: node };
|
|
1028
|
+
}
|
|
1029
|
+
AlterUserMappingStmt(node, context) {
|
|
1030
|
+
return { AlterUserMappingStmt: node };
|
|
1031
|
+
}
|
|
1032
|
+
DropUserMappingStmt(node, context) {
|
|
1033
|
+
return { DropUserMappingStmt: node };
|
|
1034
|
+
}
|
|
1035
|
+
ImportForeignSchemaStmt(node, context) {
|
|
1036
|
+
return { ImportForeignSchemaStmt: node };
|
|
1037
|
+
}
|
|
1038
|
+
ClusterStmt(node, context) {
|
|
1039
|
+
return { ClusterStmt: node };
|
|
1040
|
+
}
|
|
1041
|
+
VacuumStmt(node, context) {
|
|
1042
|
+
return { VacuumStmt: node };
|
|
1043
|
+
}
|
|
1044
|
+
ExplainStmt(node, context) {
|
|
1045
|
+
return { ExplainStmt: node };
|
|
1046
|
+
}
|
|
1047
|
+
ReindexStmt(node, context) {
|
|
1048
|
+
return { ReindexStmt: node };
|
|
1049
|
+
}
|
|
1050
|
+
CallStmt(node, context) {
|
|
1051
|
+
return { CallStmt: node };
|
|
1052
|
+
}
|
|
1053
|
+
CreatedbStmt(node, context) {
|
|
1054
|
+
return { CreatedbStmt: node };
|
|
1055
|
+
}
|
|
1056
|
+
DropdbStmt(node, context) {
|
|
1057
|
+
return { DropdbStmt: node };
|
|
1058
|
+
}
|
|
1059
|
+
RenameStmt(node, context) {
|
|
1060
|
+
return { RenameStmt: node };
|
|
1061
|
+
}
|
|
1062
|
+
AlterOwnerStmt(node, context) {
|
|
1063
|
+
return { AlterOwnerStmt: node };
|
|
1064
|
+
}
|
|
1065
|
+
GrantStmt(node, context) {
|
|
1066
|
+
return { GrantStmt: node };
|
|
1067
|
+
}
|
|
1068
|
+
GrantRoleStmt(node, context) {
|
|
1069
|
+
return { GrantRoleStmt: node };
|
|
1070
|
+
}
|
|
1071
|
+
SecLabelStmt(node, context) {
|
|
1072
|
+
return { SecLabelStmt: node };
|
|
1073
|
+
}
|
|
1074
|
+
AlterDefaultPrivilegesStmt(node, context) {
|
|
1075
|
+
return { AlterDefaultPrivilegesStmt: node };
|
|
1076
|
+
}
|
|
1077
|
+
CreateConversionStmt(node, context) {
|
|
1078
|
+
return { CreateConversionStmt: node };
|
|
1079
|
+
}
|
|
1080
|
+
CreateCastStmt(node, context) {
|
|
1081
|
+
return { CreateCastStmt: node };
|
|
1082
|
+
}
|
|
1083
|
+
CreatePLangStmt(node, context) {
|
|
1084
|
+
return { CreatePLangStmt: node };
|
|
1085
|
+
}
|
|
1086
|
+
CreateTransformStmt(node, context) {
|
|
1087
|
+
return { CreateTransformStmt: node };
|
|
1088
|
+
}
|
|
1089
|
+
CreateTrigStmt(node, context) {
|
|
1090
|
+
return { CreateTrigStmt: node };
|
|
1091
|
+
}
|
|
1092
|
+
TriggerTransition(node, context) {
|
|
1093
|
+
return { TriggerTransition: node };
|
|
1094
|
+
}
|
|
1095
|
+
CreateEventTrigStmt(node, context) {
|
|
1096
|
+
return { CreateEventTrigStmt: node };
|
|
1097
|
+
}
|
|
1098
|
+
AlterEventTrigStmt(node, context) {
|
|
1099
|
+
return { AlterEventTrigStmt: node };
|
|
1100
|
+
}
|
|
1101
|
+
CreateOpClassStmt(node, context) {
|
|
1102
|
+
return { CreateOpClassStmt: node };
|
|
1103
|
+
}
|
|
1104
|
+
CreateOpFamilyStmt(node, context) {
|
|
1105
|
+
return { CreateOpFamilyStmt: node };
|
|
1106
|
+
}
|
|
1107
|
+
AlterOpFamilyStmt(node, context) {
|
|
1108
|
+
return { AlterOpFamilyStmt: node };
|
|
1109
|
+
}
|
|
1110
|
+
MergeStmt(node, context) {
|
|
1111
|
+
return { MergeStmt: node };
|
|
1112
|
+
}
|
|
1113
|
+
AlterTableMoveAllStmt(node, context) {
|
|
1114
|
+
return { AlterTableMoveAllStmt: node };
|
|
1115
|
+
}
|
|
1116
|
+
CreateSeqStmt(node, context) {
|
|
1117
|
+
return { CreateSeqStmt: node };
|
|
1118
|
+
}
|
|
1119
|
+
AlterSeqStmt(node, context) {
|
|
1120
|
+
return { AlterSeqStmt: node };
|
|
1121
|
+
}
|
|
1122
|
+
CompositeTypeStmt(node, context) {
|
|
1123
|
+
const result = {};
|
|
1124
|
+
if (node.typevar !== undefined) {
|
|
1125
|
+
result.typevar = this.transform(node.typevar, context);
|
|
1126
|
+
}
|
|
1127
|
+
if (node.coldeflist !== undefined) {
|
|
1128
|
+
result.coldeflist = Array.isArray(node.coldeflist)
|
|
1129
|
+
? node.coldeflist.map(item => this.transform(item, context))
|
|
1130
|
+
: this.transform(node.coldeflist, context);
|
|
1131
|
+
}
|
|
1132
|
+
return { CompositeTypeStmt: result };
|
|
1133
|
+
}
|
|
1134
|
+
CreateRangeStmt(node, context) {
|
|
1135
|
+
return { CreateRangeStmt: node };
|
|
1136
|
+
}
|
|
1137
|
+
AlterEnumStmt(node, context) {
|
|
1138
|
+
return { AlterEnumStmt: node };
|
|
1139
|
+
}
|
|
1140
|
+
AlterTypeStmt(node, context) {
|
|
1141
|
+
return { AlterTypeStmt: node };
|
|
1142
|
+
}
|
|
1143
|
+
AlterRoleStmt(node, context) {
|
|
1144
|
+
return { AlterRoleStmt: node };
|
|
1145
|
+
}
|
|
1146
|
+
DropRoleStmt(node, context) {
|
|
1147
|
+
return { DropRoleStmt: node };
|
|
1148
|
+
}
|
|
1149
|
+
// NOTE PG 17 has a no CreateAggregateStmt?
|
|
1150
|
+
// In PostgreSQL 17, the CreateAggregateStmt has been removed from the backend parser infrastructure and replaced by CreateFunctionStmt with a kind = OBJECT_AGGREGATE variant.
|
|
1151
|
+
CreateAggregateStmt(node, context) {
|
|
1152
|
+
return { CreateAggregateStmt: node };
|
|
1153
|
+
}
|
|
1154
|
+
CreateTableAsStmt(node, context) {
|
|
1155
|
+
return { CreateTableAsStmt: node };
|
|
1156
|
+
}
|
|
1157
|
+
RefreshMatViewStmt(node, context) {
|
|
1158
|
+
return { RefreshMatViewStmt: node };
|
|
1159
|
+
}
|
|
1160
|
+
AccessPriv(node, context) {
|
|
1161
|
+
return { AccessPriv: node };
|
|
1162
|
+
}
|
|
1163
|
+
DefineStmt(node, context) {
|
|
1164
|
+
return { DefineStmt: node };
|
|
1165
|
+
}
|
|
1166
|
+
AlterDatabaseStmt(node, context) {
|
|
1167
|
+
return { AlterDatabaseStmt: node };
|
|
1168
|
+
}
|
|
1169
|
+
AlterDatabaseRefreshCollStmt(node, context) {
|
|
1170
|
+
return { AlterDatabaseRefreshCollStmt: node };
|
|
1171
|
+
}
|
|
1172
|
+
AlterDatabaseSetStmt(node, context) {
|
|
1173
|
+
return { AlterDatabaseSetStmt: node };
|
|
1174
|
+
}
|
|
1175
|
+
DeclareCursorStmt(node, context) {
|
|
1176
|
+
return { DeclareCursorStmt: node };
|
|
1177
|
+
}
|
|
1178
|
+
PublicationObjSpec(node, context) {
|
|
1179
|
+
return { PublicationObjSpec: node };
|
|
1180
|
+
}
|
|
1181
|
+
PublicationTable(node, context) {
|
|
1182
|
+
return { PublicationTable: node };
|
|
1183
|
+
}
|
|
1184
|
+
CreateAmStmt(node, context) {
|
|
1185
|
+
return { CreateAmStmt: node };
|
|
1186
|
+
}
|
|
1187
|
+
IntoClause(node, context) {
|
|
1188
|
+
return { IntoClause: node };
|
|
1189
|
+
}
|
|
1190
|
+
OnConflictExpr(node, context) {
|
|
1191
|
+
return { OnConflictExpr: node };
|
|
1192
|
+
}
|
|
1193
|
+
ScanToken(node, context) {
|
|
1194
|
+
return { ScanToken: node };
|
|
1195
|
+
}
|
|
1196
|
+
CreateOpClassItem(node, context) {
|
|
1197
|
+
return { CreateOpClassItem: node };
|
|
1198
|
+
}
|
|
1199
|
+
Var(node, context) {
|
|
1200
|
+
return { Var: node };
|
|
1201
|
+
}
|
|
1202
|
+
TableFunc(node, context) {
|
|
1203
|
+
return { TableFunc: node };
|
|
1204
|
+
}
|
|
1205
|
+
RangeTableFunc(node, context) {
|
|
1206
|
+
return { RangeTableFunc: node };
|
|
1207
|
+
}
|
|
1208
|
+
RangeTableFuncCol(node, context) {
|
|
1209
|
+
return { RangeTableFuncCol: node };
|
|
1210
|
+
}
|
|
1211
|
+
JsonArrayQueryConstructor(node, context) {
|
|
1212
|
+
return { JsonArrayQueryConstructor: node };
|
|
1213
|
+
}
|
|
1214
|
+
RangeFunction(node, context) {
|
|
1215
|
+
const result = {};
|
|
1216
|
+
if (node.lateral !== undefined) {
|
|
1217
|
+
result.lateral = node.lateral;
|
|
1218
|
+
}
|
|
1219
|
+
if (node.ordinality !== undefined) {
|
|
1220
|
+
result.ordinality = node.ordinality;
|
|
1221
|
+
}
|
|
1222
|
+
if (node.is_rowsfrom !== undefined) {
|
|
1223
|
+
result.is_rowsfrom = node.is_rowsfrom;
|
|
1224
|
+
}
|
|
1225
|
+
if (node.functions !== undefined) {
|
|
1226
|
+
result.functions = Array.isArray(node.functions)
|
|
1227
|
+
? node.functions.map(item => this.transform(item, context))
|
|
1228
|
+
: this.transform(node.functions, context);
|
|
1229
|
+
}
|
|
1230
|
+
if (node.alias !== undefined) {
|
|
1231
|
+
result.alias = this.transform(node.alias, context);
|
|
1232
|
+
}
|
|
1233
|
+
if (node.coldeflist !== undefined) {
|
|
1234
|
+
result.coldeflist = Array.isArray(node.coldeflist)
|
|
1235
|
+
? node.coldeflist.map(item => this.transform(item, context))
|
|
1236
|
+
: this.transform(node.coldeflist, context);
|
|
1237
|
+
}
|
|
1238
|
+
return { RangeFunction: result };
|
|
1239
|
+
}
|
|
1240
|
+
XmlSerialize(node, context) {
|
|
1241
|
+
const result = {};
|
|
1242
|
+
if (node.xmloption !== undefined) {
|
|
1243
|
+
result.xmloption = node.xmloption;
|
|
1244
|
+
}
|
|
1245
|
+
if (node.expr !== undefined) {
|
|
1246
|
+
result.expr = this.transform(node.expr, context);
|
|
1247
|
+
}
|
|
1248
|
+
if (node.typeName !== undefined) {
|
|
1249
|
+
result.typeName = this.transform(node.typeName, context);
|
|
1250
|
+
}
|
|
1251
|
+
if (node.location !== undefined) {
|
|
1252
|
+
result.location = node.location;
|
|
1253
|
+
}
|
|
1254
|
+
return { XmlSerialize: result };
|
|
1255
|
+
}
|
|
1256
|
+
RuleStmt(node, context) {
|
|
1257
|
+
return { RuleStmt: node };
|
|
1258
|
+
}
|
|
1259
|
+
GroupingFunc(node, context) {
|
|
1260
|
+
const result = {};
|
|
1261
|
+
if (node.args !== undefined) {
|
|
1262
|
+
result.args = Array.isArray(node.args)
|
|
1263
|
+
? node.args.map((item) => this.transform(item, context))
|
|
1264
|
+
: this.transform(node.args, context);
|
|
1265
|
+
}
|
|
1266
|
+
if (node.refs !== undefined) {
|
|
1267
|
+
result.refs = Array.isArray(node.refs)
|
|
1268
|
+
? node.refs.map((item) => this.transform(item, context))
|
|
1269
|
+
: this.transform(node.refs, context);
|
|
1270
|
+
}
|
|
1271
|
+
if (node.agglevelsup !== undefined) {
|
|
1272
|
+
result.agglevelsup = node.agglevelsup;
|
|
1273
|
+
}
|
|
1274
|
+
if (node.location !== undefined) {
|
|
1275
|
+
result.location = node.location;
|
|
1276
|
+
}
|
|
1277
|
+
return { GroupingFunc: result };
|
|
1278
|
+
}
|
|
1279
|
+
MultiAssignRef(node, context) {
|
|
1280
|
+
const result = {};
|
|
1281
|
+
if (node.source !== undefined) {
|
|
1282
|
+
result.source = this.transform(node.source, context);
|
|
1283
|
+
}
|
|
1284
|
+
if (node.colno !== undefined) {
|
|
1285
|
+
result.colno = node.colno;
|
|
1286
|
+
}
|
|
1287
|
+
if (node.ncolumns !== undefined) {
|
|
1288
|
+
result.ncolumns = node.ncolumns;
|
|
1289
|
+
}
|
|
1290
|
+
return { MultiAssignRef: result };
|
|
1291
|
+
}
|
|
1292
|
+
CurrentOfExpr(node, context) {
|
|
1293
|
+
const result = {};
|
|
1294
|
+
if (node.cursor_name !== undefined) {
|
|
1295
|
+
result.cursor_name = node.cursor_name;
|
|
1296
|
+
}
|
|
1297
|
+
if (node.cursor_param !== undefined) {
|
|
1298
|
+
result.cursor_param = node.cursor_param;
|
|
1299
|
+
}
|
|
1300
|
+
return { CurrentOfExpr: result };
|
|
1301
|
+
}
|
|
1302
|
+
TableLikeClause(node, context) {
|
|
1303
|
+
return { TableLikeClause: node };
|
|
1304
|
+
}
|
|
1305
|
+
AlterFunctionStmt(node, context) {
|
|
1306
|
+
return { AlterFunctionStmt: node };
|
|
1307
|
+
}
|
|
1308
|
+
AlterObjectSchemaStmt(node, context) {
|
|
1309
|
+
return { AlterObjectSchemaStmt: node };
|
|
1310
|
+
}
|
|
1311
|
+
AlterRoleSetStmt(node, context) {
|
|
1312
|
+
const result = {};
|
|
1313
|
+
if (node.role !== undefined) {
|
|
1314
|
+
result.role = this.transform(node.role, context);
|
|
1315
|
+
}
|
|
1316
|
+
if (node.database !== undefined) {
|
|
1317
|
+
result.database = node.database;
|
|
1318
|
+
}
|
|
1319
|
+
if (node.setstmt !== undefined) {
|
|
1320
|
+
result.setstmt = this.transform(node.setstmt, context);
|
|
1321
|
+
}
|
|
1322
|
+
return { AlterRoleSetStmt: result };
|
|
1323
|
+
}
|
|
1324
|
+
CreateForeignTableStmt(node, context) {
|
|
1325
|
+
return { CreateForeignTableStmt: node };
|
|
1326
|
+
}
|
|
1327
|
+
getFuncformatValue(node, funcname, context) {
|
|
1328
|
+
const functionName = this.getFunctionName(node, funcname);
|
|
1329
|
+
if (!functionName) {
|
|
1330
|
+
return 'COERCE_EXPLICIT_CALL';
|
|
1331
|
+
}
|
|
1332
|
+
const hasPgCatalogPrefix = this.hasPgCatalogPrefix(funcname);
|
|
1333
|
+
const sqlSyntaxFunctions = [
|
|
1334
|
+
'trim', 'ltrim', 'rtrim', 'btrim',
|
|
1335
|
+
'position', 'overlay', 'substring',
|
|
1336
|
+
'extract', 'timezone', 'xmlexists',
|
|
1337
|
+
'current_date', 'current_time', 'current_timestamp',
|
|
1338
|
+
'localtime', 'localtimestamp', 'overlaps'
|
|
1339
|
+
];
|
|
1340
|
+
// Handle specific functions that depend on pg_catalog prefix
|
|
1341
|
+
if (functionName.toLowerCase() === 'substring') {
|
|
1342
|
+
if (hasPgCatalogPrefix) {
|
|
1343
|
+
return 'COERCE_SQL_SYNTAX';
|
|
1344
|
+
}
|
|
1345
|
+
return 'COERCE_EXPLICIT_CALL';
|
|
1346
|
+
}
|
|
1347
|
+
if (functionName.toLowerCase() === 'ltrim') {
|
|
1348
|
+
if (hasPgCatalogPrefix) {
|
|
1349
|
+
return 'COERCE_SQL_SYNTAX';
|
|
1350
|
+
}
|
|
1351
|
+
return 'COERCE_EXPLICIT_CALL';
|
|
1352
|
+
}
|
|
1353
|
+
if (functionName.toLowerCase() === 'btrim') {
|
|
1354
|
+
if (hasPgCatalogPrefix) {
|
|
1355
|
+
return 'COERCE_SQL_SYNTAX';
|
|
1356
|
+
}
|
|
1357
|
+
return 'COERCE_EXPLICIT_CALL';
|
|
1358
|
+
}
|
|
1359
|
+
if (functionName.toLowerCase() === 'pg_collation_for') {
|
|
1360
|
+
if (hasPgCatalogPrefix) {
|
|
1361
|
+
return 'COERCE_SQL_SYNTAX';
|
|
1362
|
+
}
|
|
1363
|
+
return 'COERCE_EXPLICIT_CALL';
|
|
1364
|
+
}
|
|
1365
|
+
if (sqlSyntaxFunctions.includes(functionName.toLowerCase())) {
|
|
1366
|
+
return 'COERCE_SQL_SYNTAX';
|
|
1367
|
+
}
|
|
1368
|
+
return 'COERCE_EXPLICIT_CALL';
|
|
1369
|
+
}
|
|
1370
|
+
getFunctionName(node, funcname) {
|
|
1371
|
+
const names = funcname || node?.funcname;
|
|
1372
|
+
if (names && Array.isArray(names) && names.length > 0) {
|
|
1373
|
+
const lastName = names[names.length - 1];
|
|
1374
|
+
if (lastName && typeof lastName === 'object' && 'String' in lastName) {
|
|
1375
|
+
return lastName.String.str || lastName.String.sval;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return null;
|
|
1379
|
+
}
|
|
1380
|
+
hasPgCatalogPrefix(funcname) {
|
|
1381
|
+
if (funcname && Array.isArray(funcname) && funcname.length >= 2) {
|
|
1382
|
+
const firstElement = funcname[0];
|
|
1383
|
+
if (firstElement && typeof firstElement === 'object' && 'String' in firstElement) {
|
|
1384
|
+
const prefix = firstElement.String.str || firstElement.String.sval;
|
|
1385
|
+
return prefix === 'pg_catalog';
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1390
|
+
RangeTableSample(node, context) {
|
|
1391
|
+
const result = {};
|
|
1392
|
+
if (node.relation !== undefined) {
|
|
1393
|
+
result.relation = this.transform(node.relation, context);
|
|
1394
|
+
}
|
|
1395
|
+
if (node.method !== undefined) {
|
|
1396
|
+
result.method = Array.isArray(node.method)
|
|
1397
|
+
? node.method.map(item => this.transform(item, context))
|
|
1398
|
+
: this.transform(node.method, context);
|
|
1399
|
+
}
|
|
1400
|
+
if (node.args !== undefined) {
|
|
1401
|
+
result.args = Array.isArray(node.args)
|
|
1402
|
+
? node.args.map(item => this.transform(item, context))
|
|
1403
|
+
: this.transform(node.args, context);
|
|
1404
|
+
}
|
|
1405
|
+
if (node.repeatable !== undefined) {
|
|
1406
|
+
result.repeatable = this.transform(node.repeatable, context);
|
|
1407
|
+
}
|
|
1408
|
+
if (node.location !== undefined) {
|
|
1409
|
+
result.location = node.location;
|
|
1410
|
+
}
|
|
1411
|
+
return { RangeTableSample: result };
|
|
1412
|
+
}
|
|
1413
|
+
SQLValueFunction(node, context) {
|
|
1414
|
+
const result = {};
|
|
1415
|
+
if (node.op !== undefined) {
|
|
1416
|
+
result.op = node.op;
|
|
1417
|
+
}
|
|
1418
|
+
if (node.type !== undefined) {
|
|
1419
|
+
result.type = node.type;
|
|
1420
|
+
}
|
|
1421
|
+
if (node.typmod !== undefined) {
|
|
1422
|
+
result.typmod = node.typmod;
|
|
1423
|
+
}
|
|
1424
|
+
if (node.location !== undefined) {
|
|
1425
|
+
result.location = node.location;
|
|
1426
|
+
}
|
|
1427
|
+
return { SQLValueFunction: result };
|
|
1428
|
+
}
|
|
1429
|
+
XmlExpr(node, context) {
|
|
1430
|
+
const result = {};
|
|
1431
|
+
if (node.op !== undefined) {
|
|
1432
|
+
result.op = node.op;
|
|
1433
|
+
}
|
|
1434
|
+
if (node.name !== undefined) {
|
|
1435
|
+
result.name = node.name;
|
|
1436
|
+
}
|
|
1437
|
+
if (node.named_args !== undefined) {
|
|
1438
|
+
result.named_args = Array.isArray(node.named_args)
|
|
1439
|
+
? node.named_args.map(item => this.transform(item, context))
|
|
1440
|
+
: this.transform(node.named_args, context);
|
|
1441
|
+
}
|
|
1442
|
+
if (node.arg_names !== undefined) {
|
|
1443
|
+
result.arg_names = Array.isArray(node.arg_names)
|
|
1444
|
+
? node.arg_names.map(item => this.transform(item, context))
|
|
1445
|
+
: this.transform(node.arg_names, context);
|
|
1446
|
+
}
|
|
1447
|
+
if (node.args !== undefined) {
|
|
1448
|
+
result.args = Array.isArray(node.args)
|
|
1449
|
+
? node.args.map(item => this.transform(item, context))
|
|
1450
|
+
: this.transform(node.args, context);
|
|
1451
|
+
}
|
|
1452
|
+
if (node.xmloption !== undefined) {
|
|
1453
|
+
result.xmloption = node.xmloption;
|
|
1454
|
+
}
|
|
1455
|
+
if (node.type !== undefined) {
|
|
1456
|
+
result.type = node.type;
|
|
1457
|
+
}
|
|
1458
|
+
if (node.typmod !== undefined) {
|
|
1459
|
+
result.typmod = node.typmod;
|
|
1460
|
+
}
|
|
1461
|
+
if (node.location !== undefined) {
|
|
1462
|
+
result.location = node.location;
|
|
1463
|
+
}
|
|
1464
|
+
return { XmlExpr: result };
|
|
1465
|
+
}
|
|
1466
|
+
RangeSubselect(node, context) {
|
|
1467
|
+
const result = {};
|
|
1468
|
+
if (node.lateral !== undefined) {
|
|
1469
|
+
result.lateral = node.lateral;
|
|
1470
|
+
}
|
|
1471
|
+
if (node.subquery !== undefined) {
|
|
1472
|
+
result.subquery = this.transform(node.subquery, context);
|
|
1473
|
+
}
|
|
1474
|
+
if (node.alias !== undefined) {
|
|
1475
|
+
result.alias = this.transform(node.alias, context);
|
|
1476
|
+
}
|
|
1477
|
+
return { RangeSubselect: result };
|
|
1478
|
+
}
|
|
1479
|
+
SetToDefault(node, context) {
|
|
1480
|
+
const result = {};
|
|
1481
|
+
if (node.location !== undefined) {
|
|
1482
|
+
result.location = node.location;
|
|
1483
|
+
}
|
|
1484
|
+
return { SetToDefault: result };
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
exports.V16ToV17Transformer = V16ToV17Transformer;
|