pg_query 5.1.0 → 6.0.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 (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
@@ -4,7 +4,7 @@
4
4
  * header file for postgres vacuum cleaner and statistics analyzer
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/commands/vacuum.h
@@ -17,6 +17,7 @@
17
17
  #include "access/htup.h"
18
18
  #include "access/genam.h"
19
19
  #include "access/parallel.h"
20
+ #include "access/tidstore.h"
20
21
  #include "catalog/pg_class.h"
21
22
  #include "catalog/pg_statistic.h"
22
23
  #include "catalog/pg_type.h"
@@ -116,16 +117,12 @@ typedef struct VacAttrStats
116
117
  {
117
118
  /*
118
119
  * These fields are set up by the main ANALYZE code before invoking the
119
- * type-specific typanalyze function.
120
- *
121
- * Note: do not assume that the data being analyzed has the same datatype
122
- * shown in attr, ie do not trust attr->atttypid, attlen, etc. This is
123
- * because some index opclasses store a different type than the underlying
124
- * column/expression. Instead use attrtypid, attrtypmod, and attrtype for
120
+ * type-specific typanalyze function. They don't necessarily match what
121
+ * is in pg_attribute, because some index opclasses store a different type
122
+ * than the underlying column/expression. Therefore, use these fields for
125
123
  * information about the datatype being fed to the typanalyze function.
126
- * Likewise, use attrcollid not attr->attcollation.
127
124
  */
128
- Form_pg_attribute attr; /* copy of pg_attribute row for column */
125
+ int attstattarget; /* -1 to use default */
129
126
  Oid attrtypid; /* type of data being analyzed */
130
127
  int32 attrtypmod; /* typmod of data being analyzed */
131
128
  Form_pg_type attrtype; /* copy of pg_type row for attrtypid */
@@ -232,6 +229,7 @@ typedef struct VacuumParams
232
229
  * default */
233
230
  VacOptValue index_cleanup; /* Do index vacuum and cleanup */
234
231
  VacOptValue truncate; /* Truncate empty pages at the end */
232
+ Oid toast_parent; /* for privilege checks when recursing */
235
233
 
236
234
  /*
237
235
  * The number of parallel vacuum workers. 0 by default which means choose
@@ -281,19 +279,14 @@ struct VacuumCutoffs
281
279
  };
282
280
 
283
281
  /*
284
- * VacDeadItems stores TIDs whose index tuples are deleted by index vacuuming.
282
+ * VacDeadItemsInfo stores supplemental information for dead tuple TID
283
+ * storage (i.e. TidStore).
285
284
  */
286
- typedef struct VacDeadItems
285
+ typedef struct VacDeadItemsInfo
287
286
  {
288
- int max_items; /* # slots allocated in array */
289
- int num_items; /* current # of entries */
290
-
291
- /* Sorted array of TIDs to delete from indexes */
292
- ItemPointerData items[FLEXIBLE_ARRAY_MEMBER];
293
- } VacDeadItems;
294
-
295
- #define MAXDEADITEMS(avail_mem) \
296
- (((avail_mem) - offsetof(VacDeadItems, items)) / sizeof(ItemPointerData))
287
+ size_t max_bytes; /* the maximum bytes TidStore can use */
288
+ int64 num_items; /* current # of entries */
289
+ } VacDeadItemsInfo;
297
290
 
298
291
  /* GUC parameters */
299
292
  extern PGDLLIMPORT int default_statistics_target; /* PGDLLIMPORT for PostGIS */
@@ -304,6 +297,13 @@ extern PGDLLIMPORT int vacuum_multixact_freeze_table_age;
304
297
  extern PGDLLIMPORT int vacuum_failsafe_age;
305
298
  extern PGDLLIMPORT int vacuum_multixact_failsafe_age;
306
299
 
300
+ /*
301
+ * Maximum value for default_statistics_target and per-column statistics
302
+ * targets. This is fairly arbitrary, mainly to prevent users from creating
303
+ * unreasonably large statistics that the system cannot handle well.
304
+ */
305
+ #define MAX_STATISTICS_TARGET 10000
306
+
307
307
  /* Variables for cost-based parallel vacuum */
308
308
  extern PGDLLIMPORT pg_atomic_uint32 *VacuumSharedCostBalance;
309
309
  extern PGDLLIMPORT pg_atomic_uint32 *VacuumActiveNWorkers;
@@ -340,17 +340,17 @@ extern bool vacuum_get_cutoffs(Relation rel, const VacuumParams *params,
340
340
  extern bool vacuum_xid_failsafe_check(const struct VacuumCutoffs *cutoffs);
341
341
  extern void vac_update_datfrozenxid(void);
342
342
  extern void vacuum_delay_point(void);
343
- extern bool vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple,
344
- bits32 options);
343
+ extern bool vacuum_is_permitted_for_relation(Oid relid, Form_pg_class reltuple,
344
+ bits32 options);
345
345
  extern Relation vacuum_open_relation(Oid relid, RangeVar *relation,
346
346
  bits32 options, bool verbose,
347
347
  LOCKMODE lmode);
348
348
  extern IndexBulkDeleteResult *vac_bulkdel_one_index(IndexVacuumInfo *ivinfo,
349
349
  IndexBulkDeleteResult *istat,
350
- VacDeadItems *dead_items);
350
+ TidStore *dead_items,
351
+ VacDeadItemsInfo *dead_items_info);
351
352
  extern IndexBulkDeleteResult *vac_cleanup_one_index(IndexVacuumInfo *ivinfo,
352
353
  IndexBulkDeleteResult *istat);
