pg_query 5.1.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (479) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +1 -1
  4. data/Rakefile +2 -2
  5. data/ext/pg_query/include/pg_query.h +4 -3
  6. data/ext/pg_query/include/pg_query_enum_defs.c +424 -154
  7. data/ext/pg_query/include/pg_query_fingerprint_conds.c +68 -4
  8. data/ext/pg_query/include/pg_query_fingerprint_defs.c +2952 -1845
  9. data/ext/pg_query/include/pg_query_outfuncs_conds.c +51 -3
  10. data/ext/pg_query/include/pg_query_outfuncs_defs.c +210 -23
  11. data/ext/pg_query/include/pg_query_readfuncs_conds.c +17 -1
  12. data/ext/pg_query/include/pg_query_readfuncs_defs.c +271 -52
  13. data/ext/pg_query/include/postgres/access/amapi.h +10 -3
  14. data/ext/pg_query/include/postgres/access/attmap.h +1 -1
  15. data/ext/pg_query/include/postgres/access/attnum.h +1 -1
  16. data/ext/pg_query/include/postgres/access/brin_internal.h +116 -0
  17. data/ext/pg_query/include/postgres/access/brin_tuple.h +112 -0
  18. data/ext/pg_query/include/postgres/access/clog.h +2 -3
  19. data/ext/pg_query/include/postgres/access/commit_ts.h +2 -3
  20. data/ext/pg_query/include/postgres/access/detoast.h +1 -1
  21. data/ext/pg_query/include/postgres/access/genam.h +8 -4
  22. data/ext/pg_query/include/postgres/access/gin.h +1 -1
  23. data/ext/pg_query/include/postgres/access/htup.h +1 -1
  24. data/ext/pg_query/include/postgres/access/htup_details.h +11 -11
  25. data/ext/pg_query/include/postgres/access/itup.h +3 -3
  26. data/ext/pg_query/include/postgres/access/parallel.h +1 -2
  27. data/ext/pg_query/include/postgres/access/printtup.h +1 -1
  28. data/ext/pg_query/include/postgres/access/relation.h +1 -1
  29. data/ext/pg_query/include/postgres/access/relscan.h +1 -1
  30. data/ext/pg_query/include/postgres/access/rmgrlist.h +1 -1
  31. data/ext/pg_query/include/postgres/access/sdir.h +1 -1
  32. data/ext/pg_query/include/postgres/access/skey.h +1 -1
  33. data/ext/pg_query/include/postgres/access/slru.h +221 -0
  34. data/ext/pg_query/include/postgres/access/stratnum.h +1 -1
  35. data/ext/pg_query/include/postgres/access/sysattr.h +1 -1
  36. data/ext/pg_query/include/postgres/access/table.h +1 -1
  37. data/ext/pg_query/include/postgres/access/tableam.h +33 -24
  38. data/ext/pg_query/include/postgres/access/tidstore.h +50 -0
  39. data/ext/pg_query/include/postgres/access/toast_compression.h +2 -2
  40. data/ext/pg_query/include/postgres/access/transam.h +7 -7
  41. data/ext/pg_query/include/postgres/access/tsmapi.h +1 -1
  42. data/ext/pg_query/include/postgres/access/tupconvert.h +1 -1
  43. data/ext/pg_query/include/postgres/access/tupdesc.h +5 -5
  44. data/ext/pg_query/include/postgres/access/tupmacs.h +1 -1
  45. data/ext/pg_query/include/postgres/access/twophase.h +2 -2
  46. data/ext/pg_query/include/postgres/access/xact.h +5 -5
  47. data/ext/pg_query/include/postgres/access/xlog.h +20 -12
  48. data/ext/pg_query/include/postgres/access/xlog_internal.h +4 -3
  49. data/ext/pg_query/include/postgres/access/xlogbackup.h +3 -1
  50. data/ext/pg_query/include/postgres/access/xlogdefs.h +5 -5
  51. data/ext/pg_query/include/postgres/access/xlogprefetcher.h +2 -2
  52. data/ext/pg_query/include/postgres/access/xlogreader.h +2 -2
  53. data/ext/pg_query/include/postgres/access/xlogrecord.h +3 -3
  54. data/ext/pg_query/include/postgres/access/xlogrecovery.h +4 -4
  55. data/ext/pg_query/include/postgres/archive/archive_module.h +9 -1
  56. data/ext/pg_query/include/postgres/c.h +31 -36
  57. data/ext/pg_query/include/postgres/catalog/catalog.h +3 -1
  58. data/ext/pg_query/include/postgres/catalog/catversion.h +2 -2
  59. data/ext/pg_query/include/postgres/catalog/dependency.h +17 -59
  60. data/ext/pg_query/include/postgres/catalog/genbki.h +12 -6
  61. data/ext/pg_query/include/postgres/catalog/index.h +22 -18
  62. data/ext/pg_query/include/postgres/catalog/indexing.h +1 -1
  63. data/ext/pg_query/include/postgres/catalog/namespace.h +18 -19
  64. data/ext/pg_query/include/postgres/catalog/objectaccess.h +2 -2
  65. data/ext/pg_query/include/postgres/catalog/objectaddress.h +1 -1
  66. data/ext/pg_query/include/postgres/catalog/pg_aggregate.h +4 -2
  67. data/ext/pg_query/include/postgres/catalog/pg_aggregate_d.h +1 -1
  68. data/ext/pg_query/include/postgres/catalog/pg_am.h +6 -3
  69. data/ext/pg_query/include/postgres/catalog/pg_am_d.h +1 -1
  70. data/ext/pg_query/include/postgres/catalog/pg_attribute.h +31 -14
  71. data/ext/pg_query/include/postgres/catalog/pg_attribute_d.h +3 -3
  72. data/ext/pg_query/include/postgres/catalog/pg_authid.h +6 -3
  73. data/ext/pg_query/include/postgres/catalog/pg_authid_d.h +2 -1
  74. data/ext/pg_query/include/postgres/catalog/pg_class.h +10 -5
  75. data/ext/pg_query/include/postgres/catalog/pg_class_d.h +4 -2
  76. data/ext/pg_query/include/postgres/catalog/pg_collation.h +11 -5
  77. data/ext/pg_query/include/postgres/catalog/pg_collation_d.h +5 -2
  78. data/ext/pg_query/include/postgres/catalog/pg_constraint.h +15 -10
  79. data/ext/pg_query/include/postgres/catalog/pg_constraint_d.h +2 -1
  80. data/ext/pg_query/include/postgres/catalog/pg_control.h +5 -3
  81. data/ext/pg_query/include/postgres/catalog/pg_conversion.h +8 -4
  82. data/ext/pg_query/include/postgres/catalog/pg_conversion_d.h +1 -1
  83. data/ext/pg_query/include/postgres/catalog/pg_database.h +9 -4
  84. data/ext/pg_query/include/postgres/catalog/pg_database_d.h +13 -12
  85. data/ext/pg_query/include/postgres/catalog/pg_depend.h +3 -3
  86. data/ext/pg_query/include/postgres/catalog/pg_depend_d.h +1 -1
  87. data/ext/pg_query/include/postgres/catalog/pg_event_trigger.h +6 -3
  88. data/ext/pg_query/include/postgres/catalog/pg_event_trigger_d.h +1 -1
  89. data/ext/pg_query/include/postgres/catalog/pg_index.h +5 -3
  90. data/ext/pg_query/include/postgres/catalog/pg_index_d.h +1 -1
  91. data/ext/pg_query/include/postgres/catalog/pg_language.h +6 -3
  92. data/ext/pg_query/include/postgres/catalog/pg_language_d.h +1 -1
  93. data/ext/pg_query/include/postgres/catalog/pg_namespace.h +6 -3
  94. data/ext/pg_query/include/postgres/catalog/pg_namespace_d.h +1 -1
  95. data/ext/pg_query/include/postgres/catalog/pg_opclass.h +6 -3
  96. data/ext/pg_query/include/postgres/catalog/pg_opclass_d.h +1 -1
  97. data/ext/pg_query/include/postgres/catalog/pg_operator.h +20 -3
  98. data/ext/pg_query/include/postgres/catalog/pg_operator_d.h +1 -1
  99. data/ext/pg_query/include/postgres/catalog/pg_opfamily.h +6 -3
  100. data/ext/pg_query/include/postgres/catalog/pg_opfamily_d.h +1 -1
  101. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table.h +4 -2
  102. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table_d.h +1 -1
  103. data/ext/pg_query/include/postgres/catalog/pg_proc.h +6 -3
  104. data/ext/pg_query/include/postgres/catalog/pg_proc_d.h +1 -1
  105. data/ext/pg_query/include/postgres/catalog/pg_publication.h +6 -3
  106. data/ext/pg_query/include/postgres/catalog/pg_publication_d.h +1 -1
  107. data/ext/pg_query/include/postgres/catalog/pg_replication_origin.h +6 -3
  108. data/ext/pg_query/include/postgres/catalog/pg_replication_origin_d.h +1 -1
  109. data/ext/pg_query/include/postgres/catalog/pg_statistic.h +10 -4
  110. data/ext/pg_query/include/postgres/catalog/pg_statistic_d.h +7 -3
  111. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext.h +10 -7
  112. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext_d.h +3 -3
  113. data/ext/pg_query/include/postgres/catalog/pg_transform.h +6 -3
  114. data/ext/pg_query/include/postgres/catalog/pg_transform_d.h +1 -1
  115. data/ext/pg_query/include/postgres/catalog/pg_trigger.h +4 -4
  116. data/ext/pg_query/include/postgres/catalog/pg_trigger_d.h +1 -1
  117. data/ext/pg_query/include/postgres/catalog/pg_ts_config.h +6 -3
  118. data/ext/pg_query/include/postgres/catalog/pg_ts_config_d.h +1 -1
  119. data/ext/pg_query/include/postgres/catalog/pg_ts_dict.h +6 -3
  120. data/ext/pg_query/include/postgres/catalog/pg_ts_dict_d.h +1 -1
  121. data/ext/pg_query/include/postgres/catalog/pg_ts_parser.h +6 -3
  122. data/ext/pg_query/include/postgres/catalog/pg_ts_parser_d.h +1 -1
  123. data/ext/pg_query/include/postgres/catalog/pg_ts_template.h +6 -3
  124. data/ext/pg_query/include/postgres/catalog/pg_ts_template_d.h +1 -1
  125. data/ext/pg_query/include/postgres/catalog/pg_type.h +6 -3
  126. data/ext/pg_query/include/postgres/catalog/pg_type_d.h +1 -1
  127. data/ext/pg_query/include/postgres/catalog/storage.h +1 -1
  128. data/ext/pg_query/include/postgres/catalog/syscache_ids.h +104 -0
  129. data/ext/pg_query/include/postgres/commands/async.h +2 -6
  130. data/ext/pg_query/include/postgres/commands/dbcommands.h +1 -1
  131. data/ext/pg_query/include/postgres/commands/defrem.h +6 -6
  132. data/ext/pg_query/include/postgres/commands/event_trigger.h +5 -2
  133. data/ext/pg_query/include/postgres/commands/explain.h +19 -3
  134. data/ext/pg_query/include/postgres/commands/prepare.h +1 -1
  135. data/ext/pg_query/include/postgres/commands/tablespace.h +1 -1
  136. data/ext/pg_query/include/postgres/commands/trigger.h +1 -1
  137. data/ext/pg_query/include/postgres/commands/vacuum.h +28 -26
  138. data/ext/pg_query/include/postgres/common/cryptohash.h +2 -2
  139. data/ext/pg_query/include/postgres/common/file_perm.h +1 -1
  140. data/ext/pg_query/include/postgres/common/file_utils.h +65 -0
  141. data/ext/pg_query/include/postgres/common/hashfn.h +16 -1
  142. data/ext/pg_query/include/postgres/common/hashfn_unstable.h +453 -0
  143. data/ext/pg_query/include/postgres/common/int.h +79 -4
  144. data/ext/pg_query/include/postgres/common/keywords.h +1 -1
  145. data/ext/pg_query/include/postgres/common/kwlookup.h +1 -1
  146. data/ext/pg_query/include/postgres/common/pg_prng.h +2 -1
  147. data/ext/pg_query/include/postgres/common/relpath.h +4 -4
  148. data/ext/pg_query/include/postgres/common/scram-common.h +1 -1
  149. data/ext/pg_query/include/postgres/common/sha2.h +1 -1
  150. data/ext/pg_query/include/postgres/common/string.h +1 -1
  151. data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +2 -3
  152. data/ext/pg_query/include/postgres/copyfuncs.funcs.c +278 -30
  153. data/ext/pg_query/include/postgres/copyfuncs.switch.c +55 -4
  154. data/ext/pg_query/include/postgres/datatype/timestamp.h +28 -2
  155. data/ext/pg_query/include/postgres/equalfuncs.funcs.c +239 -26
  156. data/ext/pg_query/include/postgres/equalfuncs.switch.c +55 -4
  157. data/ext/pg_query/include/postgres/executor/execdesc.h +1 -1
  158. data/ext/pg_query/include/postgres/executor/executor.h +6 -5
  159. data/ext/pg_query/include/postgres/executor/functions.h +2 -1
  160. data/ext/pg_query/include/postgres/executor/instrument.h +5 -3
  161. data/ext/pg_query/include/postgres/executor/spi.h +2 -8
  162. data/ext/pg_query/include/postgres/executor/tablefunc.h +1 -1
  163. data/ext/pg_query/include/postgres/executor/tuptable.h +31 -2
  164. data/ext/pg_query/include/postgres/fmgr.h +2 -2
  165. data/ext/pg_query/include/postgres/foreign/fdwapi.h +1 -1
  166. data/ext/pg_query/include/postgres/funcapi.h +2 -2
  167. data/ext/pg_query/include/postgres/gram.h +871 -830
  168. data/ext/pg_query/include/postgres/gramparse.h +1 -1
  169. data/ext/pg_query/include/postgres/jit/jit.h +4 -3
  170. data/ext/pg_query/include/postgres/kwlist_d.h +511 -466
  171. data/ext/pg_query/include/postgres/lib/dshash.h +25 -10
  172. data/ext/pg_query/include/postgres/lib/ilist.h +1 -1
  173. data/ext/pg_query/include/postgres/lib/pairingheap.h +1 -1
  174. data/ext/pg_query/include/postgres/lib/simplehash.h +40 -18
  175. data/ext/pg_query/include/postgres/lib/sort_template.h +14 -1
  176. data/ext/pg_query/include/postgres/lib/stringinfo.h +93 -11
  177. data/ext/pg_query/include/postgres/libpq/auth.h +1 -1
  178. data/ext/pg_query/include/postgres/libpq/crypt.h +2 -2
  179. data/ext/pg_query/include/postgres/libpq/hba.h +4 -4
  180. data/ext/pg_query/include/postgres/libpq/libpq-be.h +29 -25
  181. data/ext/pg_query/include/postgres/libpq/libpq.h +6 -7
  182. data/ext/pg_query/include/postgres/libpq/pqcomm.h +26 -20
  183. data/ext/pg_query/include/postgres/libpq/pqformat.h +2 -3
  184. data/ext/pg_query/include/postgres/libpq/pqsignal.h +1 -1
  185. data/ext/pg_query/include/postgres/libpq/protocol.h +89 -0
  186. data/ext/pg_query/include/postgres/libpq/sasl.h +1 -1
  187. data/ext/pg_query/include/postgres/libpq/scram.h +1 -1
  188. data/ext/pg_query/include/postgres/mb/pg_wchar.h +102 -82
  189. data/ext/pg_query/include/postgres/mb/stringinfo_mb.h +1 -1
  190. data/ext/pg_query/include/postgres/miscadmin.h +64 -52
  191. data/ext/pg_query/include/postgres/nodes/bitmapset.h +17 -3
  192. data/ext/pg_query/include/postgres/nodes/execnodes.h +109 -25
  193. data/ext/pg_query/include/postgres/nodes/extensible.h +1 -1
  194. data/ext/pg_query/include/postgres/nodes/lockoptions.h +4 -4
  195. data/ext/pg_query/include/postgres/nodes/makefuncs.h +8 -2
  196. data/ext/pg_query/include/postgres/nodes/memnodes.h +43 -4
  197. data/ext/pg_query/include/postgres/nodes/miscnodes.h +1 -1
  198. data/ext/pg_query/include/postgres/nodes/nodeFuncs.h +1 -1
  199. data/ext/pg_query/include/postgres/nodes/nodes.h +30 -41
  200. data/ext/pg_query/include/postgres/nodes/nodetags.h +464 -444
  201. data/ext/pg_query/include/postgres/nodes/params.h +1 -1
  202. data/ext/pg_query/include/postgres/nodes/parsenodes.h +358 -175
  203. data/ext/pg_query/include/postgres/nodes/pathnodes.h +60 -9
  204. data/ext/pg_query/include/postgres/nodes/pg_list.h +62 -11
  205. data/ext/pg_query/include/postgres/nodes/plannodes.h +11 -10
  206. data/ext/pg_query/include/postgres/nodes/primnodes.h +344 -50
  207. data/ext/pg_query/include/postgres/nodes/print.h +1 -1
  208. data/ext/pg_query/include/postgres/nodes/queryjumble.h +2 -2
  209. data/ext/pg_query/include/postgres/nodes/replnodes.h +23 -2
  210. data/ext/pg_query/include/postgres/nodes/supportnodes.h +1 -1
  211. data/ext/pg_query/include/postgres/nodes/tidbitmap.h +1 -1
  212. data/ext/pg_query/include/postgres/nodes/value.h +1 -1
  213. data/ext/pg_query/include/postgres/optimizer/cost.h +5 -4
  214. data/ext/pg_query/include/postgres/optimizer/geqo.h +1 -1
  215. data/ext/pg_query/include/postgres/optimizer/geqo_gene.h +1 -1
  216. data/ext/pg_query/include/postgres/optimizer/optimizer.h +5 -2
  217. data/ext/pg_query/include/postgres/optimizer/paths.h +13 -8
  218. data/ext/pg_query/include/postgres/optimizer/planmain.h +7 -1
  219. data/ext/pg_query/include/postgres/parser/analyze.h +3 -1
  220. data/ext/pg_query/include/postgres/parser/kwlist.h +22 -2
  221. data/ext/pg_query/include/postgres/parser/parse_agg.h +1 -1
  222. data/ext/pg_query/include/postgres/parser/parse_coerce.h +2 -2
  223. data/ext/pg_query/include/postgres/parser/parse_expr.h +1 -1
  224. data/ext/pg_query/include/postgres/parser/parse_func.h +2 -2
  225. data/ext/pg_query/include/postgres/parser/parse_node.h +3 -2
  226. data/ext/pg_query/include/postgres/parser/parse_oper.h +4 -1
  227. data/ext/pg_query/include/postgres/parser/parse_relation.h +1 -1
  228. data/ext/pg_query/include/postgres/parser/parse_type.h +2 -2
  229. data/ext/pg_query/include/postgres/parser/parser.h +3 -3
  230. data/ext/pg_query/include/postgres/parser/parsetree.h +1 -1
  231. data/ext/pg_query/include/postgres/parser/scanner.h +1 -1
  232. data/ext/pg_query/include/postgres/parser/scansup.h +1 -1
  233. data/ext/pg_query/include/postgres/partitioning/partdefs.h +1 -1
  234. data/ext/pg_query/include/postgres/pg_config.h +34 -34
  235. data/ext/pg_query/include/postgres/pg_config_manual.h +21 -8
  236. data/ext/pg_query/include/postgres/pg_getopt.h +1 -1
  237. data/ext/pg_query/include/postgres/pg_trace.h +1 -1
  238. data/ext/pg_query/include/postgres/pgstat.h +13 -11
  239. data/ext/pg_query/include/postgres/pgtime.h +1 -1
  240. data/ext/pg_query/include/postgres/pl_reserved_kwlist.h +1 -1
  241. data/ext/pg_query/include/postgres/pl_reserved_kwlist_d.h +1 -1
  242. data/ext/pg_query/include/postgres/pl_unreserved_kwlist.h +1 -1
  243. data/ext/pg_query/include/postgres/pl_unreserved_kwlist_d.h +1 -1
  244. data/ext/pg_query/include/postgres/plerrcodes.h +4 -4
  245. data/ext/pg_query/include/postgres/plpgsql.h +15 -13
  246. data/ext/pg_query/include/postgres/port/atomics/arch-arm.h +1 -1
  247. data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +1 -1
  248. data/ext/pg_query/include/postgres/port/atomics/arch-ppc.h +3 -1
  249. data/ext/pg_query/include/postgres/port/atomics/arch-x86.h +3 -1
  250. data/ext/pg_query/include/postgres/port/atomics/fallback.h +1 -1
  251. data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +38 -1
  252. data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +19 -1
  253. data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +16 -1
  254. data/ext/pg_query/include/postgres/port/atomics/generic.h +38 -2
  255. data/ext/pg_query/include/postgres/port/atomics.h +93 -6
  256. data/ext/pg_query/include/postgres/port/pg_bitutils.h +91 -9
  257. data/ext/pg_query/include/postgres/port/pg_bswap.h +1 -1
  258. data/ext/pg_query/include/postgres/port/pg_crc32c.h +10 -1
  259. data/ext/pg_query/include/postgres/port/pg_iovec.h +117 -0
  260. data/ext/pg_query/include/postgres/port/simd.h +48 -1
  261. data/ext/pg_query/include/postgres/port/win32/sys/socket.h +8 -0
  262. data/ext/pg_query/include/postgres/port/win32_port.h +1 -11
  263. data/ext/pg_query/include/postgres/port.h +7 -3
  264. data/ext/pg_query/include/postgres/portability/instr_time.h +1 -1
  265. data/ext/pg_query/include/postgres/postgres.h +1 -1
  266. data/ext/pg_query/include/postgres/postmaster/autovacuum.h +5 -16
  267. data/ext/pg_query/include/postgres/postmaster/bgworker.h +8 -6
  268. data/ext/pg_query/include/postgres/postmaster/bgworker_internals.h +3 -7
  269. data/ext/pg_query/include/postgres/postmaster/bgwriter.h +3 -3
  270. data/ext/pg_query/include/postgres/postmaster/interrupt.h +1 -1
  271. data/ext/pg_query/include/postgres/postmaster/pgarch.h +2 -2
  272. data/ext/pg_query/include/postgres/postmaster/postmaster.h +25 -5
  273. data/ext/pg_query/include/postgres/postmaster/startup.h +2 -2
  274. data/ext/pg_query/include/postgres/postmaster/syslogger.h +2 -4
  275. data/ext/pg_query/include/postgres/postmaster/walsummarizer.h +35 -0
  276. data/ext/pg_query/include/postgres/postmaster/walwriter.h +2 -2
  277. data/ext/pg_query/include/postgres/regex/regex.h +92 -9
  278. data/ext/pg_query/include/postgres/replication/logicallauncher.h +1 -1
  279. data/ext/pg_query/include/postgres/replication/logicalproto.h +2 -2
  280. data/ext/pg_query/include/postgres/replication/logicalworker.h +2 -1
  281. data/ext/pg_query/include/postgres/replication/origin.h +1 -1
  282. data/ext/pg_query/include/postgres/replication/reorderbuffer.h +18 -28
  283. data/ext/pg_query/include/postgres/replication/slot.h +41 -5
  284. data/ext/pg_query/include/postgres/replication/slotsync.h +38 -0
  285. data/ext/pg_query/include/postgres/replication/syncrep.h +1 -1
  286. data/ext/pg_query/include/postgres/replication/walreceiver.h +37 -11
  287. data/ext/pg_query/include/postgres/replication/walsender.h +5 -3
  288. data/ext/pg_query/include/postgres/rewrite/prs2lock.h +1 -1
  289. data/ext/pg_query/include/postgres/rewrite/rewriteHandler.h +7 -1
  290. data/ext/pg_query/include/postgres/rewrite/rewriteManip.h +2 -2
  291. data/ext/pg_query/include/postgres/rewrite/rewriteSupport.h +1 -1
  292. data/ext/pg_query/include/postgres/storage/block.h +1 -1
  293. data/ext/pg_query/include/postgres/storage/buf.h +1 -1
  294. data/ext/pg_query/include/postgres/storage/bufmgr.h +59 -41
  295. data/ext/pg_query/include/postgres/storage/bufpage.h +1 -1
  296. data/ext/pg_query/include/postgres/storage/condition_variable.h +1 -1
  297. data/ext/pg_query/include/postgres/storage/dsm.h +1 -1
  298. data/ext/pg_query/include/postgres/storage/dsm_impl.h +2 -2
  299. data/ext/pg_query/include/postgres/storage/fd.h +30 -13
  300. data/ext/pg_query/include/postgres/storage/fileset.h +1 -1
  301. data/ext/pg_query/include/postgres/storage/ipc.h +4 -1
  302. data/ext/pg_query/include/postgres/storage/item.h +1 -1
  303. data/ext/pg_query/include/postgres/storage/itemid.h +1 -1
  304. data/ext/pg_query/include/postgres/storage/itemptr.h +1 -1
  305. data/ext/pg_query/include/postgres/storage/large_object.h +1 -1
  306. data/ext/pg_query/include/postgres/storage/latch.h +4 -2
  307. data/ext/pg_query/include/postgres/storage/lmgr.h +8 -2
  308. data/ext/pg_query/include/postgres/storage/lock.h +19 -19
  309. data/ext/pg_query/include/postgres/storage/lockdefs.h +1 -1
  310. data/ext/pg_query/include/postgres/storage/lwlock.h +17 -9
  311. data/ext/pg_query/include/postgres/storage/lwlocknames.h +7 -10
  312. data/ext/pg_query/include/postgres/storage/off.h +1 -1
  313. data/ext/pg_query/include/postgres/storage/pg_sema.h +1 -1
  314. data/ext/pg_query/include/postgres/storage/pg_shmem.h +5 -4
  315. data/ext/pg_query/include/postgres/storage/pmsignal.h +2 -2
  316. data/ext/pg_query/include/postgres/storage/predicate.h +1 -5
  317. data/ext/pg_query/include/postgres/storage/proc.h +48 -23
  318. data/ext/pg_query/include/postgres/storage/procarray.h +5 -1
  319. data/ext/pg_query/include/postgres/storage/proclist_types.h +11 -9
  320. data/ext/pg_query/include/postgres/storage/procnumber.h +43 -0
  321. data/ext/pg_query/include/postgres/storage/procsignal.h +8 -6
  322. data/ext/pg_query/include/postgres/storage/read_stream.h +65 -0
  323. data/ext/pg_query/include/postgres/storage/relfilelocator.h +16 -15
  324. data/ext/pg_query/include/postgres/storage/s_lock.h +7 -27
  325. data/ext/pg_query/include/postgres/storage/sharedfileset.h +1 -1
  326. data/ext/pg_query/include/postgres/storage/shm_mq.h +2 -2
  327. data/ext/pg_query/include/postgres/storage/shm_toc.h +1 -1
  328. data/ext/pg_query/include/postgres/storage/shmem.h +1 -1
  329. data/ext/pg_query/include/postgres/storage/sinval.h +3 -3
  330. data/ext/pg_query/include/postgres/storage/smgr.h +41 -27
  331. data/ext/pg_query/include/postgres/storage/spin.h +1 -1
  332. data/ext/pg_query/include/postgres/storage/standby.h +13 -3
  333. data/ext/pg_query/include/postgres/storage/standbydefs.h +2 -2
  334. data/ext/pg_query/include/postgres/storage/sync.h +4 -4
  335. data/ext/pg_query/include/postgres/tcop/cmdtag.h +1 -2
  336. data/ext/pg_query/include/postgres/tcop/cmdtaglist.h +3 -2
  337. data/ext/pg_query/include/postgres/tcop/deparse_utility.h +2 -2
  338. data/ext/pg_query/include/postgres/tcop/dest.h +3 -2
  339. data/ext/pg_query/include/postgres/tcop/fastpath.h +1 -1
  340. data/ext/pg_query/include/postgres/tcop/pquery.h +1 -1
  341. data/ext/pg_query/include/postgres/tcop/tcopprot.h +9 -5
  342. data/ext/pg_query/include/postgres/tcop/utility.h +2 -2
  343. data/ext/pg_query/include/postgres/tsearch/ts_cache.h +1 -1
  344. data/ext/pg_query/include/postgres/utils/acl.h +19 -7
  345. data/ext/pg_query/include/postgres/utils/aclchk_internal.h +1 -1
  346. data/ext/pg_query/include/postgres/utils/array.h +1 -2
  347. data/ext/pg_query/include/postgres/utils/ascii.h +84 -0
  348. data/ext/pg_query/include/postgres/utils/backend_progress.h +3 -2
  349. data/ext/pg_query/include/postgres/utils/backend_status.h +8 -10
  350. data/ext/pg_query/include/postgres/utils/builtins.h +4 -1
  351. data/ext/pg_query/include/postgres/utils/bytea.h +2 -2
  352. data/ext/pg_query/include/postgres/utils/catcache.h +5 -6
  353. data/ext/pg_query/include/postgres/utils/date.h +1 -1
  354. data/ext/pg_query/include/postgres/utils/datetime.h +4 -1
  355. data/ext/pg_query/include/postgres/utils/datum.h +1 -1
  356. data/ext/pg_query/include/postgres/utils/dsa.h +44 -5
  357. data/ext/pg_query/include/postgres/utils/elog.h +3 -8
  358. data/ext/pg_query/include/postgres/utils/errcodes.h +1 -3
  359. data/ext/pg_query/include/postgres/utils/expandeddatum.h +1 -1
  360. data/ext/pg_query/include/postgres/utils/expandedrecord.h +1 -1
  361. data/ext/pg_query/include/postgres/utils/float.h +1 -1
  362. data/ext/pg_query/include/postgres/utils/fmgroids.h +49 -16
  363. data/ext/pg_query/include/postgres/utils/fmgrprotos.h +47 -14
  364. data/ext/pg_query/include/postgres/utils/fmgrtab.h +1 -1
  365. data/ext/pg_query/include/postgres/utils/guc.h +20 -6
  366. data/ext/pg_query/include/postgres/utils/guc_hooks.h +23 -2
  367. data/ext/pg_query/include/postgres/utils/guc_tables.h +6 -5
  368. data/ext/pg_query/include/postgres/utils/hsearch.h +2 -2
  369. data/ext/pg_query/include/postgres/utils/injection_point.h +44 -0
  370. data/ext/pg_query/include/postgres/utils/inval.h +1 -1
  371. data/ext/pg_query/include/postgres/utils/logtape.h +5 -5
  372. data/ext/pg_query/include/postgres/utils/lsyscache.h +6 -3
  373. data/ext/pg_query/include/postgres/utils/memdebug.h +1 -1
  374. data/ext/pg_query/include/postgres/utils/memutils.h +12 -5
  375. data/ext/pg_query/include/postgres/utils/memutils_internal.h +53 -13
  376. data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +25 -9
  377. data/ext/pg_query/include/postgres/utils/numeric.h +6 -1
  378. data/ext/pg_query/include/postgres/utils/palloc.h +1 -15
  379. data/ext/pg_query/include/postgres/utils/partcache.h +1 -1
  380. data/ext/pg_query/include/postgres/utils/pg_locale.h +8 -7
  381. data/ext/pg_query/include/postgres/utils/pgstat_internal.h +11 -17
  382. data/ext/pg_query/include/postgres/utils/plancache.h +5 -3
  383. data/ext/pg_query/include/postgres/utils/portal.h +9 -9
  384. data/ext/pg_query/include/postgres/utils/queryenvironment.h +2 -2
  385. data/ext/pg_query/include/postgres/utils/regproc.h +1 -1
  386. data/ext/pg_query/include/postgres/utils/rel.h +14 -15
  387. data/ext/pg_query/include/postgres/utils/relcache.h +2 -5
  388. data/ext/pg_query/include/postgres/utils/reltrigger.h +1 -1
  389. data/ext/pg_query/include/postgres/utils/resowner.h +90 -9
  390. data/ext/pg_query/include/postgres/utils/ruleutils.h +1 -1
  391. data/ext/pg_query/include/postgres/utils/sharedtuplestore.h +1 -1
  392. data/ext/pg_query/include/postgres/utils/snapmgr.h +1 -52
  393. data/ext/pg_query/include/postgres/utils/snapshot.h +2 -2
  394. data/ext/pg_query/include/postgres/utils/sortsupport.h +1 -1
  395. data/ext/pg_query/include/postgres/utils/syscache.h +2 -98
  396. data/ext/pg_query/include/postgres/utils/timeout.h +3 -2
  397. data/ext/pg_query/include/postgres/utils/timestamp.h +1 -1
  398. data/ext/pg_query/include/postgres/utils/tuplesort.h +36 -9
  399. data/ext/pg_query/include/postgres/utils/tuplestore.h +2 -5
  400. data/ext/pg_query/include/postgres/utils/typcache.h +2 -1
  401. data/ext/pg_query/include/postgres/utils/varlena.h +1 -1
  402. data/ext/pg_query/include/postgres/utils/wait_event.h +28 -214
  403. data/ext/pg_query/include/postgres/utils/wait_event_types.h +218 -0
  404. data/ext/pg_query/include/postgres/utils/xml.h +4 -4
  405. data/ext/pg_query/include/postgres/varatt.h +1 -1
  406. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1546 -792
  407. data/ext/pg_query/include/protobuf/pg_query.pb.h +58365 -46595
  408. data/ext/pg_query/pg_query.pb-c.c +6598 -3739
  409. data/ext/pg_query/pg_query_normalize.c +42 -1
  410. data/ext/pg_query/pg_query_outfuncs_json.c +3 -1
  411. data/ext/pg_query/pg_query_parse_plpgsql.c +12 -13
  412. data/ext/pg_query/pg_query_readfuncs_protobuf.c +2 -2
  413. data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -1
  414. data/ext/pg_query/pg_query_scan.c +1 -1
  415. data/ext/pg_query/postgres_deparse.c +409 -21
  416. data/ext/pg_query/src_backend_catalog_namespace.c +241 -66
  417. data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -3
  418. data/ext/pg_query/src_backend_commands_define.c +2 -3
  419. data/ext/pg_query/src_backend_nodes_bitmapset.c +137 -94
  420. data/ext/pg_query/src_backend_nodes_copyfuncs.c +1 -1
  421. data/ext/pg_query/src_backend_nodes_equalfuncs.c +1 -1
  422. data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
  423. data/ext/pg_query/src_backend_nodes_list.c +3 -7
  424. data/ext/pg_query/src_backend_nodes_makefuncs.c +59 -20
  425. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +109 -2
  426. data/ext/pg_query/src_backend_nodes_value.c +1 -1
  427. data/ext/pg_query/src_backend_parser_gram.c +34490 -32135
  428. data/ext/pg_query/src_backend_parser_parser.c +8 -8
  429. data/ext/pg_query/src_backend_parser_scan.c +5637 -3028
  430. data/ext/pg_query/src_backend_parser_scansup.c +2 -1
  431. data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
  432. data/ext/pg_query/src_backend_tcop_postgres.c +34 -10
  433. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +2 -2
  434. data/ext/pg_query/src_backend_utils_adt_datum.c +8 -6
  435. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  436. data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
  437. data/ext/pg_query/src_backend_utils_adt_numutils.c +4 -5
  438. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +101 -28
  439. data/ext/pg_query/src_backend_utils_error_assert.c +1 -1
  440. data/ext/pg_query/src_backend_utils_error_elog.c +47 -42
  441. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +4 -2
  442. data/ext/pg_query/src_backend_utils_init_globals.c +15 -3
  443. data/ext/pg_query/src_backend_utils_mb_mbutils.c +11 -18
  444. data/ext/pg_query/src_backend_utils_misc_guc_tables.c +16 -6
  445. data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +8 -5
  446. data/ext/pg_query/src_backend_utils_mmgr_aset.c +308 -238
  447. data/ext/pg_query/src_backend_utils_mmgr_bump.c +728 -0
  448. data/ext/pg_query/src_backend_utils_mmgr_generation.c +273 -197
  449. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +270 -215
  450. data/ext/pg_query/src_backend_utils_mmgr_slab.c +154 -96
  451. data/ext/pg_query/src_common_encnames.c +43 -44
  452. data/ext/pg_query/src_common_hashfn.c +1 -1
  453. data/ext/pg_query/src_common_keywords.c +1 -1
  454. data/ext/pg_query/src_common_kwlist_d.h +511 -466
  455. data/ext/pg_query/src_common_kwlookup.c +1 -1
  456. data/ext/pg_query/src_common_psprintf.c +3 -3
  457. data/ext/pg_query/src_common_stringinfo.c +18 -1
  458. data/ext/pg_query/src_common_wchar.c +45 -108
  459. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +99 -5
  460. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -1
  461. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +242 -143
  462. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  463. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +1 -1
  464. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +19 -1
  465. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +1 -1
  466. data/ext/pg_query/src_port_pg_bitutils.c +173 -28
  467. data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
  468. data/ext/pg_query/src_port_snprintf.c +1 -1
  469. data/ext/pg_query/src_port_strerror.c +1 -3
  470. data/ext/pg_query/src_port_strlcpy.c +1 -1
  471. data/lib/pg_query/param_refs.rb +1 -1
  472. data/lib/pg_query/pg_query_pb.rb +26 -3
  473. data/lib/pg_query/treewalker.rb +38 -11
  474. data/lib/pg_query/truncate.rb +1 -1
  475. data/lib/pg_query/version.rb +1 -1
  476. metadata +25 -11
  477. data/ext/pg_query/include/postgres/storage/backendid.h +0 -37
  478. data/ext/pg_query/include/postgres/storage/sinvaladt.h +0 -45
  479. data/ext/pg_query/src_backend_nodes_nodes.c +0 -38
