pg_query 5.1.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (490) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/README.md +1 -1
  4. data/Rakefile +4 -4
  5. data/ext/pg_query/ext_symbols_freebsd.sym +1 -0
  6. data/ext/pg_query/ext_symbols_freebsd_with_ruby_abi_version.sym +2 -0
  7. data/ext/pg_query/ext_symbols_openbsd.sym +1 -0
  8. data/ext/pg_query/ext_symbols_openbsd_with_ruby_abi_version.sym +2 -0
  9. data/ext/pg_query/ext_symbols_with_ruby_abi_version.sym +2 -0
  10. data/ext/pg_query/extconf.rb +20 -6
  11. data/ext/pg_query/include/pg_query.h +4 -3
  12. data/ext/pg_query/include/pg_query_enum_defs.c +424 -154
  13. data/ext/pg_query/include/pg_query_fingerprint_conds.c +68 -4
  14. data/ext/pg_query/include/pg_query_fingerprint_defs.c +2952 -1845
  15. data/ext/pg_query/include/pg_query_outfuncs_conds.c +51 -3
  16. data/ext/pg_query/include/pg_query_outfuncs_defs.c +210 -23
  17. data/ext/pg_query/include/pg_query_readfuncs_conds.c +17 -1
  18. data/ext/pg_query/include/pg_query_readfuncs_defs.c +271 -52
  19. data/ext/pg_query/include/postgres/access/amapi.h +14 -3
  20. data/ext/pg_query/include/postgres/access/attmap.h +1 -1
  21. data/ext/pg_query/include/postgres/access/attnum.h +1 -1
  22. data/ext/pg_query/include/postgres/access/brin_internal.h +116 -0
  23. data/ext/pg_query/include/postgres/access/brin_tuple.h +112 -0
  24. data/ext/pg_query/include/postgres/access/clog.h +2 -3
  25. data/ext/pg_query/include/postgres/access/commit_ts.h +2 -3
  26. data/ext/pg_query/include/postgres/access/detoast.h +1 -1
  27. data/ext/pg_query/include/postgres/access/genam.h +17 -4
  28. data/ext/pg_query/include/postgres/access/gin.h +1 -1
  29. data/ext/pg_query/include/postgres/access/htup.h +1 -1
  30. data/ext/pg_query/include/postgres/access/htup_details.h +11 -11
  31. data/ext/pg_query/include/postgres/access/itup.h +3 -3
  32. data/ext/pg_query/include/postgres/access/parallel.h +1 -2
  33. data/ext/pg_query/include/postgres/access/printtup.h +1 -1
  34. data/ext/pg_query/include/postgres/access/relation.h +1 -1
  35. data/ext/pg_query/include/postgres/access/relscan.h +1 -1
  36. data/ext/pg_query/include/postgres/access/rmgrlist.h +1 -1
  37. data/ext/pg_query/include/postgres/access/sdir.h +1 -1
  38. data/ext/pg_query/include/postgres/access/skey.h +1 -1
  39. data/ext/pg_query/include/postgres/access/slru.h +218 -0
  40. data/ext/pg_query/include/postgres/access/stratnum.h +1 -1
  41. data/ext/pg_query/include/postgres/access/sysattr.h +1 -1
  42. data/ext/pg_query/include/postgres/access/table.h +1 -1
  43. data/ext/pg_query/include/postgres/access/tableam.h +35 -25
  44. data/ext/pg_query/include/postgres/access/tidstore.h +50 -0
  45. data/ext/pg_query/include/postgres/access/toast_compression.h +2 -2
  46. data/ext/pg_query/include/postgres/access/transam.h +50 -7
  47. data/ext/pg_query/include/postgres/access/tsmapi.h +1 -1
  48. data/ext/pg_query/include/postgres/access/tupconvert.h +1 -1
  49. data/ext/pg_query/include/postgres/access/tupdesc.h +5 -5
  50. data/ext/pg_query/include/postgres/access/tupmacs.h +1 -1
  51. data/ext/pg_query/include/postgres/access/twophase.h +2 -2
  52. data/ext/pg_query/include/postgres/access/xact.h +5 -5
  53. data/ext/pg_query/include/postgres/access/xlog.h +20 -12
  54. data/ext/pg_query/include/postgres/access/xlog_internal.h +4 -3
  55. data/ext/pg_query/include/postgres/access/xlogbackup.h +3 -1
  56. data/ext/pg_query/include/postgres/access/xlogdefs.h +5 -5
  57. data/ext/pg_query/include/postgres/access/xlogprefetcher.h +2 -2
  58. data/ext/pg_query/include/postgres/access/xlogreader.h +2 -2
  59. data/ext/pg_query/include/postgres/access/xlogrecord.h +3 -3
  60. data/ext/pg_query/include/postgres/access/xlogrecovery.h +4 -4
  61. data/ext/pg_query/include/postgres/archive/archive_module.h +9 -1
  62. data/ext/pg_query/include/postgres/c.h +32 -37
  63. data/ext/pg_query/include/postgres/catalog/catalog.h +3 -1
  64. data/ext/pg_query/include/postgres/catalog/catversion.h +2 -2
  65. data/ext/pg_query/include/postgres/catalog/dependency.h +17 -59
  66. data/ext/pg_query/include/postgres/catalog/genbki.h +12 -6
  67. data/ext/pg_query/include/postgres/catalog/index.h +22 -18
  68. data/ext/pg_query/include/postgres/catalog/indexing.h +1 -1
  69. data/ext/pg_query/include/postgres/catalog/namespace.h +18 -19
  70. data/ext/pg_query/include/postgres/catalog/objectaccess.h +2 -2
  71. data/ext/pg_query/include/postgres/catalog/objectaddress.h +5 -1
  72. data/ext/pg_query/include/postgres/catalog/pg_aggregate.h +4 -2
  73. data/ext/pg_query/include/postgres/catalog/pg_aggregate_d.h +1 -1
  74. data/ext/pg_query/include/postgres/catalog/pg_am.h +6 -3
  75. data/ext/pg_query/include/postgres/catalog/pg_am_d.h +1 -1
  76. data/ext/pg_query/include/postgres/catalog/pg_attribute.h +31 -14
  77. data/ext/pg_query/include/postgres/catalog/pg_attribute_d.h +3 -3
  78. data/ext/pg_query/include/postgres/catalog/pg_authid.h +6 -3
  79. data/ext/pg_query/include/postgres/catalog/pg_authid_d.h +2 -1
  80. data/ext/pg_query/include/postgres/catalog/pg_class.h +10 -5
  81. data/ext/pg_query/include/postgres/catalog/pg_class_d.h +4 -2
  82. data/ext/pg_query/include/postgres/catalog/pg_collation.h +11 -5
  83. data/ext/pg_query/include/postgres/catalog/pg_collation_d.h +5 -2
  84. data/ext/pg_query/include/postgres/catalog/pg_constraint.h +15 -10
  85. data/ext/pg_query/include/postgres/catalog/pg_constraint_d.h +2 -1
  86. data/ext/pg_query/include/postgres/catalog/pg_control.h +5 -3
  87. data/ext/pg_query/include/postgres/catalog/pg_conversion.h +8 -4
  88. data/ext/pg_query/include/postgres/catalog/pg_conversion_d.h +1 -1
  89. data/ext/pg_query/include/postgres/catalog/pg_database.h +9 -4
  90. data/ext/pg_query/include/postgres/catalog/pg_database_d.h +13 -12
  91. data/ext/pg_query/include/postgres/catalog/pg_depend.h +3 -3
  92. data/ext/pg_query/include/postgres/catalog/pg_depend_d.h +1 -1
  93. data/ext/pg_query/include/postgres/catalog/pg_event_trigger.h +6 -3
  94. data/ext/pg_query/include/postgres/catalog/pg_event_trigger_d.h +1 -1
  95. data/ext/pg_query/include/postgres/catalog/pg_index.h +5 -3
  96. data/ext/pg_query/include/postgres/catalog/pg_index_d.h +1 -1
  97. data/ext/pg_query/include/postgres/catalog/pg_language.h +6 -3
  98. data/ext/pg_query/include/postgres/catalog/pg_language_d.h +1 -1
  99. data/ext/pg_query/include/postgres/catalog/pg_namespace.h +6 -3
  100. data/ext/pg_query/include/postgres/catalog/pg_namespace_d.h +1 -1
  101. data/ext/pg_query/include/postgres/catalog/pg_opclass.h +6 -3
  102. data/ext/pg_query/include/postgres/catalog/pg_opclass_d.h +1 -1
  103. data/ext/pg_query/include/postgres/catalog/pg_operator.h +20 -3
  104. data/ext/pg_query/include/postgres/catalog/pg_operator_d.h +1 -1
  105. data/ext/pg_query/include/postgres/catalog/pg_opfamily.h +6 -3
  106. data/ext/pg_query/include/postgres/catalog/pg_opfamily_d.h +1 -1
  107. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table.h +4 -2
  108. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table_d.h +1 -1
  109. data/ext/pg_query/include/postgres/catalog/pg_proc.h +6 -3
  110. data/ext/pg_query/include/postgres/catalog/pg_proc_d.h +1 -1
  111. data/ext/pg_query/include/postgres/catalog/pg_publication.h +6 -3
  112. data/ext/pg_query/include/postgres/catalog/pg_publication_d.h +1 -1
  113. data/ext/pg_query/include/postgres/catalog/pg_replication_origin.h +6 -3
  114. data/ext/pg_query/include/postgres/catalog/pg_replication_origin_d.h +1 -1
  115. data/ext/pg_query/include/postgres/catalog/pg_statistic.h +10 -4
  116. data/ext/pg_query/include/postgres/catalog/pg_statistic_d.h +7 -3
  117. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext.h +10 -7
  118. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext_d.h +3 -3
  119. data/ext/pg_query/include/postgres/catalog/pg_transform.h +6 -3
  120. data/ext/pg_query/include/postgres/catalog/pg_transform_d.h +1 -1
  121. data/ext/pg_query/include/postgres/catalog/pg_trigger.h +4 -4
  122. data/ext/pg_query/include/postgres/catalog/pg_trigger_d.h +1 -1
  123. data/ext/pg_query/include/postgres/catalog/pg_ts_config.h +6 -3
  124. data/ext/pg_query/include/postgres/catalog/pg_ts_config_d.h +1 -1
  125. data/ext/pg_query/include/postgres/catalog/pg_ts_dict.h +6 -3
  126. data/ext/pg_query/include/postgres/catalog/pg_ts_dict_d.h +1 -1
  127. data/ext/pg_query/include/postgres/catalog/pg_ts_parser.h +6 -3
  128. data/ext/pg_query/include/postgres/catalog/pg_ts_parser_d.h +1 -1
  129. data/ext/pg_query/include/postgres/catalog/pg_ts_template.h +6 -3
  130. data/ext/pg_query/include/postgres/catalog/pg_ts_template_d.h +1 -1
  131. data/ext/pg_query/include/postgres/catalog/pg_type.h +6 -3
  132. data/ext/pg_query/include/postgres/catalog/pg_type_d.h +1 -1
  133. data/ext/pg_query/include/postgres/catalog/storage.h +1 -1
  134. data/ext/pg_query/include/postgres/catalog/syscache_ids.h +104 -0
  135. data/ext/pg_query/include/postgres/commands/async.h +2 -6
  136. data/ext/pg_query/include/postgres/commands/dbcommands.h +1 -1
  137. data/ext/pg_query/include/postgres/commands/defrem.h +6 -6
  138. data/ext/pg_query/include/postgres/commands/event_trigger.h +11 -2
  139. data/ext/pg_query/include/postgres/commands/explain.h +19 -3
  140. data/ext/pg_query/include/postgres/commands/prepare.h +1 -1
  141. data/ext/pg_query/include/postgres/commands/tablespace.h +1 -1
  142. data/ext/pg_query/include/postgres/commands/trigger.h +1 -1
  143. data/ext/pg_query/include/postgres/commands/vacuum.h +28 -26
  144. data/ext/pg_query/include/postgres/common/cryptohash.h +2 -2
  145. data/ext/pg_query/include/postgres/common/file_perm.h +1 -1
  146. data/ext/pg_query/include/postgres/common/file_utils.h +65 -0
  147. data/ext/pg_query/include/postgres/common/hashfn.h +16 -1
  148. data/ext/pg_query/include/postgres/common/hashfn_unstable.h +407 -0
  149. data/ext/pg_query/include/postgres/common/int.h +79 -4
  150. data/ext/pg_query/include/postgres/common/keywords.h +1 -1
  151. data/ext/pg_query/include/postgres/common/kwlookup.h +1 -1
  152. data/ext/pg_query/include/postgres/common/pg_prng.h +2 -1
  153. data/ext/pg_query/include/postgres/common/relpath.h +4 -4
  154. data/ext/pg_query/include/postgres/common/scram-common.h +1 -1
  155. data/ext/pg_query/include/postgres/common/sha2.h +1 -1
  156. data/ext/pg_query/include/postgres/common/string.h +1 -1
  157. data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +2 -3
  158. data/ext/pg_query/include/postgres/copyfuncs.funcs.c +278 -30
  159. data/ext/pg_query/include/postgres/copyfuncs.switch.c +55 -4
  160. data/ext/pg_query/include/postgres/datatype/timestamp.h +29 -3
  161. data/ext/pg_query/include/postgres/equalfuncs.funcs.c +239 -26
  162. data/ext/pg_query/include/postgres/equalfuncs.switch.c +55 -4
  163. data/ext/pg_query/include/postgres/executor/execdesc.h +2 -2
  164. data/ext/pg_query/include/postgres/executor/executor.h +6 -5
  165. data/ext/pg_query/include/postgres/executor/functions.h +2 -1
  166. data/ext/pg_query/include/postgres/executor/instrument.h +5 -3
  167. data/ext/pg_query/include/postgres/executor/spi.h +2 -8
  168. data/ext/pg_query/include/postgres/executor/tablefunc.h +1 -1
  169. data/ext/pg_query/include/postgres/executor/tuptable.h +31 -2
  170. data/ext/pg_query/include/postgres/fmgr.h +2 -2
  171. data/ext/pg_query/include/postgres/foreign/fdwapi.h +1 -1
  172. data/ext/pg_query/include/postgres/funcapi.h +2 -2
  173. data/ext/pg_query/include/postgres/gram.h +871 -830
  174. data/ext/pg_query/include/postgres/gramparse.h +1 -1
  175. data/ext/pg_query/include/postgres/jit/jit.h +4 -3
  176. data/ext/pg_query/include/postgres/kwlist_d.h +511 -466
  177. data/ext/pg_query/include/postgres/lib/dshash.h +25 -10
  178. data/ext/pg_query/include/postgres/lib/ilist.h +1 -1
  179. data/ext/pg_query/include/postgres/lib/pairingheap.h +1 -1
  180. data/ext/pg_query/include/postgres/lib/simplehash.h +40 -18
  181. data/ext/pg_query/include/postgres/lib/sort_template.h +14 -1
  182. data/ext/pg_query/include/postgres/lib/stringinfo.h +93 -11
  183. data/ext/pg_query/include/postgres/libpq/auth.h +1 -1
  184. data/ext/pg_query/include/postgres/libpq/crypt.h +2 -2
  185. data/ext/pg_query/include/postgres/libpq/hba.h +4 -4
  186. data/ext/pg_query/include/postgres/libpq/libpq-be.h +35 -28
  187. data/ext/pg_query/include/postgres/libpq/libpq.h +6 -7
  188. data/ext/pg_query/include/postgres/libpq/pqcomm.h +26 -20
  189. data/ext/pg_query/include/postgres/libpq/pqformat.h +2 -3
  190. data/ext/pg_query/include/postgres/libpq/pqsignal.h +1 -1
  191. data/ext/pg_query/include/postgres/libpq/protocol.h +89 -0
  192. data/ext/pg_query/include/postgres/libpq/sasl.h +1 -1
  193. data/ext/pg_query/include/postgres/libpq/scram.h +1 -1
  194. data/ext/pg_query/include/postgres/mb/pg_wchar.h +103 -82
  195. data/ext/pg_query/include/postgres/mb/stringinfo_mb.h +1 -1
  196. data/ext/pg_query/include/postgres/miscadmin.h +72 -52
  197. data/ext/pg_query/include/postgres/nodes/bitmapset.h +17 -3
  198. data/ext/pg_query/include/postgres/nodes/execnodes.h +112 -25
  199. data/ext/pg_query/include/postgres/nodes/extensible.h +1 -1
  200. data/ext/pg_query/include/postgres/nodes/lockoptions.h +4 -4
  201. data/ext/pg_query/include/postgres/nodes/makefuncs.h +8 -2
  202. data/ext/pg_query/include/postgres/nodes/memnodes.h +43 -4
  203. data/ext/pg_query/include/postgres/nodes/miscnodes.h +1 -1
  204. data/ext/pg_query/include/postgres/nodes/nodeFuncs.h +1 -1
  205. data/ext/pg_query/include/postgres/nodes/nodes.h +30 -41
  206. data/ext/pg_query/include/postgres/nodes/nodetags.h +464 -444
  207. data/ext/pg_query/include/postgres/nodes/params.h +1 -1
  208. data/ext/pg_query/include/postgres/nodes/parsenodes.h +358 -175
  209. data/ext/pg_query/include/postgres/nodes/pathnodes.h +64 -10
  210. data/ext/pg_query/include/postgres/nodes/pg_list.h +62 -11
  211. data/ext/pg_query/include/postgres/nodes/plannodes.h +11 -10
  212. data/ext/pg_query/include/postgres/nodes/primnodes.h +352 -54
  213. data/ext/pg_query/include/postgres/nodes/print.h +1 -1
  214. data/ext/pg_query/include/postgres/nodes/queryjumble.h +2 -2
  215. data/ext/pg_query/include/postgres/nodes/replnodes.h +23 -2
  216. data/ext/pg_query/include/postgres/nodes/supportnodes.h +1 -1
  217. data/ext/pg_query/include/postgres/nodes/tidbitmap.h +1 -1
  218. data/ext/pg_query/include/postgres/nodes/value.h +1 -1
  219. data/ext/pg_query/include/postgres/optimizer/cost.h +5 -4
  220. data/ext/pg_query/include/postgres/optimizer/geqo.h +1 -1
  221. data/ext/pg_query/include/postgres/optimizer/geqo_gene.h +1 -1
  222. data/ext/pg_query/include/postgres/optimizer/optimizer.h +5 -2
  223. data/ext/pg_query/include/postgres/optimizer/paths.h +13 -8
  224. data/ext/pg_query/include/postgres/optimizer/planmain.h +7 -1
  225. data/ext/pg_query/include/postgres/parser/analyze.h +3 -1
  226. data/ext/pg_query/include/postgres/parser/kwlist.h +22 -2
  227. data/ext/pg_query/include/postgres/parser/parse_agg.h +1 -1
  228. data/ext/pg_query/include/postgres/parser/parse_coerce.h +5 -2
  229. data/ext/pg_query/include/postgres/parser/parse_expr.h +1 -1
  230. data/ext/pg_query/include/postgres/parser/parse_func.h +2 -2
  231. data/ext/pg_query/include/postgres/parser/parse_node.h +3 -2
  232. data/ext/pg_query/include/postgres/parser/parse_oper.h +4 -1
  233. data/ext/pg_query/include/postgres/parser/parse_relation.h +1 -1
  234. data/ext/pg_query/include/postgres/parser/parse_type.h +2 -2
  235. data/ext/pg_query/include/postgres/parser/parser.h +3 -3
  236. data/ext/pg_query/include/postgres/parser/parsetree.h +1 -1
  237. data/ext/pg_query/include/postgres/parser/scanner.h +1 -1
  238. data/ext/pg_query/include/postgres/parser/scansup.h +1 -1
  239. data/ext/pg_query/include/postgres/partitioning/partdefs.h +1 -1
  240. data/ext/pg_query/include/postgres/pg_config.h +53 -45
  241. data/ext/pg_query/include/postgres/pg_config_manual.h +21 -8
  242. data/ext/pg_query/include/postgres/pg_getopt.h +1 -1
  243. data/ext/pg_query/include/postgres/pg_trace.h +1 -1
  244. data/ext/pg_query/include/postgres/pgstat.h +13 -11
  245. data/ext/pg_query/include/postgres/pgtime.h +1 -1
  246. data/ext/pg_query/include/postgres/pl_reserved_kwlist.h +1 -1
  247. data/ext/pg_query/include/postgres/pl_reserved_kwlist_d.h +1 -1
  248. data/ext/pg_query/include/postgres/pl_unreserved_kwlist.h +1 -1
  249. data/ext/pg_query/include/postgres/pl_unreserved_kwlist_d.h +1 -1
  250. data/ext/pg_query/include/postgres/plerrcodes.h +4 -4
  251. data/ext/pg_query/include/postgres/plpgsql.h +15 -13
  252. data/ext/pg_query/include/postgres/port/atomics/arch-arm.h +1 -1
  253. data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +1 -1
  254. data/ext/pg_query/include/postgres/port/atomics/arch-ppc.h +3 -1
  255. data/ext/pg_query/include/postgres/port/atomics/arch-x86.h +3 -1
  256. data/ext/pg_query/include/postgres/port/atomics/fallback.h +1 -1
  257. data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +38 -1
  258. data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +19 -1
  259. data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +16 -1
  260. data/ext/pg_query/include/postgres/port/atomics/generic.h +38 -2
  261. data/ext/pg_query/include/postgres/port/atomics.h +93 -6
  262. data/ext/pg_query/include/postgres/port/pg_bitutils.h +91 -9
  263. data/ext/pg_query/include/postgres/port/pg_bswap.h +1 -1
  264. data/ext/pg_query/include/postgres/port/pg_crc32c.h +10 -1
  265. data/ext/pg_query/include/postgres/port/pg_iovec.h +117 -0
  266. data/ext/pg_query/include/postgres/port/simd.h +48 -1
  267. data/ext/pg_query/include/postgres/port/win32/sys/socket.h +8 -0
  268. data/ext/pg_query/include/postgres/port/win32_port.h +1 -13
  269. data/ext/pg_query/include/postgres/port.h +39 -4
  270. data/ext/pg_query/include/postgres/portability/instr_time.h +1 -1
  271. data/ext/pg_query/include/postgres/postgres.h +1 -1
  272. data/ext/pg_query/include/postgres/postmaster/autovacuum.h +5 -16
  273. data/ext/pg_query/include/postgres/postmaster/bgworker.h +8 -6
  274. data/ext/pg_query/include/postgres/postmaster/bgworker_internals.h +3 -7
  275. data/ext/pg_query/include/postgres/postmaster/bgwriter.h +3 -3
  276. data/ext/pg_query/include/postgres/postmaster/interrupt.h +1 -1
  277. data/ext/pg_query/include/postgres/postmaster/pgarch.h +2 -2
  278. data/ext/pg_query/include/postgres/postmaster/postmaster.h +25 -5
  279. data/ext/pg_query/include/postgres/postmaster/startup.h +2 -2
  280. data/ext/pg_query/include/postgres/postmaster/syslogger.h +2 -4
  281. data/ext/pg_query/include/postgres/postmaster/walsummarizer.h +35 -0
  282. data/ext/pg_query/include/postgres/postmaster/walwriter.h +2 -2
  283. data/ext/pg_query/include/postgres/regex/regex.h +92 -9
  284. data/ext/pg_query/include/postgres/replication/logicallauncher.h +1 -1
  285. data/ext/pg_query/include/postgres/replication/logicalproto.h +2 -2
  286. data/ext/pg_query/include/postgres/replication/logicalworker.h +2 -1
  287. data/ext/pg_query/include/postgres/replication/origin.h +1 -1
  288. data/ext/pg_query/include/postgres/replication/reorderbuffer.h +27 -46
  289. data/ext/pg_query/include/postgres/replication/slot.h +45 -5
  290. data/ext/pg_query/include/postgres/replication/slotsync.h +38 -0
  291. data/ext/pg_query/include/postgres/replication/syncrep.h +1 -1
  292. data/ext/pg_query/include/postgres/replication/walreceiver.h +37 -11
  293. data/ext/pg_query/include/postgres/replication/walsender.h +5 -3
  294. data/ext/pg_query/include/postgres/rewrite/prs2lock.h +1 -1
  295. data/ext/pg_query/include/postgres/rewrite/rewriteHandler.h +7 -1
  296. data/ext/pg_query/include/postgres/rewrite/rewriteManip.h +2 -2
  297. data/ext/pg_query/include/postgres/rewrite/rewriteSupport.h +1 -1
  298. data/ext/pg_query/include/postgres/storage/block.h +1 -1
  299. data/ext/pg_query/include/postgres/storage/buf.h +1 -1
  300. data/ext/pg_query/include/postgres/storage/bufmgr.h +59 -41
  301. data/ext/pg_query/include/postgres/storage/bufpage.h +1 -1
  302. data/ext/pg_query/include/postgres/storage/condition_variable.h +1 -1
  303. data/ext/pg_query/include/postgres/storage/dsm.h +1 -1
  304. data/ext/pg_query/include/postgres/storage/dsm_impl.h +2 -2
  305. data/ext/pg_query/include/postgres/storage/fd.h +30 -13
  306. data/ext/pg_query/include/postgres/storage/fileset.h +1 -1
  307. data/ext/pg_query/include/postgres/storage/ipc.h +4 -1
  308. data/ext/pg_query/include/postgres/storage/item.h +1 -1
  309. data/ext/pg_query/include/postgres/storage/itemid.h +1 -1
  310. data/ext/pg_query/include/postgres/storage/itemptr.h +1 -1
  311. data/ext/pg_query/include/postgres/storage/large_object.h +1 -1
  312. data/ext/pg_query/include/postgres/storage/latch.h +4 -2
  313. data/ext/pg_query/include/postgres/storage/lmgr.h +8 -2
  314. data/ext/pg_query/include/postgres/storage/lock.h +19 -19
  315. data/ext/pg_query/include/postgres/storage/lockdefs.h +3 -1
  316. data/ext/pg_query/include/postgres/storage/lwlock.h +17 -9
  317. data/ext/pg_query/include/postgres/storage/lwlocknames.h +7 -10
  318. data/ext/pg_query/include/postgres/storage/off.h +1 -1
  319. data/ext/pg_query/include/postgres/storage/pg_sema.h +1 -1
  320. data/ext/pg_query/include/postgres/storage/pg_shmem.h +5 -4
  321. data/ext/pg_query/include/postgres/storage/pmsignal.h +2 -2
  322. data/ext/pg_query/include/postgres/storage/predicate.h +1 -5
  323. data/ext/pg_query/include/postgres/storage/proc.h +48 -26
  324. data/ext/pg_query/include/postgres/storage/procarray.h +5 -1
  325. data/ext/pg_query/include/postgres/storage/proclist_types.h +11 -9
  326. data/ext/pg_query/include/postgres/storage/procnumber.h +43 -0
  327. data/ext/pg_query/include/postgres/storage/procsignal.h +8 -6
  328. data/ext/pg_query/include/postgres/storage/read_stream.h +65 -0
  329. data/ext/pg_query/include/postgres/storage/relfilelocator.h +16 -15
  330. data/ext/pg_query/include/postgres/storage/s_lock.h +7 -27
  331. data/ext/pg_query/include/postgres/storage/sharedfileset.h +1 -1
  332. data/ext/pg_query/include/postgres/storage/shm_mq.h +2 -2
  333. data/ext/pg_query/include/postgres/storage/shm_toc.h +1 -1
  334. data/ext/pg_query/include/postgres/storage/shmem.h +1 -1
  335. data/ext/pg_query/include/postgres/storage/sinval.h +3 -3
  336. data/ext/pg_query/include/postgres/storage/smgr.h +46 -29
  337. data/ext/pg_query/include/postgres/storage/spin.h +1 -1
  338. data/ext/pg_query/include/postgres/storage/standby.h +13 -3
  339. data/ext/pg_query/include/postgres/storage/standbydefs.h +2 -2
  340. data/ext/pg_query/include/postgres/storage/sync.h +4 -4
  341. data/ext/pg_query/include/postgres/tcop/cmdtag.h +1 -2
  342. data/ext/pg_query/include/postgres/tcop/cmdtaglist.h +3 -2
  343. data/ext/pg_query/include/postgres/tcop/deparse_utility.h +2 -2
  344. data/ext/pg_query/include/postgres/tcop/dest.h +3 -2
  345. data/ext/pg_query/include/postgres/tcop/fastpath.h +1 -1
  346. data/ext/pg_query/include/postgres/tcop/pquery.h +1 -1
  347. data/ext/pg_query/include/postgres/tcop/tcopprot.h +9 -5
  348. data/ext/pg_query/include/postgres/tcop/utility.h +2 -2
  349. data/ext/pg_query/include/postgres/tsearch/ts_cache.h +1 -1
  350. data/ext/pg_query/include/postgres/utils/acl.h +19 -7
  351. data/ext/pg_query/include/postgres/utils/aclchk_internal.h +1 -1
  352. data/ext/pg_query/include/postgres/utils/array.h +1 -2
  353. data/ext/pg_query/include/postgres/utils/ascii.h +84 -0
  354. data/ext/pg_query/include/postgres/utils/backend_progress.h +3 -2
  355. data/ext/pg_query/include/postgres/utils/backend_status.h +8 -10
  356. data/ext/pg_query/include/postgres/utils/builtins.h +4 -1
  357. data/ext/pg_query/include/postgres/utils/bytea.h +2 -2
  358. data/ext/pg_query/include/postgres/utils/catcache.h +6 -6
  359. data/ext/pg_query/include/postgres/utils/date.h +1 -1
  360. data/ext/pg_query/include/postgres/utils/datetime.h +4 -1
  361. data/ext/pg_query/include/postgres/utils/datum.h +1 -1
  362. data/ext/pg_query/include/postgres/utils/dsa.h +44 -5
  363. data/ext/pg_query/include/postgres/utils/elog.h +3 -8
  364. data/ext/pg_query/include/postgres/utils/errcodes.h +1 -3
  365. data/ext/pg_query/include/postgres/utils/expandeddatum.h +1 -1
  366. data/ext/pg_query/include/postgres/utils/expandedrecord.h +1 -1
  367. data/ext/pg_query/include/postgres/utils/float.h +1 -1
  368. data/ext/pg_query/include/postgres/utils/fmgroids.h +49 -16
  369. data/ext/pg_query/include/postgres/utils/fmgrprotos.h +47 -14
  370. data/ext/pg_query/include/postgres/utils/fmgrtab.h +1 -1
  371. data/ext/pg_query/include/postgres/utils/guc.h +20 -6
  372. data/ext/pg_query/include/postgres/utils/guc_hooks.h +23 -2
  373. data/ext/pg_query/include/postgres/utils/guc_tables.h +6 -5
  374. data/ext/pg_query/include/postgres/utils/hsearch.h +2 -2
  375. data/ext/pg_query/include/postgres/utils/injection_point.h +44 -0
  376. data/ext/pg_query/include/postgres/utils/inval.h +1 -1
  377. data/ext/pg_query/include/postgres/utils/logtape.h +5 -5
  378. data/ext/pg_query/include/postgres/utils/lsyscache.h +6 -3
  379. data/ext/pg_query/include/postgres/utils/memdebug.h +1 -1
  380. data/ext/pg_query/include/postgres/utils/memutils.h +12 -5
  381. data/ext/pg_query/include/postgres/utils/memutils_internal.h +53 -13
  382. data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +25 -9
  383. data/ext/pg_query/include/postgres/utils/numeric.h +6 -1
  384. data/ext/pg_query/include/postgres/utils/palloc.h +1 -15
  385. data/ext/pg_query/include/postgres/utils/partcache.h +1 -1
  386. data/ext/pg_query/include/postgres/utils/pg_locale.h +8 -7
  387. data/ext/pg_query/include/postgres/utils/pgstat_internal.h +30 -17
  388. data/ext/pg_query/include/postgres/utils/plancache.h +5 -3
  389. data/ext/pg_query/include/postgres/utils/portal.h +10 -10
  390. data/ext/pg_query/include/postgres/utils/queryenvironment.h +2 -2
  391. data/ext/pg_query/include/postgres/utils/regproc.h +1 -1
  392. data/ext/pg_query/include/postgres/utils/rel.h +14 -15
  393. data/ext/pg_query/include/postgres/utils/relcache.h +2 -5
  394. data/ext/pg_query/include/postgres/utils/reltrigger.h +1 -1
  395. data/ext/pg_query/include/postgres/utils/resowner.h +90 -9
  396. data/ext/pg_query/include/postgres/utils/ruleutils.h +1 -1
  397. data/ext/pg_query/include/postgres/utils/sharedtuplestore.h +1 -1
  398. data/ext/pg_query/include/postgres/utils/snapmgr.h +1 -52
  399. data/ext/pg_query/include/postgres/utils/snapshot.h +2 -2
  400. data/ext/pg_query/include/postgres/utils/sortsupport.h +1 -1
  401. data/ext/pg_query/include/postgres/utils/syscache.h +7 -98
  402. data/ext/pg_query/include/postgres/utils/timeout.h +3 -2
  403. data/ext/pg_query/include/postgres/utils/timestamp.h +1 -1
  404. data/ext/pg_query/include/postgres/utils/tuplesort.h +36 -9
  405. data/ext/pg_query/include/postgres/utils/tuplestore.h +2 -5
  406. data/ext/pg_query/include/postgres/utils/typcache.h +2 -1
  407. data/ext/pg_query/include/postgres/utils/varlena.h +1 -1
  408. data/ext/pg_query/include/postgres/utils/wait_event.h +28 -214
  409. data/ext/pg_query/include/postgres/utils/wait_event_types.h +218 -0
  410. data/ext/pg_query/include/postgres/utils/xml.h +4 -4
  411. data/ext/pg_query/include/postgres/varatt.h +1 -1
  412. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1546 -792
  413. data/ext/pg_query/include/protobuf/pg_query.pb.h +58365 -46595
  414. data/ext/pg_query/pg_query.pb-c.c +6598 -3739
  415. data/ext/pg_query/pg_query_normalize.c +42 -1
  416. data/ext/pg_query/pg_query_outfuncs_json.c +3 -1
  417. data/ext/pg_query/pg_query_parse_plpgsql.c +12 -13
  418. data/ext/pg_query/pg_query_readfuncs_protobuf.c +2 -2
  419. data/ext/pg_query/pg_query_scan.c +1 -1
  420. data/ext/pg_query/postgres_deparse.c +601 -172
  421. data/ext/pg_query/src_backend_catalog_namespace.c +241 -66
  422. data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -3
  423. data/ext/pg_query/src_backend_commands_define.c +2 -3
  424. data/ext/pg_query/src_backend_nodes_bitmapset.c +137 -94
  425. data/ext/pg_query/src_backend_nodes_copyfuncs.c +1 -1
  426. data/ext/pg_query/src_backend_nodes_equalfuncs.c +1 -1
  427. data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
  428. data/ext/pg_query/src_backend_nodes_list.c +3 -7
  429. data/ext/pg_query/src_backend_nodes_makefuncs.c +59 -20
  430. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +109 -2
  431. data/ext/pg_query/src_backend_nodes_value.c +1 -1
  432. data/ext/pg_query/src_backend_parser_gram.c +34491 -32136
  433. data/ext/pg_query/src_backend_parser_parser.c +8 -8
  434. data/ext/pg_query/src_backend_parser_scan.c +5637 -3028
  435. data/ext/pg_query/src_backend_parser_scansup.c +2 -1
  436. data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
  437. data/ext/pg_query/src_backend_tcop_postgres.c +34 -10
  438. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +2 -2
  439. data/ext/pg_query/src_backend_utils_adt_datum.c +8 -6
  440. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  441. data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
  442. data/ext/pg_query/src_backend_utils_adt_numutils.c +4 -5
  443. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +101 -28
  444. data/ext/pg_query/src_backend_utils_error_assert.c +1 -1
  445. data/ext/pg_query/src_backend_utils_error_elog.c +47 -42
  446. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +4 -2
  447. data/ext/pg_query/src_backend_utils_init_globals.c +15 -3
  448. data/ext/pg_query/src_backend_utils_mb_mbutils.c +11 -18
  449. data/ext/pg_query/src_backend_utils_misc_guc_tables.c +16 -6
  450. data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +8 -5
  451. data/ext/pg_query/src_backend_utils_mmgr_aset.c +308 -238
  452. data/ext/pg_query/src_backend_utils_mmgr_bump.c +728 -0
  453. data/ext/pg_query/src_backend_utils_mmgr_generation.c +273 -197
  454. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +270 -215
  455. data/ext/pg_query/src_backend_utils_mmgr_slab.c +154 -96
  456. data/ext/pg_query/src_common_encnames.c +43 -44
  457. data/ext/pg_query/src_common_hashfn.c +1 -1
  458. data/ext/pg_query/src_common_keywords.c +1 -1
  459. data/ext/pg_query/src_common_kwlist_d.h +511 -466
  460. data/ext/pg_query/src_common_kwlookup.c +1 -1
  461. data/ext/pg_query/src_common_psprintf.c +3 -3
  462. data/ext/pg_query/src_common_stringinfo.c +18 -1
  463. data/ext/pg_query/src_common_wchar.c +92 -109
  464. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +99 -5
  465. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -1
  466. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +242 -143
  467. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  468. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +1 -1
  469. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +19 -1
  470. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +1 -1
  471. data/ext/pg_query/src_port_pg_bitutils.c +173 -28
  472. data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
  473. data/ext/pg_query/src_port_snprintf.c +15 -18
  474. data/ext/pg_query/src_port_strerror.c +1 -3
  475. data/ext/pg_query/src_port_strlcpy.c +1 -1
  476. data/lib/pg_query/fingerprint.rb +3 -5
  477. data/lib/pg_query/param_refs.rb +2 -2
  478. data/lib/pg_query/parse.rb +5 -7
  479. data/lib/pg_query/parse_error.rb +1 -0
  480. data/lib/pg_query/pg_query_pb.rb +27 -25
  481. data/lib/pg_query/scan.rb +1 -0
  482. data/lib/pg_query/treewalker.rb +38 -15
  483. data/lib/pg_query/truncate.rb +18 -20
  484. data/lib/pg_query/version.rb +1 -1
  485. metadata +31 -82
  486. data/ext/pg_query/include/postgres/storage/backendid.h +0 -37
  487. data/ext/pg_query/include/postgres/storage/sinvaladt.h +0 -45
  488. data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -2
  489. data/ext/pg_query/src_backend_nodes_nodes.c +0 -38
  490. /data/ext/pg_query/{pg_query_ruby.sym → ext_symbols.sym} +0 -0