353
- extern Size vac_max_items_to_alloc_size(int max_items);
354
354
 
355
355
  /* In postmaster/autovacuum.c */
356
356
  extern void AutoVacuumUpdateCostLimit(void);
@@ -359,10 +359,12 @@ extern void VacuumUpdateCosts(void);
359
359
  /* in commands/vacuumparallel.c */
360
360
  extern ParallelVacuumState *parallel_vacuum_init(Relation rel, Relation *indrels,
361
361
  int nindexes, int nrequested_workers,
362
- int max_items, int elevel,
362
+ int vac_work_mem, int elevel,
363
363
  BufferAccessStrategy bstrategy);
364
364
  extern void parallel_vacuum_end(ParallelVacuumState *pvs, IndexBulkDeleteResult **istats);
365
- extern VacDeadItems *parallel_vacuum_get_dead_items(ParallelVacuumState *pvs);
365
+ extern TidStore *parallel_vacuum_get_dead_items(ParallelVacuumState *pvs,
366
+ VacDeadItemsInfo **dead_items_info_p);
367
+ extern void parallel_vacuum_reset_dead_items(ParallelVacuumState *pvs);
366
368
  extern void parallel_vacuum_bulkdel_all_indexes(ParallelVacuumState *pvs,
367
369
  long num_table_tuples,
368
370
  int num_index_scans);
@@ -3,7 +3,7 @@
3
3
  * cryptohash.h
4
4
  * Generic headers for cryptographic hash functions.
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
@@ -23,7 +23,7 @@ typedef enum
23
23
  PG_SHA224,
24
24
  PG_SHA256,
25
25
  PG_SHA384,
26
- PG_SHA512
26
+ PG_SHA512,
27
27
  } pg_cryptohash_type;
28
28
 
29
29
  /* opaque context, private to each cryptohash implementation */
@@ -3,7 +3,7 @@
3
3
  * File and directory permission definitions
