pg_query 2.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (467) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +59 -31
  4. data/Rakefile +2 -2
  5. data/ext/pg_query/include/access/amapi.h +45 -1
  6. data/ext/pg_query/include/access/attmap.h +1 -1
  7. data/ext/pg_query/include/access/attnum.h +2 -2
  8. data/ext/pg_query/include/access/clog.h +4 -2
  9. data/ext/pg_query/include/access/commit_ts.h +6 -9
  10. data/ext/pg_query/include/access/detoast.h +1 -11
  11. data/ext/pg_query/include/access/genam.h +15 -12
  12. data/ext/pg_query/include/access/gin.h +2 -2
  13. data/ext/pg_query/include/access/htup.h +1 -1
  14. data/ext/pg_query/include/access/htup_details.h +75 -87
  15. data/ext/pg_query/include/access/itup.h +7 -1
  16. data/ext/pg_query/include/access/parallel.h +2 -2
  17. data/ext/pg_query/include/access/printtup.h +1 -1
  18. data/ext/pg_query/include/access/relation.h +1 -1
  19. data/ext/pg_query/include/access/relscan.h +17 -2
  20. data/ext/pg_query/include/access/rmgr.h +30 -3
  21. data/ext/pg_query/include/access/rmgrlist.h +23 -23
  22. data/ext/pg_query/include/access/sdir.h +1 -1
  23. data/ext/pg_query/include/access/skey.h +1 -1
  24. data/ext/pg_query/include/access/stratnum.h +4 -2
  25. data/ext/pg_query/include/access/sysattr.h +1 -1
  26. data/ext/pg_query/include/access/table.h +2 -1
  27. data/ext/pg_query/include/access/tableam.h +272 -20
  28. data/ext/pg_query/include/access/toast_compression.h +73 -0
  29. data/ext/pg_query/include/access/transam.h +123 -13
  30. data/ext/pg_query/include/access/tupconvert.h +1 -1
  31. data/ext/pg_query/include/access/tupdesc.h +1 -1
  32. data/ext/pg_query/include/access/tupmacs.h +3 -3
  33. data/ext/pg_query/include/access/twophase.h +3 -1
  34. data/ext/pg_query/include/access/xact.h +73 -19
  35. data/ext/pg_query/include/access/xlog.h +60 -155
  36. data/ext/pg_query/include/access/xlog_internal.h +40 -13
  37. data/ext/pg_query/include/access/xlogdefs.h +8 -16
  38. data/ext/pg_query/include/access/xlogprefetcher.h +55 -0
  39. data/ext/pg_query/include/access/xlogreader.h +145 -39
  40. data/ext/pg_query/include/access/xlogrecord.h +18 -9
  41. data/ext/pg_query/include/access/xlogrecovery.h +157 -0
  42. data/ext/pg_query/include/c.h +101 -44
  43. data/ext/pg_query/include/catalog/catalog.h +3 -1
  44. data/ext/pg_query/include/catalog/catversion.h +2 -2
  45. data/ext/pg_query/include/catalog/dependency.h +8 -16
  46. data/ext/pg_query/include/catalog/genbki.h +83 -5
  47. data/ext/pg_query/include/catalog/index.h +18 -3
  48. data/ext/pg_query/include/catalog/indexing.h +12 -324
  49. data/ext/pg_query/include/catalog/namespace.h +4 -2
  50. data/ext/pg_query/include/catalog/objectaccess.h +70 -2
  51. data/ext/pg_query/include/catalog/objectaddress.h +11 -6
  52. data/ext/pg_query/include/catalog/pg_aggregate.h +14 -10
  53. data/ext/pg_query/include/catalog/pg_aggregate_d.h +2 -1
  54. data/ext/pg_query/include/catalog/pg_am.h +4 -1
  55. data/ext/pg_query/include/catalog/pg_am_d.h +3 -1
  56. data/ext/pg_query/include/catalog/pg_attribute.h +27 -10
  57. data/ext/pg_query/include/catalog/pg_attribute_d.h +21 -18
  58. data/ext/pg_query/include/catalog/pg_authid.h +7 -2
  59. data/ext/pg_query/include/catalog/pg_authid_d.h +17 -9
  60. data/ext/pg_query/include/catalog/pg_class.h +44 -14
  61. data/ext/pg_query/include/catalog/pg_class_d.h +30 -1
  62. data/ext/pg_query/include/catalog/pg_collation.h +33 -8
  63. data/ext/pg_query/include/catalog/pg_collation_d.h +20 -3
  64. data/ext/pg_query/include/catalog/pg_constraint.h +38 -12
  65. data/ext/pg_query/include/catalog/pg_constraint_d.h +10 -4
  66. data/ext/pg_query/include/catalog/pg_control.h +3 -5
  67. data/ext/pg_query/include/catalog/pg_conversion.h +7 -4
  68. data/ext/pg_query/include/catalog/pg_conversion_d.h +4 -1
  69. data/ext/pg_query/include/catalog/pg_depend.h +11 -7
  70. data/ext/pg_query/include/catalog/pg_depend_d.h +3 -1
  71. data/ext/pg_query/include/catalog/pg_event_trigger.h +9 -3
  72. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +3 -1
  73. data/ext/pg_query/include/catalog/pg_index.h +17 -7
  74. data/ext/pg_query/include/catalog/pg_index_d.h +20 -17
  75. data/ext/pg_query/include/catalog/pg_language.h +10 -5
  76. data/ext/pg_query/include/catalog/pg_language_d.h +3 -1
  77. data/ext/pg_query/include/catalog/pg_namespace.h +7 -2
  78. data/ext/pg_query/include/catalog/pg_namespace_d.h +3 -1
  79. data/ext/pg_query/include/catalog/pg_opclass.h +8 -5
  80. data/ext/pg_query/include/catalog/pg_opclass_d.h +3 -1
  81. data/ext/pg_query/include/catalog/pg_operator.h +18 -15
  82. data/ext/pg_query/include/catalog/pg_operator_d.h +37 -1
  83. data/ext/pg_query/include/catalog/pg_opfamily.h +6 -3
  84. data/ext/pg_query/include/catalog/pg_opfamily_d.h +3 -1
  85. data/ext/pg_query/include/catalog/pg_parameter_acl.h +60 -0
  86. data/ext/pg_query/include/catalog/pg_parameter_acl_d.h +34 -0
  87. data/ext/pg_query/include/catalog/pg_partitioned_table.h +20 -9
  88. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +2 -1
  89. data/ext/pg_query/include/catalog/pg_proc.h +20 -11
  90. data/ext/pg_query/include/catalog/pg_proc_d.h +10 -8
  91. data/ext/pg_query/include/catalog/pg_publication.h +50 -7
  92. data/ext/pg_query/include/catalog/pg_publication_d.h +3 -1
  93. data/ext/pg_query/include/catalog/pg_replication_origin.h +6 -1
  94. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +5 -1
  95. data/ext/pg_query/include/catalog/pg_statistic.h +19 -12
  96. data/ext/pg_query/include/catalog/pg_statistic_d.h +2 -1
  97. data/ext/pg_query/include/catalog/pg_statistic_ext.h +19 -5
  98. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +7 -2
  99. data/ext/pg_query/include/catalog/pg_transform.h +8 -5
  100. data/ext/pg_query/include/catalog/pg_transform_d.h +3 -1
  101. data/ext/pg_query/include/catalog/pg_trigger.h +24 -8
  102. data/ext/pg_query/include/catalog/pg_trigger_d.h +4 -1
  103. data/ext/pg_query/include/catalog/pg_ts_config.h +6 -3
  104. data/ext/pg_query/include/catalog/pg_ts_config_d.h +3 -1
  105. data/ext/pg_query/include/catalog/pg_ts_dict.h +8 -3
  106. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +3 -1
  107. data/ext/pg_query/include/catalog/pg_ts_parser.h +6 -3
  108. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +3 -1
  109. data/ext/pg_query/include/catalog/pg_ts_template.h +6 -3
  110. data/ext/pg_query/include/catalog/pg_ts_template_d.h +3 -1
  111. data/ext/pg_query/include/catalog/pg_type.h +55 -24
  112. data/ext/pg_query/include/catalog/pg_type_d.h +70 -31
  113. data/ext/pg_query/include/catalog/storage.h +5 -3
  114. data/ext/pg_query/include/commands/async.h +3 -4
  115. data/ext/pg_query/include/commands/dbcommands.h +2 -1
  116. data/ext/pg_query/include/commands/defrem.h +11 -24
  117. data/ext/pg_query/include/commands/event_trigger.h +2 -2
  118. data/ext/pg_query/include/commands/explain.h +1 -1
  119. data/ext/pg_query/include/commands/prepare.h +1 -1
  120. data/ext/pg_query/include/commands/tablespace.h +2 -2
  121. data/ext/pg_query/include/commands/trigger.h +18 -16
  122. data/ext/pg_query/include/commands/user.h +2 -2
  123. data/ext/pg_query/include/commands/vacuum.h +88 -41
  124. data/ext/pg_query/include/commands/variable.h +1 -1
  125. data/ext/pg_query/include/common/file_perm.h +4 -4
  126. data/ext/pg_query/include/common/hashfn.h +1 -1
  127. data/ext/pg_query/include/common/ip.h +1 -7
  128. data/ext/pg_query/include/common/keywords.h +2 -6
  129. data/ext/pg_query/include/common/kwlookup.h +1 -1
  130. data/ext/pg_query/include/common/pg_prng.h +60 -0
  131. data/ext/pg_query/include/common/relpath.h +2 -2
  132. data/ext/pg_query/include/common/string.h +24 -1
  133. data/ext/pg_query/include/common/unicode_combining_table.h +114 -2
  134. data/ext/pg_query/include/common/unicode_east_asian_fw_table.h +125 -0
  135. data/ext/pg_query/include/datatype/timestamp.h +40 -1
  136. data/ext/pg_query/include/executor/execdesc.h +1 -1
  137. data/ext/pg_query/include/executor/executor.h +65 -22
  138. data/ext/pg_query/include/executor/functions.h +17 -3
  139. data/ext/pg_query/include/executor/instrument.h +33 -16
  140. data/ext/pg_query/include/executor/spi.h +41 -3
  141. data/ext/pg_query/include/executor/tablefunc.h +1 -1
  142. data/ext/pg_query/include/executor/tuptable.h +1 -1
  143. data/ext/pg_query/include/fmgr.h +13 -7
  144. data/ext/pg_query/include/funcapi.h +16 -4
  145. data/ext/pg_query/include/getaddrinfo.h +1 -1
  146. data/ext/pg_query/include/jit/jit.h +11 -11
  147. data/ext/pg_query/include/kwlist_d.h +517 -494
  148. data/ext/pg_query/include/lib/dshash.h +112 -0
  149. data/ext/pg_query/include/lib/ilist.h +20 -1
  150. data/ext/pg_query/include/lib/pairingheap.h +1 -1
  151. data/ext/pg_query/include/lib/simplehash.h +140 -15
  152. data/ext/pg_query/include/lib/sort_template.h +432 -0
  153. data/ext/pg_query/include/lib/stringinfo.h +1 -1
  154. data/ext/pg_query/include/libpq/auth.h +6 -4
  155. data/ext/pg_query/include/libpq/crypt.h +5 -4
  156. data/ext/pg_query/include/libpq/hba.h +43 -4
  157. data/ext/pg_query/include/libpq/libpq-be.h +23 -6
  158. data/ext/pg_query/include/libpq/libpq.h +30 -20
  159. data/ext/pg_query/include/libpq/pqcomm.h +17 -31
  160. data/ext/pg_query/include/libpq/pqformat.h +1 -1
  161. data/ext/pg_query/include/libpq/pqsignal.h +4 -4
  162. data/ext/pg_query/include/mb/pg_wchar.h +105 -23
  163. data/ext/pg_query/include/mb/stringinfo_mb.h +1 -1
  164. data/ext/pg_query/include/miscadmin.h +47 -41
  165. data/ext/pg_query/include/nodes/bitmapset.h +1 -1
  166. data/ext/pg_query/include/nodes/execnodes.h +270 -78
  167. data/ext/pg_query/include/nodes/extensible.h +4 -2
  168. data/ext/pg_query/include/nodes/lockoptions.h +1 -1
  169. data/ext/pg_query/include/nodes/makefuncs.h +7 -6
  170. data/ext/pg_query/include/nodes/memnodes.h +5 -3
  171. data/ext/pg_query/include/nodes/nodeFuncs.h +1 -1
  172. data/ext/pg_query/include/nodes/nodes.h +30 -11
  173. data/ext/pg_query/include/nodes/params.h +1 -1
  174. data/ext/pg_query/include/nodes/parsenodes.h +322 -90
  175. data/ext/pg_query/include/nodes/pathnodes.h +243 -66
  176. data/ext/pg_query/include/nodes/pg_list.h +75 -69
  177. data/ext/pg_query/include/nodes/plannodes.h +111 -28
  178. data/ext/pg_query/include/nodes/primnodes.h +99 -47
  179. data/ext/pg_query/include/nodes/print.h +1 -1
  180. data/ext/pg_query/include/nodes/tidbitmap.h +1 -1
  181. data/ext/pg_query/include/nodes/value.h +58 -39
  182. data/ext/pg_query/include/optimizer/cost.h +9 -2
  183. data/ext/pg_query/include/optimizer/geqo.h +9 -7
  184. data/ext/pg_query/include/optimizer/geqo_gene.h +1 -1
  185. data/ext/pg_query/include/optimizer/optimizer.h +25 -17
  186. data/ext/pg_query/include/optimizer/paths.h +6 -6
  187. data/ext/pg_query/include/optimizer/planmain.h +15 -14
  188. data/ext/pg_query/include/parser/analyze.h +19 -5
  189. data/ext/pg_query/include/parser/gram.h +947 -913
  190. data/ext/pg_query/include/parser/gramparse.h +1 -1
  191. data/ext/pg_query/include/parser/kwlist.h +463 -453
  192. data/ext/pg_query/include/parser/parse_agg.h +2 -7
  193. data/ext/pg_query/include/parser/parse_coerce.h +3 -1
  194. data/ext/pg_query/include/parser/parse_expr.h +2 -3
  195. data/ext/pg_query/include/parser/parse_func.h +2 -1
  196. data/ext/pg_query/include/parser/parse_node.h +21 -9
  197. data/ext/pg_query/include/parser/parse_oper.h +1 -3
  198. data/ext/pg_query/include/parser/parse_relation.h +5 -4
  199. data/ext/pg_query/include/parser/parse_type.h +1 -1
  200. data/ext/pg_query/include/parser/parser.h +31 -4
  201. data/ext/pg_query/include/parser/parsetree.h +1 -1
  202. data/ext/pg_query/include/parser/scanner.h +1 -1
  203. data/ext/pg_query/include/parser/scansup.h +2 -5
  204. data/ext/pg_query/include/partitioning/partdefs.h +1 -1
  205. data/ext/pg_query/include/pg_config.h +83 -41
  206. data/ext/pg_query/include/pg_config_manual.h +74 -21
  207. data/ext/pg_query/include/pg_getopt.h +6 -6
  208. data/ext/pg_query/include/pg_query.h +5 -4
  209. data/ext/pg_query/include/pg_query_enum_defs.c +358 -241
  210. data/ext/pg_query/include/pg_query_fingerprint_conds.c +44 -7
  211. data/ext/pg_query/include/pg_query_fingerprint_defs.c +939 -113
  212. data/ext/pg_query/include/pg_query_outfuncs_conds.c +43 -13
  213. data/ext/pg_query/include/pg_query_outfuncs_defs.c +151 -26
  214. data/ext/pg_query/include/pg_query_readfuncs_conds.c +11 -2
  215. data/ext/pg_query/include/pg_query_readfuncs_defs.c +173 -30
  216. data/ext/pg_query/include/pg_trace.h +1 -1
  217. data/ext/pg_query/include/pgstat.h +449 -1238
  218. data/ext/pg_query/include/pgtime.h +14 -4
  219. data/ext/pg_query/include/pl_gram.h +126 -128
  220. data/ext/pg_query/include/pl_reserved_kwlist.h +1 -1
  221. data/ext/pg_query/include/pl_reserved_kwlist_d.h +10 -10
  222. data/ext/pg_query/include/pl_unreserved_kwlist.h +2 -3
  223. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +54 -56
  224. data/ext/pg_query/include/plerrcodes.h +9 -1
  225. data/ext/pg_query/include/plpgsql.h +52 -54
  226. data/ext/pg_query/include/port/atomics/arch-arm.h +7 -1
  227. data/ext/pg_query/include/port/atomics/arch-ppc.h +1 -1
  228. data/ext/pg_query/include/port/atomics/arch-x86.h +1 -1
  229. data/ext/pg_query/include/port/atomics/fallback.h +1 -1
  230. data/ext/pg_query/include/port/atomics/generic-gcc.h +3 -3
  231. data/ext/pg_query/include/port/atomics/generic.h +1 -1
  232. data/ext/pg_query/include/port/atomics.h +1 -1
  233. data/ext/pg_query/include/port/pg_bitutils.h +40 -10
  234. data/ext/pg_query/include/port/pg_bswap.h +1 -1
  235. data/ext/pg_query/include/port/pg_crc32c.h +1 -1
  236. data/ext/pg_query/include/port.h +71 -46
  237. data/ext/pg_query/include/portability/instr_time.h +1 -1
  238. data/ext/pg_query/include/postgres.h +60 -16
  239. data/ext/pg_query/include/postmaster/autovacuum.h +17 -17
  240. data/ext/pg_query/include/postmaster/auxprocess.h +20 -0
  241. data/ext/pg_query/include/postmaster/bgworker.h +2 -1
  242. data/ext/pg_query/include/postmaster/bgworker_internals.h +2 -2
  243. data/ext/pg_query/include/postmaster/bgwriter.h +5 -5
  244. data/ext/pg_query/include/postmaster/fork_process.h +1 -1
  245. data/ext/pg_query/include/postmaster/interrupt.h +1 -1
  246. data/ext/pg_query/include/postmaster/pgarch.h +42 -8
  247. data/ext/pg_query/include/postmaster/postmaster.h +18 -17
  248. data/ext/pg_query/include/postmaster/startup.h +39 -0
  249. data/ext/pg_query/include/postmaster/syslogger.h +15 -10
  250. data/ext/pg_query/include/postmaster/walwriter.h +3 -3
  251. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1419 -914
  252. data/ext/pg_query/include/protobuf/pg_query.pb.h +43678 -32769
  253. data/ext/pg_query/include/regex/regex.h +18 -16
  254. data/ext/pg_query/include/replication/logicallauncher.h +3 -5
  255. data/ext/pg_query/include/replication/logicalproto.h +161 -17
  256. data/ext/pg_query/include/replication/logicalworker.h +1 -1
  257. data/ext/pg_query/include/replication/origin.h +7 -7
  258. data/ext/pg_query/include/replication/reorderbuffer.h +259 -42
  259. data/ext/pg_query/include/replication/slot.h +22 -11
  260. data/ext/pg_query/include/replication/syncrep.h +5 -5
  261. data/ext/pg_query/include/replication/walreceiver.h +145 -13
  262. data/ext/pg_query/include/replication/walsender.h +8 -8
  263. data/ext/pg_query/include/rewrite/prs2lock.h +1 -1
  264. data/ext/pg_query/include/rewrite/rewriteHandler.h +1 -3
  265. data/ext/pg_query/include/rewrite/rewriteManip.h +1 -1
  266. data/ext/pg_query/include/rewrite/rewriteSupport.h +1 -1
  267. data/ext/pg_query/include/storage/backendid.h +3 -3
  268. data/ext/pg_query/include/storage/block.h +4 -10
  269. data/ext/pg_query/include/storage/buf.h +1 -1
  270. data/ext/pg_query/include/storage/bufmgr.h +19 -14
  271. data/ext/pg_query/include/storage/bufpage.h +6 -8
  272. data/ext/pg_query/include/storage/condition_variable.h +13 -2
  273. data/ext/pg_query/include/storage/dsm.h +4 -1
  274. data/ext/pg_query/include/storage/dsm_impl.h +3 -2
  275. data/ext/pg_query/include/storage/fd.h +33 -3
  276. data/ext/pg_query/include/storage/fileset.h +40 -0
  277. data/ext/pg_query/include/storage/ipc.h +4 -1
  278. data/ext/pg_query/include/storage/item.h +1 -1
  279. data/ext/pg_query/include/storage/itemid.h +1 -1
  280. data/ext/pg_query/include/storage/itemptr.h +3 -1
  281. data/ext/pg_query/include/storage/large_object.h +2 -2
  282. data/ext/pg_query/include/storage/latch.h +9 -13
  283. data/ext/pg_query/include/storage/lmgr.h +2 -1
  284. data/ext/pg_query/include/storage/lock.h +11 -8
  285. data/ext/pg_query/include/storage/lockdefs.h +2 -2
  286. data/ext/pg_query/include/storage/lwlock.h +5 -32
  287. data/ext/pg_query/include/storage/lwlocknames.h +0 -1
  288. data/ext/pg_query/include/storage/off.h +1 -1
  289. data/ext/pg_query/include/storage/pg_sema.h +1 -1
  290. data/ext/pg_query/include/storage/pg_shmem.h +9 -7
  291. data/ext/pg_query/include/storage/pmsignal.h +15 -4
  292. data/ext/pg_query/include/storage/predicate.h +4 -4
  293. data/ext/pg_query/include/storage/proc.h +173 -59
  294. data/ext/pg_query/include/storage/procarray.h +98 -0
  295. data/ext/pg_query/include/storage/proclist_types.h +1 -1
  296. data/ext/pg_query/include/storage/procsignal.h +3 -7
  297. data/ext/pg_query/include/storage/relfilenode.h +1 -1
  298. data/ext/pg_query/include/storage/s_lock.h +60 -21
  299. data/ext/pg_query/include/storage/sharedfileset.h +3 -11
  300. data/ext/pg_query/include/storage/shm_mq.h +5 -4
  301. data/ext/pg_query/include/storage/shm_toc.h +1 -1
  302. data/ext/pg_query/include/storage/shmem.h +1 -1
  303. data/ext/pg_query/include/storage/sinval.h +3 -3
  304. data/ext/pg_query/include/storage/sinvaladt.h +1 -1
  305. data/ext/pg_query/include/storage/smgr.h +10 -8
  306. data/ext/pg_query/include/storage/spin.h +2 -2
  307. data/ext/pg_query/include/storage/standby.h +13 -6
  308. data/ext/pg_query/include/storage/standbydefs.h +2 -2
  309. data/ext/pg_query/include/storage/sync.h +7 -3
  310. data/ext/pg_query/include/tcop/cmdtag.h +1 -1
  311. data/ext/pg_query/include/tcop/cmdtaglist.h +3 -2
  312. data/ext/pg_query/include/tcop/deparse_utility.h +1 -1
  313. data/ext/pg_query/include/tcop/dest.h +1 -1
  314. data/ext/pg_query/include/tcop/fastpath.h +1 -2
  315. data/ext/pg_query/include/tcop/pquery.h +1 -1
  316. data/ext/pg_query/include/tcop/tcopprot.h +19 -11
  317. data/ext/pg_query/include/tcop/utility.h +7 -3
  318. data/ext/pg_query/include/tsearch/ts_cache.h +2 -2
  319. data/ext/pg_query/include/utils/acl.h +24 -3
  320. data/ext/pg_query/include/utils/aclchk_internal.h +1 -1
  321. data/ext/pg_query/include/utils/array.h +7 -2
  322. data/ext/pg_query/include/utils/backend_progress.h +44 -0
  323. data/ext/pg_query/include/utils/backend_status.h +321 -0
  324. data/ext/pg_query/include/utils/builtins.h +10 -11
  325. data/ext/pg_query/include/utils/bytea.h +3 -2
  326. data/ext/pg_query/include/utils/catcache.h +1 -1
  327. data/ext/pg_query/include/utils/date.h +1 -1
  328. data/ext/pg_query/include/utils/datetime.h +8 -7
  329. data/ext/pg_query/include/utils/datum.h +9 -1
  330. data/ext/pg_query/include/utils/dsa.h +1 -1
  331. data/ext/pg_query/include/utils/dynahash.h +4 -3
  332. data/ext/pg_query/include/utils/elog.h +52 -21
  333. data/ext/pg_query/include/utils/errcodes.h +2 -0
  334. data/ext/pg_query/include/utils/expandeddatum.h +1 -1
  335. data/ext/pg_query/include/utils/expandedrecord.h +1 -1
  336. data/ext/pg_query/include/utils/float.h +7 -7
  337. data/ext/pg_query/include/utils/fmgroids.h +1300 -696
  338. data/ext/pg_query/include/utils/fmgrprotos.h +199 -16
  339. data/ext/pg_query/include/utils/fmgrtab.h +6 -5
  340. data/ext/pg_query/include/utils/guc.h +69 -43
  341. data/ext/pg_query/include/utils/guc_tables.h +23 -19
  342. data/ext/pg_query/include/utils/hsearch.h +15 -11
  343. data/ext/pg_query/include/utils/inval.h +4 -1
  344. data/ext/pg_query/include/utils/lsyscache.h +11 -1
  345. data/ext/pg_query/include/utils/memdebug.h +1 -1
  346. data/ext/pg_query/include/utils/memutils.h +8 -3
  347. data/ext/pg_query/include/utils/numeric.h +19 -5
  348. data/ext/pg_query/include/utils/palloc.h +25 -3
  349. data/ext/pg_query/include/utils/partcache.h +1 -1
  350. data/ext/pg_query/include/utils/pg_locale.h +17 -9
  351. data/ext/pg_query/include/utils/pg_lsn.h +1 -1
  352. data/ext/pg_query/include/utils/pgstat_internal.h +784 -0
  353. data/ext/pg_query/include/utils/pidfile.h +1 -1
  354. data/ext/pg_query/include/utils/plancache.h +6 -5
  355. data/ext/pg_query/include/utils/portal.h +10 -12
  356. data/ext/pg_query/include/utils/ps_status.h +1 -1
  357. data/ext/pg_query/include/utils/queryenvironment.h +1 -1
  358. data/ext/pg_query/include/utils/queryjumble.h +88 -0
  359. data/ext/pg_query/include/utils/regproc.h +14 -3
  360. data/ext/pg_query/include/utils/rel.h +71 -19
  361. data/ext/pg_query/include/utils/relcache.h +8 -5
  362. data/ext/pg_query/include/utils/reltrigger.h +1 -1
  363. data/ext/pg_query/include/utils/resowner.h +1 -1
  364. data/ext/pg_query/include/utils/rls.h +2 -2
  365. data/ext/pg_query/include/utils/ruleutils.h +4 -1
  366. data/ext/pg_query/include/utils/sharedtuplestore.h +1 -1
  367. data/ext/pg_query/include/utils/snapmgr.h +34 -14
  368. data/ext/pg_query/include/utils/snapshot.h +14 -1
  369. data/ext/pg_query/include/utils/sortsupport.h +117 -2
  370. data/ext/pg_query/include/utils/syscache.h +6 -1
  371. data/ext/pg_query/include/utils/timeout.h +11 -4
  372. data/ext/pg_query/include/utils/timestamp.h +6 -5
  373. data/ext/pg_query/include/utils/tuplesort.h +25 -11
  374. data/ext/pg_query/include/utils/tuplestore.h +2 -2
  375. data/ext/pg_query/include/utils/typcache.h +24 -17
  376. data/ext/pg_query/include/utils/tzparser.h +1 -1
  377. data/ext/pg_query/include/utils/varlena.h +5 -3
  378. data/ext/pg_query/include/utils/wait_event.h +289 -0
  379. data/ext/pg_query/include/utils/xml.h +4 -4
  380. data/ext/pg_query/pg_query.pb-c.c +4302 -2304
  381. data/ext/pg_query/pg_query_deparse.c +1106 -373
  382. data/ext/pg_query/pg_query_fingerprint.c +30 -10
  383. data/ext/pg_query/pg_query_json_plpgsql.c +0 -25
  384. data/ext/pg_query/pg_query_normalize.c +1 -1
  385. data/ext/pg_query/pg_query_outfuncs_json.c +54 -16
  386. data/ext/pg_query/pg_query_outfuncs_protobuf.c +70 -10
  387. data/ext/pg_query/pg_query_parse.c +1 -1
  388. data/ext/pg_query/pg_query_readfuncs_protobuf.c +42 -8
  389. data/ext/pg_query/pg_query_scan.c +2 -1
  390. data/ext/pg_query/pg_query_split.c +3 -2
  391. data/ext/pg_query/src_backend_catalog_namespace.c +20 -9
  392. data/ext/pg_query/src_backend_catalog_pg_proc.c +4 -1
  393. data/ext/pg_query/src_backend_commands_define.c +11 -1
  394. data/ext/pg_query/src_backend_nodes_bitmapset.c +3 -1
  395. data/ext/pg_query/src_backend_nodes_copyfuncs.c +401 -76
  396. data/ext/pg_query/src_backend_nodes_equalfuncs.c +290 -46
  397. data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
  398. data/ext/pg_query/src_backend_nodes_list.c +74 -11
  399. data/ext/pg_query/src_backend_nodes_makefuncs.c +5 -4
  400. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +55 -12
  401. data/ext/pg_query/src_backend_nodes_value.c +28 -19
  402. data/ext/pg_query/src_backend_parser_gram.c +33874 -31261
  403. data/ext/pg_query/src_backend_parser_parser.c +26 -7
  404. data/ext/pg_query/src_backend_parser_scan.c +172 -209
  405. data/ext/pg_query/src_backend_parser_scansup.c +4 -28
  406. data/ext/pg_query/src_backend_postmaster_postmaster.c +77 -106
  407. data/ext/pg_query/src_backend_storage_ipc_ipc.c +13 -4
  408. data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +5 -4
  409. data/ext/pg_query/src_backend_tcop_postgres.c +62 -23
  410. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +140 -0
  411. data/ext/pg_query/src_backend_utils_adt_datum.c +13 -1
  412. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  413. data/ext/pg_query/src_backend_utils_adt_format_type.c +6 -2
  414. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +71 -5
  415. data/ext/pg_query/src_backend_utils_error_assert.c +16 -14
  416. data/ext/pg_query/src_backend_utils_error_elog.c +172 -99
  417. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +12 -17
  418. data/ext/pg_query/src_backend_utils_hash_dynahash.c +40 -10
  419. data/ext/pg_query/src_backend_utils_init_globals.c +5 -5
  420. data/ext/pg_query/src_backend_utils_mb_mbutils.c +55 -66
  421. data/ext/pg_query/src_backend_utils_misc_guc.c +206 -45
  422. data/ext/pg_query/src_backend_utils_mmgr_aset.c +7 -5
  423. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +123 -35
  424. data/ext/pg_query/src_common_encnames.c +1 -1
  425. data/ext/pg_query/src_common_hashfn.c +3 -3
  426. data/ext/pg_query/src_common_keywords.c +15 -2
  427. data/ext/pg_query/src_common_kwlist_d.h +517 -494
  428. data/ext/pg_query/src_common_kwlookup.c +1 -1
  429. data/ext/pg_query/src_common_pg_prng.c +152 -0
  430. data/ext/pg_query/src_common_psprintf.c +1 -1
  431. data/ext/pg_query/src_common_string.c +7 -1
  432. data/ext/pg_query/src_common_stringinfo.c +1 -1
  433. data/ext/pg_query/src_common_wchar.c +701 -109
  434. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +45 -20
  435. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -18
  436. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +1233 -1259
  437. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  438. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +10 -10
  439. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +2 -2
  440. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +54 -56
  441. data/ext/pg_query/src_port_pg_bitutils.c +41 -31
  442. data/ext/pg_query/src_port_pgsleep.c +1 -1
  443. data/ext/pg_query/src_port_pgstrcasecmp.c +1 -1
  444. data/ext/pg_query/src_port_qsort.c +12 -224
  445. data/ext/pg_query/src_port_snprintf.c +37 -13
  446. data/ext/pg_query/src_port_strerror.c +9 -19
  447. data/ext/pg_query/src_port_strnlen.c +1 -1
  448. data/lib/pg_query/filter_columns.rb +1 -1
  449. data/lib/pg_query/fingerprint.rb +5 -1
  450. data/lib/pg_query/node.rb +2 -2
  451. data/lib/pg_query/param_refs.rb +1 -1
  452. data/lib/pg_query/parse.rb +20 -8
  453. data/lib/pg_query/pg_query_pb.rb +1108 -942
  454. data/lib/pg_query/treewalker.rb +6 -0
  455. data/lib/pg_query/truncate.rb +1 -1
  456. data/lib/pg_query/version.rb +1 -1
  457. metadata +27 -17
  458. data/ext/pg_query/include/access/xloginsert.h +0 -64
  459. data/ext/pg_query/include/bootstrap/bootstrap.h +0 -62
  460. data/ext/pg_query/include/parser/parse_clause.h +0 -54
  461. data/ext/pg_query/include/parser/parse_collate.h +0 -27
  462. data/ext/pg_query/include/parser/parse_target.h +0 -46
  463. data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -2
  464. data/ext/pg_query/src_backend_libpq_pqcomm.c +0 -659
  465. data/ext/pg_query/src_backend_parser_parse_expr.c +0 -313
  466. data/ext/pg_query/src_port_erand48.c +0 -127
  467. data/ext/pg_query/src_port_random.c +0 -31
