pg_query 5.0.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (898) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/README.md +1 -1
  4. data/Rakefile +3 -4
  5. data/ext/pg_query/extconf.rb +14 -4
  6. data/ext/pg_query/include/pg_query.h +4 -3
  7. data/ext/pg_query/include/pg_query_enum_defs.c +424 -154
  8. data/ext/pg_query/include/pg_query_fingerprint_conds.c +68 -4
  9. data/ext/pg_query/include/pg_query_fingerprint_defs.c +2901 -1794
  10. data/ext/pg_query/include/pg_query_outfuncs_conds.c +51 -3
  11. data/ext/pg_query/include/pg_query_outfuncs_defs.c +211 -24
  12. data/ext/pg_query/include/pg_query_readfuncs_conds.c +17 -1
  13. data/ext/pg_query/include/pg_query_readfuncs_defs.c +272 -53
  14. data/ext/pg_query/include/postgres/access/amapi.h +299 -0
  15. data/ext/pg_query/include/postgres/access/attmap.h +54 -0
  16. data/ext/pg_query/include/postgres/access/attnum.h +64 -0
  17. data/ext/pg_query/include/postgres/access/brin_internal.h +116 -0
  18. data/ext/pg_query/include/postgres/access/brin_tuple.h +112 -0
  19. data/ext/pg_query/include/postgres/access/clog.h +62 -0
  20. data/ext/pg_query/include/postgres/access/commit_ts.h +73 -0
  21. data/ext/pg_query/include/postgres/access/detoast.h +82 -0
  22. data/ext/pg_query/include/postgres/access/genam.h +237 -0
  23. data/ext/pg_query/include/postgres/access/gin.h +91 -0
  24. data/ext/pg_query/include/postgres/access/htup.h +89 -0
  25. data/ext/pg_query/include/postgres/access/htup_details.h +811 -0
  26. data/ext/pg_query/include/postgres/access/itup.h +170 -0
  27. data/ext/pg_query/include/postgres/access/parallel.h +81 -0
  28. data/ext/pg_query/include/postgres/access/printtup.h +35 -0
  29. data/ext/pg_query/include/postgres/access/relation.h +28 -0
  30. data/ext/pg_query/include/postgres/access/relscan.h +191 -0
  31. data/ext/pg_query/include/postgres/access/rmgrlist.h +49 -0
  32. data/ext/pg_query/include/postgres/access/sdir.h +67 -0
  33. data/ext/pg_query/include/postgres/access/skey.h +151 -0
  34. data/ext/pg_query/include/postgres/access/slru.h +221 -0
  35. data/ext/pg_query/include/postgres/access/stratnum.h +85 -0
  36. data/ext/pg_query/include/postgres/access/sysattr.h +29 -0
  37. data/ext/pg_query/include/postgres/access/table.h +28 -0
  38. data/ext/pg_query/include/postgres/access/tableam.h +2109 -0
  39. data/ext/pg_query/include/postgres/access/tidstore.h +50 -0
  40. data/ext/pg_query/include/postgres/access/toast_compression.h +73 -0
  41. data/ext/pg_query/include/postgres/access/transam.h +375 -0
  42. data/ext/pg_query/include/postgres/access/tsmapi.h +82 -0
  43. data/ext/pg_query/include/postgres/access/tupconvert.h +54 -0
  44. data/ext/pg_query/include/postgres/access/tupdesc.h +154 -0
  45. data/ext/pg_query/include/postgres/access/tupmacs.h +207 -0
  46. data/ext/pg_query/include/postgres/access/twophase.h +65 -0
  47. data/ext/pg_query/include/postgres/access/xact.h +530 -0
  48. data/ext/pg_query/include/postgres/access/xlog.h +310 -0
  49. data/ext/pg_query/include/postgres/access/xlog_internal.h +405 -0
  50. data/ext/pg_query/include/postgres/access/xlogbackup.h +43 -0
  51. data/ext/pg_query/include/postgres/access/xlogdefs.h +82 -0
  52. data/ext/pg_query/include/postgres/access/xlogprefetcher.h +55 -0
  53. data/ext/pg_query/include/postgres/access/xlogreader.h +444 -0
  54. data/ext/pg_query/include/postgres/access/xlogrecord.h +248 -0
  55. data/ext/pg_query/include/postgres/access/xlogrecovery.h +158 -0
  56. data/ext/pg_query/include/postgres/archive/archive_module.h +67 -0
  57. data/ext/pg_query/include/postgres/c.h +1374 -0
  58. data/ext/pg_query/include/postgres/catalog/catalog.h +47 -0
  59. data/ext/pg_query/include/postgres/catalog/catversion.h +62 -0
  60. data/ext/pg_query/include/postgres/catalog/dependency.h +228 -0
  61. data/ext/pg_query/include/postgres/catalog/genbki.h +149 -0
  62. data/ext/pg_query/include/postgres/catalog/index.h +218 -0
  63. data/ext/pg_query/include/postgres/catalog/indexing.h +54 -0
  64. data/ext/pg_query/include/postgres/catalog/namespace.h +189 -0
  65. data/ext/pg_query/include/postgres/catalog/objectaccess.h +267 -0
  66. data/ext/pg_query/include/postgres/catalog/objectaddress.h +89 -0
  67. data/ext/pg_query/include/postgres/catalog/pg_aggregate.h +182 -0
  68. data/ext/pg_query/include/postgres/catalog/pg_aggregate_d.h +78 -0
  69. data/ext/pg_query/include/postgres/catalog/pg_am.h +66 -0
  70. data/ext/pg_query/include/postgres/catalog/pg_am_d.h +47 -0
  71. data/ext/pg_query/include/postgres/catalog/pg_attribute.h +240 -0
  72. data/ext/pg_query/include/postgres/catalog/pg_attribute_d.h +62 -0
  73. data/ext/pg_query/include/postgres/catalog/pg_authid.h +66 -0
  74. data/ext/pg_query/include/postgres/catalog/pg_authid_d.h +60 -0
  75. data/ext/pg_query/include/postgres/catalog/pg_class.h +235 -0
  76. data/ext/pg_query/include/postgres/catalog/pg_class_d.h +134 -0
  77. data/ext/pg_query/include/postgres/catalog/pg_collation.h +106 -0
  78. data/ext/pg_query/include/postgres/catalog/pg_collation_d.h +66 -0
  79. data/ext/pg_query/include/postgres/catalog/pg_constraint.h +278 -0
  80. data/ext/pg_query/include/postgres/catalog/pg_constraint_d.h +74 -0
  81. data/ext/pg_query/include/postgres/catalog/pg_control.h +260 -0
  82. data/ext/pg_query/include/postgres/catalog/pg_conversion.h +79 -0
  83. data/ext/pg_query/include/postgres/catalog/pg_conversion_d.h +38 -0
  84. data/ext/pg_query/include/postgres/catalog/pg_database.h +129 -0
  85. data/ext/pg_query/include/postgres/catalog/pg_database_d.h +53 -0
  86. data/ext/pg_query/include/postgres/catalog/pg_depend.h +77 -0
  87. data/ext/pg_query/include/postgres/catalog/pg_depend_d.h +36 -0
  88. data/ext/pg_query/include/postgres/catalog/pg_event_trigger.h +60 -0
  89. data/ext/pg_query/include/postgres/catalog/pg_event_trigger_d.h +36 -0
  90. data/ext/pg_query/include/postgres/catalog/pg_index.h +92 -0
  91. data/ext/pg_query/include/postgres/catalog/pg_index_d.h +59 -0
  92. data/ext/pg_query/include/postgres/catalog/pg_language.h +75 -0
  93. data/ext/pg_query/include/postgres/catalog/pg_language_d.h +41 -0
  94. data/ext/pg_query/include/postgres/catalog/pg_namespace.h +67 -0
  95. data/ext/pg_query/include/postgres/catalog/pg_namespace_d.h +36 -0
  96. data/ext/pg_query/include/postgres/catalog/pg_opclass.h +91 -0
  97. data/ext/pg_query/include/postgres/catalog/pg_opclass_d.h +51 -0
  98. data/ext/pg_query/include/postgres/catalog/pg_operator.h +124 -0
  99. data/ext/pg_query/include/postgres/catalog/pg_operator_d.h +142 -0
  100. data/ext/pg_query/include/postgres/catalog/pg_opfamily.h +67 -0
  101. data/ext/pg_query/include/postgres/catalog/pg_opfamily_d.h +51 -0
  102. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table.h +76 -0
  103. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table_d.h +36 -0
  104. data/ext/pg_query/include/postgres/catalog/pg_proc.h +223 -0
  105. data/ext/pg_query/include/postgres/catalog/pg_proc_d.h +101 -0
  106. data/ext/pg_query/include/postgres/catalog/pg_publication.h +161 -0
  107. data/ext/pg_query/include/postgres/catalog/pg_publication_d.h +38 -0
  108. data/ext/pg_query/include/postgres/catalog/pg_replication_origin.h +65 -0
  109. data/ext/pg_query/include/postgres/catalog/pg_replication_origin_d.h +33 -0
  110. data/ext/pg_query/include/postgres/catalog/pg_statistic.h +288 -0
  111. data/ext/pg_query/include/postgres/catalog/pg_statistic_d.h +199 -0
  112. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext.h +91 -0
  113. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext_d.h +45 -0
  114. data/ext/pg_query/include/postgres/catalog/pg_transform.h +51 -0
  115. data/ext/pg_query/include/postgres/catalog/pg_transform_d.h +34 -0
  116. data/ext/pg_query/include/postgres/catalog/pg_trigger.h +153 -0
  117. data/ext/pg_query/include/postgres/catalog/pg_trigger_d.h +109 -0
  118. data/ext/pg_query/include/postgres/catalog/pg_ts_config.h +56 -0
  119. data/ext/pg_query/include/postgres/catalog/pg_ts_config_d.h +34 -0
  120. data/ext/pg_query/include/postgres/catalog/pg_ts_dict.h +62 -0
  121. data/ext/pg_query/include/postgres/catalog/pg_ts_dict_d.h +35 -0
  122. data/ext/pg_query/include/postgres/catalog/pg_ts_parser.h +63 -0
  123. data/ext/pg_query/include/postgres/catalog/pg_ts_parser_d.h +37 -0
  124. data/ext/pg_query/include/postgres/catalog/pg_ts_template.h +54 -0
  125. data/ext/pg_query/include/postgres/catalog/pg_ts_template_d.h +34 -0
  126. data/ext/pg_query/include/postgres/catalog/pg_type.h +407 -0
  127. data/ext/pg_query/include/postgres/catalog/pg_type_d.h +324 -0
  128. data/ext/pg_query/include/postgres/catalog/storage.h +50 -0
  129. data/ext/pg_query/include/postgres/catalog/syscache_ids.h +104 -0
  130. data/ext/pg_query/include/postgres/commands/async.h +49 -0
  131. data/ext/pg_query/include/postgres/commands/dbcommands.h +37 -0
  132. data/ext/pg_query/include/postgres/commands/defrem.h +161 -0
  133. data/ext/pg_query/include/postgres/commands/event_trigger.h +91 -0
  134. data/ext/pg_query/include/postgres/commands/explain.h +145 -0
  135. data/ext/pg_query/include/postgres/commands/prepare.h +61 -0
  136. data/ext/pg_query/include/postgres/commands/tablespace.h +69 -0
  137. data/ext/pg_query/include/postgres/commands/trigger.h +288 -0
  138. data/ext/pg_query/include/postgres/commands/vacuum.h +388 -0
  139. data/ext/pg_query/include/postgres/common/cryptohash.h +39 -0
  140. data/ext/pg_query/include/postgres/common/file_perm.h +56 -0
  141. data/ext/pg_query/include/postgres/common/file_utils.h +65 -0
  142. data/ext/pg_query/include/postgres/common/hashfn.h +119 -0
  143. data/ext/pg_query/include/postgres/common/hashfn_unstable.h +453 -0
  144. data/ext/pg_query/include/postgres/common/int.h +512 -0
  145. data/ext/pg_query/include/postgres/common/keywords.h +29 -0
  146. data/ext/pg_query/include/postgres/common/kwlookup.h +44 -0
  147. data/ext/pg_query/include/postgres/common/pg_prng.h +62 -0
  148. data/ext/pg_query/include/postgres/common/relpath.h +97 -0
  149. data/ext/pg_query/include/postgres/common/scram-common.h +70 -0
  150. data/ext/pg_query/include/postgres/common/sha2.h +32 -0
  151. data/ext/pg_query/include/postgres/common/string.h +44 -0
  152. data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +124 -0
  153. data/ext/pg_query/include/postgres/copyfuncs.funcs.c +5261 -0
  154. data/ext/pg_query/include/postgres/copyfuncs.switch.c +989 -0
  155. data/ext/pg_query/include/postgres/datatype/timestamp.h +269 -0
  156. data/ext/pg_query/include/postgres/equalfuncs.funcs.c +3310 -0
  157. data/ext/pg_query/include/postgres/equalfuncs.switch.c +836 -0
  158. data/ext/pg_query/include/postgres/executor/execdesc.h +70 -0
  159. data/ext/pg_query/include/postgres/executor/executor.h +681 -0
  160. data/ext/pg_query/include/postgres/executor/functions.h +56 -0
  161. data/ext/pg_query/include/postgres/executor/instrument.h +120 -0
  162. data/ext/pg_query/include/postgres/executor/spi.h +207 -0
  163. data/ext/pg_query/include/postgres/executor/tablefunc.h +67 -0
  164. data/ext/pg_query/include/postgres/executor/tuptable.h +523 -0
  165. data/ext/pg_query/include/postgres/fmgr.h +800 -0
  166. data/ext/pg_query/include/postgres/foreign/fdwapi.h +294 -0
  167. data/ext/pg_query/include/postgres/funcapi.h +360 -0
  168. data/ext/pg_query/include/postgres/gram.h +1168 -0
  169. data/ext/pg_query/include/postgres/gramparse.h +75 -0
  170. data/ext/pg_query/include/postgres/jit/jit.h +106 -0
  171. data/ext/pg_query/include/postgres/kwlist_d.h +1164 -0
  172. data/ext/pg_query/include/postgres/lib/dshash.h +130 -0
  173. data/ext/pg_query/include/postgres/lib/ilist.h +1159 -0
  174. data/ext/pg_query/include/postgres/lib/pairingheap.h +102 -0
  175. data/ext/pg_query/include/postgres/lib/simplehash.h +1206 -0
  176. data/ext/pg_query/include/postgres/lib/sort_template.h +445 -0
  177. data/ext/pg_query/include/postgres/lib/stringinfo.h +243 -0
  178. data/ext/pg_query/include/postgres/libpq/auth.h +37 -0
  179. data/ext/pg_query/include/postgres/libpq/crypt.h +47 -0
  180. data/ext/pg_query/include/postgres/libpq/hba.h +186 -0
  181. data/ext/pg_query/include/postgres/libpq/libpq-be.h +358 -0
  182. data/ext/pg_query/include/postgres/libpq/libpq.h +143 -0
  183. data/ext/pg_query/include/postgres/libpq/pqcomm.h +169 -0
  184. data/ext/pg_query/include/postgres/libpq/pqformat.h +209 -0
  185. data/ext/pg_query/include/postgres/libpq/pqsignal.h +54 -0
  186. data/ext/pg_query/include/postgres/libpq/protocol.h +89 -0
  187. data/ext/pg_query/include/postgres/libpq/sasl.h +136 -0
  188. data/ext/pg_query/include/postgres/libpq/scram.h +37 -0
  189. data/ext/pg_query/include/postgres/mb/pg_wchar.h +792 -0
  190. data/ext/pg_query/include/postgres/mb/stringinfo_mb.h +24 -0
  191. data/ext/pg_query/include/postgres/miscadmin.h +519 -0
  192. data/ext/pg_query/include/postgres/nodes/bitmapset.h +140 -0
  193. data/ext/pg_query/include/postgres/nodes/execnodes.h +2852 -0
  194. data/ext/pg_query/include/postgres/nodes/extensible.h +164 -0
  195. data/ext/pg_query/include/postgres/nodes/lockoptions.h +61 -0
  196. data/ext/pg_query/include/postgres/nodes/makefuncs.h +127 -0
  197. data/ext/pg_query/include/postgres/nodes/memnodes.h +152 -0
  198. data/ext/pg_query/include/postgres/nodes/miscnodes.h +56 -0
  199. data/ext/pg_query/include/postgres/nodes/nodeFuncs.h +222 -0
  200. data/ext/pg_query/include/postgres/nodes/nodes.h +435 -0
  201. data/ext/pg_query/include/postgres/nodes/nodetags.h +491 -0
  202. data/ext/pg_query/include/postgres/nodes/params.h +170 -0
  203. data/ext/pg_query/include/postgres/nodes/parsenodes.h +4233 -0
  204. data/ext/pg_query/include/postgres/nodes/pathnodes.h +3435 -0
  205. data/ext/pg_query/include/postgres/nodes/pg_list.h +686 -0
  206. data/ext/pg_query/include/postgres/nodes/plannodes.h +1593 -0
  207. data/ext/pg_query/include/postgres/nodes/primnodes.h +2335 -0
  208. data/ext/pg_query/include/postgres/nodes/print.h +34 -0
  209. data/ext/pg_query/include/postgres/nodes/queryjumble.h +86 -0
  210. data/ext/pg_query/include/postgres/nodes/replnodes.h +132 -0
  211. data/ext/pg_query/include/postgres/nodes/supportnodes.h +346 -0
  212. data/ext/pg_query/include/postgres/nodes/tidbitmap.h +75 -0
  213. data/ext/pg_query/include/postgres/nodes/value.h +90 -0
  214. data/ext/pg_query/include/postgres/optimizer/cost.h +216 -0
  215. data/ext/pg_query/include/postgres/optimizer/geqo.h +90 -0
  216. data/ext/pg_query/include/postgres/optimizer/geqo_gene.h +45 -0
  217. data/ext/pg_query/include/postgres/optimizer/optimizer.h +205 -0
  218. data/ext/pg_query/include/postgres/optimizer/paths.h +271 -0
  219. data/ext/pg_query/include/postgres/optimizer/planmain.h +123 -0
  220. data/ext/pg_query/include/postgres/parser/analyze.h +66 -0
  221. data/ext/pg_query/include/postgres/parser/kwlist.h +518 -0
  222. data/ext/pg_query/include/postgres/parser/parse_agg.h +65 -0
  223. data/ext/pg_query/include/postgres/parser/parse_coerce.h +102 -0
  224. data/ext/pg_query/include/postgres/parser/parse_expr.h +25 -0
  225. data/ext/pg_query/include/postgres/parser/parse_func.h +74 -0
  226. data/ext/pg_query/include/postgres/parser/parse_node.h +358 -0
  227. data/ext/pg_query/include/postgres/parser/parse_oper.h +68 -0
  228. data/ext/pg_query/include/postgres/parser/parse_relation.h +129 -0
  229. data/ext/pg_query/include/postgres/parser/parse_type.h +61 -0
  230. data/ext/pg_query/include/postgres/parser/parser.h +68 -0
  231. data/ext/pg_query/include/postgres/parser/parsetree.h +61 -0
  232. data/ext/pg_query/include/postgres/parser/scanner.h +152 -0
  233. data/ext/pg_query/include/postgres/parser/scansup.h +27 -0
  234. data/ext/pg_query/include/postgres/partitioning/partdefs.h +26 -0
  235. data/ext/pg_query/include/postgres/pg_config.h +977 -0
  236. data/ext/pg_query/include/postgres/pg_config_manual.h +385 -0
  237. data/ext/pg_query/include/postgres/pg_config_os.h +8 -0
  238. data/ext/pg_query/include/postgres/pg_getopt.h +56 -0
  239. data/ext/pg_query/include/postgres/pg_trace.h +17 -0
  240. data/ext/pg_query/include/postgres/pgstat.h +780 -0
  241. data/ext/pg_query/include/postgres/pgtime.h +94 -0
  242. data/ext/pg_query/include/postgres/pl_gram.h +385 -0
  243. data/ext/pg_query/include/postgres/pl_reserved_kwlist.h +52 -0
  244. data/ext/pg_query/include/postgres/pl_reserved_kwlist_d.h +114 -0
  245. data/ext/pg_query/include/postgres/pl_unreserved_kwlist.h +112 -0
  246. data/ext/pg_query/include/postgres/pl_unreserved_kwlist_d.h +246 -0
  247. data/ext/pg_query/include/postgres/plerrcodes.h +998 -0
  248. data/ext/pg_query/include/postgres/plpgsql.h +1342 -0
  249. data/ext/pg_query/include/postgres/port/atomics/arch-arm.h +32 -0
  250. data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +17 -0
  251. data/ext/pg_query/include/postgres/port/atomics/arch-ppc.h +256 -0
  252. data/ext/pg_query/include/postgres/port/atomics/arch-x86.h +254 -0
  253. data/ext/pg_query/include/postgres/port/atomics/fallback.h +170 -0
  254. data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +323 -0
  255. data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +119 -0
  256. data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +121 -0
  257. data/ext/pg_query/include/postgres/port/atomics/generic.h +437 -0
  258. data/ext/pg_query/include/postgres/port/atomics.h +606 -0
  259. data/ext/pg_query/include/postgres/port/pg_bitutils.h +421 -0
  260. data/ext/pg_query/include/postgres/port/pg_bswap.h +161 -0
  261. data/ext/pg_query/include/postgres/port/pg_crc32c.h +110 -0
  262. data/ext/pg_query/include/postgres/port/pg_iovec.h +117 -0
  263. data/ext/pg_query/include/postgres/port/simd.h +422 -0
  264. data/ext/pg_query/include/postgres/port/win32/arpa/inet.h +3 -0
  265. data/ext/pg_query/include/postgres/port/win32/dlfcn.h +1 -0
  266. data/ext/pg_query/include/postgres/port/win32/grp.h +1 -0
  267. data/ext/pg_query/include/postgres/port/win32/netdb.h +7 -0
  268. data/ext/pg_query/include/postgres/port/win32/netinet/in.h +3 -0
  269. data/ext/pg_query/include/postgres/port/win32/netinet/tcp.h +7 -0
  270. data/ext/pg_query/include/postgres/port/win32/pwd.h +3 -0
  271. data/ext/pg_query/include/postgres/port/win32/sys/resource.h +20 -0
  272. data/ext/pg_query/include/postgres/port/win32/sys/select.h +3 -0
  273. data/ext/pg_query/include/postgres/port/win32/sys/socket.h +34 -0
  274. data/ext/pg_query/include/postgres/port/win32/sys/un.h +17 -0
  275. data/ext/pg_query/include/postgres/port/win32/sys/wait.h +3 -0
  276. data/ext/pg_query/include/postgres/port/win32.h +59 -0
  277. data/ext/pg_query/include/postgres/port/win32_msvc/dirent.h +34 -0
  278. data/ext/pg_query/include/postgres/port/win32_msvc/sys/file.h +1 -0
  279. data/ext/pg_query/include/postgres/port/win32_msvc/sys/param.h +1 -0
  280. data/ext/pg_query/include/postgres/port/win32_msvc/sys/time.h +1 -0
  281. data/ext/pg_query/include/postgres/port/win32_msvc/unistd.h +9 -0
  282. data/ext/pg_query/include/postgres/port/win32_msvc/utime.h +3 -0
  283. data/ext/pg_query/include/postgres/port/win32_port.h +584 -0
  284. data/ext/pg_query/include/postgres/port.h +524 -0
  285. data/ext/pg_query/include/postgres/portability/instr_time.h +197 -0
  286. data/ext/pg_query/include/postgres/postgres.h +579 -0
  287. data/ext/pg_query/include/postgres/postmaster/autovacuum.h +69 -0
  288. data/ext/pg_query/include/postgres/postmaster/bgworker.h +164 -0
  289. data/ext/pg_query/include/postgres/postmaster/bgworker_internals.h +60 -0
  290. data/ext/pg_query/include/postgres/postmaster/bgwriter.h +45 -0
  291. data/ext/pg_query/include/postgres/postmaster/interrupt.h +32 -0
  292. data/ext/pg_query/include/postgres/postmaster/pgarch.h +36 -0
  293. data/ext/pg_query/include/postgres/postmaster/postmaster.h +101 -0
  294. data/ext/pg_query/include/postgres/postmaster/startup.h +41 -0
  295. data/ext/pg_query/include/postgres/postmaster/syslogger.h +101 -0
  296. data/ext/pg_query/include/postgres/postmaster/walsummarizer.h +35 -0
  297. data/ext/pg_query/include/postgres/postmaster/walwriter.h +23 -0
  298. data/ext/pg_query/include/postgres/regex/regex.h +272 -0
  299. data/ext/pg_query/include/postgres/replication/logicallauncher.h +34 -0
  300. data/ext/pg_query/include/postgres/replication/logicalproto.h +274 -0
  301. data/ext/pg_query/include/postgres/replication/logicalworker.h +33 -0
  302. data/ext/pg_query/include/postgres/replication/origin.h +73 -0
  303. data/ext/pg_query/include/postgres/replication/reorderbuffer.h +743 -0
  304. data/ext/pg_query/include/postgres/replication/slot.h +285 -0
  305. data/ext/pg_query/include/postgres/replication/slotsync.h +38 -0
  306. data/ext/pg_query/include/postgres/replication/syncrep.h +109 -0
  307. data/ext/pg_query/include/postgres/replication/walreceiver.h +504 -0
  308. data/ext/pg_query/include/postgres/replication/walsender.h +76 -0
  309. data/ext/pg_query/include/postgres/rewrite/prs2lock.h +46 -0
  310. data/ext/pg_query/include/postgres/rewrite/rewriteHandler.h +41 -0
  311. data/ext/pg_query/include/postgres/rewrite/rewriteManip.h +96 -0
  312. data/ext/pg_query/include/postgres/rewrite/rewriteSupport.h +26 -0
  313. data/ext/pg_query/include/postgres/storage/block.h +108 -0
  314. data/ext/pg_query/include/postgres/storage/buf.h +46 -0
  315. data/ext/pg_query/include/postgres/storage/bufmgr.h +411 -0
  316. data/ext/pg_query/include/postgres/storage/bufpage.h +510 -0
  317. data/ext/pg_query/include/postgres/storage/condition_variable.h +73 -0
  318. data/ext/pg_query/include/postgres/storage/dsm.h +61 -0
  319. data/ext/pg_query/include/postgres/storage/dsm_impl.h +79 -0
  320. data/ext/pg_query/include/postgres/storage/fd.h +219 -0
  321. data/ext/pg_query/include/postgres/storage/fileset.h +40 -0
  322. data/ext/pg_query/include/postgres/storage/ipc.h +87 -0
  323. data/ext/pg_query/include/postgres/storage/item.h +19 -0
  324. data/ext/pg_query/include/postgres/storage/itemid.h +184 -0
  325. data/ext/pg_query/include/postgres/storage/itemptr.h +245 -0
  326. data/ext/pg_query/include/postgres/storage/large_object.h +100 -0
  327. data/ext/pg_query/include/postgres/storage/latch.h +196 -0
  328. data/ext/pg_query/include/postgres/storage/lmgr.h +126 -0
  329. data/ext/pg_query/include/postgres/storage/lock.h +624 -0
  330. data/ext/pg_query/include/postgres/storage/lockdefs.h +59 -0
  331. data/ext/pg_query/include/postgres/storage/lwlock.h +228 -0
  332. data/ext/pg_query/include/postgres/storage/lwlocknames.h +47 -0
  333. data/ext/pg_query/include/postgres/storage/off.h +57 -0
  334. data/ext/pg_query/include/postgres/storage/pg_sema.h +61 -0
  335. data/ext/pg_query/include/postgres/storage/pg_shmem.h +93 -0
  336. data/ext/pg_query/include/postgres/storage/pmsignal.h +105 -0
  337. data/ext/pg_query/include/postgres/storage/predicate.h +83 -0
  338. data/ext/pg_query/include/postgres/storage/proc.h +491 -0
  339. data/ext/pg_query/include/postgres/storage/procarray.h +103 -0
  340. data/ext/pg_query/include/postgres/storage/proclist_types.h +53 -0
  341. data/ext/pg_query/include/postgres/storage/procnumber.h +43 -0
  342. data/ext/pg_query/include/postgres/storage/procsignal.h +75 -0
  343. data/ext/pg_query/include/postgres/storage/read_stream.h +65 -0
  344. data/ext/pg_query/include/postgres/storage/relfilelocator.h +100 -0
  345. data/ext/pg_query/include/postgres/storage/s_lock.h +847 -0
  346. data/ext/pg_query/include/postgres/storage/sharedfileset.h +37 -0
  347. data/ext/pg_query/include/postgres/storage/shm_mq.h +86 -0
  348. data/ext/pg_query/include/postgres/storage/shm_toc.h +58 -0
  349. data/ext/pg_query/include/postgres/storage/shmem.h +59 -0
  350. data/ext/pg_query/include/postgres/storage/sinval.h +153 -0
  351. data/ext/pg_query/include/postgres/storage/smgr.h +127 -0
  352. data/ext/pg_query/include/postgres/storage/spin.h +77 -0
  353. data/ext/pg_query/include/postgres/storage/standby.h +109 -0
  354. data/ext/pg_query/include/postgres/storage/standbydefs.h +74 -0
  355. data/ext/pg_query/include/postgres/storage/sync.h +66 -0
  356. data/ext/pg_query/include/postgres/tcop/cmdtag.h +62 -0
  357. data/ext/pg_query/include/postgres/tcop/cmdtaglist.h +219 -0
  358. data/ext/pg_query/include/postgres/tcop/deparse_utility.h +108 -0
  359. data/ext/pg_query/include/postgres/tcop/dest.h +148 -0
  360. data/ext/pg_query/include/postgres/tcop/fastpath.h +20 -0
  361. data/ext/pg_query/include/postgres/tcop/pquery.h +51 -0
  362. data/ext/pg_query/include/postgres/tcop/tcopprot.h +98 -0
  363. data/ext/pg_query/include/postgres/tcop/utility.h +112 -0
  364. data/ext/pg_query/include/postgres/tsearch/ts_cache.h +96 -0
  365. data/ext/pg_query/include/postgres/utils/acl.h +290 -0
  366. data/ext/pg_query/include/postgres/utils/aclchk_internal.h +45 -0
  367. data/ext/pg_query/include/postgres/utils/array.h +481 -0
  368. data/ext/pg_query/include/postgres/utils/ascii.h +84 -0
  369. data/ext/pg_query/include/postgres/utils/backend_progress.h +46 -0
  370. data/ext/pg_query/include/postgres/utils/backend_status.h +340 -0
  371. data/ext/pg_query/include/postgres/utils/builtins.h +139 -0
  372. data/ext/pg_query/include/postgres/utils/bytea.h +28 -0
  373. data/ext/pg_query/include/postgres/utils/catcache.h +230 -0
  374. data/ext/pg_query/include/postgres/utils/date.h +118 -0
  375. data/ext/pg_query/include/postgres/utils/datetime.h +367 -0
  376. data/ext/pg_query/include/postgres/utils/datum.h +76 -0
  377. data/ext/pg_query/include/postgres/utils/dsa.h +166 -0
  378. data/ext/pg_query/include/postgres/utils/elog.h +540 -0
  379. data/ext/pg_query/include/postgres/utils/errcodes.h +352 -0
  380. data/ext/pg_query/include/postgres/utils/expandeddatum.h +170 -0
  381. data/ext/pg_query/include/postgres/utils/expandedrecord.h +241 -0
  382. data/ext/pg_query/include/postgres/utils/float.h +357 -0
  383. data/ext/pg_query/include/postgres/utils/fmgroids.h +3347 -0
  384. data/ext/pg_query/include/postgres/utils/fmgrprotos.h +2904 -0
  385. data/ext/pg_query/include/postgres/utils/fmgrtab.h +49 -0
  386. data/ext/pg_query/include/postgres/utils/guc.h +456 -0
  387. data/ext/pg_query/include/postgres/utils/guc_hooks.h +184 -0
  388. data/ext/pg_query/include/postgres/utils/guc_tables.h +323 -0
  389. data/ext/pg_query/include/postgres/utils/hsearch.h +153 -0
  390. data/ext/pg_query/include/postgres/utils/injection_point.h +44 -0
  391. data/ext/pg_query/include/postgres/utils/inval.h +68 -0
  392. data/ext/pg_query/include/postgres/utils/logtape.h +77 -0
  393. data/ext/pg_query/include/postgres/utils/lsyscache.h +215 -0
  394. data/ext/pg_query/include/postgres/utils/memdebug.h +82 -0
  395. data/ext/pg_query/include/postgres/utils/memutils.h +193 -0
  396. data/ext/pg_query/include/postgres/utils/memutils_internal.h +176 -0
  397. data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +253 -0
  398. data/ext/pg_query/include/postgres/utils/numeric.h +110 -0
  399. data/ext/pg_query/include/postgres/utils/palloc.h +151 -0
  400. data/ext/pg_query/include/postgres/utils/partcache.h +103 -0
  401. data/ext/pg_query/include/postgres/utils/pg_locale.h +136 -0
  402. data/ext/pg_query/include/postgres/utils/pgstat_internal.h +808 -0
  403. data/ext/pg_query/include/postgres/utils/plancache.h +238 -0
  404. data/ext/pg_query/include/postgres/utils/portal.h +252 -0
  405. data/ext/pg_query/include/postgres/utils/queryenvironment.h +74 -0
  406. data/ext/pg_query/include/postgres/utils/regproc.h +39 -0
  407. data/ext/pg_query/include/postgres/utils/rel.h +711 -0
  408. data/ext/pg_query/include/postgres/utils/relcache.h +155 -0
  409. data/ext/pg_query/include/postgres/utils/reltrigger.h +81 -0
  410. data/ext/pg_query/include/postgres/utils/resowner.h +167 -0
  411. data/ext/pg_query/include/postgres/utils/ruleutils.h +52 -0
  412. data/ext/pg_query/include/postgres/utils/sharedtuplestore.h +61 -0
  413. data/ext/pg_query/include/postgres/utils/snapmgr.h +130 -0
  414. data/ext/pg_query/include/postgres/utils/snapshot.h +219 -0
  415. data/ext/pg_query/include/postgres/utils/sortsupport.h +391 -0
  416. data/ext/pg_query/include/postgres/utils/syscache.h +131 -0
  417. data/ext/pg_query/include/postgres/utils/timeout.h +96 -0
  418. data/ext/pg_query/include/postgres/utils/timestamp.h +147 -0
  419. data/ext/pg_query/include/postgres/utils/tuplesort.h +472 -0
  420. data/ext/pg_query/include/postgres/utils/tuplestore.h +88 -0
  421. data/ext/pg_query/include/postgres/utils/typcache.h +210 -0
  422. data/ext/pg_query/include/postgres/utils/varlena.h +53 -0
  423. data/ext/pg_query/include/postgres/utils/wait_event.h +108 -0
  424. data/ext/pg_query/include/postgres/utils/wait_event_types.h +218 -0
  425. data/ext/pg_query/include/postgres/utils/xml.h +94 -0
  426. data/ext/pg_query/include/postgres/varatt.h +358 -0
  427. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1546 -792
  428. data/ext/pg_query/include/protobuf/pg_query.pb.h +58365 -46595
  429. data/ext/pg_query/pg_query.c +9 -0
  430. data/ext/pg_query/pg_query.pb-c.c +6598 -3739
  431. data/ext/pg_query/pg_query_fingerprint.c +4 -5
  432. data/ext/pg_query/pg_query_normalize.c +42 -1
  433. data/ext/pg_query/pg_query_outfuncs_json.c +9 -1
  434. data/ext/pg_query/pg_query_outfuncs_protobuf.c +1 -0
  435. data/ext/pg_query/pg_query_parse.c +1 -1
  436. data/ext/pg_query/pg_query_parse_plpgsql.c +18 -17
  437. data/ext/pg_query/pg_query_readfuncs_protobuf.c +3 -2
  438. data/ext/pg_query/pg_query_ruby.c +5 -0
  439. data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -1
  440. data/ext/pg_query/pg_query_scan.c +1 -1
  441. data/ext/pg_query/pg_query_split.c +1 -1
  442. data/ext/pg_query/postgres_deparse.c +409 -21
  443. data/ext/pg_query/src_backend_catalog_namespace.c +241 -66
  444. data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -3
  445. data/ext/pg_query/src_backend_commands_define.c +2 -3
  446. data/ext/pg_query/src_backend_nodes_bitmapset.c +137 -94
  447. data/ext/pg_query/src_backend_nodes_copyfuncs.c +1 -1
  448. data/ext/pg_query/src_backend_nodes_equalfuncs.c +1 -1
  449. data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
  450. data/ext/pg_query/src_backend_nodes_list.c +3 -7
  451. data/ext/pg_query/src_backend_nodes_makefuncs.c +59 -20
  452. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +109 -2
  453. data/ext/pg_query/src_backend_nodes_value.c +1 -1
  454. data/ext/pg_query/src_backend_parser_gram.c +34490 -32135
  455. data/ext/pg_query/src_backend_parser_parser.c +8 -8
  456. data/ext/pg_query/src_backend_parser_scan.c +5637 -3028
  457. data/ext/pg_query/src_backend_parser_scansup.c +2 -1
  458. data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
  459. data/ext/pg_query/src_backend_tcop_postgres.c +34 -10
  460. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +2 -2
  461. data/ext/pg_query/src_backend_utils_adt_datum.c +8 -6
  462. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  463. data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
  464. data/ext/pg_query/src_backend_utils_adt_numutils.c +4 -5
  465. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +101 -28
  466. data/ext/pg_query/src_backend_utils_error_assert.c +1 -1
  467. data/ext/pg_query/src_backend_utils_error_elog.c +60 -190
  468. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +4 -2
  469. data/ext/pg_query/src_backend_utils_init_globals.c +16 -4
  470. data/ext/pg_query/src_backend_utils_mb_mbutils.c +19 -81
  471. data/ext/pg_query/src_backend_utils_misc_guc_tables.c +16 -8
  472. data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +8 -5
  473. data/ext/pg_query/src_backend_utils_mmgr_aset.c +308 -238
  474. data/ext/pg_query/src_backend_utils_mmgr_bump.c +728 -0
  475. data/ext/pg_query/src_backend_utils_mmgr_generation.c +273 -197
  476. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +270 -215
  477. data/ext/pg_query/src_backend_utils_mmgr_slab.c +154 -96
  478. data/ext/pg_query/src_common_encnames.c +43 -44
  479. data/ext/pg_query/src_common_hashfn.c +1 -1
  480. data/ext/pg_query/src_common_keywords.c +1 -1
  481. data/ext/pg_query/src_common_kwlist_d.h +511 -466
  482. data/ext/pg_query/src_common_kwlookup.c +1 -1
  483. data/ext/pg_query/src_common_psprintf.c +3 -3
  484. data/ext/pg_query/src_common_stringinfo.c +18 -1
  485. data/ext/pg_query/src_common_wchar.c +45 -108
  486. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +99 -5
  487. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -1
  488. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +242 -143
  489. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  490. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +1 -1
  491. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +19 -1
  492. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +1 -1
  493. data/ext/pg_query/src_port_pg_bitutils.c +251 -32
  494. data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
  495. data/ext/pg_query/src_port_snprintf.c +4 -4
  496. data/ext/pg_query/src_port_strerror.c +1 -3
  497. data/ext/pg_query/src_port_strlcpy.c +79 -0
  498. data/lib/pg_query/fingerprint.rb +2 -3
  499. data/lib/pg_query/node.rb +16 -11
  500. data/lib/pg_query/param_refs.rb +1 -1
  501. data/lib/pg_query/parse.rb +1 -1
  502. data/lib/pg_query/pg_query_pb.rb +26 -3
  503. data/lib/pg_query/treewalker.rb +52 -12
  504. data/lib/pg_query/truncate.rb +1 -1
  505. data/lib/pg_query/version.rb +1 -1
  506. metadata +444 -400
  507. data/ext/pg_query/guc-file.c +0 -0
  508. data/ext/pg_query/include/access/amapi.h +0 -292
  509. data/ext/pg_query/include/access/attmap.h +0 -54
  510. data/ext/pg_query/include/access/attnum.h +0 -64
  511. data/ext/pg_query/include/access/clog.h +0 -63
  512. data/ext/pg_query/include/access/commit_ts.h +0 -74
  513. data/ext/pg_query/include/access/detoast.h +0 -82
  514. data/ext/pg_query/include/access/genam.h +0 -233
  515. data/ext/pg_query/include/access/gin.h +0 -91
  516. data/ext/pg_query/include/access/htup.h +0 -89
  517. data/ext/pg_query/include/access/htup_details.h +0 -811
  518. data/ext/pg_query/include/access/itup.h +0 -170
  519. data/ext/pg_query/include/access/parallel.h +0 -82
  520. data/ext/pg_query/include/access/printtup.h +0 -35
  521. data/ext/pg_query/include/access/relation.h +0 -28
  522. data/ext/pg_query/include/access/relscan.h +0 -191
  523. data/ext/pg_query/include/access/rmgrlist.h +0 -49
  524. data/ext/pg_query/include/access/sdir.h +0 -67
  525. data/ext/pg_query/include/access/skey.h +0 -151
  526. data/ext/pg_query/include/access/stratnum.h +0 -85
  527. data/ext/pg_query/include/access/sysattr.h +0 -29
  528. data/ext/pg_query/include/access/table.h +0 -28
  529. data/ext/pg_query/include/access/tableam.h +0 -2100
  530. data/ext/pg_query/include/access/toast_compression.h +0 -73
  531. data/ext/pg_query/include/access/transam.h +0 -375
  532. data/ext/pg_query/include/access/tsmapi.h +0 -82
  533. data/ext/pg_query/include/access/tupconvert.h +0 -54
  534. data/ext/pg_query/include/access/tupdesc.h +0 -154
  535. data/ext/pg_query/include/access/tupmacs.h +0 -207
  536. data/ext/pg_query/include/access/twophase.h +0 -65
  537. data/ext/pg_query/include/access/xact.h +0 -530
  538. data/ext/pg_query/include/access/xlog.h +0 -302
  539. data/ext/pg_query/include/access/xlog_internal.h +0 -404
  540. data/ext/pg_query/include/access/xlogbackup.h +0 -41
  541. data/ext/pg_query/include/access/xlogdefs.h +0 -82
  542. data/ext/pg_query/include/access/xlogprefetcher.h +0 -55
  543. data/ext/pg_query/include/access/xlogreader.h +0 -444
  544. data/ext/pg_query/include/access/xlogrecord.h +0 -248
  545. data/ext/pg_query/include/access/xlogrecovery.h +0 -158
  546. data/ext/pg_query/include/archive/archive_module.h +0 -59
  547. data/ext/pg_query/include/c.h +0 -1379
  548. data/ext/pg_query/include/catalog/catalog.h +0 -45
  549. data/ext/pg_query/include/catalog/catversion.h +0 -62
  550. data/ext/pg_query/include/catalog/dependency.h +0 -270
  551. data/ext/pg_query/include/catalog/genbki.h +0 -143
  552. data/ext/pg_query/include/catalog/index.h +0 -214
  553. data/ext/pg_query/include/catalog/indexing.h +0 -54
  554. data/ext/pg_query/include/catalog/namespace.h +0 -190
  555. data/ext/pg_query/include/catalog/objectaccess.h +0 -267
  556. data/ext/pg_query/include/catalog/objectaddress.h +0 -89
  557. data/ext/pg_query/include/catalog/pg_aggregate.h +0 -180
  558. data/ext/pg_query/include/catalog/pg_aggregate_d.h +0 -78
  559. data/ext/pg_query/include/catalog/pg_am.h +0 -63
  560. data/ext/pg_query/include/catalog/pg_am_d.h +0 -47
  561. data/ext/pg_query/include/catalog/pg_attribute.h +0 -223
  562. data/ext/pg_query/include/catalog/pg_attribute_d.h +0 -62
  563. data/ext/pg_query/include/catalog/pg_authid.h +0 -63
  564. data/ext/pg_query/include/catalog/pg_authid_d.h +0 -59
  565. data/ext/pg_query/include/catalog/pg_class.h +0 -230
  566. data/ext/pg_query/include/catalog/pg_class_d.h +0 -132
  567. data/ext/pg_query/include/catalog/pg_collation.h +0 -100
  568. data/ext/pg_query/include/catalog/pg_collation_d.h +0 -63
  569. data/ext/pg_query/include/catalog/pg_constraint.h +0 -273
  570. data/ext/pg_query/include/catalog/pg_constraint_d.h +0 -73
  571. data/ext/pg_query/include/catalog/pg_control.h +0 -258
  572. data/ext/pg_query/include/catalog/pg_conversion.h +0 -75
  573. data/ext/pg_query/include/catalog/pg_conversion_d.h +0 -38
  574. data/ext/pg_query/include/catalog/pg_database.h +0 -124
  575. data/ext/pg_query/include/catalog/pg_database_d.h +0 -52
  576. data/ext/pg_query/include/catalog/pg_depend.h +0 -77
  577. data/ext/pg_query/include/catalog/pg_depend_d.h +0 -36
  578. data/ext/pg_query/include/catalog/pg_event_trigger.h +0 -57
  579. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +0 -36
  580. data/ext/pg_query/include/catalog/pg_index.h +0 -90
  581. data/ext/pg_query/include/catalog/pg_index_d.h +0 -59
  582. data/ext/pg_query/include/catalog/pg_language.h +0 -72
  583. data/ext/pg_query/include/catalog/pg_language_d.h +0 -41
  584. data/ext/pg_query/include/catalog/pg_namespace.h +0 -64
  585. data/ext/pg_query/include/catalog/pg_namespace_d.h +0 -36
  586. data/ext/pg_query/include/catalog/pg_opclass.h +0 -88
  587. data/ext/pg_query/include/catalog/pg_opclass_d.h +0 -51
  588. data/ext/pg_query/include/catalog/pg_operator.h +0 -107
  589. data/ext/pg_query/include/catalog/pg_operator_d.h +0 -142
  590. data/ext/pg_query/include/catalog/pg_opfamily.h +0 -64
  591. data/ext/pg_query/include/catalog/pg_opfamily_d.h +0 -51
  592. data/ext/pg_query/include/catalog/pg_partitioned_table.h +0 -74
  593. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +0 -36
  594. data/ext/pg_query/include/catalog/pg_proc.h +0 -220
  595. data/ext/pg_query/include/catalog/pg_proc_d.h +0 -101
  596. data/ext/pg_query/include/catalog/pg_publication.h +0 -158
  597. data/ext/pg_query/include/catalog/pg_publication_d.h +0 -38
  598. data/ext/pg_query/include/catalog/pg_replication_origin.h +0 -62
  599. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +0 -33
  600. data/ext/pg_query/include/catalog/pg_statistic.h +0 -282
  601. data/ext/pg_query/include/catalog/pg_statistic_d.h +0 -195
  602. data/ext/pg_query/include/catalog/pg_statistic_ext.h +0 -88
  603. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +0 -45
  604. data/ext/pg_query/include/catalog/pg_transform.h +0 -48
  605. data/ext/pg_query/include/catalog/pg_transform_d.h +0 -34
  606. data/ext/pg_query/include/catalog/pg_trigger.h +0 -153
  607. data/ext/pg_query/include/catalog/pg_trigger_d.h +0 -109
  608. data/ext/pg_query/include/catalog/pg_ts_config.h +0 -53
  609. data/ext/pg_query/include/catalog/pg_ts_config_d.h +0 -34
  610. data/ext/pg_query/include/catalog/pg_ts_dict.h +0 -59
  611. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +0 -35
  612. data/ext/pg_query/include/catalog/pg_ts_parser.h +0 -60
  613. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +0 -37
  614. data/ext/pg_query/include/catalog/pg_ts_template.h +0 -51
  615. data/ext/pg_query/include/catalog/pg_ts_template_d.h +0 -34
  616. data/ext/pg_query/include/catalog/pg_type.h +0 -404
  617. data/ext/pg_query/include/catalog/pg_type_d.h +0 -324
  618. data/ext/pg_query/include/catalog/storage.h +0 -50
  619. data/ext/pg_query/include/commands/async.h +0 -53
  620. data/ext/pg_query/include/commands/dbcommands.h +0 -37
  621. data/ext/pg_query/include/commands/defrem.h +0 -161
  622. data/ext/pg_query/include/commands/event_trigger.h +0 -88
  623. data/ext/pg_query/include/commands/explain.h +0 -129
  624. data/ext/pg_query/include/commands/prepare.h +0 -61
  625. data/ext/pg_query/include/commands/tablespace.h +0 -69
  626. data/ext/pg_query/include/commands/trigger.h +0 -288
  627. data/ext/pg_query/include/commands/vacuum.h +0 -386
  628. data/ext/pg_query/include/common/cryptohash.h +0 -39
  629. data/ext/pg_query/include/common/file_perm.h +0 -56
  630. data/ext/pg_query/include/common/hashfn.h +0 -104
  631. data/ext/pg_query/include/common/int.h +0 -437
  632. data/ext/pg_query/include/common/ip.h +0 -33
  633. data/ext/pg_query/include/common/keywords.h +0 -29
  634. data/ext/pg_query/include/common/kwlookup.h +0 -44
  635. data/ext/pg_query/include/common/pg_prng.h +0 -61
  636. data/ext/pg_query/include/common/relpath.h +0 -97
  637. data/ext/pg_query/include/common/scram-common.h +0 -70
  638. data/ext/pg_query/include/common/sha2.h +0 -32
  639. data/ext/pg_query/include/common/string.h +0 -44
  640. data/ext/pg_query/include/common/unicode_east_asian_fw_table.h +0 -125
  641. data/ext/pg_query/include/copyfuncs.funcs.c +0 -5013
  642. data/ext/pg_query/include/copyfuncs.switch.c +0 -938
  643. data/ext/pg_query/include/datatype/timestamp.h +0 -243
  644. data/ext/pg_query/include/equalfuncs.funcs.c +0 -3097
  645. data/ext/pg_query/include/equalfuncs.switch.c +0 -785
  646. data/ext/pg_query/include/executor/execdesc.h +0 -70
  647. data/ext/pg_query/include/executor/executor.h +0 -680
  648. data/ext/pg_query/include/executor/functions.h +0 -55
  649. data/ext/pg_query/include/executor/instrument.h +0 -118
  650. data/ext/pg_query/include/executor/spi.h +0 -213
  651. data/ext/pg_query/include/executor/tablefunc.h +0 -67
  652. data/ext/pg_query/include/executor/tuptable.h +0 -494
  653. data/ext/pg_query/include/fmgr.h +0 -800
  654. data/ext/pg_query/include/foreign/fdwapi.h +0 -294
  655. data/ext/pg_query/include/funcapi.h +0 -360
  656. data/ext/pg_query/include/gram.h +0 -1127
  657. data/ext/pg_query/include/gramparse.h +0 -75
  658. data/ext/pg_query/include/jit/jit.h +0 -105
  659. data/ext/pg_query/include/kwlist_d.h +0 -1119
  660. data/ext/pg_query/include/lib/dshash.h +0 -115
  661. data/ext/pg_query/include/lib/ilist.h +0 -1159
  662. data/ext/pg_query/include/lib/pairingheap.h +0 -102
  663. data/ext/pg_query/include/lib/simplehash.h +0 -1184
  664. data/ext/pg_query/include/lib/sort_template.h +0 -432
  665. data/ext/pg_query/include/lib/stringinfo.h +0 -161
  666. data/ext/pg_query/include/libpq/auth.h +0 -37
  667. data/ext/pg_query/include/libpq/crypt.h +0 -47
  668. data/ext/pg_query/include/libpq/hba.h +0 -186
  669. data/ext/pg_query/include/libpq/libpq-be.h +0 -354
  670. data/ext/pg_query/include/libpq/libpq.h +0 -144
  671. data/ext/pg_query/include/libpq/pqcomm.h +0 -163
  672. data/ext/pg_query/include/libpq/pqformat.h +0 -210
  673. data/ext/pg_query/include/libpq/pqsignal.h +0 -54
  674. data/ext/pg_query/include/libpq/sasl.h +0 -136
  675. data/ext/pg_query/include/libpq/scram.h +0 -37
  676. data/ext/pg_query/include/mb/pg_wchar.h +0 -772
  677. data/ext/pg_query/include/mb/stringinfo_mb.h +0 -24
  678. data/ext/pg_query/include/miscadmin.h +0 -507
  679. data/ext/pg_query/include/nodes/bitmapset.h +0 -126
  680. data/ext/pg_query/include/nodes/execnodes.h +0 -2768
  681. data/ext/pg_query/include/nodes/extensible.h +0 -164
  682. data/ext/pg_query/include/nodes/lockoptions.h +0 -61
  683. data/ext/pg_query/include/nodes/makefuncs.h +0 -121
  684. data/ext/pg_query/include/nodes/memnodes.h +0 -113
  685. data/ext/pg_query/include/nodes/miscnodes.h +0 -56
  686. data/ext/pg_query/include/nodes/nodeFuncs.h +0 -222
  687. data/ext/pg_query/include/nodes/nodes.h +0 -446
  688. data/ext/pg_query/include/nodes/nodetags.h +0 -471
  689. data/ext/pg_query/include/nodes/params.h +0 -170
  690. data/ext/pg_query/include/nodes/parsenodes.h +0 -4050
  691. data/ext/pg_query/include/nodes/pathnodes.h +0 -3384
  692. data/ext/pg_query/include/nodes/pg_list.h +0 -635
  693. data/ext/pg_query/include/nodes/plannodes.h +0 -1592
  694. data/ext/pg_query/include/nodes/primnodes.h +0 -2041
  695. data/ext/pg_query/include/nodes/print.h +0 -34
  696. data/ext/pg_query/include/nodes/queryjumble.h +0 -86
  697. data/ext/pg_query/include/nodes/replnodes.h +0 -111
  698. data/ext/pg_query/include/nodes/supportnodes.h +0 -346
  699. data/ext/pg_query/include/nodes/tidbitmap.h +0 -75
  700. data/ext/pg_query/include/nodes/value.h +0 -90
  701. data/ext/pg_query/include/optimizer/cost.h +0 -215
  702. data/ext/pg_query/include/optimizer/geqo.h +0 -90
  703. data/ext/pg_query/include/optimizer/geqo_gene.h +0 -45
  704. data/ext/pg_query/include/optimizer/optimizer.h +0 -202
  705. data/ext/pg_query/include/optimizer/paths.h +0 -266
  706. data/ext/pg_query/include/optimizer/planmain.h +0 -117
  707. data/ext/pg_query/include/parser/analyze.h +0 -64
  708. data/ext/pg_query/include/parser/kwlist.h +0 -498
  709. data/ext/pg_query/include/parser/parse_agg.h +0 -65
  710. data/ext/pg_query/include/parser/parse_coerce.h +0 -102
  711. data/ext/pg_query/include/parser/parse_expr.h +0 -25
  712. data/ext/pg_query/include/parser/parse_func.h +0 -74
  713. data/ext/pg_query/include/parser/parse_node.h +0 -357
  714. data/ext/pg_query/include/parser/parse_oper.h +0 -65
  715. data/ext/pg_query/include/parser/parse_relation.h +0 -129
  716. data/ext/pg_query/include/parser/parse_type.h +0 -61
  717. data/ext/pg_query/include/parser/parser.h +0 -68
  718. data/ext/pg_query/include/parser/parsetree.h +0 -61
  719. data/ext/pg_query/include/parser/scanner.h +0 -152
  720. data/ext/pg_query/include/parser/scansup.h +0 -27
  721. data/ext/pg_query/include/partitioning/partdefs.h +0 -26
  722. data/ext/pg_query/include/pg_config.h +0 -843
  723. data/ext/pg_query/include/pg_config_manual.h +0 -372
  724. data/ext/pg_query/include/pg_config_os.h +0 -8
  725. data/ext/pg_query/include/pg_getopt.h +0 -56
  726. data/ext/pg_query/include/pg_trace.h +0 -17
  727. data/ext/pg_query/include/pgstat.h +0 -778
  728. data/ext/pg_query/include/pgtime.h +0 -94
  729. data/ext/pg_query/include/pl_gram.h +0 -385
  730. data/ext/pg_query/include/pl_reserved_kwlist.h +0 -52
  731. data/ext/pg_query/include/pl_reserved_kwlist_d.h +0 -114
  732. data/ext/pg_query/include/pl_unreserved_kwlist.h +0 -112
  733. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +0 -246
  734. data/ext/pg_query/include/plerrcodes.h +0 -998
  735. data/ext/pg_query/include/plpgsql.h +0 -1340
  736. data/ext/pg_query/include/port/atomics/arch-arm.h +0 -32
  737. data/ext/pg_query/include/port/atomics/arch-ppc.h +0 -254
  738. data/ext/pg_query/include/port/atomics/arch-x86.h +0 -252
  739. data/ext/pg_query/include/port/atomics/fallback.h +0 -170
  740. data/ext/pg_query/include/port/atomics/generic-gcc.h +0 -286
  741. data/ext/pg_query/include/port/atomics/generic.h +0 -401
  742. data/ext/pg_query/include/port/atomics.h +0 -519
  743. data/ext/pg_query/include/port/pg_bitutils.h +0 -339
  744. data/ext/pg_query/include/port/pg_bswap.h +0 -161
  745. data/ext/pg_query/include/port/pg_crc32c.h +0 -101
  746. data/ext/pg_query/include/port/simd.h +0 -375
  747. data/ext/pg_query/include/port.h +0 -520
  748. data/ext/pg_query/include/portability/instr_time.h +0 -197
  749. data/ext/pg_query/include/postgres.h +0 -579
  750. data/ext/pg_query/include/postmaster/autovacuum.h +0 -80
  751. data/ext/pg_query/include/postmaster/auxprocess.h +0 -20
  752. data/ext/pg_query/include/postmaster/bgworker.h +0 -162
  753. data/ext/pg_query/include/postmaster/bgworker_internals.h +0 -64
  754. data/ext/pg_query/include/postmaster/bgwriter.h +0 -45
  755. data/ext/pg_query/include/postmaster/fork_process.h +0 -17
  756. data/ext/pg_query/include/postmaster/interrupt.h +0 -32
  757. data/ext/pg_query/include/postmaster/pgarch.h +0 -36
  758. data/ext/pg_query/include/postmaster/postmaster.h +0 -81
  759. data/ext/pg_query/include/postmaster/startup.h +0 -41
  760. data/ext/pg_query/include/postmaster/syslogger.h +0 -103
  761. data/ext/pg_query/include/postmaster/walwriter.h +0 -23
  762. data/ext/pg_query/include/regex/regex.h +0 -189
  763. data/ext/pg_query/include/replication/logicallauncher.h +0 -34
  764. data/ext/pg_query/include/replication/logicalproto.h +0 -274
  765. data/ext/pg_query/include/replication/logicalworker.h +0 -32
  766. data/ext/pg_query/include/replication/origin.h +0 -73
  767. data/ext/pg_query/include/replication/reorderbuffer.h +0 -753
  768. data/ext/pg_query/include/replication/slot.h +0 -249
  769. data/ext/pg_query/include/replication/syncrep.h +0 -109
  770. data/ext/pg_query/include/replication/walreceiver.h +0 -478
  771. data/ext/pg_query/include/replication/walsender.h +0 -74
  772. data/ext/pg_query/include/rewrite/prs2lock.h +0 -46
  773. data/ext/pg_query/include/rewrite/rewriteHandler.h +0 -35
  774. data/ext/pg_query/include/rewrite/rewriteManip.h +0 -96
  775. data/ext/pg_query/include/rewrite/rewriteSupport.h +0 -26
  776. data/ext/pg_query/include/src_backend_nodes_copyfuncs.funcs.c +0 -5321
  777. data/ext/pg_query/include/src_backend_nodes_equalfuncs.funcs.c +0 -3354
  778. data/ext/pg_query/include/storage/backendid.h +0 -37
  779. data/ext/pg_query/include/storage/block.h +0 -108
  780. data/ext/pg_query/include/storage/buf.h +0 -46
  781. data/ext/pg_query/include/storage/bufmgr.h +0 -393
  782. data/ext/pg_query/include/storage/bufpage.h +0 -510
  783. data/ext/pg_query/include/storage/condition_variable.h +0 -73
  784. data/ext/pg_query/include/storage/dsm.h +0 -61
  785. data/ext/pg_query/include/storage/dsm_impl.h +0 -79
  786. data/ext/pg_query/include/storage/fd.h +0 -202
  787. data/ext/pg_query/include/storage/fileset.h +0 -40
  788. data/ext/pg_query/include/storage/ipc.h +0 -84
  789. data/ext/pg_query/include/storage/item.h +0 -19
  790. data/ext/pg_query/include/storage/itemid.h +0 -184
  791. data/ext/pg_query/include/storage/itemptr.h +0 -245
  792. data/ext/pg_query/include/storage/large_object.h +0 -100
  793. data/ext/pg_query/include/storage/latch.h +0 -194
  794. data/ext/pg_query/include/storage/lmgr.h +0 -120
  795. data/ext/pg_query/include/storage/lock.h +0 -624
  796. data/ext/pg_query/include/storage/lockdefs.h +0 -59
  797. data/ext/pg_query/include/storage/lwlock.h +0 -220
  798. data/ext/pg_query/include/storage/lwlocknames.h +0 -50
  799. data/ext/pg_query/include/storage/off.h +0 -57
  800. data/ext/pg_query/include/storage/pg_sema.h +0 -61
  801. data/ext/pg_query/include/storage/pg_shmem.h +0 -92
  802. data/ext/pg_query/include/storage/pmsignal.h +0 -105
  803. data/ext/pg_query/include/storage/predicate.h +0 -87
  804. data/ext/pg_query/include/storage/proc.h +0 -466
  805. data/ext/pg_query/include/storage/procarray.h +0 -99
  806. data/ext/pg_query/include/storage/proclist_types.h +0 -51
  807. data/ext/pg_query/include/storage/procsignal.h +0 -73
  808. data/ext/pg_query/include/storage/relfilelocator.h +0 -99
  809. data/ext/pg_query/include/storage/s_lock.h +0 -867
  810. data/ext/pg_query/include/storage/sharedfileset.h +0 -37
  811. data/ext/pg_query/include/storage/shm_mq.h +0 -86
  812. data/ext/pg_query/include/storage/shm_toc.h +0 -58
  813. data/ext/pg_query/include/storage/shmem.h +0 -59
  814. data/ext/pg_query/include/storage/sinval.h +0 -153
  815. data/ext/pg_query/include/storage/sinvaladt.h +0 -45
  816. data/ext/pg_query/include/storage/smgr.h +0 -113
  817. data/ext/pg_query/include/storage/spin.h +0 -77
  818. data/ext/pg_query/include/storage/standby.h +0 -99
  819. data/ext/pg_query/include/storage/standbydefs.h +0 -74
  820. data/ext/pg_query/include/storage/sync.h +0 -66
  821. data/ext/pg_query/include/tcop/cmdtag.h +0 -63
  822. data/ext/pg_query/include/tcop/cmdtaglist.h +0 -218
  823. data/ext/pg_query/include/tcop/deparse_utility.h +0 -108
  824. data/ext/pg_query/include/tcop/dest.h +0 -147
  825. data/ext/pg_query/include/tcop/fastpath.h +0 -20
  826. data/ext/pg_query/include/tcop/pquery.h +0 -51
  827. data/ext/pg_query/include/tcop/tcopprot.h +0 -94
  828. data/ext/pg_query/include/tcop/utility.h +0 -112
  829. data/ext/pg_query/include/tsearch/ts_cache.h +0 -96
  830. data/ext/pg_query/include/utils/acl.h +0 -278
  831. data/ext/pg_query/include/utils/aclchk_internal.h +0 -45
  832. data/ext/pg_query/include/utils/array.h +0 -482
  833. data/ext/pg_query/include/utils/backend_progress.h +0 -45
  834. data/ext/pg_query/include/utils/backend_status.h +0 -342
  835. data/ext/pg_query/include/utils/builtins.h +0 -136
  836. data/ext/pg_query/include/utils/bytea.h +0 -28
  837. data/ext/pg_query/include/utils/catcache.h +0 -231
  838. data/ext/pg_query/include/utils/date.h +0 -118
  839. data/ext/pg_query/include/utils/datetime.h +0 -364
  840. data/ext/pg_query/include/utils/datum.h +0 -76
  841. data/ext/pg_query/include/utils/dsa.h +0 -127
  842. data/ext/pg_query/include/utils/elog.h +0 -545
  843. data/ext/pg_query/include/utils/errcodes.h +0 -354
  844. data/ext/pg_query/include/utils/expandeddatum.h +0 -170
  845. data/ext/pg_query/include/utils/expandedrecord.h +0 -241
  846. data/ext/pg_query/include/utils/float.h +0 -357
  847. data/ext/pg_query/include/utils/fmgroids.h +0 -3314
  848. data/ext/pg_query/include/utils/fmgrprotos.h +0 -2871
  849. data/ext/pg_query/include/utils/fmgrtab.h +0 -49
  850. data/ext/pg_query/include/utils/guc.h +0 -442
  851. data/ext/pg_query/include/utils/guc_hooks.h +0 -163
  852. data/ext/pg_query/include/utils/guc_tables.h +0 -322
  853. data/ext/pg_query/include/utils/hsearch.h +0 -153
  854. data/ext/pg_query/include/utils/inval.h +0 -68
  855. data/ext/pg_query/include/utils/logtape.h +0 -77
  856. data/ext/pg_query/include/utils/lsyscache.h +0 -212
  857. data/ext/pg_query/include/utils/memdebug.h +0 -82
  858. data/ext/pg_query/include/utils/memutils.h +0 -186
  859. data/ext/pg_query/include/utils/memutils_internal.h +0 -136
  860. data/ext/pg_query/include/utils/memutils_memorychunk.h +0 -237
  861. data/ext/pg_query/include/utils/numeric.h +0 -105
  862. data/ext/pg_query/include/utils/palloc.h +0 -165
  863. data/ext/pg_query/include/utils/partcache.h +0 -103
  864. data/ext/pg_query/include/utils/pg_locale.h +0 -135
  865. data/ext/pg_query/include/utils/pgstat_internal.h +0 -814
  866. data/ext/pg_query/include/utils/pidfile.h +0 -56
  867. data/ext/pg_query/include/utils/plancache.h +0 -236
  868. data/ext/pg_query/include/utils/portal.h +0 -252
  869. data/ext/pg_query/include/utils/queryenvironment.h +0 -74
  870. data/ext/pg_query/include/utils/regproc.h +0 -39
  871. data/ext/pg_query/include/utils/rel.h +0 -712
  872. data/ext/pg_query/include/utils/relcache.h +0 -158
  873. data/ext/pg_query/include/utils/reltrigger.h +0 -81
  874. data/ext/pg_query/include/utils/resowner.h +0 -86
  875. data/ext/pg_query/include/utils/ruleutils.h +0 -52
  876. data/ext/pg_query/include/utils/sharedtuplestore.h +0 -61
  877. data/ext/pg_query/include/utils/snapmgr.h +0 -181
  878. data/ext/pg_query/include/utils/snapshot.h +0 -219
  879. data/ext/pg_query/include/utils/sortsupport.h +0 -391
  880. data/ext/pg_query/include/utils/syscache.h +0 -227
  881. data/ext/pg_query/include/utils/timeout.h +0 -95
  882. data/ext/pg_query/include/utils/timestamp.h +0 -147
  883. data/ext/pg_query/include/utils/tuplesort.h +0 -445
  884. data/ext/pg_query/include/utils/tuplestore.h +0 -91
  885. data/ext/pg_query/include/utils/typcache.h +0 -209
  886. data/ext/pg_query/include/utils/varlena.h +0 -53
  887. data/ext/pg_query/include/utils/wait_event.h +0 -294
  888. data/ext/pg_query/include/utils/xml.h +0 -94
  889. data/ext/pg_query/include/varatt.h +0 -358
  890. data/ext/pg_query/src_backend_postmaster_postmaster.c +0 -2220
  891. data/ext/pg_query/src_port_strnlen.c +0 -39
  892. /data/ext/pg_query/include/{access → postgres/access}/rmgr.h +0 -0
  893. /data/ext/pg_query/include/{commands → postgres/commands}/user.h +0 -0
  894. /data/ext/pg_query/include/{common → postgres/common}/unicode_nonspacing_table.h +0 -0
  895. /data/ext/pg_query/include/{pg_config_ext.h → postgres/pg_config_ext.h} +0 -0
  896. /data/ext/pg_query/include/{postgres_ext.h → postgres/postgres_ext.h} +0 -0
  897. /data/ext/pg_query/include/{utils → postgres/utils}/probes.h +0 -0
  898. /data/ext/pg_query/include/{utils → postgres/utils}/ps_status.h +0 -0