@@ -3,7 +3,7 @@
3
3
  * dshash.h
4
4
  * Concurrent hash tables backed by dynamic shared memory areas.
5
5
  *
6
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
6
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7
7
  * Portions Copyright (c) 1994, Regents of the University of California
8
8
  *
9
9
  * IDENTIFICATION
@@ -37,17 +37,19 @@ typedef int (*dshash_compare_function) (const void *a, const void *b,
37
37
  typedef dshash_hash (*dshash_hash_function) (const void *v, size_t size,
38
38
  void *arg);
39
39
 
40
+ /* A function type for copying keys. */
41
+ typedef void (*dshash_copy_function) (void *dest, const void *src, size_t size,
42
+ void *arg);
43
+
40
44
  /*
41
45
  * The set of parameters needed to create or attach to a hash table. The
42
- * members tranche_id and tranche_name do not need to be initialized when
43
- * attaching to an existing hash table.
46
+ * tranche_id member does not need to be initialized when attaching to an
47
+ * existing hash table.
44
48
  *
45
- * Compare and hash functions must be supplied even when attaching, because we
46
- * can't safely share function pointers between backends in general. Either
47
- * the arg variants or the non-arg variants should be supplied; the other
48
- * function pointers should be NULL. If the arg variants are supplied then the
49
- * user data pointer supplied to the create and attach functions will be
50
- * passed to the hash and compare functions.
49
+ * Compare, hash, and copy functions must be supplied even when attaching,
50
+ * because we can't safely share function pointers between backends in general.
51
+ * The user data pointer supplied to the create and attach functions will be
52
+ * passed to these functions.
51
53
  */
52
54
  typedef struct dshash_parameters
53
55
  {
@@ -55,6 +57,7 @@ typedef struct dshash_parameters
55
57
  size_t entry_size; /* Total size of entry */
56
58
  dshash_compare_function compare_function; /* Compare function */
57
59
  dshash_hash_function hash_function; /* Hash function */
60
+ dshash_copy_function copy_function; /* Copy function */
58
61
  int tranche_id; /* The tranche ID to use for locks */
59
62
  } dshash_parameters;
60
63
 
@@ -105,9 +108,21 @@ extern void *dshash_seq_next(dshash_seq_status *status);
105
108
  extern void dshash_seq_term(dshash_seq_status *status);
106
109
  extern void dshash_delete_current(dshash_seq_status *status);
107
110
 
108
- /* Convenience hash and compare functions wrapping memcmp and tag_hash. */
111
+ /*
112
+ * Convenience hash, compare, and copy functions wrapping memcmp, tag_hash, and
113
+ * memcpy.
114
+ */
109
115
  extern int dshash_memcmp(const void *a, const void *b, size_t size, void *arg);
110
116
  extern dshash_hash dshash_memhash(const void *v, size_t size, void *arg);
117
+ extern void dshash_memcpy(void *dest, const void *src, size_t size, void *arg);
118
+
119
+ /*
120
+ * Convenience hash, compare, and copy functions wrapping strcmp, string_hash,
121
+ * and strcpy.
122
+ */
123
+ extern int dshash_strcmp(const void *a, const void *b, size_t size, void *arg);
124
+ extern dshash_hash dshash_strhash(const void *v, size_t size, void *arg);
125
+ extern void dshash_strcpy(void *dest, const void *src, size_t size, void *arg);
111
126
 
112
127
  /* Debugging support. */
113
128
  extern void dshash_dump(dshash_table *hash_table);
@@ -112,7 +112,7 @@
112
112
  * }
