pg_query 2.2.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (465) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Rakefile +2 -2
  4. data/ext/pg_query/include/access/amapi.h +45 -1
  5. data/ext/pg_query/include/access/attmap.h +1 -1
  6. data/ext/pg_query/include/access/attnum.h +2 -2
  7. data/ext/pg_query/include/access/clog.h +4 -2
  8. data/ext/pg_query/include/access/commit_ts.h +6 -9
  9. data/ext/pg_query/include/access/detoast.h +1 -11
  10. data/ext/pg_query/include/access/genam.h +15 -12
  11. data/ext/pg_query/include/access/gin.h +2 -2
  12. data/ext/pg_query/include/access/htup.h +1 -1
  13. data/ext/pg_query/include/access/htup_details.h +75 -87
  14. data/ext/pg_query/include/access/itup.h +7 -1
  15. data/ext/pg_query/include/access/parallel.h +2 -2
  16. data/ext/pg_query/include/access/printtup.h +1 -1
  17. data/ext/pg_query/include/access/relation.h +1 -1
  18. data/ext/pg_query/include/access/relscan.h +17 -2
  19. data/ext/pg_query/include/access/rmgr.h +30 -3
  20. data/ext/pg_query/include/access/rmgrlist.h +23 -23
  21. data/ext/pg_query/include/access/sdir.h +1 -1
  22. data/ext/pg_query/include/access/skey.h +1 -1
  23. data/ext/pg_query/include/access/stratnum.h +4 -2
  24. data/ext/pg_query/include/access/sysattr.h +1 -1
  25. data/ext/pg_query/include/access/table.h +2 -1
  26. data/ext/pg_query/include/access/tableam.h +272 -20
  27. data/ext/pg_query/include/access/toast_compression.h +73 -0
  28. data/ext/pg_query/include/access/transam.h +123 -13
  29. data/ext/pg_query/include/access/tupconvert.h +1 -1
  30. data/ext/pg_query/include/access/tupdesc.h +1 -1
  31. data/ext/pg_query/include/access/tupmacs.h +3 -3
  32. data/ext/pg_query/include/access/twophase.h +3 -1
  33. data/ext/pg_query/include/access/xact.h +73 -19
  34. data/ext/pg_query/include/access/xlog.h +60 -155
  35. data/ext/pg_query/include/access/xlog_internal.h +40 -13
  36. data/ext/pg_query/include/access/xlogdefs.h +8 -16
  37. data/ext/pg_query/include/access/xlogprefetcher.h +55 -0
  38. data/ext/pg_query/include/access/xlogreader.h +145 -39
  39. data/ext/pg_query/include/access/xlogrecord.h +18 -9
  40. data/ext/pg_query/include/access/xlogrecovery.h +157 -0
  41. data/ext/pg_query/include/c.h +101 -44
  42. data/ext/pg_query/include/catalog/catalog.h +3 -1
  43. data/ext/pg_query/include/catalog/catversion.h +2 -2
  44. data/ext/pg_query/include/catalog/dependency.h +8 -16
  45. data/ext/pg_query/include/catalog/genbki.h +83 -5
  46. data/ext/pg_query/include/catalog/index.h +18 -3
  47. data/ext/pg_query/include/catalog/indexing.h +12 -324
  48. data/ext/pg_query/include/catalog/namespace.h +4 -2
  49. data/ext/pg_query/include/catalog/objectaccess.h +70 -2
  50. data/ext/pg_query/include/catalog/objectaddress.h +11 -6
  51. data/ext/pg_query/include/catalog/pg_aggregate.h +14 -10
  52. data/ext/pg_query/include/catalog/pg_aggregate_d.h +2 -1
  53. data/ext/pg_query/include/catalog/pg_am.h +4 -1
  54. data/ext/pg_query/include/catalog/pg_am_d.h +3 -1
  55. data/ext/pg_query/include/catalog/pg_attribute.h +27 -10
  56. data/ext/pg_query/include/catalog/pg_attribute_d.h +21 -18
  57. data/ext/pg_query/include/catalog/pg_authid.h +7 -2
  58. data/ext/pg_query/include/catalog/pg_authid_d.h +17 -9
  59. data/ext/pg_query/include/catalog/pg_class.h +44 -14
  60. data/ext/pg_query/include/catalog/pg_class_d.h +30 -1
  61. data/ext/pg_query/include/catalog/pg_collation.h +33 -8
  62. data/ext/pg_query/include/catalog/pg_collation_d.h +20 -3
  63. data/ext/pg_query/include/catalog/pg_constraint.h +38 -12
  64. data/ext/pg_query/include/catalog/pg_constraint_d.h +10 -4
  65. data/ext/pg_query/include/catalog/pg_control.h +3 -5
  66. data/ext/pg_query/include/catalog/pg_conversion.h +7 -4
  67. data/ext/pg_query/include/catalog/pg_conversion_d.h +4 -1
  68. data/ext/pg_query/include/catalog/pg_depend.h +11 -7
  69. data/ext/pg_query/include/catalog/pg_depend_d.h +3 -1
  70. data/ext/pg_query/include/catalog/pg_event_trigger.h +9 -3
  71. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +3 -1
  72. data/ext/pg_query/include/catalog/pg_index.h +17 -7
  73. data/ext/pg_query/include/catalog/pg_index_d.h +20 -17
  74. data/ext/pg_query/include/catalog/pg_language.h +10 -5
  75. data/ext/pg_query/include/catalog/pg_language_d.h +3 -1
  76. data/ext/pg_query/include/catalog/pg_namespace.h +7 -2
  77. data/ext/pg_query/include/catalog/pg_namespace_d.h +3 -1
  78. data/ext/pg_query/include/catalog/pg_opclass.h +8 -5
  79. data/ext/pg_query/include/catalog/pg_opclass_d.h +3 -1
  80. data/ext/pg_query/include/catalog/pg_operator.h +18 -15
  81. data/ext/pg_query/include/catalog/pg_operator_d.h +37 -1
  82. data/ext/pg_query/include/catalog/pg_opfamily.h +6 -3
  83. data/ext/pg_query/include/catalog/pg_opfamily_d.h +3 -1
  84. data/ext/pg_query/include/catalog/pg_parameter_acl.h +60 -0
  85. data/ext/pg_query/include/catalog/pg_parameter_acl_d.h +34 -0
  86. data/ext/pg_query/include/catalog/pg_partitioned_table.h +20 -9
  87. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +2 -1
  88. data/ext/pg_query/include/catalog/pg_proc.h +20 -11
  89. data/ext/pg_query/include/catalog/pg_proc_d.h +10 -8
  90. data/ext/pg_query/include/catalog/pg_publication.h +50 -7
  91. data/ext/pg_query/include/catalog/pg_publication_d.h +3 -1
  92. data/ext/pg_query/include/catalog/pg_replication_origin.h +6 -1
  93. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +5 -1
  94. data/ext/pg_query/include/catalog/pg_statistic.h +19 -12
  95. data/ext/pg_query/include/catalog/pg_statistic_d.h +2 -1
  96. data/ext/pg_query/include/catalog/pg_statistic_ext.h +19 -5
  97. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +7 -2
  98. data/ext/pg_query/include/catalog/pg_transform.h +8 -5
  99. data/ext/pg_query/include/catalog/pg_transform_d.h +3 -1
  100. data/ext/pg_query/include/catalog/pg_trigger.h +24 -8
  101. data/ext/pg_query/include/catalog/pg_trigger_d.h +4 -1
  102. data/ext/pg_query/include/catalog/pg_ts_config.h +6 -3
  103. data/ext/pg_query/include/catalog/pg_ts_config_d.h +3 -1
  104. data/ext/pg_query/include/catalog/pg_ts_dict.h +8 -3
  105. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +3 -1
  106. data/ext/pg_query/include/catalog/pg_ts_parser.h +6 -3
  107. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +3 -1
  108. data/ext/pg_query/include/catalog/pg_ts_template.h +6 -3
  109. data/ext/pg_query/include/catalog/pg_ts_template_d.h +3 -1
  110. data/ext/pg_query/include/catalog/pg_type.h +55 -24
  111. data/ext/pg_query/include/catalog/pg_type_d.h +70 -31
  112. data/ext/pg_query/include/catalog/storage.h +5 -3
  113. data/ext/pg_query/include/commands/async.h +3 -4
  114. data/ext/pg_query/include/commands/dbcommands.h +2 -1
  115. data/ext/pg_query/include/commands/defrem.h +11 -24
  116. data/ext/pg_query/include/commands/event_trigger.h +2 -2
  117. data/ext/pg_query/include/commands/explain.h +1 -1
  118. data/ext/pg_query/include/commands/prepare.h +1 -1
  119. data/ext/pg_query/include/commands/tablespace.h +2 -2
  120. data/ext/pg_query/include/commands/trigger.h +18 -16
  121. data/ext/pg_query/include/commands/user.h +2 -2
  122. data/ext/pg_query/include/commands/vacuum.h +88 -41
  123. data/ext/pg_query/include/commands/variable.h +1 -1
  124. data/ext/pg_query/include/common/file_perm.h +4 -4
  125. data/ext/pg_query/include/common/hashfn.h +1 -1
  126. data/ext/pg_query/include/common/ip.h +1 -7
  127. data/ext/pg_query/include/common/keywords.h +2 -6
  128. data/ext/pg_query/include/common/kwlookup.h +1 -1
  129. data/ext/pg_query/include/common/pg_prng.h +60 -0
  130. data/ext/pg_query/include/common/relpath.h +2 -2
  131. data/ext/pg_query/include/common/string.h +24 -1
  132. data/ext/pg_query/include/common/unicode_combining_table.h +114 -2
  133. data/ext/pg_query/include/common/unicode_east_asian_fw_table.h +125 -0
  134. data/ext/pg_query/include/datatype/timestamp.h +40 -1
  135. data/ext/pg_query/include/executor/execdesc.h +1 -1
  136. data/ext/pg_query/include/executor/executor.h +65 -22
  137. data/ext/pg_query/include/executor/functions.h +17 -3
  138. data/ext/pg_query/include/executor/instrument.h +33 -16
  139. data/ext/pg_query/include/executor/spi.h +41 -3
  140. data/ext/pg_query/include/executor/tablefunc.h +1 -1
  141. data/ext/pg_query/include/executor/tuptable.h +1 -1
  142. data/ext/pg_query/include/fmgr.h +13 -7
  143. data/ext/pg_query/include/funcapi.h +16 -4
  144. data/ext/pg_query/include/getaddrinfo.h +1 -1
  145. data/ext/pg_query/include/jit/jit.h +11 -11
  146. data/ext/pg_query/include/kwlist_d.h +517 -494
  147. data/ext/pg_query/include/lib/dshash.h +112 -0
  148. data/ext/pg_query/include/lib/ilist.h +20 -1
  149. data/ext/pg_query/include/lib/pairingheap.h +1 -1
  150. data/ext/pg_query/include/lib/simplehash.h +140 -15
  151. data/ext/pg_query/include/lib/sort_template.h +432 -0
  152. data/ext/pg_query/include/lib/stringinfo.h +1 -1
  153. data/ext/pg_query/include/libpq/auth.h +6 -4
  154. data/ext/pg_query/include/libpq/crypt.h +5 -4
  155. data/ext/pg_query/include/libpq/hba.h +43 -4
  156. data/ext/pg_query/include/libpq/libpq-be.h +23 -6
  157. data/ext/pg_query/include/libpq/libpq.h +30 -20
  158. data/ext/pg_query/include/libpq/pqcomm.h +17 -31
  159. data/ext/pg_query/include/libpq/pqformat.h +1 -1
  160. data/ext/pg_query/include/libpq/pqsignal.h +4 -4
  161. data/ext/pg_query/include/mb/pg_wchar.h +105 -23
  162. data/ext/pg_query/include/mb/stringinfo_mb.h +1 -1
  163. data/ext/pg_query/include/miscadmin.h +47 -41
  164. data/ext/pg_query/include/nodes/bitmapset.h +1 -1
  165. data/ext/pg_query/include/nodes/execnodes.h +270 -78
  166. data/ext/pg_query/include/nodes/extensible.h +4 -2
  167. data/ext/pg_query/include/nodes/lockoptions.h +1 -1
  168. data/ext/pg_query/include/nodes/makefuncs.h +7 -6
  169. data/ext/pg_query/include/nodes/memnodes.h +5 -3
  170. data/ext/pg_query/include/nodes/nodeFuncs.h +1 -1
  171. data/ext/pg_query/include/nodes/nodes.h +30 -11
  172. data/ext/pg_query/include/nodes/params.h +1 -1
  173. data/ext/pg_query/include/nodes/parsenodes.h +322 -90
  174. data/ext/pg_query/include/nodes/pathnodes.h +243 -66
  175. data/ext/pg_query/include/nodes/pg_list.h +75 -69
  176. data/ext/pg_query/include/nodes/plannodes.h +111 -28
  177. data/ext/pg_query/include/nodes/primnodes.h +99 -47
  178. data/ext/pg_query/include/nodes/print.h +1 -1
  179. data/ext/pg_query/include/nodes/tidbitmap.h +1 -1
  180. data/ext/pg_query/include/nodes/value.h +58 -39
  181. data/ext/pg_query/include/optimizer/cost.h +9 -2
  182. data/ext/pg_query/include/optimizer/geqo.h +9 -7
  183. data/ext/pg_query/include/optimizer/geqo_gene.h +1 -1
  184. data/ext/pg_query/include/optimizer/optimizer.h +25 -17
  185. data/ext/pg_query/include/optimizer/paths.h +6 -6
  186. data/ext/pg_query/include/optimizer/planmain.h +15 -14
  187. data/ext/pg_query/include/parser/analyze.h +19 -5
  188. data/ext/pg_query/include/parser/gram.h +947 -913
  189. data/ext/pg_query/include/parser/gramparse.h +1 -1
  190. data/ext/pg_query/include/parser/kwlist.h +463 -453
  191. data/ext/pg_query/include/parser/parse_agg.h +2 -7
  192. data/ext/pg_query/include/parser/parse_coerce.h +3 -1
  193. data/ext/pg_query/include/parser/parse_expr.h +2 -3
  194. data/ext/pg_query/include/parser/parse_func.h +2 -1
  195. data/ext/pg_query/include/parser/parse_node.h +21 -9
  196. data/ext/pg_query/include/parser/parse_oper.h +1 -3
  197. data/ext/pg_query/include/parser/parse_relation.h +5 -4
  198. data/ext/pg_query/include/parser/parse_type.h +1 -1
  199. data/ext/pg_query/include/parser/parser.h +31 -4
  200. data/ext/pg_query/include/parser/parsetree.h +1 -1
  201. data/ext/pg_query/include/parser/scanner.h +1 -1
  202. data/ext/pg_query/include/parser/scansup.h +2 -5
  203. data/ext/pg_query/include/partitioning/partdefs.h +1 -1
  204. data/ext/pg_query/include/pg_config.h +83 -41
  205. data/ext/pg_query/include/pg_config_manual.h +74 -21
  206. data/ext/pg_query/include/pg_getopt.h +6 -6
  207. data/ext/pg_query/include/pg_query.h +5 -4
  208. data/ext/pg_query/include/pg_query_enum_defs.c +358 -241
  209. data/ext/pg_query/include/pg_query_fingerprint_conds.c +44 -7
  210. data/ext/pg_query/include/pg_query_fingerprint_defs.c +939 -113
  211. data/ext/pg_query/include/pg_query_outfuncs_conds.c +43 -13
  212. data/ext/pg_query/include/pg_query_outfuncs_defs.c +151 -26
  213. data/ext/pg_query/include/pg_query_readfuncs_conds.c +11 -2
  214. data/ext/pg_query/include/pg_query_readfuncs_defs.c +173 -30
  215. data/ext/pg_query/include/pg_trace.h +1 -1
  216. data/ext/pg_query/include/pgstat.h +449 -1238
  217. data/ext/pg_query/include/pgtime.h +14 -4
  218. data/ext/pg_query/include/pl_gram.h +126 -128
  219. data/ext/pg_query/include/pl_reserved_kwlist.h +1 -1
  220. data/ext/pg_query/include/pl_reserved_kwlist_d.h +10 -10
  221. data/ext/pg_query/include/pl_unreserved_kwlist.h +2 -3
  222. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +54 -56
  223. data/ext/pg_query/include/plerrcodes.h +9 -1
  224. data/ext/pg_query/include/plpgsql.h +52 -54
  225. data/ext/pg_query/include/port/atomics/arch-arm.h +7 -1
  226. data/ext/pg_query/include/port/atomics/arch-ppc.h +1 -1
  227. data/ext/pg_query/include/port/atomics/arch-x86.h +1 -1
  228. data/ext/pg_query/include/port/atomics/fallback.h +1 -1
  229. data/ext/pg_query/include/port/atomics/generic-gcc.h +3 -3
  230. data/ext/pg_query/include/port/atomics/generic.h +1 -1
  231. data/ext/pg_query/include/port/atomics.h +1 -1
  232. data/ext/pg_query/include/port/pg_bitutils.h +40 -10
  233. data/ext/pg_query/include/port/pg_bswap.h +1 -1
  234. data/ext/pg_query/include/port/pg_crc32c.h +1 -1
  235. data/ext/pg_query/include/port.h +71 -46
  236. data/ext/pg_query/include/portability/instr_time.h +1 -1
  237. data/ext/pg_query/include/postgres.h +60 -16
  238. data/ext/pg_query/include/postmaster/autovacuum.h +17 -17
  239. data/ext/pg_query/include/postmaster/auxprocess.h +20 -0
  240. data/ext/pg_query/include/postmaster/bgworker.h +2 -1
  241. data/ext/pg_query/include/postmaster/bgworker_internals.h +2 -2
  242. data/ext/pg_query/include/postmaster/bgwriter.h +5 -5
  243. data/ext/pg_query/include/postmaster/fork_process.h +1 -1
  244. data/ext/pg_query/include/postmaster/interrupt.h +1 -1
  245. data/ext/pg_query/include/postmaster/pgarch.h +42 -8
  246. data/ext/pg_query/include/postmaster/postmaster.h +18 -17
  247. data/ext/pg_query/include/postmaster/startup.h +39 -0
  248. data/ext/pg_query/include/postmaster/syslogger.h +15 -10
  249. data/ext/pg_query/include/postmaster/walwriter.h +3 -3
  250. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1419 -914
  251. data/ext/pg_query/include/protobuf/pg_query.pb.h +43678 -32769
  252. data/ext/pg_query/include/regex/regex.h +18 -16
  253. data/ext/pg_query/include/replication/logicallauncher.h +3 -5
  254. data/ext/pg_query/include/replication/logicalproto.h +161 -17
  255. data/ext/pg_query/include/replication/logicalworker.h +1 -1
  256. data/ext/pg_query/include/replication/origin.h +7 -7
  257. data/ext/pg_query/include/replication/reorderbuffer.h +259 -42
  258. data/ext/pg_query/include/replication/slot.h +22 -11
  259. data/ext/pg_query/include/replication/syncrep.h +5 -5
  260. data/ext/pg_query/include/replication/walreceiver.h +145 -13
  261. data/ext/pg_query/include/replication/walsender.h +8 -8
  262. data/ext/pg_query/include/rewrite/prs2lock.h +1 -1
  263. data/ext/pg_query/include/rewrite/rewriteHandler.h +1 -3
  264. data/ext/pg_query/include/rewrite/rewriteManip.h +1 -1
  265. data/ext/pg_query/include/rewrite/rewriteSupport.h +1 -1
  266. data/ext/pg_query/include/storage/backendid.h +3 -3
  267. data/ext/pg_query/include/storage/block.h +4 -10
  268. data/ext/pg_query/include/storage/buf.h +1 -1
  269. data/ext/pg_query/include/storage/bufmgr.h +19 -14
  270. data/ext/pg_query/include/storage/bufpage.h +6 -8
  271. data/ext/pg_query/include/storage/condition_variable.h +13 -2
  272. data/ext/pg_query/include/storage/dsm.h +4 -1
  273. data/ext/pg_query/include/storage/dsm_impl.h +3 -2
  274. data/ext/pg_query/include/storage/fd.h +33 -3
  275. data/ext/pg_query/include/storage/fileset.h +40 -0
  276. data/ext/pg_query/include/storage/ipc.h +4 -1
  277. data/ext/pg_query/include/storage/item.h +1 -1
  278. data/ext/pg_query/include/storage/itemid.h +1 -1
  279. data/ext/pg_query/include/storage/itemptr.h +3 -1
  280. data/ext/pg_query/include/storage/large_object.h +2 -2
  281. data/ext/pg_query/include/storage/latch.h +9 -13
  282. data/ext/pg_query/include/storage/lmgr.h +2 -1
  283. data/ext/pg_query/include/storage/lock.h +11 -8
  284. data/ext/pg_query/include/storage/lockdefs.h +2 -2
  285. data/ext/pg_query/include/storage/lwlock.h +5 -32
  286. data/ext/pg_query/include/storage/lwlocknames.h +0 -1
  287. data/ext/pg_query/include/storage/off.h +1 -1
  288. data/ext/pg_query/include/storage/pg_sema.h +1 -1
  289. data/ext/pg_query/include/storage/pg_shmem.h +9 -7
  290. data/ext/pg_query/include/storage/pmsignal.h +15 -4
  291. data/ext/pg_query/include/storage/predicate.h +4 -4
  292. data/ext/pg_query/include/storage/proc.h +173 -59
  293. data/ext/pg_query/include/storage/procarray.h +98 -0
  294. data/ext/pg_query/include/storage/proclist_types.h +1 -1
  295. data/ext/pg_query/include/storage/procsignal.h +3 -7
  296. data/ext/pg_query/include/storage/relfilenode.h +1 -1
  297. data/ext/pg_query/include/storage/s_lock.h +60 -21
  298. data/ext/pg_query/include/storage/sharedfileset.h +3 -11
  299. data/ext/pg_query/include/storage/shm_mq.h +5 -4
  300. data/ext/pg_query/include/storage/shm_toc.h +1 -1
  301. data/ext/pg_query/include/storage/shmem.h +1 -1
  302. data/ext/pg_query/include/storage/sinval.h +3 -3
  303. data/ext/pg_query/include/storage/sinvaladt.h +1 -1
  304. data/ext/pg_query/include/storage/smgr.h +10 -8
  305. data/ext/pg_query/include/storage/spin.h +2 -2
  306. data/ext/pg_query/include/storage/standby.h +13 -6
  307. data/ext/pg_query/include/storage/standbydefs.h +2 -2
  308. data/ext/pg_query/include/storage/sync.h +7 -3
  309. data/ext/pg_query/include/tcop/cmdtag.h +1 -1
  310. data/ext/pg_query/include/tcop/cmdtaglist.h +3 -2
  311. data/ext/pg_query/include/tcop/deparse_utility.h +1 -1
  312. data/ext/pg_query/include/tcop/dest.h +1 -1
  313. data/ext/pg_query/include/tcop/fastpath.h +1 -2
  314. data/ext/pg_query/include/tcop/pquery.h +1 -1
  315. data/ext/pg_query/include/tcop/tcopprot.h +19 -11
  316. data/ext/pg_query/include/tcop/utility.h +7 -3
  317. data/ext/pg_query/include/tsearch/ts_cache.h +2 -2
  318. data/ext/pg_query/include/utils/acl.h +24 -3
  319. data/ext/pg_query/include/utils/aclchk_internal.h +1 -1
  320. data/ext/pg_query/include/utils/array.h +7 -2
  321. data/ext/pg_query/include/utils/backend_progress.h +44 -0
  322. data/ext/pg_query/include/utils/backend_status.h +321 -0
  323. data/ext/pg_query/include/utils/builtins.h +10 -11
  324. data/ext/pg_query/include/utils/bytea.h +3 -2
  325. data/ext/pg_query/include/utils/catcache.h +1 -1
  326. data/ext/pg_query/include/utils/date.h +1 -1
  327. data/ext/pg_query/include/utils/datetime.h +8 -7
  328. data/ext/pg_query/include/utils/datum.h +9 -1
  329. data/ext/pg_query/include/utils/dsa.h +1 -1
  330. data/ext/pg_query/include/utils/dynahash.h +4 -3
  331. data/ext/pg_query/include/utils/elog.h +52 -21
  332. data/ext/pg_query/include/utils/errcodes.h +2 -0
  333. data/ext/pg_query/include/utils/expandeddatum.h +1 -1
  334. data/ext/pg_query/include/utils/expandedrecord.h +1 -1
  335. data/ext/pg_query/include/utils/float.h +7 -7
  336. data/ext/pg_query/include/utils/fmgroids.h +1300 -696
  337. data/ext/pg_query/include/utils/fmgrprotos.h +199 -16
  338. data/ext/pg_query/include/utils/fmgrtab.h +6 -5
  339. data/ext/pg_query/include/utils/guc.h +69 -43
  340. data/ext/pg_query/include/utils/guc_tables.h +23 -19
  341. data/ext/pg_query/include/utils/hsearch.h +15 -11
  342. data/ext/pg_query/include/utils/inval.h +4 -1
  343. data/ext/pg_query/include/utils/lsyscache.h +11 -1
  344. data/ext/pg_query/include/utils/memdebug.h +1 -1
  345. data/ext/pg_query/include/utils/memutils.h +8 -3
  346. data/ext/pg_query/include/utils/numeric.h +19 -5
  347. data/ext/pg_query/include/utils/palloc.h +25 -3
  348. data/ext/pg_query/include/utils/partcache.h +1 -1
  349. data/ext/pg_query/include/utils/pg_locale.h +17 -9
  350. data/ext/pg_query/include/utils/pg_lsn.h +1 -1
  351. data/ext/pg_query/include/utils/pgstat_internal.h +784 -0
  352. data/ext/pg_query/include/utils/pidfile.h +1 -1
  353. data/ext/pg_query/include/utils/plancache.h +6 -5
  354. data/ext/pg_query/include/utils/portal.h +10 -12
  355. data/ext/pg_query/include/utils/ps_status.h +1 -1
  356. data/ext/pg_query/include/utils/queryenvironment.h +1 -1
  357. data/ext/pg_query/include/utils/queryjumble.h +88 -0
  358. data/ext/pg_query/include/utils/regproc.h +14 -3
  359. data/ext/pg_query/include/utils/rel.h +71 -19
  360. data/ext/pg_query/include/utils/relcache.h +8 -5
  361. data/ext/pg_query/include/utils/reltrigger.h +1 -1
  362. data/ext/pg_query/include/utils/resowner.h +1 -1
  363. data/ext/pg_query/include/utils/rls.h +2 -2
  364. data/ext/pg_query/include/utils/ruleutils.h +4 -1
  365. data/ext/pg_query/include/utils/sharedtuplestore.h +1 -1
  366. data/ext/pg_query/include/utils/snapmgr.h +34 -14
  367. data/ext/pg_query/include/utils/snapshot.h +14 -1
  368. data/ext/pg_query/include/utils/sortsupport.h +117 -2
  369. data/ext/pg_query/include/utils/syscache.h +6 -1
  370. data/ext/pg_query/include/utils/timeout.h +11 -4
  371. data/ext/pg_query/include/utils/timestamp.h +6 -5
  372. data/ext/pg_query/include/utils/tuplesort.h +25 -11
  373. data/ext/pg_query/include/utils/tuplestore.h +2 -2
  374. data/ext/pg_query/include/utils/typcache.h +24 -17
  375. data/ext/pg_query/include/utils/tzparser.h +1 -1
  376. data/ext/pg_query/include/utils/varlena.h +5 -3
  377. data/ext/pg_query/include/utils/wait_event.h +289 -0
  378. data/ext/pg_query/include/utils/xml.h +4 -4
  379. data/ext/pg_query/pg_query.pb-c.c +4302 -2304
  380. data/ext/pg_query/pg_query_deparse.c +986 -301
  381. data/ext/pg_query/pg_query_fingerprint.c +30 -10
  382. data/ext/pg_query/pg_query_json_plpgsql.c +0 -25
  383. data/ext/pg_query/pg_query_normalize.c +1 -1
  384. data/ext/pg_query/pg_query_outfuncs_json.c +54 -16
  385. data/ext/pg_query/pg_query_outfuncs_protobuf.c +70 -10
  386. data/ext/pg_query/pg_query_parse.c +1 -1
  387. data/ext/pg_query/pg_query_readfuncs_protobuf.c +42 -8
  388. data/ext/pg_query/pg_query_scan.c +2 -1
  389. data/ext/pg_query/pg_query_split.c +3 -2
  390. data/ext/pg_query/src_backend_catalog_namespace.c +20 -9
  391. data/ext/pg_query/src_backend_catalog_pg_proc.c +4 -1
  392. data/ext/pg_query/src_backend_commands_define.c +11 -1
  393. data/ext/pg_query/src_backend_nodes_bitmapset.c +3 -1
  394. data/ext/pg_query/src_backend_nodes_copyfuncs.c +401 -76
  395. data/ext/pg_query/src_backend_nodes_equalfuncs.c +290 -46
  396. data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
  397. data/ext/pg_query/src_backend_nodes_list.c +74 -11
  398. data/ext/pg_query/src_backend_nodes_makefuncs.c +5 -4
  399. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +55 -12
  400. data/ext/pg_query/src_backend_nodes_value.c +28 -19
  401. data/ext/pg_query/src_backend_parser_gram.c +33874 -31261
  402. data/ext/pg_query/src_backend_parser_parser.c +26 -7
  403. data/ext/pg_query/src_backend_parser_scan.c +172 -209
  404. data/ext/pg_query/src_backend_parser_scansup.c +4 -28
  405. data/ext/pg_query/src_backend_postmaster_postmaster.c +77 -106
  406. data/ext/pg_query/src_backend_storage_ipc_ipc.c +13 -4
  407. data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +5 -4
  408. data/ext/pg_query/src_backend_tcop_postgres.c +62 -23
  409. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +140 -0
  410. data/ext/pg_query/src_backend_utils_adt_datum.c +13 -1
  411. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  412. data/ext/pg_query/src_backend_utils_adt_format_type.c +6 -2
  413. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +71 -5
  414. data/ext/pg_query/src_backend_utils_error_assert.c +16 -14
  415. data/ext/pg_query/src_backend_utils_error_elog.c +172 -99
  416. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +12 -17
  417. data/ext/pg_query/src_backend_utils_hash_dynahash.c +40 -10
  418. data/ext/pg_query/src_backend_utils_init_globals.c +5 -5
  419. data/ext/pg_query/src_backend_utils_mb_mbutils.c +55 -66
  420. data/ext/pg_query/src_backend_utils_misc_guc.c +206 -45
  421. data/ext/pg_query/src_backend_utils_mmgr_aset.c +7 -5
  422. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +123 -35
  423. data/ext/pg_query/src_common_encnames.c +1 -1
  424. data/ext/pg_query/src_common_hashfn.c +3 -3
  425. data/ext/pg_query/src_common_keywords.c +15 -2
  426. data/ext/pg_query/src_common_kwlist_d.h +517 -494
  427. data/ext/pg_query/src_common_kwlookup.c +1 -1
  428. data/ext/pg_query/src_common_pg_prng.c +152 -0
  429. data/ext/pg_query/src_common_psprintf.c +1 -1
  430. data/ext/pg_query/src_common_string.c +7 -1
  431. data/ext/pg_query/src_common_stringinfo.c +1 -1
  432. data/ext/pg_query/src_common_wchar.c +701 -109
  433. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +45 -20
  434. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -18
  435. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +1233 -1259
  436. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  437. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +10 -10
  438. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +2 -2
  439. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +54 -56
  440. data/ext/pg_query/src_port_pg_bitutils.c +41 -31
  441. data/ext/pg_query/src_port_pgsleep.c +1 -1
  442. data/ext/pg_query/src_port_pgstrcasecmp.c +1 -1
  443. data/ext/pg_query/src_port_qsort.c +12 -224
  444. data/ext/pg_query/src_port_snprintf.c +37 -13
  445. data/ext/pg_query/src_port_strerror.c +9 -19
  446. data/ext/pg_query/src_port_strnlen.c +1 -1
  447. data/lib/pg_query/filter_columns.rb +1 -1
  448. data/lib/pg_query/fingerprint.rb +5 -1
  449. data/lib/pg_query/node.rb +2 -2
  450. data/lib/pg_query/param_refs.rb +1 -1
  451. data/lib/pg_query/parse.rb +8 -7
  452. data/lib/pg_query/pg_query_pb.rb +1108 -942
  453. data/lib/pg_query/truncate.rb +1 -1
  454. data/lib/pg_query/version.rb +1 -1
  455. metadata +23 -13
  456. data/ext/pg_query/include/access/xloginsert.h +0 -64
  457. data/ext/pg_query/include/bootstrap/bootstrap.h +0 -62
  458. data/ext/pg_query/include/parser/parse_clause.h +0 -54
  459. data/ext/pg_query/include/parser/parse_collate.h +0 -27
  460. data/ext/pg_query/include/parser/parse_target.h +0 -46
  461. data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -2
  462. data/ext/pg_query/src_backend_libpq_pqcomm.c +0 -659
  463. data/ext/pg_query/src_backend_parser_parse_expr.c +0 -313
  464. data/ext/pg_query/src_port_erand48.c +0 -127
  465. data/ext/pg_query/src_port_random.c +0 -31