@@ -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
@@ -204,7 +189,8 @@ typedef struct Port
204
189
  /*
205
190
  * If GSSAPI is supported and used on this connection, store GSSAPI
206
191
  * information. Even when GSSAPI is not compiled in, store a NULL pointer
207
- * to keep struct offsets the same (for extension ABI compatibility).
192
+ * to keep struct offsets of the "SSL structures" below the same (for
193
+ * extension ABI compatibility).
208
194
  */
209
195
  pg_gssinfo *gss;
210
196
  #else
@@ -218,17 +204,44 @@ typedef struct Port
218
204
  char *peer_cn;
219
205
  char *peer_dn;
220
206
  bool peer_cert_valid;
207
+ bool alpn_used;
221
208
 
222
209
  /*
223
- * OpenSSL structures. (Keep these last so that the locations of other
224
- * fields are the same whether or not you build with SSL enabled.)
210
+ * OpenSSL structures.
225
211
  */
226
212
  #ifdef USE_OPENSSL
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
+ * NB: the offsets of these fields depend on USE_OPENSSL. These should
227
+ * not be accessed in an extension because of the ABI incompatibility.
228
+ */
229
+ char *raw_buf;
230
+ ssize_t raw_buf_consumed,
231
+ raw_buf_remaining;
230
232
  } Port;
231
233
 
234
+ /*
235
+ * ClientSocket holds a socket for an accepted connection, along with the
236
+ * information about the remote endpoint. This is passed from postmaster to
237
+ * the backend process.
238
+ */
239
+ typedef struct ClientSocket
240
+ {
241
+ pgsocket sock; /* File descriptor */
242
+ SockAddr raddr; /* remote addr (client) */
243
+ } ClientSocket;
244
+
232
245
  #ifdef USE_SSL
233
246
  /*
234
247
  * Hardcoded DH parameters, used in ephemeral DH keying. (See also
@@ -305,14 +318,8 @@ extern void be_tls_get_peer_serial(Port *port, char *ptr, size_t len);
305
318
  *
306
319
  * The result is a palloc'd hash of the server certificate with its
307
320
  * 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
321
  */
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
322
  extern char *be_tls_get_certificate_hash(Port *port, size_t *len);
315
- #endif
316
323
 
317
324
  /* init hook for SSL, the default sets the password callback if appropriate */
318
325
  #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