113
113
  *
114
114
  *
115
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
115
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
116
116
  * Portions Copyright (c) 1994, Regents of the University of California
117
117
  *
118
118
  * IDENTIFICATION
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A Pairing Heap implementation
5
5
  *
6
- * Portions Copyright (c) 2012-2023, PostgreSQL Global Development Group
6
+ * Portions Copyright (c) 2012-2024, PostgreSQL Global Development Group
7
7
  *
8
8
  * src/include/lib/pairingheap.h
9
9
  */
@@ -87,7 +87,7 @@
87
87
  * looking or is done - buckets following a deleted element are shifted
88
88
  * backwards, unless they're empty or already at their optimal position.
89
89
  *
90
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
90
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
91
91
  * Portions Copyright (c) 1994, Regents of the University of California
92
92
  *
93
93
  * src/include/lib/simplehash.h
@@ -128,7 +128,8 @@
128
128
  #define SH_STAT SH_MAKE_NAME(stat)
129
129
 
130
130
  /* internal helper functions (no externally visible prototypes) */
131
- #define SH_COMPUTE_PARAMETERS SH_MAKE_NAME(compute_parameters)
131
+ #define SH_COMPUTE_SIZE SH_MAKE_NAME(compute_size)
132
+ #define SH_UPDATE_PARAMETERS SH_MAKE_NAME(update_parameters)
132
133
  #define SH_NEXT SH_MAKE_NAME(next)