@@ -19,17 +19,44 @@ typedef uint8 RmgrId;
19
19
  * Note: RM_MAX_ID must fit in RmgrId; widening that type will affect the XLOG
20
20
  * file format.
21
21
  */
22
- #define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask) \
22
+ #define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask,decode) \
23
23
  symname,
24
24
 
25
25
  typedef enum RmgrIds
26
26
  {
27
27
  #include "access/rmgrlist.h"
28
28
  RM_NEXT_ID
29
- } RmgrIds;
29
+ } RmgrIds;
30
30
 
31
31
  #undef PG_RMGR
32
32
 
33
- #define RM_MAX_ID (RM_NEXT_ID - 1)
33
+ #define RM_MAX_ID UINT8_MAX
34
+ #define RM_MAX_BUILTIN_ID (RM_NEXT_ID - 1)
35
+ #define RM_MIN_CUSTOM_ID 128
36
+ #define RM_MAX_CUSTOM_ID UINT8_MAX
37
+ #define RM_N_IDS (UINT8_MAX + 1)
38
+ #define RM_N_BUILTIN_IDS (RM_MAX_BUILTIN_ID + 1)
39
+ #define RM_N_CUSTOM_IDS (RM_MAX_CUSTOM_ID - RM_MIN_CUSTOM_ID + 1)
40
+
41
+ static inline bool
42
+ RmgrIdIsBuiltin(int rmid)
43
+ {
44
+ return rmid <= RM_MAX_BUILTIN_ID;
45
+ }
46
+
47
+ static inline bool
48
+ RmgrIdIsCustom(int rmid)
49
+ {
50
+ return rmid >= RM_MIN_CUSTOM_ID && rmid <= RM_MAX_CUSTOM_ID;
51
+ }
52
+
53
+ #define RmgrIdIsValid(rmid) (RmgrIdIsBuiltin((rmid)) || RmgrIdIsCustom((rmid)))
54
+
55
+ /*
56
+ * RmgrId to use for extensions that require an RmgrId, but are still in
57
+ * development and have not reserved their own unique RmgrId yet. See:
58
+ * https://wiki.postgresql.org/wiki/CustomWALResourceManagers
59
+ */
60
+ #define RM_EXPERIMENTAL_ID 128
34
61
 