@@ -93,34 +93,48 @@ _fingerprintString(FingerprintContext *ctx, const char *str)
93
93
  }
94
94
 
95
95
  static void
96
- _fingerprintInteger(FingerprintContext *ctx, const Value *node)
96
+ _fingerprintInteger(FingerprintContext *ctx, const union ValUnion *value)
97
97
  {
98
- if (node->val.ival != 0) {
98
+ if (value->ival.ival != 0) {
99
99
  _fingerprintString(ctx, "Integer");
100
100
  _fingerprintString(ctx, "ival");
101
101
  char buffer[50];
102
- sprintf(buffer, "%d", node->val.ival);
102
+ sprintf(buffer, "%d", value->ival.ival);
103
103
  _fingerprintString(ctx, buffer);
104
104
  }
105
105
  }
106
106
 
107
107
  static void
108
- _fingerprintFloat(FingerprintContext *ctx, const Value *node)
108
+ _fingerprintFloat(FingerprintContext *ctx, const union ValUnion *value)
109
109
  {
110
- if (node->val.str != NULL) {
110
+ if (value->fval.fval != NULL) {
111
+ // NB: We output `str` here intentionally, to match the output format from libpg_query 14
112
+ // and below. This results in stable fingerprints, despite the field name being changed in
113
+ // PG15 to `fval`.
111
114
  _fingerprintString(ctx, "Float");
112
115
  _fingerprintString(ctx, "str");
113
- _fingerprintString(ctx, node->val.str);
116
+ _fingerprintString(ctx, value->fval.fval);
114
117
  }
115
118
  }
116
119
 
117
120
  static void
118
- _fingerprintBitString(FingerprintContext *ctx, const Value *node)
121
+ _fingerprintBoolean(FingerprintContext *ctx, const union ValUnion *value)
119
122
  {
120
- if (node->val.str != NULL) {
123
+ _fingerprintString(ctx, "Boolean");
124
+ _fingerprintString(ctx, "boolval");
125
+ _fingerprintString(ctx, value->boolval.boolval ? "true" : "false");
126
+ }
127
+
128
+ static void
129
+ _fingerprintBitString(FingerprintContext *ctx, const union ValUnion *value)
130
+ {
131
+ if (value->bsval.bsval != NULL) {
132
+ // NB: We output `str` here intentionally, to match the output format from libpg_query 14
133
+ // and below. This results in stable fingerprints, despite the field name being changed in
134
+ // PG15 to `bsval`.
121
135
  _fingerprintString(ctx, "BitString");
122
136
  _fingerprintString(ctx, "str");
123
- _fingerprintString(ctx, node->val.str);
137
+ _fingerprintString(ctx, value->bsval.bsval);
124
138
  }
125
139
  }
126
140
 
@@ -272,10 +286,16 @@ _fingerprintNode(FingerprintContext *ctx, const void *obj, const void *parent, c
272
286
  case T_Float:
273
287
  _fingerprintFloat(ctx, obj);
274
288
  break;
289
+ case T_Boolean:
290
+ _fingerprintBoolean(ctx, obj);
291
+ break;
275
292
  case T_String:
293
+ // NB: We output `str` here intentionally, to match the output format from libpg_query
294
+ // 14 and below. This results in stable fingerprints, despite the field name being
295
+ // changed in PG15 to `sval`.
276
296
  _fingerprintString(ctx, "String");
277
297
  _fingerprintString(ctx, "str");
278
- _fingerprintString(ctx, ((Value*) obj)->val.str);
298
+ _fingerprintString(ctx, ((union ValUnion*) obj)->sval.sval);
279
299
  break;
280
300
  case T_BitString:
281
301
  _fingerprintBitString(ctx, obj);
@@ -96,7 +96,6 @@ static void dump_row(StringInfo out, PLpgSQL_row *stmt);
96
96
  static void dump_var(StringInfo out, PLpgSQL_var *stmt);
97
97
  static void dump_variable(StringInfo out, PLpgSQL_variable *stmt);
98
98
  static void dump_record_field(StringInfo out, PLpgSQL_recfield *node);
99
- static void dump_array_elem(StringInfo out, PLpgSQL_arrayelem *node);
100
99
  static void dump_stmt(StringInfo out, PLpgSQL_stmt *stmt);
101
100
  static void dump_block(StringInfo out, PLpgSQL_stmt_block *block);
102
101
  static void dump_exception_block(StringInfo out, PLpgSQL_exception_block *node);
@@ -130,7 +129,6 @@ static void dump_perform(StringInfo out, PLpgSQL_stmt_perform *stmt);
130
129
  static void dump_call(StringInfo out, PLpgSQL_stmt_call *stmt);
131
130
  static void dump_commit(StringInfo out, PLpgSQL_stmt_commit *stmt);
132
131
  static void dump_rollback(StringInfo out, PLpgSQL_stmt_rollback *stmt);
133
- static void dump_set(StringInfo out, PLpgSQL_stmt_set *stmt);
134
132
  static void dump_expr(StringInfo out, PLpgSQL_expr *expr);
135
133
  static void dump_function(StringInfo out, PLpgSQL_function *func);
136
134
  static void dump_exception(StringInfo out, PLpgSQL_exception *node);
@@ -224,9 +222,6 @@ dump_stmt(StringInfo out, PLpgSQL_stmt *node)
224
222
  case PLPGSQL_STMT_ROLLBACK:
225
223
  dump_rollback(out, (PLpgSQL_stmt_rollback *) node);
226
224
  break;
227
- case PLPGSQL_STMT_SET:
228
- dump_set(out, (PLpgSQL_stmt_set *) node);
229
- break;
230
225
  default:
231
226
  elog(ERROR, "unrecognized cmd_type: %d", node->cmd_type);
232
227
  break;
@@ -493,15 +488,6 @@ dump_rollback(StringInfo out, PLpgSQL_stmt_rollback *node)
493
488
  WRITE_BOOL_FIELD(chain, chain, chain);
494
489
  }
495
490
 
496
- static void
497
- dump_set(StringInfo out, PLpgSQL_stmt_set *node)
498
- {
499
- WRITE_NODE_TYPE("PLpgSQL_stmt_set");
500
-
501
- WRITE_INT_FIELD(lineno, lineno, lineno);
502
- WRITE_EXPR_FIELD(expr);
503
- }
504
-
505
491
  static void
506
492
  dump_exit(StringInfo out, PLpgSQL_stmt_exit *node)
507
493
  {
@@ -673,9 +659,6 @@ dump_function(StringInfo out, PLpgSQL_function *node)
673
659
  case PLPGSQL_DTYPE_RECFIELD:
674
660
  dump_record_field(out, (PLpgSQL_recfield *) d);
675
661
  break;
676
- case PLPGSQL_DTYPE_ARRAYELEM:
677
- dump_array_elem(out, (PLpgSQL_arrayelem *) d);
678
- break;
679
662
  default:
680
663
  elog(WARNING, "could not dump unrecognized dtype: %d",
681
664
  (int) d->dtype);
@@ -780,14 +763,6 @@ dump_record_field(StringInfo out, PLpgSQL_recfield *node) {
780
763
  WRITE_INT_FIELD(recparentno, recparentno, recparentno);
781
764
  }
782
765
 
783
- static void
784
- dump_array_elem(StringInfo out, PLpgSQL_arrayelem *node) {
785
- WRITE_NODE_TYPE("PLpgSQL_arrayelem");
786
-
787
- WRITE_EXPR_FIELD(subscript);
788
- WRITE_INT_FIELD(arrayparentno, arrayparentno, arrayparentno);
789
- }
790
-
791
766
  char *
792
767
  plpgsqlToJSON(PLpgSQL_function *func)
793
768
  {
@@ -572,7 +572,7 @@ PgQueryNormalizeResult pg_query_normalize(const char* input)
572
572
  int query_len;
573
573
 
574
574
  /* Parse query */
575
- tree = raw_parser(input);
575
+ tree = raw_parser(input, RAW_PARSE_DEFAULT);
576
576
 
577
577
  query_len = (int) strlen(input);
578
578
 
@@ -195,39 +195,77 @@ _outOidList(StringInfo out, const List *node)
195
195
  }
196
196
 
197
197
  static void
198
- _outInteger(StringInfo out, const Value *node)
198
+ _outInteger(StringInfo out, const Integer *node)
199
199
  {
200
- appendStringInfo(out, "\"ival\":%d,", node->val.ival);
200
+ if (node->ival > 0)
201
+ appendStringInfo(out, "\"ival\":%d", node->ival);
201
202
  }
202
203
 
203
204
  static void
204
- _outFloat(StringInfo out, const Value *node)
205
+ _outBoolean(StringInfo out, const Boolean *node)
205
206
  {
206
- appendStringInfo(out, "\"str\":");
207
- _outToken(out, node->val.str);
208
- appendStringInfo(out, ",");
207
+ appendStringInfo(out, "\"boolval\":%s", booltostr(node->boolval));
209
208
  }
210
209
 
211
210
  static void
212
- _outString(StringInfo out, const Value *node)
211
+ _outFloat(StringInfo out, const Float *node)
213
212
  {
214
- appendStringInfo(out, "\"str\":");
215
- _outToken(out, node->val.str);
216
- appendStringInfo(out, ",");
213
+ appendStringInfo(out, "\"fval\":");
214
+ _outToken(out, node->fval);
217
215
  }
218
216
 
219
217
  static void
220
- _outBitString(StringInfo out, const Value *node)
218
+ _outString(StringInfo out, const String *node)
221
219
  {
222
- appendStringInfo(out, "\"str\":");
223
- _outToken(out, node->val.str);
224
- appendStringInfo(out, ",");
220
+ appendStringInfo(out, "\"sval\":");
221
+ _outToken(out, node->sval);
225
222
  }
226
223
 
227
224
  static void
228
- _outNull(StringInfo out, const Value *node)
225
+ _outBitString(StringInfo out, const BitString *node)
229
226
  {
230
- // No fields
227
+ appendStringInfo(out, "\"bsval\":");
228
+ _outToken(out, node->bsval);
229
+ }
230
+
231
+ static void
232
+ _outAConst(StringInfo out, const A_Const *node)
233
+ {
234
+ if (node->isnull) {
235
+ appendStringInfo(out, "\"isnull\":true");
236
+ } else {
237
+ switch (node->val.node.type) {
238
+ case T_Integer:
239
+ appendStringInfoString(out, "\"ival\":{");
240
+ _outInteger(out, &node->val.ival);
241
+ appendStringInfoChar(out, '}');
242
+ break;
243
+ case T_Float:
244
+ appendStringInfoString(out, "\"fval\":{");
245
+ _outFloat(out, &node->val.fval);
246
+ appendStringInfoChar(out, '}');
247
+ break;
248
+ case T_Boolean:
249
+ appendStringInfo(out, "\"boolval\":{%s}", node->val.boolval.boolval ? "\"boolval\":true" : "");
250
+ break;
251
+ case T_String:
252
+ appendStringInfoString(out, "\"sval\":{");
253
+ _outString(out, &node->val.sval);
254
+ appendStringInfoChar(out, '}');
255
+ break;
256
+ case T_BitString:
257
+ appendStringInfoString(out, "\"bsval\":{");
258
+ _outBitString(out, &node->val.bsval);
259
+ appendStringInfoChar(out, '}');
260
+ break;
261
+
262
+ // Unreachable, A_Const cannot contain any other nodes.
263
+ default:
264
+ Assert(false);
265
+ }
266
+ }
267
+
268
+ appendStringInfo(out, ",\"location\":%d", node->location);
231
269
  }
232
270
 
233
271
  #include "pg_query_enum_defs.c"
@@ -150,33 +150,93 @@ _outOidList(PgQuery__OidList* out, const List *node)
150
150
  // TODO: Add Bitmapset
151
151
 
152
152
  static void
153
- _outInteger(PgQuery__Integer* out, const Value *node)
153
+ _outInteger(PgQuery__Integer* out, const Integer *node)
154
154
  {
155
- out->ival = node->val.ival;
155
+ out->ival = node->ival;
156
156
  }
157
157
 
158
158
  static void
159
- _outFloat(PgQuery__Float* out, const Value *node)
159
+ _outFloat(PgQuery__Float* out, const Float *node)
160
160
  {
161
- out->str = node->val.str;
161
+ out->fval = node->fval;
162
162
  }
163
163
 
164
164
  static void
165
- _outString(PgQuery__String* out, const Value *node)
165
+ _outBoolean(PgQuery__Boolean* out, const Boolean *node)
166
166
  {
167
- out->str = node->val.str;
167
+ out->boolval = node->boolval;
168
168
  }
169
169
 
170
170
  static void
171
- _outBitString(PgQuery__BitString* out, const Value *node)
171
+ _outString(PgQuery__String* out, const String *node)
172
172
  {
173
- out->str = node->val.str;
173
+ out->sval = node->sval;
174
174
  }
175
175
 
176
176
  static void
177
- _outNull(PgQuery__Null* out, const Value *node)
177
+ _outBitString(PgQuery__BitString* out, const BitString *node)
178
178
  {
179
- // Null has no fields
179
+ out->bsval = node->bsval;
180
+ }
181
+
182
+ static void
183
+ _outAConst(PgQuery__AConst* out, const A_Const *node)
184
+ {
185
+ out->isnull = node->isnull;
186
+ out->location = node->location;
187
+
188
+ if (!node->isnull) {
189
+ switch (nodeTag(&node->val.node)) {
190
+ case T_Integer: {
191
+ PgQuery__Integer *value = palloc(sizeof(PgQuery__Integer));
192
+ pg_query__integer__init(value);
193
+ value->ival = node->val.ival.ival;
194
+
195
+ out->val_case = PG_QUERY__A__CONST__VAL_IVAL;
196
+ out->ival = value;
197
+ break;
198
+ }
199
+ case T_Float: {
200
+ PgQuery__Float *value = palloc(sizeof(PgQuery__Float));
201
+ pg_query__float__init(value);
202
+ value->fval = pstrdup(node->val.fval.fval);
203
+
204
+ out->val_case = PG_QUERY__A__CONST__VAL_FVAL;
205
+ out->fval = value;
206
+ break;
207
+ }
208
+ case T_Boolean: {
209
+ PgQuery__Boolean *value = palloc(sizeof(PgQuery__Boolean));
210
+ pg_query__boolean__init(value);
211
+ value->boolval = node->val.boolval.boolval;
212
+
213
+ out->val_case = PG_QUERY__A__CONST__VAL_BOOLVAL;
214
+ out->boolval = value;
215
+ break;
216
+ }
217
+ case T_String: {
218
+ PgQuery__String *value = palloc(sizeof(PgQuery__String));
219
+ pg_query__string__init(value);
220
+ value->sval = pstrdup(node->val.sval.sval);
221
+
222
+ out->val_case = PG_QUERY__A__CONST__VAL_SVAL;
223
+ out->sval = value;
224
+ break;
225
+ }
226
+ case T_BitString: {
227
+ PgQuery__BitString *value = palloc(sizeof(PgQuery__BitString));
228
+ pg_query__bit_string__init(value);
229
+ value->bsval = pstrdup(node->val.bsval.bsval);
230
+
231
+ out->val_case = PG_QUERY__A__CONST__VAL_BSVAL;
232
+ out->bsval = value;
233
+ break;
234
+ }
235
+ default:
236
+ // Unreachable
237
+ Assert(false);
238
+ }
239
+ }
180
240
  }
181
241
 
182
242
  #include "pg_query_enum_defs.c"
@@ -42,7 +42,7 @@ PgQueryInternalParsetreeAndError pg_query_raw_parse(const char* input)
42
42
 
43
43
  PG_TRY();
44
44
  {
45
- result.tree = raw_parser(input);
45
+ result.tree = raw_parser(input, RAW_PARSE_DEFAULT);
46
46
 
47
47
  #ifndef DEBUG
48
48
  // Save stderr for result
@@ -74,6 +74,12 @@
74
74
 
75
75
  static Node * _readNode(PgQuery__Node *msg);
76
76
 
77
+ static String *
78
+ _readString(PgQuery__String* msg)
79
+ {
80
+ return makeString(pstrdup(msg->sval));
81
+ }
82
+
77
83
  #include "pg_query_enum_defs.c"
78
84
  #include "pg_query_readfuncs_defs.c"
79
85
 
@@ -96,17 +102,45 @@ static Node * _readNode(PgQuery__Node *msg)
96
102
  case PG_QUERY__NODE__NODE_INTEGER:
97
103
  return (Node *) makeInteger(msg->integer->ival);
98
104
  case PG_QUERY__NODE__NODE_FLOAT:
99
- return (Node *) makeFloat(pstrdup(msg->float_->str));
105
+ return (Node *) makeFloat(pstrdup(msg->float_->fval));
106
+ case PG_QUERY__NODE__NODE_BOOLEAN:
107
+ return (Node *) makeBoolean(msg->boolean->boolval);
100
108
  case PG_QUERY__NODE__NODE_STRING:
101
- return (Node *) makeString(pstrdup(msg->string->str));
109
+ return (Node *) makeString(pstrdup(msg->string->sval));
102
110
  case PG_QUERY__NODE__NODE_BIT_STRING:
103
- return (Node *) makeBitString(pstrdup(msg->bit_string->str));
104
- case PG_QUERY__NODE__NODE_NULL:
105
- {
106
- Value *v = makeNode(Value);
107
- v->type = T_Null;
108
- return (Node *) v;
111
+ return (Node *) makeBitString(pstrdup(msg->bit_string->bsval));
112
+ case PG_QUERY__NODE__NODE_A_CONST: {
113
+ A_Const *ac = makeNode(A_Const);
114
+ ac->location = msg->a_const->location;
115
+
116
+ if (msg->a_const->isnull) {
117
+ ac->isnull = true;
118
+ } else {
119
+ switch (msg->a_const->val_case) {
120
+ case PG_QUERY__A__CONST__VAL_IVAL:
121
+ ac->val.ival = *makeInteger(msg->a_const->ival->ival);
122
+ break;
123
+ case PG_QUERY__A__CONST__VAL_FVAL:
124
+ ac->val.fval = *makeFloat(pstrdup(msg->a_const->fval->fval));
125
+ break;
126
+ case PG_QUERY__A__CONST__VAL_BOOLVAL:
127
+ ac->val.boolval = *makeBoolean(msg->a_const->boolval->boolval);
128
+ break;
129
+ case PG_QUERY__A__CONST__VAL_SVAL:
130
+ ac->val.sval = *makeString(pstrdup(msg->a_const->sval->sval));
131
+ break;
132
+ case PG_QUERY__A__CONST__VAL_BSVAL:
133
+ ac->val.bsval = *makeBitString(pstrdup(msg->a_const->bsval->bsval));
134
+ break;
135
+ case PG_QUERY__A__CONST__VAL__NOT_SET:
136
+ case _PG_QUERY__A__CONST__VAL__CASE_IS_INT_SIZE:
137
+ Assert(false);
138
+ break;
139
+ }
109
140
  }
141
+
142
+ return (Node *) ac;
143
+ }
110
144
  case PG_QUERY__NODE__NODE_LIST:
111
145
  return (Node *) _readList(msg->list);
112
146
  case PG_QUERY__NODE__NODE__NOT_SET:
@@ -101,8 +101,9 @@ PgQueryScanResult pg_query_scan(const char* input)
101
101
  output_tokens[i]->token = tok;
102
102
 
103
103
  switch (tok) {
104
- #define PG_KEYWORD(a,b,c) case b: output_tokens[i]->keyword_kind = c + 1; break;
104
+ #define PG_KEYWORD(a,b,c,d) case b: output_tokens[i]->keyword_kind = c + 1; break;
105
105
  #include "parser/kwlist.h"
106
+ #undef PG_KEYWORD
106
107
  default: output_tokens[i]->keyword_kind = 0;
107
108
  }
108
109
  }
@@ -59,8 +59,9 @@ PgQuerySplitResult pg_query_split_with_scanner(const char* input)
59
59
  {
60
60
  int tok = core_yylex(&yylval, &yylloc, yyscanner);
61
61
  switch (tok) {
62
- #define PG_KEYWORD(a,b,c) case b: is_keyword = true; break;
62
+ #define PG_KEYWORD(a,b,c,d) case b: is_keyword = true; break;
63
63
  #include "parser/kwlist.h"
64
+ #undef PG_KEYWORD
64
65
  default: is_keyword = false;
65
66
  }
66
67
  if (is_keyword)
@@ -88,7 +89,7 @@ PgQuerySplitResult pg_query_split_with_scanner(const char* input)
88
89
  {
89
90
  int tok = core_yylex(&yylval, &yylloc, yyscanner);
90
91
  switch (tok) {
91
- #define PG_KEYWORD(a,b,c) case b: is_keyword = true; break;
92
+ #define PG_KEYWORD(a,b,c,d) case b: is_keyword = true; break;
92
93
  #include "parser/kwlist.h"
93
94
  default: is_keyword = false;
94
95
  }
@@ -16,7 +16,7 @@
16
16
  * and implementing search-path-controlled searches.
17
17
  *
18
18
  *
19
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
19
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
20
20
  * Portions Copyright (c) 1994, Regents of the University of California
21
21
  *
22
22
  * IDENTIFICATION
@@ -214,6 +214,7 @@ static void RemoveTempRelations(Oid tempNamespaceId);
214
214
  static void RemoveTempRelationsCallback(int code, Datum arg);
215
215
  static void NamespaceCallback(Datum arg, int cacheid, uint32 hashvalue);
216
216
  static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
217
+ bool include_out_arguments, int pronargs,
217
218
  int **argnumbers);
218
219
 
219
220
 
@@ -356,6 +357,12 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
356
357
  * of additional args (which can be retrieved from the function's
357
358
  * proargdefaults entry).
358
359
  *
360
+ * If include_out_arguments is true, then OUT-mode arguments are considered to
361
+ * be included in the argument list. Their types are included in the returned
362
+ * arrays, and argnumbers are indexes in proallargtypes not proargtypes.
363
+ * We also set nominalnargs to be the length of proallargtypes not proargtypes.
364
+ * Otherwise OUT-mode arguments are ignored.
365
+ *
359
366
  * It is not possible for nvargs and ndargs to both be nonzero in the same
360
367
  * list entry, since default insertion allows matches to functions with more
361
368
  * than nargs arguments while the variadic transformation requires the same
@@ -366,7 +373,8 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
366
373
  * first any positional arguments, then the named arguments, then defaulted
367
374
  * arguments (if needed and allowed by expand_defaults). The argnumbers[]
368
375
  * array can be used to map this back to the catalog information.
369
- * argnumbers[k] is set to the proargtypes index of the k'th call argument.
376
+ * argnumbers[k] is set to the proargtypes or proallargtypes index of the
377
+ * k'th call argument.
370
378
  *
371
379
  * We search a single namespace if the function name is qualified, else
372
380
  * all namespaces in the search path. In the multiple-namespace case,
@@ -390,7 +398,7 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
390
398
  * such an entry it should react as though the call were ambiguous.
391
399
  *
392
400
  * If missing_ok is true, an empty list (NULL) is returned if the name was
393
- * schema- qualified with a schema that does not exist. Likewise if no
401
+ * schema-qualified with a schema that does not exist. Likewise if no
394
402
  * candidate is found for other reasons.
395
403
  */
396
404
 
@@ -404,6 +412,10 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
404
412
  * the function, in positions after the last positional argument, and there
405
413
  * are defaults for all unsupplied arguments.
406
414
  *
415
+ * If include_out_arguments is true, we are treating OUT arguments as
416
+ * included in the argument list. pronargs is the number of arguments
417
+ * we're considering (the length of either proargtypes or proallargtypes).
418
+ *
407
419
  * The number of positional arguments is nargs - list_length(argnames).
408
420
  * Note caller has already done basic checks on argument count.
409
421
  *
@@ -428,8 +440,7 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
428
440
  * Given a possibly-qualified operator name and exact input datatypes,
429
441
  * look up the operator. Returns InvalidOid if not found.
430
442
  *
431
- * Pass oprleft = InvalidOid for a prefix op, oprright = InvalidOid for
432
- * a postfix op.
443
+ * Pass oprleft = InvalidOid for a prefix op.
433
444
  *
434
445
  * If the operator name is not schema-qualified, it is sought in the current
435
446
  * namespace search path. If the name is schema-qualified and the given
@@ -451,8 +462,8 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
451
462
  * namespace case, we arrange for entries in earlier namespaces to mask
452
463
  * identical entries in later namespaces.
453
464
  *
454
- * The returned items always have two args[] entries --- one or the other
455
- * will be InvalidOid for a prefix or postfix oprkind. nargs is 2, too.
465
+ * The returned items always have two args[] entries --- the first will be
466
+ * InvalidOid for a prefix oprkind. nargs is always 2, too.
456
467
  */
457
468
  #define SPACE_PER_OP MAXALIGN(offsetof(struct _FuncCandidateList, args) + \
458
469
  2 * sizeof(Oid))
@@ -677,7 +688,7 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
677
688
 
678
689
  /*
679
690
  * QualifiedNameGetCreationNamespace
680
- * Given a possibly-qualified name for an object (in List-of-Values
691
+ * Given a possibly-qualified name for an object (in List-of-Strings
681
692
  * format), determine what namespace the object should be created in.
682
693
  * Also extract and return the object name (last component of list).
683
694
  *
@@ -710,7 +721,7 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
710
721
  * This is used primarily to form error messages, and so we do not quote
711
722
  * the list elements, for the sake of legibility.
712
723
  *
713
- * In most scenarios the list elements should always be Value strings,
724
+ * In most scenarios the list elements should always be String values,
714
725
  * but we also allow A_Star for the convenience of ColumnRef processing.
715
726
  */
716
727
  char *
@@ -9,7 +9,7 @@
9
9
  * pg_proc.c
10
10
  * routines to support manipulation of the pg_proc relation
11
11
  *
12
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
12
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
13
13
  * Portions Copyright (c) 1994, Regents of the University of California
14
14
  *
15
15
  *
@@ -38,8 +38,11 @@
38
38
  #include "mb/pg_wchar.h"
39
39
  #include "miscadmin.h"
40
40
  #include "nodes/nodeFuncs.h"
41
+ #include "parser/analyze.h"
41
42
  #include "parser/parse_coerce.h"
42
43
  #include "parser/parse_type.h"
44
+ #include "pgstat.h"
45
+ #include "rewrite/rewriteHandler.h"
43
46
  #include "tcop/pquery.h"
44
47
  #include "tcop/tcopprot.h"
45
48
  #include "utils/acl.h"
@@ -10,7 +10,7 @@
10
10
  * Support routines for various kinds of object creation.
11
11
  *
12
12
  *
13
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
13
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
14
14
  * Portions Copyright (c) 1994, Regents of the University of California
15
15
  *
16
16
  *
@@ -92,6 +92,11 @@ defGetInt32(DefElem *def)
92
92
  */
93
93
 
94
94
 
95
+ /*
96
+ * Extract an OID value from a DefElem.
97
+ */
98
+
99
+
95
100
  /*
96
101
  * Extract a possibly-qualified name (as a List of Strings) from a DefElem.
97
102
  */
@@ -115,3 +120,8 @@ defGetInt32(DefElem *def)
115
120
  * Extract a list of string values (otherwise uninterpreted) from a DefElem.
116
121
  */
117
122
 
123
+
124
+ /*
125
+ * Raise an error about a conflicting DefElem.
126
+ */
127
+
@@ -23,7 +23,7 @@
23
23
  * bms_is_empty() in preference to testing for NULL.)
24
24
  *
25
25
  *
26
- * Copyright (c) 2003-2020, PostgreSQL Global Development Group
26
+ * Copyright (c) 2003-2022, PostgreSQL Global Development Group
27
27
  *
28
28
  * IDENTIFICATION
29
29
  * src/backend/nodes/bitmapset.c
@@ -233,6 +233,8 @@ bms_free(Bitmapset *a)
233
233
 
234
234
  /*
235
235
  * bms_nonempty_difference - do sets have a nonempty difference?
236
+ *
237
+ * i.e., are any members set in 'a' that are not also set in 'b'.
236
238
  */
237
239
 
238
240