133
134
  #define SH_PREV SH_MAKE_NAME(prev)
134
135
  #define SH_DISTANCE_FROM_OPTIMAL SH_MAKE_NAME(distance)
@@ -303,11 +304,11 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
303
304
  #endif
304
305
 
305
306
  /*
306
- * Compute sizing parameters for hashtable. Called when creating and growing
307
- * the hashtable.
307
+ * Compute allocation size for hashtable. Result can be passed to
308
+ * SH_UPDATE_PARAMETERS.
308
309
  */
309
- static inline void
310
- SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint64 newsize)
310
+ static inline uint64
311
+ SH_COMPUTE_SIZE(uint64 newsize)
311
312
  {
312
313
  uint64 size;
313
314
 
@@ -325,6 +326,18 @@ SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint64 newsize)
325
326
  if (unlikely((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2))
326
327
  sh_error("hash table too large");
327
328
 
329
+ return size;
330
+ }
331
+
332
+ /*
333
+ * Update sizing parameters for hashtable. Called when creating and growing
334
+ * the hashtable.
335
+ */
336
+ static inline void
337
+ SH_UPDATE_PARAMETERS(SH_TYPE * tb, uint64 newsize)
338
+ {
339
+ uint64 size = SH_COMPUTE_SIZE(newsize);
340
+
328
341
  /* now set size */
329
342
  tb->size = size;
330
343
  tb->sizemask = (uint32) (size - 1);
@@ -446,10 +459,11 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
446
459
  /* increase nelements by fillfactor, want to store nelements elements */
447
460
  size = Min((double) SH_MAX_SIZE, ((double) nelements) / SH_FILLFACTOR);
448
461
 
449
- SH_COMPUTE_PARAMETERS(tb, size);
462
+ size = SH_COMPUTE_SIZE(size);
450
463
 
451
- tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
464
+ tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * size);
452
465
 