35
62
  #endif /* RMGR_H */
@@ -6,7 +6,7 @@
6
6
  * by the PG_RMGR macro, which is not defined in this file; it can be
7
7
  * defined by the caller for special purposes.
8
8
  *
9
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
9
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
10
10
  * Portions Copyright (c) 1994, Regents of the University of California
11
11
  *
12
12
  * src/include/access/rmgrlist.h
@@ -25,25 +25,25 @@
25
25
  */
26
26
 
27
27
  /* symbol name, textual name, redo, desc, identify, startup, cleanup */
28
- PG_RMGR(RM_XLOG_ID, "XLOG", xlog_redo, xlog_desc, xlog_identify, NULL, NULL, NULL)
29
- PG_RMGR(RM_XACT_ID, "Transaction", xact_redo, xact_desc, xact_identify, NULL, NULL, NULL)
30
- PG_RMGR(RM_SMGR_ID, "Storage", smgr_redo, smgr_desc, smgr_identify, NULL, NULL, NULL)
31
- PG_RMGR(RM_CLOG_ID, "CLOG", clog_redo, clog_desc, clog_identify, NULL, NULL, NULL)
32
- PG_RMGR(RM_DBASE_ID, "Database", dbase_redo, dbase_desc, dbase_identify, NULL, NULL, NULL)
33
- PG_RMGR(RM_TBLSPC_ID, "Tablespace", tblspc_redo, tblspc_desc, tblspc_identify, NULL, NULL, NULL)
34
- PG_RMGR(RM_MULTIXACT_ID, "MultiXact", multixact_redo, multixact_desc, multixact_identify, NULL, NULL, NULL)
35
- PG_RMGR(RM_RELMAP_ID, "RelMap", relmap_redo, relmap_desc, relmap_identify, NULL, NULL, NULL)
36
- PG_RMGR(RM_STANDBY_ID, "Standby", standby_redo, standby_desc, standby_identify, NULL, NULL, NULL)
37
- PG_RMGR(RM_HEAP2_ID, "Heap2", heap2_redo, heap2_desc, heap2_identify, NULL, NULL, heap_mask)
38
- PG_RMGR(RM_HEAP_ID, "Heap", heap_redo, heap_desc, heap_identify, NULL, NULL, heap_mask)
39
- PG_RMGR(RM_BTREE_ID, "Btree", btree_redo, btree_desc, btree_identify, btree_xlog_startup, btree_xlog_cleanup, btree_mask)
40
- PG_RMGR(RM_HASH_ID, "Hash", hash_redo, hash_desc, hash_identify, NULL, NULL, hash_mask)
41
- PG_RMGR(RM_GIN_ID, "Gin", gin_redo, gin_desc, gin_identify, gin_xlog_startup, gin_xlog_cleanup, gin_mask)
42
- PG_RMGR(RM_GIST_ID, "Gist", gist_redo, gist_desc, gist_identify, gist_xlog_startup, gist_xlog_cleanup, gist_mask)
43
- PG_RMGR(RM_SEQ_ID, "Sequence", seq_redo, seq_desc, seq_identify, NULL, NULL, seq_mask)
44
- PG_RMGR(RM_SPGIST_ID, "SPGist", spg_redo, spg_desc, spg_identify, spg_xlog_startup, spg_xlog_cleanup, spg_mask)
45
- PG_RMGR(RM_BRIN_ID, "BRIN", brin_redo, brin_desc, brin_identify, NULL, NULL, brin_mask)
46
- PG_RMGR(RM_COMMIT_TS_ID, "CommitTs", commit_ts_redo, commit_ts_desc, commit_ts_identify, NULL, NULL, NULL)
47
- PG_RMGR(RM_REPLORIGIN_ID, "ReplicationOrigin", replorigin_redo, replorigin_desc, replorigin_identify, NULL, NULL, NULL)
48
- PG_RMGR(RM_GENERIC_ID, "Generic", generic_redo, generic_desc, generic_identify, NULL, NULL, generic_mask)
49
- PG_RMGR(RM_LOGICALMSG_ID, "LogicalMessage", logicalmsg_redo, logicalmsg_desc, logicalmsg_identify, NULL, NULL, NULL)
28
+ PG_RMGR(RM_XLOG_ID, "XLOG", xlog_redo, xlog_desc, xlog_identify, NULL, NULL, NULL, xlog_decode)
29
+ PG_RMGR(RM_XACT_ID, "Transaction", xact_redo, xact_desc, xact_identify, NULL, NULL, NULL, xact_decode)
30
+ PG_RMGR(RM_SMGR_ID, "Storage", smgr_redo, smgr_desc, smgr_identify, NULL, NULL, NULL, NULL)
31
+ PG_RMGR(RM_CLOG_ID, "CLOG", clog_redo, clog_desc, clog_identify, NULL, NULL, NULL, NULL)
32
+ PG_RMGR(RM_DBASE_ID, "Database", dbase_redo, dbase_desc, dbase_identify, NULL, NULL, NULL, NULL)
33
+ PG_RMGR(RM_TBLSPC_ID, "Tablespace", tblspc_redo, tblspc_desc, tblspc_identify, NULL, NULL, NULL, NULL)
34
+ PG_RMGR(RM_MULTIXACT_ID, "MultiXact", multixact_redo, multixact_desc, multixact_identify, NULL, NULL, NULL, NULL)
35
+ PG_RMGR(RM_RELMAP_ID, "RelMap", relmap_redo, relmap_desc, relmap_identify, NULL, NULL, NULL, NULL)
36
+ PG_RMGR(RM_STANDBY_ID, "Standby", standby_redo, standby_desc, standby_identify, NULL, NULL, NULL, standby_decode)
37
+ PG_RMGR(RM_HEAP2_ID, "Heap2", heap2_redo, heap2_desc, heap2_identify, NULL, NULL, heap_mask, heap2_decode)
38
+ PG_RMGR(RM_HEAP_ID, "Heap", heap_redo, heap_desc, heap_identify, NULL, NULL, heap_mask, heap_decode)
39
+ PG_RMGR(RM_BTREE_ID, "Btree", btree_redo, btree_desc, btree_identify, btree_xlog_startup, btree_xlog_cleanup, btree_mask, NULL)
40
+ PG_RMGR(RM_HASH_ID, "Hash", hash_redo, hash_desc, hash_identify, NULL, NULL, hash_mask, NULL)
41
+ PG_RMGR(RM_GIN_ID, "Gin", gin_redo, gin_desc, gin_identify, gin_xlog_startup, gin_xlog_cleanup, gin_mask, NULL)
42
+ PG_RMGR(RM_GIST_ID, "Gist", gist_redo, gist_desc, gist_identify, gist_xlog_startup, gist_xlog_cleanup, gist_mask, NULL)
43
+ PG_RMGR(RM_SEQ_ID, "Sequence", seq_redo, seq_desc, seq_identify, NULL, NULL, seq_mask, NULL)
44
+ PG_RMGR(RM_SPGIST_ID, "SPGist", spg_redo, spg_desc, spg_identify, spg_xlog_startup, spg_xlog_cleanup, spg_mask, NULL)
45
+ PG_RMGR(RM_BRIN_ID, "BRIN", brin_redo, brin_desc, brin_identify, NULL, NULL, brin_mask, NULL)
46
+ PG_RMGR(RM_COMMIT_TS_ID, "CommitTs", commit_ts_redo, commit_ts_desc, commit_ts_identify, NULL, NULL, NULL, NULL)
47
+ PG_RMGR(RM_REPLORIGIN_ID, "ReplicationOrigin", replorigin_redo, replorigin_desc, replorigin_identify, NULL, NULL, NULL, NULL)
48
+ PG_RMGR(RM_GENERIC_ID, "Generic", generic_redo, generic_desc, generic_identify, NULL, NULL, generic_mask, NULL)
49
+ PG_RMGR(RM_LOGICALMSG_ID, "LogicalMessage", logicalmsg_redo, logicalmsg_desc, logicalmsg_identify, NULL, NULL, NULL, logicalmsg_decode)
@@ -4,7 +4,7 @@
4
4
  * POSTGRES scan direction definitions.
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/access/sdir.h
@@ -4,7 +4,7 @@
4
4
  * POSTGRES scan key definitions.
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/access/skey.h
@@ -4,7 +4,7 @@
4
4
  * POSTGRES strategy number definitions.
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/access/stratnum.h
@@ -76,8 +76,10 @@ typedef uint16 StrategyNumber;
76
76
  #define RTSuperStrategyNumber 26 /* for inet << */