4
4
  *
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/common/file_perm.h
@@ -0,0 +1,65 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * Assorted utility functions to work on files.
4
+ *
5
+ *
6
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1994, Regents of the University of California
8
+ *
9
+ * src/include/common/file_utils.h
10
+ *
11
+ *-------------------------------------------------------------------------
12
+ */
13
+ #ifndef FILE_UTILS_H
14
+ #define FILE_UTILS_H
15
+
16
+ #include <dirent.h>
17
+
18
+ typedef enum PGFileType
19
+ {
20
+ PGFILETYPE_ERROR,
21
+ PGFILETYPE_UNKNOWN,
22
+ PGFILETYPE_REG,
23
+ PGFILETYPE_DIR,
24
+ PGFILETYPE_LNK,
25
+ } PGFileType;
26
+
27
+ typedef enum DataDirSyncMethod
28
+ {
29
+ DATA_DIR_SYNC_METHOD_FSYNC,
30
+ DATA_DIR_SYNC_METHOD_SYNCFS,
31
+ } DataDirSyncMethod;
32
+
33
+ struct iovec; /* avoid including port/pg_iovec.h here */
34
+
35
+ #ifdef FRONTEND
36
+ extern int fsync_fname(const char *fname, bool isdir);
37
+ extern void sync_pgdata(const char *pg_data, int serverVersion,
38
+ DataDirSyncMethod sync_method);
39
+ extern void sync_dir_recurse(const char *dir, DataDirSyncMethod sync_method);
40
+ extern int durable_rename(const char *oldfile, const char *newfile);
41
+ extern int fsync_parent_path(const char *fname);
42
+ #endif
43
+
44
+ extern PGFileType get_dirent_type(const char *path,
45
+ const struct dirent *de,
46
+ bool look_through_symlinks,
47
+ int elevel);
48
+
49
+ extern int compute_remaining_iovec(struct iovec *destination,
50
+ const struct iovec *source,
51
+ int iovcnt,
52
+ size_t transferred);
53
+
54
+ extern ssize_t pg_pwritev_with_retry(int fd,
55
+ const struct iovec *iov,
56
+ int iovcnt,
57
+ off_t offset);
58
+
59
+ extern ssize_t pg_pwrite_zeros(int fd, size_t size, off_t offset);
60
+
61
+ /* Filename components */
62
+ #define PG_TEMP_FILES_DIR "pgsql_tmp"
63
+ #define PG_TEMP_FILE_PREFIX "pgsql_tmp"
64
+
65
+ #endif /* FILE_UTILS_H */
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Utilities for working with hash values.
3
3
  *
4
- * Portions Copyright (c) 2017-2023, PostgreSQL Global Development Group
4
+ * Portions Copyright (c) 2017-2024, PostgreSQL Global Development Group
5
5
  */
6
6
 
7
7
  #ifndef HASHFN_H
@@ -101,4 +101,19 @@ murmurhash32(uint32 data)
101
101
  return h;
102
102
  }
103
103
 
104
+ /* 64-bit variant */
105
+ static inline uint64
106
+ murmurhash64(uint64 data)
107
+ {
108
+ uint64 h = data;
109
+
110
+ h ^= h >> 33;
111
+ h *= 0xff51afd7ed558ccd;
112
+ h ^= h >> 33;
113
+ h *= 0xc4ceb9fe1a85ec53;
114
+ h ^= h >> 33;
115
+
116
+ return h;
117
+ }
118
+
104
119
  #endif /* HASHFN_H */