466
+ SH_UPDATE_PARAMETERS(tb, size);
453
467
  return tb;
454
468
  }
455
469
 
@@ -490,10 +504,15 @@ SH_GROW(SH_TYPE * tb, uint64 newsize)
490
504
  Assert(oldsize != SH_MAX_SIZE);
491
505
  Assert(oldsize < newsize);
492
506
 
493
- /* compute parameters for new table */
494
- SH_COMPUTE_PARAMETERS(tb, newsize);
507
+ newsize = SH_COMPUTE_SIZE(newsize);
495
508
 
496
- tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
509
+ tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * newsize);
510
+
511
+ /*
512
+ * Update parameters for new table after allocation succeeds to avoid
513
+ * inconsistent state on OOM.
514
+ */
515
+ SH_UPDATE_PARAMETERS(tb, newsize);
497
516
 
498
517
  newdata = tb->data;
499
518
 
@@ -751,9 +770,8 @@ restart:
751
770
  }
752
771
 
753
772
  /*
754
- * Insert the key key into the hash-table, set *found to true if the key
755
- * already exists, false otherwise. Returns the hash-table entry in either
756
- * case.
773
+ * Insert the key into the hash-table, set *found to true if the key already
774
+ * exists, false otherwise. Returns the hash-table entry in either case.
757
775
  */