77
77
  #define RTSuperEqualStrategyNumber 27 /* for inet >>= */
78
78
  #define RTPrefixStrategyNumber 28 /* for text ^@ */
79
+ #define RTOldBelowStrategyNumber 29 /* for old spelling of <<| */
80
+ #define RTOldAboveStrategyNumber 30 /* for old spelling of |>> */
79
81
 
80
- #define RTMaxStrategyNumber 28
82
+ #define RTMaxStrategyNumber 30
81
83
 
82
84
 
83
85
  #endif /* STRATNUM_H */
@@ -4,7 +4,7 @@
4
4
  * POSTGRES system attribute definitions.
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/access/sysattr.h
@@ -4,7 +4,7 @@
4
4
  * Generic routines for table related code.
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/access/table.h
@@ -22,6 +22,7 @@ extern Relation table_open(Oid relationId, LOCKMODE lockmode);
22
22
  extern Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode);
23
23
  extern Relation table_openrv_extended(const RangeVar *relation,
24
24
  LOCKMODE lockmode, bool missing_ok);
25
+ extern Relation try_table_open(Oid relationId, LOCKMODE lockmode);
25
26
  extern void table_close(Relation relation, LOCKMODE lockmode);
26
27
 
27
28
  #endif /* TABLE_H */
@@ -4,7 +4,7 @@
4
4
  * POSTGRES table access method definitions.
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/access/tableam.h
@@ -19,6 +19,7 @@
19
19
 