@@ -0,0 +1,453 @@
1
+ /*
2
+ * hashfn_unstable.h
3
+ *
4
+ * Building blocks for creating fast inlineable hash functions. The
5
+ * functions in this file are not guaranteed to be stable between versions,
6
+ * and may differ by hardware platform. Hence they must not be used in
7
+ * indexes or other on-disk structures. See hashfn.h if you need stability.
8
+ *
9
+ *
10
+ * Portions Copyright (c) 2024, PostgreSQL Global Development Group
11
+ *
12
+ * src/include/common/hashfn_unstable.h
13
+ */
14
+ #ifndef HASHFN_UNSTABLE_H
15
+ #define HASHFN_UNSTABLE_H
16
+
17
+ #include "port/pg_bitutils.h"
18
+ #include "port/pg_bswap.h"
19
+
20
+ /*
21
+ * fasthash is a modification of code taken from
22
+ * https://code.google.com/archive/p/fast-hash/source/default/source
23
+ * under the terms of the MIT license. The original copyright
24
+ * notice follows:
25
+ */
26
+
27
+ /* The MIT License
28
+
29
+ Copyright (C) 2012 Zilong Tan (eric.zltan@gmail.com)
30
+
31
+ Permission is hereby granted, free of charge, to any person
32
+ obtaining a copy of this software and associated documentation
33
+ files (the "Software"), to deal in the Software without
34
+ restriction, including without limitation the rights to use, copy,
35
+ modify, merge, publish, distribute, sublicense, and/or sell copies
36
+ of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, subject to the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
45
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
46
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
47
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49
+ SOFTWARE.
50
+ */
51
+
52
+ /*
53
+ * fasthash as implemented here has two interfaces:
54
+ *
55
+ * 1) Standalone functions, e.g. fasthash32() for a single value with a
56
+ * known length. These return the same hash code as the original, at
57
+ * least on little-endian machines.
58
+ *
59
+ * 2) Incremental interface. This can used for incorporating multiple
60
+ * inputs. First, initialize the hash state (here with a zero seed):
61
+ *
62
+ * fasthash_state hs;
63
+ * fasthash_init(&hs, 0);
64
+ *
65
+ * If the inputs are of types that can be trivially cast to uint64, it's
66
+ * sufficient to do:
67
+ *
68
+ * hs.accum = value1;
69
+ * fasthash_combine(&hs);
70
+ * hs.accum = value2;
71
+ * fasthash_combine(&hs);
72
+ * ...
73
+ *
74
+ * For longer or variable-length input, fasthash_accum() is a more
75
+ * flexible, but more verbose method. The standalone functions use this
76
+ * internally, so see fasthash64() for an example of this.
77
+ *
78
+ * After all inputs have been mixed in, finalize the hash:
79
+ *
80
+ * hashcode = fasthash_final32(&hs, 0);
81
+ *
82
+ * The incremental interface allows an optimization for NUL-terminated
83
+ * C strings:
84
+ *
85
+ * len = fasthash_accum_cstring(&hs, str);
86
+ * hashcode = fasthash_final32(&hs, len);
87
+ *
88
+ * By handling the terminator on-the-fly, we can avoid needing a strlen()
89
+ * call to tell us how many bytes to hash. Experimentation has found that
90
+ * SMHasher fails unless we incorporate the length, so it is passed to
91
+ * the finalizer as a tweak.
92
+ */
93
+
94
+
95
+ typedef struct fasthash_state
96
+ {
97
+ /* staging area for chunks of input */
98
+ uint64 accum;
99
+
100
+ uint64 hash;
101
+ } fasthash_state;
102
+
103
+ #define FH_SIZEOF_ACCUM sizeof(uint64)
104
+
105
+
106
+ /*
107
+ * Initialize the hash state.
108
+ *
109
+ * 'seed' can be zero.
110
+ */
111
+ static inline void
112
+ fasthash_init(fasthash_state *hs, uint64 seed)
113
+ {
114
+ memset(hs, 0, sizeof(fasthash_state));
115
+ hs->hash = seed ^ 0x880355f21e6d1965;
116
+ }
117
+
118
+ /* both the finalizer and part of the combining step */
119
+ static inline uint64
120
+ fasthash_mix(uint64 h, uint64 tweak)
121
+ {
122
+ h ^= (h >> 23) + tweak;
123
+ h *= 0x2127599bf4325c37;
124
+ h ^= h >> 47;
125
+ return h;
126
+ }
127
+
128
+ /* combine one chunk of input into the hash */
129
+ static inline void
130
+ fasthash_combine(fasthash_state *hs)
131
+ {
132
+ hs->hash ^= fasthash_mix(hs->accum, 0);
133
+ hs->hash *= 0x880355f21e6d1965;
134
+ }
135
+
136
+ /* accumulate up to 8 bytes of input and combine it into the hash */
137
+ static inline void
138
+ fasthash_accum(fasthash_state *hs, const char *k, size_t len)
139
+ {
140
+ uint32 lower_four;
141
+
142
+ Assert(len <= FH_SIZEOF_ACCUM);
143
+ hs->accum = 0;
144
+
145
+ /*
146
+ * For consistency, bytewise loads must match the platform's endianness.
147
+ */
148
+ #ifdef WORDS_BIGENDIAN
149
+ switch (len)
150
+ {
151
+ case 8:
152
+ memcpy(&hs->accum, k, 8);
153
+ break;
154
+ case 7:
155
+ hs->accum |= (uint64) k[6] << 8;
156
+ /* FALLTHROUGH */
157
+ case 6:
158
+ hs->accum |= (uint64) k[5] << 16;
159
+ /* FALLTHROUGH */
160
+ case 5:
161
+ hs->accum |= (uint64) k[4] << 24;
162
+ /* FALLTHROUGH */
163
+ case 4:
164
+ memcpy(&lower_four, k, sizeof(lower_four));
165
+ hs->accum |= (uint64) lower_four << 32;
166
+ break;
167
+ case 3:
168
+ hs->accum |= (uint64) k[2] << 40;
169
+ /* FALLTHROUGH */
170
+ case 2:
171
+ hs->accum |= (uint64) k[1] << 48;
172
+ /* FALLTHROUGH */
173
+ case 1:
174
+ hs->accum |= (uint64) k[0] << 56;
175
+ break;
176
+ case 0:
177
+ return;
178
+ }
179
+ #else
180
+ switch (len)
181
+ {
182
+ case 8:
183
+ memcpy(&hs->accum, k, 8);
184
+ break;
185
+ case 7:
186
+ hs->accum |= (uint64) k[6] << 48;
187
+ /* FALLTHROUGH */
188
+ case 6:
189
+ hs->accum |= (uint64) k[5] << 40;
190
+ /* FALLTHROUGH */
191
+ case 5:
192
+ hs->accum |= (uint64) k[4] << 32;
193
+ /* FALLTHROUGH */
194
+ case 4:
195
+ memcpy(&lower_four, k, sizeof(lower_four));
196
+ hs->accum |= lower_four;
197
+ break;
198
+ case 3:
199
+ hs->accum |= (uint64) k[2] << 16;
200
+ /* FALLTHROUGH */
201
+ case 2:
202
+ hs->accum |= (uint64) k[1] << 8;
203
+ /* FALLTHROUGH */
204
+ case 1:
205
+ hs->accum |= (uint64) k[0];
206
+ break;
207
+ case 0:
208
+ return;
209
+ }
210
+ #endif
211
+
212
+ fasthash_combine(hs);
213
+ }
214
+
215
+ /*
216
+ * Set high bit in lowest byte where the input is zero, from:
217
+ * https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord
218
+ */
219
+ #define haszero64(v) \
220
+ (((v) - 0x0101010101010101) & ~(v) & 0x8080808080808080)
221
+
222
+ /* get first byte in memory order */
223
+ #ifdef WORDS_BIGENDIAN
224
+ #define firstbyte64(v) ((v) >> 56)
225
+ #else
226
+ #define firstbyte64(v) ((v) & 0xFF)
227
+ #endif
228
+
229
+ /*
230
+ * all-purpose workhorse for fasthash_accum_cstring
231
+ */
232
+ static inline size_t
233
+ fasthash_accum_cstring_unaligned(fasthash_state *hs, const char *str)
234
+ {
235
+ const char *const start = str;
236
+
237
+ while (*str)
238
+ {
239
+ size_t chunk_len = 0;
240
+
241
+ while (chunk_len < FH_SIZEOF_ACCUM && str[chunk_len] != '\0')
242
+ chunk_len++;
243
+
244
+ fasthash_accum(hs, str, chunk_len);
245
+ str += chunk_len;
246
+ }
247
+
248
+ return str - start;
249
+ }
250
+
251
+ /*
252
+ * specialized workhorse for fasthash_accum_cstring
253
+ *
254
+ * With an aligned pointer, we consume the string a word at a time.
255
+ * Loading the word containing the NUL terminator cannot segfault since
256
+ * allocation boundaries are suitably aligned. To keep from setting
257
+ * off alarms with address sanitizers, exclude this function from
258
+ * such testing.
259
+ */
260
+ pg_attribute_no_sanitize_address()
261
+ static inline size_t
262
+ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
263
+ {
264
+ const char *const start = str;
265
+ uint64 chunk;
266
+ uint64 zero_byte_low;
267
+
268
+ Assert(PointerIsAligned(start, uint64));
269
+
270
+ /*
271
+ * For every chunk of input, check for zero bytes before mixing into the
272
+ * hash. The chunk with zeros must contain the NUL terminator. We arrange
273
+ * so that zero_byte_low tells us not only that a zero exists, but also
274
+ * where it is, so we can hash the remainder of the string.
275
+ *
276
+ * The haszero64 calculation will set bits corresponding to the lowest
277
+ * byte where a zero exists, so that suffices for little-endian machines.
278
+ * For big-endian machines, we would need bits set for the highest zero
279
+ * byte in the chunk, since the trailing junk past the terminator could
280
+ * contain additional zeros. haszero64 does not give us that, so we
281
+ * byteswap the chunk first.
282
+ */
283
+ for (;;)
284
+ {
285
+ chunk = *(uint64 *) str;
286
+
287
+ #ifdef WORDS_BIGENDIAN
288
+ zero_byte_low = haszero64(pg_bswap64(chunk));
289
+ #else
290
+ zero_byte_low = haszero64(chunk);
291
+ #endif
292
+ if (zero_byte_low)
293
+ break;
294
+
295
+ hs->accum = chunk;
296
+ fasthash_combine(hs);
297
+ str += FH_SIZEOF_ACCUM;
298
+ }
299
+
300
+ if (firstbyte64(chunk) != 0)
301
+ {
302
+ size_t remainder;
303
+ uint64 mask;
304
+
305
+ /*
306
+ * The byte corresponding to the NUL will be 0x80, so the rightmost
307
+ * bit position will be in the range 15, 23, ..., 63. Turn this into
308
+ * byte position by dividing by 8.
309
+ */
310
+ remainder = pg_rightmost_one_pos64(zero_byte_low) / BITS_PER_BYTE;
311
+
312
+ /*
313
+ * Create a mask for the remaining bytes so we can combine them into
314
+ * the hash. This must have the same result as mixing the remaining
315
+ * bytes with fasthash_accum().
316
+ */
317
+ #ifdef WORDS_BIGENDIAN
318
+ mask = ~UINT64CONST(0) << BITS_PER_BYTE * (FH_SIZEOF_ACCUM - remainder);
319
+ #else
320
+ mask = ~UINT64CONST(0) >> BITS_PER_BYTE * (FH_SIZEOF_ACCUM - remainder);
321
+ #endif
322
+ hs->accum = chunk & mask;
323
+ fasthash_combine(hs);
324
+
325
+ str += remainder;
326
+ }
327
+
328
+ return str - start;
329
+ }
330
+
331
+ /*
332
+ * Mix 'str' into the hash state and return the length of the string.
333
+ */
334
+ static inline size_t
335
+ fasthash_accum_cstring(fasthash_state *hs, const char *str)
336
+ {
337
+ #if SIZEOF_VOID_P >= 8
338
+
339
+ size_t len;
340
+ #ifdef USE_ASSERT_CHECKING
341
+ size_t len_check;
342
+ fasthash_state hs_check;
343
+
344
+ memcpy(&hs_check, hs, sizeof(fasthash_state));
345
+ len_check = fasthash_accum_cstring_unaligned(&hs_check, str);
346
+ #endif
347
+ if (PointerIsAligned(str, uint64))
348
+ {
349
+ len = fasthash_accum_cstring_aligned(hs, str);
350
+ Assert(len_check == len);
351
+ Assert(hs_check.hash == hs->hash);
352
+ return len;
353
+ }
354
+ #endif /* SIZEOF_VOID_P */
355
+
356
+ /*
357
+ * It's not worth it to try to make the word-at-a-time optimization work
358
+ * on 32-bit platforms.
359
+ */
360
+ return fasthash_accum_cstring_unaligned(hs, str);
361
+ }
362
+
363
+ /*
364
+ * The finalizer
365
+ *
366
+ * 'tweak' is intended to be the input length when the caller doesn't know
367
+ * the length ahead of time, such as for NUL-terminated strings, otherwise
368
+ * zero.
369
+ */
370
+ static inline uint64
371
+ fasthash_final64(fasthash_state *hs, uint64 tweak)
372
+ {
373
+ return fasthash_mix(hs->hash, tweak);
374
+ }
375
+
376
+ /*
377
+ * Reduce a 64-bit hash to a 32-bit hash.
378
+ *
379
+ * This optional step provides a bit more additional mixing compared to
380
+ * just taking the lower 32-bits.
381
+ */
382
+ static inline uint32
383
+ fasthash_reduce32(uint64 h)
384
+ {
385
+ /*
386
+ * Convert the 64-bit hashcode to Fermat residue, which shall retain
387
+ * information from both the higher and lower parts of hashcode.
388
+ */
389
+ return h - (h >> 32);
390
+ }
391
+
392
+ /* finalize and reduce */
393
+ static inline uint32
394
+ fasthash_final32(fasthash_state *hs, uint64 tweak)
395
+ {
396
+ return fasthash_reduce32(fasthash_final64(hs, tweak));
397
+ }
398
+
399
+ /*
400
+ * The original fasthash64 function, re-implemented using the incremental
401
+ * interface. Returns a 64-bit hashcode. 'len' controls not only how
402
+ * many bytes to hash, but also modifies the internal seed.
403
+ * 'seed' can be zero.
404
+ */
405
+ static inline uint64
406
+ fasthash64(const char *k, size_t len, uint64 seed)
407
+ {
408
+ fasthash_state hs;
409
+
410
+ fasthash_init(&hs, 0);
411
+
412
+ /* re-initialize the seed according to input length */
413
+ hs.hash = seed ^ (len * 0x880355f21e6d1965);
414
+
415
+ while (len >= FH_SIZEOF_ACCUM)
416
+ {
417
+ fasthash_accum(&hs, k, FH_SIZEOF_ACCUM);
418
+ k += FH_SIZEOF_ACCUM;
419
+ len -= FH_SIZEOF_ACCUM;
420
+ }
421
+
422
+ fasthash_accum(&hs, k, len);
423
+ return fasthash_final64(&hs, 0);
424
+ }
425
+
426
+ /* like fasthash64, but returns a 32-bit hashcode */
427
+ static inline uint32
428
+ fasthash32(const char *k, size_t len, uint64 seed)
429
+ {
430
+ return fasthash_reduce32(fasthash64(k, len, seed));
431
+ }
432
+
433
+ /*
434
+ * Convenience function for hashing NUL-terminated strings
435
+ */
436
+ static inline uint32
437
+ hash_string(const char *s)
438
+ {
439
+ fasthash_state hs;
440
+ size_t s_len;
441
+
442
+ fasthash_init(&hs, 0);
443
+
444
+ /*
445
+ * Combine string into the hash and save the length for tweaking the final
446
+ * mix.
447
+ */
448
+ s_len = fasthash_accum_cstring(&hs, s);
449
+
450
+ return fasthash_final32(&hs, s_len);
451
+ }
452
+
453
+ #endif /* HASHFN_UNSTABLE_H */