758
776
  SH_SCOPE SH_ELEMENT_TYPE *
759
777
  SH_INSERT(SH_TYPE * tb, SH_KEY_TYPE key, bool *found)
@@ -764,9 +782,9 @@ SH_INSERT(SH_TYPE * tb, SH_KEY_TYPE key, bool *found)
764
782
  }
765
783
 
766
784
  /*
767
- * Insert the key key into the hash-table using an already-calculated
768
- * hash. Set *found to true if the key already exists, false
769
- * otherwise. Returns the hash-table entry in either case.
785
+ * Insert the key into the hash-table using an already-calculated hash. Set
786
+ * *found to true if the key already exists, false otherwise. Returns the
787
+ * hash-table entry in either case.
770
788
  */
771
789
  SH_SCOPE SH_ELEMENT_TYPE *
772
790
  SH_INSERT_HASH(SH_TYPE * tb, SH_KEY_TYPE key, uint32 hash, bool *found)
@@ -1101,6 +1119,9 @@ SH_STAT(SH_TYPE * tb)
1101
1119
  max_collisions = curcoll;
1102
1120
  }
1103
1121
 
1122
+ /* large enough to be worth freeing, even if just used for debugging */
1123
+ pfree(collisions);
1124
+
1104
1125
  if (tb->members > 0)