20
20
  #include "access/relscan.h"
21
21
  #include "access/sdir.h"
22
+ #include "access/xact.h"
22
23
  #include "utils/guc.h"
23
24
  #include "utils/rel.h"
24
25
  #include "utils/snapshot.h"
@@ -27,8 +28,8 @@
27
28
  #define DEFAULT_TABLE_ACCESS_METHOD "heap"
28
29
 
29
30
  /* GUCs */
30
- extern char *default_table_access_method;
31
- extern bool synchronize_seqscans;
31
+ extern PGDLLIMPORT char *default_table_access_method;
32
+ extern PGDLLIMPORT bool synchronize_seqscans;
32
33
 
33
34
 
34
35
  struct BulkInsertStateData;
@@ -48,18 +49,19 @@ typedef enum ScanOptions
48
49
  SO_TYPE_BITMAPSCAN = 1 << 1,
49
50
  SO_TYPE_SAMPLESCAN = 1 << 2,
50
51
  SO_TYPE_TIDSCAN = 1 << 3,
51
- SO_TYPE_ANALYZE = 1 << 4,
52
+ SO_TYPE_TIDRANGESCAN = 1 << 4,
53
+ SO_TYPE_ANALYZE = 1 << 5,
52
54
 
53
55
  /* several of SO_ALLOW_* may be specified */
