/
ast.py
3939 lines (3207 loc) · 164 KB
/
ast.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
# :Project: pglast -- DO NOT EDIT: automatically extracted from struct_defs.json @ 13-2.1.1-0-g7eb584d
# :Author: Lele Gaifax <lele@metapensiero.it>
# :License: GNU General Public License version 3 or later
# :Copyright: © 2021-2022 Lele Gaifax
#
from collections import namedtuple
from decimal import Decimal
from enum import Enum
SlotTypeInfo = namedtuple('SlotTypeInfo', ['c_type', 'py_type', 'adaptor'])
def _serialize_node(n, depth, ellipsis, skip_none):
d = {'@': n.__class__.__name__}
for a in n:
v = _serialize_value(getattr(n, a), depth, ellipsis, skip_none)
if not skip_none or v is not None:
d[a] = v
return d
def _serialize_value(v, depth, ellipsis, skip_none):
if isinstance(v, Node):
if depth is None or depth > 0:
v = _serialize_node(v, None if depth is None else depth - 1,
ellipsis, skip_none)
else:
v = ellipsis
elif isinstance(v, tuple):
if depth is None or depth > 0:
v = tuple(_serialize_value(i, None if depth is None else depth - 1,
ellipsis, skip_none)
for i in v)
else:
v = ellipsis
elif isinstance(v, Enum):
v = {'#': v.__class__.__name__, 'name': v.name, 'value': v.value}
return v
class Omissis:
def __eq__(self, other):
if other is ... or other is self:
return True
return False
def __repr__(self):
return '…'
Omissis = Omissis()
"Marker value used as default for the ellipsis argument"
class Node:
"Base class for all AST nodes."
__slots__ = ('ancestors',)
def __init__(self, data):
if not isinstance(data, dict): # pragma: no cover
raise ValueError(f'Bad argument, expected a dictionary, got {type(data)!r}')
if '@' not in data: # pragma: no cover
raise ValueError('Bad argument, expected a dictionary with a "@" key')
if data['@'] != self.__class__.__name__:
raise ValueError(f'Bad argument, wrong "@" value, expected'
f' {self.__class__.__name__!r}, got {data["@"]!r}')
G = globals()
for a in self:
v = data.get(a)
if v is not None:
if isinstance(v, dict) and '@' in v:
v = G[v['@']](v)
elif isinstance(v, (tuple, list)):
v = tuple(G[i['@']](i) if isinstance(i, dict) and '@' in i else i
for i in v)
setattr(self, a, v)
def __iter__(self):
"Iterate over all attribute names of this node."
return iter(self.__slots__)
def __repr__(self):
"Build a representation of the whole node and its subtree, for debug."
attrs = []
for a in self:
if a != 'location':
v = getattr(self, a)
if v is not None:
attrs.append(f'{a}={v!r}')
if attrs:
attrs = ' ' + ' '.join(attrs)
else:
attrs = ''
return '<' + self.__class__.__name__ + attrs + '>'
def __eq__(self, other):
'''
Compare two nodes, returning ``True`` if they are considered equivalent.
This is mainly an helper method used by tests: for this reason, two nodes are
considered equal when all their attributes match, ignoring *positional* ones such as
``location``, ``stmt_len`` and ``stmt_location``.
'''
if not isinstance(other, type(self)):
return False
for a in self:
if ((a not in ('location', 'stmt_len', 'stmt_location')
and getattr(self, a) != getattr(other, a))):
return False
return True
def __call__(self, depth=None, ellipsis=Omissis, skip_none=False):
'''Serialize the node as a structure made of simple Python data-types.
:type depth: ``None`` or ``int``
:param depth: if not ``None``, the maximum depth to reach
:param ellipsis: the marker value that will be used to replace cut-off branch
:param bool skip_none: whether ``None``-valued attributes should be elided
:param bool enum_name: whether Enums will be rendered as their name only
:return: a :class:`dict` instance
This performs a top-down recursive visit to the whole AST tree: each :class:`Node`
instance becomes a dictionary with a special ``@`` key carrying the node type, lists
becomes tuples and ``Enum`` instances become dictionaries with a special ``#`` key
carrying the enum name.'''
return _serialize_node(self, depth, ellipsis, skip_none)
def __setattr__(self, name, value):
'''Validate the given `value` and if acceptable assign it to the `name` attribute.
This tries to coerce the given `value` accordingly with the *ctype* of the
attribute, raising opportune exception when that is not possible.
'''
if value is not None and name in self.__slots__:
ctype, ptype, adaptor = self.__slots__[name]
if not isinstance(ptype, tuple):
ptype = (ptype,)
if not isinstance(value, ptype):
raise ValueError(f'Bad value for attribute {self.__class__.__name__}'
f'.{name}, expected {ptype}, got {type(value)}:'
f' {value!r}')
if adaptor is not None:
value = adaptor(value)
elif ctype != 'char*':
from pglast import enums
if hasattr(enums, ctype):
enum = getattr(enums, ctype)
if not isinstance(value, enum):
if isinstance(value, dict) and '#' in value:
if value['#'] != ctype:
raise ValueError(f'Bad value for attribute'
f' {self.__class__.__name__}.{name},'
f' expected a {ptype}, got'
f' {value!r}') from None
if 'name' in value:
value = value['name']
elif 'value' in value:
value = value['value']
else:
raise ValueError(f'Bad value for attribute'
f' {self.__class__.__name__}.{name},'
f' expected a {ptype}, got'
f' {value!r}') from None
try:
if isinstance(value, str) and len(value) > 1:
value = enum[value]
else:
value = enum(value)
except (KeyError, ValueError):
raise ValueError(f'Bad value for attribute'
f' {self.__class__.__name__}.{name},'
f' expected a {ptype}, got'
f' {value!r}') from None
else:
if ctype.endswith('*'):
cls = globals().get(ctype[:-1])
if cls is None:
raise NotImplementedError(f'Unhandled {ctype!r} for attribute'
f' {self.__class__.__name__}.{name}')
if isinstance(value, dict) and '@' in value:
value = cls(value)
super().__setattr__(name, value)
class Expr(Node):
'''Abstract super class of several *expression* classes.'''
__slots__ = ()
class Value(Node):
'''Abstract super class, representing PG's `Value`__ union type.
__ https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/value.h
'''
__slots__ = ()
def __init__(self, value=None):
if ((value is not None
and isinstance(value, dict)
and '@' in value)):
super().__init__(value)
else:
self.val = value
class BitString(Value):
'''Implement the ``T_BitString`` variant of the :class:`Value` union.'''
__slots__ = {'val': SlotTypeInfo('char*', str, None)}
class Float(Value):
'''Implement the ``T_Float`` variant of the :class:`Value` union.'''
__slots__ = {'val': SlotTypeInfo('char*', (str, Decimal), Decimal)}
class Integer(Value):
'''Implement the ``T_Integer`` variant of the :class:`Value` union.'''
__slots__ = {'val': SlotTypeInfo('char*', int, None)}
class Null(Value):
'''Implement the ``T_Null`` variant of the :class:`Value` union.'''
__slots__ = {'val': SlotTypeInfo('char*', type(None), None)}
class String(Value):
'''Implement the ``T_String`` variant of the :class:`Value` union.'''
__slots__ = {'val': SlotTypeInfo('char*', str, None)}
class A_ArrayExpr(Node):
__slots__ = {'elements': 'List*', 'location': 'int'} # noqa: E501
def __init__(self, elements=None, location=None): # pragma: no cover # noqa: E501
if ((elements is not None
and location is None # noqa: E501
and isinstance(elements, dict)
and '@' in elements)):
super().__init__(elements)
else:
self.elements = elements
self.location = location
class A_Const(Node):
__slots__ = {'val': 'Value', 'location': 'int'} # noqa: E501
def __init__(self, val=None, location=None): # pragma: no cover # noqa: E501
if ((val is not None
and location is None # noqa: E501
and isinstance(val, dict)
and '@' in val)):
super().__init__(val)
else:
self.val = val
self.location = location
class A_Expr(Node):
__slots__ = {'kind': 'A_Expr_Kind', 'name': 'List*', 'lexpr': 'Node*', 'rexpr': 'Node*', 'location': 'int'} # noqa: E501
def __init__(self, kind=None, name=None, lexpr=None, rexpr=None, location=None): # pragma: no cover # noqa: E501
if ((kind is not None
and name is lexpr is rexpr is location is None # noqa: E501
and isinstance(kind, dict)
and '@' in kind)):
super().__init__(kind)
else:
self.kind = kind
self.name = name
self.lexpr = lexpr
self.rexpr = rexpr
self.location = location
class A_Indices(Node):
__slots__ = {'is_slice': 'bool', 'lidx': 'Node*', 'uidx': 'Node*'} # noqa: E501
def __init__(self, is_slice=None, lidx=None, uidx=None): # pragma: no cover # noqa: E501
if ((is_slice is not None
and lidx is uidx is None # noqa: E501
and isinstance(is_slice, dict)
and '@' in is_slice)):
super().__init__(is_slice)
else:
self.is_slice = is_slice
self.lidx = lidx
self.uidx = uidx
class A_Indirection(Node):
__slots__ = {'arg': 'Node*', 'indirection': 'List*'} # noqa: E501
def __init__(self, arg=None, indirection=None): # pragma: no cover # noqa: E501
if ((arg is not None
and indirection is None # noqa: E501
and isinstance(arg, dict)
and '@' in arg)):
super().__init__(arg)
else:
self.arg = arg
self.indirection = indirection
class A_Star(Node):
__slots__ = {} # noqa: E501
def __init__(self): # pragma: no cover
pass
class AccessPriv(Node):
__slots__ = {'priv_name': 'char*', 'cols': 'List*'} # noqa: E501
def __init__(self, priv_name=None, cols=None): # pragma: no cover # noqa: E501
if ((priv_name is not None
and cols is None # noqa: E501
and isinstance(priv_name, dict)
and '@' in priv_name)):
super().__init__(priv_name)
else:
self.priv_name = priv_name
self.cols = cols
class Aggref(Expr):
__slots__ = {'aggargtypes': 'List*', 'aggdirectargs': 'List*', 'args': 'List*', 'aggorder': 'List*', 'aggdistinct': 'List*', 'aggfilter': 'Expr*', 'aggstar': 'bool', 'aggvariadic': 'bool', 'aggkind': 'char', 'agglevelsup': 'Index', 'aggsplit': 'AggSplit', 'location': 'int'} # noqa: E501
def __init__(self, aggargtypes=None, aggdirectargs=None, args=None, aggorder=None, aggdistinct=None, aggfilter=None, aggstar=None, aggvariadic=None, aggkind=None, agglevelsup=None, aggsplit=None, location=None): # pragma: no cover # noqa: E501
if ((aggargtypes is not None
and aggdirectargs is args is aggorder is aggdistinct is aggfilter is aggstar is aggvariadic is aggkind is agglevelsup is aggsplit is location is None # noqa: E501
and isinstance(aggargtypes, dict)
and '@' in aggargtypes)):
super().__init__(aggargtypes)
else:
self.aggargtypes = aggargtypes
self.aggdirectargs = aggdirectargs
self.args = args
self.aggorder = aggorder
self.aggdistinct = aggdistinct
self.aggfilter = aggfilter
self.aggstar = aggstar
self.aggvariadic = aggvariadic
self.aggkind = aggkind
self.agglevelsup = agglevelsup
self.aggsplit = aggsplit
self.location = location
class Alias(Node):
__slots__ = {'aliasname': 'char*', 'colnames': 'List*'} # noqa: E501
def __init__(self, aliasname=None, colnames=None): # pragma: no cover # noqa: E501
if ((aliasname is not None
and colnames is None # noqa: E501
and isinstance(aliasname, dict)
and '@' in aliasname)):
super().__init__(aliasname)
else:
self.aliasname = aliasname
self.colnames = colnames
class AlterCollationStmt(Node):
__slots__ = {'collname': 'List*'} # noqa: E501
def __init__(self, collname=None): # pragma: no cover # noqa: E501
if ((collname is not None
and isinstance(collname, dict)
and '@' in collname)):
super().__init__(collname)
else:
self.collname = collname
class AlterDatabaseSetStmt(Node):
__slots__ = {'dbname': 'char*', 'setstmt': 'VariableSetStmt*'} # noqa: E501
def __init__(self, dbname=None, setstmt=None): # pragma: no cover # noqa: E501
if ((dbname is not None
and setstmt is None # noqa: E501
and isinstance(dbname, dict)
and '@' in dbname)):
super().__init__(dbname)
else:
self.dbname = dbname
self.setstmt = setstmt
class AlterDatabaseStmt(Node):
__slots__ = {'dbname': 'char*', 'options': 'List*'} # noqa: E501
def __init__(self, dbname=None, options=None): # pragma: no cover # noqa: E501
if ((dbname is not None
and options is None # noqa: E501
and isinstance(dbname, dict)
and '@' in dbname)):
super().__init__(dbname)
else:
self.dbname = dbname
self.options = options
class AlterDefaultPrivilegesStmt(Node):
__slots__ = {'options': 'List*', 'action': 'GrantStmt*'} # noqa: E501
def __init__(self, options=None, action=None): # pragma: no cover # noqa: E501
if ((options is not None
and action is None # noqa: E501
and isinstance(options, dict)
and '@' in options)):
super().__init__(options)
else:
self.options = options
self.action = action
class AlterDomainStmt(Node):
__slots__ = {'subtype': 'char', 'typeName': 'List*', 'name': 'char*', 'def_': 'Node*', 'behavior': 'DropBehavior', 'missing_ok': 'bool'} # noqa: E501
def __init__(self, subtype=None, typeName=None, name=None, def_=None, behavior=None, missing_ok=None): # pragma: no cover # noqa: E501
if ((subtype is not None
and typeName is name is def_ is behavior is missing_ok is None # noqa: E501
and isinstance(subtype, dict)
and '@' in subtype)):
super().__init__(subtype)
else:
self.subtype = subtype
self.typeName = typeName
self.name = name
self.def_ = def_
self.behavior = behavior
self.missing_ok = missing_ok
class AlterEnumStmt(Node):
__slots__ = {'typeName': 'List*', 'oldVal': 'char*', 'newVal': 'char*', 'newValNeighbor': 'char*', 'newValIsAfter': 'bool', 'skipIfNewValExists': 'bool'} # noqa: E501
def __init__(self, typeName=None, oldVal=None, newVal=None, newValNeighbor=None, newValIsAfter=None, skipIfNewValExists=None): # pragma: no cover # noqa: E501
if ((typeName is not None
and oldVal is newVal is newValNeighbor is newValIsAfter is skipIfNewValExists is None # noqa: E501
and isinstance(typeName, dict)
and '@' in typeName)):
super().__init__(typeName)
else:
self.typeName = typeName
self.oldVal = oldVal
self.newVal = newVal
self.newValNeighbor = newValNeighbor
self.newValIsAfter = newValIsAfter
self.skipIfNewValExists = skipIfNewValExists
class AlterEventTrigStmt(Node):
__slots__ = {'trigname': 'char*', 'tgenabled': 'char'} # noqa: E501
def __init__(self, trigname=None, tgenabled=None): # pragma: no cover # noqa: E501
if ((trigname is not None
and tgenabled is None # noqa: E501
and isinstance(trigname, dict)
and '@' in trigname)):
super().__init__(trigname)
else:
self.trigname = trigname
self.tgenabled = tgenabled
class AlterExtensionContentsStmt(Node):
__slots__ = {'extname': 'char*', 'action': 'int', 'objtype': 'ObjectType', 'object': 'Node*'} # noqa: E501
def __init__(self, extname=None, action=None, objtype=None, object=None): # pragma: no cover # noqa: E501
if ((extname is not None
and action is objtype is object is None # noqa: E501
and isinstance(extname, dict)
and '@' in extname)):
super().__init__(extname)
else:
self.extname = extname
self.action = action
self.objtype = objtype
self.object = object
class AlterExtensionStmt(Node):
__slots__ = {'extname': 'char*', 'options': 'List*'} # noqa: E501
def __init__(self, extname=None, options=None): # pragma: no cover # noqa: E501
if ((extname is not None
and options is None # noqa: E501
and isinstance(extname, dict)
and '@' in extname)):
super().__init__(extname)
else:
self.extname = extname
self.options = options
class AlterFdwStmt(Node):
__slots__ = {'fdwname': 'char*', 'func_options': 'List*', 'options': 'List*'} # noqa: E501
def __init__(self, fdwname=None, func_options=None, options=None): # pragma: no cover # noqa: E501
if ((fdwname is not None
and func_options is options is None # noqa: E501
and isinstance(fdwname, dict)
and '@' in fdwname)):
super().__init__(fdwname)
else:
self.fdwname = fdwname
self.func_options = func_options
self.options = options
class AlterForeignServerStmt(Node):
__slots__ = {'servername': 'char*', 'version': 'char*', 'options': 'List*', 'has_version': 'bool'} # noqa: E501
def __init__(self, servername=None, version=None, options=None, has_version=None): # pragma: no cover # noqa: E501
if ((servername is not None
and version is options is has_version is None # noqa: E501
and isinstance(servername, dict)
and '@' in servername)):
super().__init__(servername)
else:
self.servername = servername
self.version = version
self.options = options
self.has_version = has_version
class AlterFunctionStmt(Node):
__slots__ = {'objtype': 'ObjectType', 'func': 'ObjectWithArgs*', 'actions': 'List*'} # noqa: E501
def __init__(self, objtype=None, func=None, actions=None): # pragma: no cover # noqa: E501
if ((objtype is not None
and func is actions is None # noqa: E501
and isinstance(objtype, dict)
and '@' in objtype)):
super().__init__(objtype)
else:
self.objtype = objtype
self.func = func
self.actions = actions
class AlterObjectDependsStmt(Node):
__slots__ = {'objectType': 'ObjectType', 'relation': 'RangeVar*', 'object': 'Node*', 'extname': 'Value*', 'remove': 'bool'} # noqa: E501
def __init__(self, objectType=None, relation=None, object=None, extname=None, remove=None): # pragma: no cover # noqa: E501
if ((objectType is not None
and relation is object is extname is remove is None # noqa: E501
and isinstance(objectType, dict)
and '@' in objectType)):
super().__init__(objectType)
else:
self.objectType = objectType
self.relation = relation
self.object = object
self.extname = extname
self.remove = remove
class AlterObjectSchemaStmt(Node):
__slots__ = {'objectType': 'ObjectType', 'relation': 'RangeVar*', 'object': 'Node*', 'newschema': 'char*', 'missing_ok': 'bool'} # noqa: E501
def __init__(self, objectType=None, relation=None, object=None, newschema=None, missing_ok=None): # pragma: no cover # noqa: E501
if ((objectType is not None
and relation is object is newschema is missing_ok is None # noqa: E501
and isinstance(objectType, dict)
and '@' in objectType)):
super().__init__(objectType)
else:
self.objectType = objectType
self.relation = relation
self.object = object
self.newschema = newschema
self.missing_ok = missing_ok
class AlterOpFamilyStmt(Node):
__slots__ = {'opfamilyname': 'List*', 'amname': 'char*', 'isDrop': 'bool', 'items': 'List*'} # noqa: E501
def __init__(self, opfamilyname=None, amname=None, isDrop=None, items=None): # pragma: no cover # noqa: E501
if ((opfamilyname is not None
and amname is isDrop is items is None # noqa: E501
and isinstance(opfamilyname, dict)
and '@' in opfamilyname)):
super().__init__(opfamilyname)
else:
self.opfamilyname = opfamilyname
self.amname = amname
self.isDrop = isDrop
self.items = items
class AlterOperatorStmt(Node):
__slots__ = {'opername': 'ObjectWithArgs*', 'options': 'List*'} # noqa: E501
def __init__(self, opername=None, options=None): # pragma: no cover # noqa: E501
if ((opername is not None
and options is None # noqa: E501
and isinstance(opername, dict)
and '@' in opername)):
super().__init__(opername)
else:
self.opername = opername
self.options = options
class AlterOwnerStmt(Node):
__slots__ = {'objectType': 'ObjectType', 'relation': 'RangeVar*', 'object': 'Node*', 'newowner': 'RoleSpec*'} # noqa: E501
def __init__(self, objectType=None, relation=None, object=None, newowner=None): # pragma: no cover # noqa: E501
if ((objectType is not None
and relation is object is newowner is None # noqa: E501
and isinstance(objectType, dict)
and '@' in objectType)):
super().__init__(objectType)
else:
self.objectType = objectType
self.relation = relation
self.object = object
self.newowner = newowner
class AlterPolicyStmt(Node):
__slots__ = {'policy_name': 'char*', 'table': 'RangeVar*', 'roles': 'List*', 'qual': 'Node*', 'with_check': 'Node*'} # noqa: E501
def __init__(self, policy_name=None, table=None, roles=None, qual=None, with_check=None): # pragma: no cover # noqa: E501
if ((policy_name is not None
and table is roles is qual is with_check is None # noqa: E501
and isinstance(policy_name, dict)
and '@' in policy_name)):
super().__init__(policy_name)
else:
self.policy_name = policy_name
self.table = table
self.roles = roles
self.qual = qual
self.with_check = with_check
class AlterPublicationStmt(Node):
__slots__ = {'pubname': 'char*', 'options': 'List*', 'tables': 'List*', 'for_all_tables': 'bool', 'tableAction': 'DefElemAction'} # noqa: E501
def __init__(self, pubname=None, options=None, tables=None, for_all_tables=None, tableAction=None): # pragma: no cover # noqa: E501
if ((pubname is not None
and options is tables is for_all_tables is tableAction is None # noqa: E501
and isinstance(pubname, dict)
and '@' in pubname)):
super().__init__(pubname)
else:
self.pubname = pubname
self.options = options
self.tables = tables
self.for_all_tables = for_all_tables
self.tableAction = tableAction
class AlterRoleSetStmt(Node):
__slots__ = {'role': 'RoleSpec*', 'database': 'char*', 'setstmt': 'VariableSetStmt*'} # noqa: E501
def __init__(self, role=None, database=None, setstmt=None): # pragma: no cover # noqa: E501
if ((role is not None
and database is setstmt is None # noqa: E501
and isinstance(role, dict)
and '@' in role)):
super().__init__(role)
else:
self.role = role
self.database = database
self.setstmt = setstmt
class AlterRoleStmt(Node):
__slots__ = {'role': 'RoleSpec*', 'options': 'List*', 'action': 'int'} # noqa: E501
def __init__(self, role=None, options=None, action=None): # pragma: no cover # noqa: E501
if ((role is not None
and options is action is None # noqa: E501
and isinstance(role, dict)
and '@' in role)):
super().__init__(role)
else:
self.role = role
self.options = options
self.action = action
class AlterSeqStmt(Node):
__slots__ = {'sequence': 'RangeVar*', 'options': 'List*', 'for_identity': 'bool', 'missing_ok': 'bool'} # noqa: E501
def __init__(self, sequence=None, options=None, for_identity=None, missing_ok=None): # pragma: no cover # noqa: E501
if ((sequence is not None
and options is for_identity is missing_ok is None # noqa: E501
and isinstance(sequence, dict)
and '@' in sequence)):
super().__init__(sequence)
else:
self.sequence = sequence
self.options = options
self.for_identity = for_identity
self.missing_ok = missing_ok
class AlterStatsStmt(Node):
__slots__ = {'defnames': 'List*', 'stxstattarget': 'int', 'missing_ok': 'bool'} # noqa: E501
def __init__(self, defnames=None, stxstattarget=None, missing_ok=None): # pragma: no cover # noqa: E501
if ((defnames is not None
and stxstattarget is missing_ok is None # noqa: E501
and isinstance(defnames, dict)
and '@' in defnames)):
super().__init__(defnames)
else:
self.defnames = defnames
self.stxstattarget = stxstattarget
self.missing_ok = missing_ok
class AlterSubscriptionStmt(Node):
__slots__ = {'kind': 'AlterSubscriptionType', 'subname': 'char*', 'conninfo': 'char*', 'publication': 'List*', 'options': 'List*'} # noqa: E501
def __init__(self, kind=None, subname=None, conninfo=None, publication=None, options=None): # pragma: no cover # noqa: E501
if ((kind is not None
and subname is conninfo is publication is options is None # noqa: E501
and isinstance(kind, dict)
and '@' in kind)):
super().__init__(kind)
else:
self.kind = kind
self.subname = subname
self.conninfo = conninfo
self.publication = publication
self.options = options
class AlterSystemStmt(Node):
__slots__ = {'setstmt': 'VariableSetStmt*'} # noqa: E501
def __init__(self, setstmt=None): # pragma: no cover # noqa: E501
if ((setstmt is not None
and isinstance(setstmt, dict)
and '@' in setstmt)):
super().__init__(setstmt)
else:
self.setstmt = setstmt
class AlterTSConfigurationStmt(Node):
__slots__ = {'kind': 'AlterTSConfigType', 'cfgname': 'List*', 'tokentype': 'List*', 'dicts': 'List*', 'override': 'bool', 'replace': 'bool', 'missing_ok': 'bool'} # noqa: E501
def __init__(self, kind=None, cfgname=None, tokentype=None, dicts=None, override=None, replace=None, missing_ok=None): # pragma: no cover # noqa: E501
if ((kind is not None
and cfgname is tokentype is dicts is override is replace is missing_ok is None # noqa: E501
and isinstance(kind, dict)
and '@' in kind)):
super().__init__(kind)
else:
self.kind = kind
self.cfgname = cfgname
self.tokentype = tokentype
self.dicts = dicts
self.override = override
self.replace = replace
self.missing_ok = missing_ok
class AlterTSDictionaryStmt(Node):
__slots__ = {'dictname': 'List*', 'options': 'List*'} # noqa: E501
def __init__(self, dictname=None, options=None): # pragma: no cover # noqa: E501
if ((dictname is not None
and options is None # noqa: E501
and isinstance(dictname, dict)
and '@' in dictname)):
super().__init__(dictname)
else:
self.dictname = dictname
self.options = options
class AlterTableCmd(Node):
__slots__ = {'subtype': 'AlterTableType', 'name': 'char*', 'num': 'int16', 'newowner': 'RoleSpec*', 'def_': 'Node*', 'behavior': 'DropBehavior', 'missing_ok': 'bool'} # noqa: E501
def __init__(self, subtype=None, name=None, num=None, newowner=None, def_=None, behavior=None, missing_ok=None): # pragma: no cover # noqa: E501
if ((subtype is not None
and name is num is newowner is def_ is behavior is missing_ok is None # noqa: E501
and isinstance(subtype, dict)
and '@' in subtype)):
super().__init__(subtype)
else:
self.subtype = subtype
self.name = name
self.num = num
self.newowner = newowner
self.def_ = def_
self.behavior = behavior
self.missing_ok = missing_ok
class AlterTableMoveAllStmt(Node):
__slots__ = {'orig_tablespacename': 'char*', 'objtype': 'ObjectType', 'roles': 'List*', 'new_tablespacename': 'char*', 'nowait': 'bool'} # noqa: E501
def __init__(self, orig_tablespacename=None, objtype=None, roles=None, new_tablespacename=None, nowait=None): # pragma: no cover # noqa: E501
if ((orig_tablespacename is not None
and objtype is roles is new_tablespacename is nowait is None # noqa: E501
and isinstance(orig_tablespacename, dict)
and '@' in orig_tablespacename)):
super().__init__(orig_tablespacename)
else:
self.orig_tablespacename = orig_tablespacename
self.objtype = objtype
self.roles = roles
self.new_tablespacename = new_tablespacename
self.nowait = nowait
class AlterTableSpaceOptionsStmt(Node):
__slots__ = {'tablespacename': 'char*', 'options': 'List*', 'isReset': 'bool'} # noqa: E501
def __init__(self, tablespacename=None, options=None, isReset=None): # pragma: no cover # noqa: E501
if ((tablespacename is not None
and options is isReset is None # noqa: E501
and isinstance(tablespacename, dict)
and '@' in tablespacename)):
super().__init__(tablespacename)
else:
self.tablespacename = tablespacename
self.options = options
self.isReset = isReset
class AlterTableStmt(Node):
__slots__ = {'relation': 'RangeVar*', 'cmds': 'List*', 'relkind': 'ObjectType', 'missing_ok': 'bool'} # noqa: E501
def __init__(self, relation=None, cmds=None, relkind=None, missing_ok=None): # pragma: no cover # noqa: E501
if ((relation is not None
and cmds is relkind is missing_ok is None # noqa: E501
and isinstance(relation, dict)
and '@' in relation)):
super().__init__(relation)
else:
self.relation = relation
self.cmds = cmds
self.relkind = relkind
self.missing_ok = missing_ok
class AlterTypeStmt(Node):
__slots__ = {'typeName': 'List*', 'options': 'List*'} # noqa: E501
def __init__(self, typeName=None, options=None): # pragma: no cover # noqa: E501
if ((typeName is not None
and options is None # noqa: E501
and isinstance(typeName, dict)
and '@' in typeName)):
super().__init__(typeName)
else:
self.typeName = typeName
self.options = options
class AlterUserMappingStmt(Node):
__slots__ = {'user': 'RoleSpec*', 'servername': 'char*', 'options': 'List*'} # noqa: E501
def __init__(self, user=None, servername=None, options=None): # pragma: no cover # noqa: E501
if ((user is not None
and servername is options is None # noqa: E501
and isinstance(user, dict)
and '@' in user)):
super().__init__(user)
else:
self.user = user
self.servername = servername
self.options = options
class AlternativeSubPlan(Expr):
__slots__ = {'subplans': 'List*'} # noqa: E501
def __init__(self, subplans=None): # pragma: no cover # noqa: E501
if ((subplans is not None
and isinstance(subplans, dict)
and '@' in subplans)):
super().__init__(subplans)
else:
self.subplans = subplans
class ArrayCoerceExpr(Expr):
__slots__ = {'arg': 'Expr*', 'elemexpr': 'Expr*', 'resulttypmod': 'int32', 'coerceformat': 'CoercionForm', 'location': 'int'} # noqa: E501
def __init__(self, arg=None, elemexpr=None, resulttypmod=None, coerceformat=None, location=None): # pragma: no cover # noqa: E501
if ((arg is not None
and elemexpr is resulttypmod is coerceformat is location is None # noqa: E501
and isinstance(arg, dict)
and '@' in arg)):
super().__init__(arg)
else:
self.arg = arg
self.elemexpr = elemexpr
self.resulttypmod = resulttypmod
self.coerceformat = coerceformat
self.location = location
class ArrayExpr(Expr):
__slots__ = {'elements': 'List*', 'multidims': 'bool', 'location': 'int'} # noqa: E501
def __init__(self, elements=None, multidims=None, location=None): # pragma: no cover # noqa: E501
if ((elements is not None
and multidims is location is None # noqa: E501
and isinstance(elements, dict)
and '@' in elements)):
super().__init__(elements)
else:
self.elements = elements
self.multidims = multidims
self.location = location
class BoolExpr(Expr):
__slots__ = {'boolop': 'BoolExprType', 'args': 'List*', 'location': 'int'} # noqa: E501
def __init__(self, boolop=None, args=None, location=None): # pragma: no cover # noqa: E501
if ((boolop is not None
and args is location is None # noqa: E501
and isinstance(boolop, dict)
and '@' in boolop)):
super().__init__(boolop)
else:
self.boolop = boolop
self.args = args
self.location = location
class BooleanTest(Expr):
__slots__ = {'arg': 'Expr*', 'booltesttype': 'BoolTestType', 'location': 'int'} # noqa: E501
def __init__(self, arg=None, booltesttype=None, location=None): # pragma: no cover # noqa: E501
if ((arg is not None
and booltesttype is location is None # noqa: E501
and isinstance(arg, dict)
and '@' in arg)):
super().__init__(arg)
else:
self.arg = arg
self.booltesttype = booltesttype
self.location = location
class CallContext(Node):
__slots__ = {'atomic': 'bool'} # noqa: E501
def __init__(self, atomic=None): # pragma: no cover # noqa: E501
if ((atomic is not None
and isinstance(atomic, dict)
and '@' in atomic)):
super().__init__(atomic)
else:
self.atomic = atomic
class CallStmt(Node):
__slots__ = {'funccall': 'FuncCall*', 'funcexpr': 'FuncExpr*'} # noqa: E501
def __init__(self, funccall=None, funcexpr=None): # pragma: no cover # noqa: E501
if ((funccall is not None
and funcexpr is None # noqa: E501
and isinstance(funccall, dict)
and '@' in funccall)):
super().__init__(funccall)
else:
self.funccall = funccall
self.funcexpr = funcexpr