1105
1126
  {
1106
1127
  fillfactor = tb->members / ((double) tb->size);
@@ -1173,7 +1194,8 @@ SH_STAT(SH_TYPE * tb)
1173
1194
  #undef SH_STAT
1174
1195
 
1175
1196
  /* internal function names */
1176
- #undef SH_COMPUTE_PARAMETERS
1197
+ #undef SH_COMPUTE_SIZE
1198
+ #undef SH_UPDATE_PARAMETERS
1177
1199
  #undef SH_COMPARE_KEYS
1178
1200
  #undef SH_INITIAL_BUCKET
1179
1201
  #undef SH_NEXT
@@ -5,7 +5,7 @@
5
5
  * A template for a sort algorithm that supports varying degrees of
6
6
  * specialization.
7
7
  *
8
- * Copyright (c) 2021-2023, PostgreSQL Global Development Group
8
+ * Copyright (c) 2021-2024, PostgreSQL Global Development Group
9
9
  * Portions Copyright (c) 1992-1994, Regents of the University of California
10
10
  *
11
11
  * Usage notes:
@@ -34,6 +34,16 @@
34
34
  * - ST_COMPARE(a, b, arg) - variant that takes an extra argument
35
35
  * - ST_COMPARE_RUNTIME_POINTER - sort function takes a function pointer
36
36
  *
37
+ * NB: If the comparator function is inlined, some compilers may produce
38
+ * worse code with the optimized comparison routines in common/int.h than
39
+ * with code with the following form:
40
+ *
41
+ * if (a < b)
42
+ * return -1;
43
+ * if (a > b)
44
+ * return 1;
45
+ * return 0;
46
+ *
37
47
  * To say that the comparator and therefore also sort function should
38
48
  * receive an extra pass-through argument, specify the type of the
39
49
  * argument.
@@ -243,6 +253,9 @@ ST_SCOPE void ST_SORT(ST_ELEMENT_TYPE * first, size_t n
243
253
  * Find the median of three values. Currently, performance seems to be best
244
254
  * if the comparator is inlined here, but the med3 function is not inlined
245
255
  * in the qsort function.
256
+ *
257
+ * Refer to the comment at the top of this file for known caveats to consider
258
+ * when writing inlined comparator functions.
246
259
  */
247
260
  static pg_noinline ST_ELEMENT_TYPE *
248
261
  ST_MED3(ST_ELEMENT_TYPE * a,
@@ -8,7 +8,7 @@
8
8
  * (null-terminated text) or arbitrary binary data. All storage is allocated
9
9
  * with palloc() (falling back to malloc in frontend code).
10
10
  *
11
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
11
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
12
12
  * Portions Copyright (c) 1994, Regents of the University of California
13
13
  *
14
14
  * src/include/lib/stringinfo.h
@@ -20,17 +20,27 @@
20
20
 
21
21
  /*-------------------------
22
22
  * StringInfoData holds information about an extensible string.
23
- * data is the current buffer for the string (allocated with palloc).
24
- * len is the current string length. There is guaranteed to be
25
- * a terminating '\0' at data[len], although this is not very
26
- * useful when the string holds binary data rather than text.
23
+ * data is the current buffer for the string.
24
+ * len is the current string length. Except in the case of read-only
25
+ * strings described below, there is guaranteed to be a
26
+ * terminating '\0' at data[len].
27
27
  * maxlen is the allocated size in bytes of 'data', i.e. the maximum
28
28
  * string size (including the terminating '\0' char) that we can
29
29
  * currently store in 'data' without having to reallocate
30
- * more space. We must always have maxlen > len.
31
- * cursor is initialized to zero by makeStringInfo or initStringInfo,
32
- * but is not otherwise touched by the stringinfo.c routines.
33
- * Some routines use it to scan through a StringInfo.
30
+ * more space. We must always have maxlen > len, except
31
+ * in the read-only case described below.
32
+ * cursor is initialized to zero by makeStringInfo, initStringInfo,
33
+ * initReadOnlyStringInfo and initStringInfoFromString but is not
34
+ * otherwise touched by the stringinfo.c routines. Some routines
35
+ * use it to scan through a StringInfo.
36
+ *
37
+ * As a special case, a StringInfoData can be initialized with a read-only
38
+ * string buffer. In this case "data" does not necessarily point at a
39
+ * palloc'd chunk, and management of the buffer storage is the caller's
40
+ * responsibility. maxlen is set to zero to indicate that this is the case.
41
+ * Read-only StringInfoDatas cannot be appended to or reset.
42
+ * Also, it is caller's option whether a read-only string buffer has a
43
+ * terminating '\0' or not. This depends on the intended usage.
34
44
  *-------------------------
35
45
  */
36
46
  typedef struct StringInfoData
@@ -45,7 +55,7 @@ typedef StringInfoData *StringInfo;
45
55
 
46
56
 
47
57
  /*------------------------
48
- * There are two ways to create a StringInfo object initially:
58
+ * There are four ways to create a StringInfo object initially:
49
59
  *
50
60
  * StringInfo stringptr = makeStringInfo();
51
61
  * Both the StringInfoData and the data buffer are palloc'd.
@@ -56,8 +66,32 @@ typedef StringInfoData *StringInfo;
56
66
  * This is the easiest approach for a StringInfo object that will
57
67
  * only live as long as the current routine.
58
68
  *
69
+ * StringInfoData string;
70
+ * initReadOnlyStringInfo(&string, existingbuf, len);
71
+ * The StringInfoData's data field is set to point directly to the
72
+ * existing buffer and the StringInfoData's len is set to the given len.
73
+ * The given buffer can point to memory that's not managed by palloc or
74
+ * is pointing partway through a palloc'd chunk. The maxlen field is set
75
+ * to 0. A read-only StringInfo cannot be appended to using any of the
76
+ * appendStringInfo functions or reset with resetStringInfo(). The given
77
+ * buffer can optionally omit the trailing NUL.
78
+ *
79
+ * StringInfoData string;
80
+ * initStringInfoFromString(&string, palloced_buf, len);
81
+ * The StringInfoData's data field is set to point directly to the given
82
+ * buffer and the StringInfoData's len is set to the given len. This
83
+ * method of initialization is useful when the buffer already exists.
84
+ * StringInfos initialized this way can be appended to using the
85
+ * appendStringInfo functions and reset with resetStringInfo(). The
86
+ * given buffer must be NUL-terminated. The palloc'd buffer is assumed
87
+ * to be len + 1 in size.
88
+ *
59
89
  * To destroy a StringInfo, pfree() the data buffer, and then pfree() the
60
- * StringInfoData if it was palloc'd. There's no special support for this.
90
+ * StringInfoData if it was palloc'd. For StringInfos created with
91
+ * makeStringInfo(), destroyStringInfo() is provided for this purpose.
92
+ * However, if the StringInfo was initialized using initReadOnlyStringInfo()
93
+ * then the caller will need to consider if it is safe to pfree the data
94
+ * buffer.
61
95
  *
62
96
  * NOTE: some routines build up a string using StringInfo, and then
63
97
  * release the StringInfoData but return the data string itself to their
@@ -79,6 +113,48 @@ extern StringInfo makeStringInfo(void);
79
113
  */
80
114
  extern void initStringInfo(StringInfo str);
81
115
 
116
+ /*------------------------
117
+ * initReadOnlyStringInfo
118
+ * Initialize a StringInfoData struct from an existing string without copying
119
+ * the string. The caller is responsible for ensuring the given string
120
+ * remains valid as long as the StringInfoData does. Calls to this are used
121
+ * in performance critical locations where allocating a new buffer and copying
122
+ * would be too costly. Read-only StringInfoData's may not be appended to
123
+ * using any of the appendStringInfo functions or reset with
124
+ * resetStringInfo().
125
+ *
126
+ * 'data' does not need to point directly to a palloc'd chunk of memory and may
127
+ * omit the NUL termination character at data[len].
128
+ */
129
+ static inline void
130
+ initReadOnlyStringInfo(StringInfo str, char *data, int len)
131
+ {
132
+ str->data = data;
133
+ str->len = len;
134
+ str->maxlen = 0; /* read-only */
135
+ str->cursor = 0;
136
+ }
137
+
138
+ /*------------------------
139
+ * initStringInfoFromString
140
+ * Initialize a StringInfoData struct from an existing string without copying
141
+ * the string. 'data' must be a valid palloc'd chunk of memory that can have
142
+ * repalloc() called should more space be required during a call to any of the
143
+ * appendStringInfo functions.
144
+ *
145
+ * 'data' must be NUL terminated at 'len' bytes.
146
+ */
147
+ static inline void
148
+ initStringInfoFromString(StringInfo str, char *data, int len)
149
+ {
150
+ Assert(data[len] == '\0');
151
+
152
+ str->data = data;
153
+ str->len = len;
154
+ str->maxlen = len + 1;
155
+ str->cursor = 0;
156
+ }
157
+
82
158
  /*------------------------
83
159
  * resetStringInfo
84
160
  * Clears the current content of the StringInfo, if any. The
@@ -158,4 +234,10 @@ extern void appendBinaryStringInfoNT(StringInfo str,
158
234
  */
159
235
  extern void enlargeStringInfo(StringInfo str, int needed);
160
236
 
237
+ /*------------------------
238
+ * destroyStringInfo
239
+ * Frees a StringInfo and its buffer (opposite of makeStringInfo()).
240
+ */
241
+ extern void destroyStringInfo(StringInfo str);
242
+
161
243
  #endif /* STRINGINFO_H */
@@ -4,7 +4,7 @@
4
4
  * Definitions for network authentication routines
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/libpq/auth.h
@@ -3,7 +3,7 @@
3
3
  * crypt.h
4
4
  * Interface to libpq/crypt.c
5
5
  *
6
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
6
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7
7
  * Portions Copyright (c) 1994, Regents of the University of California
8
8
  *
9
9
  * src/include/libpq/crypt.h
@@ -28,7 +28,7 @@ typedef enum PasswordType
28
28
  {
29
29
  PASSWORD_TYPE_PLAINTEXT = 0,
30
30
  PASSWORD_TYPE_MD5,
31
- PASSWORD_TYPE_SCRAM_SHA_256
31
+ PASSWORD_TYPE_SCRAM_SHA_256,
32
32
  } PasswordType;
33
33
 
34
34
  extern PasswordType get_password_type(const char *shadow_pass);
@@ -38,7 +38,7 @@ typedef enum UserAuth
38
38
  uaLDAP,
39
39
  uaCert,
40
40
  uaRADIUS,
41
- uaPeer
41
+ uaPeer,
42
42
  #define USER_AUTH_LAST uaPeer /* Must be last value of this enum */
43
43
  } UserAuth;
44
44
 
@@ -51,7 +51,7 @@ typedef enum IPCompareMethod
51
51
  ipCmpMask,
52
52
  ipCmpSameHost,
53
53
  ipCmpSameNet,
54
- ipCmpAll
54
+ ipCmpAll,
55
55
  } IPCompareMethod;
56
56
 
57
57
  typedef enum ConnType
@@ -68,13 +68,13 @@ typedef enum ClientCertMode
68
68
  {
69
69
  clientCertOff,
70
70
  clientCertCA,
71
- clientCertFull
71
+ clientCertFull,
72
72
  } ClientCertMode;
73
73
 
74
74
  typedef enum ClientCertName
75
75
  {
76
76
  clientCertCN,
77
- clientCertDN
77
+ clientCertDN,
78
78
  } ClientCertName;
79
79
 
80
80
  /*
@@ -8,7 +8,7 @@
8
8
  * Structs that need to be client-visible are in pqcomm.h.
9
9
  *
10
10
  *
11
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
11
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
12
12
  * Portions Copyright (c) 1994, Regents of the University of California
13
13
  *
14
14
  * src/include/libpq/libpq-be.h
@@ -58,17 +58,6 @@ typedef struct
58
58
  #include "libpq/pqcomm.h"
59
59
 
60
60
 
61
- typedef enum CAC_state
62
- {
63
- CAC_OK,
64
- CAC_STARTUP,
65
- CAC_SHUTDOWN,
66
- CAC_RECOVERY,
67
- CAC_NOTCONSISTENT,
68
- CAC_TOOMANY
69
- } CAC_state;
70
-
71
-
72
61
  /*
73
62
  * GSSAPI specific state information
74
63
  */
@@ -121,12 +110,9 @@ typedef struct ClientConnectionInfo
121
110
  } ClientConnectionInfo;