54
56
  /* allow or disallow use of access strategy */
55
- SO_ALLOW_STRAT = 1 << 5,
57
+ SO_ALLOW_STRAT = 1 << 6,
56
58
  /* report location to syncscan logic? */
57
- SO_ALLOW_SYNC = 1 << 6,
59
+ SO_ALLOW_SYNC = 1 << 7,
58
60
  /* verify visibility page-at-a-time? */
59
- SO_ALLOW_PAGEMODE = 1 << 7,
61
+ SO_ALLOW_PAGEMODE = 1 << 8,
60
62
 
61
63
  /* unregister snapshot at scan end? */
62
- SO_TEMP_SNAPSHOT = 1 << 8
64
+ SO_TEMP_SNAPSHOT = 1 << 9
63
65
  } ScanOptions;
64
66
 
65
67
  /*
@@ -127,6 +129,108 @@ typedef struct TM_FailureData
127
129
  bool traversed;
128
130
  } TM_FailureData;
129
131
 
132
+ /*
133
+ * State used when calling table_index_delete_tuples().
134
+ *
135
+ * Represents the status of table tuples, referenced by table TID and taken by
136
+ * index AM from index tuples. State consists of high level parameters of the
137
+ * deletion operation, plus two mutable palloc()'d arrays for information
138
+ * about the status of individual table tuples. These are conceptually one
139
+ * single array. Using two arrays keeps the TM_IndexDelete struct small,
140
+ * which makes sorting the first array (the deltids array) fast.
141
+ *
142
+ * Some index AM callers perform simple index tuple deletion (by specifying
143
+ * bottomup = false), and include only known-dead deltids. These known-dead
144
+ * entries are all marked knowndeletable = true directly (typically these are
145
+ * TIDs from LP_DEAD-marked index tuples), but that isn't strictly required.
146
+ *
147
+ * Callers that specify bottomup = true are "bottom-up index deletion"
148
+ * callers. The considerations for the tableam are more subtle with these
149
+ * callers because they ask the tableam to perform highly speculative work,
150
+ * and might only expect the tableam to check a small fraction of all entries.
151
+ * Caller is not allowed to specify knowndeletable = true for any entry
152
+ * because everything is highly speculative. Bottom-up caller provides
153
+ * context and hints to tableam -- see comments below for details on how index
154
+ * AMs and tableams should coordinate during bottom-up index deletion.
155
+ *
156
+ * Simple index deletion callers may ask the tableam to perform speculative
157
+ * work, too. This is a little like bottom-up deletion, but not too much.
158
+ * The tableam will only perform speculative work when it's practically free
159
+ * to do so in passing for simple deletion caller (while always performing
160
+ * whatever work is needed to enable knowndeletable/LP_DEAD index tuples to
161
+ * be deleted within index AM). This is the real reason why it's possible for
162
+ * simple index deletion caller to specify knowndeletable = false up front
163
+ * (this means "check if it's possible for me to delete corresponding index
164
+ * tuple when it's cheap to do so in passing"). The index AM should only
165
+ * include "extra" entries for index tuples whose TIDs point to a table block
166
+ * that tableam is expected to have to visit anyway (in the event of a block
167
+ * orientated tableam). The tableam isn't strictly obligated to check these
168
+ * "extra" TIDs, but a block-based AM should always manage to do so in
169
+ * practice.
170
+ *
171
+ * The final contents of the deltids/status arrays are interesting to callers
172
+ * that ask tableam to perform speculative work (i.e. when _any_ items have
173
+ * knowndeletable set to false up front). These index AM callers will
174
+ * naturally need to consult final state to determine which index tuples are
175
+ * in fact deletable.
176
+ *
177
+ * The index AM can keep track of which index tuple relates to which deltid by
178
+ * setting idxoffnum (and/or relying on each entry being uniquely identifiable
179
+ * using tid), which is important when the final contents of the array will
180
+ * need to be interpreted -- the array can shrink from initial size after
181
+ * tableam processing and/or have entries in a new order (tableam may sort
182
+ * deltids array for its own reasons). Bottom-up callers may find that final
183
+ * ndeltids is 0 on return from call to tableam, in which case no index tuple
184
+ * deletions are possible. Simple deletion callers can rely on any entries
185
+ * they know to be deletable appearing in the final array as deletable.
186
+ */
187
+ typedef struct TM_IndexDelete
188
+ {
189
+ ItemPointerData tid; /* table TID from index tuple */
190
+ int16 id; /* Offset into TM_IndexStatus array */
191
+ } TM_IndexDelete;
192
+
193
+ typedef struct TM_IndexStatus
194
+ {
195
+ OffsetNumber idxoffnum; /* Index am page offset number */
196
+ bool knowndeletable; /* Currently known to be deletable? */
197
+
198
+ /* Bottom-up index deletion specific fields follow */
199
+ bool promising; /* Promising (duplicate) index tuple? */
200
+ int16 freespace; /* Space freed in index if deleted */
201
+ } TM_IndexStatus;
202
+
203
+ /*
204
+ * Index AM/tableam coordination is central to the design of bottom-up index
205
+ * deletion. The index AM provides hints about where to look to the tableam
206
+ * by marking some entries as "promising". Index AM does this with duplicate
207
+ * index tuples that are strongly suspected to be old versions left behind by
208
+ * UPDATEs that did not logically modify indexed values. Index AM may find it
209
+ * helpful to only mark entries as promising when they're thought to have been
210
+ * affected by such an UPDATE in the recent past.
211
+ *
212
+ * Bottom-up index deletion casts a wide net at first, usually by including
213
+ * all TIDs on a target index page. It is up to the tableam to worry about
214
+ * the cost of checking transaction status information. The tableam is in
215
+ * control, but needs careful guidance from the index AM. Index AM requests
216
+ * that bottomupfreespace target be met, while tableam measures progress
217
+ * towards that goal by tallying the per-entry freespace value for known
218
+ * deletable entries. (All !bottomup callers can just set these space related
219
+ * fields to zero.)
220
+ */
221
+ typedef struct TM_IndexDeleteOp
222
+ {
223
+ Relation irel; /* Target index relation */
224
+ BlockNumber iblknum; /* Index block number (for error reports) */
225
+ bool bottomup; /* Bottom-up (not simple) deletion? */
226
+ int bottomupfreespace; /* Bottom-up space target */
227
+
228
+ /* Mutable per-TID information follows (index AM initializes entries) */
229
+ int ndeltids; /* Current # of deltids/status elements */
230
+ TM_IndexDelete *deltids;
231
+ TM_IndexStatus *status;
232
+ } TM_IndexDeleteOp;
233
+
130
234
  /* "options" flag bits for table_tuple_insert */