@@ -0,0 +1,4233 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * parsenodes.h
4
+ * definitions for parse tree nodes
5
+ *
6
+ * Many of the node types used in parsetrees include a "location" field.
7
+ * This is a byte (not character) offset in the original source text, to be
8
+ * used for positioning an error cursor when there is an error related to
9
+ * the node. Access to the original source text is needed to make use of
10
+ * the location. At the topmost (statement) level, we also provide a
11
+ * statement length, likewise measured in bytes, for convenience in
12
+ * identifying statement boundaries in multi-statement source strings.
13
+ *
14
+ *
15
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
16
+ * Portions Copyright (c) 1994, Regents of the University of California
17
+ *
18
+ * src/include/nodes/parsenodes.h
19
+ *
20
+ *-------------------------------------------------------------------------
21
+ */
22
+ #ifndef PARSENODES_H
23
+ #define PARSENODES_H
24
+
25
+ #include "common/relpath.h"
26
+ #include "nodes/bitmapset.h"
27
+ #include "nodes/lockoptions.h"
28
+ #include "nodes/primnodes.h"
29
+ #include "nodes/value.h"
30
+ #include "partitioning/partdefs.h"
31
+
32
+
33
+ /* Possible sources of a Query */
34
+ typedef enum QuerySource
35
+ {
36
+ QSRC_ORIGINAL, /* original parsetree (explicit query) */
37
+ QSRC_PARSER, /* added by parse analysis (now unused) */
38
+ QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */
39
+ QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */
40
+ QSRC_NON_INSTEAD_RULE, /* added by non-INSTEAD rule */
41
+ } QuerySource;
42
+
43
+ /* Sort ordering options for ORDER BY and CREATE INDEX */
44
+ typedef enum SortByDir
45
+ {
46
+ SORTBY_DEFAULT,
47
+ SORTBY_ASC,
48
+ SORTBY_DESC,
49
+ SORTBY_USING, /* not allowed in CREATE INDEX ... */
50
+ } SortByDir;
51
+
52
+ typedef enum SortByNulls
53
+ {
54
+ SORTBY_NULLS_DEFAULT,
55
+ SORTBY_NULLS_FIRST,
56
+ SORTBY_NULLS_LAST,
57
+ } SortByNulls;
58
+
59
+ /* Options for [ ALL | DISTINCT ] */
60
+ typedef enum SetQuantifier
61
+ {
62
+ SET_QUANTIFIER_DEFAULT,
63
+ SET_QUANTIFIER_ALL,
64
+ SET_QUANTIFIER_DISTINCT,
65
+ } SetQuantifier;
66
+
67
+ /*
68
+ * Grantable rights are encoded so that we can OR them together in a bitmask.
69
+ * The present representation of AclItem limits us to 32 distinct rights,
70
+ * even though AclMode is defined as uint64. See utils/acl.h.
71
+ *
72
+ * Caution: changing these codes breaks stored ACLs, hence forces initdb.
73
+ */
74
+ typedef uint64 AclMode; /* a bitmask of privilege bits */
75
+
76
+ #define ACL_INSERT (1<<0) /* for relations */
77
+ #define ACL_SELECT (1<<1)
78
+ #define ACL_UPDATE (1<<2)
79
+ #define ACL_DELETE (1<<3)
80
+ #define ACL_TRUNCATE (1<<4)
81
+ #define ACL_REFERENCES (1<<5)
82
+ #define ACL_TRIGGER (1<<6)
83
+ #define ACL_EXECUTE (1<<7) /* for functions */
84
+ #define ACL_USAGE (1<<8) /* for various object types */
85
+ #define ACL_CREATE (1<<9) /* for namespaces and databases */
86
+ #define ACL_CREATE_TEMP (1<<10) /* for databases */
87
+ #define ACL_CONNECT (1<<11) /* for databases */
88
+ #define ACL_SET (1<<12) /* for configuration parameters */
89
+ #define ACL_ALTER_SYSTEM (1<<13) /* for configuration parameters */
90
+ #define ACL_MAINTAIN (1<<14) /* for relations */
91
+ #define N_ACL_RIGHTS 15 /* 1 plus the last 1<<x */
92
+ #define ACL_NO_RIGHTS 0
93
+ /* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
94
+ #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
95
+
96
+
97
+ /*****************************************************************************
98
+ * Query Tree
99
+ *****************************************************************************/
100
+
101
+ /*
102
+ * Query -
103
+ * Parse analysis turns all statements into a Query tree
104
+ * for further processing by the rewriter and planner.
105
+ *
106
+ * Utility statements (i.e. non-optimizable statements) have the
107
+ * utilityStmt field set, and the rest of the Query is mostly dummy.
108
+ *
109
+ * Planning converts a Query tree into a Plan tree headed by a PlannedStmt
110
+ * node --- the Query structure is not used by the executor.
111
+ *
112
+ * All the fields ignored for the query jumbling are not semantically
113
+ * significant (such as alias names), as is ignored anything that can
114
+ * be deduced from child nodes (else we'd just be double-hashing that
115
+ * piece of information).
116
+ */
117
+ typedef struct Query
118
+ {
119
+ NodeTag type;
120
+
121
+ CmdType commandType; /* select|insert|update|delete|merge|utility */
122
+
123
+ /* where did I come from? */
124
+ QuerySource querySource pg_node_attr(query_jumble_ignore);
125
+
126
+ /*
127
+ * query identifier (can be set by plugins); ignored for equal, as it
128
+ * might not be set; also not stored. This is the result of the query
129
+ * jumble, hence ignored.
130
+ */
131
+ uint64 queryId pg_node_attr(equal_ignore, query_jumble_ignore, read_write_ignore, read_as(0));
132
+
133
+ /* do I set the command result tag? */
134
+ bool canSetTag pg_node_attr(query_jumble_ignore);
135
+
136
+ Node *utilityStmt; /* non-null if commandType == CMD_UTILITY */
137
+
138
+ /*
139
+ * rtable index of target relation for INSERT/UPDATE/DELETE/MERGE; 0 for
140
+ * SELECT. This is ignored in the query jumble as unrelated to the
141
+ * compilation of the query ID.
142
+ */
143
+ int resultRelation pg_node_attr(query_jumble_ignore);
144
+
145
+ /* has aggregates in tlist or havingQual */
146
+ bool hasAggs pg_node_attr(query_jumble_ignore);
147
+ /* has window functions in tlist */
148
+ bool hasWindowFuncs pg_node_attr(query_jumble_ignore);
149
+ /* has set-returning functions in tlist */
150
+ bool hasTargetSRFs pg_node_attr(query_jumble_ignore);
151
+ /* has subquery SubLink */
152
+ bool hasSubLinks pg_node_attr(query_jumble_ignore);
153
+ /* distinctClause is from DISTINCT ON */
154
+ bool hasDistinctOn pg_node_attr(query_jumble_ignore);
155
+ /* WITH RECURSIVE was specified */
156
+ bool hasRecursive pg_node_attr(query_jumble_ignore);
157
+ /* has INSERT/UPDATE/DELETE/MERGE in WITH */
158
+ bool hasModifyingCTE pg_node_attr(query_jumble_ignore);
159
+ /* FOR [KEY] UPDATE/SHARE was specified */
160
+ bool hasForUpdate pg_node_attr(query_jumble_ignore);
161
+ /* rewriter has applied some RLS policy */
162
+ bool hasRowSecurity pg_node_attr(query_jumble_ignore);
163
+ /* is a RETURN statement */
164
+ bool isReturn pg_node_attr(query_jumble_ignore);
165
+
166
+ List *cteList; /* WITH list (of CommonTableExpr's) */
167
+
168
+ List *rtable; /* list of range table entries */
169
+
170
+ /*
171
+ * list of RTEPermissionInfo nodes for the rtable entries having
172
+ * perminfoindex > 0
173
+ */
174
+ List *rteperminfos pg_node_attr(query_jumble_ignore);
175
+ FromExpr *jointree; /* table join tree (FROM and WHERE clauses);
176
+ * also USING clause for MERGE */
177
+
178
+ List *mergeActionList; /* list of actions for MERGE (only) */
179
+
180
+ /*
181
+ * rtable index of target relation for MERGE to pull data. Initially, this
182
+ * is the same as resultRelation, but after query rewriting, if the target
183
+ * relation is a trigger-updatable view, this is the index of the expanded
184
+ * view subquery, whereas resultRelation is the index of the target view.
185
+ */
186
+ int mergeTargetRelation pg_node_attr(query_jumble_ignore);
187
+
188
+ /* join condition between source and target for MERGE */
189
+ Node *mergeJoinCondition;
190
+
191
+ List *targetList; /* target list (of TargetEntry) */
192
+
193
+ /* OVERRIDING clause */
194
+ OverridingKind override pg_node_attr(query_jumble_ignore);
195
+
196
+ OnConflictExpr *onConflict; /* ON CONFLICT DO [NOTHING | UPDATE] */
197
+
198
+ List *returningList; /* return-values list (of TargetEntry) */
199
+
200
+ List *groupClause; /* a list of SortGroupClause's */
201
+ bool groupDistinct; /* is the group by clause distinct? */
202
+
203
+ List *groupingSets; /* a list of GroupingSet's if present */
204
+
205
+ Node *havingQual; /* qualifications applied to groups */
206
+
207
+ List *windowClause; /* a list of WindowClause's */
208
+
209
+ List *distinctClause; /* a list of SortGroupClause's */
210
+
211
+ List *sortClause; /* a list of SortGroupClause's */
212
+
213
+ Node *limitOffset; /* # of result tuples to skip (int8 expr) */
214
+ Node *limitCount; /* # of result tuples to return (int8 expr) */
215
+ LimitOption limitOption; /* limit type */
216
+
217
+ List *rowMarks; /* a list of RowMarkClause's */
218
+
219
+ Node *setOperations; /* set-operation tree if this is top level of
220
+ * a UNION/INTERSECT/EXCEPT query */
221
+
222
+ /*
223
+ * A list of pg_constraint OIDs that the query depends on to be
224
+ * semantically valid
225
+ */
226
+ List *constraintDeps pg_node_attr(query_jumble_ignore);
227
+
228
+ /* a list of WithCheckOption's (added during rewrite) */
229
+ List *withCheckOptions pg_node_attr(query_jumble_ignore);
230
+
231
+ /*
232
+ * The following two fields identify the portion of the source text string
233
+ * containing this query. They are typically only populated in top-level
234
+ * Queries, not in sub-queries. When not set, they might both be zero, or
235
+ * both be -1 meaning "unknown".
236
+ */
237
+ /* start location, or -1 if unknown */
238
+ ParseLoc stmt_location;
239
+ /* length in bytes; 0 means "rest of string" */
240
+ ParseLoc stmt_len pg_node_attr(query_jumble_ignore);
241
+ } Query;
242
+
243
+
244
+ /****************************************************************************
245
+ * Supporting data structures for Parse Trees
246
+ *
247
+ * Most of these node types appear in raw parsetrees output by the grammar,
248
+ * and get transformed to something else by the analyzer. A few of them
249
+ * are used as-is in transformed querytrees.
250
+ ****************************************************************************/
251
+
252
+ /*
253
+ * TypeName - specifies a type in definitions
254
+ *
255
+ * For TypeName structures generated internally, it is often easier to
256
+ * specify the type by OID than by name. If "names" is NIL then the
257
+ * actual type OID is given by typeOid, otherwise typeOid is unused.
258
+ * Similarly, if "typmods" is NIL then the actual typmod is expected to
259
+ * be prespecified in typemod, otherwise typemod is unused.
260
+ *
261
+ * If pct_type is true, then names is actually a field name and we look up
262
+ * the type of that field. Otherwise (the normal case), names is a type
263
+ * name possibly qualified with schema and database name.
264
+ */
265
+ typedef struct TypeName
266
+ {
267
+ NodeTag type;
268
+ List *names; /* qualified name (list of String nodes) */
269
+ Oid typeOid; /* type identified by OID */
270
+ bool setof; /* is a set? */
271
+ bool pct_type; /* %TYPE specified? */
272
+ List *typmods; /* type modifier expression(s) */
273
+ int32 typemod; /* prespecified type modifier */
274
+ List *arrayBounds; /* array bounds */
275
+ ParseLoc location; /* token location, or -1 if unknown */
276
+ } TypeName;
277
+
278
+ /*
279
+ * ColumnRef - specifies a reference to a column, or possibly a whole tuple
280
+ *
281
+ * The "fields" list must be nonempty. It can contain String nodes
282
+ * (representing names) and A_Star nodes (representing occurrence of a '*').
283
+ * Currently, A_Star must appear only as the last list element --- the grammar
284
+ * is responsible for enforcing this!
285
+ *
286
+ * Note: any container subscripting or selection of fields from composite columns
287
+ * is represented by an A_Indirection node above the ColumnRef. However,
288
+ * for simplicity in the normal case, initial field selection from a table
289
+ * name is represented within ColumnRef and not by adding A_Indirection.
290
+ */
291
+ typedef struct ColumnRef
292
+ {
293
+ NodeTag type;
294
+ List *fields; /* field names (String nodes) or A_Star */
295
+ ParseLoc location; /* token location, or -1 if unknown */
296
+ } ColumnRef;
297
+
298
+ /*
299
+ * ParamRef - specifies a $n parameter reference
300
+ */
301
+ typedef struct ParamRef
302
+ {
303
+ NodeTag type;
304
+ int number; /* the number of the parameter */
305
+ ParseLoc location; /* token location, or -1 if unknown */
306
+ } ParamRef;
307
+
308
+ /*
309
+ * A_Expr - infix, prefix, and postfix expressions
310
+ */
311
+ typedef enum A_Expr_Kind
312
+ {
313
+ AEXPR_OP, /* normal operator */
314
+ AEXPR_OP_ANY, /* scalar op ANY (array) */
315
+ AEXPR_OP_ALL, /* scalar op ALL (array) */
316
+ AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */
317
+ AEXPR_NOT_DISTINCT, /* IS NOT DISTINCT FROM - name must be "=" */
318
+ AEXPR_NULLIF, /* NULLIF - name must be "=" */
319
+ AEXPR_IN, /* [NOT] IN - name must be "=" or "<>" */
320
+ AEXPR_LIKE, /* [NOT] LIKE - name must be "~~" or "!~~" */
321
+ AEXPR_ILIKE, /* [NOT] ILIKE - name must be "~~*" or "!~~*" */
322
+ AEXPR_SIMILAR, /* [NOT] SIMILAR - name must be "~" or "!~" */
323
+ AEXPR_BETWEEN, /* name must be "BETWEEN" */
324
+ AEXPR_NOT_BETWEEN, /* name must be "NOT BETWEEN" */
325
+ AEXPR_BETWEEN_SYM, /* name must be "BETWEEN SYMMETRIC" */
326
+ AEXPR_NOT_BETWEEN_SYM, /* name must be "NOT BETWEEN SYMMETRIC" */
327
+ } A_Expr_Kind;
328
+
329
+ typedef struct A_Expr
330
+ {
331
+ pg_node_attr(custom_read_write)
332
+
333
+ NodeTag type;
334
+ A_Expr_Kind kind; /* see above */
335
+ List *name; /* possibly-qualified name of operator */
336
+ Node *lexpr; /* left argument, or NULL if none */
337
+ Node *rexpr; /* right argument, or NULL if none */
338
+ ParseLoc location; /* token location, or -1 if unknown */
339
+ } A_Expr;
340
+
341
+ /*
342
+ * A_Const - a literal constant
343
+ *
344
+ * Value nodes are inline for performance. You can treat 'val' as a node,
345
+ * as in IsA(&val, Integer). 'val' is not valid if isnull is true.
346
+ */
347
+ union ValUnion
348
+ {
349
+ Node node;
350
+ Integer ival;
351
+ Float fval;
352
+ Boolean boolval;
353
+ String sval;
354
+ BitString bsval;
355
+ };
356
+
357
+ typedef struct A_Const
358
+ {
359
+ pg_node_attr(custom_copy_equal, custom_read_write, custom_query_jumble)
360
+
361
+ NodeTag type;
362
+ union ValUnion val;
363
+ bool isnull; /* SQL NULL constant */
364
+ ParseLoc location; /* token location, or -1 if unknown */
365
+ } A_Const;
366
+
367
+ /*
368
+ * TypeCast - a CAST expression
369
+ */
370
+ typedef struct TypeCast
371
+ {
372
+ NodeTag type;
373
+ Node *arg; /* the expression being casted */
374
+ TypeName *typeName; /* the target type */
375
+ ParseLoc location; /* token location, or -1 if unknown */
376
+ } TypeCast;
377
+
378
+ /*
379
+ * CollateClause - a COLLATE expression
380
+ */
381
+ typedef struct CollateClause
382
+ {
383
+ NodeTag type;
384
+ Node *arg; /* input expression */
385
+ List *collname; /* possibly-qualified collation name */
386
+ ParseLoc location; /* token location, or -1 if unknown */
387
+ } CollateClause;
388
+
389
+ /*
390
+ * RoleSpec - a role name or one of a few special values.
391
+ */
392
+ typedef enum RoleSpecType
393
+ {
394
+ ROLESPEC_CSTRING, /* role name is stored as a C string */
395
+ ROLESPEC_CURRENT_ROLE, /* role spec is CURRENT_ROLE */
396
+ ROLESPEC_CURRENT_USER, /* role spec is CURRENT_USER */
397
+ ROLESPEC_SESSION_USER, /* role spec is SESSION_USER */
398
+ ROLESPEC_PUBLIC, /* role name is "public" */
399
+ } RoleSpecType;
400
+
401
+ typedef struct RoleSpec
402
+ {
403
+ NodeTag type;
404
+ RoleSpecType roletype; /* Type of this rolespec */
405
+ char *rolename; /* filled only for ROLESPEC_CSTRING */
406
+ ParseLoc location; /* token location, or -1 if unknown */
407
+ } RoleSpec;
408
+
409
+ /*
410
+ * FuncCall - a function or aggregate invocation
411
+ *
412
+ * agg_order (if not NIL) indicates we saw 'foo(... ORDER BY ...)', or if
413
+ * agg_within_group is true, it was 'foo(...) WITHIN GROUP (ORDER BY ...)'.
414
+ * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
415
+ * indicates we saw 'foo(DISTINCT ...)'. In any of these cases, the
416
+ * construct *must* be an aggregate call. Otherwise, it might be either an
417
+ * aggregate or some other kind of function. However, if FILTER or OVER is
418
+ * present it had better be an aggregate or window function.
419
+ *
420
+ * Normally, you'd initialize this via makeFuncCall() and then only change the
421
+ * parts of the struct its defaults don't match afterwards, as needed.
422
+ */
423
+ typedef struct FuncCall
424
+ {
425
+ NodeTag type;
426
+ List *funcname; /* qualified name of function */
427
+ List *args; /* the arguments (list of exprs) */
428
+ List *agg_order; /* ORDER BY (list of SortBy) */
429
+ Node *agg_filter; /* FILTER clause, if any */
430
+ struct WindowDef *over; /* OVER clause, if any */
431
+ bool agg_within_group; /* ORDER BY appeared in WITHIN GROUP */
432
+ bool agg_star; /* argument was really '*' */
433
+ bool agg_distinct; /* arguments were labeled DISTINCT */
434
+ bool func_variadic; /* last argument was labeled VARIADIC */
435
+ CoercionForm funcformat; /* how to display this node */
436
+ ParseLoc location; /* token location, or -1 if unknown */
437
+ } FuncCall;
438
+
439
+ /*
440
+ * A_Star - '*' representing all columns of a table or compound field
441
+ *
442
+ * This can appear within ColumnRef.fields, A_Indirection.indirection, and
443
+ * ResTarget.indirection lists.
444
+ */
445
+ typedef struct A_Star
446
+ {
447
+ NodeTag type;
448
+ } A_Star;
449
+
450
+ /*
451
+ * A_Indices - array subscript or slice bounds ([idx] or [lidx:uidx])
452
+ *
453
+ * In slice case, either or both of lidx and uidx can be NULL (omitted).
454
+ * In non-slice case, uidx holds the single subscript and lidx is always NULL.
455
+ */
456
+ typedef struct A_Indices
457
+ {
458
+ NodeTag type;
459
+ bool is_slice; /* true if slice (i.e., colon present) */
460
+ Node *lidx; /* slice lower bound, if any */
461
+ Node *uidx; /* subscript, or slice upper bound if any */
462
+ } A_Indices;
463
+
464
+ /*
465
+ * A_Indirection - select a field and/or array element from an expression
466
+ *
467
+ * The indirection list can contain A_Indices nodes (representing
468
+ * subscripting), String nodes (representing field selection --- the
469
+ * string value is the name of the field to select), and A_Star nodes
470
+ * (representing selection of all fields of a composite type).
471
+ * For example, a complex selection operation like
472
+ * (foo).field1[42][7].field2
473
+ * would be represented with a single A_Indirection node having a 4-element
474
+ * indirection list.
475
+ *
476
+ * Currently, A_Star must appear only as the last list element --- the grammar
477
+ * is responsible for enforcing this!
478
+ */
479
+ typedef struct A_Indirection
480
+ {
481
+ NodeTag type;
482
+ Node *arg; /* the thing being selected from */
483
+ List *indirection; /* subscripts and/or field names and/or * */
484
+ } A_Indirection;
485
+
486
+ /*
487
+ * A_ArrayExpr - an ARRAY[] construct
488
+ */
489
+ typedef struct A_ArrayExpr
490
+ {
491
+ NodeTag type;
492
+ List *elements; /* array element expressions */
493
+ ParseLoc location; /* token location, or -1 if unknown */
494
+ } A_ArrayExpr;
495
+
496
+ /*
497
+ * ResTarget -
498
+ * result target (used in target list of pre-transformed parse trees)
499
+ *
500
+ * In a SELECT target list, 'name' is the column label from an
501
+ * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
502
+ * value expression itself. The 'indirection' field is not used.
503
+ *
504
+ * INSERT uses ResTarget in its target-column-names list. Here, 'name' is
505
+ * the name of the destination column, 'indirection' stores any subscripts
506
+ * attached to the destination, and 'val' is not used.
507
+ *
508
+ * In an UPDATE target list, 'name' is the name of the destination column,
509
+ * 'indirection' stores any subscripts attached to the destination, and
510
+ * 'val' is the expression to assign.
511
+ *
512
+ * See A_Indirection for more info about what can appear in 'indirection'.
513
+ */
514
+ typedef struct ResTarget
515
+ {
516
+ NodeTag type;
517
+ char *name; /* column name or NULL */
518
+ List *indirection; /* subscripts, field names, and '*', or NIL */
519
+ Node *val; /* the value expression to compute or assign */
520
+ ParseLoc location; /* token location, or -1 if unknown */
521
+ } ResTarget;
522
+
523
+ /*
524
+ * MultiAssignRef - element of a row source expression for UPDATE
525
+ *
526
+ * In an UPDATE target list, when we have SET (a,b,c) = row-valued-expression,
527
+ * we generate separate ResTarget items for each of a,b,c. Their "val" trees
528
+ * are MultiAssignRef nodes numbered 1..n, linking to a common copy of the
529
+ * row-valued-expression (which parse analysis will process only once, when
530
+ * handling the MultiAssignRef with colno=1).
531
+ */
532
+ typedef struct MultiAssignRef
533
+ {
534
+ NodeTag type;
535
+ Node *source; /* the row-valued expression */
536
+ int colno; /* column number for this target (1..n) */
537
+ int ncolumns; /* number of targets in the construct */
538
+ } MultiAssignRef;
539
+
540
+ /*
541
+ * SortBy - for ORDER BY clause
542
+ */
543
+ typedef struct SortBy
544
+ {
545
+ NodeTag type;
546
+ Node *node; /* expression to sort on */
547
+ SortByDir sortby_dir; /* ASC/DESC/USING/default */
548
+ SortByNulls sortby_nulls; /* NULLS FIRST/LAST */
549
+ List *useOp; /* name of op to use, if SORTBY_USING */
550
+ ParseLoc location; /* operator location, or -1 if none/unknown */
551
+ } SortBy;
552
+
553
+ /*
554
+ * WindowDef - raw representation of WINDOW and OVER clauses
555
+ *
556
+ * For entries in a WINDOW list, "name" is the window name being defined.
557
+ * For OVER clauses, we use "name" for the "OVER window" syntax, or "refname"
558
+ * for the "OVER (window)" syntax, which is subtly different --- the latter
559
+ * implies overriding the window frame clause.
560
+ */
561
+ typedef struct WindowDef
562
+ {
563
+ NodeTag type;
564
+ char *name; /* window's own name */
565
+ char *refname; /* referenced window name, if any */
566
+ List *partitionClause; /* PARTITION BY expression list */
567
+ List *orderClause; /* ORDER BY (list of SortBy) */
568
+ int frameOptions; /* frame_clause options, see below */
569
+ Node *startOffset; /* expression for starting bound, if any */
570
+ Node *endOffset; /* expression for ending bound, if any */
571
+ ParseLoc location; /* parse location, or -1 if none/unknown */
572
+ } WindowDef;
573
+
574
+ /*
575
+ * frameOptions is an OR of these bits. The NONDEFAULT and BETWEEN bits are
576
+ * used so that ruleutils.c can tell which properties were specified and
577
+ * which were defaulted; the correct behavioral bits must be set either way.
578
+ * The START_foo and END_foo options must come in pairs of adjacent bits for
579
+ * the convenience of gram.y, even though some of them are useless/invalid.
580
+ */
581
+ #define FRAMEOPTION_NONDEFAULT 0x00001 /* any specified? */
582
+ #define FRAMEOPTION_RANGE 0x00002 /* RANGE behavior */
583
+ #define FRAMEOPTION_ROWS 0x00004 /* ROWS behavior */
584
+ #define FRAMEOPTION_GROUPS 0x00008 /* GROUPS behavior */
585
+ #define FRAMEOPTION_BETWEEN 0x00010 /* BETWEEN given? */
586
+ #define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00020 /* start is U. P. */
587
+ #define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00040 /* (disallowed) */
588
+ #define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00080 /* (disallowed) */
589
+ #define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00100 /* end is U. F. */
590
+ #define FRAMEOPTION_START_CURRENT_ROW 0x00200 /* start is C. R. */
591
+ #define FRAMEOPTION_END_CURRENT_ROW 0x00400 /* end is C. R. */
592
+ #define FRAMEOPTION_START_OFFSET_PRECEDING 0x00800 /* start is O. P. */
593
+ #define FRAMEOPTION_END_OFFSET_PRECEDING 0x01000 /* end is O. P. */
594
+ #define FRAMEOPTION_START_OFFSET_FOLLOWING 0x02000 /* start is O. F. */
595
+ #define FRAMEOPTION_END_OFFSET_FOLLOWING 0x04000 /* end is O. F. */
596
+ #define FRAMEOPTION_EXCLUDE_CURRENT_ROW 0x08000 /* omit C.R. */
597
+ #define FRAMEOPTION_EXCLUDE_GROUP 0x10000 /* omit C.R. & peers */
598
+ #define FRAMEOPTION_EXCLUDE_TIES 0x20000 /* omit C.R.'s peers */
599
+
600
+ #define FRAMEOPTION_START_OFFSET \
601
+ (FRAMEOPTION_START_OFFSET_PRECEDING | FRAMEOPTION_START_OFFSET_FOLLOWING)
602
+ #define FRAMEOPTION_END_OFFSET \
603
+ (FRAMEOPTION_END_OFFSET_PRECEDING | FRAMEOPTION_END_OFFSET_FOLLOWING)
604
+ #define FRAMEOPTION_EXCLUSION \
605
+ (FRAMEOPTION_EXCLUDE_CURRENT_ROW | FRAMEOPTION_EXCLUDE_GROUP | \
606
+ FRAMEOPTION_EXCLUDE_TIES)
607
+
608
+ #define FRAMEOPTION_DEFAULTS \
609
+ (FRAMEOPTION_RANGE | FRAMEOPTION_START_UNBOUNDED_PRECEDING | \
610
+ FRAMEOPTION_END_CURRENT_ROW)
611
+
612
+ /*
613
+ * RangeSubselect - subquery appearing in a FROM clause
614
+ */
615
+ typedef struct RangeSubselect
616
+ {
617
+ NodeTag type;
618
+ bool lateral; /* does it have LATERAL prefix? */
619
+ Node *subquery; /* the untransformed sub-select clause */
620
+ Alias *alias; /* table alias & optional column aliases */
621
+ } RangeSubselect;
622
+
623
+ /*
624
+ * RangeFunction - function call appearing in a FROM clause
625
+ *
626
+ * functions is a List because we use this to represent the construct
627
+ * ROWS FROM(func1(...), func2(...), ...). Each element of this list is a
628
+ * two-element sublist, the first element being the untransformed function
629
+ * call tree, and the second element being a possibly-empty list of ColumnDef
630
+ * nodes representing any columndef list attached to that function within the
631
+ * ROWS FROM() syntax.
632
+ *
633
+ * alias and coldeflist represent any alias and/or columndef list attached
634
+ * at the top level. (We disallow coldeflist appearing both here and
635
+ * per-function, but that's checked in parse analysis, not by the grammar.)
636
+ */
637
+ typedef struct RangeFunction
638
+ {
639
+ NodeTag type;
640
+ bool lateral; /* does it have LATERAL prefix? */
641
+ bool ordinality; /* does it have WITH ORDINALITY suffix? */
642
+ bool is_rowsfrom; /* is result of ROWS FROM() syntax? */
643
+ List *functions; /* per-function information, see above */
644
+ Alias *alias; /* table alias & optional column aliases */
645
+ List *coldeflist; /* list of ColumnDef nodes to describe result
646
+ * of function returning RECORD */
647
+ } RangeFunction;
648
+
649
+ /*
650
+ * RangeTableFunc - raw form of "table functions" such as XMLTABLE
651
+ *
652
+ * Note: JSON_TABLE is also a "table function", but it uses JsonTable node,
653
+ * not RangeTableFunc.
654
+ */
655
+ typedef struct RangeTableFunc
656
+ {
657
+ NodeTag type;
658
+ bool lateral; /* does it have LATERAL prefix? */
659
+ Node *docexpr; /* document expression */
660
+ Node *rowexpr; /* row generator expression */
661
+ List *namespaces; /* list of namespaces as ResTarget */
662
+ List *columns; /* list of RangeTableFuncCol */
663
+ Alias *alias; /* table alias & optional column aliases */
664
+ ParseLoc location; /* token location, or -1 if unknown */
665
+ } RangeTableFunc;
666
+
667
+ /*
668
+ * RangeTableFuncCol - one column in a RangeTableFunc->columns
669
+ *
670
+ * If for_ordinality is true (FOR ORDINALITY), then the column is an int4
671
+ * column and the rest of the fields are ignored.
672
+ */
673
+ typedef struct RangeTableFuncCol
674
+ {
675
+ NodeTag type;
676
+ char *colname; /* name of generated column */
677
+ TypeName *typeName; /* type of generated column */
678
+ bool for_ordinality; /* does it have FOR ORDINALITY? */
679
+ bool is_not_null; /* does it have NOT NULL? */
680
+ Node *colexpr; /* column filter expression */
681
+ Node *coldefexpr; /* column default value expression */
682
+ ParseLoc location; /* token location, or -1 if unknown */
683
+ } RangeTableFuncCol;
684
+
685
+ /*
686
+ * RangeTableSample - TABLESAMPLE appearing in a raw FROM clause
687
+ *
688
+ * This node, appearing only in raw parse trees, represents
689
+ * <relation> TABLESAMPLE <method> (<params>) REPEATABLE (<num>)
690
+ * Currently, the <relation> can only be a RangeVar, but we might in future
691
+ * allow RangeSubselect and other options. Note that the RangeTableSample
692
+ * is wrapped around the node representing the <relation>, rather than being
693
+ * a subfield of it.
694
+ */
695
+ typedef struct RangeTableSample
696
+ {
697
+ NodeTag type;
698
+ Node *relation; /* relation to be sampled */
699
+ List *method; /* sampling method name (possibly qualified) */
700
+ List *args; /* argument(s) for sampling method */
701
+ Node *repeatable; /* REPEATABLE expression, or NULL if none */
702
+ ParseLoc location; /* method name location, or -1 if unknown */
703
+ } RangeTableSample;
704
+
705
+ /*
706
+ * ColumnDef - column definition (used in various creates)
707
+ *
708
+ * If the column has a default value, we may have the value expression
709
+ * in either "raw" form (an untransformed parse tree) or "cooked" form
710
+ * (a post-parse-analysis, executable expression tree), depending on
711
+ * how this ColumnDef node was created (by parsing, or by inheritance
712
+ * from an existing relation). We should never have both in the same node!
713
+ *
714
+ * Similarly, we may have a COLLATE specification in either raw form
715
+ * (represented as a CollateClause with arg==NULL) or cooked form
716
+ * (the collation's OID).
717
+ *
718
+ * The constraints list may contain a CONSTR_DEFAULT item in a raw
719
+ * parsetree produced by gram.y, but transformCreateStmt will remove
720
+ * the item and set raw_default instead. CONSTR_DEFAULT items
721
+ * should not appear in any subsequent processing.
722
+ */
723
+ typedef struct ColumnDef
724
+ {
725
+ NodeTag type;
726
+ char *colname; /* name of column */
727
+ TypeName *typeName; /* type of column */
728
+ char *compression; /* compression method for column */
729
+ int inhcount; /* number of times column is inherited */
730
+ bool is_local; /* column has local (non-inherited) def'n */
731
+ bool is_not_null; /* NOT NULL constraint specified? */
732
+ bool is_from_type; /* column definition came from table type */
733
+ char storage; /* attstorage setting, or 0 for default */
734
+ char *storage_name; /* attstorage setting name or NULL for default */
735
+ Node *raw_default; /* default value (untransformed parse tree) */
736
+ Node *cooked_default; /* default value (transformed expr tree) */
737
+ char identity; /* attidentity setting */
738
+ RangeVar *identitySequence; /* to store identity sequence name for
739
+ * ALTER TABLE ... ADD COLUMN */
740
+ char generated; /* attgenerated setting */
741
+ CollateClause *collClause; /* untransformed COLLATE spec, if any */
742
+ Oid collOid; /* collation OID (InvalidOid if not set) */
743
+ List *constraints; /* other constraints on column */
744
+ List *fdwoptions; /* per-column FDW options */
745
+ ParseLoc location; /* parse location, or -1 if none/unknown */
746
+ } ColumnDef;
747
+
748
+ /*
749
+ * TableLikeClause - CREATE TABLE ( ... LIKE ... ) clause
750
+ */
751
+ typedef struct TableLikeClause
752
+ {
753
+ NodeTag type;
754
+ RangeVar *relation;
755
+ bits32 options; /* OR of TableLikeOption flags */
756
+ Oid relationOid; /* If table has been looked up, its OID */
757
+ } TableLikeClause;
758
+
759
+ typedef enum TableLikeOption
760
+ {
761
+ CREATE_TABLE_LIKE_COMMENTS = 1 << 0,
762
+ CREATE_TABLE_LIKE_COMPRESSION = 1 << 1,
763
+ CREATE_TABLE_LIKE_CONSTRAINTS = 1 << 2,
764
+ CREATE_TABLE_LIKE_DEFAULTS = 1 << 3,
765
+ CREATE_TABLE_LIKE_GENERATED = 1 << 4,
766
+ CREATE_TABLE_LIKE_IDENTITY = 1 << 5,
767
+ CREATE_TABLE_LIKE_INDEXES = 1 << 6,
768
+ CREATE_TABLE_LIKE_STATISTICS = 1 << 7,
769
+ CREATE_TABLE_LIKE_STORAGE = 1 << 8,
770
+ CREATE_TABLE_LIKE_ALL = PG_INT32_MAX
771
+ } TableLikeOption;
772
+
773
+ /*
774
+ * IndexElem - index parameters (used in CREATE INDEX, and in ON CONFLICT)
775
+ *
776
+ * For a plain index attribute, 'name' is the name of the table column to
777
+ * index, and 'expr' is NULL. For an index expression, 'name' is NULL and
778
+ * 'expr' is the expression tree.
779
+ */
780
+ typedef struct IndexElem
781
+ {
782
+ NodeTag type;
783
+ char *name; /* name of attribute to index, or NULL */
784
+ Node *expr; /* expression to index, or NULL */
785
+ char *indexcolname; /* name for index column; NULL = default */
786
+ List *collation; /* name of collation; NIL = default */
787
+ List *opclass; /* name of desired opclass; NIL = default */
788
+ List *opclassopts; /* opclass-specific options, or NIL */
789
+ SortByDir ordering; /* ASC/DESC/default */
790
+ SortByNulls nulls_ordering; /* FIRST/LAST/default */
791
+ } IndexElem;
792
+
793
+ /*
794
+ * DefElem - a generic "name = value" option definition
795
+ *
796
+ * In some contexts the name can be qualified. Also, certain SQL commands
797
+ * allow a SET/ADD/DROP action to be attached to option settings, so it's
798
+ * convenient to carry a field for that too. (Note: currently, it is our
799
+ * practice that the grammar allows namespace and action only in statements
800
+ * where they are relevant; C code can just ignore those fields in other
801
+ * statements.)
802
+ */
803
+ typedef enum DefElemAction
804
+ {
805
+ DEFELEM_UNSPEC, /* no action given */
806
+ DEFELEM_SET,
807
+ DEFELEM_ADD,
808
+ DEFELEM_DROP,
809
+ } DefElemAction;
810
+
811
+ typedef struct DefElem
812
+ {
813
+ NodeTag type;
814
+ char *defnamespace; /* NULL if unqualified name */
815
+ char *defname;
816
+ Node *arg; /* typically Integer, Float, String, or
817
+ * TypeName */
818
+ DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */
819
+ ParseLoc location; /* token location, or -1 if unknown */
820
+ } DefElem;
821
+
822
+ /*
823
+ * LockingClause - raw representation of FOR [NO KEY] UPDATE/[KEY] SHARE
824
+ * options
825
+ *
826
+ * Note: lockedRels == NIL means "all relations in query". Otherwise it
827
+ * is a list of RangeVar nodes. (We use RangeVar mainly because it carries
828
+ * a location field --- currently, parse analysis insists on unqualified
829
+ * names in LockingClause.)
830
+ */
831
+ typedef struct LockingClause
832
+ {
833
+ NodeTag type;
834
+ List *lockedRels; /* FOR [KEY] UPDATE/SHARE relations */
835
+ LockClauseStrength strength;
836
+ LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
837
+ } LockingClause;
838
+
839
+ /*
840
+ * XMLSERIALIZE (in raw parse tree only)
841
+ */
842
+ typedef struct XmlSerialize
843
+ {
844
+ NodeTag type;
845
+ XmlOptionType xmloption; /* DOCUMENT or CONTENT */
846
+ Node *expr;
847
+ TypeName *typeName;
848
+ bool indent; /* [NO] INDENT */
849
+ ParseLoc location; /* token location, or -1 if unknown */
850
+ } XmlSerialize;
851
+
852
+ /* Partitioning related definitions */
853
+
854
+ /*
855
+ * PartitionElem - parse-time representation of a single partition key
856
+ *
857
+ * expr can be either a raw expression tree or a parse-analyzed expression.
858
+ * We don't store these on-disk, though.
859
+ */
860
+ typedef struct PartitionElem
861
+ {
862
+ NodeTag type;
863
+ char *name; /* name of column to partition on, or NULL */
864
+ Node *expr; /* expression to partition on, or NULL */
865
+ List *collation; /* name of collation; NIL = default */
866
+ List *opclass; /* name of desired opclass; NIL = default */
867
+ ParseLoc location; /* token location, or -1 if unknown */
868
+ } PartitionElem;
869
+
870
+ typedef enum PartitionStrategy
871
+ {
872
+ PARTITION_STRATEGY_LIST = 'l',
873
+ PARTITION_STRATEGY_RANGE = 'r',
874
+ PARTITION_STRATEGY_HASH = 'h',
875
+ } PartitionStrategy;
876
+
877
+ /*
878
+ * PartitionSpec - parse-time representation of a partition key specification
879
+ *
880
+ * This represents the key space we will be partitioning on.
881
+ */
882
+ typedef struct PartitionSpec
883
+ {
884
+ NodeTag type;
885
+ PartitionStrategy strategy;
886
+ List *partParams; /* List of PartitionElems */
887
+ ParseLoc location; /* token location, or -1 if unknown */
888
+ } PartitionSpec;
889
+
890
+ /*
891
+ * PartitionBoundSpec - a partition bound specification
892
+ *
893
+ * This represents the portion of the partition key space assigned to a
894
+ * particular partition. These are stored on disk in pg_class.relpartbound.
895
+ */
896
+ struct PartitionBoundSpec
897
+ {
898
+ NodeTag type;
899
+
900
+ char strategy; /* see PARTITION_STRATEGY codes above */
901
+ bool is_default; /* is it a default partition bound? */
902
+
903
+ /* Partitioning info for HASH strategy: */
904
+ int modulus;
905
+ int remainder;
906
+
907
+ /* Partitioning info for LIST strategy: */
908
+ List *listdatums; /* List of Consts (or A_Consts in raw tree) */
909
+
910
+ /* Partitioning info for RANGE strategy: */
911
+ List *lowerdatums; /* List of PartitionRangeDatums */
912
+ List *upperdatums; /* List of PartitionRangeDatums */
913
+
914
+ ParseLoc location; /* token location, or -1 if unknown */
915
+ };
916
+
917
+ /*
918
+ * PartitionRangeDatum - one of the values in a range partition bound
919
+ *
920
+ * This can be MINVALUE, MAXVALUE or a specific bounded value.
921
+ */
922
+ typedef enum PartitionRangeDatumKind
923
+ {
924
+ PARTITION_RANGE_DATUM_MINVALUE = -1, /* less than any other value */
925
+ PARTITION_RANGE_DATUM_VALUE = 0, /* a specific (bounded) value */
926
+ PARTITION_RANGE_DATUM_MAXVALUE = 1, /* greater than any other value */
927
+ } PartitionRangeDatumKind;
928
+
929
+ typedef struct PartitionRangeDatum
930
+ {
931
+ NodeTag type;
932
+
933
+ PartitionRangeDatumKind kind;
934
+ Node *value; /* Const (or A_Const in raw tree), if kind is
935
+ * PARTITION_RANGE_DATUM_VALUE, else NULL */
936
+
937
+ ParseLoc location; /* token location, or -1 if unknown */
938
+ } PartitionRangeDatum;
939
+
940
+ /*
941
+ * PartitionDesc - used in reverted ALTER TABLE SPLIT PARTITION command
942
+ *
943
+ * Kept as a stub for nodetag ABI compatibility.
944
+ */
945
+ typedef struct SinglePartitionSpec
946
+ {
947
+ NodeTag type;
948
+ } SinglePartitionSpec;
949
+
950
+ /*
951
+ * PartitionCmd - info for ALTER TABLE/INDEX ATTACH/DETACH PARTITION commands
952
+ */
953
+ typedef struct PartitionCmd
954
+ {
955
+ NodeTag type;
956
+ RangeVar *name; /* name of partition to attach/detach */
957
+ PartitionBoundSpec *bound; /* FOR VALUES, if attaching */
958
+ bool concurrent;
959
+ } PartitionCmd;
960
+
961
+ /****************************************************************************
962
+ * Nodes for a Query tree
963
+ ****************************************************************************/
964
+
965
+ /*--------------------
966
+ * RangeTblEntry -
967
+ * A range table is a List of RangeTblEntry nodes.
968
+ *
969
+ * A range table entry may represent a plain relation, a sub-select in
970
+ * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
971
+ * produces an RTE, not the implicit join resulting from multiple FROM
972
+ * items. This is because we only need the RTE to deal with SQL features
973
+ * like outer joins and join-output-column aliasing.) Other special
974
+ * RTE types also exist, as indicated by RTEKind.
975
+ *
976
+ * Note that we consider RTE_RELATION to cover anything that has a pg_class
977
+ * entry. relkind distinguishes the sub-cases.
978
+ *
979
+ * alias is an Alias node representing the AS alias-clause attached to the
980
+ * FROM expression, or NULL if no clause.
981
+ *
982
+ * eref is the table reference name and column reference names (either
983
+ * real or aliases). Note that system columns (OID etc) are not included
984
+ * in the column list.
985
+ * eref->aliasname is required to be present, and should generally be used
986
+ * to identify the RTE for error messages etc.
987
+ *
988
+ * In RELATION RTEs, the colnames in both alias and eref are indexed by
989
+ * physical attribute number; this means there must be colname entries for
990
+ * dropped columns. When building an RTE we insert empty strings ("") for
991
+ * dropped columns. Note however that a stored rule may have nonempty
992
+ * colnames for columns dropped since the rule was created (and for that
993
+ * matter the colnames might be out of date due to column renamings).
994
+ * The same comments apply to FUNCTION RTEs when a function's return type
995
+ * is a named composite type.
996
+ *
997
+ * In JOIN RTEs, the colnames in both alias and eref are one-to-one with
998
+ * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
999
+ * those columns are known to be dropped at parse time. Again, however,
1000
+ * a stored rule might contain entries for columns dropped since the rule
1001
+ * was created. (This is only possible for columns not actually referenced
1002
+ * in the rule.) When loading a stored rule, we replace the joinaliasvars
1003
+ * items for any such columns with null pointers. (We can't simply delete
1004
+ * them from the joinaliasvars list, because that would affect the attnums
1005
+ * of Vars referencing the rest of the list.)
1006
+ *
1007
+ * inFromCl marks those range variables that are listed in the FROM clause.
1008
+ * It's false for RTEs that are added to a query behind the scenes, such
1009
+ * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
1010
+ * This flag is not used during parsing (except in transformLockingClause,
1011
+ * q.v.); the parser now uses a separate "namespace" data structure to
1012
+ * control visibility. But it is needed by ruleutils.c to determine
1013
+ * whether RTEs should be shown in decompiled queries.
1014
+ *
1015
+ * securityQuals is a list of security barrier quals (boolean expressions),
1016
+ * to be tested in the listed order before returning a row from the
1017
+ * relation. It is always NIL in parser output. Entries are added by the
1018
+ * rewriter to implement security-barrier views and/or row-level security.
1019
+ * Note that the planner turns each boolean expression into an implicitly
1020
+ * AND'ed sublist, as is its usual habit with qualification expressions.
1021
+ *--------------------
1022
+ */
1023
+ typedef enum RTEKind
1024
+ {
1025
+ RTE_RELATION, /* ordinary relation reference */
1026
+ RTE_SUBQUERY, /* subquery in FROM */
1027
+ RTE_JOIN, /* join */
1028
+ RTE_FUNCTION, /* function in FROM */
1029
+ RTE_TABLEFUNC, /* TableFunc(.., column list) */
1030
+ RTE_VALUES, /* VALUES (<exprlist>), (<exprlist>), ... */
1031
+ RTE_CTE, /* common table expr (WITH list element) */
1032
+ RTE_NAMEDTUPLESTORE, /* tuplestore, e.g. for AFTER triggers */
1033
+ RTE_RESULT, /* RTE represents an empty FROM clause; such
1034
+ * RTEs are added by the planner, they're not
1035
+ * present during parsing or rewriting */
1036
+ } RTEKind;
1037
+
1038
+ typedef struct RangeTblEntry
1039
+ {
1040
+ pg_node_attr(custom_read_write)
1041
+
1042
+ NodeTag type;
1043
+
1044
+ /*
1045
+ * Fields valid in all RTEs:
1046
+ *
1047
+ * put alias + eref first to make dump more legible
1048
+ */
1049
+ /* user-written alias clause, if any */
1050
+ Alias *alias pg_node_attr(query_jumble_ignore);
1051
+ /* expanded reference names */
1052
+ Alias *eref pg_node_attr(query_jumble_ignore);
1053
+
1054
+ RTEKind rtekind; /* see above */
1055
+
1056
+ /*
1057
+ * Fields valid for a plain relation RTE (else zero):
1058
+ *
1059
+ * inh is true for relation references that should be expanded to include
1060
+ * inheritance children, if the rel has any. In the parser, this will
1061
+ * only be true for RTE_RELATION entries. The planner also uses this
1062
+ * field to mark RTE_SUBQUERY entries that contain UNION ALL queries that
1063
+ * it has flattened into pulled-up subqueries (creating a structure much
1064
+ * like the effects of inheritance).
1065
+ *
1066
+ * rellockmode is really LOCKMODE, but it's declared int to avoid having
1067
+ * to include lock-related headers here. It must be RowExclusiveLock if
1068
+ * the RTE is an INSERT/UPDATE/DELETE/MERGE target, else RowShareLock if
1069
+ * the RTE is a SELECT FOR UPDATE/FOR SHARE target, else AccessShareLock.
1070
+ *
1071
+ * Note: in some cases, rule expansion may result in RTEs that are marked
1072
+ * with RowExclusiveLock even though they are not the target of the
1073
+ * current query; this happens if a DO ALSO rule simply scans the original
1074
+ * target table. We leave such RTEs with their original lockmode so as to
1075
+ * avoid getting an additional, lesser lock.
1076
+ *
1077
+ * perminfoindex is 1-based index of the RTEPermissionInfo belonging to
1078
+ * this RTE in the containing struct's list of same; 0 if permissions need
1079
+ * not be checked for this RTE.
1080
+ *
1081
+ * As a special case, relid, relkind, rellockmode, and perminfoindex can
1082
+ * also be set (nonzero) in an RTE_SUBQUERY RTE. This occurs when we
1083
+ * convert an RTE_RELATION RTE naming a view into an RTE_SUBQUERY
1084
+ * containing the view's query. We still need to perform run-time locking
1085
+ * and permission checks on the view, even though it's not directly used
1086
+ * in the query anymore, and the most expedient way to do that is to
1087
+ * retain these fields from the old state of the RTE.
1088
+ *
1089
+ * As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
1090
+ * that the tuple format of the tuplestore is the same as the referenced
1091
+ * relation. This allows plans referencing AFTER trigger transition
1092
+ * tables to be invalidated if the underlying table is altered.
1093
+ */
1094
+ /* OID of the relation */
1095
+ Oid relid;
1096
+ /* inheritance requested? */
1097
+ bool inh;
1098
+ /* relation kind (see pg_class.relkind) */
1099
+ char relkind pg_node_attr(query_jumble_ignore);
1100
+ /* lock level that query requires on the rel */
1101
+ int rellockmode pg_node_attr(query_jumble_ignore);
1102
+ /* index of RTEPermissionInfo entry, or 0 */
1103
+ Index perminfoindex pg_node_attr(query_jumble_ignore);
1104
+ /* sampling info, or NULL */
1105
+ struct TableSampleClause *tablesample;
1106
+
1107
+ /*
1108
+ * Fields valid for a subquery RTE (else NULL):
1109
+ */
1110
+ /* the sub-query */
1111
+ Query *subquery;
1112
+ /* is from security_barrier view? */
1113
+ bool security_barrier pg_node_attr(query_jumble_ignore);
1114
+
1115
+ /*
1116
+ * Fields valid for a join RTE (else NULL/zero):
1117
+ *
1118
+ * joinaliasvars is a list of (usually) Vars corresponding to the columns
1119
+ * of the join result. An alias Var referencing column K of the join
1120
+ * result can be replaced by the K'th element of joinaliasvars --- but to
1121
+ * simplify the task of reverse-listing aliases correctly, we do not do
1122
+ * that until planning time. In detail: an element of joinaliasvars can
1123
+ * be a Var of one of the join's input relations, or such a Var with an
1124
+ * implicit coercion to the join's output column type, or a COALESCE
1125
+ * expression containing the two input column Vars (possibly coerced).
1126
+ * Elements beyond the first joinmergedcols entries are always just Vars,
1127
+ * and are never referenced from elsewhere in the query (that is, join
1128
+ * alias Vars are generated only for merged columns). We keep these
1129
+ * entries only because they're needed in expandRTE() and similar code.
1130
+ *
1131
+ * Vars appearing within joinaliasvars are marked with varnullingrels sets
1132
+ * that describe the nulling effects of this join and lower ones. This is
1133
+ * essential for FULL JOIN cases, because the COALESCE expression only
1134
+ * describes the semantics correctly if its inputs have been nulled by the
1135
+ * join. For other cases, it allows expandRTE() to generate a valid
1136
+ * representation of the join's output without consulting additional
1137
+ * parser state.
1138
+ *
1139
+ * Within a Query loaded from a stored rule, it is possible for non-merged
1140
+ * joinaliasvars items to be null pointers, which are placeholders for
1141
+ * (necessarily unreferenced) columns dropped since the rule was made.
1142
+ * Also, once planning begins, joinaliasvars items can be almost anything,
1143
+ * as a result of subquery-flattening substitutions.
1144
+ *
1145
+ * joinleftcols is an integer list of physical column numbers of the left
1146
+ * join input rel that are included in the join; likewise joinrighttcols
1147
+ * for the right join input rel. (Which rels those are can be determined
1148
+ * from the associated JoinExpr.) If the join is USING/NATURAL, then the
1149
+ * first joinmergedcols entries in each list identify the merged columns.
1150
+ * The merged columns come first in the join output, then remaining
1151
+ * columns of the left input, then remaining columns of the right.
1152
+ *
1153
+ * Note that input columns could have been dropped after creation of a
1154
+ * stored rule, if they are not referenced in the query (in particular,
1155
+ * merged columns could not be dropped); this is not accounted for in
1156
+ * joinleftcols/joinrighttcols.
1157
+ */
1158
+ JoinType jointype;
1159
+ /* number of merged (JOIN USING) columns */
1160
+ int joinmergedcols pg_node_attr(query_jumble_ignore);
1161
+ /* list of alias-var expansions */
1162
+ List *joinaliasvars pg_node_attr(query_jumble_ignore);
1163
+ /* left-side input column numbers */
1164
+ List *joinleftcols pg_node_attr(query_jumble_ignore);
1165
+ /* right-side input column numbers */
1166
+ List *joinrightcols pg_node_attr(query_jumble_ignore);
1167
+
1168
+ /*
1169
+ * join_using_alias is an alias clause attached directly to JOIN/USING. It
1170
+ * is different from the alias field (below) in that it does not hide the
1171
+ * range variables of the tables being joined.
1172
+ */
1173
+ Alias *join_using_alias pg_node_attr(query_jumble_ignore);
1174
+
1175
+ /*
1176
+ * Fields valid for a function RTE (else NIL/zero):
1177
+ *
1178
+ * When funcordinality is true, the eref->colnames list includes an alias
1179
+ * for the ordinality column. The ordinality column is otherwise
1180
+ * implicit, and must be accounted for "by hand" in places such as
1181
+ * expandRTE().
1182
+ */
1183
+ /* list of RangeTblFunction nodes */
1184
+ List *functions;
1185
+ /* is this called WITH ORDINALITY? */
1186
+ bool funcordinality;
1187
+
1188
+ /*
1189
+ * Fields valid for a TableFunc RTE (else NULL):
1190
+ */
1191
+ TableFunc *tablefunc;
1192
+
1193
+ /*
1194
+ * Fields valid for a values RTE (else NIL):
1195
+ */
1196
+ /* list of expression lists */
1197
+ List *values_lists;
1198
+
1199
+ /*
1200
+ * Fields valid for a CTE RTE (else NULL/zero):
1201
+ */
1202
+ /* name of the WITH list item */
1203
+ char *ctename;
1204
+ /* number of query levels up */
1205
+ Index ctelevelsup;
1206
+ /* is this a recursive self-reference? */
1207
+ bool self_reference pg_node_attr(query_jumble_ignore);
1208
+
1209
+ /*
1210
+ * Fields valid for CTE, VALUES, ENR, and TableFunc RTEs (else NIL):
1211
+ *
1212
+ * We need these for CTE RTEs so that the types of self-referential
1213
+ * columns are well-defined. For VALUES RTEs, storing these explicitly
1214
+ * saves having to re-determine the info by scanning the values_lists. For
1215
+ * ENRs, we store the types explicitly here (we could get the information
1216
+ * from the catalogs if 'relid' was supplied, but we'd still need these
1217
+ * for TupleDesc-based ENRs, so we might as well always store the type
1218
+ * info here). For TableFuncs, these fields are redundant with data in
1219
+ * the TableFunc node, but keeping them here allows some code sharing with
1220
+ * the other cases.
1221
+ *
1222
+ * For ENRs only, we have to consider the possibility of dropped columns.
1223
+ * A dropped column is included in these lists, but it will have zeroes in
1224
+ * all three lists (as well as an empty-string entry in eref). Testing
1225
+ * for zero coltype is the standard way to detect a dropped column.
1226
+ */
1227
+ /* OID list of column type OIDs */
1228
+ List *coltypes pg_node_attr(query_jumble_ignore);
1229
+ /* integer list of column typmods */
1230
+ List *coltypmods pg_node_attr(query_jumble_ignore);
1231
+ /* OID list of column collation OIDs */
1232
+ List *colcollations pg_node_attr(query_jumble_ignore);
1233
+
1234
+ /*
1235
+ * Fields valid for ENR RTEs (else NULL/zero):
1236
+ */
1237
+ /* name of ephemeral named relation */
1238
+ char *enrname;
1239
+ /* estimated or actual from caller */
1240
+ Cardinality enrtuples pg_node_attr(query_jumble_ignore);
1241
+
1242
+ /*
1243
+ * Fields valid in all RTEs:
1244
+ */
1245
+ /* was LATERAL specified? */
1246
+ bool lateral pg_node_attr(query_jumble_ignore);
1247
+ /* present in FROM clause? */
1248
+ bool inFromCl pg_node_attr(query_jumble_ignore);
1249
+ /* security barrier quals to apply, if any */
1250
+ List *securityQuals pg_node_attr(query_jumble_ignore);
1251
+ } RangeTblEntry;
1252
+
1253
+ /*
1254
+ * RTEPermissionInfo
1255
+ * Per-relation information for permission checking. Added to the Query
1256
+ * node by the parser when adding the corresponding RTE to the query
1257
+ * range table and subsequently editorialized on by the rewriter if
1258
+ * needed after rule expansion.
1259
+ *
1260
+ * Only the relations directly mentioned in the query are checked for
1261
+ * access permissions by the core executor, so only their RTEPermissionInfos
1262
+ * are present in the Query. However, extensions may want to check inheritance
1263
+ * children too, depending on the value of rte->inh, so it's copied in 'inh'
1264
+ * for their perusal.
1265
+ *
1266
+ * requiredPerms and checkAsUser specify run-time access permissions checks
1267
+ * to be performed at query startup. The user must have *all* of the
1268
+ * permissions that are OR'd together in requiredPerms (never 0!). If
1269
+ * checkAsUser is not zero, then do the permissions checks using the access
1270
+ * rights of that user, not the current effective user ID. (This allows rules
1271
+ * to act as setuid gateways.)
1272
+ *
1273
+ * For SELECT/INSERT/UPDATE permissions, if the user doesn't have table-wide
1274
+ * permissions then it is sufficient to have the permissions on all columns
1275
+ * identified in selectedCols (for SELECT) and/or insertedCols and/or
1276
+ * updatedCols (INSERT with ON CONFLICT DO UPDATE may have all 3).
1277
+ * selectedCols, insertedCols and updatedCols are bitmapsets, which cannot have
1278
+ * negative integer members, so we subtract FirstLowInvalidHeapAttributeNumber
1279
+ * from column numbers before storing them in these fields. A whole-row Var
1280
+ * reference is represented by setting the bit for InvalidAttrNumber.
1281
+ *
1282
+ * updatedCols is also used in some other places, for example, to determine
1283
+ * which triggers to fire and in FDWs to know which changed columns they need
1284
+ * to ship off.
1285
+ */
1286
+ typedef struct RTEPermissionInfo
1287
+ {
1288
+ NodeTag type;
1289
+
1290
+ Oid relid; /* relation OID */
1291
+ bool inh; /* separately check inheritance children? */
1292
+ AclMode requiredPerms; /* bitmask of required access permissions */
1293
+ Oid checkAsUser; /* if valid, check access as this role */
1294
+ Bitmapset *selectedCols; /* columns needing SELECT permission */
1295
+ Bitmapset *insertedCols; /* columns needing INSERT permission */
1296
+ Bitmapset *updatedCols; /* columns needing UPDATE permission */
1297
+ } RTEPermissionInfo;
1298
+
1299
+ /*
1300
+ * RangeTblFunction -
1301
+ * RangeTblEntry subsidiary data for one function in a FUNCTION RTE.
1302
+ *
1303
+ * If the function had a column definition list (required for an
1304
+ * otherwise-unspecified RECORD result), funccolnames lists the names given
1305
+ * in the definition list, funccoltypes lists their declared column types,
1306
+ * funccoltypmods lists their typmods, funccolcollations their collations.
1307
+ * Otherwise, those fields are NIL.
1308
+ *
1309
+ * Notice we don't attempt to store info about the results of functions
1310
+ * returning named composite types, because those can change from time to
1311
+ * time. We do however remember how many columns we thought the type had
1312
+ * (including dropped columns!), so that we can successfully ignore any
1313
+ * columns added after the query was parsed.
1314
+ *
1315
+ * The query jumbling only needs to track the function expression.
1316
+ */
1317
+ typedef struct RangeTblFunction
1318
+ {
1319
+ NodeTag type;
1320
+
1321
+ Node *funcexpr; /* expression tree for func call */
1322
+ /* number of columns it contributes to RTE */
1323
+ int funccolcount pg_node_attr(query_jumble_ignore);
1324
+ /* These fields record the contents of a column definition list, if any: */
1325
+ /* column names (list of String) */
1326
+ List *funccolnames pg_node_attr(query_jumble_ignore);
1327
+ /* OID list of column type OIDs */
1328
+ List *funccoltypes pg_node_attr(query_jumble_ignore);
1329
+ /* integer list of column typmods */
1330
+ List *funccoltypmods pg_node_attr(query_jumble_ignore);
1331
+ /* OID list of column collation OIDs */
1332
+ List *funccolcollations pg_node_attr(query_jumble_ignore);
1333
+
1334
+ /* This is set during planning for use by the executor: */
1335
+ /* PARAM_EXEC Param IDs affecting this func */
1336
+ Bitmapset *funcparams pg_node_attr(query_jumble_ignore);
1337
+ } RangeTblFunction;
1338
+
1339
+ /*
1340
+ * TableSampleClause - TABLESAMPLE appearing in a transformed FROM clause
1341
+ *
1342
+ * Unlike RangeTableSample, this is a subnode of the relevant RangeTblEntry.
1343
+ */
1344
+ typedef struct TableSampleClause
1345
+ {
1346
+ NodeTag type;
1347
+ Oid tsmhandler; /* OID of the tablesample handler function */
1348
+ List *args; /* tablesample argument expression(s) */
1349
+ Expr *repeatable; /* REPEATABLE expression, or NULL if none */
1350
+ } TableSampleClause;
1351
+
1352
+ /*
1353
+ * WithCheckOption -
1354
+ * representation of WITH CHECK OPTION checks to be applied to new tuples
1355
+ * when inserting/updating an auto-updatable view, or RLS WITH CHECK
1356
+ * policies to be applied when inserting/updating a relation with RLS.
1357
+ */
1358
+ typedef enum WCOKind
1359
+ {
1360
+ WCO_VIEW_CHECK, /* WCO on an auto-updatable view */
1361
+ WCO_RLS_INSERT_CHECK, /* RLS INSERT WITH CHECK policy */
1362
+ WCO_RLS_UPDATE_CHECK, /* RLS UPDATE WITH CHECK policy */
1363
+ WCO_RLS_CONFLICT_CHECK, /* RLS ON CONFLICT DO UPDATE USING policy */
1364
+ WCO_RLS_MERGE_UPDATE_CHECK, /* RLS MERGE UPDATE USING policy */
1365
+ WCO_RLS_MERGE_DELETE_CHECK, /* RLS MERGE DELETE USING policy */
1366
+ } WCOKind;
1367
+
1368
+ typedef struct WithCheckOption
1369
+ {
1370
+ NodeTag type;
1371
+ WCOKind kind; /* kind of WCO */
1372
+ char *relname; /* name of relation that specified the WCO */
1373
+ char *polname; /* name of RLS policy being checked */
1374
+ Node *qual; /* constraint qual to check */
1375
+ bool cascaded; /* true for a cascaded WCO on a view */
1376
+ } WithCheckOption;
1377
+
1378
+ /*
1379
+ * SortGroupClause -
1380
+ * representation of ORDER BY, GROUP BY, PARTITION BY,
1381
+ * DISTINCT, DISTINCT ON items
1382
+ *
1383
+ * You might think that ORDER BY is only interested in defining ordering,
1384
+ * and GROUP/DISTINCT are only interested in defining equality. However,
1385
+ * one way to implement grouping is to sort and then apply a "uniq"-like
1386
+ * filter. So it's also interesting to keep track of possible sort operators
1387
+ * for GROUP/DISTINCT, and in particular to try to sort for the grouping
1388
+ * in a way that will also yield a requested ORDER BY ordering. So we need
1389
+ * to be able to compare ORDER BY and GROUP/DISTINCT lists, which motivates
1390
+ * the decision to give them the same representation.
1391
+ *
1392
+ * tleSortGroupRef must match ressortgroupref of exactly one entry of the
1393
+ * query's targetlist; that is the expression to be sorted or grouped by.
1394
+ * eqop is the OID of the equality operator.
1395
+ * sortop is the OID of the ordering operator (a "<" or ">" operator),
1396
+ * or InvalidOid if not available.
1397
+ * nulls_first means about what you'd expect. If sortop is InvalidOid
1398
+ * then nulls_first is meaningless and should be set to false.
1399
+ * hashable is true if eqop is hashable (note this condition also depends
1400
+ * on the datatype of the input expression).
1401
+ *
1402
+ * In an ORDER BY item, all fields must be valid. (The eqop isn't essential
1403
+ * here, but it's cheap to get it along with the sortop, and requiring it
1404
+ * to be valid eases comparisons to grouping items.) Note that this isn't
1405
+ * actually enough information to determine an ordering: if the sortop is
1406
+ * collation-sensitive, a collation OID is needed too. We don't store the
1407
+ * collation in SortGroupClause because it's not available at the time the
1408
+ * parser builds the SortGroupClause; instead, consult the exposed collation
1409
+ * of the referenced targetlist expression to find out what it is.
1410
+ *
1411
+ * In a grouping item, eqop must be valid. If the eqop is a btree equality
1412
+ * operator, then sortop should be set to a compatible ordering operator.
1413
+ * We prefer to set eqop/sortop/nulls_first to match any ORDER BY item that
1414
+ * the query presents for the same tlist item. If there is none, we just
1415
+ * use the default ordering op for the datatype.
1416
+ *
1417
+ * If the tlist item's type has a hash opclass but no btree opclass, then
1418
+ * we will set eqop to the hash equality operator, sortop to InvalidOid,
1419
+ * and nulls_first to false. A grouping item of this kind can only be
1420
+ * implemented by hashing, and of course it'll never match an ORDER BY item.
1421
+ *
1422
+ * The hashable flag is provided since we generally have the requisite
1423
+ * information readily available when the SortGroupClause is constructed,
1424
+ * and it's relatively expensive to get it again later. Note there is no
1425
+ * need for a "sortable" flag since OidIsValid(sortop) serves the purpose.
1426
+ *
1427
+ * A query might have both ORDER BY and DISTINCT (or DISTINCT ON) clauses.
1428
+ * In SELECT DISTINCT, the distinctClause list is as long or longer than the
1429
+ * sortClause list, while in SELECT DISTINCT ON it's typically shorter.
1430
+ * The two lists must match up to the end of the shorter one --- the parser
1431
+ * rearranges the distinctClause if necessary to make this true. (This
1432
+ * restriction ensures that only one sort step is needed to both satisfy the
1433
+ * ORDER BY and set up for the Unique step. This is semantically necessary
1434
+ * for DISTINCT ON, and presents no real drawback for DISTINCT.)
1435
+ */
1436
+ typedef struct SortGroupClause
1437
+ {
1438
+ NodeTag type;
1439
+ Index tleSortGroupRef; /* reference into targetlist */
1440
+ Oid eqop; /* the equality operator ('=' op) */
1441
+ Oid sortop; /* the ordering operator ('<' op), or 0 */
1442
+ bool nulls_first; /* do NULLs come before normal values? */
1443
+ /* can eqop be implemented by hashing? */
1444
+ bool hashable pg_node_attr(query_jumble_ignore);
1445
+ } SortGroupClause;
1446
+
1447
+ /*
1448
+ * GroupingSet -
1449
+ * representation of CUBE, ROLLUP and GROUPING SETS clauses
1450
+ *
1451
+ * In a Query with grouping sets, the groupClause contains a flat list of
1452
+ * SortGroupClause nodes for each distinct expression used. The actual
1453
+ * structure of the GROUP BY clause is given by the groupingSets tree.
1454
+ *
1455
+ * In the raw parser output, GroupingSet nodes (of all types except SIMPLE
1456
+ * which is not used) are potentially mixed in with the expressions in the
1457
+ * groupClause of the SelectStmt. (An expression can't contain a GroupingSet,
1458
+ * but a list may mix GroupingSet and expression nodes.) At this stage, the
1459
+ * content of each node is a list of expressions, some of which may be RowExprs
1460
+ * which represent sublists rather than actual row constructors, and nested
1461
+ * GroupingSet nodes where legal in the grammar. The structure directly
1462
+ * reflects the query syntax.
1463
+ *
1464
+ * In parse analysis, the transformed expressions are used to build the tlist
1465
+ * and groupClause list (of SortGroupClause nodes), and the groupingSets tree
1466
+ * is eventually reduced to a fixed format:
1467
+ *
1468
+ * EMPTY nodes represent (), and obviously have no content
1469
+ *
1470
+ * SIMPLE nodes represent a list of one or more expressions to be treated as an
1471
+ * atom by the enclosing structure; the content is an integer list of
1472
+ * ressortgroupref values (see SortGroupClause)
1473
+ *
1474
+ * CUBE and ROLLUP nodes contain a list of one or more SIMPLE nodes.
1475
+ *
1476
+ * SETS nodes contain a list of EMPTY, SIMPLE, CUBE or ROLLUP nodes, but after
1477
+ * parse analysis they cannot contain more SETS nodes; enough of the syntactic
1478
+ * transforms of the spec have been applied that we no longer have arbitrarily
1479
+ * deep nesting (though we still preserve the use of cube/rollup).
1480
+ *
1481
+ * Note that if the groupingSets tree contains no SIMPLE nodes (only EMPTY
1482
+ * nodes at the leaves), then the groupClause will be empty, but this is still
1483
+ * an aggregation query (similar to using aggs or HAVING without GROUP BY).
1484
+ *
1485
+ * As an example, the following clause:
1486
+ *
1487
+ * GROUP BY GROUPING SETS ((a,b), CUBE(c,(d,e)))
1488
+ *
1489
+ * looks like this after raw parsing:
1490
+ *
1491
+ * SETS( RowExpr(a,b) , CUBE( c, RowExpr(d,e) ) )
1492
+ *
1493
+ * and parse analysis converts it to:
1494
+ *
1495
+ * SETS( SIMPLE(1,2), CUBE( SIMPLE(3), SIMPLE(4,5) ) )
1496
+ */
1497
+ typedef enum GroupingSetKind
1498
+ {
1499
+ GROUPING_SET_EMPTY,
1500
+ GROUPING_SET_SIMPLE,
1501
+ GROUPING_SET_ROLLUP,
1502
+ GROUPING_SET_CUBE,
1503
+ GROUPING_SET_SETS,
1504
+ } GroupingSetKind;
1505
+
1506
+ typedef struct GroupingSet
1507
+ {
1508
+ NodeTag type;
1509
+ GroupingSetKind kind pg_node_attr(query_jumble_ignore);
1510
+ List *content;
1511
+ ParseLoc location;
1512
+ } GroupingSet;
1513
+
1514
+ /*
1515
+ * WindowClause -
1516
+ * transformed representation of WINDOW and OVER clauses
1517
+ *
1518
+ * A parsed Query's windowClause list contains these structs. "name" is set
1519
+ * if the clause originally came from WINDOW, and is NULL if it originally
1520
+ * was an OVER clause (but note that we collapse out duplicate OVERs).
1521
+ * partitionClause and orderClause are lists of SortGroupClause structs.
1522
+ * partitionClause is sanitized by the query planner to remove any columns or
1523
+ * expressions belonging to redundant PathKeys.
1524
+ * If we have RANGE with offset PRECEDING/FOLLOWING, the semantics of that are
1525
+ * specified by startInRangeFunc/inRangeColl/inRangeAsc/inRangeNullsFirst
1526
+ * for the start offset, or endInRangeFunc/inRange* for the end offset.
1527
+ * winref is an ID number referenced by WindowFunc nodes; it must be unique
1528
+ * among the members of a Query's windowClause list.
1529
+ * When refname isn't null, the partitionClause is always copied from there;
1530
+ * the orderClause might or might not be copied (see copiedOrder); the framing
1531
+ * options are never copied, per spec.
1532
+ *
1533
+ * The information relevant for the query jumbling is the partition clause
1534
+ * type and its bounds.
1535
+ */
1536
+ typedef struct WindowClause
1537
+ {
1538
+ NodeTag type;
1539
+ /* window name (NULL in an OVER clause) */
1540
+ char *name pg_node_attr(query_jumble_ignore);
1541
+ /* referenced window name, if any */
1542
+ char *refname pg_node_attr(query_jumble_ignore);
1543
+ List *partitionClause; /* PARTITION BY list */
1544
+ /* ORDER BY list */
1545
+ List *orderClause;
1546
+ int frameOptions; /* frame_clause options, see WindowDef */
1547
+ Node *startOffset; /* expression for starting bound, if any */
1548
+ Node *endOffset; /* expression for ending bound, if any */
1549
+ /* in_range function for startOffset */
1550
+ Oid startInRangeFunc pg_node_attr(query_jumble_ignore);
1551
+ /* in_range function for endOffset */
1552
+ Oid endInRangeFunc pg_node_attr(query_jumble_ignore);
1553
+ /* collation for in_range tests */
1554
+ Oid inRangeColl pg_node_attr(query_jumble_ignore);
1555
+ /* use ASC sort order for in_range tests? */
1556
+ bool inRangeAsc pg_node_attr(query_jumble_ignore);
1557
+ /* nulls sort first for in_range tests? */
1558
+ bool inRangeNullsFirst pg_node_attr(query_jumble_ignore);
1559
+ Index winref; /* ID referenced by window functions */
1560
+ /* did we copy orderClause from refname? */
1561
+ bool copiedOrder pg_node_attr(query_jumble_ignore);
1562
+ } WindowClause;
1563
+
1564
+ /*
1565
+ * RowMarkClause -
1566
+ * parser output representation of FOR [KEY] UPDATE/SHARE clauses
1567
+ *
1568
+ * Query.rowMarks contains a separate RowMarkClause node for each relation
1569
+ * identified as a FOR [KEY] UPDATE/SHARE target. If one of these clauses
1570
+ * is applied to a subquery, we generate RowMarkClauses for all normal and
1571
+ * subquery rels in the subquery, but they are marked pushedDown = true to
1572
+ * distinguish them from clauses that were explicitly written at this query
1573
+ * level. Also, Query.hasForUpdate tells whether there were explicit FOR
1574
+ * UPDATE/SHARE/KEY SHARE clauses in the current query level.
1575
+ */
1576
+ typedef struct RowMarkClause
1577
+ {
1578
+ NodeTag type;
1579
+ Index rti; /* range table index of target relation */
1580
+ LockClauseStrength strength;
1581
+ LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
1582
+ bool pushedDown; /* pushed down from higher query level? */
1583
+ } RowMarkClause;
1584
+
1585
+ /*
1586
+ * WithClause -
1587
+ * representation of WITH clause
1588
+ *
1589
+ * Note: WithClause does not propagate into the Query representation;
1590
+ * but CommonTableExpr does.
1591
+ */
1592
+ typedef struct WithClause
1593
+ {
1594
+ NodeTag type;
1595
+ List *ctes; /* list of CommonTableExprs */
1596
+ bool recursive; /* true = WITH RECURSIVE */
1597
+ ParseLoc location; /* token location, or -1 if unknown */
1598
+ } WithClause;
1599
+
1600
+ /*
1601
+ * InferClause -
1602
+ * ON CONFLICT unique index inference clause
1603
+ *
1604
+ * Note: InferClause does not propagate into the Query representation.
1605
+ */
1606
+ typedef struct InferClause
1607
+ {
1608
+ NodeTag type;
1609
+ List *indexElems; /* IndexElems to infer unique index */
1610
+ Node *whereClause; /* qualification (partial-index predicate) */
1611
+ char *conname; /* Constraint name, or NULL if unnamed */
1612
+ ParseLoc location; /* token location, or -1 if unknown */
1613
+ } InferClause;
1614
+
1615
+ /*
1616
+ * OnConflictClause -
1617
+ * representation of ON CONFLICT clause
1618
+ *
1619
+ * Note: OnConflictClause does not propagate into the Query representation.
1620
+ */
1621
+ typedef struct OnConflictClause
1622
+ {
1623
+ NodeTag type;
1624
+ OnConflictAction action; /* DO NOTHING or UPDATE? */
1625
+ InferClause *infer; /* Optional index inference clause */
1626
+ List *targetList; /* the target list (of ResTarget) */
1627
+ Node *whereClause; /* qualifications */
1628
+ ParseLoc location; /* token location, or -1 if unknown */
1629
+ } OnConflictClause;
1630
+
1631
+ /*
1632
+ * CommonTableExpr -
1633
+ * representation of WITH list element
1634
+ */
1635
+
1636
+ typedef enum CTEMaterialize
1637
+ {
1638
+ CTEMaterializeDefault, /* no option specified */
1639
+ CTEMaterializeAlways, /* MATERIALIZED */
1640
+ CTEMaterializeNever, /* NOT MATERIALIZED */
1641
+ } CTEMaterialize;
1642
+
1643
+ typedef struct CTESearchClause
1644
+ {
1645
+ NodeTag type;
1646
+ List *search_col_list;
1647
+ bool search_breadth_first;
1648
+ char *search_seq_column;
1649
+ ParseLoc location;
1650
+ } CTESearchClause;
1651
+
1652
+ typedef struct CTECycleClause
1653
+ {
1654
+ NodeTag type;
1655
+ List *cycle_col_list;
1656
+ char *cycle_mark_column;
1657
+ Node *cycle_mark_value;
1658
+ Node *cycle_mark_default;
1659
+ char *cycle_path_column;
1660
+ ParseLoc location;
1661
+ /* These fields are set during parse analysis: */
1662
+ Oid cycle_mark_type; /* common type of _value and _default */
1663
+ int cycle_mark_typmod;
1664
+ Oid cycle_mark_collation;
1665
+ Oid cycle_mark_neop; /* <> operator for type */
1666
+ } CTECycleClause;
1667
+
1668
+ typedef struct CommonTableExpr
1669
+ {
1670
+ NodeTag type;
1671
+
1672
+ /*
1673
+ * Query name (never qualified). The string name is included in the query
1674
+ * jumbling because RTE_CTE RTEs need it.
1675
+ */
1676
+ char *ctename;
1677
+ /* optional list of column names */
1678
+ List *aliascolnames pg_node_attr(query_jumble_ignore);
1679
+ CTEMaterialize ctematerialized; /* is this an optimization fence? */
1680
+ /* SelectStmt/InsertStmt/etc before parse analysis, Query afterwards: */
1681
+ Node *ctequery; /* the CTE's subquery */
1682
+ CTESearchClause *search_clause pg_node_attr(query_jumble_ignore);
1683
+ CTECycleClause *cycle_clause pg_node_attr(query_jumble_ignore);
1684
+ ParseLoc location; /* token location, or -1 if unknown */
1685
+ /* These fields are set during parse analysis: */
1686
+ /* is this CTE actually recursive? */
1687
+ bool cterecursive pg_node_attr(query_jumble_ignore);
1688
+
1689
+ /*
1690
+ * Number of RTEs referencing this CTE (excluding internal
1691
+ * self-references), irrelevant for query jumbling.
1692
+ */
1693
+ int cterefcount pg_node_attr(query_jumble_ignore);
1694
+ /* list of output column names */
1695
+ List *ctecolnames pg_node_attr(query_jumble_ignore);
1696
+ /* OID list of output column type OIDs */
1697
+ List *ctecoltypes pg_node_attr(query_jumble_ignore);
1698
+ /* integer list of output column typmods */
1699
+ List *ctecoltypmods pg_node_attr(query_jumble_ignore);
1700
+ /* OID list of column collation OIDs */
1701
+ List *ctecolcollations pg_node_attr(query_jumble_ignore);
1702
+ } CommonTableExpr;
1703
+
1704
+ /* Convenience macro to get the output tlist of a CTE's query */
1705
+ #define GetCTETargetList(cte) \
1706
+ (AssertMacro(IsA((cte)->ctequery, Query)), \
1707
+ ((Query *) (cte)->ctequery)->commandType == CMD_SELECT ? \
1708
+ ((Query *) (cte)->ctequery)->targetList : \
1709
+ ((Query *) (cte)->ctequery)->returningList)
1710
+
1711
+ /*
1712
+ * MergeWhenClause -
1713
+ * raw parser representation of a WHEN clause in a MERGE statement
1714
+ *
1715
+ * This is transformed into MergeAction by parse analysis
1716
+ */
1717
+ typedef struct MergeWhenClause
1718
+ {
1719
+ NodeTag type;
1720
+ MergeMatchKind matchKind; /* MATCHED/NOT MATCHED BY SOURCE/TARGET */
1721
+ CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
1722
+ OverridingKind override; /* OVERRIDING clause */
1723
+ Node *condition; /* WHEN conditions (raw parser) */
1724
+ List *targetList; /* INSERT/UPDATE targetlist */
1725
+ /* the following members are only used in INSERT actions */
1726
+ List *values; /* VALUES to INSERT, or NULL */
1727
+ } MergeWhenClause;
1728
+
1729
+ /*
1730
+ * TriggerTransition -
1731
+ * representation of transition row or table naming clause
1732
+ *
1733
+ * Only transition tables are initially supported in the syntax, and only for
1734
+ * AFTER triggers, but other permutations are accepted by the parser so we can
1735
+ * give a meaningful message from C code.
1736
+ */
1737
+ typedef struct TriggerTransition
1738
+ {
1739
+ NodeTag type;
1740
+ char *name;
1741
+ bool isNew;
1742
+ bool isTable;
1743
+ } TriggerTransition;
1744
+
1745
+ /* Nodes for SQL/JSON support */
1746
+
1747
+ /*
1748
+ * JsonOutput -
1749
+ * representation of JSON output clause (RETURNING type [FORMAT format])
1750
+ */
1751
+ typedef struct JsonOutput
1752
+ {
1753
+ NodeTag type;
1754
+ TypeName *typeName; /* RETURNING type name, if specified */
1755
+ JsonReturning *returning; /* RETURNING FORMAT clause and type Oids */
1756
+ } JsonOutput;
1757
+
1758
+ /*
1759
+ * JsonArgument -
1760
+ * representation of argument from JSON PASSING clause
1761
+ */
1762
+ typedef struct JsonArgument
1763
+ {
1764
+ NodeTag type;
1765
+ JsonValueExpr *val; /* argument value expression */
1766
+ char *name; /* argument name */
1767
+ } JsonArgument;
1768
+
1769
+ /*
1770
+ * JsonQuotes -
1771
+ * representation of [KEEP|OMIT] QUOTES clause for JSON_QUERY()
1772
+ */
1773
+ typedef enum JsonQuotes
1774
+ {
1775
+ JS_QUOTES_UNSPEC, /* unspecified */
1776
+ JS_QUOTES_KEEP, /* KEEP QUOTES */
1777
+ JS_QUOTES_OMIT, /* OMIT QUOTES */
1778
+ } JsonQuotes;
1779
+
1780
+ /*
1781
+ * JsonFuncExpr -
1782
+ * untransformed representation of function expressions for
1783
+ * SQL/JSON query functions
1784
+ */
1785
+ typedef struct JsonFuncExpr
1786
+ {
1787
+ NodeTag type;
1788
+ JsonExprOp op; /* expression type */
1789
+ char *column_name; /* JSON_TABLE() column name or NULL if this is
1790
+ * not for a JSON_TABLE() */
1791
+ JsonValueExpr *context_item; /* context item expression */
1792
+ Node *pathspec; /* JSON path specification expression */
1793
+ List *passing; /* list of PASSING clause arguments, if any */
1794
+ JsonOutput *output; /* output clause, if specified */
1795
+ JsonBehavior *on_empty; /* ON EMPTY behavior */
1796
+ JsonBehavior *on_error; /* ON ERROR behavior */
1797
+ JsonWrapper wrapper; /* array wrapper behavior (JSON_QUERY only) */
1798
+ JsonQuotes quotes; /* omit or keep quotes? (JSON_QUERY only) */
1799
+ ParseLoc location; /* token location, or -1 if unknown */
1800
+ } JsonFuncExpr;
1801
+
1802
+ /*
1803
+ * JsonTablePathSpec
1804
+ * untransformed specification of JSON path expression with an optional
1805
+ * name
1806
+ */
1807
+ typedef struct JsonTablePathSpec
1808
+ {
1809
+ NodeTag type;
1810
+
1811
+ Node *string;
1812
+ char *name;
1813
+ ParseLoc name_location;
1814
+ ParseLoc location; /* location of 'string' */
1815
+ } JsonTablePathSpec;
1816
+
1817
+ /*
1818
+ * JsonTable -
1819
+ * untransformed representation of JSON_TABLE
1820
+ */
1821
+ typedef struct JsonTable
1822
+ {
1823
+ NodeTag type;
1824
+ JsonValueExpr *context_item; /* context item expression */
1825
+ JsonTablePathSpec *pathspec; /* JSON path specification */
1826
+ List *passing; /* list of PASSING clause arguments, if any */
1827
+ List *columns; /* list of JsonTableColumn */
1828
+ JsonBehavior *on_error; /* ON ERROR behavior */
1829
+ Alias *alias; /* table alias in FROM clause */
1830
+ bool lateral; /* does it have LATERAL prefix? */
1831
+ ParseLoc location; /* token location, or -1 if unknown */
1832
+ } JsonTable;
1833
+
1834
+ /*
1835
+ * JsonTableColumnType -
1836
+ * enumeration of JSON_TABLE column types
1837
+ */
1838
+ typedef enum JsonTableColumnType
1839
+ {
1840
+ JTC_FOR_ORDINALITY,
1841
+ JTC_REGULAR,
1842
+ JTC_EXISTS,
1843
+ JTC_FORMATTED,
1844
+ JTC_NESTED,
1845
+ } JsonTableColumnType;
1846
+
1847
+ /*
1848
+ * JsonTableColumn -
1849
+ * untransformed representation of JSON_TABLE column
1850
+ */
1851
+ typedef struct JsonTableColumn
1852
+ {
1853
+ NodeTag type;
1854
+ JsonTableColumnType coltype; /* column type */
1855
+ char *name; /* column name */
1856
+ TypeName *typeName; /* column type name */
1857
+ JsonTablePathSpec *pathspec; /* JSON path specification */
1858
+ JsonFormat *format; /* JSON format clause, if specified */
1859
+ JsonWrapper wrapper; /* WRAPPER behavior for formatted columns */
1860
+ JsonQuotes quotes; /* omit or keep quotes on scalar strings? */
1861
+ List *columns; /* nested columns */
1862
+ JsonBehavior *on_empty; /* ON EMPTY behavior */
1863
+ JsonBehavior *on_error; /* ON ERROR behavior */
1864
+ ParseLoc location; /* token location, or -1 if unknown */
1865
+ } JsonTableColumn;
1866
+
1867
+ /*
1868
+ * JsonKeyValue -
1869
+ * untransformed representation of JSON object key-value pair for
1870
+ * JSON_OBJECT() and JSON_OBJECTAGG()
1871
+ */
1872
+ typedef struct JsonKeyValue
1873
+ {
1874
+ NodeTag type;
1875
+ Expr *key; /* key expression */
1876
+ JsonValueExpr *value; /* JSON value expression */
1877
+ } JsonKeyValue;
1878
+
1879
+ /*
1880
+ * JsonParseExpr -
1881
+ * untransformed representation of JSON()
1882
+ */
1883
+ typedef struct JsonParseExpr
1884
+ {
1885
+ NodeTag type;
1886
+ JsonValueExpr *expr; /* string expression */
1887
+ JsonOutput *output; /* RETURNING clause, if specified */
1888
+ bool unique_keys; /* WITH UNIQUE KEYS? */
1889
+ ParseLoc location; /* token location, or -1 if unknown */
1890
+ } JsonParseExpr;
1891
+
1892
+ /*
1893
+ * JsonScalarExpr -
1894
+ * untransformed representation of JSON_SCALAR()
1895
+ */
1896
+ typedef struct JsonScalarExpr
1897
+ {
1898
+ NodeTag type;
1899
+ Expr *expr; /* scalar expression */
1900
+ JsonOutput *output; /* RETURNING clause, if specified */
1901
+ ParseLoc location; /* token location, or -1 if unknown */
1902
+ } JsonScalarExpr;
1903
+
1904
+ /*
1905
+ * JsonSerializeExpr -
1906
+ * untransformed representation of JSON_SERIALIZE() function
1907
+ */
1908
+ typedef struct JsonSerializeExpr
1909
+ {
1910
+ NodeTag type;
1911
+ JsonValueExpr *expr; /* json value expression */
1912
+ JsonOutput *output; /* RETURNING clause, if specified */
1913
+ ParseLoc location; /* token location, or -1 if unknown */
1914
+ } JsonSerializeExpr;
1915
+
1916
+ /*
1917
+ * JsonObjectConstructor -
1918
+ * untransformed representation of JSON_OBJECT() constructor
1919
+ */
1920
+ typedef struct JsonObjectConstructor
1921
+ {
1922
+ NodeTag type;
1923
+ List *exprs; /* list of JsonKeyValue pairs */
1924
+ JsonOutput *output; /* RETURNING clause, if specified */
1925
+ bool absent_on_null; /* skip NULL values? */
1926
+ bool unique; /* check key uniqueness? */
1927
+ ParseLoc location; /* token location, or -1 if unknown */
1928
+ } JsonObjectConstructor;
1929
+
1930
+ /*
1931
+ * JsonArrayConstructor -
1932
+ * untransformed representation of JSON_ARRAY(element,...) constructor
1933
+ */
1934
+ typedef struct JsonArrayConstructor
1935
+ {
1936
+ NodeTag type;
1937
+ List *exprs; /* list of JsonValueExpr elements */
1938
+ JsonOutput *output; /* RETURNING clause, if specified */
1939
+ bool absent_on_null; /* skip NULL elements? */
1940
+ ParseLoc location; /* token location, or -1 if unknown */
1941
+ } JsonArrayConstructor;
1942
+
1943
+ /*
1944
+ * JsonArrayQueryConstructor -
1945
+ * untransformed representation of JSON_ARRAY(subquery) constructor
1946
+ */
1947
+ typedef struct JsonArrayQueryConstructor
1948
+ {
1949
+ NodeTag type;
1950
+ Node *query; /* subquery */
1951
+ JsonOutput *output; /* RETURNING clause, if specified */
1952
+ JsonFormat *format; /* FORMAT clause for subquery, if specified */
1953
+ bool absent_on_null; /* skip NULL elements? */
1954
+ ParseLoc location; /* token location, or -1 if unknown */
1955
+ } JsonArrayQueryConstructor;
1956
+
1957
+ /*
1958
+ * JsonAggConstructor -
1959
+ * common fields of untransformed representation of
1960
+ * JSON_ARRAYAGG() and JSON_OBJECTAGG()
1961
+ */
1962
+ typedef struct JsonAggConstructor
1963
+ {
1964
+ NodeTag type;
1965
+ JsonOutput *output; /* RETURNING clause, if any */
1966
+ Node *agg_filter; /* FILTER clause, if any */
1967
+ List *agg_order; /* ORDER BY clause, if any */
1968
+ struct WindowDef *over; /* OVER clause, if any */
1969
+ ParseLoc location; /* token location, or -1 if unknown */
1970
+ } JsonAggConstructor;
1971
+
1972
+ /*
1973
+ * JsonObjectAgg -
1974
+ * untransformed representation of JSON_OBJECTAGG()
1975
+ */
1976
+ typedef struct JsonObjectAgg
1977
+ {
1978
+ NodeTag type;
1979
+ JsonAggConstructor *constructor; /* common fields */
1980
+ JsonKeyValue *arg; /* object key-value pair */
1981
+ bool absent_on_null; /* skip NULL values? */
1982
+ bool unique; /* check key uniqueness? */
1983
+ } JsonObjectAgg;
1984
+
1985
+ /*
1986
+ * JsonArrayAgg -
1987
+ * untransformed representation of JSON_ARRAYAGG()
1988
+ */
1989
+ typedef struct JsonArrayAgg
1990
+ {
1991
+ NodeTag type;
1992
+ JsonAggConstructor *constructor; /* common fields */
1993
+ JsonValueExpr *arg; /* array element expression */
1994
+ bool absent_on_null; /* skip NULL elements? */
1995
+ } JsonArrayAgg;
1996
+
1997
+
1998
+ /*****************************************************************************
1999
+ * Raw Grammar Output Statements
2000
+ *****************************************************************************/
2001
+
2002
+ /*
2003
+ * RawStmt --- container for any one statement's raw parse tree
2004
+ *
2005
+ * Parse analysis converts a raw parse tree headed by a RawStmt node into
2006
+ * an analyzed statement headed by a Query node. For optimizable statements,
2007
+ * the conversion is complex. For utility statements, the parser usually just
2008
+ * transfers the raw parse tree (sans RawStmt) into the utilityStmt field of
2009
+ * the Query node, and all the useful work happens at execution time.
2010
+ *
2011
+ * stmt_location/stmt_len identify the portion of the source text string
2012
+ * containing this raw statement (useful for multi-statement strings).
2013
+ *
2014
+ * This is irrelevant for query jumbling, as this is not used in parsed
2015
+ * queries.
2016
+ */
2017
+ typedef struct RawStmt
2018
+ {
2019
+ pg_node_attr(no_query_jumble)
2020
+
2021
+ NodeTag type;
2022
+ Node *stmt; /* raw parse tree */
2023
+ ParseLoc stmt_location; /* start location, or -1 if unknown */
2024
+ ParseLoc stmt_len; /* length in bytes; 0 means "rest of string" */
2025
+ } RawStmt;
2026
+
2027
+ /*****************************************************************************
2028
+ * Optimizable Statements
2029
+ *****************************************************************************/
2030
+
2031
+ /* ----------------------
2032
+ * Insert Statement
2033
+ *
2034
+ * The source expression is represented by SelectStmt for both the
2035
+ * SELECT and VALUES cases. If selectStmt is NULL, then the query
2036
+ * is INSERT ... DEFAULT VALUES.
2037
+ * ----------------------
2038
+ */
2039
+ typedef struct InsertStmt
2040
+ {
2041
+ NodeTag type;
2042
+ RangeVar *relation; /* relation to insert into */
2043
+ List *cols; /* optional: names of the target columns */
2044
+ Node *selectStmt; /* the source SELECT/VALUES, or NULL */
2045
+ OnConflictClause *onConflictClause; /* ON CONFLICT clause */
2046
+ List *returningList; /* list of expressions to return */
2047
+ WithClause *withClause; /* WITH clause */
2048
+ OverridingKind override; /* OVERRIDING clause */
2049
+ } InsertStmt;
2050
+
2051
+ /* ----------------------
2052
+ * Delete Statement
2053
+ * ----------------------
2054
+ */
2055
+ typedef struct DeleteStmt
2056
+ {
2057
+ NodeTag type;
2058
+ RangeVar *relation; /* relation to delete from */
2059
+ List *usingClause; /* optional using clause for more tables */
2060
+ Node *whereClause; /* qualifications */
2061
+ List *returningList; /* list of expressions to return */
2062
+ WithClause *withClause; /* WITH clause */
2063
+ } DeleteStmt;
2064
+
2065
+ /* ----------------------
2066
+ * Update Statement
2067
+ * ----------------------
2068
+ */
2069
+ typedef struct UpdateStmt
2070
+ {
2071
+ NodeTag type;
2072
+ RangeVar *relation; /* relation to update */
2073
+ List *targetList; /* the target list (of ResTarget) */
2074
+ Node *whereClause; /* qualifications */
2075
+ List *fromClause; /* optional from clause for more tables */
2076
+ List *returningList; /* list of expressions to return */
2077
+ WithClause *withClause; /* WITH clause */
2078
+ } UpdateStmt;
2079
+
2080
+ /* ----------------------
2081
+ * Merge Statement
2082
+ * ----------------------
2083
+ */
2084
+ typedef struct MergeStmt
2085
+ {
2086
+ NodeTag type;
2087
+ RangeVar *relation; /* target relation to merge into */
2088
+ Node *sourceRelation; /* source relation */
2089
+ Node *joinCondition; /* join condition between source and target */
2090
+ List *mergeWhenClauses; /* list of MergeWhenClause(es) */
2091
+ List *returningList; /* list of expressions to return */
2092
+ WithClause *withClause; /* WITH clause */
2093
+ } MergeStmt;
2094
+
2095
+ /* ----------------------
2096
+ * Select Statement
2097
+ *
2098
+ * A "simple" SELECT is represented in the output of gram.y by a single
2099
+ * SelectStmt node; so is a VALUES construct. A query containing set
2100
+ * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt
2101
+ * nodes, in which the leaf nodes are component SELECTs and the internal nodes
2102
+ * represent UNION, INTERSECT, or EXCEPT operators. Using the same node
2103
+ * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
2104
+ * LIMIT, etc, clause values into a SELECT statement without worrying
2105
+ * whether it is a simple or compound SELECT.
2106
+ * ----------------------
2107
+ */
2108
+ typedef enum SetOperation
2109
+ {
2110
+ SETOP_NONE = 0,
2111
+ SETOP_UNION,
2112
+ SETOP_INTERSECT,
2113
+ SETOP_EXCEPT,
2114
+ } SetOperation;
2115
+
2116
+ typedef struct SelectStmt
2117
+ {
2118
+ NodeTag type;
2119
+
2120
+ /*
2121
+ * These fields are used only in "leaf" SelectStmts.
2122
+ */
2123
+ List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
2124
+ * lcons(NIL,NIL) for all (SELECT DISTINCT) */
2125
+ IntoClause *intoClause; /* target for SELECT INTO */
2126
+ List *targetList; /* the target list (of ResTarget) */
2127
+ List *fromClause; /* the FROM clause */
2128
+ Node *whereClause; /* WHERE qualification */
2129
+ List *groupClause; /* GROUP BY clauses */
2130
+ bool groupDistinct; /* Is this GROUP BY DISTINCT? */
2131
+ Node *havingClause; /* HAVING conditional-expression */
2132
+ List *windowClause; /* WINDOW window_name AS (...), ... */
2133
+
2134
+ /*
2135
+ * In a "leaf" node representing a VALUES list, the above fields are all
2136
+ * null, and instead this field is set. Note that the elements of the
2137
+ * sublists are just expressions, without ResTarget decoration. Also note
2138
+ * that a list element can be DEFAULT (represented as a SetToDefault
2139
+ * node), regardless of the context of the VALUES list. It's up to parse
2140
+ * analysis to reject that where not valid.
2141
+ */
2142
+ List *valuesLists; /* untransformed list of expression lists */
2143
+
2144
+ /*
2145
+ * These fields are used in both "leaf" SelectStmts and upper-level
2146
+ * SelectStmts.
2147
+ */
2148
+ List *sortClause; /* sort clause (a list of SortBy's) */
2149
+ Node *limitOffset; /* # of result tuples to skip */
2150
+ Node *limitCount; /* # of result tuples to return */
2151
+ LimitOption limitOption; /* limit type */
2152
+ List *lockingClause; /* FOR UPDATE (list of LockingClause's) */
2153
+ WithClause *withClause; /* WITH clause */
2154
+
2155
+ /*
2156
+ * These fields are used only in upper-level SelectStmts.
2157
+ */
2158
+ SetOperation op; /* type of set op */
2159
+ bool all; /* ALL specified? */
2160
+ struct SelectStmt *larg; /* left child */
2161
+ struct SelectStmt *rarg; /* right child */
2162
+ /* Eventually add fields for CORRESPONDING spec here */
2163
+ } SelectStmt;
2164
+
2165
+
2166
+ /* ----------------------
2167
+ * Set Operation node for post-analysis query trees
2168
+ *
2169
+ * After parse analysis, a SELECT with set operations is represented by a
2170
+ * top-level Query node containing the leaf SELECTs as subqueries in its
2171
+ * range table. Its setOperations field shows the tree of set operations,
2172
+ * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
2173
+ * nodes replaced by SetOperationStmt nodes. Information about the output
2174
+ * column types is added, too. (Note that the child nodes do not necessarily
2175
+ * produce these types directly, but we've checked that their output types
2176
+ * can be coerced to the output column type.) Also, if it's not UNION ALL,
2177
+ * information about the types' sort/group semantics is provided in the form
2178
+ * of a SortGroupClause list (same representation as, eg, DISTINCT).
2179
+ * The resolved common column collations are provided too; but note that if
2180
+ * it's not UNION ALL, it's okay for a column to not have a common collation,
2181
+ * so a member of the colCollations list could be InvalidOid even though the
2182
+ * column has a collatable type.
2183
+ * ----------------------
2184
+ */
2185
+ typedef struct SetOperationStmt
2186
+ {
2187
+ NodeTag type;
2188
+ SetOperation op; /* type of set op */
2189
+ bool all; /* ALL specified? */
2190
+ Node *larg; /* left child */
2191
+ Node *rarg; /* right child */
2192
+ /* Eventually add fields for CORRESPONDING spec here */
2193
+
2194
+ /* Fields derived during parse analysis (irrelevant for query jumbling): */
2195
+ /* OID list of output column type OIDs */
2196
+ List *colTypes pg_node_attr(query_jumble_ignore);
2197
+ /* integer list of output column typmods */
2198
+ List *colTypmods pg_node_attr(query_jumble_ignore);
2199
+ /* OID list of output column collation OIDs */
2200
+ List *colCollations pg_node_attr(query_jumble_ignore);
2201
+ /* a list of SortGroupClause's */
2202
+ List *groupClauses pg_node_attr(query_jumble_ignore);
2203
+ /* groupClauses is NIL if UNION ALL, but must be set otherwise */
2204
+ } SetOperationStmt;
2205
+
2206
+
2207
+ /*
2208
+ * RETURN statement (inside SQL function body)
2209
+ */
2210
+ typedef struct ReturnStmt
2211
+ {
2212
+ NodeTag type;
2213
+ Node *returnval;
2214
+ } ReturnStmt;
2215
+
2216
+
2217
+ /* ----------------------
2218
+ * PL/pgSQL Assignment Statement
2219
+ *
2220
+ * Like SelectStmt, this is transformed into a SELECT Query.
2221
+ * However, the targetlist of the result looks more like an UPDATE.
2222
+ * ----------------------
2223
+ */
2224
+ typedef struct PLAssignStmt
2225
+ {
2226
+ NodeTag type;
2227
+
2228
+ char *name; /* initial column name */
2229
+ List *indirection; /* subscripts and field names, if any */
2230
+ int nnames; /* number of names to use in ColumnRef */
2231
+ SelectStmt *val; /* the PL/pgSQL expression to assign */
2232
+ ParseLoc location; /* name's token location, or -1 if unknown */
2233
+ } PLAssignStmt;
2234
+
2235
+
2236
+ /*****************************************************************************
2237
+ * Other Statements (no optimizations required)
2238
+ *
2239
+ * These are not touched by parser/analyze.c except to put them into
2240
+ * the utilityStmt field of a Query. This is eventually passed to
2241
+ * ProcessUtility (by-passing rewriting and planning). Some of the
2242
+ * statements do need attention from parse analysis, and this is
2243
+ * done by routines in parser/parse_utilcmd.c after ProcessUtility
2244
+ * receives the command for execution.
2245
+ * DECLARE CURSOR, EXPLAIN, and CREATE TABLE AS are special cases:
2246
+ * they contain optimizable statements, which get processed normally
2247
+ * by parser/analyze.c.
2248
+ *****************************************************************************/
2249
+
2250
+ /*
2251
+ * When a command can act on several kinds of objects with only one
2252
+ * parse structure required, use these constants to designate the
2253
+ * object type. Note that commands typically don't support all the types.
2254
+ */
2255
+
2256
+ typedef enum ObjectType
2257
+ {
2258
+ OBJECT_ACCESS_METHOD,
2259
+ OBJECT_AGGREGATE,
2260
+ OBJECT_AMOP,
2261
+ OBJECT_AMPROC,
2262
+ OBJECT_ATTRIBUTE, /* type's attribute, when distinct from column */
2263
+ OBJECT_CAST,
2264
+ OBJECT_COLUMN,
2265
+ OBJECT_COLLATION,
2266
+ OBJECT_CONVERSION,
2267
+ OBJECT_DATABASE,
2268
+ OBJECT_DEFAULT,
2269
+ OBJECT_DEFACL,
2270
+ OBJECT_DOMAIN,
2271
+ OBJECT_DOMCONSTRAINT,
2272
+ OBJECT_EVENT_TRIGGER,
2273
+ OBJECT_EXTENSION,
2274
+ OBJECT_FDW,
2275
+ OBJECT_FOREIGN_SERVER,
2276
+ OBJECT_FOREIGN_TABLE,
2277
+ OBJECT_FUNCTION,
2278
+ OBJECT_INDEX,
2279
+ OBJECT_LANGUAGE,
2280
+ OBJECT_LARGEOBJECT,
2281
+ OBJECT_MATVIEW,
2282
+ OBJECT_OPCLASS,
2283
+ OBJECT_OPERATOR,
2284
+ OBJECT_OPFAMILY,
2285
+ OBJECT_PARAMETER_ACL,
2286
+ OBJECT_POLICY,
2287
+ OBJECT_PROCEDURE,
2288
+ OBJECT_PUBLICATION,
2289
+ OBJECT_PUBLICATION_NAMESPACE,
2290
+ OBJECT_PUBLICATION_REL,
2291
+ OBJECT_ROLE,
2292
+ OBJECT_ROUTINE,
2293
+ OBJECT_RULE,
2294
+ OBJECT_SCHEMA,
2295
+ OBJECT_SEQUENCE,
2296
+ OBJECT_SUBSCRIPTION,
2297
+ OBJECT_STATISTIC_EXT,
2298
+ OBJECT_TABCONSTRAINT,
2299
+ OBJECT_TABLE,
2300
+ OBJECT_TABLESPACE,
2301
+ OBJECT_TRANSFORM,
2302
+ OBJECT_TRIGGER,
2303
+ OBJECT_TSCONFIGURATION,
2304
+ OBJECT_TSDICTIONARY,
2305
+ OBJECT_TSPARSER,
2306
+ OBJECT_TSTEMPLATE,
2307
+ OBJECT_TYPE,
2308
+ OBJECT_USER_MAPPING,
2309
+ OBJECT_VIEW,
2310
+ } ObjectType;
2311
+
2312
+ /* ----------------------
2313
+ * Create Schema Statement
2314
+ *
2315
+ * NOTE: the schemaElts list contains raw parsetrees for component statements
2316
+ * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
2317
+ * executed after the schema itself is created.
2318
+ * ----------------------
2319
+ */
2320
+ typedef struct CreateSchemaStmt
2321
+ {
2322
+ NodeTag type;
2323
+ char *schemaname; /* the name of the schema to create */
2324
+ RoleSpec *authrole; /* the owner of the created schema */
2325
+ List *schemaElts; /* schema components (list of parsenodes) */
2326
+ bool if_not_exists; /* just do nothing if schema already exists? */
2327
+ } CreateSchemaStmt;
2328
+
2329
+ typedef enum DropBehavior
2330
+ {
2331
+ DROP_RESTRICT, /* drop fails if any dependent objects */
2332
+ DROP_CASCADE, /* remove dependent objects too */
2333
+ } DropBehavior;
2334
+
2335
+ /* ----------------------
2336
+ * Alter Table
2337
+ * ----------------------
2338
+ */
2339
+ typedef struct AlterTableStmt
2340
+ {
2341
+ NodeTag type;
2342
+ RangeVar *relation; /* table to work on */
2343
+ List *cmds; /* list of subcommands */
2344
+ ObjectType objtype; /* type of object */
2345
+ bool missing_ok; /* skip error if table missing */
2346
+ } AlterTableStmt;
2347
+
2348
+ typedef enum AlterTableType
2349
+ {
2350
+ AT_AddColumn, /* add column */
2351
+ AT_AddColumnToView, /* implicitly via CREATE OR REPLACE VIEW */
2352
+ AT_ColumnDefault, /* alter column default */
2353
+ AT_CookedColumnDefault, /* add a pre-cooked column default */
2354
+ AT_DropNotNull, /* alter column drop not null */
2355
+ AT_SetNotNull, /* alter column set not null */
2356
+ AT_SetExpression, /* alter column set expression */
2357
+ AT_DropExpression, /* alter column drop expression */
2358
+ AT_CheckNotNull, /* check column is already marked not null */
2359
+ AT_SetStatistics, /* alter column set statistics */
2360
+ AT_SetOptions, /* alter column set ( options ) */
2361
+ AT_ResetOptions, /* alter column reset ( options ) */
2362
+ AT_SetStorage, /* alter column set storage */
2363
+ AT_SetCompression, /* alter column set compression */
2364
+ AT_DropColumn, /* drop column */
2365
+ AT_AddIndex, /* add index */
2366
+ AT_ReAddIndex, /* internal to commands/tablecmds.c */
2367
+ AT_AddConstraint, /* add constraint */
2368
+ AT_ReAddConstraint, /* internal to commands/tablecmds.c */
2369
+ AT_ReAddDomainConstraint, /* internal to commands/tablecmds.c */
2370
+ AT_AlterConstraint, /* alter constraint */
2371
+ AT_ValidateConstraint, /* validate constraint */
2372
+ AT_AddIndexConstraint, /* add constraint using existing index */
2373
+ AT_DropConstraint, /* drop constraint */
2374
+ AT_ReAddComment, /* internal to commands/tablecmds.c */
2375
+ AT_AlterColumnType, /* alter column type */
2376
+ AT_AlterColumnGenericOptions, /* alter column OPTIONS (...) */
2377
+ AT_ChangeOwner, /* change owner */
2378
+ AT_ClusterOn, /* CLUSTER ON */
2379
+ AT_DropCluster, /* SET WITHOUT CLUSTER */
2380
+ AT_SetLogged, /* SET LOGGED */
2381
+ AT_SetUnLogged, /* SET UNLOGGED */
2382
+ AT_DropOids, /* SET WITHOUT OIDS */
2383
+ AT_SetAccessMethod, /* SET ACCESS METHOD */
2384
+ AT_SetTableSpace, /* SET TABLESPACE */
2385
+ AT_SetRelOptions, /* SET (...) -- AM specific parameters */
2386
+ AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */
2387
+ AT_ReplaceRelOptions, /* replace reloption list in its entirety */
2388
+ AT_EnableTrig, /* ENABLE TRIGGER name */
2389
+ AT_EnableAlwaysTrig, /* ENABLE ALWAYS TRIGGER name */
2390
+ AT_EnableReplicaTrig, /* ENABLE REPLICA TRIGGER name */
2391
+ AT_DisableTrig, /* DISABLE TRIGGER name */
2392
+ AT_EnableTrigAll, /* ENABLE TRIGGER ALL */
2393
+ AT_DisableTrigAll, /* DISABLE TRIGGER ALL */
2394
+ AT_EnableTrigUser, /* ENABLE TRIGGER USER */
2395
+ AT_DisableTrigUser, /* DISABLE TRIGGER USER */
2396
+ AT_EnableRule, /* ENABLE RULE name */
2397
+ AT_EnableAlwaysRule, /* ENABLE ALWAYS RULE name */
2398
+ AT_EnableReplicaRule, /* ENABLE REPLICA RULE name */
2399
+ AT_DisableRule, /* DISABLE RULE name */
2400
+ AT_AddInherit, /* INHERIT parent */
2401
+ AT_DropInherit, /* NO INHERIT parent */
2402
+ AT_AddOf, /* OF <type_name> */
2403
+ AT_DropOf, /* NOT OF */
2404
+ AT_ReplicaIdentity, /* REPLICA IDENTITY */
2405
+ AT_EnableRowSecurity, /* ENABLE ROW SECURITY */
2406
+ AT_DisableRowSecurity, /* DISABLE ROW SECURITY */
2407
+ AT_ForceRowSecurity, /* FORCE ROW SECURITY */
2408
+ AT_NoForceRowSecurity, /* NO FORCE ROW SECURITY */
2409
+ AT_GenericOptions, /* OPTIONS (...) */
2410
+ AT_AttachPartition, /* ATTACH PARTITION */
2411
+ AT_DetachPartition, /* DETACH PARTITION */
2412
+ AT_DetachPartitionFinalize, /* DETACH PARTITION FINALIZE */
2413
+ AT_AddIdentity, /* ADD IDENTITY */
2414
+ AT_SetIdentity, /* SET identity column options */
2415
+ AT_DropIdentity, /* DROP IDENTITY */
2416
+ AT_ReAddStatistics, /* internal to commands/tablecmds.c */
2417
+ } AlterTableType;
2418
+
2419
+ typedef struct ReplicaIdentityStmt
2420
+ {
2421
+ NodeTag type;
2422
+ char identity_type;
2423
+ char *name;
2424
+ } ReplicaIdentityStmt;
2425
+
2426
+ typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
2427
+ {
2428
+ NodeTag type;
2429
+ AlterTableType subtype; /* Type of table alteration to apply */
2430
+ char *name; /* column, constraint, or trigger to act on,
2431
+ * or tablespace, access method */
2432
+ int16 num; /* attribute number for columns referenced by
2433
+ * number */
2434
+ RoleSpec *newowner;
2435
+ Node *def; /* definition of new column, index,
2436
+ * constraint, or parent table */
2437
+ DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
2438
+ bool missing_ok; /* skip error if missing? */
2439
+ bool recurse; /* exec-time recursion */
2440
+ } AlterTableCmd;
2441
+
2442
+
2443
+ /* ----------------------
2444
+ * Alter Collation
2445
+ * ----------------------
2446
+ */
2447
+ typedef struct AlterCollationStmt
2448
+ {
2449
+ NodeTag type;
2450
+ List *collname;
2451
+ } AlterCollationStmt;
2452
+
2453
+
2454
+ /* ----------------------
2455
+ * Alter Domain
2456
+ *
2457
+ * The fields are used in different ways by the different variants of
2458
+ * this command.
2459
+ * ----------------------
2460
+ */
2461
+ typedef struct AlterDomainStmt
2462
+ {
2463
+ NodeTag type;
2464
+ char subtype; /*------------
2465
+ * T = alter column default
2466
+ * N = alter column drop not null
2467
+ * O = alter column set not null
2468
+ * C = add constraint
2469
+ * X = drop constraint
2470
+ *------------
2471
+ */
2472
+ List *typeName; /* domain to work on */
2473
+ char *name; /* column or constraint name to act on */
2474
+ Node *def; /* definition of default or constraint */
2475
+ DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
2476
+ bool missing_ok; /* skip error if missing? */
2477
+ } AlterDomainStmt;
2478
+
2479
+
2480
+ /* ----------------------
2481
+ * Grant|Revoke Statement
2482
+ * ----------------------
2483
+ */
2484
+ typedef enum GrantTargetType
2485
+ {
2486
+ ACL_TARGET_OBJECT, /* grant on specific named object(s) */
2487
+ ACL_TARGET_ALL_IN_SCHEMA, /* grant on all objects in given schema(s) */
2488
+ ACL_TARGET_DEFAULTS, /* ALTER DEFAULT PRIVILEGES */
2489
+ } GrantTargetType;
2490
+
2491
+ typedef struct GrantStmt
2492
+ {
2493
+ NodeTag type;
2494
+ bool is_grant; /* true = GRANT, false = REVOKE */
2495
+ GrantTargetType targtype; /* type of the grant target */
2496
+ ObjectType objtype; /* kind of object being operated on */
2497
+ List *objects; /* list of RangeVar nodes, ObjectWithArgs
2498
+ * nodes, or plain names (as String values) */
2499
+ List *privileges; /* list of AccessPriv nodes */
2500
+ /* privileges == NIL denotes ALL PRIVILEGES */
2501
+ List *grantees; /* list of RoleSpec nodes */
2502
+ bool grant_option; /* grant or revoke grant option */
2503
+ RoleSpec *grantor;
2504
+ DropBehavior behavior; /* drop behavior (for REVOKE) */
2505
+ } GrantStmt;
2506
+
2507
+ /*
2508
+ * ObjectWithArgs represents a function/procedure/operator name plus parameter
2509
+ * identification.
2510
+ *
2511
+ * objargs includes only the types of the input parameters of the object.
2512
+ * In some contexts, that will be all we have, and it's enough to look up
2513
+ * objects according to the traditional Postgres rules (i.e., when only input
2514
+ * arguments matter).
2515
+ *
2516
+ * objfuncargs, if not NIL, carries the full specification of the parameter
2517
+ * list, including parameter mode annotations.
2518
+ *
2519
+ * Some grammar productions can set args_unspecified = true instead of
2520
+ * providing parameter info. In this case, lookup will succeed only if
2521
+ * the object name is unique. Note that otherwise, NIL parameter lists
2522
+ * mean zero arguments.
2523
+ */
2524
+ typedef struct ObjectWithArgs
2525
+ {
2526
+ NodeTag type;
2527
+ List *objname; /* qualified name of function/operator */
2528
+ List *objargs; /* list of Typename nodes (input args only) */
2529
+ List *objfuncargs; /* list of FunctionParameter nodes */
2530
+ bool args_unspecified; /* argument list was omitted? */
2531
+ } ObjectWithArgs;
2532
+
2533
+ /*
2534
+ * An access privilege, with optional list of column names
2535
+ * priv_name == NULL denotes ALL PRIVILEGES (only used with a column list)
2536
+ * cols == NIL denotes "all columns"
2537
+ * Note that simple "ALL PRIVILEGES" is represented as a NIL list, not
2538
+ * an AccessPriv with both fields null.
2539
+ */
2540
+ typedef struct AccessPriv
2541
+ {
2542
+ NodeTag type;
2543
+ char *priv_name; /* string name of privilege */
2544
+ List *cols; /* list of String */
2545
+ } AccessPriv;
2546
+
2547
+ /* ----------------------
2548
+ * Grant/Revoke Role Statement
2549
+ *
2550
+ * Note: because of the parsing ambiguity with the GRANT <privileges>
2551
+ * statement, granted_roles is a list of AccessPriv; the execution code
2552
+ * should complain if any column lists appear. grantee_roles is a list
2553
+ * of role names, as String values.
2554
+ * ----------------------
2555
+ */
2556
+ typedef struct GrantRoleStmt
2557
+ {
2558
+ NodeTag type;
2559
+ List *granted_roles; /* list of roles to be granted/revoked */
2560
+ List *grantee_roles; /* list of member roles to add/delete */
2561
+ bool is_grant; /* true = GRANT, false = REVOKE */
2562
+ List *opt; /* options e.g. WITH GRANT OPTION */
2563
+ RoleSpec *grantor; /* set grantor to other than current role */
2564
+ DropBehavior behavior; /* drop behavior (for REVOKE) */
2565
+ } GrantRoleStmt;
2566
+
2567
+ /* ----------------------
2568
+ * Alter Default Privileges Statement
2569
+ * ----------------------
2570
+ */
2571
+ typedef struct AlterDefaultPrivilegesStmt
2572
+ {
2573
+ NodeTag type;
2574
+ List *options; /* list of DefElem */
2575
+ GrantStmt *action; /* GRANT/REVOKE action (with objects=NIL) */
2576
+ } AlterDefaultPrivilegesStmt;
2577
+
2578
+ /* ----------------------
2579
+ * Copy Statement
2580
+ *
2581
+ * We support "COPY relation FROM file", "COPY relation TO file", and
2582
+ * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
2583
+ * and "query" must be non-NULL.
2584
+ * ----------------------
2585
+ */
2586
+ typedef struct CopyStmt
2587
+ {
2588
+ NodeTag type;
2589
+ RangeVar *relation; /* the relation to copy */
2590
+ Node *query; /* the query (SELECT or DML statement with
2591
+ * RETURNING) to copy, as a raw parse tree */
2592
+ List *attlist; /* List of column names (as Strings), or NIL
2593
+ * for all columns */
2594
+ bool is_from; /* TO or FROM */
2595
+ bool is_program; /* is 'filename' a program to popen? */
2596
+ char *filename; /* filename, or NULL for STDIN/STDOUT */
2597
+ List *options; /* List of DefElem nodes */
2598
+ Node *whereClause; /* WHERE condition (or NULL) */
2599
+ } CopyStmt;
2600
+
2601
+ /* ----------------------
2602
+ * SET Statement (includes RESET)
2603
+ *
2604
+ * "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we
2605
+ * preserve the distinction in VariableSetKind for CreateCommandTag().
2606
+ * ----------------------
2607
+ */
2608
+ typedef enum VariableSetKind
2609
+ {
2610
+ VAR_SET_VALUE, /* SET var = value */
2611
+ VAR_SET_DEFAULT, /* SET var TO DEFAULT */
2612
+ VAR_SET_CURRENT, /* SET var FROM CURRENT */
2613
+ VAR_SET_MULTI, /* special case for SET TRANSACTION ... */
2614
+ VAR_RESET, /* RESET var */
2615
+ VAR_RESET_ALL, /* RESET ALL */
2616
+ } VariableSetKind;
2617
+
2618
+ typedef struct VariableSetStmt
2619
+ {
2620
+ NodeTag type;
2621
+ VariableSetKind kind;
2622
+ char *name; /* variable to be set */
2623
+ List *args; /* List of A_Const nodes */
2624
+ bool is_local; /* SET LOCAL? */
2625
+ } VariableSetStmt;
2626
+
2627
+ /* ----------------------
2628
+ * Show Statement
2629
+ * ----------------------
2630
+ */
2631
+ typedef struct VariableShowStmt
2632
+ {
2633
+ NodeTag type;
2634
+ char *name;
2635
+ } VariableShowStmt;
2636
+
2637
+ /* ----------------------
2638
+ * Create Table Statement
2639
+ *
2640
+ * NOTE: in the raw gram.y output, ColumnDef and Constraint nodes are
2641
+ * intermixed in tableElts, and constraints is NIL. After parse analysis,
2642
+ * tableElts contains just ColumnDefs, and constraints contains just
2643
+ * Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
2644
+ * implementation).
2645
+ * ----------------------
2646
+ */
2647
+
2648
+ typedef struct CreateStmt
2649
+ {
2650
+ NodeTag type;
2651
+ RangeVar *relation; /* relation to create */
2652
+ List *tableElts; /* column definitions (list of ColumnDef) */
2653
+ List *inhRelations; /* relations to inherit from (list of
2654
+ * RangeVar) */
2655
+ PartitionBoundSpec *partbound; /* FOR VALUES clause */
2656
+ PartitionSpec *partspec; /* PARTITION BY clause */
2657
+ TypeName *ofTypename; /* OF typename */
2658
+ List *constraints; /* constraints (list of Constraint nodes) */
2659
+ List *options; /* options from WITH clause */
2660
+ OnCommitAction oncommit; /* what do we do at COMMIT? */
2661
+ char *tablespacename; /* table space to use, or NULL */
2662
+ char *accessMethod; /* table access method */
2663
+ bool if_not_exists; /* just do nothing if it already exists? */
2664
+ } CreateStmt;
2665
+
2666
+ /* ----------
2667
+ * Definitions for constraints in CreateStmt
2668
+ *
2669
+ * Note that column defaults are treated as a type of constraint,
2670
+ * even though that's a bit odd semantically.
2671
+ *
2672
+ * For constraints that use expressions (CONSTR_CHECK, CONSTR_DEFAULT)
2673
+ * we may have the expression in either "raw" form (an untransformed
2674
+ * parse tree) or "cooked" form (the nodeToString representation of
2675
+ * an executable expression tree), depending on how this Constraint
2676
+ * node was created (by parsing, or by inheritance from an existing
2677
+ * relation). We should never have both in the same node!
2678
+ *
2679
+ * FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
2680
+ * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
2681
+ * stored into pg_constraint.confmatchtype. Changing the code values may
2682
+ * require an initdb!
2683
+ *
2684
+ * If skip_validation is true then we skip checking that the existing rows
2685
+ * in the table satisfy the constraint, and just install the catalog entries
2686
+ * for the constraint. A new FK constraint is marked as valid iff
2687
+ * initially_valid is true. (Usually skip_validation and initially_valid
2688
+ * are inverses, but we can set both true if the table is known empty.)
2689
+ *
2690
+ * Constraint attributes (DEFERRABLE etc) are initially represented as
2691
+ * separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes
2692
+ * a pass through the constraints list to insert the info into the appropriate
2693
+ * Constraint node.
2694
+ * ----------
2695
+ */
2696
+
2697
+ typedef enum ConstrType /* types of constraints */
2698
+ {
2699
+ CONSTR_NULL, /* not standard SQL, but a lot of people
2700
+ * expect it */
2701
+ CONSTR_NOTNULL,
2702
+ CONSTR_DEFAULT,
2703
+ CONSTR_IDENTITY,
2704
+ CONSTR_GENERATED,
2705
+ CONSTR_CHECK,
2706
+ CONSTR_PRIMARY,
2707
+ CONSTR_UNIQUE,
2708
+ CONSTR_EXCLUSION,
2709
+ CONSTR_FOREIGN,
2710
+ CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */
2711
+ CONSTR_ATTR_NOT_DEFERRABLE,
2712
+ CONSTR_ATTR_DEFERRED,
2713
+ CONSTR_ATTR_IMMEDIATE,
2714
+ } ConstrType;
2715
+
2716
+ /* Foreign key action codes */
2717
+ #define FKCONSTR_ACTION_NOACTION 'a'
2718
+ #define FKCONSTR_ACTION_RESTRICT 'r'
2719
+ #define FKCONSTR_ACTION_CASCADE 'c'
2720
+ #define FKCONSTR_ACTION_SETNULL 'n'
2721
+ #define FKCONSTR_ACTION_SETDEFAULT 'd'
2722
+
2723
+ /* Foreign key matchtype codes */
2724
+ #define FKCONSTR_MATCH_FULL 'f'
2725
+ #define FKCONSTR_MATCH_PARTIAL 'p'
2726
+ #define FKCONSTR_MATCH_SIMPLE 's'
2727
+
2728
+ typedef struct Constraint
2729
+ {
2730
+ NodeTag type;
2731
+ ConstrType contype; /* see above */
2732
+ char *conname; /* Constraint name, or NULL if unnamed */
2733
+ bool deferrable; /* DEFERRABLE? */
2734
+ bool initdeferred; /* INITIALLY DEFERRED? */
2735
+ bool skip_validation; /* skip validation of existing rows? */
2736
+ bool initially_valid; /* mark the new constraint as valid? */
2737
+ bool is_no_inherit; /* is constraint non-inheritable? */
2738
+ Node *raw_expr; /* CHECK or DEFAULT expression, as
2739
+ * untransformed parse tree */
2740
+ char *cooked_expr; /* CHECK or DEFAULT expression, as
2741
+ * nodeToString representation */
2742
+ char generated_when; /* ALWAYS or BY DEFAULT */
2743
+ int inhcount; /* initial inheritance count to apply, for
2744
+ * "raw" NOT NULL constraints */
2745
+ bool nulls_not_distinct; /* null treatment for UNIQUE constraints */
2746
+ List *keys; /* String nodes naming referenced key
2747
+ * column(s); for UNIQUE/PK/NOT NULL */
2748
+ List *including; /* String nodes naming referenced nonkey
2749
+ * column(s); for UNIQUE/PK */
2750
+ List *exclusions; /* list of (IndexElem, operator name) pairs;
2751
+ * for exclusion constraints */
2752
+ List *options; /* options from WITH clause */
2753
+ char *indexname; /* existing index to use; otherwise NULL */
2754
+ char *indexspace; /* index tablespace; NULL for default */
2755
+ bool reset_default_tblspc; /* reset default_tablespace prior to
2756
+ * creating the index */
2757
+ char *access_method; /* index access method; NULL for default */
2758
+ Node *where_clause; /* partial index predicate */
2759
+
2760
+ /* Fields used for FOREIGN KEY constraints: */
2761
+ RangeVar *pktable; /* Primary key table */
2762
+ List *fk_attrs; /* Attributes of foreign key */
2763
+ List *pk_attrs; /* Corresponding attrs in PK table */
2764
+ char fk_matchtype; /* FULL, PARTIAL, SIMPLE */
2765
+ char fk_upd_action; /* ON UPDATE action */
2766
+ char fk_del_action; /* ON DELETE action */
2767
+ List *fk_del_set_cols; /* ON DELETE SET NULL/DEFAULT (col1, col2) */
2768
+ List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */
2769
+ Oid old_pktable_oid; /* pg_constraint.confrelid of my former
2770
+ * self */
2771
+
2772
+ ParseLoc location; /* token location, or -1 if unknown */
2773
+ } Constraint;
2774
+
2775
+ /* ----------------------
2776
+ * Create/Drop Table Space Statements
2777
+ * ----------------------
2778
+ */
2779
+
2780
+ typedef struct CreateTableSpaceStmt
2781
+ {
2782
+ NodeTag type;
2783
+ char *tablespacename;
2784
+ RoleSpec *owner;
2785
+ char *location;
2786
+ List *options;
2787
+ } CreateTableSpaceStmt;
2788
+
2789
+ typedef struct DropTableSpaceStmt
2790
+ {
2791
+ NodeTag type;
2792
+ char *tablespacename;
2793
+ bool missing_ok; /* skip error if missing? */
2794
+ } DropTableSpaceStmt;
2795
+
2796
+ typedef struct AlterTableSpaceOptionsStmt
2797
+ {
2798
+ NodeTag type;
2799
+ char *tablespacename;
2800
+ List *options;
2801
+ bool isReset;
2802
+ } AlterTableSpaceOptionsStmt;
2803
+
2804
+ typedef struct AlterTableMoveAllStmt
2805
+ {
2806
+ NodeTag type;
2807
+ char *orig_tablespacename;
2808
+ ObjectType objtype; /* Object type to move */
2809
+ List *roles; /* List of roles to move objects of */
2810
+ char *new_tablespacename;
2811
+ bool nowait;
2812
+ } AlterTableMoveAllStmt;
2813
+
2814
+ /* ----------------------
2815
+ * Create/Alter Extension Statements
2816
+ * ----------------------
2817
+ */
2818
+
2819
+ typedef struct CreateExtensionStmt
2820
+ {
2821
+ NodeTag type;
2822
+ char *extname;
2823
+ bool if_not_exists; /* just do nothing if it already exists? */
2824
+ List *options; /* List of DefElem nodes */
2825
+ } CreateExtensionStmt;
2826
+
2827
+ /* Only used for ALTER EXTENSION UPDATE; later might need an action field */
2828
+ typedef struct AlterExtensionStmt
2829
+ {
2830
+ NodeTag type;
2831
+ char *extname;
2832
+ List *options; /* List of DefElem nodes */
2833
+ } AlterExtensionStmt;
2834
+
2835
+ typedef struct AlterExtensionContentsStmt
2836
+ {
2837
+ NodeTag type;
2838
+ char *extname; /* Extension's name */
2839
+ int action; /* +1 = add object, -1 = drop object */
2840
+ ObjectType objtype; /* Object's type */
2841
+ Node *object; /* Qualified name of the object */
2842
+ } AlterExtensionContentsStmt;
2843
+
2844
+ /* ----------------------
2845
+ * Create/Alter FOREIGN DATA WRAPPER Statements
2846
+ * ----------------------
2847
+ */
2848
+
2849
+ typedef struct CreateFdwStmt
2850
+ {
2851
+ NodeTag type;
2852
+ char *fdwname; /* foreign-data wrapper name */
2853
+ List *func_options; /* HANDLER/VALIDATOR options */
2854
+ List *options; /* generic options to FDW */
2855
+ } CreateFdwStmt;
2856
+
2857
+ typedef struct AlterFdwStmt
2858
+ {
2859
+ NodeTag type;
2860
+ char *fdwname; /* foreign-data wrapper name */
2861
+ List *func_options; /* HANDLER/VALIDATOR options */
2862
+ List *options; /* generic options to FDW */
2863
+ } AlterFdwStmt;
2864
+
2865
+ /* ----------------------
2866
+ * Create/Alter FOREIGN SERVER Statements
2867
+ * ----------------------
2868
+ */
2869
+
2870
+ typedef struct CreateForeignServerStmt
2871
+ {
2872
+ NodeTag type;
2873
+ char *servername; /* server name */
2874
+ char *servertype; /* optional server type */
2875
+ char *version; /* optional server version */
2876
+ char *fdwname; /* FDW name */
2877
+ bool if_not_exists; /* just do nothing if it already exists? */
2878
+ List *options; /* generic options to server */
2879
+ } CreateForeignServerStmt;
2880
+
2881
+ typedef struct AlterForeignServerStmt
2882
+ {
2883
+ NodeTag type;
2884
+ char *servername; /* server name */
2885
+ char *version; /* optional server version */
2886
+ List *options; /* generic options to server */
2887
+ bool has_version; /* version specified */
2888
+ } AlterForeignServerStmt;
2889
+
2890
+ /* ----------------------
2891
+ * Create FOREIGN TABLE Statement
2892
+ * ----------------------
2893
+ */
2894
+
2895
+ typedef struct CreateForeignTableStmt
2896
+ {
2897
+ CreateStmt base;
2898
+ char *servername;
2899
+ List *options;
2900
+ } CreateForeignTableStmt;
2901
+
2902
+ /* ----------------------
2903
+ * Create/Drop USER MAPPING Statements
2904
+ * ----------------------
2905
+ */
2906
+
2907
+ typedef struct CreateUserMappingStmt
2908
+ {
2909
+ NodeTag type;
2910
+ RoleSpec *user; /* user role */
2911
+ char *servername; /* server name */
2912
+ bool if_not_exists; /* just do nothing if it already exists? */
2913
+ List *options; /* generic options to server */
2914
+ } CreateUserMappingStmt;
2915
+
2916
+ typedef struct AlterUserMappingStmt
2917
+ {
2918
+ NodeTag type;
2919
+ RoleSpec *user; /* user role */
2920
+ char *servername; /* server name */
2921
+ List *options; /* generic options to server */
2922
+ } AlterUserMappingStmt;
2923
+
2924
+ typedef struct DropUserMappingStmt
2925
+ {
2926
+ NodeTag type;
2927
+ RoleSpec *user; /* user role */
2928
+ char *servername; /* server name */
2929
+ bool missing_ok; /* ignore missing mappings */
2930
+ } DropUserMappingStmt;
2931
+
2932
+ /* ----------------------
2933
+ * Import Foreign Schema Statement
2934
+ * ----------------------
2935
+ */
2936
+
2937
+ typedef enum ImportForeignSchemaType
2938
+ {
2939
+ FDW_IMPORT_SCHEMA_ALL, /* all relations wanted */
2940
+ FDW_IMPORT_SCHEMA_LIMIT_TO, /* include only listed tables in import */
2941
+ FDW_IMPORT_SCHEMA_EXCEPT, /* exclude listed tables from import */
2942
+ } ImportForeignSchemaType;
2943
+
2944
+ typedef struct ImportForeignSchemaStmt
2945
+ {
2946
+ NodeTag type;
2947
+ char *server_name; /* FDW server name */
2948
+ char *remote_schema; /* remote schema name to query */
2949
+ char *local_schema; /* local schema to create objects in */
2950
+ ImportForeignSchemaType list_type; /* type of table list */
2951
+ List *table_list; /* List of RangeVar */
2952
+ List *options; /* list of options to pass to FDW */
2953
+ } ImportForeignSchemaStmt;
2954
+
2955
+ /*----------------------
2956
+ * Create POLICY Statement
2957
+ *----------------------
2958
+ */
2959
+ typedef struct CreatePolicyStmt
2960
+ {
2961
+ NodeTag type;
2962
+ char *policy_name; /* Policy's name */
2963
+ RangeVar *table; /* the table name the policy applies to */
2964
+ char *cmd_name; /* the command name the policy applies to */
2965
+ bool permissive; /* restrictive or permissive policy */
2966
+ List *roles; /* the roles associated with the policy */
2967
+ Node *qual; /* the policy's condition */
2968
+ Node *with_check; /* the policy's WITH CHECK condition. */
2969
+ } CreatePolicyStmt;
2970
+
2971
+ /*----------------------
2972
+ * Alter POLICY Statement
2973
+ *----------------------
2974
+ */
2975
+ typedef struct AlterPolicyStmt
2976
+ {
2977
+ NodeTag type;
2978
+ char *policy_name; /* Policy's name */
2979
+ RangeVar *table; /* the table name the policy applies to */
2980
+ List *roles; /* the roles associated with the policy */
2981
+ Node *qual; /* the policy's condition */
2982
+ Node *with_check; /* the policy's WITH CHECK condition. */
2983
+ } AlterPolicyStmt;
2984
+
2985
+ /*----------------------
2986
+ * Create ACCESS METHOD Statement
2987
+ *----------------------
2988
+ */
2989
+ typedef struct CreateAmStmt
2990
+ {
2991
+ NodeTag type;
2992
+ char *amname; /* access method name */
2993
+ List *handler_name; /* handler function name */
2994
+ char amtype; /* type of access method */
2995
+ } CreateAmStmt;
2996
+
2997
+ /* ----------------------
2998
+ * Create TRIGGER Statement
2999
+ * ----------------------
3000
+ */
3001
+ typedef struct CreateTrigStmt
3002
+ {
3003
+ NodeTag type;
3004
+ bool replace; /* replace trigger if already exists */
3005
+ bool isconstraint; /* This is a constraint trigger */
3006
+ char *trigname; /* TRIGGER's name */
3007
+ RangeVar *relation; /* relation trigger is on */
3008
+ List *funcname; /* qual. name of function to call */
3009
+ List *args; /* list of String or NIL */
3010
+ bool row; /* ROW/STATEMENT */
3011
+ /* timing uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
3012
+ int16 timing; /* BEFORE, AFTER, or INSTEAD */
3013
+ /* events uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
3014
+ int16 events; /* "OR" of INSERT/UPDATE/DELETE/TRUNCATE */
3015
+ List *columns; /* column names, or NIL for all columns */
3016
+ Node *whenClause; /* qual expression, or NULL if none */
3017
+ /* explicitly named transition data */
3018
+ List *transitionRels; /* TriggerTransition nodes, or NIL if none */
3019
+ /* The remaining fields are only used for constraint triggers */
3020
+ bool deferrable; /* [NOT] DEFERRABLE */
3021
+ bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */
3022
+ RangeVar *constrrel; /* opposite relation, if RI trigger */
3023
+ } CreateTrigStmt;
3024
+
3025
+ /* ----------------------
3026
+ * Create EVENT TRIGGER Statement
3027
+ * ----------------------
3028
+ */
3029
+ typedef struct CreateEventTrigStmt
3030
+ {
3031
+ NodeTag type;
3032
+ char *trigname; /* TRIGGER's name */
3033
+ char *eventname; /* event's identifier */
3034
+ List *whenclause; /* list of DefElems indicating filtering */
3035
+ List *funcname; /* qual. name of function to call */
3036
+ } CreateEventTrigStmt;
3037
+
3038
+ /* ----------------------
3039
+ * Alter EVENT TRIGGER Statement
3040
+ * ----------------------
3041
+ */
3042
+ typedef struct AlterEventTrigStmt
3043
+ {
3044
+ NodeTag type;
3045
+ char *trigname; /* TRIGGER's name */
3046
+ char tgenabled; /* trigger's firing configuration WRT
3047
+ * session_replication_role */
3048
+ } AlterEventTrigStmt;
3049
+
3050
+ /* ----------------------
3051
+ * Create LANGUAGE Statements
3052
+ * ----------------------
3053
+ */
3054
+ typedef struct CreatePLangStmt
3055
+ {
3056
+ NodeTag type;
3057
+ bool replace; /* T => replace if already exists */
3058
+ char *plname; /* PL name */
3059
+ List *plhandler; /* PL call handler function (qual. name) */
3060
+ List *plinline; /* optional inline function (qual. name) */
3061
+ List *plvalidator; /* optional validator function (qual. name) */
3062
+ bool pltrusted; /* PL is trusted */
3063
+ } CreatePLangStmt;
3064
+
3065
+ /* ----------------------
3066
+ * Create/Alter/Drop Role Statements
3067
+ *
3068
+ * Note: these node types are also used for the backwards-compatible
3069
+ * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
3070
+ * there's really no need to distinguish what the original spelling was,
3071
+ * but for CREATE we mark the type because the defaults vary.
3072
+ * ----------------------
3073
+ */
3074
+ typedef enum RoleStmtType
3075
+ {
3076
+ ROLESTMT_ROLE,
3077
+ ROLESTMT_USER,
3078
+ ROLESTMT_GROUP,
3079
+ } RoleStmtType;
3080
+
3081
+ typedef struct CreateRoleStmt
3082
+ {
3083
+ NodeTag type;
3084
+ RoleStmtType stmt_type; /* ROLE/USER/GROUP */
3085
+ char *role; /* role name */
3086
+ List *options; /* List of DefElem nodes */
3087
+ } CreateRoleStmt;
3088
+
3089
+ typedef struct AlterRoleStmt
3090
+ {
3091
+ NodeTag type;
3092
+ RoleSpec *role; /* role */
3093
+ List *options; /* List of DefElem nodes */
3094
+ int action; /* +1 = add members, -1 = drop members */
3095
+ } AlterRoleStmt;
3096
+
3097
+ typedef struct AlterRoleSetStmt
3098
+ {
3099
+ NodeTag type;
3100
+ RoleSpec *role; /* role */
3101
+ char *database; /* database name, or NULL */
3102
+ VariableSetStmt *setstmt; /* SET or RESET subcommand */
3103
+ } AlterRoleSetStmt;
3104
+
3105
+ typedef struct DropRoleStmt
3106
+ {
3107
+ NodeTag type;
3108
+ List *roles; /* List of roles to remove */
3109
+ bool missing_ok; /* skip error if a role is missing? */
3110
+ } DropRoleStmt;
3111
+
3112
+ /* ----------------------
3113
+ * {Create|Alter} SEQUENCE Statement
3114
+ * ----------------------
3115
+ */
3116
+
3117
+ typedef struct CreateSeqStmt
3118
+ {
3119
+ NodeTag type;
3120
+ RangeVar *sequence; /* the sequence to create */
3121
+ List *options;
3122
+ Oid ownerId; /* ID of owner, or InvalidOid for default */
3123
+ bool for_identity;
3124
+ bool if_not_exists; /* just do nothing if it already exists? */
3125
+ } CreateSeqStmt;
3126
+
3127
+ typedef struct AlterSeqStmt
3128
+ {
3129
+ NodeTag type;
3130
+ RangeVar *sequence; /* the sequence to alter */
3131
+ List *options;
3132
+ bool for_identity;
3133
+ bool missing_ok; /* skip error if a role is missing? */
3134
+ } AlterSeqStmt;
3135
+
3136
+ /* ----------------------
3137
+ * Create {Aggregate|Operator|Type} Statement
3138
+ * ----------------------
3139
+ */
3140
+ typedef struct DefineStmt
3141
+ {
3142
+ NodeTag type;
3143
+ ObjectType kind; /* aggregate, operator, type */
3144
+ bool oldstyle; /* hack to signal old CREATE AGG syntax */
3145
+ List *defnames; /* qualified name (list of String) */
3146
+ List *args; /* a list of TypeName (if needed) */
3147
+ List *definition; /* a list of DefElem */
3148
+ bool if_not_exists; /* just do nothing if it already exists? */
3149
+ bool replace; /* replace if already exists? */
3150
+ } DefineStmt;
3151
+
3152
+ /* ----------------------
3153
+ * Create Domain Statement
3154
+ * ----------------------
3155
+ */
3156
+ typedef struct CreateDomainStmt
3157
+ {
3158
+ NodeTag type;
3159
+ List *domainname; /* qualified name (list of String) */
3160
+ TypeName *typeName; /* the base type */
3161
+ CollateClause *collClause; /* untransformed COLLATE spec, if any */
3162
+ List *constraints; /* constraints (list of Constraint nodes) */
3163
+ } CreateDomainStmt;
3164
+
3165
+ /* ----------------------
3166
+ * Create Operator Class Statement
3167
+ * ----------------------
3168
+ */
3169
+ typedef struct CreateOpClassStmt
3170
+ {
3171
+ NodeTag type;
3172
+ List *opclassname; /* qualified name (list of String) */
3173
+ List *opfamilyname; /* qualified name (ditto); NIL if omitted */
3174
+ char *amname; /* name of index AM opclass is for */
3175
+ TypeName *datatype; /* datatype of indexed column */
3176
+ List *items; /* List of CreateOpClassItem nodes */
3177
+ bool isDefault; /* Should be marked as default for type? */
3178
+ } CreateOpClassStmt;
3179
+
3180
+ #define OPCLASS_ITEM_OPERATOR 1
3181
+ #define OPCLASS_ITEM_FUNCTION 2
3182
+ #define OPCLASS_ITEM_STORAGETYPE 3
3183
+
3184
+ typedef struct CreateOpClassItem
3185
+ {
3186
+ NodeTag type;
3187
+ int itemtype; /* see codes above */
3188
+ ObjectWithArgs *name; /* operator or function name and args */
3189
+ int number; /* strategy num or support proc num */
3190
+ List *order_family; /* only used for ordering operators */
3191
+ List *class_args; /* amproclefttype/amprocrighttype or
3192
+ * amoplefttype/amoprighttype */
3193
+ /* fields used for a storagetype item: */
3194
+ TypeName *storedtype; /* datatype stored in index */
3195
+ } CreateOpClassItem;
3196
+
3197
+ /* ----------------------
3198
+ * Create Operator Family Statement
3199
+ * ----------------------
3200
+ */
3201
+ typedef struct CreateOpFamilyStmt
3202
+ {
3203
+ NodeTag type;
3204
+ List *opfamilyname; /* qualified name (list of String) */
3205
+ char *amname; /* name of index AM opfamily is for */
3206
+ } CreateOpFamilyStmt;
3207
+
3208
+ /* ----------------------
3209
+ * Alter Operator Family Statement
3210
+ * ----------------------
3211
+ */
3212
+ typedef struct AlterOpFamilyStmt
3213
+ {
3214
+ NodeTag type;
3215
+ List *opfamilyname; /* qualified name (list of String) */
3216
+ char *amname; /* name of index AM opfamily is for */
3217
+ bool isDrop; /* ADD or DROP the items? */
3218
+ List *items; /* List of CreateOpClassItem nodes */
3219
+ } AlterOpFamilyStmt;
3220
+
3221
+ /* ----------------------
3222
+ * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
3223
+ * ----------------------
3224
+ */
3225
+
3226
+ typedef struct DropStmt
3227
+ {
3228
+ NodeTag type;
3229
+ List *objects; /* list of names */
3230
+ ObjectType removeType; /* object type */
3231
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
3232
+ bool missing_ok; /* skip error if object is missing? */
3233
+ bool concurrent; /* drop index concurrently? */
3234
+ } DropStmt;
3235
+
3236
+ /* ----------------------
3237
+ * Truncate Table Statement
3238
+ * ----------------------
3239
+ */
3240
+ typedef struct TruncateStmt
3241
+ {
3242
+ NodeTag type;
3243
+ List *relations; /* relations (RangeVars) to be truncated */
3244
+ bool restart_seqs; /* restart owned sequences? */
3245
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
3246
+ } TruncateStmt;
3247
+
3248
+ /* ----------------------
3249
+ * Comment On Statement
3250
+ * ----------------------
3251
+ */
3252
+ typedef struct CommentStmt
3253
+ {
3254
+ NodeTag type;
3255
+ ObjectType objtype; /* Object's type */
3256
+ Node *object; /* Qualified name of the object */
3257
+ char *comment; /* Comment to insert, or NULL to remove */
3258
+ } CommentStmt;
3259
+
3260
+ /* ----------------------
3261
+ * SECURITY LABEL Statement
3262
+ * ----------------------
3263
+ */
3264
+ typedef struct SecLabelStmt
3265
+ {
3266
+ NodeTag type;
3267
+ ObjectType objtype; /* Object's type */
3268
+ Node *object; /* Qualified name of the object */
3269
+ char *provider; /* Label provider (or NULL) */
3270
+ char *label; /* New security label to be assigned */
3271
+ } SecLabelStmt;
3272
+
3273
+ /* ----------------------
3274
+ * Declare Cursor Statement
3275
+ *
3276
+ * The "query" field is initially a raw parse tree, and is converted to a
3277
+ * Query node during parse analysis. Note that rewriting and planning
3278
+ * of the query are always postponed until execution.
3279
+ * ----------------------
3280
+ */
3281
+ #define CURSOR_OPT_BINARY 0x0001 /* BINARY */
3282
+ #define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
3283
+ #define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
3284
+ #define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
3285
+ #define CURSOR_OPT_ASENSITIVE 0x0010 /* ASENSITIVE */
3286
+ #define CURSOR_OPT_HOLD 0x0020 /* WITH HOLD */
3287
+ /* these planner-control flags do not correspond to any SQL grammar: */
3288
+ #define CURSOR_OPT_FAST_PLAN 0x0100 /* prefer fast-start plan */
3289
+ #define CURSOR_OPT_GENERIC_PLAN 0x0200 /* force use of generic plan */
3290
+ #define CURSOR_OPT_CUSTOM_PLAN 0x0400 /* force use of custom plan */
3291
+ #define CURSOR_OPT_PARALLEL_OK 0x0800 /* parallel mode OK */
3292
+
3293
+ typedef struct DeclareCursorStmt
3294
+ {
3295
+ NodeTag type;
3296
+ char *portalname; /* name of the portal (cursor) */
3297
+ int options; /* bitmask of options (see above) */
3298
+ Node *query; /* the query (see comments above) */
3299
+ } DeclareCursorStmt;
3300
+
3301
+ /* ----------------------
3302
+ * Close Portal Statement
3303
+ * ----------------------
3304
+ */
3305
+ typedef struct ClosePortalStmt
3306
+ {
3307
+ NodeTag type;
3308
+ char *portalname; /* name of the portal (cursor) */
3309
+ /* NULL means CLOSE ALL */
3310
+ } ClosePortalStmt;
3311
+
3312
+ /* ----------------------
3313
+ * Fetch Statement (also Move)
3314
+ * ----------------------
3315
+ */
3316
+ typedef enum FetchDirection
3317
+ {
3318
+ /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
3319
+ FETCH_FORWARD,
3320
+ FETCH_BACKWARD,
3321
+ /* for these, howMany indicates a position; only one row is fetched */
3322
+ FETCH_ABSOLUTE,
3323
+ FETCH_RELATIVE,
3324
+ } FetchDirection;
3325
+
3326
+ #define FETCH_ALL LONG_MAX
3327
+
3328
+ typedef struct FetchStmt
3329
+ {
3330
+ NodeTag type;
3331
+ FetchDirection direction; /* see above */
3332
+ long howMany; /* number of rows, or position argument */
3333
+ char *portalname; /* name of portal (cursor) */
3334
+ bool ismove; /* true if MOVE */
3335
+ } FetchStmt;
3336
+
3337
+ /* ----------------------
3338
+ * Create Index Statement
3339
+ *
3340
+ * This represents creation of an index and/or an associated constraint.
3341
+ * If isconstraint is true, we should create a pg_constraint entry along
3342
+ * with the index. But if indexOid isn't InvalidOid, we are not creating an
3343
+ * index, just a UNIQUE/PKEY constraint using an existing index. isconstraint
3344
+ * must always be true in this case, and the fields describing the index
3345
+ * properties are empty.
3346
+ * ----------------------
3347
+ */
3348
+ typedef struct IndexStmt
3349
+ {
3350
+ NodeTag type;
3351
+ char *idxname; /* name of new index, or NULL for default */
3352
+ RangeVar *relation; /* relation to build index on */
3353
+ char *accessMethod; /* name of access method (eg. btree) */
3354
+ char *tableSpace; /* tablespace, or NULL for default */
3355
+ List *indexParams; /* columns to index: a list of IndexElem */
3356
+ List *indexIncludingParams; /* additional columns to index: a list
3357
+ * of IndexElem */
3358
+ List *options; /* WITH clause options: a list of DefElem */
3359
+ Node *whereClause; /* qualification (partial-index predicate) */
3360
+ List *excludeOpNames; /* exclusion operator names, or NIL if none */
3361
+ char *idxcomment; /* comment to apply to index, or NULL */
3362
+ Oid indexOid; /* OID of an existing index, if any */
3363
+ RelFileNumber oldNumber; /* relfilenumber of existing storage, if any */
3364
+ SubTransactionId oldCreateSubid; /* rd_createSubid of oldNumber */
3365
+ SubTransactionId oldFirstRelfilelocatorSubid; /* rd_firstRelfilelocatorSubid
3366
+ * of oldNumber */
3367
+ bool unique; /* is index unique? */
3368
+ bool nulls_not_distinct; /* null treatment for UNIQUE constraints */
3369
+ bool primary; /* is index a primary key? */
3370
+ bool isconstraint; /* is it for a pkey/unique constraint? */
3371
+ bool deferrable; /* is the constraint DEFERRABLE? */
3372
+ bool initdeferred; /* is the constraint INITIALLY DEFERRED? */
3373
+ bool transformed; /* true when transformIndexStmt is finished */
3374
+ bool concurrent; /* should this be a concurrent index build? */
3375
+ bool if_not_exists; /* just do nothing if index already exists? */
3376
+ bool reset_default_tblspc; /* reset default_tablespace prior to
3377
+ * executing */
3378
+ } IndexStmt;
3379
+
3380
+ /* ----------------------
3381
+ * Create Statistics Statement
3382
+ * ----------------------
3383
+ */
3384
+ typedef struct CreateStatsStmt
3385
+ {
3386
+ NodeTag type;
3387
+ List *defnames; /* qualified name (list of String) */
3388
+ List *stat_types; /* stat types (list of String) */
3389
+ List *exprs; /* expressions to build statistics on */
3390
+ List *relations; /* rels to build stats on (list of RangeVar) */
3391
+ char *stxcomment; /* comment to apply to stats, or NULL */
3392
+ bool transformed; /* true when transformStatsStmt is finished */
3393
+ bool if_not_exists; /* do nothing if stats name already exists */
3394
+ } CreateStatsStmt;
3395
+
3396
+ /*
3397
+ * StatsElem - statistics parameters (used in CREATE STATISTICS)
3398
+ *
3399
+ * For a plain attribute, 'name' is the name of the referenced table column
3400
+ * and 'expr' is NULL. For an expression, 'name' is NULL and 'expr' is the
3401
+ * expression tree.
3402
+ */
3403
+ typedef struct StatsElem
3404
+ {
3405
+ NodeTag type;
3406
+ char *name; /* name of attribute to index, or NULL */
3407
+ Node *expr; /* expression to index, or NULL */
3408
+ } StatsElem;
3409
+
3410
+
3411
+ /* ----------------------
3412
+ * Alter Statistics Statement
3413
+ * ----------------------
3414
+ */
3415
+ typedef struct AlterStatsStmt
3416
+ {
3417
+ NodeTag type;
3418
+ List *defnames; /* qualified name (list of String) */
3419
+ Node *stxstattarget; /* statistics target */
3420
+ bool missing_ok; /* skip error if statistics object is missing */
3421
+ } AlterStatsStmt;
3422
+
3423
+ /* ----------------------
3424
+ * Create Function Statement
3425
+ * ----------------------
3426
+ */
3427
+ typedef struct CreateFunctionStmt
3428
+ {
3429
+ NodeTag type;
3430
+ bool is_procedure; /* it's really CREATE PROCEDURE */
3431
+ bool replace; /* T => replace if already exists */
3432
+ List *funcname; /* qualified name of function to create */
3433
+ List *parameters; /* a list of FunctionParameter */
3434
+ TypeName *returnType; /* the return type */
3435
+ List *options; /* a list of DefElem */
3436
+ Node *sql_body;
3437
+ } CreateFunctionStmt;
3438
+
3439
+ typedef enum FunctionParameterMode
3440
+ {
3441
+ /* the assigned enum values appear in pg_proc, don't change 'em! */
3442
+ FUNC_PARAM_IN = 'i', /* input only */
3443
+ FUNC_PARAM_OUT = 'o', /* output only */
3444
+ FUNC_PARAM_INOUT = 'b', /* both */
3445
+ FUNC_PARAM_VARIADIC = 'v', /* variadic (always input) */
3446
+ FUNC_PARAM_TABLE = 't', /* table function output column */
3447
+ /* this is not used in pg_proc: */
3448
+ FUNC_PARAM_DEFAULT = 'd', /* default; effectively same as IN */
3449
+ } FunctionParameterMode;
3450
+
3451
+ typedef struct FunctionParameter
3452
+ {
3453
+ NodeTag type;
3454
+ char *name; /* parameter name, or NULL if not given */
3455
+ TypeName *argType; /* TypeName for parameter type */
3456
+ FunctionParameterMode mode; /* IN/OUT/etc */
3457
+ Node *defexpr; /* raw default expr, or NULL if not given */
3458
+ } FunctionParameter;
3459
+
3460
+ typedef struct AlterFunctionStmt
3461
+ {
3462
+ NodeTag type;
3463
+ ObjectType objtype;
3464
+ ObjectWithArgs *func; /* name and args of function */
3465
+ List *actions; /* list of DefElem */
3466
+ } AlterFunctionStmt;
3467
+
3468
+ /* ----------------------
3469
+ * DO Statement
3470
+ *
3471
+ * DoStmt is the raw parser output, InlineCodeBlock is the execution-time API
3472
+ * ----------------------
3473
+ */
3474
+ typedef struct DoStmt
3475
+ {
3476
+ NodeTag type;
3477
+ List *args; /* List of DefElem nodes */
3478
+ } DoStmt;
3479
+
3480
+ typedef struct InlineCodeBlock
3481
+ {
3482
+ pg_node_attr(nodetag_only) /* this is not a member of parse trees */
3483
+
3484
+ NodeTag type;
3485
+ char *source_text; /* source text of anonymous code block */
3486
+ Oid langOid; /* OID of selected language */
3487
+ bool langIsTrusted; /* trusted property of the language */
3488
+ bool atomic; /* atomic execution context */
3489
+ } InlineCodeBlock;
3490
+
3491
+ /* ----------------------
3492
+ * CALL statement
3493
+ *
3494
+ * OUT-mode arguments are removed from the transformed funcexpr. The outargs
3495
+ * list contains copies of the expressions for all output arguments, in the
3496
+ * order of the procedure's declared arguments. (outargs is never evaluated,
3497
+ * but is useful to the caller as a reference for what to assign to.)
3498
+ * The transformed call state is not relevant in the query jumbling, only the
3499
+ * function call is.
3500
+ * ----------------------
3501
+ */
3502
+ typedef struct CallStmt
3503
+ {
3504
+ NodeTag type;
3505
+ /* from the parser */
3506
+ FuncCall *funccall pg_node_attr(query_jumble_ignore);
3507
+ /* transformed call, with only input args */
3508
+ FuncExpr *funcexpr;
3509
+ /* transformed output-argument expressions */
3510
+ List *outargs;
3511
+ } CallStmt;
3512
+
3513
+ typedef struct CallContext
3514
+ {
3515
+ pg_node_attr(nodetag_only) /* this is not a member of parse trees */
3516
+
3517
+ NodeTag type;
3518
+ bool atomic;
3519
+ } CallContext;
3520
+
3521
+ /* ----------------------
3522
+ * Alter Object Rename Statement
3523
+ * ----------------------
3524
+ */
3525
+ typedef struct RenameStmt
3526
+ {
3527
+ NodeTag type;
3528
+ ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
3529
+ ObjectType relationType; /* if column name, associated relation type */
3530
+ RangeVar *relation; /* in case it's a table */
3531
+ Node *object; /* in case it's some other object */
3532
+ char *subname; /* name of contained object (column, rule,
3533
+ * trigger, etc) */
3534
+ char *newname; /* the new name */
3535
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
3536
+ bool missing_ok; /* skip error if missing? */
3537
+ } RenameStmt;
3538
+
3539
+ /* ----------------------
3540
+ * ALTER object DEPENDS ON EXTENSION extname
3541
+ * ----------------------
3542
+ */
3543
+ typedef struct AlterObjectDependsStmt
3544
+ {
3545
+ NodeTag type;
3546
+ ObjectType objectType; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
3547
+ RangeVar *relation; /* in case a table is involved */
3548
+ Node *object; /* name of the object */
3549
+ String *extname; /* extension name */
3550
+ bool remove; /* set true to remove dep rather than add */
3551
+ } AlterObjectDependsStmt;
3552
+
3553
+ /* ----------------------
3554
+ * ALTER object SET SCHEMA Statement
3555
+ * ----------------------
3556
+ */
3557
+ typedef struct AlterObjectSchemaStmt
3558
+ {
3559
+ NodeTag type;
3560
+ ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
3561
+ RangeVar *relation; /* in case it's a table */
3562
+ Node *object; /* in case it's some other object */
3563
+ char *newschema; /* the new schema */
3564
+ bool missing_ok; /* skip error if missing? */
3565
+ } AlterObjectSchemaStmt;
3566
+
3567
+ /* ----------------------
3568
+ * Alter Object Owner Statement
3569
+ * ----------------------
3570
+ */
3571
+ typedef struct AlterOwnerStmt
3572
+ {
3573
+ NodeTag type;
3574
+ ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
3575
+ RangeVar *relation; /* in case it's a table */
3576
+ Node *object; /* in case it's some other object */
3577
+ RoleSpec *newowner; /* the new owner */
3578
+ } AlterOwnerStmt;
3579
+
3580
+ /* ----------------------
3581
+ * Alter Operator Set ( this-n-that )
3582
+ * ----------------------
3583
+ */
3584
+ typedef struct AlterOperatorStmt
3585
+ {
3586
+ NodeTag type;
3587
+ ObjectWithArgs *opername; /* operator name and argument types */
3588
+ List *options; /* List of DefElem nodes */
3589
+ } AlterOperatorStmt;
3590
+
3591
+ /* ------------------------
3592
+ * Alter Type Set ( this-n-that )
3593
+ * ------------------------
3594
+ */
3595
+ typedef struct AlterTypeStmt
3596
+ {
3597
+ NodeTag type;
3598
+ List *typeName; /* type name (possibly qualified) */
3599
+ List *options; /* List of DefElem nodes */
3600
+ } AlterTypeStmt;
3601
+
3602
+ /* ----------------------
3603
+ * Create Rule Statement
3604
+ * ----------------------
3605
+ */
3606
+ typedef struct RuleStmt
3607
+ {
3608
+ NodeTag type;
3609
+ RangeVar *relation; /* relation the rule is for */
3610
+ char *rulename; /* name of the rule */
3611
+ Node *whereClause; /* qualifications */
3612
+ CmdType event; /* SELECT, INSERT, etc */
3613
+ bool instead; /* is a 'do instead'? */
3614
+ List *actions; /* the action statements */
3615
+ bool replace; /* OR REPLACE */
3616
+ } RuleStmt;
3617
+
3618
+ /* ----------------------
3619
+ * Notify Statement
3620
+ * ----------------------
3621
+ */
3622
+ typedef struct NotifyStmt
3623
+ {
3624
+ NodeTag type;
3625
+ char *conditionname; /* condition name to notify */
3626
+ char *payload; /* the payload string, or NULL if none */
3627
+ } NotifyStmt;
3628
+
3629
+ /* ----------------------
3630
+ * Listen Statement
3631
+ * ----------------------
3632
+ */
3633
+ typedef struct ListenStmt
3634
+ {
3635
+ NodeTag type;
3636
+ char *conditionname; /* condition name to listen on */
3637
+ } ListenStmt;
3638
+
3639
+ /* ----------------------
3640
+ * Unlisten Statement
3641
+ * ----------------------
3642
+ */
3643
+ typedef struct UnlistenStmt
3644
+ {
3645
+ NodeTag type;
3646
+ char *conditionname; /* name to unlisten on, or NULL for all */
3647
+ } UnlistenStmt;
3648
+
3649
+ /* ----------------------
3650
+ * {Begin|Commit|Rollback} Transaction Statement
3651
+ * ----------------------
3652
+ */
3653
+ typedef enum TransactionStmtKind
3654
+ {
3655
+ TRANS_STMT_BEGIN,
3656
+ TRANS_STMT_START, /* semantically identical to BEGIN */
3657
+ TRANS_STMT_COMMIT,
3658
+ TRANS_STMT_ROLLBACK,
3659
+ TRANS_STMT_SAVEPOINT,
3660
+ TRANS_STMT_RELEASE,
3661
+ TRANS_STMT_ROLLBACK_TO,
3662
+ TRANS_STMT_PREPARE,
3663
+ TRANS_STMT_COMMIT_PREPARED,
3664
+ TRANS_STMT_ROLLBACK_PREPARED,
3665
+ } TransactionStmtKind;
3666
+
3667
+ typedef struct TransactionStmt
3668
+ {
3669
+ NodeTag type;
3670
+ TransactionStmtKind kind; /* see above */
3671
+ List *options; /* for BEGIN/START commands */
3672
+ /* for savepoint commands */
3673
+ char *savepoint_name pg_node_attr(query_jumble_ignore);
3674
+ /* for two-phase-commit related commands */
3675
+ char *gid pg_node_attr(query_jumble_ignore);
3676
+ bool chain; /* AND CHAIN option */
3677
+ /* token location, or -1 if unknown */
3678
+ ParseLoc location pg_node_attr(query_jumble_location);
3679
+ } TransactionStmt;
3680
+
3681
+ /* ----------------------
3682
+ * Create Type Statement, composite types
3683
+ * ----------------------
3684
+ */
3685
+ typedef struct CompositeTypeStmt
3686
+ {
3687
+ NodeTag type;
3688
+ RangeVar *typevar; /* the composite type to be created */
3689
+ List *coldeflist; /* list of ColumnDef nodes */
3690
+ } CompositeTypeStmt;
3691
+
3692
+ /* ----------------------
3693
+ * Create Type Statement, enum types
3694
+ * ----------------------
3695
+ */
3696
+ typedef struct CreateEnumStmt
3697
+ {
3698
+ NodeTag type;
3699
+ List *typeName; /* qualified name (list of String) */
3700
+ List *vals; /* enum values (list of String) */
3701
+ } CreateEnumStmt;
3702
+
3703
+ /* ----------------------
3704
+ * Create Type Statement, range types
3705
+ * ----------------------
3706
+ */
3707
+ typedef struct CreateRangeStmt
3708
+ {
3709
+ NodeTag type;
3710
+ List *typeName; /* qualified name (list of String) */
3711
+ List *params; /* range parameters (list of DefElem) */
3712
+ } CreateRangeStmt;
3713
+
3714
+ /* ----------------------
3715
+ * Alter Type Statement, enum types
3716
+ * ----------------------
3717
+ */
3718
+ typedef struct AlterEnumStmt
3719
+ {
3720
+ NodeTag type;
3721
+ List *typeName; /* qualified name (list of String) */
3722
+ char *oldVal; /* old enum value's name, if renaming */
3723
+ char *newVal; /* new enum value's name */
3724
+ char *newValNeighbor; /* neighboring enum value, if specified */
3725
+ bool newValIsAfter; /* place new enum value after neighbor? */
3726
+ bool skipIfNewValExists; /* no error if new already exists? */
3727
+ } AlterEnumStmt;
3728
+
3729
+ /* ----------------------
3730
+ * Create View Statement
3731
+ * ----------------------
3732
+ */
3733
+ typedef enum ViewCheckOption
3734
+ {
3735
+ NO_CHECK_OPTION,
3736
+ LOCAL_CHECK_OPTION,
3737
+ CASCADED_CHECK_OPTION,
3738
+ } ViewCheckOption;
3739
+
3740
+ typedef struct ViewStmt
3741
+ {
3742
+ NodeTag type;
3743
+ RangeVar *view; /* the view to be created */
3744
+ List *aliases; /* target column names */
3745
+ Node *query; /* the SELECT query (as a raw parse tree) */
3746
+ bool replace; /* replace an existing view? */
3747
+ List *options; /* options from WITH clause */
3748
+ ViewCheckOption withCheckOption; /* WITH CHECK OPTION */
3749
+ } ViewStmt;
3750
+
3751
+ /* ----------------------
3752
+ * Load Statement
3753
+ * ----------------------
3754
+ */
3755
+ typedef struct LoadStmt
3756
+ {
3757
+ NodeTag type;
3758
+ char *filename; /* file to load */
3759
+ } LoadStmt;
3760
+
3761
+ /* ----------------------
3762
+ * Createdb Statement
3763
+ * ----------------------
3764
+ */
3765
+ typedef struct CreatedbStmt
3766
+ {
3767
+ NodeTag type;
3768
+ char *dbname; /* name of database to create */
3769
+ List *options; /* List of DefElem nodes */
3770
+ } CreatedbStmt;
3771
+
3772
+ /* ----------------------
3773
+ * Alter Database
3774
+ * ----------------------
3775
+ */
3776
+ typedef struct AlterDatabaseStmt
3777
+ {
3778
+ NodeTag type;
3779
+ char *dbname; /* name of database to alter */
3780
+ List *options; /* List of DefElem nodes */
3781
+ } AlterDatabaseStmt;
3782
+
3783
+ typedef struct AlterDatabaseRefreshCollStmt
3784
+ {
3785
+ NodeTag type;
3786
+ char *dbname;
3787
+ } AlterDatabaseRefreshCollStmt;
3788
+
3789
+ typedef struct AlterDatabaseSetStmt
3790
+ {
3791
+ NodeTag type;
3792
+ char *dbname; /* database name */
3793
+ VariableSetStmt *setstmt; /* SET or RESET subcommand */
3794
+ } AlterDatabaseSetStmt;
3795
+
3796
+ /* ----------------------
3797
+ * Dropdb Statement
3798
+ * ----------------------
3799
+ */
3800
+ typedef struct DropdbStmt
3801
+ {
3802
+ NodeTag type;
3803
+ char *dbname; /* database to drop */
3804
+ bool missing_ok; /* skip error if db is missing? */
3805
+ List *options; /* currently only FORCE is supported */
3806
+ } DropdbStmt;
3807
+
3808
+ /* ----------------------
3809
+ * Alter System Statement
3810
+ * ----------------------
3811
+ */
3812
+ typedef struct AlterSystemStmt
3813
+ {
3814
+ NodeTag type;
3815
+ VariableSetStmt *setstmt; /* SET subcommand */
3816
+ } AlterSystemStmt;
3817
+
3818
+ /* ----------------------
3819
+ * Cluster Statement (support pbrown's cluster index implementation)
3820
+ * ----------------------
3821
+ */
3822
+ typedef struct ClusterStmt
3823
+ {
3824
+ NodeTag type;
3825
+ RangeVar *relation; /* relation being indexed, or NULL if all */
3826
+ char *indexname; /* original index defined */
3827
+ List *params; /* list of DefElem nodes */
3828
+ } ClusterStmt;
3829
+
3830
+ /* ----------------------
3831
+ * Vacuum and Analyze Statements
3832
+ *
3833
+ * Even though these are nominally two statements, it's convenient to use
3834
+ * just one node type for both.
3835
+ * ----------------------
3836
+ */
3837
+ typedef struct VacuumStmt
3838
+ {
3839
+ NodeTag type;
3840
+ List *options; /* list of DefElem nodes */
3841
+ List *rels; /* list of VacuumRelation, or NIL for all */
3842
+ bool is_vacuumcmd; /* true for VACUUM, false for ANALYZE */
3843
+ } VacuumStmt;
3844
+
3845
+ /*
3846
+ * Info about a single target table of VACUUM/ANALYZE.
3847
+ *
3848
+ * If the OID field is set, it always identifies the table to process.
3849
+ * Then the relation field can be NULL; if it isn't, it's used only to report
3850
+ * failure to open/lock the relation.
3851
+ */
3852
+ typedef struct VacuumRelation
3853
+ {
3854
+ NodeTag type;
3855
+ RangeVar *relation; /* table name to process, or NULL */
3856
+ Oid oid; /* table's OID; InvalidOid if not looked up */
3857
+ List *va_cols; /* list of column names, or NIL for all */
3858
+ } VacuumRelation;
3859
+
3860
+ /* ----------------------
3861
+ * Explain Statement
3862
+ *
3863
+ * The "query" field is initially a raw parse tree, and is converted to a
3864
+ * Query node during parse analysis. Note that rewriting and planning
3865
+ * of the query are always postponed until execution.
3866
+ * ----------------------
3867
+ */
3868
+ typedef struct ExplainStmt
3869
+ {
3870
+ NodeTag type;
3871
+ Node *query; /* the query (see comments above) */
3872
+ List *options; /* list of DefElem nodes */
3873
+ } ExplainStmt;
3874
+
3875
+ /* ----------------------
3876
+ * CREATE TABLE AS Statement (a/k/a SELECT INTO)
3877
+ *
3878
+ * A query written as CREATE TABLE AS will produce this node type natively.
3879
+ * A query written as SELECT ... INTO will be transformed to this form during
3880
+ * parse analysis.
3881
+ * A query written as CREATE MATERIALIZED view will produce this node type,
3882
+ * during parse analysis, since it needs all the same data.
3883
+ *
3884
+ * The "query" field is handled similarly to EXPLAIN, though note that it
3885
+ * can be a SELECT or an EXECUTE, but not other DML statements.
3886
+ * ----------------------
3887
+ */
3888
+ typedef struct CreateTableAsStmt
3889
+ {
3890
+ NodeTag type;
3891
+ Node *query; /* the query (see comments above) */
3892
+ IntoClause *into; /* destination table */
3893
+ ObjectType objtype; /* OBJECT_TABLE or OBJECT_MATVIEW */
3894
+ bool is_select_into; /* it was written as SELECT INTO */
3895
+ bool if_not_exists; /* just do nothing if it already exists? */
3896
+ } CreateTableAsStmt;
3897
+
3898
+ /* ----------------------
3899
+ * REFRESH MATERIALIZED VIEW Statement
3900
+ * ----------------------
3901
+ */
3902
+ typedef struct RefreshMatViewStmt
3903
+ {
3904
+ NodeTag type;
3905
+ bool concurrent; /* allow concurrent access? */
3906
+ bool skipData; /* true for WITH NO DATA */
3907
+ RangeVar *relation; /* relation to insert into */
3908
+ } RefreshMatViewStmt;
3909
+
3910
+ /* ----------------------
3911
+ * Checkpoint Statement
3912
+ * ----------------------
3913
+ */
3914
+ typedef struct CheckPointStmt
3915
+ {
3916
+ NodeTag type;
3917
+ } CheckPointStmt;
3918
+
3919
+ /* ----------------------
3920
+ * Discard Statement
3921
+ * ----------------------
3922
+ */
3923
+
3924
+ typedef enum DiscardMode
3925
+ {
3926
+ DISCARD_ALL,
3927
+ DISCARD_PLANS,
3928
+ DISCARD_SEQUENCES,
3929
+ DISCARD_TEMP,
3930
+ } DiscardMode;
3931
+
3932
+ typedef struct DiscardStmt
3933
+ {
3934
+ NodeTag type;
3935
+ DiscardMode target;
3936
+ } DiscardStmt;
3937
+
3938
+ /* ----------------------
3939
+ * LOCK Statement
3940
+ * ----------------------
3941
+ */
3942
+ typedef struct LockStmt
3943
+ {
3944
+ NodeTag type;
3945
+ List *relations; /* relations to lock */
3946
+ int mode; /* lock mode */
3947
+ bool nowait; /* no wait mode */
3948
+ } LockStmt;
3949
+
3950
+ /* ----------------------
3951
+ * SET CONSTRAINTS Statement
3952
+ * ----------------------
3953
+ */
3954
+ typedef struct ConstraintsSetStmt
3955
+ {
3956
+ NodeTag type;
3957
+ List *constraints; /* List of names as RangeVars */
3958
+ bool deferred;
3959
+ } ConstraintsSetStmt;
3960
+
3961
+ /* ----------------------
3962
+ * REINDEX Statement
3963
+ * ----------------------
3964
+ */
3965
+ typedef enum ReindexObjectType
3966
+ {
3967
+ REINDEX_OBJECT_INDEX, /* index */
3968
+ REINDEX_OBJECT_TABLE, /* table or materialized view */
3969
+ REINDEX_OBJECT_SCHEMA, /* schema */
3970
+ REINDEX_OBJECT_SYSTEM, /* system catalogs */
3971
+ REINDEX_OBJECT_DATABASE, /* database */
3972
+ } ReindexObjectType;
3973
+
3974
+ typedef struct ReindexStmt
3975
+ {
3976
+ NodeTag type;
3977
+ ReindexObjectType kind; /* REINDEX_OBJECT_INDEX, REINDEX_OBJECT_TABLE,
3978
+ * etc. */
3979
+ RangeVar *relation; /* Table or index to reindex */
3980
+ const char *name; /* name of database to reindex */
3981
+ List *params; /* list of DefElem nodes */
3982
+ } ReindexStmt;
3983
+
3984
+ /* ----------------------
3985
+ * CREATE CONVERSION Statement
3986
+ * ----------------------
3987
+ */
3988
+ typedef struct CreateConversionStmt
3989
+ {
3990
+ NodeTag type;
3991
+ List *conversion_name; /* Name of the conversion */
3992
+ char *for_encoding_name; /* source encoding name */
3993
+ char *to_encoding_name; /* destination encoding name */
3994
+ List *func_name; /* qualified conversion function name */
3995
+ bool def; /* is this a default conversion? */
3996
+ } CreateConversionStmt;
3997
+
3998
+ /* ----------------------
3999
+ * CREATE CAST Statement
4000
+ * ----------------------
4001
+ */
4002
+ typedef struct CreateCastStmt
4003
+ {
4004
+ NodeTag type;
4005
+ TypeName *sourcetype;
4006
+ TypeName *targettype;
4007
+ ObjectWithArgs *func;
4008
+ CoercionContext context;
4009
+ bool inout;
4010
+ } CreateCastStmt;
4011
+
4012
+ /* ----------------------
4013
+ * CREATE TRANSFORM Statement
4014
+ * ----------------------
4015
+ */
4016
+ typedef struct CreateTransformStmt
4017
+ {
4018
+ NodeTag type;
4019
+ bool replace;
4020
+ TypeName *type_name;
4021
+ char *lang;
4022
+ ObjectWithArgs *fromsql;
4023
+ ObjectWithArgs *tosql;
4024
+ } CreateTransformStmt;
4025
+
4026
+ /* ----------------------
4027
+ * PREPARE Statement
4028
+ * ----------------------
4029
+ */
4030
+ typedef struct PrepareStmt
4031
+ {
4032
+ NodeTag type;
4033
+ char *name; /* Name of plan, arbitrary */
4034
+ List *argtypes; /* Types of parameters (List of TypeName) */
4035
+ Node *query; /* The query itself (as a raw parsetree) */
4036
+ } PrepareStmt;
4037
+
4038
+
4039
+ /* ----------------------
4040
+ * EXECUTE Statement
4041
+ * ----------------------
4042
+ */
4043
+
4044
+ typedef struct ExecuteStmt
4045
+ {
4046
+ NodeTag type;
4047
+ char *name; /* The name of the plan to execute */
4048
+ List *params; /* Values to assign to parameters */
4049
+ } ExecuteStmt;
4050
+
4051
+
4052
+ /* ----------------------
4053
+ * DEALLOCATE Statement
4054
+ * ----------------------
4055
+ */
4056
+ typedef struct DeallocateStmt
4057
+ {
4058
+ NodeTag type;
4059
+ /* The name of the plan to remove, NULL if DEALLOCATE ALL */
4060
+ char *name pg_node_attr(query_jumble_ignore);
4061
+
4062
+ /*
4063
+ * True if DEALLOCATE ALL. This is redundant with "name == NULL", but we
4064
+ * make it a separate field so that exactly this condition (and not the
4065
+ * precise name) will be accounted for in query jumbling.
4066
+ */
4067
+ bool isall;
4068
+ /* token location, or -1 if unknown */
4069
+ ParseLoc location pg_node_attr(query_jumble_location);
4070
+ } DeallocateStmt;
4071
+
4072
+ /*
4073
+ * DROP OWNED statement
4074
+ */
4075
+ typedef struct DropOwnedStmt
4076
+ {
4077
+ NodeTag type;
4078
+ List *roles;
4079
+ DropBehavior behavior;
4080
+ } DropOwnedStmt;
4081
+
4082
+ /*
4083
+ * REASSIGN OWNED statement
4084
+ */
4085
+ typedef struct ReassignOwnedStmt
4086
+ {
4087
+ NodeTag type;
4088
+ List *roles;
4089
+ RoleSpec *newrole;
4090
+ } ReassignOwnedStmt;
4091
+
4092
+ /*
4093
+ * TS Dictionary stmts: DefineStmt, RenameStmt and DropStmt are default
4094
+ */
4095
+ typedef struct AlterTSDictionaryStmt
4096
+ {
4097
+ NodeTag type;
4098
+ List *dictname; /* qualified name (list of String) */
4099
+ List *options; /* List of DefElem nodes */
4100
+ } AlterTSDictionaryStmt;
4101
+
4102
+ /*
4103
+ * TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default
4104
+ */
4105
+ typedef enum AlterTSConfigType
4106
+ {
4107
+ ALTER_TSCONFIG_ADD_MAPPING,
4108
+ ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN,
4109
+ ALTER_TSCONFIG_REPLACE_DICT,
4110
+ ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN,
4111
+ ALTER_TSCONFIG_DROP_MAPPING,
4112
+ } AlterTSConfigType;
4113
+
4114
+ typedef struct AlterTSConfigurationStmt
4115
+ {
4116
+ NodeTag type;
4117
+ AlterTSConfigType kind; /* ALTER_TSCONFIG_ADD_MAPPING, etc */
4118
+ List *cfgname; /* qualified name (list of String) */
4119
+
4120
+ /*
4121
+ * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
4122
+ * NIL, but tokentype isn't, DROP MAPPING was specified.
4123
+ */
4124
+ List *tokentype; /* list of String */
4125
+ List *dicts; /* list of list of String */
4126
+ bool override; /* if true - remove old variant */
4127
+ bool replace; /* if true - replace dictionary by another */
4128
+ bool missing_ok; /* for DROP - skip error if missing? */
4129
+ } AlterTSConfigurationStmt;
4130
+
4131
+ typedef struct PublicationTable
4132
+ {
4133
+ NodeTag type;
4134
+ RangeVar *relation; /* relation to be published */
4135
+ Node *whereClause; /* qualifications */
4136
+ List *columns; /* List of columns in a publication table */
4137
+ } PublicationTable;
4138
+
4139
+ /*
4140
+ * Publication object type
4141
+ */
4142
+ typedef enum PublicationObjSpecType
4143
+ {
4144
+ PUBLICATIONOBJ_TABLE, /* A table */
4145
+ PUBLICATIONOBJ_TABLES_IN_SCHEMA, /* All tables in schema */
4146
+ PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA, /* All tables in first element of
4147
+ * search_path */
4148
+ PUBLICATIONOBJ_CONTINUATION, /* Continuation of previous type */
4149
+ } PublicationObjSpecType;
4150
+
4151
+ typedef struct PublicationObjSpec
4152
+ {
4153
+ NodeTag type;
4154
+ PublicationObjSpecType pubobjtype; /* type of this publication object */
4155
+ char *name;
4156
+ PublicationTable *pubtable;
4157
+ ParseLoc location; /* token location, or -1 if unknown */
4158
+ } PublicationObjSpec;
4159
+
4160
+ typedef struct CreatePublicationStmt
4161
+ {
4162
+ NodeTag type;
4163
+ char *pubname; /* Name of the publication */
4164
+ List *options; /* List of DefElem nodes */
4165
+ List *pubobjects; /* Optional list of publication objects */
4166
+ bool for_all_tables; /* Special publication for all tables in db */
4167
+ } CreatePublicationStmt;
4168
+
4169
+ typedef enum AlterPublicationAction
4170
+ {
4171
+ AP_AddObjects, /* add objects to publication */
4172
+ AP_DropObjects, /* remove objects from publication */
4173
+ AP_SetObjects, /* set list of objects */
4174
+ } AlterPublicationAction;
4175
+
4176
+ typedef struct AlterPublicationStmt
4177
+ {
4178
+ NodeTag type;
4179
+ char *pubname; /* Name of the publication */
4180
+
4181
+ /* parameters used for ALTER PUBLICATION ... WITH */
4182
+ List *options; /* List of DefElem nodes */
4183
+
4184
+ /*
4185
+ * Parameters used for ALTER PUBLICATION ... ADD/DROP/SET publication
4186
+ * objects.
4187
+ */
4188
+ List *pubobjects; /* Optional list of publication objects */
4189
+ bool for_all_tables; /* Special publication for all tables in db */
4190
+ AlterPublicationAction action; /* What action to perform with the given
4191
+ * objects */
4192
+ } AlterPublicationStmt;
4193
+
4194
+ typedef struct CreateSubscriptionStmt
4195
+ {
4196
+ NodeTag type;
4197
+ char *subname; /* Name of the subscription */
4198
+ char *conninfo; /* Connection string to publisher */
4199
+ List *publication; /* One or more publication to subscribe to */
4200
+ List *options; /* List of DefElem nodes */
4201
+ } CreateSubscriptionStmt;
4202
+
4203
+ typedef enum AlterSubscriptionType
4204
+ {
4205
+ ALTER_SUBSCRIPTION_OPTIONS,
4206
+ ALTER_SUBSCRIPTION_CONNECTION,
4207
+ ALTER_SUBSCRIPTION_SET_PUBLICATION,
4208
+ ALTER_SUBSCRIPTION_ADD_PUBLICATION,
4209
+ ALTER_SUBSCRIPTION_DROP_PUBLICATION,
4210
+ ALTER_SUBSCRIPTION_REFRESH,
4211
+ ALTER_SUBSCRIPTION_ENABLED,
4212
+ ALTER_SUBSCRIPTION_SKIP,
4213
+ } AlterSubscriptionType;
4214
+
4215
+ typedef struct AlterSubscriptionStmt
4216
+ {
4217
+ NodeTag type;
4218
+ AlterSubscriptionType kind; /* ALTER_SUBSCRIPTION_OPTIONS, etc */
4219
+ char *subname; /* Name of the subscription */
4220
+ char *conninfo; /* Connection string to publisher */
4221
+ List *publication; /* One or more publication to subscribe to */
4222
+ List *options; /* List of DefElem nodes */
4223
+ } AlterSubscriptionStmt;
4224
+
4225
+ typedef struct DropSubscriptionStmt
4226
+ {
4227
+ NodeTag type;
4228
+ char *subname; /* Name of the subscription */
4229
+ bool missing_ok; /* Skip error if missing? */
4230
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
4231
+ } DropSubscriptionStmt;
4232
+
4233
+ #endif /* PARSENODES_H */