@pgsql/transform-ast 18.3.0

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.
Files changed (93) hide show
  1. package/13/enums.d.ts +62 -0
  2. package/13/enums.js +2 -0
  3. package/13/types.d.ts +2103 -0
  4. package/13/types.js +2 -0
  5. package/14/enums.d.ts +62 -0
  6. package/14/enums.js +2 -0
  7. package/14/types.d.ts +2164 -0
  8. package/14/types.js +2 -0
  9. package/15/enums.d.ts +64 -0
  10. package/15/enums.js +2 -0
  11. package/15/types.d.ts +2222 -0
  12. package/15/types.js +2 -0
  13. package/16/enums.d.ts +69 -0
  14. package/16/enums.js +2 -0
  15. package/16/types.d.ts +2328 -0
  16. package/16/types.js +2 -0
  17. package/17/enums.d.ts +76 -0
  18. package/17/enums.js +2 -0
  19. package/17/types.d.ts +2488 -0
  20. package/17/types.js +2 -0
  21. package/18/enums.d.ts +78 -0
  22. package/18/enums.js +2 -0
  23. package/18/types.d.ts +2538 -0
  24. package/18/types.js +2 -0
  25. package/LICENSE +21 -0
  26. package/README.md +141 -0
  27. package/esm/13/enums.js +1 -0
  28. package/esm/13/types.js +1 -0
  29. package/esm/14/enums.js +1 -0
  30. package/esm/14/types.js +1 -0
  31. package/esm/15/enums.js +1 -0
  32. package/esm/15/types.js +1 -0
  33. package/esm/16/enums.js +1 -0
  34. package/esm/16/types.js +1 -0
  35. package/esm/17/enums.js +1 -0
  36. package/esm/17/types.js +1 -0
  37. package/esm/18/enums.js +1 -0
  38. package/esm/18/types.js +1 -0
  39. package/esm/index.js +22 -0
  40. package/esm/multi-version-transformer.js +80 -0
  41. package/esm/transformers/context.js +1 -0
  42. package/esm/transformers/v13-to-v14.js +2767 -0
  43. package/esm/transformers/v14-to-v15.js +1218 -0
  44. package/esm/transformers/v15-to-v16.js +2935 -0
  45. package/esm/transformers/v16-to-v17.js +1526 -0
  46. package/esm/transformers/v17-to-v18.js +204 -0
  47. package/esm/transformers-direct/index.js +13 -0
  48. package/esm/transformers-direct/v13-to-v17/index.js +74 -0
  49. package/esm/transformers-direct/v13-to-v18/index.js +84 -0
  50. package/esm/transformers-direct/v14-to-v17/index.js +63 -0
  51. package/esm/transformers-direct/v14-to-v18/index.js +73 -0
  52. package/esm/transformers-direct/v15-to-v17/index.js +53 -0
  53. package/esm/transformers-direct/v15-to-v18/index.js +62 -0
  54. package/esm/transformers-direct/v16-to-v17/index.js +40 -0
  55. package/esm/transformers-direct/v16-to-v18/index.js +51 -0
  56. package/esm/transformers-direct/v17-to-v18/index.js +39 -0
  57. package/index.d.ts +28 -0
  58. package/index.js +78 -0
  59. package/multi-version-transformer.d.ts +14 -0
  60. package/multi-version-transformer.js +84 -0
  61. package/package.json +45 -0
  62. package/transformers/context.d.ts +4 -0
  63. package/transformers/context.js +2 -0
  64. package/transformers/v13-to-v14.d.ts +255 -0
  65. package/transformers/v13-to-v14.js +2771 -0
  66. package/transformers/v14-to-v15.d.ts +615 -0
  67. package/transformers/v14-to-v15.js +1222 -0
  68. package/transformers/v15-to-v16.d.ts +632 -0
  69. package/transformers/v15-to-v16.js +2939 -0
  70. package/transformers/v16-to-v17.d.ts +640 -0
  71. package/transformers/v16-to-v17.js +1530 -0
  72. package/transformers/v17-to-v18.d.ts +54 -0
  73. package/transformers/v17-to-v18.js +208 -0
  74. package/transformers-direct/index.d.ts +13 -0
  75. package/transformers-direct/index.js +25 -0
  76. package/transformers-direct/v13-to-v17/index.d.ts +27 -0
  77. package/transformers-direct/v13-to-v17/index.js +78 -0
  78. package/transformers-direct/v13-to-v18/index.d.ts +28 -0
  79. package/transformers-direct/v13-to-v18/index.js +88 -0
  80. package/transformers-direct/v14-to-v17/index.d.ts +26 -0
  81. package/transformers-direct/v14-to-v17/index.js +67 -0
  82. package/transformers-direct/v14-to-v18/index.d.ts +27 -0
  83. package/transformers-direct/v14-to-v18/index.js +77 -0
  84. package/transformers-direct/v15-to-v17/index.d.ts +25 -0
  85. package/transformers-direct/v15-to-v17/index.js +57 -0
  86. package/transformers-direct/v15-to-v18/index.d.ts +26 -0
  87. package/transformers-direct/v15-to-v18/index.js +66 -0
  88. package/transformers-direct/v16-to-v17/index.d.ts +24 -0
  89. package/transformers-direct/v16-to-v17/index.js +44 -0
  90. package/transformers-direct/v16-to-v18/index.d.ts +25 -0
  91. package/transformers-direct/v16-to-v18/index.js +55 -0
  92. package/transformers-direct/v17-to-v18/index.d.ts +24 -0
  93. package/transformers-direct/v17-to-v18/index.js +43 -0