131
235
  /* TABLE_INSERT_SKIP_WAL was 0x0001; RelationNeedsWAL() now governs */
132
236
  #define TABLE_INSERT_SKIP_FSM 0x0002
@@ -224,6 +328,34 @@ typedef struct TableAmRoutine
224
328
  ScanDirection direction,
225
329
  TupleTableSlot *slot);
226
330
 
331
+ /*-----------
332
+ * Optional functions to provide scanning for ranges of ItemPointers.
333
+ * Implementations must either provide both of these functions, or neither
334
+ * of them.
335
+ *
336
+ * Implementations of scan_set_tidrange must themselves handle
337
+ * ItemPointers of any value. i.e, they must handle each of the following:
338
+ *
339
+ * 1) mintid or maxtid is beyond the end of the table; and
340
+ * 2) mintid is above maxtid; and
341
+ * 3) item offset for mintid or maxtid is beyond the maximum offset
342
+ * allowed by the AM.
343
+ *
344
+ * Implementations can assume that scan_set_tidrange is always called
345
+ * before can_getnextslot_tidrange or after scan_rescan and before any
346
+ * further calls to scan_getnextslot_tidrange.
347
+ */
348
+ void (*scan_set_tidrange) (TableScanDesc scan,
349
+ ItemPointer mintid,
350
+ ItemPointer maxtid);
351
+
352
+ /*
353
+ * Return next tuple from `scan` that's in the range of TIDs defined by
354
+ * scan_set_tidrange.
355
+ */
356
+ bool (*scan_getnextslot_tidrange) (TableScanDesc scan,
357
+ ScanDirection direction,
358
+ TupleTableSlot *slot);
227
359
 
228
360
  /* ------------------------------------------------------------------------
229
361
  * Parallel table scan related functions.
@@ -341,10 +473,9 @@ typedef struct TableAmRoutine
341
473
  TupleTableSlot *slot,
342
474
  Snapshot snapshot);
343
475
 
344
- /* see table_compute_xid_horizon_for_tuples() */
345
- TransactionId (*compute_xid_horizon_for_tuples) (Relation rel,
346
- ItemPointerData *items,
347
- int nitems);
476
+ /* see table_index_delete_tuples() */
477
+ TransactionId (*index_delete_tuples) (Relation rel,
478
+ TM_IndexDeleteOp *delstate);
348
479
 
349
480
 
350
481
  /* ------------------------------------------------------------------------
@@ -496,7 +627,7 @@ typedef struct TableAmRoutine
496
627
  * There probably, in the future, needs to be a separate callback to
497
628
  * integrate with autovacuum's scheduling.
498
629
  */
499
- void (*relation_vacuum) (Relation onerel,
630
+ void (*relation_vacuum) (Relation rel,
500
631
  struct VacuumParams *params,
501
632
  BufferAccessStrategy bstrategy);
502
633
 
@@ -903,9 +1034,76 @@ static inline bool
903
1034
  table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
904
1035
  {
905
1036
  slot->tts_tableOid = RelationGetRelid(sscan->rs_rd);
1037
+
1038
+ /*
1039
+ * We don't expect direct calls to table_scan_getnextslot with valid
1040
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
1041
+ * xact.c where these variables are declared.
1042
+ */
1043
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1044
+ elog(ERROR, "unexpected table_scan_getnextslot call during logical decoding");
1045
+
906
1046
  return sscan->rs_rd->rd_tableam->scan_getnextslot(sscan, direction, slot);
907
1047
  }
908
1048
 
1049
+ /* ----------------------------------------------------------------------------
1050
+ * TID Range scanning related functions.
1051
+ * ----------------------------------------------------------------------------
1052
+ */
1053
+
1054
+ /*
1055
+ * table_beginscan_tidrange is the entry point for setting up a TableScanDesc
1056
+ * for a TID range scan.
1057
+ */
1058
+ static inline TableScanDesc
1059
+ table_beginscan_tidrange(Relation rel, Snapshot snapshot,
1060
+ ItemPointer mintid,
1061
+ ItemPointer maxtid)
1062
+ {
1063
+ TableScanDesc sscan;
1064
+ uint32 flags = SO_TYPE_TIDRANGESCAN | SO_ALLOW_PAGEMODE;
1065
+
1066
+ sscan = rel->rd_tableam->scan_begin(rel, snapshot, 0, NULL, NULL, flags);
1067
+
1068
+ /* Set the range of TIDs to scan */
1069
+ sscan->rs_rd->rd_tableam->scan_set_tidrange(sscan, mintid, maxtid);
1070
+
1071
+ return sscan;
1072
+ }
1073
+
1074
+ /*
1075
+ * table_rescan_tidrange resets the scan position and sets the minimum and
1076
+ * maximum TID range to scan for a TableScanDesc created by
1077
+ * table_beginscan_tidrange.
1078
+ */
1079
+ static inline void
1080
+ table_rescan_tidrange(TableScanDesc sscan, ItemPointer mintid,
1081
+ ItemPointer maxtid)
1082
+ {
1083
+ /* Ensure table_beginscan_tidrange() was used. */
1084
+ Assert((sscan->rs_flags & SO_TYPE_TIDRANGESCAN) != 0);
1085
+
1086
+ sscan->rs_rd->rd_tableam->scan_rescan(sscan, NULL, false, false, false, false);
1087
+ sscan->rs_rd->rd_tableam->scan_set_tidrange(sscan, mintid, maxtid);
1088
+ }
1089
+
1090
+ /*
1091
+ * Fetch the next tuple from `sscan` for a TID range scan created by
1092
+ * table_beginscan_tidrange(). Stores the tuple in `slot` and returns true,
1093
+ * or returns false if no more tuples exist in the range.
1094
+ */
1095
+ static inline bool
1096
+ table_scan_getnextslot_tidrange(TableScanDesc sscan, ScanDirection direction,
1097
+ TupleTableSlot *slot)
1098
+ {
1099
+ /* Ensure table_beginscan_tidrange() was used. */
1100
+ Assert((sscan->rs_flags & SO_TYPE_TIDRANGESCAN) != 0);
1101
+
1102
+ return sscan->rs_rd->rd_tableam->scan_getnextslot_tidrange(sscan,
1103
+ direction,
1104
+ slot);
1105
+ }
1106
+
909
1107
 
910
1108
  /* ----------------------------------------------------------------------------
911
1109
  * Parallel table scan related functions.
@@ -1017,6 +1215,13 @@ table_index_fetch_tuple(struct IndexFetchTableData *scan,
1017
1215
  TupleTableSlot *slot,
1018
1216
  bool *call_again, bool *all_dead)
1019
1217
  {
1218
+ /*
1219
+ * We don't expect direct calls to table_index_fetch_tuple with valid
1220
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
1221
+ * xact.c where these variables are declared.
1222
+ */
1223
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1224
+ elog(ERROR, "unexpected table_index_fetch_tuple call during logical decoding");
1020
1225
 
1021
1226
  return scan->rel->rd_tableam->index_fetch_tuple(scan, tid, snapshot,
1022
1227
  slot, call_again,
@@ -1056,6 +1261,14 @@ table_tuple_fetch_row_version(Relation rel,
1056
1261
  Snapshot snapshot,
1057
1262
  TupleTableSlot *slot)
1058
1263
  {
1264
+ /*
1265
+ * We don't expect direct calls to table_tuple_fetch_row_version with
1266
+ * valid CheckXidAlive for catalog or regular tables. See detailed
1267
+ * comments in xact.c where these variables are declared.
1268
+ */
1269
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1270
+ elog(ERROR, "unexpected table_tuple_fetch_row_version call during logical decoding");
1271
+
1059
1272
  return rel->rd_tableam->tuple_fetch_row_version(rel, tid, snapshot, slot);
1060
1273
  }
1061
1274
 
@@ -1097,16 +1310,23 @@ table_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
1097
1310
  }
1098
1311
 
1099
1312
  /*
1100
- * Compute the newest xid among the tuples pointed to by items. This is used
1101
- * to compute what snapshots to conflict with when replaying WAL records for
1102
- * page-level index vacuums.
1313
+ * Determine which index tuples are safe to delete based on their table TID.
1314
+ *
1315
+ * Determines which entries from index AM caller's TM_IndexDeleteOp state
1316
+ * point to vacuumable table tuples. Entries that are found by tableam to be
1317
+ * vacuumable are naturally safe for index AM to delete, and so get directly
1318
+ * marked as deletable. See comments above TM_IndexDelete and comments above
1319
+ * TM_IndexDeleteOp for full details.
1320
+ *
1321
+ * Returns a latestRemovedXid transaction ID that caller generally places in
1322
+ * its index deletion WAL record. This might be used during subsequent REDO
1323
+ * of the WAL record when in Hot Standby mode -- a recovery conflict for the
1324
+ * index deletion operation might be required on the standby.
1103
1325
  */
1104
1326
  static inline TransactionId
1105
- table_compute_xid_horizon_for_tuples(Relation rel,
1106
- ItemPointerData *items,
1107
- int nitems)
1327
+ table_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
1108
1328
  {
1109
- return rel->rd_tableam->compute_xid_horizon_for_tuples(rel, items, nitems);
1329
+ return rel->rd_tableam->index_delete_tuples(rel, delstate);
1110
1330
  }
1111
1331
 
1112
1332
 
@@ -1713,6 +1933,14 @@ static inline bool
1713
1933
  table_scan_bitmap_next_block(TableScanDesc scan,
1714
1934
  struct TBMIterateResult *tbmres)
1715
1935
  {
1936
+ /*
1937
+ * We don't expect direct calls to table_scan_bitmap_next_block with valid
1938
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
1939
+ * xact.c where these variables are declared.
1940
+ */
1941
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1942
+ elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding");
1943
+
1716
1944
  return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan,
1717
1945
  tbmres);
1718
1946
  }