122
111
 
123
112
  /*
124
- * This is used by the postmaster in its communication with frontends. It
125
- * contains all state information needed during this communication before the
126
- * backend is run. The Port structure is kept in malloc'd memory and is
127
- * still available when a backend is running (see MyProcPort). The data
128
- * it points to must also be malloc'd, or else palloc'd in TopMemoryContext,
129
- * so that it survives into PostgresMain execution!
113
+ * The Port structure holds state information about a client connection in a
114
+ * backend process. It is available in the global variable MyProcPort. The
115
+ * struct and all the data it points are kept in TopMemoryContext.
130
116
  *
131
117
  * remote_hostname is set if we did a successful reverse lookup of the
132
118
  * client's IP address during connection setup.
@@ -156,7 +142,6 @@ typedef struct Port
156
142
  int remote_hostname_resolv; /* see above */
157
143
  int remote_hostname_errcode; /* see above */
158
144
  char *remote_port; /* text rep of remote port */
159
- CAC_state canAcceptConnections; /* postmaster connection status */
160
145
 
161
146
  /*
162
147
  * Information that needs to be saved from the startup packet and passed
@@ -218,6 +203,7 @@ typedef struct Port
218
203
  char *peer_cn;
219
204
  char *peer_dn;
220
205
  bool peer_cert_valid;
206
+ bool alpn_used;
221
207
 
222
208
  /*
223
209
  * OpenSSL structures. (Keep these last so that the locations of other
@@ -227,8 +213,32 @@ typedef struct Port
227
213
  SSL *ssl;
228
214
  X509 *peer;
229
215
  #endif
216
+
217
+ /*
218
+ * This is a bit of a hack. raw_buf is data that was previously read and
219
+ * buffered in a higher layer but then "unread" and needs to be read again
220
+ * while establishing an SSL connection via the SSL library layer.
221
+ *
222
+ * There's no API to "unread", the upper layer just places the data in the
223
+ * Port structure in raw_buf and sets raw_buf_remaining to the amount of
224
+ * bytes unread and raw_buf_consumed to 0.
225
+ */
226
+ char *raw_buf;
227
+ ssize_t raw_buf_consumed,
228
+ raw_buf_remaining;
230
229
  } Port;
231
230
 
231
+ /*
232
+ * ClientSocket holds a socket for an accepted connection, along with the
233
+ * information about the remote endpoint. This is passed from postmaster to
234
+ * the backend process.
235
+ */
236
+ typedef struct ClientSocket
237
+ {
238
+ pgsocket sock; /* File descriptor */
239
+ SockAddr raddr; /* remote addr (client) */
240
+ } ClientSocket;
241
+
232
242
  #ifdef USE_SSL
233
243
  /*
234
244
  * Hardcoded DH parameters, used in ephemeral DH keying. (See also
@@ -305,14 +315,8 @@ extern void be_tls_get_peer_serial(Port *port, char *ptr, size_t len);
305
315
  *
306
316
  * The result is a palloc'd hash of the server certificate with its
307
317
  * size, and NULL if there is no certificate available.
308
- *
309
- * This is not supported with old versions of OpenSSL that don't have
310
- * the X509_get_signature_nid() function.
311
318
  */
312
- #if defined(USE_OPENSSL) && (defined(HAVE_X509_GET_SIGNATURE_NID) || defined(HAVE_X509_GET_SIGNATURE_INFO))
313
- #define HAVE_BE_TLS_GET_CERTIFICATE_HASH
314
319
  extern char *be_tls_get_certificate_hash(Port *port, size_t *len);
315
- #endif
316
320
 
317
321
  /* init hook for SSL, the default sets the password callback if appropriate */
318
322
  #ifdef USE_OPENSSL
@@ -4,7 +4,7 @@
4
4
  * POSTGRES LIBPQ buffer structure definitions.
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/libpq/libpq.h
@@ -64,14 +64,13 @@ extern PGDLLIMPORT WaitEventSet *FeBeWaitSet;
64
64
  #define FeBeWaitSetLatchPos 1
65
65
  #define FeBeWaitSetNEvents 3
66
66
 
67
- extern int StreamServerPort(int family, const char *hostName,
67
+ extern int ListenServerPort(int family, const char *hostName,
68
68
  unsigned short portNumber, const char *unixSocketDir,
69
- pgsocket ListenSocket[], int MaxListen);
70
- extern int StreamConnection(pgsocket server_fd, Port *port);
71
- extern void StreamClose(pgsocket sock);
69
+ pgsocket ListenSockets[], int *NumListenSockets, int MaxListen);
70
+ extern int AcceptConnection(pgsocket server_fd, ClientSocket *client_sock);
72
71
  extern void TouchSocketFiles(void);
73
72
  extern void RemoveSocketFiles(void);
74
- extern void pq_init(void);
73
+ extern Port *pq_init(ClientSocket *client_sock);
75
74
  extern int pq_getbytes(char *s, size_t len);
76
75
  extern void pq_startmsgread(void);
77
76
  extern void pq_endmsgread(void);
@@ -80,7 +79,7 @@ extern int pq_getmessage(StringInfo s, int maxlen);
80
79
  extern int pq_getbyte(void);
81
80
  extern int pq_peekbyte(void);
82
81
  extern int pq_getbyte_if_available(unsigned char *c);
83
- extern bool pq_buffer_has_data(void);
82
+ extern ssize_t pq_buffer_remaining_data(void);
84
83
  extern int pq_putmessage_v2(char msgtype, const char *s, size_t len);
85
84
  extern bool pq_check_connection(void);
86
85