@@ -0,0 +1,2935 @@
1
+ /**
2
+ * V15 to V16 AST Transformer
3
+ * Transforms PostgreSQL v15 AST nodes to v16 format
4
+ */
5
+ export class V15ToV16Transformer {
6
+ transform(node, context = { parentNodeTypes: [] }) {
7
+ if (node == null) {
8
+ return null;
9
+ }
10
+ if (typeof node === 'number' || node instanceof Number) {
11
+ return node;
12
+ }
13
+ if (typeof node === 'string') {
14
+ return node;
15
+ }
16
+ if (Array.isArray(node)) {
17
+ return node.map(item => this.transform(item, context));
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
+ return this[methodName](nodeData, childContext);
41
+ }
42
+ // If no specific method, return the node as-is
43
+ return node;
44
+ }
45
+ getNodeType(node) {
46
+ const keys = Object.keys(node);
47
+ // Handle parse result structure with version and stmts
48
+ if (keys.length === 2 && keys.includes('version') && keys.includes('stmts')) {
49
+ return 'ParseResult';
50
+ }
51
+ return keys[0];
52
+ }
53
+ getNodeData(node) {
54
+ const keys = Object.keys(node);
55
+ if (keys.length === 1 && typeof node[keys[0]] === 'object') {
56
+ return node[keys[0]];
57
+ }
58
+ return node;
59
+ }
60
+ ParseResult(node, context) {
61
+ if (node && typeof node === 'object' && 'version' in node && 'stmts' in node) {
62
+ return {
63
+ version: 160000, // PG16 version
64
+ stmts: node.stmts.map((stmt) => {
65
+ if (stmt && typeof stmt === 'object' && 'stmt' in stmt) {
66
+ return {
67
+ ...stmt,
68
+ stmt: this.transform(stmt.stmt, context)
69
+ };
70
+ }
71
+ return this.transform(stmt, context);
72
+ })
73
+ };
74
+ }
75
+ return node;
76
+ }
77
+ RawStmt(node, context) {
78
+ const result = {};
79
+ if (node.stmt !== undefined) {
80
+ result.stmt = this.transform(node.stmt, context);
81
+ }
82
+ if (node.stmt_location !== undefined) {
83
+ result.stmt_location = node.stmt_location;
84
+ }
85
+ if (node.stmt_len !== undefined) {
86
+ result.stmt_len = node.stmt_len;
87
+ }
88
+ return { RawStmt: result };
89
+ }
90
+ SelectStmt(node, context) {
91
+ const result = {};
92
+ if (node.distinctClause !== undefined) {
93
+ result.distinctClause = Array.isArray(node.distinctClause)
94
+ ? node.distinctClause.map((item) => this.transform(item, context))
95
+ : this.transform(node.distinctClause, context);
96
+ }
97
+ if (node.intoClause !== undefined) {
98
+ result.intoClause = this.transform(node.intoClause, context);
99
+ }
100
+ if (node.targetList !== undefined) {
101
+ result.targetList = Array.isArray(node.targetList)
102
+ ? node.targetList.map((item) => this.transform(item, context))
103
+ : this.transform(node.targetList, context);
104
+ }
105
+ if (node.fromClause !== undefined) {
106
+ result.fromClause = Array.isArray(node.fromClause)
107
+ ? node.fromClause.map((item) => this.transform(item, context))
108
+ : this.transform(node.fromClause, context);
109
+ }
110
+ if (node.whereClause !== undefined) {
111
+ result.whereClause = this.transform(node.whereClause, context);
112
+ }
113
+ if (node.groupClause !== undefined) {
114
+ result.groupClause = Array.isArray(node.groupClause)
115
+ ? node.groupClause.map((item) => this.transform(item, context))
116
+ : this.transform(node.groupClause, context);
117
+ }
118
+ if (node.groupDistinct !== undefined) {
119
+ result.groupDistinct = node.groupDistinct;
120
+ }
121
+ if (node.havingClause !== undefined) {
122
+ result.havingClause = this.transform(node.havingClause, context);
123
+ }
124
+ if (node.windowClause !== undefined) {
125
+ result.windowClause = Array.isArray(node.windowClause)
126
+ ? node.windowClause.map((item) => this.transform(item, context))
127
+ : this.transform(node.windowClause, context);
128
+ }
129
+ if (node.valuesLists !== undefined) {
130
+ result.valuesLists = Array.isArray(node.valuesLists)
131
+ ? node.valuesLists.map((item) => this.transform(item, context))
132
+ : this.transform(node.valuesLists, context);
133
+ }
134
+ if (node.sortClause !== undefined) {
135
+ result.sortClause = Array.isArray(node.sortClause)
136
+ ? node.sortClause.map((item) => this.transform(item, context))
137
+ : this.transform(node.sortClause, context);
138
+ }
139
+ if (node.limitOffset !== undefined) {
140
+ result.limitOffset = this.transform(node.limitOffset, context);
141
+ }
142
+ if (node.limitCount !== undefined) {
143
+ result.limitCount = this.transform(node.limitCount, context);
144
+ }
145
+ if (node.limitOption !== undefined) {
146
+ result.limitOption = node.limitOption;
147
+ }
148
+ if (node.lockingClause !== undefined) {
149
+ result.lockingClause = Array.isArray(node.lockingClause)
150
+ ? node.lockingClause.map((item) => this.transform(item, context))
151
+ : this.transform(node.lockingClause, context);
152
+ }
153
+ if (node.withClause !== undefined) {
154
+ result.withClause = this.transform(node.withClause, context);
155
+ }
156
+ if (node.op !== undefined) {
157
+ result.op = node.op;
158
+ }
159
+ if (node.all !== undefined) {
160
+ result.all = node.all;
161
+ }
162
+ if (node.larg !== undefined) {
163
+ result.larg = this.transform(node.larg, context);
164
+ }
165
+ if (node.rarg !== undefined) {
166
+ result.rarg = this.transform(node.rarg, context);
167
+ }
168
+ return { SelectStmt: result };
169
+ }
170
+ A_Expr(node, context) {
171
+ const result = {};
172
+ if (node.kind !== undefined) {
173
+ result.kind = node.kind;
174
+ }
175
+ if (node.name !== undefined) {
176
+ result.name = Array.isArray(node.name)
177
+ ? node.name.map((item) => this.transform(item, context))
178
+ : this.transform(node.name, context);
179
+ }
180
+ if (node.lexpr !== undefined) {
181
+ result.lexpr = this.transform(node.lexpr, context);
182
+ }
183
+ if (node.rexpr !== undefined) {
184
+ result.rexpr = this.transform(node.rexpr, context);
185
+ }
186
+ if (node.location !== undefined) {
187
+ result.location = node.location;
188
+ }
189
+ return { A_Expr: result };
190
+ }
191
+ InsertStmt(node, context) {
192
+ const result = {};
193
+ if (node.relation !== undefined) {
194
+ result.relation = this.transform(node.relation, context);
195
+ }
196
+ if (node.cols !== undefined) {
197
+ result.cols = Array.isArray(node.cols)
198
+ ? node.cols.map((item) => this.transform(item, context))
199
+ : this.transform(node.cols, context);
200
+ }
201
+ if (node.selectStmt !== undefined) {
202
+ result.selectStmt = this.transform(node.selectStmt, context);
203
+ }
204
+ if (node.onConflictClause !== undefined) {
205
+ result.onConflictClause = this.transform(node.onConflictClause, context);
206
+ }
207
+ if (node.returningList !== undefined) {
208
+ result.returningList = Array.isArray(node.returningList)
209
+ ? node.returningList.map((item) => this.transform(item, context))
210
+ : this.transform(node.returningList, context);
211
+ }
212
+ if (node.withClause !== undefined) {
213
+ result.withClause = this.transform(node.withClause, context);
214
+ }
215
+ if (node.override !== undefined) {
216
+ result.override = node.override;
217
+ }
218
+ return { InsertStmt: result };
219
+ }
220
+ UpdateStmt(node, context) {
221
+ const result = {};
222
+ if (node.relation !== undefined) {
223
+ result.relation = this.transform(node.relation, context);
224
+ }
225
+ if (node.targetList !== undefined) {
226
+ result.targetList = Array.isArray(node.targetList)
227
+ ? node.targetList.map((item) => this.transform(item, context))
228
+ : this.transform(node.targetList, context);
229
+ }
230
+ if (node.whereClause !== undefined) {
231
+ result.whereClause = this.transform(node.whereClause, context);
232
+ }
233
+ if (node.fromClause !== undefined) {
234
+ result.fromClause = Array.isArray(node.fromClause)
235
+ ? node.fromClause.map((item) => this.transform(item, context))
236
+ : this.transform(node.fromClause, context);
237
+ }
238
+ if (node.returningList !== undefined) {
239
+ result.returningList = Array.isArray(node.returningList)
240
+ ? node.returningList.map((item) => this.transform(item, context))
241
+ : this.transform(node.returningList, context);
242
+ }
243
+ if (node.withClause !== undefined) {
244
+ result.withClause = this.transform(node.withClause, context);
245
+ }
246
+ return { UpdateStmt: result };
247
+ }
248
+ DeleteStmt(node, context) {
249
+ const result = {};
250
+ if (node.relation !== undefined) {
251
+ result.relation = this.transform(node.relation, context);
252
+ }
253
+ if (node.usingClause !== undefined) {
254
+ result.usingClause = Array.isArray(node.usingClause)
255
+ ? node.usingClause.map((item) => this.transform(item, context))
256
+ : this.transform(node.usingClause, context);
257
+ }
258
+ if (node.whereClause !== undefined) {
259
+ result.whereClause = this.transform(node.whereClause, context);
260
+ }
261
+ if (node.returningList !== undefined) {
262
+ result.returningList = Array.isArray(node.returningList)
263
+ ? node.returningList.map((item) => this.transform(item, context))
264
+ : this.transform(node.returningList, context);
265
+ }
266
+ if (node.withClause !== undefined) {
267
+ result.withClause = this.transform(node.withClause, context);
268
+ }
269
+ return { DeleteStmt: result };
270
+ }
271
+ WithClause(node, context) {
272
+ const result = {};
273
+ if (node.ctes !== undefined) {
274
+ result.ctes = Array.isArray(node.ctes)
275
+ ? node.ctes.map((item) => this.transform(item, context))
276
+ : this.transform(node.ctes, context);
277
+ }
278
+ if (node.recursive !== undefined) {
279
+ result.recursive = node.recursive;
280
+ }
281
+ if (node.location !== undefined) {
282
+ result.location = node.location;
283
+ }
284
+ return { WithClause: result };
285
+ }
286
+ ResTarget(node, context) {
287
+ const result = {};
288
+ if (node.name !== undefined) {
289
+ result.name = node.name;
290
+ }
291
+ if (node.indirection !== undefined) {
292
+ result.indirection = Array.isArray(node.indirection)
293
+ ? node.indirection.map((item) => this.transform(item, context))
294
+ : this.transform(node.indirection, context);
295
+ }
296
+ if (node.val !== undefined) {
297
+ result.val = this.transform(node.val, context);
298
+ }
299
+ if (node.location !== undefined) {
300
+ result.location = node.location;
301
+ }
302
+ return { ResTarget: result };
303
+ }
304
+ BoolExpr(node, context) {
305
+ const result = {};
306
+ if (node.boolop !== undefined) {
307
+ result.boolop = node.boolop;
308
+ }
309
+ if (node.args !== undefined) {
310
+ result.args = Array.isArray(node.args)
311
+ ? node.args.map((item) => this.transform(item, context))
312
+ : this.transform(node.args, context);
313
+ }
314
+ if (node.location !== undefined) {
315
+ result.location = node.location;
316
+ }
317
+ return { BoolExpr: result };
318
+ }
319
+ FuncCall(node, context) {
320
+ const result = {};
321
+ if (node.funcname !== undefined) {
322
+ if (node.funcname.length === 1 && node.funcname[0]?.String?.sval === 'json_object') {
323
+ result.funcname = [
324
+ {
325
+ String: { sval: 'pg_catalog' }
326
+ },
327
+ { String: { sval: 'json_object' } }
328
+ ];
329
+ }
330
+ else if (node.funcname.length === 2 &&
331
+ node.funcname[0]?.String?.sval === 'pg_catalog' &&
332
+ node.funcname[1]?.String?.sval === 'system_user' &&
333
+ node.funcformat === 'COERCE_SQL_SYNTAX') {
334
+ return {
335
+ ColumnRef: {
336
+ fields: [
337
+ { String: { sval: 'system_user' } }
338
+ ]
339
+ }
340
+ };
341
+ }
342
+ else {
343
+ result.funcname = Array.isArray(node.funcname)
344
+ ? node.funcname.map((item) => this.transform(item, context))
345
+ : this.transform(node.funcname, context);
346
+ }
347
+ }
348
+ if (node.args !== undefined) {
349
+ result.args = Array.isArray(node.args)
350
+ ? node.args.map((item) => this.transform(item, context))
351
+ : this.transform(node.args, context);
352
+ }
353
+ if (node.agg_order !== undefined) {
354
+ result.agg_order = Array.isArray(node.agg_order)
355
+ ? node.agg_order.map((item) => this.transform(item, context))
356
+ : this.transform(node.agg_order, context);
357
+ }
358
+ if (node.agg_filter !== undefined) {
359
+ result.agg_filter = this.transform(node.agg_filter, context);
360
+ }
361
+ if (node.over !== undefined) {
362
+ result.over = this.transform(node.over, context);
363
+ }
364
+ if (node.agg_within_group !== undefined) {
365
+ result.agg_within_group = node.agg_within_group;
366
+ }
367
+ if (node.agg_star !== undefined) {
368
+ result.agg_star = node.agg_star;
369
+ }
370
+ if (node.agg_distinct !== undefined) {
371
+ result.agg_distinct = node.agg_distinct;
372
+ }
373
+ if (node.func_variadic !== undefined) {
374
+ result.func_variadic = node.func_variadic;
375
+ }
376
+ if (node.funcformat !== undefined) {
377
+ result.funcformat = node.funcformat;
378
+ }
379
+ if (node.location !== undefined) {
380
+ result.location = node.location;
381
+ }
382
+ return { FuncCall: result };
383
+ }
384
+ FuncExpr(node, context) {
385
+ const result = {};
386
+ if (node.xpr !== undefined) {
387
+ result.xpr = this.transform(node.xpr, context);
388
+ }
389
+ if (node.funcid !== undefined) {
390
+ result.funcid = node.funcid;
391
+ }
392
+ if (node.funcresulttype !== undefined) {
393
+ result.funcresulttype = node.funcresulttype;
394
+ }
395
+ if (node.funcretset !== undefined) {
396
+ result.funcretset = node.funcretset;
397
+ }
398
+ if (node.funcvariadic !== undefined) {
399
+ result.funcvariadic = node.funcvariadic;
400
+ }
401
+ if (node.funcformat !== undefined) {
402
+ result.funcformat = node.funcformat;
403
+ }
404
+ if (node.funccollid !== undefined) {
405
+ result.funccollid = node.funccollid;
406
+ }
407
+ if (node.inputcollid !== undefined) {
408
+ result.inputcollid = node.inputcollid;
409
+ }
410
+ if (node.args !== undefined) {
411
+ result.args = Array.isArray(node.args)
412
+ ? node.args.map((item) => this.transform(item, context))
413
+ : this.transform(node.args, context);
414
+ }
415
+ if (node.location !== undefined) {
416
+ result.location = node.location;
417
+ }
418
+ return { FuncExpr: result };
419
+ }
420
+ A_Const(node, context) {
421
+ const result = { ...node };
422
+ if (result.val) {
423
+ const val = result.val;
424
+ if (val.String && val.String.str !== undefined) {
425
+ result.sval = val.String.str;
426
+ delete result.val;
427
+ }
428
+ else if (val.Integer !== undefined) {
429
+ result.ival = val.Integer;
430
+ delete result.val;
431
+ }
432
+ else if (val.Float && val.Float.str !== undefined) {
433
+ result.fval = val.Float.str;
434
+ delete result.val;
435
+ }
436
+ else if (val.BitString && val.BitString.str !== undefined) {
437
+ result.bsval = val.BitString.str;
438
+ delete result.val;
439
+ }
440
+ else if (val.Null !== undefined) {
441
+ delete result.val;
442
+ }
443
+ }
444
+ return { A_Const: result };
445
+ }
446
+ ColumnRef(node, context) {
447
+ if (node.fields && Array.isArray(node.fields) && node.fields.length === 1) {
448
+ const field = node.fields[0];
449
+ if (field?.String?.sval === 'system_user') {
450
+ return {
451
+ FuncCall: {
452
+ funcname: [
453
+ { String: { sval: 'pg_catalog' } },
454
+ { String: { sval: 'system_user' } }
455
+ ],
456
+ funcformat: 'COERCE_SQL_SYNTAX'
457
+ }
458
+ };
459
+ }
460
+ }
461
+ const result = {};
462
+ if (node.fields !== undefined) {
463
+ result.fields = Array.isArray(node.fields)
464
+ ? node.fields.map((item) => this.transform(item, context))
465
+ : this.transform(node.fields, context);
466
+ }
467
+ if (node.location !== undefined) {
468
+ result.location = node.location;
469
+ }
470
+ return { ColumnRef: result };
471
+ }
472
+ TypeName(node, context) {
473
+ const result = {};
474
+ if (node.names !== undefined) {
475
+ result.names = Array.isArray(node.names)
476
+ ? node.names.map((item) => this.transform(item, context))
477
+ : this.transform(node.names, context);
478
+ }
479
+ if (node.typeOid !== undefined) {
480
+ result.typeOid = node.typeOid;
481
+ }
482
+ if (node.setof !== undefined) {
483
+ result.setof = node.setof;
484
+ }
485
+ if (node.pct_type !== undefined) {
486
+ result.pct_type = node.pct_type;
487
+ }
488
+ if (node.typmods !== undefined) {
489
+ result.typmods = Array.isArray(node.typmods)
490
+ ? node.typmods.map((item) => this.transform(item, context))
491
+ : this.transform(node.typmods, context);
492
+ }
493
+ if (node.typemod !== undefined) {
494
+ result.typemod = node.typemod;
495
+ }
496
+ if (node.arrayBounds !== undefined) {
497
+ const childContext = {
498
+ ...context,
499
+ parentNodeTypes: [...(context.parentNodeTypes || []), 'TypeName']
500
+ };
501
+ result.arrayBounds = Array.isArray(node.arrayBounds)
502
+ ? node.arrayBounds.map((item) => this.transform(item, childContext))
503
+ : this.transform(node.arrayBounds, childContext);
504
+ }
505
+ if (node.location !== undefined) {
506
+ result.location = node.location;
507
+ }
508
+ return { TypeName: result };
509
+ }
510
+ Alias(node, context) {
511
+ const result = {};
512
+ if (node.aliasname !== undefined) {
513
+ result.aliasname = node.aliasname;
514
+ }
515
+ if (node.colnames !== undefined) {
516
+ result.colnames = Array.isArray(node.colnames)
517
+ ? node.colnames.map((item) => this.transform(item, context))
518
+ : this.transform(node.colnames, context);
519
+ }
520
+ return { Alias: result };
521
+ }
522
+ RangeVar(node, context) {
523
+ if (node.relname === 'system_user' && node.inh === true && node.relpersistence === 'p') {
524
+ return {
525
+ RangeFunction: {
526
+ functions: [
527
+ {
528
+ List: {
529
+ items: [
530
+ {
531
+ FuncCall: {
532
+ funcname: [
533
+ { String: { sval: 'pg_catalog' } },
534
+ { String: { sval: 'system_user' } }
535
+ ],
536
+ funcformat: 'COERCE_SQL_SYNTAX'
537
+ }
538
+ },
539
+ {}
540
+ ]
541
+ }
542
+ }
543
+ ]
544
+ }
545
+ };
546
+ }
547
+ const result = {};
548
+ if (node.catalogname !== undefined) {
549
+ result.catalogname = node.catalogname;
550
+ }
551
+ if (node.schemaname !== undefined) {
552
+ result.schemaname = node.schemaname;
553
+ }
554
+ if (node.relname !== undefined) {
555
+ result.relname = node.relname;
556
+ }
557
+ if (node.inh !== undefined) {
558
+ result.inh = node.inh;
559
+ }
560
+ if (node.relpersistence !== undefined) {
561
+ result.relpersistence = node.relpersistence;
562
+ }
563
+ if (node.alias !== undefined) {
564
+ result.alias = this.transform(node.alias, context);
565
+ }
566
+ if (node.location !== undefined) {
567
+ result.location = node.location;
568
+ }
569
+ return { RangeVar: result };
570
+ }
571
+ A_ArrayExpr(node, context) {
572
+ const result = {};
573
+ if (node.elements !== undefined) {
574
+ result.elements = Array.isArray(node.elements)
575
+ ? node.elements.map((item) => this.transform(item, context))
576
+ : this.transform(node.elements, context);
577
+ }
578
+ if (node.location !== undefined) {
579
+ result.location = node.location;
580
+ }
581
+ return { A_ArrayExpr: result };
582
+ }
583
+ A_Indices(node, context) {
584
+ const result = {};
585
+ if (node.is_slice !== undefined) {
586
+ result.is_slice = node.is_slice;
587
+ }
588
+ if (node.lidx !== undefined) {
589
+ result.lidx = this.transform(node.lidx, context);
590
+ }
591
+ if (node.uidx !== undefined) {
592
+ result.uidx = this.transform(node.uidx, context);
593
+ }
594
+ return { A_Indices: result };
595
+ }
596
+ A_Indirection(node, context) {
597
+ const result = {};
598
+ if (node.arg !== undefined) {
599
+ result.arg = this.transform(node.arg, context);
600
+ }
601
+ if (node.indirection !== undefined) {
602
+ result.indirection = Array.isArray(node.indirection)
603
+ ? node.indirection.map((item) => this.transform(item, context))
604
+ : this.transform(node.indirection, context);
605
+ }
606
+ return { A_Indirection: result };
607
+ }
608
+ A_Star(node, context) {
609
+ const result = {};
610
+ return { A_Star: result };
611
+ }
612
+ CaseExpr(node, context) {
613
+ const result = {};
614
+ if (node.xpr !== undefined) {
615
+ result.xpr = this.transform(node.xpr, context);
616
+ }
617
+ if (node.casetype !== undefined) {
618
+ result.casetype = node.casetype;
619
+ }
620
+ if (node.casecollid !== undefined) {
621
+ result.casecollid = node.casecollid;
622
+ }
623
+ if (node.arg !== undefined) {
624
+ result.arg = this.transform(node.arg, context);
625
+ }
626
+ if (node.args !== undefined) {
627
+ result.args = Array.isArray(node.args)
628
+ ? node.args.map((item) => this.transform(item, context))
629
+ : this.transform(node.args, context);
630
+ }
631
+ if (node.defresult !== undefined) {
632
+ result.defresult = this.transform(node.defresult, context);
633
+ }
634
+ if (node.location !== undefined) {
635
+ result.location = node.location;
636
+ }
637
+ return { CaseExpr: result };
638
+ }
639
+ CoalesceExpr(node, context) {
640
+ const result = {};
641
+ if (node.xpr !== undefined) {
642
+ result.xpr = this.transform(node.xpr, context);
643
+ }
644
+ if (node.coalescetype !== undefined) {
645
+ result.coalescetype = node.coalescetype;
646
+ }
647
+ if (node.coalescecollid !== undefined) {
648
+ result.coalescecollid = node.coalescecollid;
649
+ }
650
+ if (node.args !== undefined) {
651
+ result.args = Array.isArray(node.args)
652
+ ? node.args.map((item) => this.transform(item, context))
653
+ : this.transform(node.args, context);
654
+ }
655
+ if (node.location !== undefined) {
656
+ result.location = node.location;
657
+ }
658
+ return { CoalesceExpr: result };
659
+ }
660
+ TypeCast(node, context) {
661
+ const result = {};
662
+ if (node.arg !== undefined) {
663
+ result.arg = this.transform(node.arg, context);
664
+ }
665
+ if (node.typeName !== undefined) {
666
+ const childContext = {
667
+ ...context,
668
+ parentNodeTypes: [...(context.parentNodeTypes || []), 'TypeCast']
669
+ };
670
+ result.typeName = this.TypeName(node.typeName, childContext).TypeName;
671
+ }
672
+ if (node.location !== undefined) {
673
+ result.location = node.location;
674
+ }
675
+ return { TypeCast: result };
676
+ }
677
+ CollateClause(node, context) {
678
+ const result = {};
679
+ if (node.arg !== undefined) {
680
+ result.arg = this.transform(node.arg, context);
681
+ }
682
+ if (node.collname !== undefined) {
683
+ result.collname = Array.isArray(node.collname)
684
+ ? node.collname.map((item) => this.transform(item, context))
685
+ : this.transform(node.collname, context);
686
+ }
687
+ if (node.location !== undefined) {
688
+ result.location = node.location;
689
+ }
690
+ return { CollateClause: result };
691
+ }
692
+ BooleanTest(node, context) {
693
+ const result = {};
694
+ if (node.xpr !== undefined) {
695
+ result.xpr = this.transform(node.xpr, context);
696
+ }
697
+ if (node.arg !== undefined) {
698
+ result.arg = this.transform(node.arg, context);
699
+ }
700
+ if (node.booltesttype !== undefined) {
701
+ result.booltesttype = node.booltesttype;
702
+ }
703
+ if (node.location !== undefined) {
704
+ result.location = node.location;
705
+ }
706
+ return { BooleanTest: result };
707
+ }
708
+ NullTest(node, context) {
709
+ const result = {};
710
+ if (node.xpr !== undefined) {
711
+ result.xpr = this.transform(node.xpr, context);
712
+ }
713
+ if (node.arg !== undefined) {
714
+ result.arg = this.transform(node.arg, context);
715
+ }
716
+ if (node.nulltesttype !== undefined) {
717
+ result.nulltesttype = node.nulltesttype;
718
+ }
719
+ if (node.argisrow !== undefined) {
720
+ result.argisrow = node.argisrow;
721
+ }
722
+ if (node.location !== undefined) {
723
+ result.location = node.location;
724
+ }
725
+ return { NullTest: result };
726
+ }
727
+ String(node, context) {
728
+ const result = { ...node };
729
+ return { String: result };
730
+ }
731
+ Integer(node, context) {
732
+ const result = { ...node };
733
+ return { Integer: result };
734
+ }
735
+ Float(node, context) {
736
+ const result = { ...node };
737
+ return { Float: result };
738
+ }
739
+ Boolean(node, context) {
740
+ const result = { ...node };
741
+ return { Boolean: result };
742
+ }
743
+ BitString(node, context) {
744
+ const result = { ...node };
745
+ return { BitString: result };
746
+ }
747
+ Null(node, context) {
748
+ return { Null: {} };
749
+ }
750
+ List(node, context) {
751
+ const result = {};
752
+ if (node.items !== undefined) {
753
+ result.items = Array.isArray(node.items)
754
+ ? node.items.map((item) => {
755
+ const transformed = this.transform(item, context);
756
+ if (transformed === null) {
757
+ return {};
758
+ }
759
+ return transformed;
760
+ })
761
+ : this.transform(node.items, context);
762
+ }
763
+ return { List: result };
764
+ }
765
+ CreateStmt(node, context) {
766
+ const result = {};
767
+ if (node.relation !== undefined) {
768
+ result.relation = this.transform(node.relation, context);
769
+ }
770
+ if (node.tableElts !== undefined) {
771
+ result.tableElts = Array.isArray(node.tableElts)
772
+ ? node.tableElts.map((item) => this.transform(item, context))
773
+ : this.transform(node.tableElts, context);
774
+ }
775
+ if (node.inhRelations !== undefined) {
776
+ result.inhRelations = Array.isArray(node.inhRelations)
777
+ ? node.inhRelations.map((item) => this.transform(item, context))
778
+ : this.transform(node.inhRelations, context);
779
+ }
780
+ if (node.partbound !== undefined) {
781
+ result.partbound = this.transform(node.partbound, context);
782
+ }
783
+ if (node.partspec !== undefined) {
784
+ // Handle partspec transformation directly since it's a plain object, not a wrapped node
785
+ const partspec = { ...node.partspec };
786
+ if (partspec.strategy !== undefined) {
787
+ const strategyMap = {
788
+ 'range': 'PARTITION_STRATEGY_RANGE',
789
+ 'list': 'PARTITION_STRATEGY_LIST',
790
+ 'hash': 'PARTITION_STRATEGY_HASH'
791
+ };
792
+ partspec.strategy = strategyMap[partspec.strategy] || partspec.strategy;
793
+ }
794
+ if (partspec.partParams !== undefined) {
795
+ partspec.partParams = Array.isArray(partspec.partParams)
796
+ ? partspec.partParams.map((item) => this.transform(item, context))
797
+ : this.transform(partspec.partParams, context);
798
+ }
799
+ result.partspec = partspec;
800
+ }
801
+ if (node.ofTypename !== undefined) {
802
+ result.ofTypename = this.transform(node.ofTypename, context);
803
+ }
804
+ if (node.constraints !== undefined) {
805
+ result.constraints = Array.isArray(node.constraints)
806
+ ? node.constraints.map((item) => this.transform(item, context))
807
+ : this.transform(node.constraints, context);
808
+ }
809
+ if (node.options !== undefined) {
810
+ result.options = Array.isArray(node.options)
811
+ ? node.options.map((item) => this.transform(item, context))
812
+ : this.transform(node.options, context);
813
+ }
814
+ if (node.oncommit !== undefined) {
815
+ result.oncommit = node.oncommit;
816
+ }
817
+ if (node.tablespacename !== undefined) {
818
+ result.tablespacename = node.tablespacename;
819
+ }
820
+ if (node.accessMethod !== undefined) {
821
+ result.accessMethod = node.accessMethod;
822
+ }
823
+ if (node.if_not_exists !== undefined) {
824
+ result.if_not_exists = node.if_not_exists;
825
+ }
826
+ return { CreateStmt: result };
827
+ }
828
+ ColumnDef(node, context) {
829
+ const result = {};
830
+ if (node.colname !== undefined) {
831
+ result.colname = node.colname;
832
+ }
833
+ if (node.typeName !== undefined) {
834
+ const transformedTypeName = this.transform({ TypeName: node.typeName }, context);
835
+ result.typeName = transformedTypeName.TypeName;
836
+ }
837
+ if (node.inhcount !== undefined) {
838
+ result.inhcount = node.inhcount;
839
+ }
840
+ if (node.is_local !== undefined) {
841
+ result.is_local = node.is_local;
842
+ }
843
+ if (node.is_not_null !== undefined) {
844
+ result.is_not_null = node.is_not_null;
845
+ }
846
+ if (node.is_from_type !== undefined) {
847
+ result.is_from_type = node.is_from_type;
848
+ }
849
+ if (node.storage !== undefined) {
850
+ result.storage = node.storage;
851
+ }
852
+ if (node.raw_default !== undefined) {
853
+ result.raw_default = this.transform(node.raw_default, context);
854
+ }
855
+ if (node.cooked_default !== undefined) {
856
+ result.cooked_default = this.transform(node.cooked_default, context);
857
+ }
858
+ if (node.identity !== undefined) {
859
+ result.identity = node.identity;
860
+ }
861
+ if (node.identitySequence !== undefined) {
862
+ result.identitySequence = this.transform(node.identitySequence, context);
863
+ }
864
+ if (node.generated !== undefined) {
865
+ result.generated = node.generated;
866
+ }
867
+ if (node.collClause !== undefined) {
868
+ result.collClause = this.transform(node.collClause, context);
869
+ }
870
+ if (node.collOid !== undefined) {
871
+ result.collOid = node.collOid;
872
+ }
873
+ if (node.constraints !== undefined) {
874
+ result.constraints = Array.isArray(node.constraints)
875
+ ? node.constraints.map((item) => this.transform(item, context))
876
+ : this.transform(node.constraints, context);
877
+ }
878
+ if (node.fdwoptions !== undefined) {
879
+ result.fdwoptions = Array.isArray(node.fdwoptions)
880
+ ? node.fdwoptions.map((item) => this.transform(item, context))
881
+ : this.transform(node.fdwoptions, context);
882
+ }
883
+ if (node.location !== undefined) {
884
+ result.location = node.location;
885
+ }
886
+ return { ColumnDef: result };
887
+ }
888
+ Constraint(node, context) {
889
+ const result = {};
890
+ if (node.contype !== undefined) {
891
+ result.contype = node.contype;
892
+ }
893
+ if (node.conname !== undefined) {
894
+ result.conname = node.conname;
895
+ }
896
+ if (node.deferrable !== undefined) {
897
+ result.deferrable = node.deferrable;
898
+ }
899
+ if (node.initdeferred !== undefined) {
900
+ result.initdeferred = node.initdeferred;
901
+ }
902
+ if (node.location !== undefined) {
903
+ result.location = node.location;
904
+ }
905
+ if (node.is_no_inherit !== undefined) {
906
+ result.is_no_inherit = node.is_no_inherit;
907
+ }
908
+ if (node.raw_expr !== undefined) {
909
+ result.raw_expr = this.transform(node.raw_expr, context);
910
+ }
911
+ if (node.cooked_expr !== undefined) {
912
+ result.cooked_expr = node.cooked_expr;
913
+ }
914
+ if (node.generated_when !== undefined) {
915
+ result.generated_when = node.generated_when;
916
+ }
917
+ if (node.keys !== undefined) {
918
+ result.keys = Array.isArray(node.keys)
919
+ ? node.keys.map((item) => this.transform(item, context))
920
+ : this.transform(node.keys, context);
921
+ }
922
+ if (node.including !== undefined) {
923
+ result.including = Array.isArray(node.including)
924
+ ? node.including.map((item) => this.transform(item, context))
925
+ : this.transform(node.including, context);
926
+ }
927
+ if (node.exclusions !== undefined) {
928
+ result.exclusions = Array.isArray(node.exclusions)
929
+ ? node.exclusions.map((item) => this.transform(item, context))
930
+ : this.transform(node.exclusions, context);
931
+ }
932
+ if (node.options !== undefined) {
933
+ result.options = Array.isArray(node.options)
934
+ ? node.options.map((item) => this.transform(item, context))
935
+ : this.transform(node.options, context);
936
+ }
937
+ if (node.indexname !== undefined) {
938
+ result.indexname = node.indexname;
939
+ }
940
+ if (node.indexspace !== undefined) {
941
+ result.indexspace = node.indexspace;
942
+ }
943
+ if (node.reset_default_tblspc !== undefined) {
944
+ result.reset_default_tblspc = node.reset_default_tblspc;
945
+ }
946
+ if (node.access_method !== undefined) {
947
+ result.access_method = node.access_method;
948
+ }
949
+ if (node.where_clause !== undefined) {
950
+ result.where_clause = this.transform(node.where_clause, context);
951
+ }
952
+ if (node.pktable !== undefined) {
953
+ result.pktable = this.transform(node.pktable, context);
954
+ }
955
+ if (node.fk_attrs !== undefined) {
956
+ result.fk_attrs = Array.isArray(node.fk_attrs)
957
+ ? node.fk_attrs.map((item) => this.transform(item, context))
958
+ : this.transform(node.fk_attrs, context);
959
+ }
960
+ if (node.pk_attrs !== undefined) {
961
+ result.pk_attrs = Array.isArray(node.pk_attrs)
962
+ ? node.pk_attrs.map((item) => this.transform(item, context))
963
+ : this.transform(node.pk_attrs, context);
964
+ }
965
+ if (node.fk_matchtype !== undefined) {
966
+ result.fk_matchtype = node.fk_matchtype;
967
+ }
968
+ if (node.fk_upd_action !== undefined) {
969
+ result.fk_upd_action = node.fk_upd_action;
970
+ }
971
+ if (node.fk_del_action !== undefined) {
972
+ result.fk_del_action = node.fk_del_action;
973
+ }
974
+ if (node.old_conpfeqop !== undefined) {
975
+ result.old_conpfeqop = Array.isArray(node.old_conpfeqop)
976
+ ? node.old_conpfeqop.map((item) => this.transform(item, context))
977
+ : this.transform(node.old_conpfeqop, context);
978
+ }
979
+ if (node.old_pktable_oid !== undefined) {
980
+ result.old_pktable_oid = node.old_pktable_oid;
981
+ }
982
+ if (node.skip_validation !== undefined) {
983
+ result.skip_validation = node.skip_validation;
984
+ }
985
+ if (node.initially_valid !== undefined) {
986
+ result.initially_valid = node.initially_valid;
987
+ }
988
+ if (node.nulls_not_distinct !== undefined) {
989
+ result.nulls_not_distinct = node.nulls_not_distinct;
990
+ }
991
+ return { Constraint: result };
992
+ }
993
+ SubLink(node, context) {
994
+ const result = {};
995
+ if (node.xpr !== undefined) {
996
+ result.xpr = this.transform(node.xpr, context);
997
+ }
998
+ if (node.subLinkType !== undefined) {
999
+ result.subLinkType = node.subLinkType;
1000
+ }
1001
+ if (node.subLinkId !== undefined) {
1002
+ result.subLinkId = node.subLinkId;
1003
+ }
1004
+ if (node.testexpr !== undefined) {
1005
+ result.testexpr = this.transform(node.testexpr, context);
1006
+ }
1007
+ if (node.operName !== undefined) {
1008
+ result.operName = Array.isArray(node.operName)
1009
+ ? node.operName.map((item) => this.transform(item, context))
1010
+ : this.transform(node.operName, context);
1011
+ }
1012
+ if (node.subselect !== undefined) {
1013
+ result.subselect = this.transform(node.subselect, context);
1014
+ }
1015
+ if (node.location !== undefined) {
1016
+ result.location = node.location;
1017
+ }
1018
+ return { SubLink: result };
1019
+ }
1020
+ CaseWhen(node, context) {
1021
+ const result = {};
1022
+ if (node.xpr !== undefined) {
1023
+ result.xpr = this.transform(node.xpr, context);
1024
+ }
1025
+ if (node.expr !== undefined) {
1026
+ result.expr = this.transform(node.expr, context);
1027
+ }
1028
+ if (node.result !== undefined) {
1029
+ result.result = this.transform(node.result, context);
1030
+ }
1031
+ if (node.location !== undefined) {
1032
+ result.location = node.location;
1033
+ }
1034
+ return { CaseWhen: result };
1035
+ }
1036
+ WindowDef(node, context) {
1037
+ const result = {};
1038
+ if (node.name !== undefined) {
1039
+ result.name = node.name;
1040
+ }
1041
+ if (node.refname !== undefined) {
1042
+ result.refname = node.refname;
1043
+ }
1044
+ if (node.partitionClause !== undefined) {
1045
+ result.partitionClause = Array.isArray(node.partitionClause)
1046
+ ? node.partitionClause.map((item) => this.transform(item, context))
1047
+ : this.transform(node.partitionClause, context);
1048
+ }
1049
+ if (node.orderClause !== undefined) {
1050
+ result.orderClause = Array.isArray(node.orderClause)
1051
+ ? node.orderClause.map((item) => this.transform(item, context))
1052
+ : this.transform(node.orderClause, context);
1053
+ }
1054
+ if (node.frameOptions !== undefined) {
1055
+ result.frameOptions = node.frameOptions;
1056
+ }
1057
+ if (node.startOffset !== undefined) {
1058
+ result.startOffset = this.transform(node.startOffset, context);
1059
+ }
1060
+ if (node.endOffset !== undefined) {
1061
+ result.endOffset = this.transform(node.endOffset, context);
1062
+ }
1063
+ if (node.location !== undefined) {
1064
+ result.location = node.location;
1065
+ }
1066
+ return { WindowDef: result };
1067
+ }
1068
+ SortBy(node, context) {
1069
+ const result = {};
1070
+ if (node.node !== undefined) {
1071
+ result.node = this.transform(node.node, context);
1072
+ }
1073
+ if (node.sortby_dir !== undefined) {
1074
+ result.sortby_dir = node.sortby_dir;
1075
+ }
1076
+ if (node.sortby_nulls !== undefined) {
1077
+ result.sortby_nulls = node.sortby_nulls;
1078
+ }
1079
+ if (node.useOp !== undefined) {
1080
+ result.useOp = Array.isArray(node.useOp)
1081
+ ? node.useOp.map((item) => this.transform(item, context))
1082
+ : this.transform(node.useOp, context);
1083
+ }
1084
+ if (node.location !== undefined) {
1085
+ result.location = node.location;
1086
+ }
1087
+ return { SortBy: result };
1088
+ }
1089
+ GroupingSet(node, context) {
1090
+ const result = {};
1091
+ if (node.kind !== undefined) {
1092
+ result.kind = node.kind;
1093
+ }
1094
+ if (node.content !== undefined) {
1095
+ result.content = Array.isArray(node.content)
1096
+ ? node.content.map((item) => this.transform(item, context))
1097
+ : this.transform(node.content, context);
1098
+ }
1099
+ if (node.location !== undefined) {
1100
+ result.location = node.location;
1101
+ }
1102
+ return { GroupingSet: result };
1103
+ }
1104
+ CommonTableExpr(node, context) {
1105
+ const result = {};
1106
+ if (node.ctename !== undefined) {
1107
+ result.ctename = node.ctename;
1108
+ }
1109
+ if (node.aliascolnames !== undefined) {
1110
+ result.aliascolnames = Array.isArray(node.aliascolnames)
1111
+ ? node.aliascolnames.map((item) => this.transform(item, context))
1112
+ : this.transform(node.aliascolnames, context);
1113
+ }
1114
+ if (node.ctematerialized !== undefined) {
1115
+ result.ctematerialized = node.ctematerialized;
1116
+ }
1117
+ if (node.ctequery !== undefined) {
1118
+ result.ctequery = this.transform(node.ctequery, context);
1119
+ }
1120
+ if (node.location !== undefined) {
1121
+ result.location = node.location;
1122
+ }
1123
+ if (node.cterecursive !== undefined) {
1124
+ result.cterecursive = node.cterecursive;
1125
+ }
1126
+ if (node.cterefcount !== undefined) {
1127
+ result.cterefcount = node.cterefcount;
1128
+ }
1129
+ if (node.ctecolnames !== undefined) {
1130
+ result.ctecolnames = Array.isArray(node.ctecolnames)
1131
+ ? node.ctecolnames.map((item) => this.transform(item, context))
1132
+ : this.transform(node.ctecolnames, context);
1133
+ }
1134
+ if (node.ctecoltypes !== undefined) {
1135
+ result.ctecoltypes = Array.isArray(node.ctecoltypes)
1136
+ ? node.ctecoltypes.map((item) => this.transform(item, context))
1137
+ : this.transform(node.ctecoltypes, context);
1138
+ }
1139
+ if (node.ctecoltypmods !== undefined) {
1140
+ result.ctecoltypmods = Array.isArray(node.ctecoltypmods)
1141
+ ? node.ctecoltypmods.map((item) => this.transform(item, context))
1142
+ : this.transform(node.ctecoltypmods, context);
1143
+ }
1144
+ if (node.ctecolcollations !== undefined) {
1145
+ result.ctecolcollations = Array.isArray(node.ctecolcollations)
1146
+ ? node.ctecolcollations.map((item) => this.transform(item, context))
1147
+ : this.transform(node.ctecolcollations, context);
1148
+ }
1149
+ return { CommonTableExpr: result };
1150
+ }
1151
+ ParamRef(node, context) {
1152
+ const result = {};
1153
+ if (node.number !== undefined) {
1154
+ result.number = node.number;
1155
+ }
1156
+ if (node.location !== undefined) {
1157
+ result.location = node.location;
1158
+ }
1159
+ return { ParamRef: result };
1160
+ }
1161
+ LockingClause(node, context) {
1162
+ const result = {};
1163
+ if (node.lockedRels !== undefined) {
1164
+ result.lockedRels = Array.isArray(node.lockedRels)
1165
+ ? node.lockedRels.map((item) => this.transform(item, context))
1166
+ : this.transform(node.lockedRels, context);
1167
+ }
1168
+ if (node.strength !== undefined) {
1169
+ result.strength = node.strength;
1170
+ }
1171
+ if (node.waitPolicy !== undefined) {
1172
+ result.waitPolicy = node.waitPolicy;
1173
+ }
1174
+ return { LockingClause: result };
1175
+ }
1176
+ MinMaxExpr(node, context) {
1177
+ const result = {};
1178
+ if (node.xpr !== undefined) {
1179
+ result.xpr = this.transform(node.xpr, context);
1180
+ }
1181
+ if (node.minmaxtype !== undefined) {
1182
+ result.minmaxtype = node.minmaxtype;
1183
+ }
1184
+ if (node.minmaxcollid !== undefined) {
1185
+ result.minmaxcollid = node.minmaxcollid;
1186
+ }
1187
+ if (node.inputcollid !== undefined) {
1188
+ result.inputcollid = node.inputcollid;
1189
+ }
1190
+ if (node.op !== undefined) {
1191
+ result.op = node.op;
1192
+ }
1193
+ if (node.args !== undefined) {
1194
+ result.args = Array.isArray(node.args)
1195
+ ? node.args.map((item) => this.transform(item, context))
1196
+ : this.transform(node.args, context);
1197
+ }
1198
+ if (node.location !== undefined) {
1199
+ result.location = node.location;
1200
+ }
1201
+ return { MinMaxExpr: result };
1202
+ }
1203
+ RowExpr(node, context) {
1204
+ const result = {};
1205
+ if (node.xpr !== undefined) {
1206
+ result.xpr = this.transform(node.xpr, context);
1207
+ }
1208
+ if (node.args !== undefined) {
1209
+ result.args = Array.isArray(node.args)
1210
+ ? node.args.map((item) => this.transform(item, context))
1211
+ : this.transform(node.args, context);
1212
+ }
1213
+ if (node.row_typeid !== undefined) {
1214
+ result.row_typeid = node.row_typeid;
1215
+ }
1216
+ if (node.row_format !== undefined) {
1217
+ result.row_format = node.row_format;
1218
+ }
1219
+ if (node.colnames !== undefined) {
1220
+ result.colnames = Array.isArray(node.colnames)
1221
+ ? node.colnames.map((item) => this.transform(item, context))
1222
+ : this.transform(node.colnames, context);
1223
+ }
1224
+ if (node.location !== undefined) {
1225
+ result.location = node.location;
1226
+ }
1227
+ return { RowExpr: result };
1228
+ }
1229
+ OpExpr(node, context) {
1230
+ const result = {};
1231
+ if (node.xpr !== undefined) {
1232
+ result.xpr = this.transform(node.xpr, context);
1233
+ }
1234
+ if (node.opno !== undefined) {
1235
+ result.opno = node.opno;
1236
+ }
1237
+ if (node.opfuncid !== undefined) {
1238
+ result.opfuncid = node.opfuncid;
1239
+ }
1240
+ if (node.opresulttype !== undefined) {
1241
+ result.opresulttype = node.opresulttype;
1242
+ }
1243
+ if (node.opretset !== undefined) {
1244
+ result.opretset = node.opretset;
1245
+ }
1246
+ if (node.opcollid !== undefined) {
1247
+ result.opcollid = node.opcollid;
1248
+ }
1249
+ if (node.inputcollid !== undefined) {
1250
+ result.inputcollid = node.inputcollid;
1251
+ }
1252
+ if (node.args !== undefined) {
1253
+ result.args = Array.isArray(node.args)
1254
+ ? node.args.map((item) => this.transform(item, context))
1255
+ : this.transform(node.args, context);
1256
+ }
1257
+ if (node.location !== undefined) {
1258
+ result.location = node.location;
1259
+ }
1260
+ return { OpExpr: result };
1261
+ }
1262
+ DistinctExpr(node, context) {
1263
+ const result = {};
1264
+ if (node.xpr !== undefined) {
1265
+ result.xpr = this.transform(node.xpr, context);
1266
+ }
1267
+ if (node.opno !== undefined) {
1268
+ result.opno = node.opno;
1269
+ }
1270
+ if (node.opfuncid !== undefined) {
1271
+ result.opfuncid = node.opfuncid;
1272
+ }
1273
+ if (node.opresulttype !== undefined) {
1274
+ result.opresulttype = node.opresulttype;
1275
+ }
1276
+ if (node.opretset !== undefined) {
1277
+ result.opretset = node.opretset;
1278
+ }
1279
+ if (node.opcollid !== undefined) {
1280
+ result.opcollid = node.opcollid;
1281
+ }
1282
+ if (node.inputcollid !== undefined) {
1283
+ result.inputcollid = node.inputcollid;
1284
+ }
1285
+ if (node.args !== undefined) {
1286
+ result.args = Array.isArray(node.args)
1287
+ ? node.args.map((item) => this.transform(item, context))
1288
+ : this.transform(node.args, context);
1289
+ }
1290
+ if (node.location !== undefined) {
1291
+ result.location = node.location;
1292
+ }
1293
+ return { DistinctExpr: result };
1294
+ }
1295
+ NullIfExpr(node, context) {
1296
+ const result = {};
1297
+ if (node.xpr !== undefined) {
1298
+ result.xpr = this.transform(node.xpr, context);
1299
+ }
1300
+ if (node.opno !== undefined) {
1301
+ result.opno = node.opno;
1302
+ }
1303
+ if (node.opfuncid !== undefined) {
1304
+ result.opfuncid = node.opfuncid;
1305
+ }
1306
+ if (node.opresulttype !== undefined) {
1307
+ result.opresulttype = node.opresulttype;
1308
+ }
1309
+ if (node.opretset !== undefined) {
1310
+ result.opretset = node.opretset;
1311
+ }
1312
+ if (node.opcollid !== undefined) {
1313
+ result.opcollid = node.opcollid;
1314
+ }
1315
+ if (node.inputcollid !== undefined) {
1316
+ result.inputcollid = node.inputcollid;
1317
+ }
1318
+ if (node.args !== undefined) {
1319
+ result.args = Array.isArray(node.args)
1320
+ ? node.args.map((item) => this.transform(item, context))
1321
+ : this.transform(node.args, context);
1322
+ }
1323
+ if (node.location !== undefined) {
1324
+ result.location = node.location;
1325
+ }
1326
+ return { NullIfExpr: result };
1327
+ }
1328
+ ScalarArrayOpExpr(node, context) {
1329
+ const result = {};
1330
+ if (node.xpr !== undefined) {
1331
+ result.xpr = this.transform(node.xpr, context);
1332
+ }
1333
+ if (node.opno !== undefined) {
1334
+ result.opno = node.opno;
1335
+ }
1336
+ if (node.opfuncid !== undefined) {
1337
+ result.opfuncid = node.opfuncid;
1338
+ }
1339
+ if (node.hashfuncid !== undefined) {
1340
+ result.hashfuncid = node.hashfuncid;
1341
+ }
1342
+ if (node.useOr !== undefined) {
1343
+ result.useOr = node.useOr;
1344
+ }
1345
+ if (node.inputcollid !== undefined) {
1346
+ result.inputcollid = node.inputcollid;
1347
+ }
1348
+ if (node.args !== undefined) {
1349
+ result.args = Array.isArray(node.args)
1350
+ ? node.args.map((item) => this.transform(item, context))
1351
+ : this.transform(node.args, context);
1352
+ }
1353
+ if (node.location !== undefined) {
1354
+ result.location = node.location;
1355
+ }
1356
+ return { ScalarArrayOpExpr: result };
1357
+ }
1358
+ Aggref(node, context) {
1359
+ const result = {};
1360
+ if (node.xpr !== undefined) {
1361
+ result.xpr = this.transform(node.xpr, context);
1362
+ }
1363
+ if (node.aggfnoid !== undefined) {
1364
+ result.aggfnoid = node.aggfnoid;
1365
+ }
1366
+ if (node.aggtype !== undefined) {
1367
+ result.aggtype = node.aggtype;
1368
+ }
1369
+ if (node.aggcollid !== undefined) {
1370
+ result.aggcollid = node.aggcollid;
1371
+ }
1372
+ if (node.inputcollid !== undefined) {
1373
+ result.inputcollid = node.inputcollid;
1374
+ }
1375
+ if (node.aggtranstype !== undefined) {
1376
+ result.aggtranstype = node.aggtranstype;
1377
+ }
1378
+ if (node.aggargtypes !== undefined) {
1379
+ result.aggargtypes = Array.isArray(node.aggargtypes)
1380
+ ? node.aggargtypes.map((item) => this.transform(item, context))
1381
+ : this.transform(node.aggargtypes, context);
1382
+ }
1383
+ if (node.aggdirectargs !== undefined) {
1384
+ result.aggdirectargs = Array.isArray(node.aggdirectargs)
1385
+ ? node.aggdirectargs.map((item) => this.transform(item, context))
1386
+ : this.transform(node.aggdirectargs, context);
1387
+ }
1388
+ if (node.args !== undefined) {
1389
+ result.args = Array.isArray(node.args)
1390
+ ? node.args.map((item) => this.transform(item, context))
1391
+ : this.transform(node.args, context);
1392
+ }
1393
+ if (node.aggorder !== undefined) {
1394
+ result.aggorder = Array.isArray(node.aggorder)
1395
+ ? node.aggorder.map((item) => this.transform(item, context))
1396
+ : this.transform(node.aggorder, context);
1397
+ }
1398
+ if (node.aggdistinct !== undefined) {
1399
+ result.aggdistinct = Array.isArray(node.aggdistinct)
1400
+ ? node.aggdistinct.map((item) => this.transform(item, context))
1401
+ : this.transform(node.aggdistinct, context);
1402
+ }
1403
+ if (node.aggfilter !== undefined) {
1404
+ result.aggfilter = this.transform(node.aggfilter, context);
1405
+ }
1406
+ if (node.aggstar !== undefined) {
1407
+ result.aggstar = node.aggstar;
1408
+ }
1409
+ if (node.aggvariadic !== undefined) {
1410
+ result.aggvariadic = node.aggvariadic;
1411
+ }
1412
+ if (node.aggkind !== undefined) {
1413
+ result.aggkind = node.aggkind;
1414
+ }
1415
+ if (node.agglevelsup !== undefined) {
1416
+ result.agglevelsup = node.agglevelsup;
1417
+ }
1418
+ if (node.aggsplit !== undefined) {
1419
+ result.aggsplit = node.aggsplit;
1420
+ }
1421
+ if (node.aggno !== undefined) {
1422
+ result.aggno = node.aggno;
1423
+ }
1424
+ if (node.aggtransno !== undefined) {
1425
+ result.aggtransno = node.aggtransno;
1426
+ }
1427
+ if (node.location !== undefined) {
1428
+ result.location = node.location;
1429
+ }
1430
+ return { Aggref: result };
1431
+ }
1432
+ WindowFunc(node, context) {
1433
+ const result = {};
1434
+ if (node.xpr !== undefined) {
1435
+ result.xpr = this.transform(node.xpr, context);
1436
+ }
1437
+ if (node.winfnoid !== undefined) {
1438
+ result.winfnoid = node.winfnoid;
1439
+ }
1440
+ if (node.wintype !== undefined) {
1441
+ result.wintype = node.wintype;
1442
+ }
1443
+ if (node.wincollid !== undefined) {
1444
+ result.wincollid = node.wincollid;
1445
+ }
1446
+ if (node.inputcollid !== undefined) {
1447
+ result.inputcollid = node.inputcollid;
1448
+ }
1449
+ if (node.args !== undefined) {
1450
+ result.args = Array.isArray(node.args)
1451
+ ? node.args.map((item) => this.transform(item, context))
1452
+ : this.transform(node.args, context);
1453
+ }
1454
+ if (node.aggfilter !== undefined) {
1455
+ result.aggfilter = this.transform(node.aggfilter, context);
1456
+ }
1457
+ if (node.winref !== undefined) {
1458
+ result.winref = node.winref;
1459
+ }
1460
+ if (node.winstar !== undefined) {
1461
+ result.winstar = node.winstar;
1462
+ }
1463
+ if (node.winagg !== undefined) {
1464
+ result.winagg = node.winagg;
1465
+ }
1466
+ if (node.location !== undefined) {
1467
+ result.location = node.location;
1468
+ }
1469
+ return { WindowFunc: result };
1470
+ }
1471
+ FieldSelect(node, context) {
1472
+ const result = {};
1473
+ if (node.xpr !== undefined) {
1474
+ result.xpr = this.transform(node.xpr, context);
1475
+ }
1476
+ if (node.arg !== undefined) {
1477
+ result.arg = this.transform(node.arg, context);
1478
+ }
1479
+ if (node.fieldnum !== undefined) {
1480
+ result.fieldnum = node.fieldnum;
1481
+ }
1482
+ if (node.resulttype !== undefined) {
1483
+ result.resulttype = node.resulttype;
1484
+ }
1485
+ if (node.resulttypmod !== undefined) {
1486
+ result.resulttypmod = node.resulttypmod;
1487
+ }
1488
+ if (node.resultcollid !== undefined) {
1489
+ result.resultcollid = node.resultcollid;
1490
+ }
1491
+ return { FieldSelect: result };
1492
+ }
1493
+ RelabelType(node, context) {
1494
+ const result = {};
1495
+ if (node.xpr !== undefined) {
1496
+ result.xpr = this.transform(node.xpr, context);
1497
+ }
1498
+ if (node.arg !== undefined) {
1499
+ result.arg = this.transform(node.arg, context);
1500
+ }
1501
+ if (node.resulttype !== undefined) {
1502
+ result.resulttype = node.resulttype;
1503
+ }
1504
+ if (node.resulttypmod !== undefined) {
1505
+ result.resulttypmod = node.resulttypmod;
1506
+ }
1507
+ if (node.resultcollid !== undefined) {
1508
+ result.resultcollid = node.resultcollid;
1509
+ }
1510
+ if (node.relabelformat !== undefined) {
1511
+ result.relabelformat = node.relabelformat;
1512
+ }
1513
+ if (node.location !== undefined) {
1514
+ result.location = node.location;
1515
+ }
1516
+ return { RelabelType: result };
1517
+ }
1518
+ CoerceViaIO(node, context) {
1519
+ const result = {};
1520
+ if (node.xpr !== undefined) {
1521
+ result.xpr = this.transform(node.xpr, context);
1522
+ }
1523
+ if (node.arg !== undefined) {
1524
+ result.arg = this.transform(node.arg, context);
1525
+ }
1526
+ if (node.resulttype !== undefined) {
1527
+ result.resulttype = node.resulttype;
1528
+ }
1529
+ if (node.resultcollid !== undefined) {
1530
+ result.resultcollid = node.resultcollid;
1531
+ }
1532
+ if (node.coerceformat !== undefined) {
1533
+ result.coerceformat = node.coerceformat;
1534
+ }
1535
+ if (node.location !== undefined) {
1536
+ result.location = node.location;
1537
+ }
1538
+ return { CoerceViaIO: result };
1539
+ }
1540
+ ArrayCoerceExpr(node, context) {
1541
+ const result = {};
1542
+ if (node.xpr !== undefined) {
1543
+ result.xpr = this.transform(node.xpr, context);
1544
+ }
1545
+ if (node.arg !== undefined) {
1546
+ result.arg = this.transform(node.arg, context);
1547
+ }
1548
+ if (node.elemexpr !== undefined) {
1549
+ result.elemexpr = this.transform(node.elemexpr, context);
1550
+ }
1551
+ if (node.resulttype !== undefined) {
1552
+ result.resulttype = node.resulttype;
1553
+ }
1554
+ if (node.resulttypmod !== undefined) {
1555
+ result.resulttypmod = node.resulttypmod;
1556
+ }
1557
+ if (node.resultcollid !== undefined) {
1558
+ result.resultcollid = node.resultcollid;
1559
+ }
1560
+ if (node.coerceformat !== undefined) {
1561
+ result.coerceformat = node.coerceformat;
1562
+ }
1563
+ if (node.location !== undefined) {
1564
+ result.location = node.location;
1565
+ }
1566
+ return { ArrayCoerceExpr: result };
1567
+ }
1568
+ ConvertRowtypeExpr(node, context) {
1569
+ const result = {};
1570
+ if (node.xpr !== undefined) {
1571
+ result.xpr = this.transform(node.xpr, context);
1572
+ }
1573
+ if (node.arg !== undefined) {
1574
+ result.arg = this.transform(node.arg, context);
1575
+ }
1576
+ if (node.resulttype !== undefined) {
1577
+ result.resulttype = node.resulttype;
1578
+ }
1579
+ if (node.convertformat !== undefined) {
1580
+ result.convertformat = node.convertformat;
1581
+ }
1582
+ if (node.location !== undefined) {
1583
+ result.location = node.location;
1584
+ }
1585
+ return { ConvertRowtypeExpr: result };
1586
+ }
1587
+ NamedArgExpr(node, context) {
1588
+ const result = {};
1589
+ if (node.xpr !== undefined) {
1590
+ result.xpr = this.transform(node.xpr, context);
1591
+ }
1592
+ if (node.arg !== undefined) {
1593
+ result.arg = this.transform(node.arg, context);
1594
+ }
1595
+ if (node.name !== undefined) {
1596
+ result.name = node.name;
1597
+ }
1598
+ if (node.argnumber !== undefined) {
1599
+ result.argnumber = node.argnumber;
1600
+ }
1601
+ if (node.location !== undefined) {
1602
+ result.location = node.location;
1603
+ }
1604
+ return { NamedArgExpr: result };
1605
+ }
1606
+ ViewStmt(node, context) {
1607
+ const result = {};
1608
+ if (node.view !== undefined) {
1609
+ result.view = this.transform(node.view, context);
1610
+ }
1611
+ if (node.aliases !== undefined) {
1612
+ result.aliases = Array.isArray(node.aliases)
1613
+ ? node.aliases.map((item) => this.transform(item, context))
1614
+ : this.transform(node.aliases, context);
1615
+ }
1616
+ if (node.query !== undefined) {
1617
+ result.query = this.transform(node.query, context);
1618
+ }
1619
+ if (node.replace !== undefined) {
1620
+ result.replace = node.replace;
1621
+ }
1622
+ if (node.options !== undefined) {
1623
+ result.options = Array.isArray(node.options)
1624
+ ? node.options.map((item) => this.transform(item, context))
1625
+ : this.transform(node.options, context);
1626
+ }
1627
+ if (node.withCheckOption !== undefined) {
1628
+ result.withCheckOption = node.withCheckOption;
1629
+ }
1630
+ return { ViewStmt: result };
1631
+ }
1632
+ IndexStmt(node, context) {
1633
+ const result = {};
1634
+ if (node.idxname !== undefined) {
1635
+ result.idxname = node.idxname;
1636
+ }
1637
+ if (node.relation !== undefined) {
1638
+ result.relation = this.transform(node.relation, context);
1639
+ }
1640
+ if (node.accessMethod !== undefined) {
1641
+ result.accessMethod = node.accessMethod;
1642
+ }
1643
+ if (node.tableSpace !== undefined) {
1644
+ result.tableSpace = node.tableSpace;
1645
+ }
1646
+ if (node.indexParams !== undefined) {
1647
+ result.indexParams = Array.isArray(node.indexParams)
1648
+ ? node.indexParams.map((item) => this.transform(item, context))
1649
+ : this.transform(node.indexParams, context);
1650
+ }
1651
+ if (node.indexIncludingParams !== undefined) {
1652
+ result.indexIncludingParams = Array.isArray(node.indexIncludingParams)
1653
+ ? node.indexIncludingParams.map((item) => this.transform(item, context))
1654
+ : this.transform(node.indexIncludingParams, context);
1655
+ }
1656
+ if (node.options !== undefined) {
1657
+ result.options = Array.isArray(node.options)
1658
+ ? node.options.map((item) => this.transform(item, context))
1659
+ : this.transform(node.options, context);
1660
+ }
1661
+ if (node.whereClause !== undefined) {
1662
+ result.whereClause = this.transform(node.whereClause, context);
1663
+ }
1664
+ if (node.excludeOpNames !== undefined) {
1665
+ result.excludeOpNames = Array.isArray(node.excludeOpNames)
1666
+ ? node.excludeOpNames.map((item) => this.transform(item, context))
1667
+ : this.transform(node.excludeOpNames, context);
1668
+ }
1669
+ if (node.idxcomment !== undefined) {
1670
+ result.idxcomment = node.idxcomment;
1671
+ }
1672
+ if (node.indexOid !== undefined) {
1673
+ result.indexOid = node.indexOid;
1674
+ }
1675
+ if (node.oldNode !== undefined) {
1676
+ result.oldNode = node.oldNode;
1677
+ }
1678
+ if (node.oldCreateSubid !== undefined) {
1679
+ result.oldCreateSubid = node.oldCreateSubid;
1680
+ }
1681
+ if (node.oldFirstRelfilenodeSubid !== undefined) {
1682
+ result.oldFirstRelfilenodeSubid = node.oldFirstRelfilenodeSubid;
1683
+ }
1684
+ if (node.unique !== undefined) {
1685
+ result.unique = node.unique;
1686
+ }
1687
+ if (node.nulls_not_distinct !== undefined) {
1688
+ result.nulls_not_distinct = node.nulls_not_distinct;
1689
+ }
1690
+ if (node.primary !== undefined) {
1691
+ result.primary = node.primary;
1692
+ }
1693
+ if (node.isconstraint !== undefined) {
1694
+ result.isconstraint = node.isconstraint;
1695
+ }
1696
+ if (node.deferrable !== undefined) {
1697
+ result.deferrable = node.deferrable;
1698
+ }
1699
+ if (node.initdeferred !== undefined) {
1700
+ result.initdeferred = node.initdeferred;
1701
+ }
1702
+ if (node.transformed !== undefined) {
1703
+ result.transformed = node.transformed;
1704
+ }
1705
+ if (node.concurrent !== undefined) {
1706
+ result.concurrent = node.concurrent;
1707
+ }
1708
+ if (node.if_not_exists !== undefined) {
1709
+ result.if_not_exists = node.if_not_exists;
1710
+ }
1711
+ if (node.reset_default_tblspc !== undefined) {
1712
+ result.reset_default_tblspc = node.reset_default_tblspc;
1713
+ }
1714
+ return { IndexStmt: result };
1715
+ }
1716
+ IndexElem(node, context) {
1717
+ const result = {};
1718
+ if (node.name !== undefined) {
1719
+ result.name = node.name;
1720
+ }
1721
+ if (node.expr !== undefined) {
1722
+ result.expr = this.transform(node.expr, context);
1723
+ }
1724
+ if (node.indexcolname !== undefined) {
1725
+ result.indexcolname = node.indexcolname;
1726
+ }
1727
+ if (node.collation !== undefined) {
1728
+ result.collation = Array.isArray(node.collation)
1729
+ ? node.collation.map((item) => this.transform(item, context))
1730
+ : this.transform(node.collation, context);
1731
+ }
1732
+ if (node.opclass !== undefined) {
1733
+ result.opclass = Array.isArray(node.opclass)
1734
+ ? node.opclass.map((item) => this.transform(item, context))
1735
+ : this.transform(node.opclass, context);
1736
+ }
1737
+ if (node.opclassopts !== undefined) {
1738
+ result.opclassopts = Array.isArray(node.opclassopts)
1739
+ ? node.opclassopts.map((item) => this.transform(item, context))
1740
+ : this.transform(node.opclassopts, context);
1741
+ }
1742
+ if (node.ordering !== undefined) {
1743
+ result.ordering = node.ordering;
1744
+ }
1745
+ if (node.nulls_ordering !== undefined) {
1746
+ result.nulls_ordering = node.nulls_ordering;
1747
+ }
1748
+ return { IndexElem: result };
1749
+ }
1750
+ PartitionElem(node, context) {
1751
+ const result = {};
1752
+ if (node.name !== undefined) {
1753
+ result.name = node.name;
1754
+ }
1755
+ if (node.expr !== undefined) {
1756
+ result.expr = this.transform(node.expr, context);
1757
+ }
1758
+ if (node.collation !== undefined) {
1759
+ result.collation = Array.isArray(node.collation)
1760
+ ? node.collation.map((item) => this.transform(item, context))
1761
+ : this.transform(node.collation, context);
1762
+ }
1763
+ if (node.opclass !== undefined) {
1764
+ result.opclass = Array.isArray(node.opclass)
1765
+ ? node.opclass.map((item) => this.transform(item, context))
1766
+ : this.transform(node.opclass, context);
1767
+ }
1768
+ if (node.location !== undefined) {
1769
+ result.location = node.location;
1770
+ }
1771
+ return { PartitionElem: result };
1772
+ }
1773
+ PartitionCmd(node, context) {
1774
+ const result = {};
1775
+ if (node.name !== undefined) {
1776
+ result.name = this.transform(node.name, context);
1777
+ }
1778
+ if (node.bound !== undefined) {
1779
+ result.bound = this.transform(node.bound, context);
1780
+ }
1781
+ if (node.concurrent !== undefined) {
1782
+ result.concurrent = node.concurrent;
1783
+ }
1784
+ return { PartitionCmd: result };
1785
+ }
1786
+ JoinExpr(node, context) {
1787
+ const result = {};
1788
+ if (node.jointype !== undefined) {
1789
+ result.jointype = node.jointype;
1790
+ }
1791
+ if (node.isNatural !== undefined) {
1792
+ result.isNatural = node.isNatural;
1793
+ }
1794
+ if (node.larg !== undefined) {
1795
+ result.larg = this.transform(node.larg, context);
1796
+ }
1797
+ if (node.rarg !== undefined) {
1798
+ result.rarg = this.transform(node.rarg, context);
1799
+ }
1800
+ if (node.usingClause !== undefined) {
1801
+ result.usingClause = Array.isArray(node.usingClause)
1802
+ ? node.usingClause.map((item) => this.transform(item, context))
1803
+ : this.transform(node.usingClause, context);
1804
+ }
1805
+ if (node.join_using_alias !== undefined) {
1806
+ result.join_using_alias = this.transform(node.join_using_alias, context);
1807
+ }
1808
+ if (node.quals !== undefined) {
1809
+ result.quals = this.transform(node.quals, context);
1810
+ }
1811
+ if (node.alias !== undefined) {
1812
+ result.alias = this.transform(node.alias, context);
1813
+ }
1814
+ if (node.rtindex !== undefined) {
1815
+ result.rtindex = node.rtindex;
1816
+ }
1817
+ return { JoinExpr: result };
1818
+ }
1819
+ FromExpr(node, context) {
1820
+ const result = {};
1821
+ if (node.fromlist !== undefined) {
1822
+ result.fromlist = Array.isArray(node.fromlist)
1823
+ ? node.fromlist.map((item) => this.transform(item, context))
1824
+ : this.transform(node.fromlist, context);
1825
+ }
1826
+ if (node.quals !== undefined) {
1827
+ result.quals = this.transform(node.quals, context);
1828
+ }
1829
+ return { FromExpr: result };
1830
+ }
1831
+ TransactionStmt(node, context) {
1832
+ const result = {};
1833
+ if (node.kind !== undefined) {
1834
+ result.kind = node.kind;
1835
+ }
1836
+ if (node.options !== undefined) {
1837
+ result.options = Array.isArray(node.options)
1838
+ ? node.options.map((item) => this.transform(item, context))
1839
+ : this.transform(node.options, context);
1840
+ }
1841
+ if (node.savepoint_name !== undefined) {
1842
+ result.savepoint_name = node.savepoint_name;
1843
+ }
1844
+ if (node.gid !== undefined) {
1845
+ result.gid = node.gid;
1846
+ }
1847
+ if (node.chain !== undefined) {
1848
+ result.chain = node.chain;
1849
+ }
1850
+ return { TransactionStmt: result };
1851
+ }
1852
+ VariableSetStmt(node, context) {
1853
+ const result = {};
1854
+ if (node.kind !== undefined) {
1855
+ result.kind = node.kind;
1856
+ }
1857
+ if (node.name !== undefined) {
1858
+ result.name = node.name;
1859
+ }
1860
+ if (node.args !== undefined) {
1861
+ result.args = Array.isArray(node.args)
1862
+ ? node.args.map((item) => this.transform(item, context))
1863
+ : this.transform(node.args, context);
1864
+ }
1865
+ if (node.is_local !== undefined) {
1866
+ result.is_local = node.is_local;
1867
+ }
1868
+ return { VariableSetStmt: result };
1869
+ }
1870
+ VariableShowStmt(node, context) {
1871
+ const result = {};
1872
+ if (node.name !== undefined) {
1873
+ result.name = node.name;
1874
+ }
1875
+ return { VariableShowStmt: result };
1876
+ }
1877
+ CreateSchemaStmt(node, context) {
1878
+ const result = {};
1879
+ if (node.schemaname !== undefined) {
1880
+ result.schemaname = node.schemaname;
1881
+ }
1882
+ if (node.authrole !== undefined) {
1883
+ result.authrole = this.transform(node.authrole, context);
1884
+ }
1885
+ if (node.schemaElts !== undefined) {
1886
+ result.schemaElts = Array.isArray(node.schemaElts)
1887
+ ? node.schemaElts.map((item) => this.transform(item, context))
1888
+ : this.transform(node.schemaElts, context);
1889
+ }
1890
+ if (node.if_not_exists !== undefined) {
1891
+ result.if_not_exists = node.if_not_exists;
1892
+ }
1893
+ return { CreateSchemaStmt: result };
1894
+ }
1895
+ RoleSpec(node, context) {
1896
+ const result = {};
1897
+ if (node.roletype !== undefined) {
1898
+ result.roletype = node.roletype;
1899
+ }
1900
+ if (node.rolename !== undefined) {
1901
+ result.rolename = node.rolename;
1902
+ }
1903
+ if (node.location !== undefined) {
1904
+ result.location = node.location;
1905
+ }
1906
+ return { RoleSpec: result };
1907
+ }
1908
+ DropStmt(node, context) {
1909
+ const result = {};
1910
+ if (node.objects !== undefined) {
1911
+ result.objects = Array.isArray(node.objects)
1912
+ ? node.objects.map((item) => this.transform(item, context))
1913
+ : this.transform(node.objects, context);
1914
+ }
1915
+ if (node.removeType !== undefined) {
1916
+ result.removeType = node.removeType;
1917
+ }
1918
+ if (node.behavior !== undefined) {
1919
+ result.behavior = node.behavior;
1920
+ }
1921
+ if (node.missing_ok !== undefined) {
1922
+ result.missing_ok = node.missing_ok;
1923
+ }
1924
+ if (node.concurrent !== undefined) {
1925
+ result.concurrent = node.concurrent;
1926
+ }
1927
+ return { DropStmt: result };
1928
+ }
1929
+ TruncateStmt(node, context) {
1930
+ const result = {};
1931
+ if (node.relations !== undefined) {
1932
+ result.relations = Array.isArray(node.relations)
1933
+ ? node.relations.map((item) => this.transform(item, context))
1934
+ : this.transform(node.relations, context);
1935
+ }
1936
+ if (node.restart_seqs !== undefined) {
1937
+ result.restart_seqs = node.restart_seqs;
1938
+ }
1939
+ if (node.behavior !== undefined) {
1940
+ result.behavior = node.behavior;
1941
+ }
1942
+ return { TruncateStmt: result };
1943
+ }
1944
+ ReturnStmt(node, context) {
1945
+ const result = {};
1946
+ if (node.returnval !== undefined) {
1947
+ result.returnval = this.transform(node.returnval, context);
1948
+ }
1949
+ return { ReturnStmt: result };
1950
+ }
1951
+ PLAssignStmt(node, context) {
1952
+ const result = {};
1953
+ if (node.name !== undefined) {
1954
+ result.name = node.name;
1955
+ }
1956
+ if (node.indirection !== undefined) {
1957
+ result.indirection = Array.isArray(node.indirection)
1958
+ ? node.indirection.map((item) => this.transform(item, context))
1959
+ : this.transform(node.indirection, context);
1960
+ }
1961
+ if (node.nnames !== undefined) {
1962
+ result.nnames = node.nnames;
1963
+ }
1964
+ if (node.val !== undefined) {
1965
+ result.val = this.transform(node.val, context);
1966
+ }
1967
+ if (node.location !== undefined) {
1968
+ result.location = node.location;
1969
+ }
1970
+ return { PLAssignStmt: result };
1971
+ }
1972
+ CopyStmt(node, context) {
1973
+ const result = {};
1974
+ if (node.relation !== undefined) {
1975
+ result.relation = this.transform(node.relation, context);
1976
+ }
1977
+ if (node.query !== undefined) {
1978
+ result.query = this.transform(node.query, context);
1979
+ }
1980
+ if (node.attlist !== undefined) {
1981
+ result.attlist = Array.isArray(node.attlist)
1982
+ ? node.attlist.map((item) => this.transform(item, context))
1983
+ : this.transform(node.attlist, context);
1984
+ }
1985
+ if (node.is_from !== undefined) {
1986
+ result.is_from = node.is_from;
1987
+ }
1988
+ if (node.is_program !== undefined) {
1989
+ result.is_program = node.is_program;
1990
+ }
1991
+ if (node.filename !== undefined) {
1992
+ result.filename = node.filename;
1993
+ }
1994
+ if (node.options !== undefined) {
1995
+ result.options = Array.isArray(node.options)
1996
+ ? node.options.map((item) => this.transform(item, context))
1997
+ : this.transform(node.options, context);
1998
+ }
1999
+ if (node.whereClause !== undefined) {
2000
+ result.whereClause = this.transform(node.whereClause, context);
2001
+ }
2002
+ return { CopyStmt: result };
2003
+ }
2004
+ AlterTableStmt(node, context) {
2005
+ const result = {};
2006
+ if (node.relation !== undefined) {
2007
+ result.relation = this.transform(node.relation, context);
2008
+ }
2009
+ if (node.cmds !== undefined) {
2010
+ result.cmds = Array.isArray(node.cmds)
2011
+ ? node.cmds.map((item) => this.transform(item, context))
2012
+ : this.transform(node.cmds, context);
2013
+ }
2014
+ if (node.objtype !== undefined) {
2015
+ result.objtype = node.objtype;
2016
+ }
2017
+ if (node.missing_ok !== undefined) {
2018
+ result.missing_ok = node.missing_ok;
2019
+ }
2020
+ return { AlterTableStmt: result };
2021
+ }
2022
+ AlterTableCmd(node, context) {
2023
+ const result = {};
2024
+ if (node.subtype !== undefined) {
2025
+ result.subtype = node.subtype;
2026
+ }
2027
+ if (node.name !== undefined) {
2028
+ result.name = node.name;
2029
+ }
2030
+ if (node.num !== undefined) {
2031
+ result.num = node.num;
2032
+ }
2033
+ if (node.newowner !== undefined) {
2034
+ result.newowner = this.transform(node.newowner, context);
2035
+ }
2036
+ if (node.def !== undefined) {
2037
+ result.def = this.transform(node.def, context);
2038
+ }
2039
+ if (node.behavior !== undefined) {
2040
+ result.behavior = node.behavior;
2041
+ }
2042
+ if (node.missing_ok !== undefined) {
2043
+ result.missing_ok = node.missing_ok;
2044
+ }
2045
+ return { AlterTableCmd: result };
2046
+ }
2047
+ CreateFunctionStmt(node, context) {
2048
+ const result = {};
2049
+ if (node.is_procedure !== undefined) {
2050
+ result.is_procedure = node.is_procedure;
2051
+ }
2052
+ if (node.replace !== undefined) {
2053
+ result.replace = node.replace;
2054
+ }
2055
+ if (node.funcname !== undefined) {
2056
+ result.funcname = Array.isArray(node.funcname)
2057
+ ? node.funcname.map((item) => this.transform(item, context))
2058
+ : this.transform(node.funcname, context);
2059
+ }
2060
+ if (node.parameters !== undefined) {
2061
+ result.parameters = Array.isArray(node.parameters)
2062
+ ? node.parameters.map((item) => this.transform(item, context))
2063
+ : this.transform(node.parameters, context);
2064
+ }
2065
+ if (node.returnType !== undefined) {
2066
+ result.returnType = this.transform(node.returnType, context);
2067
+ }
2068
+ if (node.options !== undefined) {
2069
+ result.options = Array.isArray(node.options)
2070
+ ? node.options.map((item) => this.transform(item, context))
2071
+ : this.transform(node.options, context);
2072
+ }
2073
+ if (node.sql_body !== undefined) {
2074
+ result.sql_body = this.transform(node.sql_body, context);
2075
+ }
2076
+ return { CreateFunctionStmt: result };
2077
+ }
2078
+ FunctionParameter(node, context) {
2079
+ const result = {};
2080
+ if (node.name !== undefined) {
2081
+ result.name = node.name;
2082
+ }
2083
+ if (node.argType !== undefined) {
2084
+ result.argType = this.transform(node.argType, context);
2085
+ }
2086
+ if (node.mode !== undefined) {
2087
+ result.mode = node.mode;
2088
+ }
2089
+ if (node.defexpr !== undefined) {
2090
+ result.defexpr = this.transform(node.defexpr, context);
2091
+ }
2092
+ return { FunctionParameter: result };
2093
+ }
2094
+ CompositeTypeStmt(node, context) {
2095
+ const result = {};
2096
+ if (node.typevar !== undefined) {
2097
+ result.typevar = this.transform(node.typevar, context);
2098
+ }
2099
+ if (node.coldeflist !== undefined) {
2100
+ result.coldeflist = Array.isArray(node.coldeflist)
2101
+ ? node.coldeflist.map((item) => this.transform(item, context))
2102
+ : this.transform(node.coldeflist, context);
2103
+ }
2104
+ return { CompositeTypeStmt: result };
2105
+ }
2106
+ DoStmt(node, context) {
2107
+ const result = {};
2108
+ if (node.args !== undefined) {
2109
+ result.args = Array.isArray(node.args)
2110
+ ? node.args.map((item) => this.transform(item, context))
2111
+ : this.transform(node.args, context);
2112
+ }
2113
+ return { DoStmt: result };
2114
+ }
2115
+ DefineStmt(node, context) {
2116
+ const result = {};
2117
+ if (node.kind !== undefined) {
2118
+ result.kind = node.kind;
2119
+ }
2120
+ if (node.oldstyle !== undefined) {
2121
+ result.oldstyle = node.oldstyle;
2122
+ }
2123
+ if (node.defnames !== undefined) {
2124
+ result.defnames = Array.isArray(node.defnames)
2125
+ ? node.defnames.map((item) => this.transform(item, context))
2126
+ : this.transform(node.defnames, context);
2127
+ }
2128
+ if (node.args !== undefined) {
2129
+ result.args = Array.isArray(node.args)
2130
+ ? node.args.map((item) => this.transform(item, context))
2131
+ : this.transform(node.args, context);
2132
+ }
2133
+ if (node.definition !== undefined) {
2134
+ result.definition = Array.isArray(node.definition)
2135
+ ? node.definition.map((item) => this.transform(item, context))
2136
+ : this.transform(node.definition, context);
2137
+ }
2138
+ if (node.if_not_exists !== undefined) {
2139
+ result.if_not_exists = node.if_not_exists;
2140
+ }
2141
+ if (node.replace !== undefined) {
2142
+ result.replace = node.replace;
2143
+ }
2144
+ return { DefineStmt: result };
2145
+ }
2146
+ RangeSubselect(node, context) {
2147
+ const result = {};
2148
+ if (node.lateral !== undefined) {
2149
+ result.lateral = node.lateral;
2150
+ }
2151
+ if (node.subquery !== undefined) {
2152
+ result.subquery = this.transform(node.subquery, context);
2153
+ }
2154
+ if (node.alias !== undefined) {
2155
+ result.alias = this.transform(node.alias, context);
2156
+ }
2157
+ return { RangeSubselect: result };
2158
+ }
2159
+ CreateEnumStmt(node, context) {
2160
+ const result = {};
2161
+ if (node.typeName !== undefined) {
2162
+ result.typeName = Array.isArray(node.typeName)
2163
+ ? node.typeName.map((item) => this.transform(item, context))
2164
+ : this.transform(node.typeName, context);
2165
+ }
2166
+ if (node.vals !== undefined) {
2167
+ result.vals = Array.isArray(node.vals)
2168
+ ? node.vals.map((item) => this.transform(item, context))
2169
+ : this.transform(node.vals, context);
2170
+ }
2171
+ return { CreateEnumStmt: result };
2172
+ }
2173
+ CreateDomainStmt(node, context) {
2174
+ const result = {};
2175
+ if (node.domainname !== undefined) {
2176
+ result.domainname = Array.isArray(node.domainname)
2177
+ ? node.domainname.map((item) => this.transform(item, context))
2178
+ : this.transform(node.domainname, context);
2179
+ }
2180
+ if (node.typeName !== undefined) {
2181
+ result.typeName = this.transform(node.typeName, context);
2182
+ }
2183
+ if (node.collClause !== undefined) {
2184
+ result.collClause = this.transform(node.collClause, context);
2185
+ }
2186
+ if (node.constraints !== undefined) {
2187
+ result.constraints = Array.isArray(node.constraints)
2188
+ ? node.constraints.map((item) => this.transform(item, context))
2189
+ : this.transform(node.constraints, context);
2190
+ }
2191
+ return { CreateDomainStmt: result };
2192
+ }
2193
+ CreateRoleStmt(node, context) {
2194
+ const result = {};
2195
+ if (node.stmt_type !== undefined) {
2196
+ result.stmt_type = node.stmt_type;
2197
+ }
2198
+ if (node.role !== undefined) {
2199
+ result.role = node.role;
2200
+ }
2201
+ if (node.options !== undefined) {
2202
+ result.options = Array.isArray(node.options)
2203
+ ? node.options.map((item) => this.transform(item, context))
2204
+ : this.transform(node.options, context);
2205
+ }
2206
+ return { CreateRoleStmt: result };
2207
+ }
2208
+ DefElem(node, context) {
2209
+ const result = {};
2210
+ if (node.defnamespace !== undefined) {
2211
+ result.defnamespace = node.defnamespace;
2212
+ }
2213
+ if (node.defname !== undefined) {
2214
+ result.defname = node.defname;
2215
+ }
2216
+ if (node.arg !== undefined) {
2217
+ result.arg = this.transform(node.arg, context);
2218
+ }
2219
+ if (node.defaction !== undefined) {
2220
+ result.defaction = node.defaction;
2221
+ }
2222
+ if (node.location !== undefined) {
2223
+ result.location = node.location;
2224
+ }
2225
+ return { DefElem: result };
2226
+ }
2227
+ CreateTableSpaceStmt(node, context) {
2228
+ const result = {};
2229
+ if (node.tablespacename !== undefined) {
2230
+ result.tablespacename = node.tablespacename;
2231
+ }
2232
+ if (node.owner !== undefined) {
2233
+ result.owner = this.transform(node.owner, context);
2234
+ }
2235
+ if (node.location !== undefined) {
2236
+ result.location = node.location;
2237
+ }
2238
+ if (node.options !== undefined) {
2239
+ result.options = Array.isArray(node.options)
2240
+ ? node.options.map((item) => this.transform(item, context))
2241
+ : this.transform(node.options, context);
2242
+ }
2243
+ return { CreateTableSpaceStmt: result };
2244
+ }
2245
+ DropTableSpaceStmt(node, context) {
2246
+ const result = {};
2247
+ if (node.tablespacename !== undefined) {
2248
+ result.tablespacename = node.tablespacename;
2249
+ }
2250
+ if (node.missing_ok !== undefined) {
2251
+ result.missing_ok = node.missing_ok;
2252
+ }
2253
+ return { DropTableSpaceStmt: result };
2254
+ }
2255
+ AlterTableSpaceOptionsStmt(node, context) {
2256
+ const result = {};
2257
+ if (node.tablespacename !== undefined) {
2258
+ result.tablespacename = node.tablespacename;
2259
+ }
2260
+ if (node.options !== undefined) {
2261
+ result.options = Array.isArray(node.options)
2262
+ ? node.options.map((item) => this.transform(item, context))
2263
+ : this.transform(node.options, context);
2264
+ }
2265
+ if (node.isReset !== undefined) {
2266
+ result.isReset = node.isReset;
2267
+ }
2268
+ return { AlterTableSpaceOptionsStmt: result };
2269
+ }
2270
+ CreateExtensionStmt(node, context) {
2271
+ const result = {};
2272
+ if (node.extname !== undefined) {
2273
+ result.extname = node.extname;
2274
+ }
2275
+ if (node.if_not_exists !== undefined) {
2276
+ result.if_not_exists = node.if_not_exists;
2277
+ }
2278
+ if (node.options !== undefined) {
2279
+ result.options = Array.isArray(node.options)
2280
+ ? node.options.map((item) => this.transform(item, context))
2281
+ : this.transform(node.options, context);
2282
+ }
2283
+ return { CreateExtensionStmt: result };
2284
+ }
2285
+ AlterExtensionStmt(node, context) {
2286
+ const result = {};
2287
+ if (node.extname !== undefined) {
2288
+ result.extname = node.extname;
2289
+ }
2290
+ if (node.options !== undefined) {
2291
+ result.options = Array.isArray(node.options)
2292
+ ? node.options.map((item) => this.transform(item, context))
2293
+ : this.transform(node.options, context);
2294
+ }
2295
+ return { AlterExtensionStmt: result };
2296
+ }
2297
+ CreateFdwStmt(node, context) {
2298
+ const result = { ...node };
2299
+ return { CreateFdwStmt: result };
2300
+ }
2301
+ SetOperationStmt(node, context) {
2302
+ const result = { ...node };
2303
+ return { SetOperationStmt: result };
2304
+ }
2305
+ ReplicaIdentityStmt(node, context) {
2306
+ const result = { ...node };
2307
+ return { ReplicaIdentityStmt: result };
2308
+ }
2309
+ AlterCollationStmt(node, context) {
2310
+ const result = { ...node };
2311
+ return { AlterCollationStmt: result };
2312
+ }
2313
+ AlterDomainStmt(node, context) {
2314
+ const result = { ...node };
2315
+ return { AlterDomainStmt: result };
2316
+ }
2317
+ PrepareStmt(node, context) {
2318
+ const result = { ...node };
2319
+ return { PrepareStmt: result };
2320
+ }
2321
+ ExecuteStmt(node, context) {
2322
+ const result = { ...node };
2323
+ return { ExecuteStmt: result };
2324
+ }
2325
+ DeallocateStmt(node, context) {
2326
+ const result = { ...node };
2327
+ return { DeallocateStmt: result };
2328
+ }
2329
+ NotifyStmt(node, context) {
2330
+ const result = { ...node };
2331
+ return { NotifyStmt: result };
2332
+ }
2333
+ ListenStmt(node, context) {
2334
+ const result = { ...node };
2335
+ return { ListenStmt: result };
2336
+ }
2337
+ UnlistenStmt(node, context) {
2338
+ const result = { ...node };
2339
+ return { UnlistenStmt: result };
2340
+ }
2341
+ CheckPointStmt(node, context) {
2342
+ const result = { ...node };
2343
+ return { CheckPointStmt: result };
2344
+ }
2345
+ LoadStmt(node, context) {
2346
+ const result = { ...node };
2347
+ return { LoadStmt: result };
2348
+ }
2349
+ DiscardStmt(node, context) {
2350
+ const result = { ...node };
2351
+ return { DiscardStmt: result };
2352
+ }
2353
+ CommentStmt(node, context) {
2354
+ const result = {};
2355
+ if (node.objtype !== undefined) {
2356
+ result.objtype = node.objtype;
2357
+ }
2358
+ if (node.object !== undefined) {
2359
+ result.object = this.transform(node.object, context);
2360
+ }
2361
+ if (node.comment !== undefined) {
2362
+ result.comment = node.comment;
2363
+ }
2364
+ return { CommentStmt: result };
2365
+ }
2366
+ LockStmt(node, context) {
2367
+ const result = { ...node };
2368
+ return { LockStmt: result };
2369
+ }
2370
+ CreatePolicyStmt(node, context) {
2371
+ const result = { ...node };
2372
+ return { CreatePolicyStmt: result };
2373
+ }
2374
+ AlterPolicyStmt(node, context) {
2375
+ const result = { ...node };
2376
+ return { AlterPolicyStmt: result };
2377
+ }
2378
+ CreateUserMappingStmt(node, context) {
2379
+ const result = { ...node };
2380
+ return { CreateUserMappingStmt: result };
2381
+ }
2382
+ CreateStatsStmt(node, context) {
2383
+ const result = { ...node };
2384
+ return { CreateStatsStmt: result };
2385
+ }
2386
+ StatsElem(node, context) {
2387
+ const result = { ...node };
2388
+ return { StatsElem: result };
2389
+ }
2390
+ CreatePublicationStmt(node, context) {
2391
+ const result = { ...node };
2392
+ return { CreatePublicationStmt: result };
2393
+ }
2394
+ CreateSubscriptionStmt(node, context) {
2395
+ const result = { ...node };
2396
+ return { CreateSubscriptionStmt: result };
2397
+ }
2398
+ AlterPublicationStmt(node, context) {
2399
+ const result = { ...node };
2400
+ return { AlterPublicationStmt: result };
2401
+ }
2402
+ AlterSubscriptionStmt(node, context) {
2403
+ const result = { ...node };
2404
+ return { AlterSubscriptionStmt: result };
2405
+ }
2406
+ DropSubscriptionStmt(node, context) {
2407
+ const result = { ...node };
2408
+ return { DropSubscriptionStmt: result };
2409
+ }
2410
+ InlineCodeBlock(node, context) {
2411
+ const result = { ...node };
2412
+ return { InlineCodeBlock: result };
2413
+ }
2414
+ CallContext(node, context) {
2415
+ const result = { ...node };
2416
+ return { CallContext: result };
2417
+ }
2418
+ ConstraintsSetStmt(node, context) {
2419
+ const result = { ...node };
2420
+ return { ConstraintsSetStmt: result };
2421
+ }
2422
+ AlterSystemStmt(node, context) {
2423
+ const result = { ...node };
2424
+ return { AlterSystemStmt: result };
2425
+ }
2426
+ VacuumRelation(node, context) {
2427
+ const result = { ...node };
2428
+ return { VacuumRelation: result };
2429
+ }
2430
+ DropOwnedStmt(node, context) {
2431
+ const result = { ...node };
2432
+ return { DropOwnedStmt: result };
2433
+ }
2434
+ ReassignOwnedStmt(node, context) {
2435
+ const result = { ...node };
2436
+ return { ReassignOwnedStmt: result };
2437
+ }
2438
+ AlterTSDictionaryStmt(node, context) {
2439
+ const result = { ...node };
2440
+ return { AlterTSDictionaryStmt: result };
2441
+ }
2442
+ AlterTSConfigurationStmt(node, context) {
2443
+ const result = { ...node };
2444
+ return { AlterTSConfigurationStmt: result };
2445
+ }
2446
+ ClosePortalStmt(node, context) {
2447
+ const result = { ...node };
2448
+ return { ClosePortalStmt: result };
2449
+ }
2450
+ FetchStmt(node, context) {
2451
+ const result = { ...node };
2452
+ return { FetchStmt: result };
2453
+ }
2454
+ AlterStatsStmt(node, context) {
2455
+ const result = { ...node };
2456
+ return { AlterStatsStmt: result };
2457
+ }
2458
+ ObjectWithArgs(node, context) {
2459
+ const result = { ...node };
2460
+ return { ObjectWithArgs: result };
2461
+ }
2462
+ AlterOperatorStmt(node, context) {
2463
+ const result = { ...node };
2464
+ return { AlterOperatorStmt: result };
2465
+ }
2466
+ AlterFdwStmt(node, context) {
2467
+ const result = { ...node };
2468
+ return { AlterFdwStmt: result };
2469
+ }
2470
+ CreateForeignServerStmt(node, context) {
2471
+ const result = { ...node };
2472
+ return { CreateForeignServerStmt: result };
2473
+ }
2474
+ AlterForeignServerStmt(node, context) {
2475
+ const result = { ...node };
2476
+ return { AlterForeignServerStmt: result };
2477
+ }
2478
+ AlterUserMappingStmt(node, context) {
2479
+ const result = { ...node };
2480
+ return { AlterUserMappingStmt: result };
2481
+ }
2482
+ DropUserMappingStmt(node, context) {
2483
+ const result = { ...node };
2484
+ return { DropUserMappingStmt: result };
2485
+ }
2486
+ ImportForeignSchemaStmt(node, context) {
2487
+ const result = { ...node };
2488
+ return { ImportForeignSchemaStmt: result };
2489
+ }
2490
+ ClusterStmt(node, context) {
2491
+ const result = { ...node };
2492
+ return { ClusterStmt: result };
2493
+ }
2494
+ VacuumStmt(node, context) {
2495
+ const result = { ...node };
2496
+ return { VacuumStmt: result };
2497
+ }
2498
+ ExplainStmt(node, context) {
2499
+ const result = { ...node };
2500
+ return { ExplainStmt: result };
2501
+ }
2502
+ ReindexStmt(node, context) {
2503
+ const result = { ...node };
2504
+ return { ReindexStmt: result };
2505
+ }
2506
+ CallStmt(node, context) {
2507
+ const result = { ...node };
2508
+ return { CallStmt: result };
2509
+ }
2510
+ CreatedbStmt(node, context) {
2511
+ const result = { ...node };
2512
+ return { CreatedbStmt: result };
2513
+ }
2514
+ DropdbStmt(node, context) {
2515
+ const result = { ...node };
2516
+ return { DropdbStmt: result };
2517
+ }
2518
+ RenameStmt(node, context) {
2519
+ const result = { ...node };
2520
+ return { RenameStmt: result };
2521
+ }
2522
+ AlterOwnerStmt(node, context) {
2523
+ const result = { ...node };
2524
+ return { AlterOwnerStmt: result };
2525
+ }
2526
+ GrantRoleStmt(node, context) {
2527
+ const result = {};
2528
+ if (node.granted_roles !== undefined) {
2529
+ result.granted_roles = Array.isArray(node.granted_roles)
2530
+ ? node.granted_roles.map((item) => this.transform(item, context))
2531
+ : this.transform(node.granted_roles, context);
2532
+ }
2533
+ if (node.grantee_roles !== undefined) {
2534
+ result.grantee_roles = Array.isArray(node.grantee_roles)
2535
+ ? node.grantee_roles.map((item) => this.transform(item, context))
2536
+ : this.transform(node.grantee_roles, context);
2537
+ }
2538
+ if (node.is_grant !== undefined) {
2539
+ result.is_grant = node.is_grant;
2540
+ }
2541
+ if (node.behavior !== undefined) {
2542
+ result.behavior = node.behavior;
2543
+ }
2544
+ const nodeAny = node;
2545
+ if (nodeAny.admin_opt === true) {
2546
+ result.opt = [
2547
+ {
2548
+ DefElem: {
2549
+ defname: "admin",
2550
+ arg: {
2551
+ Boolean: {
2552
+ boolval: true
2553
+ }
2554
+ },
2555
+ defaction: "DEFELEM_UNSPEC"
2556
+ }
2557
+ }
2558
+ ];
2559
+ }
2560
+ else if (nodeAny.opt !== undefined) {
2561
+ // Handle any existing opt field by transforming it
2562
+ result.opt = Array.isArray(nodeAny.opt)
2563
+ ? nodeAny.opt.map((item) => this.transform(item, context))
2564
+ : this.transform(nodeAny.opt, context);
2565
+ }
2566
+ return { GrantRoleStmt: result };
2567
+ }
2568
+ SecLabelStmt(node, context) {
2569
+ const result = { ...node };
2570
+ return { SecLabelStmt: result };
2571
+ }
2572
+ AlterDefaultPrivilegesStmt(node, context) {
2573
+ const result = { ...node };
2574
+ return { AlterDefaultPrivilegesStmt: result };
2575
+ }
2576
+ CreateConversionStmt(node, context) {
2577
+ const result = { ...node };
2578
+ return { CreateConversionStmt: result };
2579
+ }
2580
+ CreateCastStmt(node, context) {
2581
+ const result = { ...node };
2582
+ return { CreateCastStmt: result };
2583
+ }
2584
+ CreatePLangStmt(node, context) {
2585
+ const result = { ...node };
2586
+ return { CreatePLangStmt: result };
2587
+ }
2588
+ CreateTransformStmt(node, context) {
2589
+ const result = { ...node };
2590
+ return { CreateTransformStmt: result };
2591
+ }
2592
+ CreateTrigStmt(node, context) {
2593
+ const result = { ...node };
2594
+ return { CreateTrigStmt: result };
2595
+ }
2596
+ TriggerTransition(node, context) {
2597
+ const result = { ...node };
2598
+ return { TriggerTransition: result };
2599
+ }
2600
+ CreateEventTrigStmt(node, context) {
2601
+ const result = { ...node };
2602
+ return { CreateEventTrigStmt: result };
2603
+ }
2604
+ AlterEventTrigStmt(node, context) {
2605
+ const result = { ...node };
2606
+ return { AlterEventTrigStmt: result };
2607
+ }
2608
+ CreateOpClassStmt(node, context) {
2609
+ const result = { ...node };
2610
+ return { CreateOpClassStmt: result };
2611
+ }
2612
+ CreateOpFamilyStmt(node, context) {
2613
+ const result = { ...node };
2614
+ return { CreateOpFamilyStmt: result };
2615
+ }
2616
+ AlterOpFamilyStmt(node, context) {
2617
+ const result = { ...node };
2618
+ return { AlterOpFamilyStmt: result };
2619
+ }
2620
+ MergeStmt(node, context) {
2621
+ const result = { ...node };
2622
+ return { MergeStmt: result };
2623
+ }
2624
+ AlterTableMoveAllStmt(node, context) {
2625
+ const result = { ...node };
2626
+ return { AlterTableMoveAllStmt: result };
2627
+ }
2628
+ CreateSeqStmt(node, context) {
2629
+ const result = { ...node };
2630
+ return { CreateSeqStmt: result };
2631
+ }
2632
+ AlterSeqStmt(node, context) {
2633
+ const result = { ...node };
2634
+ return { AlterSeqStmt: result };
2635
+ }
2636
+ CreateRangeStmt(node, context) {
2637
+ const result = {};
2638
+ if (node.typeName !== undefined) {
2639
+ result.typeName = Array.isArray(node.typeName)
2640
+ ? node.typeName.map((item) => this.transform(item, context))
2641
+ : this.transform(node.typeName, context);
2642
+ }
2643
+ if (node.params !== undefined) {
2644
+ result.params = Array.isArray(node.params)
2645
+ ? node.params.map((item) => this.transform(item, context))
2646
+ : this.transform(node.params, context);
2647
+ }
2648
+ return { CreateRangeStmt: result };
2649
+ }
2650
+ AlterEnumStmt(node, context) {
2651
+ const result = { ...node };
2652
+ return { AlterEnumStmt: result };
2653
+ }
2654
+ AlterTypeStmt(node, context) {
2655
+ const result = { ...node };
2656
+ return { AlterTypeStmt: result };
2657
+ }
2658
+ AlterRoleStmt(node, context) {
2659
+ const result = { ...node };
2660
+ return { AlterRoleStmt: result };
2661
+ }
2662
+ CreateTableAsStmt(node, context) {
2663
+ const result = { ...node };
2664
+ return { CreateTableAsStmt: result };
2665
+ }
2666
+ RefreshMatViewStmt(node, context) {
2667
+ const result = { ...node };
2668
+ return { RefreshMatViewStmt: result };
2669
+ }
2670
+ AccessPriv(node, context) {
2671
+ const result = { ...node };
2672
+ return { AccessPriv: result };
2673
+ }
2674
+ AlterDatabaseStmt(node, context) {
2675
+ const result = { ...node };
2676
+ return { AlterDatabaseStmt: result };
2677
+ }
2678
+ AlterDatabaseRefreshCollStmt(node, context) {
2679
+ const result = { ...node };
2680
+ return { AlterDatabaseRefreshCollStmt: result };
2681
+ }
2682
+ AlterDatabaseSetStmt(node, context) {
2683
+ const result = { ...node };
2684
+ return { AlterDatabaseSetStmt: result };
2685
+ }
2686
+ DeclareCursorStmt(node, context) {
2687
+ const result = { ...node };
2688
+ return { DeclareCursorStmt: result };
2689
+ }
2690
+ PublicationObjSpec(node, context) {
2691
+ const result = { ...node };
2692
+ return { PublicationObjSpec: result };
2693
+ }
2694
+ PublicationTable(node, context) {
2695
+ const result = { ...node };
2696
+ return { PublicationTable: result };
2697
+ }
2698
+ CreateAmStmt(node, context) {
2699
+ const result = { ...node };
2700
+ return { CreateAmStmt: result };
2701
+ }
2702
+ IntoClause(node, context) {
2703
+ const result = { ...node };
2704
+ return { IntoClause: result };
2705
+ }
2706
+ OnConflictExpr(node, context) {
2707
+ const result = { ...node };
2708
+ return { OnConflictExpr: result };
2709
+ }
2710
+ ScanToken(node, context) {
2711
+ const result = { ...node };
2712
+ return { ScanToken: result };
2713
+ }
2714
+ CreateOpClassItem(node, context) {
2715
+ const result = { ...node };
2716
+ return { CreateOpClassItem: result };
2717
+ }
2718
+ Var(node, context) {
2719
+ const result = { ...node };
2720
+ return { Var: result };
2721
+ }
2722
+ TableFunc(node, context) {
2723
+ const result = { ...node };
2724
+ return { TableFunc: result };
2725
+ }
2726
+ RangeTableFunc(node, context) {
2727
+ const result = { ...node };
2728
+ return { RangeTableFunc: result };
2729
+ }
2730
+ RangeTableFuncCol(node, context) {
2731
+ const result = { ...node };
2732
+ return { RangeTableFuncCol: result };
2733
+ }
2734
+ RangeFunction(node, context) {
2735
+ const result = { ...node };
2736
+ if (node.lateral !== undefined) {
2737
+ result.lateral = node.lateral;
2738
+ }
2739
+ if (node.ordinality !== undefined) {
2740
+ result.ordinality = node.ordinality;
2741
+ }
2742
+ if (node.is_rowsfrom !== undefined) {
2743
+ result.is_rowsfrom = node.is_rowsfrom;
2744
+ }
2745
+ if (node.functions !== undefined) {
2746
+ result.functions = Array.isArray(node.functions)
2747
+ ? node.functions.map((item) => this.transform(item, context))
2748
+ : this.transform(node.functions, context);
2749
+ }
2750
+ if (node.alias !== undefined) {
2751
+ result.alias = this.transform(node.alias, context);
2752
+ }
2753
+ if (node.coldeflist !== undefined) {
2754
+ result.coldeflist = Array.isArray(node.coldeflist)
2755
+ ? node.coldeflist.map((item) => this.transform(item, context))
2756
+ : this.transform(node.coldeflist, context);
2757
+ }
2758
+ return { RangeFunction: result };
2759
+ }
2760
+ RangeTableSample(node, context) {
2761
+ const result = { ...node };
2762
+ if (node.relation !== undefined) {
2763
+ result.relation = this.transform(node.relation, context);
2764
+ }
2765
+ if (node.method !== undefined) {
2766
+ result.method = Array.isArray(node.method)
2767
+ ? node.method.map((item) => this.transform(item, context))
2768
+ : this.transform(node.method, context);
2769
+ }
2770
+ if (node.args !== undefined) {
2771
+ result.args = Array.isArray(node.args)
2772
+ ? node.args.map((item) => this.transform(item, context))
2773
+ : this.transform(node.args, context);
2774
+ }
2775
+ if (node.repeatable !== undefined) {
2776
+ result.repeatable = this.transform(node.repeatable, context);
2777
+ }
2778
+ return { RangeTableSample: result };
2779
+ }
2780
+ XmlSerialize(node, context) {
2781
+ const result = { ...node };
2782
+ if (node.xmloption !== undefined) {
2783
+ result.xmloption = node.xmloption;
2784
+ }
2785
+ if (node.expr !== undefined) {
2786
+ result.expr = this.transform(node.expr, context);
2787
+ }
2788
+ if (node.typeName !== undefined) {
2789
+ result.typeName = this.transform(node.typeName, context);
2790
+ }
2791
+ if (node.location !== undefined) {
2792
+ result.location = node.location;
2793
+ }
2794
+ return { XmlSerialize: result };
2795
+ }
2796
+ RuleStmt(node, context) {
2797
+ const result = { ...node };
2798
+ return { RuleStmt: result };
2799
+ }
2800
+ SQLValueFunction(node, context) {
2801
+ const result = { ...node };
2802
+ return { SQLValueFunction: result };
2803
+ }
2804
+ GroupingFunc(node, context) {
2805
+ const result = { ...node };
2806
+ return { GroupingFunc: result };
2807
+ }
2808
+ MultiAssignRef(node, context) {
2809
+ const result = { ...node };
2810
+ return { MultiAssignRef: result };
2811
+ }
2812
+ SetToDefault(node, context) {
2813
+ const result = { ...node };
2814
+ return { SetToDefault: result };
2815
+ }
2816
+ CurrentOfExpr(node, context) {
2817
+ const result = { ...node };
2818
+ return { CurrentOfExpr: result };
2819
+ }
2820
+ TableLikeClause(node, context) {
2821
+ const result = { ...node };
2822
+ return { TableLikeClause: result };
2823
+ }
2824
+ AlterFunctionStmt(node, context) {
2825
+ const result = { ...node };
2826
+ return { AlterFunctionStmt: result };
2827
+ }
2828
+ AlterObjectSchemaStmt(node, context) {
2829
+ const result = { ...node };
2830
+ return { AlterObjectSchemaStmt: result };
2831
+ }
2832
+ CreateForeignTableStmt(node, context) {
2833
+ const result = { ...node };
2834
+ return { CreateForeignTableStmt: result };
2835
+ }
2836
+ DropRoleStmt(node, context) {
2837
+ const result = { ...node };
2838
+ if (node.missing_ok !== undefined) {
2839
+ result.missing_ok = node.missing_ok;
2840
+ }
2841
+ if (node.roles !== undefined) {
2842
+ result.roles = Array.isArray(node.roles)
2843
+ ? node.roles.map((item) => this.transform(item, context))
2844
+ : this.transform(node.roles, context);
2845
+ }
2846
+ return { DropRoleStmt: result };
2847
+ }
2848
+ XmlExpr(node, context) {
2849
+ const result = { ...node };
2850
+ if (node.xpr !== undefined) {
2851
+ result.xpr = this.transform(node.xpr, context);
2852
+ }
2853
+ if (node.op !== undefined) {
2854
+ result.op = node.op;
2855
+ }
2856
+ if (node.name !== undefined) {
2857
+ result.name = node.name;
2858
+ }
2859
+ if (node.named_args !== undefined) {
2860
+ result.named_args = Array.isArray(node.named_args)
2861
+ ? node.named_args.map((item) => this.transform(item, context))
2862
+ : this.transform(node.named_args, context);
2863
+ }
2864
+ if (node.arg_names !== undefined) {
2865
+ result.arg_names = Array.isArray(node.arg_names)
2866
+ ? node.arg_names.map((item) => this.transform(item, context))
2867
+ : this.transform(node.arg_names, context);
2868
+ }
2869
+ if (node.args !== undefined) {
2870
+ result.args = Array.isArray(node.args)
2871
+ ? node.args.map((item) => this.transform(item, context))
2872
+ : this.transform(node.args, context);
2873
+ }
2874
+ if (node.xmloption !== undefined) {
2875
+ result.xmloption = node.xmloption;
2876
+ }
2877
+ if (node.type !== undefined) {
2878
+ result.type = node.type;
2879
+ }
2880
+ if (node.typmod !== undefined) {
2881
+ result.typmod = node.typmod;
2882
+ }
2883
+ if (node.location !== undefined) {
2884
+ result.location = node.location;
2885
+ }
2886
+ return { XmlExpr: result };
2887
+ }
2888
+ AlterRoleSetStmt(node, context) {
2889
+ const result = { ...node };
2890
+ if (node.role !== undefined) {
2891
+ result.role = this.transform(node.role, context);
2892
+ }
2893
+ if (node.database !== undefined) {
2894
+ result.database = node.database;
2895
+ }
2896
+ if (node.setstmt !== undefined) {
2897
+ result.setstmt = this.transform(node.setstmt, context);
2898
+ }
2899
+ return { AlterRoleSetStmt: result };
2900
+ }
2901
+ GrantStmt(node, context) {
2902
+ const result = { ...node };
2903
+ if (node.is_grant !== undefined) {
2904
+ result.is_grant = node.is_grant;
2905
+ }
2906
+ if (node.targtype !== undefined) {
2907
+ result.targtype = node.targtype;
2908
+ }
2909
+ if (node.objtype !== undefined) {
2910
+ result.objtype = node.objtype;
2911
+ }
2912
+ if (node.objects !== undefined) {
2913
+ result.objects = Array.isArray(node.objects)
2914
+ ? node.objects.map((item) => this.transform(item, context))
2915
+ : this.transform(node.objects, context);
2916
+ }
2917
+ if (node.privileges !== undefined) {
2918
+ result.privileges = Array.isArray(node.privileges)
2919
+ ? node.privileges.map((item) => this.transform(item, context))
2920
+ : this.transform(node.privileges, context);
2921
+ }
2922
+ if (node.grantees !== undefined) {
2923
+ result.grantees = Array.isArray(node.grantees)
2924
+ ? node.grantees.map((item) => this.transform(item, context))
2925
+ : this.transform(node.grantees, context);
2926
+ }
2927
+ if (node.grant_option !== undefined) {
2928
+ result.grant_option = node.grant_option;
2929
+ }
2930
+ if (node.behavior !== undefined) {
2931
+ result.behavior = node.behavior;
2932
+ }
2933
+ return { GrantStmt: result };
2934
+ }
2935
+ }