@@ -1730,6 +1958,14 @@ table_scan_bitmap_next_tuple(TableScanDesc scan,
1730
1958
  struct TBMIterateResult *tbmres,
1731
1959
  TupleTableSlot *slot)
1732
1960
  {
1961
+ /*
1962
+ * We don't expect direct calls to table_scan_bitmap_next_tuple with valid
1963
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
1964
+ * xact.c where these variables are declared.
1965
+ */
1966
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1967
+ elog(ERROR, "unexpected table_scan_bitmap_next_tuple call during logical decoding");
1968
+
1733
1969
  return scan->rs_rd->rd_tableam->scan_bitmap_next_tuple(scan,
1734
1970
  tbmres,
1735
1971
  slot);
@@ -1748,6 +1984,13 @@ static inline bool
1748
1984
  table_scan_sample_next_block(TableScanDesc scan,
1749
1985
  struct SampleScanState *scanstate)
1750
1986
  {
1987
+ /*
1988
+ * We don't expect direct calls to table_scan_sample_next_block with valid
1989
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
1990
+ * xact.c where these variables are declared.
1991
+ */
1992
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1993
+ elog(ERROR, "unexpected table_scan_sample_next_block call during logical decoding");
1751
1994
  return scan->rs_rd->rd_tableam->scan_sample_next_block(scan, scanstate);
1752
1995
  }
1753
1996
 
@@ -1764,6 +2007,13 @@ table_scan_sample_next_tuple(TableScanDesc scan,
1764
2007
  struct SampleScanState *scanstate,
1765
2008
  TupleTableSlot *slot)
1766
2009
  {
2010
+ /*
2011
+ * We don't expect direct calls to table_scan_sample_next_tuple with valid
2012
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
2013
+ * xact.c where these variables are declared.
2014
+ */
2015
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
2016
+ elog(ERROR, "unexpected table_scan_sample_next_tuple call during logical decoding");
1767
2017
  return scan->rs_rd->rd_tableam->scan_sample_next_tuple(scan, scanstate,
1768
2018
  slot);
1769
2019
  }
@@ -1793,8 +2043,10 @@ extern Size table_block_parallelscan_initialize(Relation rel,
1793
2043
  extern void table_block_parallelscan_reinitialize(Relation rel,
1794
2044
  ParallelTableScanDesc pscan);
1795
2045
  extern BlockNumber table_block_parallelscan_nextpage(Relation rel,
2046
+ ParallelBlockTableScanWorker pbscanwork,
1796
2047
  ParallelBlockTableScanDesc pbscan);
1797
2048
  extern void table_block_parallelscan_startblock_init(Relation rel,
2049
+ ParallelBlockTableScanWorker pbscanwork,
1798
2050
  ParallelBlockTableScanDesc pbscan);
1799
2051
 
1800
2052
 
@@ -0,0 +1,73 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * toast_compression.h
4
+ * Functions for toast compression.
5
+ *
6
+ * Copyright (c) 2021-2022, PostgreSQL Global Development Group
7
+ *
8
+ * src/include/access/toast_compression.h
9
+ *
10
+ *-------------------------------------------------------------------------
11
+ */
12
+
13
+ #ifndef TOAST_COMPRESSION_H
14
+ #define TOAST_COMPRESSION_H
15
+
16
+ /*
17
+ * GUC support.
18
+ *
19
+ * default_toast_compression is an integer for purposes of the GUC machinery,
20
+ * but the value is one of the char values defined below, as they appear in
21
+ * pg_attribute.attcompression, e.g. TOAST_PGLZ_COMPRESSION.
22
+ */
23
+ extern PGDLLIMPORT int default_toast_compression;
24
+
25
+ /*
26
+ * Built-in compression method ID. The toast compression header will store
27
+ * this in the first 2 bits of the raw length. These built-in compression
28
+ * method IDs are directly mapped to the built-in compression methods.
29
+ *
30
+ * Don't use these values for anything other than understanding the meaning
31
+ * of the raw bits from a varlena; in particular, if the goal is to identify
32
+ * a compression method, use the constants TOAST_PGLZ_COMPRESSION, etc.
33
+ * below. We might someday support more than 4 compression methods, but
34
+ * we can never have more than 4 values in this enum, because there are
35
+ * only 2 bits available in the places where this is stored.
36
+ */
37
+ typedef enum ToastCompressionId
38
+ {
39
+ TOAST_PGLZ_COMPRESSION_ID = 0,
40
+ TOAST_LZ4_COMPRESSION_ID = 1,
41
+ TOAST_INVALID_COMPRESSION_ID = 2
42
+ } ToastCompressionId;
43
+
44
+ /*
45
+ * Built-in compression methods. pg_attribute will store these in the
46
+ * attcompression column. In attcompression, InvalidCompressionMethod
47
+ * denotes the default behavior.
48
+ */
49
+ #define TOAST_PGLZ_COMPRESSION 'p'
50
+ #define TOAST_LZ4_COMPRESSION 'l'
51
+ #define InvalidCompressionMethod '\0'
52
+
53
+ #define CompressionMethodIsValid(cm) ((cm) != InvalidCompressionMethod)
54
+
55
+
56
+ /* pglz compression/decompression routines */
57
+ extern struct varlena *pglz_compress_datum(const struct varlena *value);
58
+ extern struct varlena *pglz_decompress_datum(const struct varlena *value);
59
+ extern struct varlena *pglz_decompress_datum_slice(const struct varlena *value,
60
+ int32 slicelength);
61
+
62
+ /* lz4 compression/decompression routines */
63
+ extern struct varlena *lz4_compress_datum(const struct varlena *value);
64
+ extern struct varlena *lz4_decompress_datum(const struct varlena *value);
65
+ extern struct varlena *lz4_decompress_datum_slice(const struct varlena *value,
66
+ int32 slicelength);
67
+
68
+ /* other stuff */
69
+ extern ToastCompressionId toast_get_compression_id(struct varlena *attr);
70
+ extern char CompressionNameToMethod(const char *compression);
71
+ extern const char *GetCompressionMethodName(char method);
72
+
73
+ #endif /* TOAST_COMPRESSION_H */