pg_query 5.0.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 (898) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/README.md +1 -1
  4. data/Rakefile +3 -4
  5. data/ext/pg_query/extconf.rb +14 -4
  6. data/ext/pg_query/include/pg_query.h +4 -3
  7. data/ext/pg_query/include/pg_query_enum_defs.c +424 -154
  8. data/ext/pg_query/include/pg_query_fingerprint_conds.c +68 -4
  9. data/ext/pg_query/include/pg_query_fingerprint_defs.c +2901 -1794
  10. data/ext/pg_query/include/pg_query_outfuncs_conds.c +51 -3
  11. data/ext/pg_query/include/pg_query_outfuncs_defs.c +211 -24
  12. data/ext/pg_query/include/pg_query_readfuncs_conds.c +17 -1
  13. data/ext/pg_query/include/pg_query_readfuncs_defs.c +272 -53
  14. data/ext/pg_query/include/postgres/access/amapi.h +299 -0
  15. data/ext/pg_query/include/postgres/access/attmap.h +54 -0
  16. data/ext/pg_query/include/postgres/access/attnum.h +64 -0
  17. data/ext/pg_query/include/postgres/access/brin_internal.h +116 -0
  18. data/ext/pg_query/include/postgres/access/brin_tuple.h +112 -0
  19. data/ext/pg_query/include/postgres/access/clog.h +62 -0
  20. data/ext/pg_query/include/postgres/access/commit_ts.h +73 -0
  21. data/ext/pg_query/include/postgres/access/detoast.h +82 -0
  22. data/ext/pg_query/include/postgres/access/genam.h +237 -0
  23. data/ext/pg_query/include/postgres/access/gin.h +91 -0
  24. data/ext/pg_query/include/postgres/access/htup.h +89 -0
  25. data/ext/pg_query/include/postgres/access/htup_details.h +811 -0
  26. data/ext/pg_query/include/postgres/access/itup.h +170 -0
  27. data/ext/pg_query/include/postgres/access/parallel.h +81 -0
  28. data/ext/pg_query/include/postgres/access/printtup.h +35 -0
  29. data/ext/pg_query/include/postgres/access/relation.h +28 -0
  30. data/ext/pg_query/include/postgres/access/relscan.h +191 -0
  31. data/ext/pg_query/include/postgres/access/rmgrlist.h +49 -0
  32. data/ext/pg_query/include/postgres/access/sdir.h +67 -0
  33. data/ext/pg_query/include/postgres/access/skey.h +151 -0
  34. data/ext/pg_query/include/postgres/access/slru.h +221 -0
  35. data/ext/pg_query/include/postgres/access/stratnum.h +85 -0
  36. data/ext/pg_query/include/postgres/access/sysattr.h +29 -0
  37. data/ext/pg_query/include/postgres/access/table.h +28 -0
  38. data/ext/pg_query/include/postgres/access/tableam.h +2109 -0
  39. data/ext/pg_query/include/postgres/access/tidstore.h +50 -0
  40. data/ext/pg_query/include/postgres/access/toast_compression.h +73 -0
  41. data/ext/pg_query/include/postgres/access/transam.h +375 -0
  42. data/ext/pg_query/include/postgres/access/tsmapi.h +82 -0
  43. data/ext/pg_query/include/postgres/access/tupconvert.h +54 -0
  44. data/ext/pg_query/include/postgres/access/tupdesc.h +154 -0
  45. data/ext/pg_query/include/postgres/access/tupmacs.h +207 -0
  46. data/ext/pg_query/include/postgres/access/twophase.h +65 -0
  47. data/ext/pg_query/include/postgres/access/xact.h +530 -0
  48. data/ext/pg_query/include/postgres/access/xlog.h +310 -0
  49. data/ext/pg_query/include/postgres/access/xlog_internal.h +405 -0
  50. data/ext/pg_query/include/postgres/access/xlogbackup.h +43 -0
  51. data/ext/pg_query/include/postgres/access/xlogdefs.h +82 -0
  52. data/ext/pg_query/include/postgres/access/xlogprefetcher.h +55 -0
  53. data/ext/pg_query/include/postgres/access/xlogreader.h +444 -0
  54. data/ext/pg_query/include/postgres/access/xlogrecord.h +248 -0
  55. data/ext/pg_query/include/postgres/access/xlogrecovery.h +158 -0
  56. data/ext/pg_query/include/postgres/archive/archive_module.h +67 -0
  57. data/ext/pg_query/include/postgres/c.h +1374 -0
  58. data/ext/pg_query/include/postgres/catalog/catalog.h +47 -0
  59. data/ext/pg_query/include/postgres/catalog/catversion.h +62 -0
  60. data/ext/pg_query/include/postgres/catalog/dependency.h +228 -0
  61. data/ext/pg_query/include/postgres/catalog/genbki.h +149 -0
  62. data/ext/pg_query/include/postgres/catalog/index.h +218 -0
  63. data/ext/pg_query/include/postgres/catalog/indexing.h +54 -0
  64. data/ext/pg_query/include/postgres/catalog/namespace.h +189 -0
  65. data/ext/pg_query/include/postgres/catalog/objectaccess.h +267 -0
  66. data/ext/pg_query/include/postgres/catalog/objectaddress.h +89 -0
  67. data/ext/pg_query/include/postgres/catalog/pg_aggregate.h +182 -0
  68. data/ext/pg_query/include/postgres/catalog/pg_aggregate_d.h +78 -0
  69. data/ext/pg_query/include/postgres/catalog/pg_am.h +66 -0
  70. data/ext/pg_query/include/postgres/catalog/pg_am_d.h +47 -0
  71. data/ext/pg_query/include/postgres/catalog/pg_attribute.h +240 -0
  72. data/ext/pg_query/include/postgres/catalog/pg_attribute_d.h +62 -0
  73. data/ext/pg_query/include/postgres/catalog/pg_authid.h +66 -0
  74. data/ext/pg_query/include/postgres/catalog/pg_authid_d.h +60 -0
  75. data/ext/pg_query/include/postgres/catalog/pg_class.h +235 -0
  76. data/ext/pg_query/include/postgres/catalog/pg_class_d.h +134 -0
  77. data/ext/pg_query/include/postgres/catalog/pg_collation.h +106 -0
  78. data/ext/pg_query/include/postgres/catalog/pg_collation_d.h +66 -0
  79. data/ext/pg_query/include/postgres/catalog/pg_constraint.h +278 -0
  80. data/ext/pg_query/include/postgres/catalog/pg_constraint_d.h +74 -0
  81. data/ext/pg_query/include/postgres/catalog/pg_control.h +260 -0
  82. data/ext/pg_query/include/postgres/catalog/pg_conversion.h +79 -0
  83. data/ext/pg_query/include/postgres/catalog/pg_conversion_d.h +38 -0
  84. data/ext/pg_query/include/postgres/catalog/pg_database.h +129 -0
  85. data/ext/pg_query/include/postgres/catalog/pg_database_d.h +53 -0
  86. data/ext/pg_query/include/postgres/catalog/pg_depend.h +77 -0
  87. data/ext/pg_query/include/postgres/catalog/pg_depend_d.h +36 -0
  88. data/ext/pg_query/include/postgres/catalog/pg_event_trigger.h +60 -0
  89. data/ext/pg_query/include/postgres/catalog/pg_event_trigger_d.h +36 -0
  90. data/ext/pg_query/include/postgres/catalog/pg_index.h +92 -0
  91. data/ext/pg_query/include/postgres/catalog/pg_index_d.h +59 -0
  92. data/ext/pg_query/include/postgres/catalog/pg_language.h +75 -0
  93. data/ext/pg_query/include/postgres/catalog/pg_language_d.h +41 -0
  94. data/ext/pg_query/include/postgres/catalog/pg_namespace.h +67 -0
  95. data/ext/pg_query/include/postgres/catalog/pg_namespace_d.h +36 -0
  96. data/ext/pg_query/include/postgres/catalog/pg_opclass.h +91 -0
  97. data/ext/pg_query/include/postgres/catalog/pg_opclass_d.h +51 -0
  98. data/ext/pg_query/include/postgres/catalog/pg_operator.h +124 -0
  99. data/ext/pg_query/include/postgres/catalog/pg_operator_d.h +142 -0
  100. data/ext/pg_query/include/postgres/catalog/pg_opfamily.h +67 -0
  101. data/ext/pg_query/include/postgres/catalog/pg_opfamily_d.h +51 -0
  102. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table.h +76 -0
  103. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table_d.h +36 -0
  104. data/ext/pg_query/include/postgres/catalog/pg_proc.h +223 -0
  105. data/ext/pg_query/include/postgres/catalog/pg_proc_d.h +101 -0
  106. data/ext/pg_query/include/postgres/catalog/pg_publication.h +161 -0
  107. data/ext/pg_query/include/postgres/catalog/pg_publication_d.h +38 -0
  108. data/ext/pg_query/include/postgres/catalog/pg_replication_origin.h +65 -0
  109. data/ext/pg_query/include/postgres/catalog/pg_replication_origin_d.h +33 -0
  110. data/ext/pg_query/include/postgres/catalog/pg_statistic.h +288 -0
  111. data/ext/pg_query/include/postgres/catalog/pg_statistic_d.h +199 -0
  112. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext.h +91 -0
  113. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext_d.h +45 -0
  114. data/ext/pg_query/include/postgres/catalog/pg_transform.h +51 -0
  115. data/ext/pg_query/include/postgres/catalog/pg_transform_d.h +34 -0
  116. data/ext/pg_query/include/postgres/catalog/pg_trigger.h +153 -0
  117. data/ext/pg_query/include/postgres/catalog/pg_trigger_d.h +109 -0
  118. data/ext/pg_query/include/postgres/catalog/pg_ts_config.h +56 -0
  119. data/ext/pg_query/include/postgres/catalog/pg_ts_config_d.h +34 -0
  120. data/ext/pg_query/include/postgres/catalog/pg_ts_dict.h +62 -0
  121. data/ext/pg_query/include/postgres/catalog/pg_ts_dict_d.h +35 -0
  122. data/ext/pg_query/include/postgres/catalog/pg_ts_parser.h +63 -0
  123. data/ext/pg_query/include/postgres/catalog/pg_ts_parser_d.h +37 -0
  124. data/ext/pg_query/include/postgres/catalog/pg_ts_template.h +54 -0
  125. data/ext/pg_query/include/postgres/catalog/pg_ts_template_d.h +34 -0
  126. data/ext/pg_query/include/postgres/catalog/pg_type.h +407 -0
  127. data/ext/pg_query/include/postgres/catalog/pg_type_d.h +324 -0
  128. data/ext/pg_query/include/postgres/catalog/storage.h +50 -0
  129. data/ext/pg_query/include/postgres/catalog/syscache_ids.h +104 -0
  130. data/ext/pg_query/include/postgres/commands/async.h +49 -0
  131. data/ext/pg_query/include/postgres/commands/dbcommands.h +37 -0
  132. data/ext/pg_query/include/postgres/commands/defrem.h +161 -0
  133. data/ext/pg_query/include/postgres/commands/event_trigger.h +91 -0
  134. data/ext/pg_query/include/postgres/commands/explain.h +145 -0
  135. data/ext/pg_query/include/postgres/commands/prepare.h +61 -0
  136. data/ext/pg_query/include/postgres/commands/tablespace.h +69 -0
  137. data/ext/pg_query/include/postgres/commands/trigger.h +288 -0
  138. data/ext/pg_query/include/postgres/commands/vacuum.h +388 -0
  139. data/ext/pg_query/include/postgres/common/cryptohash.h +39 -0
  140. data/ext/pg_query/include/postgres/common/file_perm.h +56 -0
  141. data/ext/pg_query/include/postgres/common/file_utils.h +65 -0
  142. data/ext/pg_query/include/postgres/common/hashfn.h +119 -0
  143. data/ext/pg_query/include/postgres/common/hashfn_unstable.h +453 -0
  144. data/ext/pg_query/include/postgres/common/int.h +512 -0
  145. data/ext/pg_query/include/postgres/common/keywords.h +29 -0
  146. data/ext/pg_query/include/postgres/common/kwlookup.h +44 -0
  147. data/ext/pg_query/include/postgres/common/pg_prng.h +62 -0
  148. data/ext/pg_query/include/postgres/common/relpath.h +97 -0
  149. data/ext/pg_query/include/postgres/common/scram-common.h +70 -0
  150. data/ext/pg_query/include/postgres/common/sha2.h +32 -0
  151. data/ext/pg_query/include/postgres/common/string.h +44 -0
  152. data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +124 -0
  153. data/ext/pg_query/include/postgres/copyfuncs.funcs.c +5261 -0
  154. data/ext/pg_query/include/postgres/copyfuncs.switch.c +989 -0
  155. data/ext/pg_query/include/postgres/datatype/timestamp.h +269 -0
  156. data/ext/pg_query/include/postgres/equalfuncs.funcs.c +3310 -0
  157. data/ext/pg_query/include/postgres/equalfuncs.switch.c +836 -0
  158. data/ext/pg_query/include/postgres/executor/execdesc.h +70 -0
  159. data/ext/pg_query/include/postgres/executor/executor.h +681 -0
  160. data/ext/pg_query/include/postgres/executor/functions.h +56 -0
  161. data/ext/pg_query/include/postgres/executor/instrument.h +120 -0
  162. data/ext/pg_query/include/postgres/executor/spi.h +207 -0
  163. data/ext/pg_query/include/postgres/executor/tablefunc.h +67 -0
  164. data/ext/pg_query/include/postgres/executor/tuptable.h +523 -0
  165. data/ext/pg_query/include/postgres/fmgr.h +800 -0
  166. data/ext/pg_query/include/postgres/foreign/fdwapi.h +294 -0
  167. data/ext/pg_query/include/postgres/funcapi.h +360 -0
  168. data/ext/pg_query/include/postgres/gram.h +1168 -0
  169. data/ext/pg_query/include/postgres/gramparse.h +75 -0
  170. data/ext/pg_query/include/postgres/jit/jit.h +106 -0
  171. data/ext/pg_query/include/postgres/kwlist_d.h +1164 -0
  172. data/ext/pg_query/include/postgres/lib/dshash.h +130 -0
  173. data/ext/pg_query/include/postgres/lib/ilist.h +1159 -0
  174. data/ext/pg_query/include/postgres/lib/pairingheap.h +102 -0
  175. data/ext/pg_query/include/postgres/lib/simplehash.h +1206 -0
  176. data/ext/pg_query/include/postgres/lib/sort_template.h +445 -0
  177. data/ext/pg_query/include/postgres/lib/stringinfo.h +243 -0
  178. data/ext/pg_query/include/postgres/libpq/auth.h +37 -0
  179. data/ext/pg_query/include/postgres/libpq/crypt.h +47 -0
  180. data/ext/pg_query/include/postgres/libpq/hba.h +186 -0
  181. data/ext/pg_query/include/postgres/libpq/libpq-be.h +358 -0
  182. data/ext/pg_query/include/postgres/libpq/libpq.h +143 -0
  183. data/ext/pg_query/include/postgres/libpq/pqcomm.h +169 -0
  184. data/ext/pg_query/include/postgres/libpq/pqformat.h +209 -0
  185. data/ext/pg_query/include/postgres/libpq/pqsignal.h +54 -0
  186. data/ext/pg_query/include/postgres/libpq/protocol.h +89 -0
  187. data/ext/pg_query/include/postgres/libpq/sasl.h +136 -0
  188. data/ext/pg_query/include/postgres/libpq/scram.h +37 -0
  189. data/ext/pg_query/include/postgres/mb/pg_wchar.h +792 -0
  190. data/ext/pg_query/include/postgres/mb/stringinfo_mb.h +24 -0
  191. data/ext/pg_query/include/postgres/miscadmin.h +519 -0
  192. data/ext/pg_query/include/postgres/nodes/bitmapset.h +140 -0
  193. data/ext/pg_query/include/postgres/nodes/execnodes.h +2852 -0
  194. data/ext/pg_query/include/postgres/nodes/extensible.h +164 -0
  195. data/ext/pg_query/include/postgres/nodes/lockoptions.h +61 -0
  196. data/ext/pg_query/include/postgres/nodes/makefuncs.h +127 -0
  197. data/ext/pg_query/include/postgres/nodes/memnodes.h +152 -0
  198. data/ext/pg_query/include/postgres/nodes/miscnodes.h +56 -0
  199. data/ext/pg_query/include/postgres/nodes/nodeFuncs.h +222 -0
  200. data/ext/pg_query/include/postgres/nodes/nodes.h +435 -0
  201. data/ext/pg_query/include/postgres/nodes/nodetags.h +491 -0
  202. data/ext/pg_query/include/postgres/nodes/params.h +170 -0
  203. data/ext/pg_query/include/postgres/nodes/parsenodes.h +4233 -0
  204. data/ext/pg_query/include/postgres/nodes/pathnodes.h +3435 -0
  205. data/ext/pg_query/include/postgres/nodes/pg_list.h +686 -0
  206. data/ext/pg_query/include/postgres/nodes/plannodes.h +1593 -0
  207. data/ext/pg_query/include/postgres/nodes/primnodes.h +2335 -0
  208. data/ext/pg_query/include/postgres/nodes/print.h +34 -0
  209. data/ext/pg_query/include/postgres/nodes/queryjumble.h +86 -0
  210. data/ext/pg_query/include/postgres/nodes/replnodes.h +132 -0
  211. data/ext/pg_query/include/postgres/nodes/supportnodes.h +346 -0
  212. data/ext/pg_query/include/postgres/nodes/tidbitmap.h +75 -0
  213. data/ext/pg_query/include/postgres/nodes/value.h +90 -0
  214. data/ext/pg_query/include/postgres/optimizer/cost.h +216 -0
  215. data/ext/pg_query/include/postgres/optimizer/geqo.h +90 -0
  216. data/ext/pg_query/include/postgres/optimizer/geqo_gene.h +45 -0
  217. data/ext/pg_query/include/postgres/optimizer/optimizer.h +205 -0
  218. data/ext/pg_query/include/postgres/optimizer/paths.h +271 -0
  219. data/ext/pg_query/include/postgres/optimizer/planmain.h +123 -0
  220. data/ext/pg_query/include/postgres/parser/analyze.h +66 -0
  221. data/ext/pg_query/include/postgres/parser/kwlist.h +518 -0
  222. data/ext/pg_query/include/postgres/parser/parse_agg.h +65 -0
  223. data/ext/pg_query/include/postgres/parser/parse_coerce.h +102 -0
  224. data/ext/pg_query/include/postgres/parser/parse_expr.h +25 -0
  225. data/ext/pg_query/include/postgres/parser/parse_func.h +74 -0
  226. data/ext/pg_query/include/postgres/parser/parse_node.h +358 -0
  227. data/ext/pg_query/include/postgres/parser/parse_oper.h +68 -0
  228. data/ext/pg_query/include/postgres/parser/parse_relation.h +129 -0
  229. data/ext/pg_query/include/postgres/parser/parse_type.h +61 -0
  230. data/ext/pg_query/include/postgres/parser/parser.h +68 -0
  231. data/ext/pg_query/include/postgres/parser/parsetree.h +61 -0
  232. data/ext/pg_query/include/postgres/parser/scanner.h +152 -0
  233. data/ext/pg_query/include/postgres/parser/scansup.h +27 -0
  234. data/ext/pg_query/include/postgres/partitioning/partdefs.h +26 -0
  235. data/ext/pg_query/include/postgres/pg_config.h +977 -0
  236. data/ext/pg_query/include/postgres/pg_config_manual.h +385 -0
  237. data/ext/pg_query/include/postgres/pg_config_os.h +8 -0
  238. data/ext/pg_query/include/postgres/pg_getopt.h +56 -0
  239. data/ext/pg_query/include/postgres/pg_trace.h +17 -0
  240. data/ext/pg_query/include/postgres/pgstat.h +780 -0
  241. data/ext/pg_query/include/postgres/pgtime.h +94 -0
  242. data/ext/pg_query/include/postgres/pl_gram.h +385 -0
  243. data/ext/pg_query/include/postgres/pl_reserved_kwlist.h +52 -0
  244. data/ext/pg_query/include/postgres/pl_reserved_kwlist_d.h +114 -0
  245. data/ext/pg_query/include/postgres/pl_unreserved_kwlist.h +112 -0
  246. data/ext/pg_query/include/postgres/pl_unreserved_kwlist_d.h +246 -0
  247. data/ext/pg_query/include/postgres/plerrcodes.h +998 -0
  248. data/ext/pg_query/include/postgres/plpgsql.h +1342 -0
  249. data/ext/pg_query/include/postgres/port/atomics/arch-arm.h +32 -0
  250. data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +17 -0
  251. data/ext/pg_query/include/postgres/port/atomics/arch-ppc.h +256 -0
  252. data/ext/pg_query/include/postgres/port/atomics/arch-x86.h +254 -0
  253. data/ext/pg_query/include/postgres/port/atomics/fallback.h +170 -0
  254. data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +323 -0
  255. data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +119 -0
  256. data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +121 -0
  257. data/ext/pg_query/include/postgres/port/atomics/generic.h +437 -0
  258. data/ext/pg_query/include/postgres/port/atomics.h +606 -0
  259. data/ext/pg_query/include/postgres/port/pg_bitutils.h +421 -0
  260. data/ext/pg_query/include/postgres/port/pg_bswap.h +161 -0
  261. data/ext/pg_query/include/postgres/port/pg_crc32c.h +110 -0
  262. data/ext/pg_query/include/postgres/port/pg_iovec.h +117 -0
  263. data/ext/pg_query/include/postgres/port/simd.h +422 -0
  264. data/ext/pg_query/include/postgres/port/win32/arpa/inet.h +3 -0
  265. data/ext/pg_query/include/postgres/port/win32/dlfcn.h +1 -0
  266. data/ext/pg_query/include/postgres/port/win32/grp.h +1 -0
  267. data/ext/pg_query/include/postgres/port/win32/netdb.h +7 -0
  268. data/ext/pg_query/include/postgres/port/win32/netinet/in.h +3 -0
  269. data/ext/pg_query/include/postgres/port/win32/netinet/tcp.h +7 -0
  270. data/ext/pg_query/include/postgres/port/win32/pwd.h +3 -0
  271. data/ext/pg_query/include/postgres/port/win32/sys/resource.h +20 -0
  272. data/ext/pg_query/include/postgres/port/win32/sys/select.h +3 -0
  273. data/ext/pg_query/include/postgres/port/win32/sys/socket.h +34 -0
  274. data/ext/pg_query/include/postgres/port/win32/sys/un.h +17 -0
  275. data/ext/pg_query/include/postgres/port/win32/sys/wait.h +3 -0
  276. data/ext/pg_query/include/postgres/port/win32.h +59 -0
  277. data/ext/pg_query/include/postgres/port/win32_msvc/dirent.h +34 -0
  278. data/ext/pg_query/include/postgres/port/win32_msvc/sys/file.h +1 -0
  279. data/ext/pg_query/include/postgres/port/win32_msvc/sys/param.h +1 -0
  280. data/ext/pg_query/include/postgres/port/win32_msvc/sys/time.h +1 -0
  281. data/ext/pg_query/include/postgres/port/win32_msvc/unistd.h +9 -0
  282. data/ext/pg_query/include/postgres/port/win32_msvc/utime.h +3 -0
  283. data/ext/pg_query/include/postgres/port/win32_port.h +584 -0
  284. data/ext/pg_query/include/postgres/port.h +524 -0
  285. data/ext/pg_query/include/postgres/portability/instr_time.h +197 -0
  286. data/ext/pg_query/include/postgres/postgres.h +579 -0
  287. data/ext/pg_query/include/postgres/postmaster/autovacuum.h +69 -0
  288. data/ext/pg_query/include/postgres/postmaster/bgworker.h +164 -0
  289. data/ext/pg_query/include/postgres/postmaster/bgworker_internals.h +60 -0
  290. data/ext/pg_query/include/postgres/postmaster/bgwriter.h +45 -0
  291. data/ext/pg_query/include/postgres/postmaster/interrupt.h +32 -0
  292. data/ext/pg_query/include/postgres/postmaster/pgarch.h +36 -0
  293. data/ext/pg_query/include/postgres/postmaster/postmaster.h +101 -0
  294. data/ext/pg_query/include/postgres/postmaster/startup.h +41 -0
  295. data/ext/pg_query/include/postgres/postmaster/syslogger.h +101 -0
  296. data/ext/pg_query/include/postgres/postmaster/walsummarizer.h +35 -0
  297. data/ext/pg_query/include/postgres/postmaster/walwriter.h +23 -0
  298. data/ext/pg_query/include/postgres/regex/regex.h +272 -0
  299. data/ext/pg_query/include/postgres/replication/logicallauncher.h +34 -0
  300. data/ext/pg_query/include/postgres/replication/logicalproto.h +274 -0
  301. data/ext/pg_query/include/postgres/replication/logicalworker.h +33 -0
  302. data/ext/pg_query/include/postgres/replication/origin.h +73 -0
  303. data/ext/pg_query/include/postgres/replication/reorderbuffer.h +743 -0
  304. data/ext/pg_query/include/postgres/replication/slot.h +285 -0
  305. data/ext/pg_query/include/postgres/replication/slotsync.h +38 -0
  306. data/ext/pg_query/include/postgres/replication/syncrep.h +109 -0
  307. data/ext/pg_query/include/postgres/replication/walreceiver.h +504 -0
  308. data/ext/pg_query/include/postgres/replication/walsender.h +76 -0
  309. data/ext/pg_query/include/postgres/rewrite/prs2lock.h +46 -0
  310. data/ext/pg_query/include/postgres/rewrite/rewriteHandler.h +41 -0
  311. data/ext/pg_query/include/postgres/rewrite/rewriteManip.h +96 -0
  312. data/ext/pg_query/include/postgres/rewrite/rewriteSupport.h +26 -0
  313. data/ext/pg_query/include/postgres/storage/block.h +108 -0
  314. data/ext/pg_query/include/postgres/storage/buf.h +46 -0
  315. data/ext/pg_query/include/postgres/storage/bufmgr.h +411 -0
  316. data/ext/pg_query/include/postgres/storage/bufpage.h +510 -0
  317. data/ext/pg_query/include/postgres/storage/condition_variable.h +73 -0
  318. data/ext/pg_query/include/postgres/storage/dsm.h +61 -0
  319. data/ext/pg_query/include/postgres/storage/dsm_impl.h +79 -0
  320. data/ext/pg_query/include/postgres/storage/fd.h +219 -0
  321. data/ext/pg_query/include/postgres/storage/fileset.h +40 -0
  322. data/ext/pg_query/include/postgres/storage/ipc.h +87 -0
  323. data/ext/pg_query/include/postgres/storage/item.h +19 -0
  324. data/ext/pg_query/include/postgres/storage/itemid.h +184 -0
  325. data/ext/pg_query/include/postgres/storage/itemptr.h +245 -0
  326. data/ext/pg_query/include/postgres/storage/large_object.h +100 -0
  327. data/ext/pg_query/include/postgres/storage/latch.h +196 -0
  328. data/ext/pg_query/include/postgres/storage/lmgr.h +126 -0
  329. data/ext/pg_query/include/postgres/storage/lock.h +624 -0
  330. data/ext/pg_query/include/postgres/storage/lockdefs.h +59 -0
  331. data/ext/pg_query/include/postgres/storage/lwlock.h +228 -0
  332. data/ext/pg_query/include/postgres/storage/lwlocknames.h +47 -0
  333. data/ext/pg_query/include/postgres/storage/off.h +57 -0
  334. data/ext/pg_query/include/postgres/storage/pg_sema.h +61 -0
  335. data/ext/pg_query/include/postgres/storage/pg_shmem.h +93 -0
  336. data/ext/pg_query/include/postgres/storage/pmsignal.h +105 -0
  337. data/ext/pg_query/include/postgres/storage/predicate.h +83 -0
  338. data/ext/pg_query/include/postgres/storage/proc.h +491 -0
  339. data/ext/pg_query/include/postgres/storage/procarray.h +103 -0
  340. data/ext/pg_query/include/postgres/storage/proclist_types.h +53 -0
  341. data/ext/pg_query/include/postgres/storage/procnumber.h +43 -0
  342. data/ext/pg_query/include/postgres/storage/procsignal.h +75 -0
  343. data/ext/pg_query/include/postgres/storage/read_stream.h +65 -0
  344. data/ext/pg_query/include/postgres/storage/relfilelocator.h +100 -0
  345. data/ext/pg_query/include/postgres/storage/s_lock.h +847 -0
  346. data/ext/pg_query/include/postgres/storage/sharedfileset.h +37 -0
  347. data/ext/pg_query/include/postgres/storage/shm_mq.h +86 -0
  348. data/ext/pg_query/include/postgres/storage/shm_toc.h +58 -0
  349. data/ext/pg_query/include/postgres/storage/shmem.h +59 -0
  350. data/ext/pg_query/include/postgres/storage/sinval.h +153 -0
  351. data/ext/pg_query/include/postgres/storage/smgr.h +127 -0
  352. data/ext/pg_query/include/postgres/storage/spin.h +77 -0
  353. data/ext/pg_query/include/postgres/storage/standby.h +109 -0
  354. data/ext/pg_query/include/postgres/storage/standbydefs.h +74 -0
  355. data/ext/pg_query/include/postgres/storage/sync.h +66 -0
  356. data/ext/pg_query/include/postgres/tcop/cmdtag.h +62 -0
  357. data/ext/pg_query/include/postgres/tcop/cmdtaglist.h +219 -0
  358. data/ext/pg_query/include/postgres/tcop/deparse_utility.h +108 -0
  359. data/ext/pg_query/include/postgres/tcop/dest.h +148 -0
  360. data/ext/pg_query/include/postgres/tcop/fastpath.h +20 -0
  361. data/ext/pg_query/include/postgres/tcop/pquery.h +51 -0
  362. data/ext/pg_query/include/postgres/tcop/tcopprot.h +98 -0
  363. data/ext/pg_query/include/postgres/tcop/utility.h +112 -0
  364. data/ext/pg_query/include/postgres/tsearch/ts_cache.h +96 -0
  365. data/ext/pg_query/include/postgres/utils/acl.h +290 -0
  366. data/ext/pg_query/include/postgres/utils/aclchk_internal.h +45 -0
  367. data/ext/pg_query/include/postgres/utils/array.h +481 -0
  368. data/ext/pg_query/include/postgres/utils/ascii.h +84 -0
  369. data/ext/pg_query/include/postgres/utils/backend_progress.h +46 -0
  370. data/ext/pg_query/include/postgres/utils/backend_status.h +340 -0
  371. data/ext/pg_query/include/postgres/utils/builtins.h +139 -0
  372. data/ext/pg_query/include/postgres/utils/bytea.h +28 -0
  373. data/ext/pg_query/include/postgres/utils/catcache.h +230 -0
  374. data/ext/pg_query/include/postgres/utils/date.h +118 -0
  375. data/ext/pg_query/include/postgres/utils/datetime.h +367 -0
  376. data/ext/pg_query/include/postgres/utils/datum.h +76 -0
  377. data/ext/pg_query/include/postgres/utils/dsa.h +166 -0
  378. data/ext/pg_query/include/postgres/utils/elog.h +540 -0
  379. data/ext/pg_query/include/postgres/utils/errcodes.h +352 -0
  380. data/ext/pg_query/include/postgres/utils/expandeddatum.h +170 -0
  381. data/ext/pg_query/include/postgres/utils/expandedrecord.h +241 -0
  382. data/ext/pg_query/include/postgres/utils/float.h +357 -0
  383. data/ext/pg_query/include/postgres/utils/fmgroids.h +3347 -0
  384. data/ext/pg_query/include/postgres/utils/fmgrprotos.h +2904 -0
  385. data/ext/pg_query/include/postgres/utils/fmgrtab.h +49 -0
  386. data/ext/pg_query/include/postgres/utils/guc.h +456 -0
  387. data/ext/pg_query/include/postgres/utils/guc_hooks.h +184 -0
  388. data/ext/pg_query/include/postgres/utils/guc_tables.h +323 -0
  389. data/ext/pg_query/include/postgres/utils/hsearch.h +153 -0
  390. data/ext/pg_query/include/postgres/utils/injection_point.h +44 -0
  391. data/ext/pg_query/include/postgres/utils/inval.h +68 -0
  392. data/ext/pg_query/include/postgres/utils/logtape.h +77 -0
  393. data/ext/pg_query/include/postgres/utils/lsyscache.h +215 -0
  394. data/ext/pg_query/include/postgres/utils/memdebug.h +82 -0
  395. data/ext/pg_query/include/postgres/utils/memutils.h +193 -0
  396. data/ext/pg_query/include/postgres/utils/memutils_internal.h +176 -0
  397. data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +253 -0
  398. data/ext/pg_query/include/postgres/utils/numeric.h +110 -0
  399. data/ext/pg_query/include/postgres/utils/palloc.h +151 -0
  400. data/ext/pg_query/include/postgres/utils/partcache.h +103 -0
  401. data/ext/pg_query/include/postgres/utils/pg_locale.h +136 -0
  402. data/ext/pg_query/include/postgres/utils/pgstat_internal.h +808 -0
  403. data/ext/pg_query/include/postgres/utils/plancache.h +238 -0
  404. data/ext/pg_query/include/postgres/utils/portal.h +252 -0
  405. data/ext/pg_query/include/postgres/utils/queryenvironment.h +74 -0
  406. data/ext/pg_query/include/postgres/utils/regproc.h +39 -0
  407. data/ext/pg_query/include/postgres/utils/rel.h +711 -0
  408. data/ext/pg_query/include/postgres/utils/relcache.h +155 -0
  409. data/ext/pg_query/include/postgres/utils/reltrigger.h +81 -0
  410. data/ext/pg_query/include/postgres/utils/resowner.h +167 -0
  411. data/ext/pg_query/include/postgres/utils/ruleutils.h +52 -0
  412. data/ext/pg_query/include/postgres/utils/sharedtuplestore.h +61 -0
  413. data/ext/pg_query/include/postgres/utils/snapmgr.h +130 -0
  414. data/ext/pg_query/include/postgres/utils/snapshot.h +219 -0
  415. data/ext/pg_query/include/postgres/utils/sortsupport.h +391 -0
  416. data/ext/pg_query/include/postgres/utils/syscache.h +131 -0
  417. data/ext/pg_query/include/postgres/utils/timeout.h +96 -0
  418. data/ext/pg_query/include/postgres/utils/timestamp.h +147 -0
  419. data/ext/pg_query/include/postgres/utils/tuplesort.h +472 -0
  420. data/ext/pg_query/include/postgres/utils/tuplestore.h +88 -0
  421. data/ext/pg_query/include/postgres/utils/typcache.h +210 -0
  422. data/ext/pg_query/include/postgres/utils/varlena.h +53 -0
  423. data/ext/pg_query/include/postgres/utils/wait_event.h +108 -0
  424. data/ext/pg_query/include/postgres/utils/wait_event_types.h +218 -0
  425. data/ext/pg_query/include/postgres/utils/xml.h +94 -0
  426. data/ext/pg_query/include/postgres/varatt.h +358 -0
  427. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1546 -792
  428. data/ext/pg_query/include/protobuf/pg_query.pb.h +58365 -46595
  429. data/ext/pg_query/pg_query.c +9 -0
  430. data/ext/pg_query/pg_query.pb-c.c +6598 -3739
  431. data/ext/pg_query/pg_query_fingerprint.c +4 -5
  432. data/ext/pg_query/pg_query_normalize.c +42 -1
  433. data/ext/pg_query/pg_query_outfuncs_json.c +9 -1
  434. data/ext/pg_query/pg_query_outfuncs_protobuf.c +1 -0
  435. data/ext/pg_query/pg_query_parse.c +1 -1
  436. data/ext/pg_query/pg_query_parse_plpgsql.c +18 -17
  437. data/ext/pg_query/pg_query_readfuncs_protobuf.c +3 -2
  438. data/ext/pg_query/pg_query_ruby.c +5 -0
  439. data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -1
  440. data/ext/pg_query/pg_query_scan.c +1 -1
  441. data/ext/pg_query/pg_query_split.c +1 -1
  442. data/ext/pg_query/postgres_deparse.c +409 -21
  443. data/ext/pg_query/src_backend_catalog_namespace.c +241 -66
  444. data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -3
  445. data/ext/pg_query/src_backend_commands_define.c +2 -3
  446. data/ext/pg_query/src_backend_nodes_bitmapset.c +137 -94
  447. data/ext/pg_query/src_backend_nodes_copyfuncs.c +1 -1
  448. data/ext/pg_query/src_backend_nodes_equalfuncs.c +1 -1
  449. data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
  450. data/ext/pg_query/src_backend_nodes_list.c +3 -7
  451. data/ext/pg_query/src_backend_nodes_makefuncs.c +59 -20
  452. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +109 -2
  453. data/ext/pg_query/src_backend_nodes_value.c +1 -1
  454. data/ext/pg_query/src_backend_parser_gram.c +34490 -32135
  455. data/ext/pg_query/src_backend_parser_parser.c +8 -8
  456. data/ext/pg_query/src_backend_parser_scan.c +5637 -3028
  457. data/ext/pg_query/src_backend_parser_scansup.c +2 -1
  458. data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
  459. data/ext/pg_query/src_backend_tcop_postgres.c +34 -10
  460. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +2 -2
  461. data/ext/pg_query/src_backend_utils_adt_datum.c +8 -6
  462. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  463. data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
  464. data/ext/pg_query/src_backend_utils_adt_numutils.c +4 -5
  465. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +101 -28
  466. data/ext/pg_query/src_backend_utils_error_assert.c +1 -1
  467. data/ext/pg_query/src_backend_utils_error_elog.c +60 -190
  468. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +4 -2
  469. data/ext/pg_query/src_backend_utils_init_globals.c +16 -4
  470. data/ext/pg_query/src_backend_utils_mb_mbutils.c +19 -81
  471. data/ext/pg_query/src_backend_utils_misc_guc_tables.c +16 -8
  472. data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +8 -5
  473. data/ext/pg_query/src_backend_utils_mmgr_aset.c +308 -238
  474. data/ext/pg_query/src_backend_utils_mmgr_bump.c +728 -0
  475. data/ext/pg_query/src_backend_utils_mmgr_generation.c +273 -197
  476. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +270 -215
  477. data/ext/pg_query/src_backend_utils_mmgr_slab.c +154 -96
  478. data/ext/pg_query/src_common_encnames.c +43 -44
  479. data/ext/pg_query/src_common_hashfn.c +1 -1
  480. data/ext/pg_query/src_common_keywords.c +1 -1
  481. data/ext/pg_query/src_common_kwlist_d.h +511 -466
  482. data/ext/pg_query/src_common_kwlookup.c +1 -1
  483. data/ext/pg_query/src_common_psprintf.c +3 -3
  484. data/ext/pg_query/src_common_stringinfo.c +18 -1
  485. data/ext/pg_query/src_common_wchar.c +45 -108
  486. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +99 -5
  487. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -1
  488. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +242 -143
  489. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  490. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +1 -1
  491. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +19 -1
  492. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +1 -1
  493. data/ext/pg_query/src_port_pg_bitutils.c +251 -32
  494. data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
  495. data/ext/pg_query/src_port_snprintf.c +4 -4
  496. data/ext/pg_query/src_port_strerror.c +1 -3
  497. data/ext/pg_query/src_port_strlcpy.c +79 -0
  498. data/lib/pg_query/fingerprint.rb +2 -3
  499. data/lib/pg_query/node.rb +16 -11
  500. data/lib/pg_query/param_refs.rb +1 -1
  501. data/lib/pg_query/parse.rb +1 -1
  502. data/lib/pg_query/pg_query_pb.rb +26 -3
  503. data/lib/pg_query/treewalker.rb +52 -12
  504. data/lib/pg_query/truncate.rb +1 -1
  505. data/lib/pg_query/version.rb +1 -1
  506. metadata +444 -400
  507. data/ext/pg_query/guc-file.c +0 -0
  508. data/ext/pg_query/include/access/amapi.h +0 -292
  509. data/ext/pg_query/include/access/attmap.h +0 -54
  510. data/ext/pg_query/include/access/attnum.h +0 -64
  511. data/ext/pg_query/include/access/clog.h +0 -63
  512. data/ext/pg_query/include/access/commit_ts.h +0 -74
  513. data/ext/pg_query/include/access/detoast.h +0 -82
  514. data/ext/pg_query/include/access/genam.h +0 -233
  515. data/ext/pg_query/include/access/gin.h +0 -91
  516. data/ext/pg_query/include/access/htup.h +0 -89
  517. data/ext/pg_query/include/access/htup_details.h +0 -811
  518. data/ext/pg_query/include/access/itup.h +0 -170
  519. data/ext/pg_query/include/access/parallel.h +0 -82
  520. data/ext/pg_query/include/access/printtup.h +0 -35
  521. data/ext/pg_query/include/access/relation.h +0 -28
  522. data/ext/pg_query/include/access/relscan.h +0 -191
  523. data/ext/pg_query/include/access/rmgrlist.h +0 -49
  524. data/ext/pg_query/include/access/sdir.h +0 -67
  525. data/ext/pg_query/include/access/skey.h +0 -151
  526. data/ext/pg_query/include/access/stratnum.h +0 -85
  527. data/ext/pg_query/include/access/sysattr.h +0 -29
  528. data/ext/pg_query/include/access/table.h +0 -28
  529. data/ext/pg_query/include/access/tableam.h +0 -2100
  530. data/ext/pg_query/include/access/toast_compression.h +0 -73
  531. data/ext/pg_query/include/access/transam.h +0 -375
  532. data/ext/pg_query/include/access/tsmapi.h +0 -82
  533. data/ext/pg_query/include/access/tupconvert.h +0 -54
  534. data/ext/pg_query/include/access/tupdesc.h +0 -154
  535. data/ext/pg_query/include/access/tupmacs.h +0 -207
  536. data/ext/pg_query/include/access/twophase.h +0 -65
  537. data/ext/pg_query/include/access/xact.h +0 -530
  538. data/ext/pg_query/include/access/xlog.h +0 -302
  539. data/ext/pg_query/include/access/xlog_internal.h +0 -404
  540. data/ext/pg_query/include/access/xlogbackup.h +0 -41
  541. data/ext/pg_query/include/access/xlogdefs.h +0 -82
  542. data/ext/pg_query/include/access/xlogprefetcher.h +0 -55
  543. data/ext/pg_query/include/access/xlogreader.h +0 -444
  544. data/ext/pg_query/include/access/xlogrecord.h +0 -248
  545. data/ext/pg_query/include/access/xlogrecovery.h +0 -158
  546. data/ext/pg_query/include/archive/archive_module.h +0 -59
  547. data/ext/pg_query/include/c.h +0 -1379
  548. data/ext/pg_query/include/catalog/catalog.h +0 -45
  549. data/ext/pg_query/include/catalog/catversion.h +0 -62
  550. data/ext/pg_query/include/catalog/dependency.h +0 -270
  551. data/ext/pg_query/include/catalog/genbki.h +0 -143
  552. data/ext/pg_query/include/catalog/index.h +0 -214
  553. data/ext/pg_query/include/catalog/indexing.h +0 -54
  554. data/ext/pg_query/include/catalog/namespace.h +0 -190
  555. data/ext/pg_query/include/catalog/objectaccess.h +0 -267
  556. data/ext/pg_query/include/catalog/objectaddress.h +0 -89
  557. data/ext/pg_query/include/catalog/pg_aggregate.h +0 -180
  558. data/ext/pg_query/include/catalog/pg_aggregate_d.h +0 -78
  559. data/ext/pg_query/include/catalog/pg_am.h +0 -63
  560. data/ext/pg_query/include/catalog/pg_am_d.h +0 -47
  561. data/ext/pg_query/include/catalog/pg_attribute.h +0 -223
  562. data/ext/pg_query/include/catalog/pg_attribute_d.h +0 -62
  563. data/ext/pg_query/include/catalog/pg_authid.h +0 -63
  564. data/ext/pg_query/include/catalog/pg_authid_d.h +0 -59
  565. data/ext/pg_query/include/catalog/pg_class.h +0 -230
  566. data/ext/pg_query/include/catalog/pg_class_d.h +0 -132
  567. data/ext/pg_query/include/catalog/pg_collation.h +0 -100
  568. data/ext/pg_query/include/catalog/pg_collation_d.h +0 -63
  569. data/ext/pg_query/include/catalog/pg_constraint.h +0 -273
  570. data/ext/pg_query/include/catalog/pg_constraint_d.h +0 -73
  571. data/ext/pg_query/include/catalog/pg_control.h +0 -258
  572. data/ext/pg_query/include/catalog/pg_conversion.h +0 -75
  573. data/ext/pg_query/include/catalog/pg_conversion_d.h +0 -38
  574. data/ext/pg_query/include/catalog/pg_database.h +0 -124
  575. data/ext/pg_query/include/catalog/pg_database_d.h +0 -52
  576. data/ext/pg_query/include/catalog/pg_depend.h +0 -77
  577. data/ext/pg_query/include/catalog/pg_depend_d.h +0 -36
  578. data/ext/pg_query/include/catalog/pg_event_trigger.h +0 -57
  579. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +0 -36
  580. data/ext/pg_query/include/catalog/pg_index.h +0 -90
  581. data/ext/pg_query/include/catalog/pg_index_d.h +0 -59
  582. data/ext/pg_query/include/catalog/pg_language.h +0 -72
  583. data/ext/pg_query/include/catalog/pg_language_d.h +0 -41
  584. data/ext/pg_query/include/catalog/pg_namespace.h +0 -64
  585. data/ext/pg_query/include/catalog/pg_namespace_d.h +0 -36
  586. data/ext/pg_query/include/catalog/pg_opclass.h +0 -88
  587. data/ext/pg_query/include/catalog/pg_opclass_d.h +0 -51
  588. data/ext/pg_query/include/catalog/pg_operator.h +0 -107
  589. data/ext/pg_query/include/catalog/pg_operator_d.h +0 -142
  590. data/ext/pg_query/include/catalog/pg_opfamily.h +0 -64
  591. data/ext/pg_query/include/catalog/pg_opfamily_d.h +0 -51
  592. data/ext/pg_query/include/catalog/pg_partitioned_table.h +0 -74
  593. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +0 -36
  594. data/ext/pg_query/include/catalog/pg_proc.h +0 -220
  595. data/ext/pg_query/include/catalog/pg_proc_d.h +0 -101
  596. data/ext/pg_query/include/catalog/pg_publication.h +0 -158
  597. data/ext/pg_query/include/catalog/pg_publication_d.h +0 -38
  598. data/ext/pg_query/include/catalog/pg_replication_origin.h +0 -62
  599. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +0 -33
  600. data/ext/pg_query/include/catalog/pg_statistic.h +0 -282
  601. data/ext/pg_query/include/catalog/pg_statistic_d.h +0 -195
  602. data/ext/pg_query/include/catalog/pg_statistic_ext.h +0 -88
  603. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +0 -45
  604. data/ext/pg_query/include/catalog/pg_transform.h +0 -48
  605. data/ext/pg_query/include/catalog/pg_transform_d.h +0 -34
  606. data/ext/pg_query/include/catalog/pg_trigger.h +0 -153
  607. data/ext/pg_query/include/catalog/pg_trigger_d.h +0 -109
  608. data/ext/pg_query/include/catalog/pg_ts_config.h +0 -53
  609. data/ext/pg_query/include/catalog/pg_ts_config_d.h +0 -34
  610. data/ext/pg_query/include/catalog/pg_ts_dict.h +0 -59
  611. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +0 -35
  612. data/ext/pg_query/include/catalog/pg_ts_parser.h +0 -60
  613. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +0 -37
  614. data/ext/pg_query/include/catalog/pg_ts_template.h +0 -51
  615. data/ext/pg_query/include/catalog/pg_ts_template_d.h +0 -34
  616. data/ext/pg_query/include/catalog/pg_type.h +0 -404
  617. data/ext/pg_query/include/catalog/pg_type_d.h +0 -324
  618. data/ext/pg_query/include/catalog/storage.h +0 -50
  619. data/ext/pg_query/include/commands/async.h +0 -53
  620. data/ext/pg_query/include/commands/dbcommands.h +0 -37
  621. data/ext/pg_query/include/commands/defrem.h +0 -161
  622. data/ext/pg_query/include/commands/event_trigger.h +0 -88
  623. data/ext/pg_query/include/commands/explain.h +0 -129
  624. data/ext/pg_query/include/commands/prepare.h +0 -61
  625. data/ext/pg_query/include/commands/tablespace.h +0 -69
  626. data/ext/pg_query/include/commands/trigger.h +0 -288
  627. data/ext/pg_query/include/commands/vacuum.h +0 -386
  628. data/ext/pg_query/include/common/cryptohash.h +0 -39
  629. data/ext/pg_query/include/common/file_perm.h +0 -56
  630. data/ext/pg_query/include/common/hashfn.h +0 -104
  631. data/ext/pg_query/include/common/int.h +0 -437
  632. data/ext/pg_query/include/common/ip.h +0 -33
  633. data/ext/pg_query/include/common/keywords.h +0 -29
  634. data/ext/pg_query/include/common/kwlookup.h +0 -44
  635. data/ext/pg_query/include/common/pg_prng.h +0 -61
  636. data/ext/pg_query/include/common/relpath.h +0 -97
  637. data/ext/pg_query/include/common/scram-common.h +0 -70
  638. data/ext/pg_query/include/common/sha2.h +0 -32
  639. data/ext/pg_query/include/common/string.h +0 -44
  640. data/ext/pg_query/include/common/unicode_east_asian_fw_table.h +0 -125
  641. data/ext/pg_query/include/copyfuncs.funcs.c +0 -5013
  642. data/ext/pg_query/include/copyfuncs.switch.c +0 -938
  643. data/ext/pg_query/include/datatype/timestamp.h +0 -243
  644. data/ext/pg_query/include/equalfuncs.funcs.c +0 -3097
  645. data/ext/pg_query/include/equalfuncs.switch.c +0 -785
  646. data/ext/pg_query/include/executor/execdesc.h +0 -70
  647. data/ext/pg_query/include/executor/executor.h +0 -680
  648. data/ext/pg_query/include/executor/functions.h +0 -55
  649. data/ext/pg_query/include/executor/instrument.h +0 -118
  650. data/ext/pg_query/include/executor/spi.h +0 -213
  651. data/ext/pg_query/include/executor/tablefunc.h +0 -67
  652. data/ext/pg_query/include/executor/tuptable.h +0 -494
  653. data/ext/pg_query/include/fmgr.h +0 -800
  654. data/ext/pg_query/include/foreign/fdwapi.h +0 -294
  655. data/ext/pg_query/include/funcapi.h +0 -360
  656. data/ext/pg_query/include/gram.h +0 -1127
  657. data/ext/pg_query/include/gramparse.h +0 -75
  658. data/ext/pg_query/include/jit/jit.h +0 -105
  659. data/ext/pg_query/include/kwlist_d.h +0 -1119
  660. data/ext/pg_query/include/lib/dshash.h +0 -115
  661. data/ext/pg_query/include/lib/ilist.h +0 -1159
  662. data/ext/pg_query/include/lib/pairingheap.h +0 -102
  663. data/ext/pg_query/include/lib/simplehash.h +0 -1184
  664. data/ext/pg_query/include/lib/sort_template.h +0 -432
  665. data/ext/pg_query/include/lib/stringinfo.h +0 -161
  666. data/ext/pg_query/include/libpq/auth.h +0 -37
  667. data/ext/pg_query/include/libpq/crypt.h +0 -47
  668. data/ext/pg_query/include/libpq/hba.h +0 -186
  669. data/ext/pg_query/include/libpq/libpq-be.h +0 -354
  670. data/ext/pg_query/include/libpq/libpq.h +0 -144
  671. data/ext/pg_query/include/libpq/pqcomm.h +0 -163
  672. data/ext/pg_query/include/libpq/pqformat.h +0 -210
  673. data/ext/pg_query/include/libpq/pqsignal.h +0 -54
  674. data/ext/pg_query/include/libpq/sasl.h +0 -136
  675. data/ext/pg_query/include/libpq/scram.h +0 -37
  676. data/ext/pg_query/include/mb/pg_wchar.h +0 -772
  677. data/ext/pg_query/include/mb/stringinfo_mb.h +0 -24
  678. data/ext/pg_query/include/miscadmin.h +0 -507
  679. data/ext/pg_query/include/nodes/bitmapset.h +0 -126
  680. data/ext/pg_query/include/nodes/execnodes.h +0 -2768
  681. data/ext/pg_query/include/nodes/extensible.h +0 -164
  682. data/ext/pg_query/include/nodes/lockoptions.h +0 -61
  683. data/ext/pg_query/include/nodes/makefuncs.h +0 -121
  684. data/ext/pg_query/include/nodes/memnodes.h +0 -113
  685. data/ext/pg_query/include/nodes/miscnodes.h +0 -56
  686. data/ext/pg_query/include/nodes/nodeFuncs.h +0 -222
  687. data/ext/pg_query/include/nodes/nodes.h +0 -446
  688. data/ext/pg_query/include/nodes/nodetags.h +0 -471
  689. data/ext/pg_query/include/nodes/params.h +0 -170
  690. data/ext/pg_query/include/nodes/parsenodes.h +0 -4050
  691. data/ext/pg_query/include/nodes/pathnodes.h +0 -3384
  692. data/ext/pg_query/include/nodes/pg_list.h +0 -635
  693. data/ext/pg_query/include/nodes/plannodes.h +0 -1592
  694. data/ext/pg_query/include/nodes/primnodes.h +0 -2041
  695. data/ext/pg_query/include/nodes/print.h +0 -34
  696. data/ext/pg_query/include/nodes/queryjumble.h +0 -86
  697. data/ext/pg_query/include/nodes/replnodes.h +0 -111
  698. data/ext/pg_query/include/nodes/supportnodes.h +0 -346
  699. data/ext/pg_query/include/nodes/tidbitmap.h +0 -75
  700. data/ext/pg_query/include/nodes/value.h +0 -90
  701. data/ext/pg_query/include/optimizer/cost.h +0 -215
  702. data/ext/pg_query/include/optimizer/geqo.h +0 -90
  703. data/ext/pg_query/include/optimizer/geqo_gene.h +0 -45
  704. data/ext/pg_query/include/optimizer/optimizer.h +0 -202
  705. data/ext/pg_query/include/optimizer/paths.h +0 -266
  706. data/ext/pg_query/include/optimizer/planmain.h +0 -117
  707. data/ext/pg_query/include/parser/analyze.h +0 -64
  708. data/ext/pg_query/include/parser/kwlist.h +0 -498
  709. data/ext/pg_query/include/parser/parse_agg.h +0 -65
  710. data/ext/pg_query/include/parser/parse_coerce.h +0 -102
  711. data/ext/pg_query/include/parser/parse_expr.h +0 -25
  712. data/ext/pg_query/include/parser/parse_func.h +0 -74
  713. data/ext/pg_query/include/parser/parse_node.h +0 -357
  714. data/ext/pg_query/include/parser/parse_oper.h +0 -65
  715. data/ext/pg_query/include/parser/parse_relation.h +0 -129
  716. data/ext/pg_query/include/parser/parse_type.h +0 -61
  717. data/ext/pg_query/include/parser/parser.h +0 -68
  718. data/ext/pg_query/include/parser/parsetree.h +0 -61
  719. data/ext/pg_query/include/parser/scanner.h +0 -152
  720. data/ext/pg_query/include/parser/scansup.h +0 -27
  721. data/ext/pg_query/include/partitioning/partdefs.h +0 -26
  722. data/ext/pg_query/include/pg_config.h +0 -843
  723. data/ext/pg_query/include/pg_config_manual.h +0 -372
  724. data/ext/pg_query/include/pg_config_os.h +0 -8
  725. data/ext/pg_query/include/pg_getopt.h +0 -56
  726. data/ext/pg_query/include/pg_trace.h +0 -17
  727. data/ext/pg_query/include/pgstat.h +0 -778
  728. data/ext/pg_query/include/pgtime.h +0 -94
  729. data/ext/pg_query/include/pl_gram.h +0 -385
  730. data/ext/pg_query/include/pl_reserved_kwlist.h +0 -52
  731. data/ext/pg_query/include/pl_reserved_kwlist_d.h +0 -114
  732. data/ext/pg_query/include/pl_unreserved_kwlist.h +0 -112
  733. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +0 -246
  734. data/ext/pg_query/include/plerrcodes.h +0 -998
  735. data/ext/pg_query/include/plpgsql.h +0 -1340
  736. data/ext/pg_query/include/port/atomics/arch-arm.h +0 -32
  737. data/ext/pg_query/include/port/atomics/arch-ppc.h +0 -254
  738. data/ext/pg_query/include/port/atomics/arch-x86.h +0 -252
  739. data/ext/pg_query/include/port/atomics/fallback.h +0 -170
  740. data/ext/pg_query/include/port/atomics/generic-gcc.h +0 -286
  741. data/ext/pg_query/include/port/atomics/generic.h +0 -401
  742. data/ext/pg_query/include/port/atomics.h +0 -519
  743. data/ext/pg_query/include/port/pg_bitutils.h +0 -339
  744. data/ext/pg_query/include/port/pg_bswap.h +0 -161
  745. data/ext/pg_query/include/port/pg_crc32c.h +0 -101
  746. data/ext/pg_query/include/port/simd.h +0 -375
  747. data/ext/pg_query/include/port.h +0 -520
  748. data/ext/pg_query/include/portability/instr_time.h +0 -197
  749. data/ext/pg_query/include/postgres.h +0 -579
  750. data/ext/pg_query/include/postmaster/autovacuum.h +0 -80
  751. data/ext/pg_query/include/postmaster/auxprocess.h +0 -20
  752. data/ext/pg_query/include/postmaster/bgworker.h +0 -162
  753. data/ext/pg_query/include/postmaster/bgworker_internals.h +0 -64
  754. data/ext/pg_query/include/postmaster/bgwriter.h +0 -45
  755. data/ext/pg_query/include/postmaster/fork_process.h +0 -17
  756. data/ext/pg_query/include/postmaster/interrupt.h +0 -32
  757. data/ext/pg_query/include/postmaster/pgarch.h +0 -36
  758. data/ext/pg_query/include/postmaster/postmaster.h +0 -81
  759. data/ext/pg_query/include/postmaster/startup.h +0 -41
  760. data/ext/pg_query/include/postmaster/syslogger.h +0 -103
  761. data/ext/pg_query/include/postmaster/walwriter.h +0 -23
  762. data/ext/pg_query/include/regex/regex.h +0 -189
  763. data/ext/pg_query/include/replication/logicallauncher.h +0 -34
  764. data/ext/pg_query/include/replication/logicalproto.h +0 -274
  765. data/ext/pg_query/include/replication/logicalworker.h +0 -32
  766. data/ext/pg_query/include/replication/origin.h +0 -73
  767. data/ext/pg_query/include/replication/reorderbuffer.h +0 -753
  768. data/ext/pg_query/include/replication/slot.h +0 -249
  769. data/ext/pg_query/include/replication/syncrep.h +0 -109
  770. data/ext/pg_query/include/replication/walreceiver.h +0 -478
  771. data/ext/pg_query/include/replication/walsender.h +0 -74
  772. data/ext/pg_query/include/rewrite/prs2lock.h +0 -46
  773. data/ext/pg_query/include/rewrite/rewriteHandler.h +0 -35
  774. data/ext/pg_query/include/rewrite/rewriteManip.h +0 -96
  775. data/ext/pg_query/include/rewrite/rewriteSupport.h +0 -26
  776. data/ext/pg_query/include/src_backend_nodes_copyfuncs.funcs.c +0 -5321
  777. data/ext/pg_query/include/src_backend_nodes_equalfuncs.funcs.c +0 -3354
  778. data/ext/pg_query/include/storage/backendid.h +0 -37
  779. data/ext/pg_query/include/storage/block.h +0 -108
  780. data/ext/pg_query/include/storage/buf.h +0 -46
  781. data/ext/pg_query/include/storage/bufmgr.h +0 -393
  782. data/ext/pg_query/include/storage/bufpage.h +0 -510
  783. data/ext/pg_query/include/storage/condition_variable.h +0 -73
  784. data/ext/pg_query/include/storage/dsm.h +0 -61
  785. data/ext/pg_query/include/storage/dsm_impl.h +0 -79
  786. data/ext/pg_query/include/storage/fd.h +0 -202
  787. data/ext/pg_query/include/storage/fileset.h +0 -40
  788. data/ext/pg_query/include/storage/ipc.h +0 -84
  789. data/ext/pg_query/include/storage/item.h +0 -19
  790. data/ext/pg_query/include/storage/itemid.h +0 -184
  791. data/ext/pg_query/include/storage/itemptr.h +0 -245
  792. data/ext/pg_query/include/storage/large_object.h +0 -100
  793. data/ext/pg_query/include/storage/latch.h +0 -194
  794. data/ext/pg_query/include/storage/lmgr.h +0 -120
  795. data/ext/pg_query/include/storage/lock.h +0 -624
  796. data/ext/pg_query/include/storage/lockdefs.h +0 -59
  797. data/ext/pg_query/include/storage/lwlock.h +0 -220
  798. data/ext/pg_query/include/storage/lwlocknames.h +0 -50
  799. data/ext/pg_query/include/storage/off.h +0 -57
  800. data/ext/pg_query/include/storage/pg_sema.h +0 -61
  801. data/ext/pg_query/include/storage/pg_shmem.h +0 -92
  802. data/ext/pg_query/include/storage/pmsignal.h +0 -105
  803. data/ext/pg_query/include/storage/predicate.h +0 -87
  804. data/ext/pg_query/include/storage/proc.h +0 -466
  805. data/ext/pg_query/include/storage/procarray.h +0 -99
  806. data/ext/pg_query/include/storage/proclist_types.h +0 -51
  807. data/ext/pg_query/include/storage/procsignal.h +0 -73
  808. data/ext/pg_query/include/storage/relfilelocator.h +0 -99
  809. data/ext/pg_query/include/storage/s_lock.h +0 -867
  810. data/ext/pg_query/include/storage/sharedfileset.h +0 -37
  811. data/ext/pg_query/include/storage/shm_mq.h +0 -86
  812. data/ext/pg_query/include/storage/shm_toc.h +0 -58
  813. data/ext/pg_query/include/storage/shmem.h +0 -59
  814. data/ext/pg_query/include/storage/sinval.h +0 -153
  815. data/ext/pg_query/include/storage/sinvaladt.h +0 -45
  816. data/ext/pg_query/include/storage/smgr.h +0 -113
  817. data/ext/pg_query/include/storage/spin.h +0 -77
  818. data/ext/pg_query/include/storage/standby.h +0 -99
  819. data/ext/pg_query/include/storage/standbydefs.h +0 -74
  820. data/ext/pg_query/include/storage/sync.h +0 -66
  821. data/ext/pg_query/include/tcop/cmdtag.h +0 -63
  822. data/ext/pg_query/include/tcop/cmdtaglist.h +0 -218
  823. data/ext/pg_query/include/tcop/deparse_utility.h +0 -108
  824. data/ext/pg_query/include/tcop/dest.h +0 -147
  825. data/ext/pg_query/include/tcop/fastpath.h +0 -20
  826. data/ext/pg_query/include/tcop/pquery.h +0 -51
  827. data/ext/pg_query/include/tcop/tcopprot.h +0 -94
  828. data/ext/pg_query/include/tcop/utility.h +0 -112
  829. data/ext/pg_query/include/tsearch/ts_cache.h +0 -96
  830. data/ext/pg_query/include/utils/acl.h +0 -278
  831. data/ext/pg_query/include/utils/aclchk_internal.h +0 -45
  832. data/ext/pg_query/include/utils/array.h +0 -482
  833. data/ext/pg_query/include/utils/backend_progress.h +0 -45
  834. data/ext/pg_query/include/utils/backend_status.h +0 -342
  835. data/ext/pg_query/include/utils/builtins.h +0 -136
  836. data/ext/pg_query/include/utils/bytea.h +0 -28
  837. data/ext/pg_query/include/utils/catcache.h +0 -231
  838. data/ext/pg_query/include/utils/date.h +0 -118
  839. data/ext/pg_query/include/utils/datetime.h +0 -364
  840. data/ext/pg_query/include/utils/datum.h +0 -76
  841. data/ext/pg_query/include/utils/dsa.h +0 -127
  842. data/ext/pg_query/include/utils/elog.h +0 -545
  843. data/ext/pg_query/include/utils/errcodes.h +0 -354
  844. data/ext/pg_query/include/utils/expandeddatum.h +0 -170
  845. data/ext/pg_query/include/utils/expandedrecord.h +0 -241
  846. data/ext/pg_query/include/utils/float.h +0 -357
  847. data/ext/pg_query/include/utils/fmgroids.h +0 -3314
  848. data/ext/pg_query/include/utils/fmgrprotos.h +0 -2871
  849. data/ext/pg_query/include/utils/fmgrtab.h +0 -49
  850. data/ext/pg_query/include/utils/guc.h +0 -442
  851. data/ext/pg_query/include/utils/guc_hooks.h +0 -163
  852. data/ext/pg_query/include/utils/guc_tables.h +0 -322
  853. data/ext/pg_query/include/utils/hsearch.h +0 -153
  854. data/ext/pg_query/include/utils/inval.h +0 -68
  855. data/ext/pg_query/include/utils/logtape.h +0 -77
  856. data/ext/pg_query/include/utils/lsyscache.h +0 -212
  857. data/ext/pg_query/include/utils/memdebug.h +0 -82
  858. data/ext/pg_query/include/utils/memutils.h +0 -186
  859. data/ext/pg_query/include/utils/memutils_internal.h +0 -136
  860. data/ext/pg_query/include/utils/memutils_memorychunk.h +0 -237
  861. data/ext/pg_query/include/utils/numeric.h +0 -105
  862. data/ext/pg_query/include/utils/palloc.h +0 -165
  863. data/ext/pg_query/include/utils/partcache.h +0 -103
  864. data/ext/pg_query/include/utils/pg_locale.h +0 -135
  865. data/ext/pg_query/include/utils/pgstat_internal.h +0 -814
  866. data/ext/pg_query/include/utils/pidfile.h +0 -56
  867. data/ext/pg_query/include/utils/plancache.h +0 -236
  868. data/ext/pg_query/include/utils/portal.h +0 -252
  869. data/ext/pg_query/include/utils/queryenvironment.h +0 -74
  870. data/ext/pg_query/include/utils/regproc.h +0 -39
  871. data/ext/pg_query/include/utils/rel.h +0 -712
  872. data/ext/pg_query/include/utils/relcache.h +0 -158
  873. data/ext/pg_query/include/utils/reltrigger.h +0 -81
  874. data/ext/pg_query/include/utils/resowner.h +0 -86
  875. data/ext/pg_query/include/utils/ruleutils.h +0 -52
  876. data/ext/pg_query/include/utils/sharedtuplestore.h +0 -61
  877. data/ext/pg_query/include/utils/snapmgr.h +0 -181
  878. data/ext/pg_query/include/utils/snapshot.h +0 -219
  879. data/ext/pg_query/include/utils/sortsupport.h +0 -391
  880. data/ext/pg_query/include/utils/syscache.h +0 -227
  881. data/ext/pg_query/include/utils/timeout.h +0 -95
  882. data/ext/pg_query/include/utils/timestamp.h +0 -147
  883. data/ext/pg_query/include/utils/tuplesort.h +0 -445
  884. data/ext/pg_query/include/utils/tuplestore.h +0 -91
  885. data/ext/pg_query/include/utils/typcache.h +0 -209
  886. data/ext/pg_query/include/utils/varlena.h +0 -53
  887. data/ext/pg_query/include/utils/wait_event.h +0 -294
  888. data/ext/pg_query/include/utils/xml.h +0 -94
  889. data/ext/pg_query/include/varatt.h +0 -358
  890. data/ext/pg_query/src_backend_postmaster_postmaster.c +0 -2220
  891. data/ext/pg_query/src_port_strnlen.c +0 -39
  892. /data/ext/pg_query/include/{access → postgres/access}/rmgr.h +0 -0
  893. /data/ext/pg_query/include/{commands → postgres/commands}/user.h +0 -0
  894. /data/ext/pg_query/include/{common → postgres/common}/unicode_nonspacing_table.h +0 -0
  895. /data/ext/pg_query/include/{pg_config_ext.h → postgres/pg_config_ext.h} +0 -0
  896. /data/ext/pg_query/include/{postgres_ext.h → postgres/postgres_ext.h} +0 -0
  897. /data/ext/pg_query/include/{utils → postgres/utils}/probes.h +0 -0
  898. /data/ext/pg_query/include/{utils → postgres/utils}/ps_status.h +0 -0
@@ -0,0 +1,2109 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * tableam.h
4
+ * POSTGRES table access method definitions.
5
+ *
6
+ *
7
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8
+ * Portions Copyright (c) 1994, Regents of the University of California
9
+ *
10
+ * src/include/access/tableam.h
11
+ *
12
+ * NOTES
13
+ * See tableam.sgml for higher level documentation.
14
+ *
15
+ *-------------------------------------------------------------------------
16
+ */
17
+ #ifndef TABLEAM_H
18
+ #define TABLEAM_H
19
+
20
+ #include "access/relscan.h"
21
+ #include "access/sdir.h"
22
+ #include "access/xact.h"
23
+ #include "executor/tuptable.h"
24
+ #include "storage/read_stream.h"
25
+ #include "utils/rel.h"
26
+ #include "utils/snapshot.h"
27
+
28
+
29
+ #define DEFAULT_TABLE_ACCESS_METHOD "heap"
30
+
31
+ /* GUCs */
32
+ extern PGDLLIMPORT char *default_table_access_method;
33
+ extern PGDLLIMPORT bool synchronize_seqscans;
34
+
35
+
36
+ struct BulkInsertStateData;
37
+ struct IndexInfo;
38
+ struct SampleScanState;
39
+ struct TBMIterateResult;
40
+ struct VacuumParams;
41
+ struct ValidateIndexState;
42
+
43
+ /*
44
+ * Bitmask values for the flags argument to the scan_begin callback.
45
+ */
46
+ typedef enum ScanOptions
47
+ {
48
+ /* one of SO_TYPE_* may be specified */
49
+ SO_TYPE_SEQSCAN = 1 << 0,
50
+ SO_TYPE_BITMAPSCAN = 1 << 1,
51
+ SO_TYPE_SAMPLESCAN = 1 << 2,
52
+ SO_TYPE_TIDSCAN = 1 << 3,
53
+ SO_TYPE_TIDRANGESCAN = 1 << 4,
54
+ SO_TYPE_ANALYZE = 1 << 5,
55
+
56
+ /* several of SO_ALLOW_* may be specified */
57
+ /* allow or disallow use of access strategy */
58
+ SO_ALLOW_STRAT = 1 << 6,
59
+ /* report location to syncscan logic? */
60
+ SO_ALLOW_SYNC = 1 << 7,
61
+ /* verify visibility page-at-a-time? */
62
+ SO_ALLOW_PAGEMODE = 1 << 8,
63
+
64
+ /* unregister snapshot at scan end? */
65
+ SO_TEMP_SNAPSHOT = 1 << 9,
66
+
67
+ /*
68
+ * At the discretion of the table AM, bitmap table scans may be able to
69
+ * skip fetching a block from the table if none of the table data is
70
+ * needed. If table data may be needed, set SO_NEED_TUPLES.
71
+ */
72
+ SO_NEED_TUPLES = 1 << 10,
73
+ } ScanOptions;
74
+
75
+ /*
76
+ * Result codes for table_{update,delete,lock_tuple}, and for visibility
77
+ * routines inside table AMs.
78
+ */
79
+ typedef enum TM_Result
80
+ {
81
+ /*
82
+ * Signals that the action succeeded (i.e. update/delete performed, lock
83
+ * was acquired)
84
+ */
85
+ TM_Ok,
86
+
87
+ /* The affected tuple wasn't visible to the relevant snapshot */
88
+ TM_Invisible,
89
+
90
+ /* The affected tuple was already modified by the calling backend */
91
+ TM_SelfModified,
92
+
93
+ /*
94
+ * The affected tuple was updated by another transaction. This includes
95
+ * the case where tuple was moved to another partition.
96
+ */
97
+ TM_Updated,
98
+
99
+ /* The affected tuple was deleted by another transaction */
100
+ TM_Deleted,
101
+
102
+ /*
103
+ * The affected tuple is currently being modified by another session. This
104
+ * will only be returned if table_(update/delete/lock_tuple) are
105
+ * instructed not to wait.
106
+ */
107
+ TM_BeingModified,
108
+
109
+ /* lock couldn't be acquired, action skipped. Only used by lock_tuple */
110
+ TM_WouldBlock,
111
+ } TM_Result;
112
+
113
+ /*
114
+ * Result codes for table_update(..., update_indexes*..).
115
+ * Used to determine which indexes to update.
116
+ */
117
+ typedef enum TU_UpdateIndexes
118
+ {
119
+ /* No indexed columns were updated (incl. TID addressing of tuple) */
120
+ TU_None,
121
+
122
+ /* A non-summarizing indexed column was updated, or the TID has changed */
123
+ TU_All,
124
+
125
+ /* Only summarized columns were updated, TID is unchanged */
126
+ TU_Summarizing,
127
+ } TU_UpdateIndexes;
128
+
129
+ /*
130
+ * When table_tuple_update, table_tuple_delete, or table_tuple_lock fail
131
+ * because the target tuple is already outdated, they fill in this struct to
132
+ * provide information to the caller about what happened.
133
+ *
134
+ * ctid is the target's ctid link: it is the same as the target's TID if the
135
+ * target was deleted, or the location of the replacement tuple if the target
136
+ * was updated.
137
+ *
138
+ * xmax is the outdating transaction's XID. If the caller wants to visit the
139
+ * replacement tuple, it must check that this matches before believing the
140
+ * replacement is really a match.
141
+ *
142
+ * cmax is the outdating command's CID, but only when the failure code is
143
+ * TM_SelfModified (i.e., something in the current transaction outdated the
144
+ * tuple); otherwise cmax is zero. (We make this restriction because
145
+ * HeapTupleHeaderGetCmax doesn't work for tuples outdated in other
146
+ * transactions.)
147
+ */
148
+ typedef struct TM_FailureData
149
+ {
150
+ ItemPointerData ctid;
151
+ TransactionId xmax;
152
+ CommandId cmax;
153
+ bool traversed;
154
+ } TM_FailureData;
155
+
156
+ /*
157
+ * State used when calling table_index_delete_tuples().
158
+ *
159
+ * Represents the status of table tuples, referenced by table TID and taken by
160
+ * index AM from index tuples. State consists of high level parameters of the
161
+ * deletion operation, plus two mutable palloc()'d arrays for information
162
+ * about the status of individual table tuples. These are conceptually one
163
+ * single array. Using two arrays keeps the TM_IndexDelete struct small,
164
+ * which makes sorting the first array (the deltids array) fast.
165
+ *
166
+ * Some index AM callers perform simple index tuple deletion (by specifying
167
+ * bottomup = false), and include only known-dead deltids. These known-dead
168
+ * entries are all marked knowndeletable = true directly (typically these are
169
+ * TIDs from LP_DEAD-marked index tuples), but that isn't strictly required.
170
+ *
171
+ * Callers that specify bottomup = true are "bottom-up index deletion"
172
+ * callers. The considerations for the tableam are more subtle with these
173
+ * callers because they ask the tableam to perform highly speculative work,
174
+ * and might only expect the tableam to check a small fraction of all entries.
175
+ * Caller is not allowed to specify knowndeletable = true for any entry
176
+ * because everything is highly speculative. Bottom-up caller provides
177
+ * context and hints to tableam -- see comments below for details on how index
178
+ * AMs and tableams should coordinate during bottom-up index deletion.
179
+ *
180
+ * Simple index deletion callers may ask the tableam to perform speculative
181
+ * work, too. This is a little like bottom-up deletion, but not too much.
182
+ * The tableam will only perform speculative work when it's practically free
183
+ * to do so in passing for simple deletion caller (while always performing
184
+ * whatever work is needed to enable knowndeletable/LP_DEAD index tuples to
185
+ * be deleted within index AM). This is the real reason why it's possible for
186
+ * simple index deletion caller to specify knowndeletable = false up front
187
+ * (this means "check if it's possible for me to delete corresponding index
188
+ * tuple when it's cheap to do so in passing"). The index AM should only
189
+ * include "extra" entries for index tuples whose TIDs point to a table block
190
+ * that tableam is expected to have to visit anyway (in the event of a block
191
+ * orientated tableam). The tableam isn't strictly obligated to check these
192
+ * "extra" TIDs, but a block-based AM should always manage to do so in
193
+ * practice.
194
+ *
195
+ * The final contents of the deltids/status arrays are interesting to callers
196
+ * that ask tableam to perform speculative work (i.e. when _any_ items have
197
+ * knowndeletable set to false up front). These index AM callers will
198
+ * naturally need to consult final state to determine which index tuples are
199
+ * in fact deletable.
200
+ *
201
+ * The index AM can keep track of which index tuple relates to which deltid by
202
+ * setting idxoffnum (and/or relying on each entry being uniquely identifiable
203
+ * using tid), which is important when the final contents of the array will
204
+ * need to be interpreted -- the array can shrink from initial size after
205
+ * tableam processing and/or have entries in a new order (tableam may sort
206
+ * deltids array for its own reasons). Bottom-up callers may find that final
207
+ * ndeltids is 0 on return from call to tableam, in which case no index tuple
208
+ * deletions are possible. Simple deletion callers can rely on any entries
209
+ * they know to be deletable appearing in the final array as deletable.
210
+ */
211
+ typedef struct TM_IndexDelete
212
+ {
213
+ ItemPointerData tid; /* table TID from index tuple */
214
+ int16 id; /* Offset into TM_IndexStatus array */
215
+ } TM_IndexDelete;
216
+
217
+ typedef struct TM_IndexStatus
218
+ {
219
+ OffsetNumber idxoffnum; /* Index am page offset number */
220
+ bool knowndeletable; /* Currently known to be deletable? */
221
+
222
+ /* Bottom-up index deletion specific fields follow */
223
+ bool promising; /* Promising (duplicate) index tuple? */
224
+ int16 freespace; /* Space freed in index if deleted */
225
+ } TM_IndexStatus;
226
+
227
+ /*
228
+ * Index AM/tableam coordination is central to the design of bottom-up index
229
+ * deletion. The index AM provides hints about where to look to the tableam
230
+ * by marking some entries as "promising". Index AM does this with duplicate
231
+ * index tuples that are strongly suspected to be old versions left behind by
232
+ * UPDATEs that did not logically modify indexed values. Index AM may find it
233
+ * helpful to only mark entries as promising when they're thought to have been
234
+ * affected by such an UPDATE in the recent past.
235
+ *
236
+ * Bottom-up index deletion casts a wide net at first, usually by including
237
+ * all TIDs on a target index page. It is up to the tableam to worry about
238
+ * the cost of checking transaction status information. The tableam is in
239
+ * control, but needs careful guidance from the index AM. Index AM requests
240
+ * that bottomupfreespace target be met, while tableam measures progress
241
+ * towards that goal by tallying the per-entry freespace value for known
242
+ * deletable entries. (All !bottomup callers can just set these space related
243
+ * fields to zero.)
244
+ */
245
+ typedef struct TM_IndexDeleteOp
246
+ {
247
+ Relation irel; /* Target index relation */
248
+ BlockNumber iblknum; /* Index block number (for error reports) */
249
+ bool bottomup; /* Bottom-up (not simple) deletion? */
250
+ int bottomupfreespace; /* Bottom-up space target */
251
+
252
+ /* Mutable per-TID information follows (index AM initializes entries) */
253
+ int ndeltids; /* Current # of deltids/status elements */
254
+ TM_IndexDelete *deltids;
255
+ TM_IndexStatus *status;
256
+ } TM_IndexDeleteOp;
257
+
258
+ /* "options" flag bits for table_tuple_insert */
259
+ /* TABLE_INSERT_SKIP_WAL was 0x0001; RelationNeedsWAL() now governs */
260
+ #define TABLE_INSERT_SKIP_FSM 0x0002
261
+ #define TABLE_INSERT_FROZEN 0x0004
262
+ #define TABLE_INSERT_NO_LOGICAL 0x0008
263
+
264
+ /* flag bits for table_tuple_lock */
265
+ /* Follow tuples whose update is in progress if lock modes don't conflict */
266
+ #define TUPLE_LOCK_FLAG_LOCK_UPDATE_IN_PROGRESS (1 << 0)
267
+ /* Follow update chain and lock latest version of tuple */
268
+ #define TUPLE_LOCK_FLAG_FIND_LAST_VERSION (1 << 1)
269
+
270
+
271
+ /* Typedef for callback function for table_index_build_scan */
272
+ typedef void (*IndexBuildCallback) (Relation index,
273
+ ItemPointer tid,
274
+ Datum *values,
275
+ bool *isnull,
276
+ bool tupleIsAlive,
277
+ void *state);
278
+
279
+ /*
280
+ * API struct for a table AM. Note this must be allocated in a
281
+ * server-lifetime manner, typically as a static const struct, which then gets
282
+ * returned by FormData_pg_am.amhandler.
283
+ *
284
+ * In most cases it's not appropriate to call the callbacks directly, use the
285
+ * table_* wrapper functions instead.
286
+ *
287
+ * GetTableAmRoutine() asserts that required callbacks are filled in, remember
288
+ * to update when adding a callback.
289
+ */
290
+ typedef struct TableAmRoutine
291
+ {
292
+ /* this must be set to T_TableAmRoutine */
293
+ NodeTag type;
294
+
295
+
296
+ /* ------------------------------------------------------------------------
297
+ * Slot related callbacks.
298
+ * ------------------------------------------------------------------------
299
+ */
300
+
301
+ /*
302
+ * Return slot implementation suitable for storing a tuple of this AM.
303
+ */
304
+ const TupleTableSlotOps *(*slot_callbacks) (Relation rel);
305
+
306
+
307
+ /* ------------------------------------------------------------------------
308
+ * Table scan callbacks.
309
+ * ------------------------------------------------------------------------
310
+ */
311
+
312
+ /*
313
+ * Start a scan of `rel`. The callback has to return a TableScanDesc,
314
+ * which will typically be embedded in a larger, AM specific, struct.
315
+ *
316
+ * If nkeys != 0, the results need to be filtered by those scan keys.
317
+ *
318
+ * pscan, if not NULL, will have already been initialized with
319
+ * parallelscan_initialize(), and has to be for the same relation. Will
320
+ * only be set coming from table_beginscan_parallel().
321
+ *
322
+ * `flags` is a bitmask indicating the type of scan (ScanOptions's
323
+ * SO_TYPE_*, currently only one may be specified), options controlling
324
+ * the scan's behaviour (ScanOptions's SO_ALLOW_*, several may be
325
+ * specified, an AM may ignore unsupported ones) and whether the snapshot
326
+ * needs to be deallocated at scan_end (ScanOptions's SO_TEMP_SNAPSHOT).
327
+ */
328
+ TableScanDesc (*scan_begin) (Relation rel,
329
+ Snapshot snapshot,
330
+ int nkeys, struct ScanKeyData *key,
331
+ ParallelTableScanDesc pscan,
332
+ uint32 flags);
333
+
334
+ /*
335
+ * Release resources and deallocate scan. If TableScanDesc.temp_snap,
336
+ * TableScanDesc.rs_snapshot needs to be unregistered.
337
+ */
338
+ void (*scan_end) (TableScanDesc scan);
339
+
340
+ /*
341
+ * Restart relation scan. If set_params is set to true, allow_{strat,
342
+ * sync, pagemode} (see scan_begin) changes should be taken into account.
343
+ */
344
+ void (*scan_rescan) (TableScanDesc scan, struct ScanKeyData *key,
345
+ bool set_params, bool allow_strat,
346
+ bool allow_sync, bool allow_pagemode);
347
+
348
+ /*
349
+ * Return next tuple from `scan`, store in slot.
350
+ */
351
+ bool (*scan_getnextslot) (TableScanDesc scan,
352
+ ScanDirection direction,
353
+ TupleTableSlot *slot);
354
+
355
+ /*-----------
356
+ * Optional functions to provide scanning for ranges of ItemPointers.
357
+ * Implementations must either provide both of these functions, or neither
358
+ * of them.
359
+ *
360
+ * Implementations of scan_set_tidrange must themselves handle
361
+ * ItemPointers of any value. i.e, they must handle each of the following:
362
+ *
363
+ * 1) mintid or maxtid is beyond the end of the table; and
364
+ * 2) mintid is above maxtid; and
365
+ * 3) item offset for mintid or maxtid is beyond the maximum offset
366
+ * allowed by the AM.
367
+ *
368
+ * Implementations can assume that scan_set_tidrange is always called
369
+ * before scan_getnextslot_tidrange or after scan_rescan and before any
370
+ * further calls to scan_getnextslot_tidrange.
371
+ */
372
+ void (*scan_set_tidrange) (TableScanDesc scan,
373
+ ItemPointer mintid,
374
+ ItemPointer maxtid);
375
+
376
+ /*
377
+ * Return next tuple from `scan` that's in the range of TIDs defined by
378
+ * scan_set_tidrange.
379
+ */
380
+ bool (*scan_getnextslot_tidrange) (TableScanDesc scan,
381
+ ScanDirection direction,
382
+ TupleTableSlot *slot);
383
+
384
+ /* ------------------------------------------------------------------------
385
+ * Parallel table scan related functions.
386
+ * ------------------------------------------------------------------------
387
+ */
388
+
389
+ /*
390
+ * Estimate the size of shared memory needed for a parallel scan of this
391
+ * relation. The snapshot does not need to be accounted for.
392
+ */
393
+ Size (*parallelscan_estimate) (Relation rel);
394
+
395
+ /*
396
+ * Initialize ParallelTableScanDesc for a parallel scan of this relation.
397
+ * `pscan` will be sized according to parallelscan_estimate() for the same
398
+ * relation.
399
+ */
400
+ Size (*parallelscan_initialize) (Relation rel,
401
+ ParallelTableScanDesc pscan);
402
+
403
+ /*
404
+ * Reinitialize `pscan` for a new scan. `rel` will be the same relation as
405
+ * when `pscan` was initialized by parallelscan_initialize.
406
+ */
407
+ void (*parallelscan_reinitialize) (Relation rel,
408
+ ParallelTableScanDesc pscan);
409
+
410
+
411
+ /* ------------------------------------------------------------------------
412
+ * Index Scan Callbacks
413
+ * ------------------------------------------------------------------------
414
+ */
415
+
416
+ /*
417
+ * Prepare to fetch tuples from the relation, as needed when fetching
418
+ * tuples for an index scan. The callback has to return an
419
+ * IndexFetchTableData, which the AM will typically embed in a larger
420
+ * structure with additional information.
421
+ *
422
+ * Tuples for an index scan can then be fetched via index_fetch_tuple.
423
+ */
424
+ struct IndexFetchTableData *(*index_fetch_begin) (Relation rel);
425
+
426
+ /*
427
+ * Reset index fetch. Typically this will release cross index fetch
428
+ * resources held in IndexFetchTableData.
429
+ */
430
+ void (*index_fetch_reset) (struct IndexFetchTableData *data);
431
+
432
+ /*
433
+ * Release resources and deallocate index fetch.
434
+ */
435
+ void (*index_fetch_end) (struct IndexFetchTableData *data);
436
+
437
+ /*
438
+ * Fetch tuple at `tid` into `slot`, after doing a visibility test
439
+ * according to `snapshot`. If a tuple was found and passed the visibility
440
+ * test, return true, false otherwise.
441
+ *
442
+ * Note that AMs that do not necessarily update indexes when indexed
443
+ * columns do not change, need to return the current/correct version of
444
+ * the tuple that is visible to the snapshot, even if the tid points to an
445
+ * older version of the tuple.
446
+ *
447
+ * *call_again is false on the first call to index_fetch_tuple for a tid.
448
+ * If there potentially is another tuple matching the tid, *call_again
449
+ * needs to be set to true by index_fetch_tuple, signaling to the caller
450
+ * that index_fetch_tuple should be called again for the same tid.
451
+ *
452
+ * *all_dead, if all_dead is not NULL, should be set to true by
453
+ * index_fetch_tuple iff it is guaranteed that no backend needs to see
454
+ * that tuple. Index AMs can use that to avoid returning that tid in
455
+ * future searches.
456
+ */
457
+ bool (*index_fetch_tuple) (struct IndexFetchTableData *scan,
458
+ ItemPointer tid,
459
+ Snapshot snapshot,
460
+ TupleTableSlot *slot,
461
+ bool *call_again, bool *all_dead);
462
+
463
+
464
+ /* ------------------------------------------------------------------------
465
+ * Callbacks for non-modifying operations on individual tuples
466
+ * ------------------------------------------------------------------------
467
+ */
468
+
469
+ /*
470
+ * Fetch tuple at `tid` into `slot`, after doing a visibility test
471
+ * according to `snapshot`. If a tuple was found and passed the visibility
472
+ * test, returns true, false otherwise.
473
+ */
474
+ bool (*tuple_fetch_row_version) (Relation rel,
475
+ ItemPointer tid,
476
+ Snapshot snapshot,
477
+ TupleTableSlot *slot);
478
+
479
+ /*
480
+ * Is tid valid for a scan of this relation.
481
+ */
482
+ bool (*tuple_tid_valid) (TableScanDesc scan,
483
+ ItemPointer tid);
484
+
485
+ /*
486
+ * Return the latest version of the tuple at `tid`, by updating `tid` to
487
+ * point at the newest version.
488
+ */
489
+ void (*tuple_get_latest_tid) (TableScanDesc scan,
490
+ ItemPointer tid);
491
+
492
+ /*
493
+ * Does the tuple in `slot` satisfy `snapshot`? The slot needs to be of
494
+ * the appropriate type for the AM.
495
+ */
496
+ bool (*tuple_satisfies_snapshot) (Relation rel,
497
+ TupleTableSlot *slot,
498
+ Snapshot snapshot);
499
+
500
+ /* see table_index_delete_tuples() */
501
+ TransactionId (*index_delete_tuples) (Relation rel,
502
+ TM_IndexDeleteOp *delstate);
503
+
504
+
505
+ /* ------------------------------------------------------------------------
506
+ * Manipulations of physical tuples.
507
+ * ------------------------------------------------------------------------
508
+ */
509
+
510
+ /* see table_tuple_insert() for reference about parameters */
511
+ void (*tuple_insert) (Relation rel, TupleTableSlot *slot,
512
+ CommandId cid, int options,
513
+ struct BulkInsertStateData *bistate);
514
+
515
+ /* see table_tuple_insert_speculative() for reference about parameters */
516
+ void (*tuple_insert_speculative) (Relation rel,
517
+ TupleTableSlot *slot,
518
+ CommandId cid,
519
+ int options,
520
+ struct BulkInsertStateData *bistate,
521
+ uint32 specToken);
522
+
523
+ /* see table_tuple_complete_speculative() for reference about parameters */
524
+ void (*tuple_complete_speculative) (Relation rel,
525
+ TupleTableSlot *slot,
526
+ uint32 specToken,
527
+ bool succeeded);
528
+
529
+ /* see table_multi_insert() for reference about parameters */
530
+ void (*multi_insert) (Relation rel, TupleTableSlot **slots, int nslots,
531
+ CommandId cid, int options, struct BulkInsertStateData *bistate);
532
+
533
+ /* see table_tuple_delete() for reference about parameters */
534
+ TM_Result (*tuple_delete) (Relation rel,
535
+ ItemPointer tid,
536
+ CommandId cid,
537
+ Snapshot snapshot,
538
+ Snapshot crosscheck,
539
+ bool wait,
540
+ TM_FailureData *tmfd,
541
+ bool changingPart);
542
+
543
+ /* see table_tuple_update() for reference about parameters */
544
+ TM_Result (*tuple_update) (Relation rel,
545
+ ItemPointer otid,
546
+ TupleTableSlot *slot,
547
+ CommandId cid,
548
+ Snapshot snapshot,
549
+ Snapshot crosscheck,
550
+ bool wait,
551
+ TM_FailureData *tmfd,
552
+ LockTupleMode *lockmode,
553
+ TU_UpdateIndexes *update_indexes);
554
+
555
+ /* see table_tuple_lock() for reference about parameters */
556
+ TM_Result (*tuple_lock) (Relation rel,
557
+ ItemPointer tid,
558
+ Snapshot snapshot,
559
+ TupleTableSlot *slot,
560
+ CommandId cid,
561
+ LockTupleMode mode,
562
+ LockWaitPolicy wait_policy,
563
+ uint8 flags,
564
+ TM_FailureData *tmfd);
565
+
566
+ /*
567
+ * Perform operations necessary to complete insertions made via
568
+ * tuple_insert and multi_insert with a BulkInsertState specified. In-tree
569
+ * access methods ceased to use this.
570
+ *
571
+ * Typically callers of tuple_insert and multi_insert will just pass all
572
+ * the flags that apply to them, and each AM has to decide which of them
573
+ * make sense for it, and then only take actions in finish_bulk_insert for
574
+ * those flags, and ignore others.
575
+ *
576
+ * Optional callback.
577
+ */
578
+ void (*finish_bulk_insert) (Relation rel, int options);
579
+
580
+
581
+ /* ------------------------------------------------------------------------
582
+ * DDL related functionality.
583
+ * ------------------------------------------------------------------------
584
+ */
585
+
586
+ /*
587
+ * This callback needs to create new relation storage for `rel`, with
588
+ * appropriate durability behaviour for `persistence`.
589
+ *
590
+ * Note that only the subset of the relcache filled by
591
+ * RelationBuildLocalRelation() can be relied upon and that the relation's
592
+ * catalog entries will either not yet exist (new relation), or will still
593
+ * reference the old relfilelocator.
594
+ *
595
+ * As output *freezeXid, *minmulti must be set to the values appropriate
596
+ * for pg_class.{relfrozenxid, relminmxid}. For AMs that don't need those
597
+ * fields to be filled they can be set to InvalidTransactionId and
598
+ * InvalidMultiXactId, respectively.
599
+ *
600
+ * See also table_relation_set_new_filelocator().
601
+ */
602
+ void (*relation_set_new_filelocator) (Relation rel,
603
+ const RelFileLocator *newrlocator,
604
+ char persistence,
605
+ TransactionId *freezeXid,
606
+ MultiXactId *minmulti);
607
+
608
+ /*
609
+ * This callback needs to remove all contents from `rel`'s current
610
+ * relfilelocator. No provisions for transactional behaviour need to be
611
+ * made. Often this can be implemented by truncating the underlying
612
+ * storage to its minimal size.
613
+ *
614
+ * See also table_relation_nontransactional_truncate().
615
+ */
616
+ void (*relation_nontransactional_truncate) (Relation rel);
617
+
618
+ /*
619
+ * See table_relation_copy_data().
620
+ *
621
+ * This can typically be implemented by directly copying the underlying
622
+ * storage, unless it contains references to the tablespace internally.
623
+ */
624
+ void (*relation_copy_data) (Relation rel,
625
+ const RelFileLocator *newrlocator);
626
+
627
+ /* See table_relation_copy_for_cluster() */
628
+ void (*relation_copy_for_cluster) (Relation OldTable,
629
+ Relation NewTable,
630
+ Relation OldIndex,
631
+ bool use_sort,
632
+ TransactionId OldestXmin,
633
+ TransactionId *xid_cutoff,
634
+ MultiXactId *multi_cutoff,
635
+ double *num_tuples,
636
+ double *tups_vacuumed,
637
+ double *tups_recently_dead);
638
+
639
+ /*
640
+ * React to VACUUM command on the relation. The VACUUM can be triggered by
641
+ * a user or by autovacuum. The specific actions performed by the AM will
642
+ * depend heavily on the individual AM.
643
+ *
644
+ * On entry a transaction is already established, and the relation is
645
+ * locked with a ShareUpdateExclusive lock.
646
+ *
647
+ * Note that neither VACUUM FULL (and CLUSTER), nor ANALYZE go through
648
+ * this routine, even if (for ANALYZE) it is part of the same VACUUM
649
+ * command.
650
+ *
651
+ * There probably, in the future, needs to be a separate callback to
652
+ * integrate with autovacuum's scheduling.
653
+ */
654
+ void (*relation_vacuum) (Relation rel,
655
+ struct VacuumParams *params,
656
+ BufferAccessStrategy bstrategy);
657
+
658
+ /*
659
+ * Prepare to analyze block `blockno` of `scan`. The scan has been started
660
+ * with table_beginscan_analyze(). See also
661
+ * table_scan_analyze_next_block().
662
+ *
663
+ * The callback may acquire resources like locks that are held until
664
+ * table_scan_analyze_next_tuple() returns false. It e.g. can make sense
665
+ * to hold a lock until all tuples on a block have been analyzed by
666
+ * scan_analyze_next_tuple.
667
+ *
668
+ * The callback can return false if the block is not suitable for
669
+ * sampling, e.g. because it's a metapage that could never contain tuples.
670
+ *
671
+ * XXX: This obviously is primarily suited for block-based AMs. It's not
672
+ * clear what a good interface for non block based AMs would be, so there
673
+ * isn't one yet.
674
+ */
675
+ bool (*scan_analyze_next_block) (TableScanDesc scan,
676
+ ReadStream *stream);
677
+
678
+ /*
679
+ * See table_scan_analyze_next_tuple().
680
+ *
681
+ * Not every AM might have a meaningful concept of dead rows, in which
682
+ * case it's OK to not increment *deadrows - but note that that may
683
+ * influence autovacuum scheduling (see comment for relation_vacuum
684
+ * callback).
685
+ */
686
+ bool (*scan_analyze_next_tuple) (TableScanDesc scan,
687
+ TransactionId OldestXmin,
688
+ double *liverows,
689
+ double *deadrows,
690
+ TupleTableSlot *slot);
691
+
692
+ /* see table_index_build_range_scan for reference about parameters */
693
+ double (*index_build_range_scan) (Relation table_rel,
694
+ Relation index_rel,
695
+ struct IndexInfo *index_info,
696
+ bool allow_sync,
697
+ bool anyvisible,
698
+ bool progress,
699
+ BlockNumber start_blockno,
700
+ BlockNumber numblocks,
701
+ IndexBuildCallback callback,
702
+ void *callback_state,
703
+ TableScanDesc scan);
704
+
705
+ /* see table_index_validate_scan for reference about parameters */
706
+ void (*index_validate_scan) (Relation table_rel,
707
+ Relation index_rel,
708
+ struct IndexInfo *index_info,
709
+ Snapshot snapshot,
710
+ struct ValidateIndexState *state);
711
+
712
+
713
+ /* ------------------------------------------------------------------------
714
+ * Miscellaneous functions.
715
+ * ------------------------------------------------------------------------
716
+ */
717
+
718
+ /*
719
+ * See table_relation_size().
720
+ *
721
+ * Note that currently a few callers use the MAIN_FORKNUM size to figure
722
+ * out the range of potentially interesting blocks (brin, analyze). It's
723
+ * probable that we'll need to revise the interface for those at some
724
+ * point.
725
+ */
726
+ uint64 (*relation_size) (Relation rel, ForkNumber forkNumber);
727
+
728
+
729
+ /*
730
+ * This callback should return true if the relation requires a TOAST table
731
+ * and false if it does not. It may wish to examine the relation's tuple
732
+ * descriptor before making a decision, but if it uses some other method
733
+ * of storing large values (or if it does not support them) it can simply
734
+ * return false.
735
+ */
736
+ bool (*relation_needs_toast_table) (Relation rel);
737
+
738
+ /*
739
+ * This callback should return the OID of the table AM that implements
740
+ * TOAST tables for this AM. If the relation_needs_toast_table callback
741
+ * always returns false, this callback is not required.
742
+ */
743
+ Oid (*relation_toast_am) (Relation rel);
744
+
745
+ /*
746
+ * This callback is invoked when detoasting a value stored in a toast
747
+ * table implemented by this AM. See table_relation_fetch_toast_slice()
748
+ * for more details.
749
+ */
750
+ void (*relation_fetch_toast_slice) (Relation toastrel, Oid valueid,
751
+ int32 attrsize,
752
+ int32 sliceoffset,
753
+ int32 slicelength,
754
+ struct varlena *result);
755
+
756
+
757
+ /* ------------------------------------------------------------------------
758
+ * Planner related functions.
759
+ * ------------------------------------------------------------------------
760
+ */
761
+
762
+ /*
763
+ * See table_relation_estimate_size().
764
+ *
765
+ * While block oriented, it shouldn't be too hard for an AM that doesn't
766
+ * internally use blocks to convert into a usable representation.
767
+ *
768
+ * This differs from the relation_size callback by returning size
769
+ * estimates (both relation size and tuple count) for planning purposes,
770
+ * rather than returning a currently correct estimate.
771
+ */
772
+ void (*relation_estimate_size) (Relation rel, int32 *attr_widths,
773
+ BlockNumber *pages, double *tuples,
774
+ double *allvisfrac);
775
+
776
+
777
+ /* ------------------------------------------------------------------------
778
+ * Executor related functions.
779
+ * ------------------------------------------------------------------------
780
+ */
781
+
782
+ /*
783
+ * Prepare to fetch / check / return tuples from `tbmres->blockno` as part
784
+ * of a bitmap table scan. `scan` was started via table_beginscan_bm().
785
+ * Return false if there are no tuples to be found on the page, true
786
+ * otherwise.
787
+ *
788
+ * This will typically read and pin the target block, and do the necessary
789
+ * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might
790
+ * make sense to perform tuple visibility checks at this time). For some
791
+ * AMs it will make more sense to do all the work referencing `tbmres`
792
+ * contents here, for others it might be better to defer more work to
793
+ * scan_bitmap_next_tuple.
794
+ *
795
+ * If `tbmres->blockno` is -1, this is a lossy scan and all visible tuples
796
+ * on the page have to be returned, otherwise the tuples at offsets in
797
+ * `tbmres->offsets` need to be returned.
798
+ *
799
+ * XXX: Currently this may only be implemented if the AM uses md.c as its
800
+ * storage manager, and uses ItemPointer->ip_blkid in a manner that maps
801
+ * blockids directly to the underlying storage. nodeBitmapHeapscan.c
802
+ * performs prefetching directly using that interface. This probably
803
+ * needs to be rectified at a later point.
804
+ *
805
+ * XXX: Currently this may only be implemented if the AM uses the
806
+ * visibilitymap, as nodeBitmapHeapscan.c unconditionally accesses it to
807
+ * perform prefetching. This probably needs to be rectified at a later
808
+ * point.
809
+ *
810
+ * Optional callback, but either both scan_bitmap_next_block and
811
+ * scan_bitmap_next_tuple need to exist, or neither.
812
+ */
813
+ bool (*scan_bitmap_next_block) (TableScanDesc scan,
814
+ struct TBMIterateResult *tbmres);
815
+
816
+ /*
817
+ * Fetch the next tuple of a bitmap table scan into `slot` and return true
818
+ * if a visible tuple was found, false otherwise.
819
+ *
820
+ * For some AMs it will make more sense to do all the work referencing
821
+ * `tbmres` contents in scan_bitmap_next_block, for others it might be
822
+ * better to defer more work to this callback.
823
+ *
824
+ * Optional callback, but either both scan_bitmap_next_block and
825
+ * scan_bitmap_next_tuple need to exist, or neither.
826
+ */
827
+ bool (*scan_bitmap_next_tuple) (TableScanDesc scan,
828
+ struct TBMIterateResult *tbmres,
829
+ TupleTableSlot *slot);
830
+
831
+ /*
832
+ * Prepare to fetch tuples from the next block in a sample scan. Return
833
+ * false if the sample scan is finished, true otherwise. `scan` was
834
+ * started via table_beginscan_sampling().
835
+ *
836
+ * Typically this will first determine the target block by calling the
837
+ * TsmRoutine's NextSampleBlock() callback if not NULL, or alternatively
838
+ * perform a sequential scan over all blocks. The determined block is
839
+ * then typically read and pinned.
840
+ *
841
+ * As the TsmRoutine interface is block based, a block needs to be passed
842
+ * to NextSampleBlock(). If that's not appropriate for an AM, it
843
+ * internally needs to perform mapping between the internal and a block
844
+ * based representation.
845
+ *
846
+ * Note that it's not acceptable to hold deadlock prone resources such as
847
+ * lwlocks until scan_sample_next_tuple() has exhausted the tuples on the
848
+ * block - the tuple is likely to be returned to an upper query node, and
849
+ * the next call could be off a long while. Holding buffer pins and such
850
+ * is obviously OK.
851
+ *
852
+ * Currently it is required to implement this interface, as there's no
853
+ * alternative way (contrary e.g. to bitmap scans) to implement sample
854
+ * scans. If infeasible to implement, the AM may raise an error.
855
+ */
856
+ bool (*scan_sample_next_block) (TableScanDesc scan,
857
+ struct SampleScanState *scanstate);
858
+
859
+ /*
860
+ * This callback, only called after scan_sample_next_block has returned
861
+ * true, should determine the next tuple to be returned from the selected
862
+ * block using the TsmRoutine's NextSampleTuple() callback.
863
+ *
864
+ * The callback needs to perform visibility checks, and only return
865
+ * visible tuples. That obviously can mean calling NextSampleTuple()
866
+ * multiple times.
867
+ *
868
+ * The TsmRoutine interface assumes that there's a maximum offset on a
869
+ * given page, so if that doesn't apply to an AM, it needs to emulate that
870
+ * assumption somehow.
871
+ */
872
+ bool (*scan_sample_next_tuple) (TableScanDesc scan,
873
+ struct SampleScanState *scanstate,
874
+ TupleTableSlot *slot);
875
+
876
+ } TableAmRoutine;
877
+
878
+
879
+ /* ----------------------------------------------------------------------------
880
+ * Slot functions.
881
+ * ----------------------------------------------------------------------------
882
+ */
883
+
884
+ /*
885
+ * Returns slot callbacks suitable for holding tuples of the appropriate type
886
+ * for the relation. Works for tables, views, foreign tables and partitioned
887
+ * tables.
888
+ */
889
+ extern const TupleTableSlotOps *table_slot_callbacks(Relation relation);
890
+
891
+ /*
892
+ * Returns slot using the callbacks returned by table_slot_callbacks(), and
893
+ * registers it on *reglist.
894
+ */
895
+ extern TupleTableSlot *table_slot_create(Relation relation, List **reglist);
896
+
897
+
898
+ /* ----------------------------------------------------------------------------
899
+ * Table scan functions.
900
+ * ----------------------------------------------------------------------------
901
+ */
902
+
903
+ /*
904
+ * Start a scan of `rel`. Returned tuples pass a visibility test of
905
+ * `snapshot`, and if nkeys != 0, the results are filtered by those scan keys.
906
+ */
907
+ static inline TableScanDesc
908
+ table_beginscan(Relation rel, Snapshot snapshot,
909
+ int nkeys, struct ScanKeyData *key)
910
+ {
911
+ uint32 flags = SO_TYPE_SEQSCAN |
912
+ SO_ALLOW_STRAT | SO_ALLOW_SYNC | SO_ALLOW_PAGEMODE;
913
+
914
+ return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
915
+ }
916
+
917
+ /*
918
+ * Like table_beginscan(), but for scanning catalog. It'll automatically use a
919
+ * snapshot appropriate for scanning catalog relations.
920
+ */
921
+ extern TableScanDesc table_beginscan_catalog(Relation relation, int nkeys,
922
+ struct ScanKeyData *key);
923
+
924
+ /*
925
+ * Like table_beginscan(), but table_beginscan_strat() offers an extended API
926
+ * that lets the caller control whether a nondefault buffer access strategy
927
+ * can be used, and whether syncscan can be chosen (possibly resulting in the
928
+ * scan not starting from block zero). Both of these default to true with
929
+ * plain table_beginscan.
930
+ */
931
+ static inline TableScanDesc
932
+ table_beginscan_strat(Relation rel, Snapshot snapshot,
933
+ int nkeys, struct ScanKeyData *key,
934
+ bool allow_strat, bool allow_sync)
935
+ {
936
+ uint32 flags = SO_TYPE_SEQSCAN | SO_ALLOW_PAGEMODE;
937
+
938
+ if (allow_strat)
939
+ flags |= SO_ALLOW_STRAT;
940
+ if (allow_sync)
941
+ flags |= SO_ALLOW_SYNC;
942
+
943
+ return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
944
+ }
945
+
946
+ /*
947
+ * table_beginscan_bm is an alternative entry point for setting up a
948
+ * TableScanDesc for a bitmap heap scan. Although that scan technology is
949
+ * really quite unlike a standard seqscan, there is just enough commonality to
950
+ * make it worth using the same data structure.
951
+ */
952
+ static inline TableScanDesc
953
+ table_beginscan_bm(Relation rel, Snapshot snapshot,
954
+ int nkeys, struct ScanKeyData *key, bool need_tuple)
955
+ {
956
+ uint32 flags = SO_TYPE_BITMAPSCAN | SO_ALLOW_PAGEMODE;
957
+
958
+ if (need_tuple)
959
+ flags |= SO_NEED_TUPLES;
960
+
961
+ return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
962
+ }
963
+
964
+ /*
965
+ * table_beginscan_sampling is an alternative entry point for setting up a
966
+ * TableScanDesc for a TABLESAMPLE scan. As with bitmap scans, it's worth
967
+ * using the same data structure although the behavior is rather different.
968
+ * In addition to the options offered by table_beginscan_strat, this call
969
+ * also allows control of whether page-mode visibility checking is used.
970
+ */
971
+ static inline TableScanDesc
972
+ table_beginscan_sampling(Relation rel, Snapshot snapshot,
973
+ int nkeys, struct ScanKeyData *key,
974
+ bool allow_strat, bool allow_sync,
975
+ bool allow_pagemode)
976
+ {
977
+ uint32 flags = SO_TYPE_SAMPLESCAN;
978
+
979
+ if (allow_strat)
980
+ flags |= SO_ALLOW_STRAT;
981
+ if (allow_sync)
982
+ flags |= SO_ALLOW_SYNC;
983
+ if (allow_pagemode)
984
+ flags |= SO_ALLOW_PAGEMODE;
985
+
986
+ return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
987
+ }
988
+
989
+ /*
990
+ * table_beginscan_tid is an alternative entry point for setting up a
991
+ * TableScanDesc for a Tid scan. As with bitmap scans, it's worth using
992
+ * the same data structure although the behavior is rather different.
993
+ */
994
+ static inline TableScanDesc
995
+ table_beginscan_tid(Relation rel, Snapshot snapshot)
996
+ {
997
+ uint32 flags = SO_TYPE_TIDSCAN;
998
+
999
+ return rel->rd_tableam->scan_begin(rel, snapshot, 0, NULL, NULL, flags);
1000
+ }
1001
+
1002
+ /*
1003
+ * table_beginscan_analyze is an alternative entry point for setting up a
1004
+ * TableScanDesc for an ANALYZE scan. As with bitmap scans, it's worth using
1005
+ * the same data structure although the behavior is rather different.
1006
+ */
1007
+ static inline TableScanDesc
1008
+ table_beginscan_analyze(Relation rel)
1009
+ {
1010
+ uint32 flags = SO_TYPE_ANALYZE;
1011
+
1012
+ return rel->rd_tableam->scan_begin(rel, NULL, 0, NULL, NULL, flags);
1013
+ }
1014
+
1015
+ /*
1016
+ * End relation scan.
1017
+ */
1018
+ static inline void
1019
+ table_endscan(TableScanDesc scan)
1020
+ {
1021
+ scan->rs_rd->rd_tableam->scan_end(scan);
1022
+ }
1023
+
1024
+ /*
1025
+ * Restart a relation scan.
1026
+ */
1027
+ static inline void
1028
+ table_rescan(TableScanDesc scan,
1029
+ struct ScanKeyData *key)
1030
+ {
1031
+ scan->rs_rd->rd_tableam->scan_rescan(scan, key, false, false, false, false);
1032
+ }
1033
+
1034
+ /*
1035
+ * Restart a relation scan after changing params.
1036
+ *
1037
+ * This call allows changing the buffer strategy, syncscan, and pagemode
1038
+ * options before starting a fresh scan. Note that although the actual use of
1039
+ * syncscan might change (effectively, enabling or disabling reporting), the
1040
+ * previously selected startblock will be kept.
1041
+ */
1042
+ static inline void
1043
+ table_rescan_set_params(TableScanDesc scan, struct ScanKeyData *key,
1044
+ bool allow_strat, bool allow_sync, bool allow_pagemode)
1045
+ {
1046
+ scan->rs_rd->rd_tableam->scan_rescan(scan, key, true,
1047
+ allow_strat, allow_sync,
1048
+ allow_pagemode);
1049
+ }
1050
+
1051
+ /*
1052
+ * Return next tuple from `scan`, store in slot.
1053
+ */
1054
+ static inline bool
1055
+ table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
1056
+ {
1057
+ slot->tts_tableOid = RelationGetRelid(sscan->rs_rd);
1058
+
1059
+ /* We don't expect actual scans using NoMovementScanDirection */
1060
+ Assert(direction == ForwardScanDirection ||
1061
+ direction == BackwardScanDirection);
1062
+
1063
+ /*
1064
+ * We don't expect direct calls to table_scan_getnextslot with valid
1065
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
1066
+ * xact.c where these variables are declared.
1067
+ */
1068
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1069
+ elog(ERROR, "unexpected table_scan_getnextslot call during logical decoding");
1070
+
1071
+ return sscan->rs_rd->rd_tableam->scan_getnextslot(sscan, direction, slot);
1072
+ }
1073
+
1074
+ /* ----------------------------------------------------------------------------
1075
+ * TID Range scanning related functions.
1076
+ * ----------------------------------------------------------------------------
1077
+ */
1078
+
1079
+ /*
1080
+ * table_beginscan_tidrange is the entry point for setting up a TableScanDesc
1081
+ * for a TID range scan.
1082
+ */
1083
+ static inline TableScanDesc
1084
+ table_beginscan_tidrange(Relation rel, Snapshot snapshot,
1085
+ ItemPointer mintid,
1086
+ ItemPointer maxtid)
1087
+ {
1088
+ TableScanDesc sscan;
1089
+ uint32 flags = SO_TYPE_TIDRANGESCAN | SO_ALLOW_PAGEMODE;
1090
+
1091
+ sscan = rel->rd_tableam->scan_begin(rel, snapshot, 0, NULL, NULL, flags);
1092
+
1093
+ /* Set the range of TIDs to scan */
1094
+ sscan->rs_rd->rd_tableam->scan_set_tidrange(sscan, mintid, maxtid);
1095
+
1096
+ return sscan;
1097
+ }
1098
+
1099
+ /*
1100
+ * table_rescan_tidrange resets the scan position and sets the minimum and
1101
+ * maximum TID range to scan for a TableScanDesc created by
1102
+ * table_beginscan_tidrange.
1103
+ */
1104
+ static inline void
1105
+ table_rescan_tidrange(TableScanDesc sscan, ItemPointer mintid,
1106
+ ItemPointer maxtid)
1107
+ {
1108
+ /* Ensure table_beginscan_tidrange() was used. */
1109
+ Assert((sscan->rs_flags & SO_TYPE_TIDRANGESCAN) != 0);
1110
+
1111
+ sscan->rs_rd->rd_tableam->scan_rescan(sscan, NULL, false, false, false, false);
1112
+ sscan->rs_rd->rd_tableam->scan_set_tidrange(sscan, mintid, maxtid);
1113
+ }
1114
+
1115
+ /*
1116
+ * Fetch the next tuple from `sscan` for a TID range scan created by
1117
+ * table_beginscan_tidrange(). Stores the tuple in `slot` and returns true,
1118
+ * or returns false if no more tuples exist in the range.
1119
+ */
1120
+ static inline bool
1121
+ table_scan_getnextslot_tidrange(TableScanDesc sscan, ScanDirection direction,
1122
+ TupleTableSlot *slot)
1123
+ {
1124
+ /* Ensure table_beginscan_tidrange() was used. */
1125
+ Assert((sscan->rs_flags & SO_TYPE_TIDRANGESCAN) != 0);
1126
+
1127
+ /* We don't expect actual scans using NoMovementScanDirection */
1128
+ Assert(direction == ForwardScanDirection ||
1129
+ direction == BackwardScanDirection);
1130
+
1131
+ return sscan->rs_rd->rd_tableam->scan_getnextslot_tidrange(sscan,
1132
+ direction,
1133
+ slot);
1134
+ }
1135
+
1136
+
1137
+ /* ----------------------------------------------------------------------------
1138
+ * Parallel table scan related functions.
1139
+ * ----------------------------------------------------------------------------
1140
+ */
1141
+
1142
+ /*
1143
+ * Estimate the size of shared memory needed for a parallel scan of this
1144
+ * relation.
1145
+ */
1146
+ extern Size table_parallelscan_estimate(Relation rel, Snapshot snapshot);
1147
+
1148
+ /*
1149
+ * Initialize ParallelTableScanDesc for a parallel scan of this
1150
+ * relation. `pscan` needs to be sized according to parallelscan_estimate()
1151
+ * for the same relation. Call this just once in the leader process; then,
1152
+ * individual workers attach via table_beginscan_parallel.
1153
+ */
1154
+ extern void table_parallelscan_initialize(Relation rel,
1155
+ ParallelTableScanDesc pscan,
1156
+ Snapshot snapshot);
1157
+
1158
+ /*
1159
+ * Begin a parallel scan. `pscan` needs to have been initialized with
1160
+ * table_parallelscan_initialize(), for the same relation. The initialization
1161
+ * does not need to have happened in this backend.
1162
+ *
1163
+ * Caller must hold a suitable lock on the relation.
1164
+ */
1165
+ extern TableScanDesc table_beginscan_parallel(Relation relation,
1166
+ ParallelTableScanDesc pscan);
1167
+
1168
+ /*
1169
+ * Restart a parallel scan. Call this in the leader process. Caller is
1170
+ * responsible for making sure that all workers have finished the scan
1171
+ * beforehand.
1172
+ */
1173
+ static inline void
1174
+ table_parallelscan_reinitialize(Relation rel, ParallelTableScanDesc pscan)
1175
+ {
1176
+ rel->rd_tableam->parallelscan_reinitialize(rel, pscan);
1177
+ }
1178
+
1179
+
1180
+ /* ----------------------------------------------------------------------------
1181
+ * Index scan related functions.
1182
+ * ----------------------------------------------------------------------------
1183
+ */
1184
+
1185
+ /*
1186
+ * Prepare to fetch tuples from the relation, as needed when fetching tuples
1187
+ * for an index scan.
1188
+ *
1189
+ * Tuples for an index scan can then be fetched via table_index_fetch_tuple().
1190
+ */
1191
+ static inline IndexFetchTableData *
1192
+ table_index_fetch_begin(Relation rel)
1193
+ {
1194
+ return rel->rd_tableam->index_fetch_begin(rel);
1195
+ }
1196
+
1197
+ /*
1198
+ * Reset index fetch. Typically this will release cross index fetch resources
1199
+ * held in IndexFetchTableData.
1200
+ */
1201
+ static inline void
1202
+ table_index_fetch_reset(struct IndexFetchTableData *scan)
1203
+ {
1204
+ scan->rel->rd_tableam->index_fetch_reset(scan);
1205
+ }
1206
+
1207
+ /*
1208
+ * Release resources and deallocate index fetch.
1209
+ */
1210
+ static inline void
1211
+ table_index_fetch_end(struct IndexFetchTableData *scan)
1212
+ {
1213
+ scan->rel->rd_tableam->index_fetch_end(scan);
1214
+ }
1215
+
1216
+ /*
1217
+ * Fetches, as part of an index scan, tuple at `tid` into `slot`, after doing
1218
+ * a visibility test according to `snapshot`. If a tuple was found and passed
1219
+ * the visibility test, returns true, false otherwise. Note that *tid may be
1220
+ * modified when we return true (see later remarks on multiple row versions
1221
+ * reachable via a single index entry).
1222
+ *
1223
+ * *call_again needs to be false on the first call to table_index_fetch_tuple() for
1224
+ * a tid. If there potentially is another tuple matching the tid, *call_again
1225
+ * will be set to true, signaling that table_index_fetch_tuple() should be called
1226
+ * again for the same tid.
1227
+ *
1228
+ * *all_dead, if all_dead is not NULL, will be set to true by
1229
+ * table_index_fetch_tuple() iff it is guaranteed that no backend needs to see
1230
+ * that tuple. Index AMs can use that to avoid returning that tid in future
1231
+ * searches.
1232
+ *
1233
+ * The difference between this function and table_tuple_fetch_row_version()
1234
+ * is that this function returns the currently visible version of a row if
1235
+ * the AM supports storing multiple row versions reachable via a single index
1236
+ * entry (like heap's HOT). Whereas table_tuple_fetch_row_version() only
1237
+ * evaluates the tuple exactly at `tid`. Outside of index entry ->table tuple
1238
+ * lookups, table_tuple_fetch_row_version() is what's usually needed.
1239
+ */
1240
+ static inline bool
1241
+ table_index_fetch_tuple(struct IndexFetchTableData *scan,
1242
+ ItemPointer tid,
1243
+ Snapshot snapshot,
1244
+ TupleTableSlot *slot,
1245
+ bool *call_again, bool *all_dead)
1246
+ {
1247
+ /*
1248
+ * We don't expect direct calls to table_index_fetch_tuple with valid
1249
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
1250
+ * xact.c where these variables are declared.
1251
+ */
1252
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1253
+ elog(ERROR, "unexpected table_index_fetch_tuple call during logical decoding");
1254
+
1255
+ return scan->rel->rd_tableam->index_fetch_tuple(scan, tid, snapshot,
1256
+ slot, call_again,
1257
+ all_dead);
1258
+ }
1259
+
1260
+ /*
1261
+ * This is a convenience wrapper around table_index_fetch_tuple() which
1262
+ * returns whether there are table tuple items corresponding to an index
1263
+ * entry. This likely is only useful to verify if there's a conflict in a
1264
+ * unique index.
1265
+ */
1266
+ extern bool table_index_fetch_tuple_check(Relation rel,
1267
+ ItemPointer tid,
1268
+ Snapshot snapshot,
1269
+ bool *all_dead);
1270
+
1271
+
1272
+ /* ------------------------------------------------------------------------
1273
+ * Functions for non-modifying operations on individual tuples
1274
+ * ------------------------------------------------------------------------
1275
+ */
1276
+
1277
+
1278
+ /*
1279
+ * Fetch tuple at `tid` into `slot`, after doing a visibility test according to
1280
+ * `snapshot`. If a tuple was found and passed the visibility test, returns
1281
+ * true, false otherwise.
1282
+ *
1283
+ * See table_index_fetch_tuple's comment about what the difference between
1284
+ * these functions is. It is correct to use this function outside of index
1285
+ * entry->table tuple lookups.
1286
+ */
1287
+ static inline bool
1288
+ table_tuple_fetch_row_version(Relation rel,
1289
+ ItemPointer tid,
1290
+ Snapshot snapshot,
1291
+ TupleTableSlot *slot)
1292
+ {
1293
+ /*
1294
+ * We don't expect direct calls to table_tuple_fetch_row_version with
1295
+ * valid CheckXidAlive for catalog or regular tables. See detailed
1296
+ * comments in xact.c where these variables are declared.
1297
+ */
1298
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1299
+ elog(ERROR, "unexpected table_tuple_fetch_row_version call during logical decoding");
1300
+
1301
+ return rel->rd_tableam->tuple_fetch_row_version(rel, tid, snapshot, slot);
1302
+ }
1303
+
1304
+ /*
1305
+ * Verify that `tid` is a potentially valid tuple identifier. That doesn't
1306
+ * mean that the pointed to row needs to exist or be visible, but that
1307
+ * attempting to fetch the row (e.g. with table_tuple_get_latest_tid() or
1308
+ * table_tuple_fetch_row_version()) should not error out if called with that
1309
+ * tid.
1310
+ *
1311
+ * `scan` needs to have been started via table_beginscan().
1312
+ */
1313
+ static inline bool
1314
+ table_tuple_tid_valid(TableScanDesc scan, ItemPointer tid)
1315
+ {
1316
+ return scan->rs_rd->rd_tableam->tuple_tid_valid(scan, tid);
1317
+ }
1318
+
1319
+ /*
1320
+ * Return the latest version of the tuple at `tid`, by updating `tid` to
1321
+ * point at the newest version.
1322
+ */
1323
+ extern void table_tuple_get_latest_tid(TableScanDesc scan, ItemPointer tid);
1324
+
1325
+ /*
1326
+ * Return true iff tuple in slot satisfies the snapshot.
1327
+ *
1328
+ * This assumes the slot's tuple is valid, and of the appropriate type for the
1329
+ * AM.
1330
+ *
1331
+ * Some AMs might modify the data underlying the tuple as a side-effect. If so
1332
+ * they ought to mark the relevant buffer dirty.
1333
+ */
1334
+ static inline bool
1335
+ table_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
1336
+ Snapshot snapshot)
1337
+ {
1338
+ return rel->rd_tableam->tuple_satisfies_snapshot(rel, slot, snapshot);
1339
+ }
1340
+
1341
+ /*
1342
+ * Determine which index tuples are safe to delete based on their table TID.
1343
+ *
1344
+ * Determines which entries from index AM caller's TM_IndexDeleteOp state
1345
+ * point to vacuumable table tuples. Entries that are found by tableam to be
1346
+ * vacuumable are naturally safe for index AM to delete, and so get directly
1347
+ * marked as deletable. See comments above TM_IndexDelete and comments above
1348
+ * TM_IndexDeleteOp for full details.
1349
+ *
1350
+ * Returns a snapshotConflictHorizon transaction ID that caller places in
1351
+ * its index deletion WAL record. This might be used during subsequent REDO
1352
+ * of the WAL record when in Hot Standby mode -- a recovery conflict for the
1353
+ * index deletion operation might be required on the standby.
1354
+ */
1355
+ static inline TransactionId
1356
+ table_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
1357
+ {
1358
+ return rel->rd_tableam->index_delete_tuples(rel, delstate);
1359
+ }
1360
+
1361
+
1362
+ /* ----------------------------------------------------------------------------
1363
+ * Functions for manipulations of physical tuples.
1364
+ * ----------------------------------------------------------------------------
1365
+ */
1366
+
1367
+ /*
1368
+ * Insert a tuple from a slot into table AM routine.
1369
+ *
1370
+ * The options bitmask allows the caller to specify options that may change the
1371
+ * behaviour of the AM. The AM will ignore options that it does not support.
1372
+ *
1373
+ * If the TABLE_INSERT_SKIP_FSM option is specified, AMs are free to not reuse
1374
+ * free space in the relation. This can save some cycles when we know the
1375
+ * relation is new and doesn't contain useful amounts of free space.
1376
+ * TABLE_INSERT_SKIP_FSM is commonly passed directly to
1377
+ * RelationGetBufferForTuple. See that method for more information.
1378
+ *
1379
+ * TABLE_INSERT_FROZEN should only be specified for inserts into
1380
+ * relation storage created during the current subtransaction and when
1381
+ * there are no prior snapshots or pre-existing portals open.
1382
+ * This causes rows to be frozen, which is an MVCC violation and
1383
+ * requires explicit options chosen by user.
1384
+ *
1385
+ * TABLE_INSERT_NO_LOGICAL force-disables the emitting of logical decoding
1386
+ * information for the tuple. This should solely be used during table rewrites
1387
+ * where RelationIsLogicallyLogged(relation) is not yet accurate for the new
1388
+ * relation.
1389
+ *
1390
+ * Note that most of these options will be applied when inserting into the
1391
+ * heap's TOAST table, too, if the tuple requires any out-of-line data.
1392
+ *
1393
+ * The BulkInsertState object (if any; bistate can be NULL for default
1394
+ * behavior) is also just passed through to RelationGetBufferForTuple. If
1395
+ * `bistate` is provided, table_finish_bulk_insert() needs to be called.
1396
+ *
1397
+ * On return the slot's tts_tid and tts_tableOid are updated to reflect the
1398
+ * insertion. But note that any toasting of fields within the slot is NOT
1399
+ * reflected in the slots contents.
1400
+ */
1401
+ static inline void
1402
+ table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid,
1403
+ int options, struct BulkInsertStateData *bistate)
1404
+ {
1405
+ rel->rd_tableam->tuple_insert(rel, slot, cid, options,
1406
+ bistate);
1407
+ }
1408
+
1409
+ /*
1410
+ * Perform a "speculative insertion". These can be backed out afterwards
1411
+ * without aborting the whole transaction. Other sessions can wait for the
1412
+ * speculative insertion to be confirmed, turning it into a regular tuple, or
1413
+ * aborted, as if it never existed. Speculatively inserted tuples behave as
1414
+ * "value locks" of short duration, used to implement INSERT .. ON CONFLICT.
1415
+ *
1416
+ * A transaction having performed a speculative insertion has to either abort,
1417
+ * or finish the speculative insertion with
1418
+ * table_tuple_complete_speculative(succeeded = ...).
1419
+ */
1420
+ static inline void
1421
+ table_tuple_insert_speculative(Relation rel, TupleTableSlot *slot,
1422
+ CommandId cid, int options,
1423
+ struct BulkInsertStateData *bistate,
1424
+ uint32 specToken)
1425
+ {
1426
+ rel->rd_tableam->tuple_insert_speculative(rel, slot, cid, options,
1427
+ bistate, specToken);
1428
+ }
1429
+
1430
+ /*
1431
+ * Complete "speculative insertion" started in the same transaction. If
1432
+ * succeeded is true, the tuple is fully inserted, if false, it's removed.
1433
+ */
1434
+ static inline void
1435
+ table_tuple_complete_speculative(Relation rel, TupleTableSlot *slot,
1436
+ uint32 specToken, bool succeeded)
1437
+ {
1438
+ rel->rd_tableam->tuple_complete_speculative(rel, slot, specToken,
1439
+ succeeded);
1440
+ }
1441
+
1442
+ /*
1443
+ * Insert multiple tuples into a table.
1444
+ *
1445
+ * This is like table_tuple_insert(), but inserts multiple tuples in one
1446
+ * operation. That's often faster than calling table_tuple_insert() in a loop,
1447
+ * because e.g. the AM can reduce WAL logging and page locking overhead.
1448
+ *
1449
+ * Except for taking `nslots` tuples as input, and an array of TupleTableSlots
1450
+ * in `slots`, the parameters for table_multi_insert() are the same as for
1451
+ * table_tuple_insert().
1452
+ *
1453
+ * Note: this leaks memory into the current memory context. You can create a
1454
+ * temporary context before calling this, if that's a problem.
1455
+ */
1456
+ static inline void
1457
+ table_multi_insert(Relation rel, TupleTableSlot **slots, int nslots,
1458
+ CommandId cid, int options, struct BulkInsertStateData *bistate)
1459
+ {
1460
+ rel->rd_tableam->multi_insert(rel, slots, nslots,
1461
+ cid, options, bistate);
1462
+ }
1463
+
1464
+ /*
1465
+ * Delete a tuple.
1466
+ *
1467
+ * NB: do not call this directly unless prepared to deal with
1468
+ * concurrent-update conditions. Use simple_table_tuple_delete instead.
1469
+ *
1470
+ * Input parameters:
1471
+ * relation - table to be modified (caller must hold suitable lock)
1472
+ * tid - TID of tuple to be deleted
1473
+ * cid - delete command ID (used for visibility test, and stored into
1474
+ * cmax if successful)
1475
+ * crosscheck - if not InvalidSnapshot, also check tuple against this
1476
+ * wait - true if should wait for any conflicting update to commit/abort
1477
+ * Output parameters:
1478
+ * tmfd - filled in failure cases (see below)
1479
+ * changingPart - true iff the tuple is being moved to another partition
1480
+ * table due to an update of the partition key. Otherwise, false.
1481
+ *
1482
+ * Normal, successful return value is TM_Ok, which means we did actually
1483
+ * delete it. Failure return codes are TM_SelfModified, TM_Updated, and
1484
+ * TM_BeingModified (the last only possible if wait == false).
1485
+ *
1486
+ * In the failure cases, the routine fills *tmfd with the tuple's t_ctid,
1487
+ * t_xmax, and, if possible, t_cmax. See comments for struct
1488
+ * TM_FailureData for additional info.
1489
+ */
1490
+ static inline TM_Result
1491
+ table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid,
1492
+ Snapshot snapshot, Snapshot crosscheck, bool wait,
1493
+ TM_FailureData *tmfd, bool changingPart)
1494
+ {
1495
+ return rel->rd_tableam->tuple_delete(rel, tid, cid,
1496
+ snapshot, crosscheck,
1497
+ wait, tmfd, changingPart);
1498
+ }
1499
+
1500
+ /*
1501
+ * Update a tuple.
1502
+ *
1503
+ * NB: do not call this directly unless you are prepared to deal with
1504
+ * concurrent-update conditions. Use simple_table_tuple_update instead.
1505
+ *
1506
+ * Input parameters:
1507
+ * relation - table to be modified (caller must hold suitable lock)
1508
+ * otid - TID of old tuple to be replaced
1509
+ * slot - newly constructed tuple data to store
1510
+ * cid - update command ID (used for visibility test, and stored into
1511
+ * cmax/cmin if successful)
1512
+ * crosscheck - if not InvalidSnapshot, also check old tuple against this
1513
+ * wait - true if should wait for any conflicting update to commit/abort
1514
+ * Output parameters:
1515
+ * tmfd - filled in failure cases (see below)
1516
+ * lockmode - filled with lock mode acquired on tuple
1517
+ * update_indexes - in success cases this is set to true if new index entries
1518
+ * are required for this tuple
1519
+ *
1520
+ * Normal, successful return value is TM_Ok, which means we did actually
1521
+ * update it. Failure return codes are TM_SelfModified, TM_Updated, and
1522
+ * TM_BeingModified (the last only possible if wait == false).
1523
+ *
1524
+ * On success, the slot's tts_tid and tts_tableOid are updated to match the new
1525
+ * stored tuple; in particular, slot->tts_tid is set to the TID where the
1526
+ * new tuple was inserted, and its HEAP_ONLY_TUPLE flag is set iff a HOT
1527
+ * update was done. However, any TOAST changes in the new tuple's
1528
+ * data are not reflected into *newtup.
1529
+ *
1530
+ * In the failure cases, the routine fills *tmfd with the tuple's t_ctid,
1531
+ * t_xmax, and, if possible, t_cmax. See comments for struct TM_FailureData
1532
+ * for additional info.
1533
+ */
1534
+ static inline TM_Result
1535
+ table_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot,
1536
+ CommandId cid, Snapshot snapshot, Snapshot crosscheck,
1537
+ bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode,
1538
+ TU_UpdateIndexes *update_indexes)
1539
+ {
1540
+ return rel->rd_tableam->tuple_update(rel, otid, slot,
1541
+ cid, snapshot, crosscheck,
1542
+ wait, tmfd,
1543
+ lockmode, update_indexes);
1544
+ }
1545
+
1546
+ /*
1547
+ * Lock a tuple in the specified mode.
1548
+ *
1549
+ * Input parameters:
1550
+ * relation: relation containing tuple (caller must hold suitable lock)
1551
+ * tid: TID of tuple to lock
1552
+ * snapshot: snapshot to use for visibility determinations
1553
+ * cid: current command ID (used for visibility test, and stored into
1554
+ * tuple's cmax if lock is successful)
1555
+ * mode: lock mode desired
1556
+ * wait_policy: what to do if tuple lock is not available
1557
+ * flags:
1558
+ * If TUPLE_LOCK_FLAG_LOCK_UPDATE_IN_PROGRESS, follow the update chain to
1559
+ * also lock descendant tuples if lock modes don't conflict.
1560
+ * If TUPLE_LOCK_FLAG_FIND_LAST_VERSION, follow the update chain and lock
1561
+ * latest version.
1562
+ *
1563
+ * Output parameters:
1564
+ * *slot: contains the target tuple
1565
+ * *tmfd: filled in failure cases (see below)
1566
+ *
1567
+ * Function result may be:
1568
+ * TM_Ok: lock was successfully acquired
1569
+ * TM_Invisible: lock failed because tuple was never visible to us
1570
+ * TM_SelfModified: lock failed because tuple updated by self
1571
+ * TM_Updated: lock failed because tuple updated by other xact
1572
+ * TM_Deleted: lock failed because tuple deleted by other xact
1573
+ * TM_WouldBlock: lock couldn't be acquired and wait_policy is skip
1574
+ *
1575
+ * In the failure cases other than TM_Invisible and TM_Deleted, the routine
1576
+ * fills *tmfd with the tuple's t_ctid, t_xmax, and, if possible, t_cmax. See
1577
+ * comments for struct TM_FailureData for additional info.
1578
+ */
1579
+ static inline TM_Result
1580
+ table_tuple_lock(Relation rel, ItemPointer tid, Snapshot snapshot,
1581
+ TupleTableSlot *slot, CommandId cid, LockTupleMode mode,
1582
+ LockWaitPolicy wait_policy, uint8 flags,
1583
+ TM_FailureData *tmfd)
1584
+ {
1585
+ return rel->rd_tableam->tuple_lock(rel, tid, snapshot, slot,
1586
+ cid, mode, wait_policy,
1587
+ flags, tmfd);
1588
+ }
1589
+
1590
+ /*
1591
+ * Perform operations necessary to complete insertions made via
1592
+ * tuple_insert and multi_insert with a BulkInsertState specified.
1593
+ */
1594
+ static inline void
1595
+ table_finish_bulk_insert(Relation rel, int options)
1596
+ {
1597
+ /* optional callback */
1598
+ if (rel->rd_tableam && rel->rd_tableam->finish_bulk_insert)
1599
+ rel->rd_tableam->finish_bulk_insert(rel, options);
1600
+ }
1601
+
1602
+
1603
+ /* ------------------------------------------------------------------------
1604
+ * DDL related functionality.
1605
+ * ------------------------------------------------------------------------
1606
+ */
1607
+
1608
+ /*
1609
+ * Create storage for `rel` in `newrlocator`, with persistence set to
1610
+ * `persistence`.
1611
+ *
1612
+ * This is used both during relation creation and various DDL operations to
1613
+ * create new rel storage that can be filled from scratch. When creating
1614
+ * new storage for an existing relfilelocator, this should be called before the
1615
+ * relcache entry has been updated.
1616
+ *
1617
+ * *freezeXid, *minmulti are set to the xid / multixact horizon for the table
1618
+ * that pg_class.{relfrozenxid, relminmxid} have to be set to.
1619
+ */
1620
+ static inline void
1621
+ table_relation_set_new_filelocator(Relation rel,
1622
+ const RelFileLocator *newrlocator,
1623
+ char persistence,
1624
+ TransactionId *freezeXid,
1625
+ MultiXactId *minmulti)
1626
+ {
1627
+ rel->rd_tableam->relation_set_new_filelocator(rel, newrlocator,
1628
+ persistence, freezeXid,
1629
+ minmulti);
1630
+ }
1631
+
1632
+ /*
1633
+ * Remove all table contents from `rel`, in a non-transactional manner.
1634
+ * Non-transactional meaning that there's no need to support rollbacks. This
1635
+ * commonly only is used to perform truncations for relation storage created in
1636
+ * the current transaction.
1637
+ */
1638
+ static inline void
1639
+ table_relation_nontransactional_truncate(Relation rel)
1640
+ {
1641
+ rel->rd_tableam->relation_nontransactional_truncate(rel);
1642
+ }
1643
+
1644
+ /*
1645
+ * Copy data from `rel` into the new relfilelocator `newrlocator`. The new
1646
+ * relfilelocator may not have storage associated before this function is
1647
+ * called. This is only supposed to be used for low level operations like
1648
+ * changing a relation's tablespace.
1649
+ */
1650
+ static inline void
1651
+ table_relation_copy_data(Relation rel, const RelFileLocator *newrlocator)
1652
+ {
1653
+ rel->rd_tableam->relation_copy_data(rel, newrlocator);
1654
+ }
1655
+
1656
+ /*
1657
+ * Copy data from `OldTable` into `NewTable`, as part of a CLUSTER or VACUUM
1658
+ * FULL.
1659
+ *
1660
+ * Additional Input parameters:
1661
+ * - use_sort - if true, the table contents are sorted appropriate for
1662
+ * `OldIndex`; if false and OldIndex is not InvalidOid, the data is copied
1663
+ * in that index's order; if false and OldIndex is InvalidOid, no sorting is
1664
+ * performed
1665
+ * - OldIndex - see use_sort
1666
+ * - OldestXmin - computed by vacuum_get_cutoffs(), even when
1667
+ * not needed for the relation's AM
1668
+ * - *xid_cutoff - ditto
1669
+ * - *multi_cutoff - ditto
1670
+ *
1671
+ * Output parameters:
1672
+ * - *xid_cutoff - rel's new relfrozenxid value, may be invalid
1673
+ * - *multi_cutoff - rel's new relminmxid value, may be invalid
1674
+ * - *tups_vacuumed - stats, for logging, if appropriate for AM
1675
+ * - *tups_recently_dead - stats, for logging, if appropriate for AM
1676
+ */
1677
+ static inline void
1678
+ table_relation_copy_for_cluster(Relation OldTable, Relation NewTable,
1679
+ Relation OldIndex,
1680
+ bool use_sort,
1681
+ TransactionId OldestXmin,
1682
+ TransactionId *xid_cutoff,
1683
+ MultiXactId *multi_cutoff,
1684
+ double *num_tuples,
1685
+ double *tups_vacuumed,
1686
+ double *tups_recently_dead)
1687
+ {
1688
+ OldTable->rd_tableam->relation_copy_for_cluster(OldTable, NewTable, OldIndex,
1689
+ use_sort, OldestXmin,
1690
+ xid_cutoff, multi_cutoff,
1691
+ num_tuples, tups_vacuumed,
1692
+ tups_recently_dead);
1693
+ }
1694
+
1695
+ /*
1696
+ * Perform VACUUM on the relation. The VACUUM can be triggered by a user or by
1697
+ * autovacuum. The specific actions performed by the AM will depend heavily on
1698
+ * the individual AM.
1699
+ *
1700
+ * On entry a transaction needs to already been established, and the
1701
+ * table is locked with a ShareUpdateExclusive lock.
1702
+ *
1703
+ * Note that neither VACUUM FULL (and CLUSTER), nor ANALYZE go through this
1704
+ * routine, even if (for ANALYZE) it is part of the same VACUUM command.
1705
+ */
1706
+ static inline void
1707
+ table_relation_vacuum(Relation rel, struct VacuumParams *params,
1708
+ BufferAccessStrategy bstrategy)
1709
+ {
1710
+ rel->rd_tableam->relation_vacuum(rel, params, bstrategy);
1711
+ }
1712
+
1713
+ /*
1714
+ * Prepare to analyze the next block in the read stream. The scan needs to
1715
+ * have been started with table_beginscan_analyze(). Note that this routine
1716
+ * might acquire resources like locks that are held until
1717
+ * table_scan_analyze_next_tuple() returns false.
1718
+ *
1719
+ * Returns false if block is unsuitable for sampling, true otherwise.
1720
+ */
1721
+ static inline bool
1722
+ table_scan_analyze_next_block(TableScanDesc scan, ReadStream *stream)
1723
+ {
1724
+ return scan->rs_rd->rd_tableam->scan_analyze_next_block(scan, stream);
1725
+ }
1726
+
1727
+ /*
1728
+ * Iterate over tuples in the block selected with
1729
+ * table_scan_analyze_next_block() (which needs to have returned true, and
1730
+ * this routine may not have returned false for the same block before). If a
1731
+ * tuple that's suitable for sampling is found, true is returned and a tuple
1732
+ * is stored in `slot`.
1733
+ *
1734
+ * *liverows and *deadrows are incremented according to the encountered
1735
+ * tuples.
1736
+ */
1737
+ static inline bool
1738
+ table_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
1739
+ double *liverows, double *deadrows,
1740
+ TupleTableSlot *slot)
1741
+ {
1742
+ return scan->rs_rd->rd_tableam->scan_analyze_next_tuple(scan, OldestXmin,
1743
+ liverows, deadrows,
1744
+ slot);
1745
+ }
1746
+
1747
+ /*
1748
+ * table_index_build_scan - scan the table to find tuples to be indexed
1749
+ *
1750
+ * This is called back from an access-method-specific index build procedure
1751
+ * after the AM has done whatever setup it needs. The parent table relation
1752
+ * is scanned to find tuples that should be entered into the index. Each
1753
+ * such tuple is passed to the AM's callback routine, which does the right
1754
+ * things to add it to the new index. After we return, the AM's index
1755
+ * build procedure does whatever cleanup it needs.
1756
+ *
1757
+ * The total count of live tuples is returned. This is for updating pg_class
1758
+ * statistics. (It's annoying not to be able to do that here, but we want to
1759
+ * merge that update with others; see index_update_stats.) Note that the
1760
+ * index AM itself must keep track of the number of index tuples; we don't do
1761
+ * so here because the AM might reject some of the tuples for its own reasons,
1762
+ * such as being unable to store NULLs.
1763
+ *
1764
+ * If 'progress', the PROGRESS_SCAN_BLOCKS_TOTAL counter is updated when
1765
+ * starting the scan, and PROGRESS_SCAN_BLOCKS_DONE is updated as we go along.
1766
+ *
1767
+ * A side effect is to set indexInfo->ii_BrokenHotChain to true if we detect
1768
+ * any potentially broken HOT chains. Currently, we set this if there are any
1769
+ * RECENTLY_DEAD or DELETE_IN_PROGRESS entries in a HOT chain, without trying
1770
+ * very hard to detect whether they're really incompatible with the chain tip.
1771
+ * This only really makes sense for heap AM, it might need to be generalized
1772
+ * for other AMs later.
1773
+ */
1774
+ static inline double
1775
+ table_index_build_scan(Relation table_rel,
1776
+ Relation index_rel,
1777
+ struct IndexInfo *index_info,
1778
+ bool allow_sync,
1779
+ bool progress,
1780
+ IndexBuildCallback callback,
1781
+ void *callback_state,
1782
+ TableScanDesc scan)
1783
+ {
1784
+ return table_rel->rd_tableam->index_build_range_scan(table_rel,
1785
+ index_rel,
1786
+ index_info,
1787
+ allow_sync,
1788
+ false,
1789
+ progress,
1790
+ 0,
1791
+ InvalidBlockNumber,
1792
+ callback,
1793
+ callback_state,
1794
+ scan);
1795
+ }
1796
+
1797
+ /*
1798
+ * As table_index_build_scan(), except that instead of scanning the complete
1799
+ * table, only the given number of blocks are scanned. Scan to end-of-rel can
1800
+ * be signaled by passing InvalidBlockNumber as numblocks. Note that
1801
+ * restricting the range to scan cannot be done when requesting syncscan.
1802
+ *
1803
+ * When "anyvisible" mode is requested, all tuples visible to any transaction
1804
+ * are indexed and counted as live, including those inserted or deleted by
1805
+ * transactions that are still in progress.
1806
+ */
1807
+ static inline double
1808
+ table_index_build_range_scan(Relation table_rel,
1809
+ Relation index_rel,
1810
+ struct IndexInfo *index_info,
1811
+ bool allow_sync,
1812
+ bool anyvisible,
1813
+ bool progress,
1814
+ BlockNumber start_blockno,
1815
+ BlockNumber numblocks,
1816
+ IndexBuildCallback callback,
1817
+ void *callback_state,
1818
+ TableScanDesc scan)
1819
+ {
1820
+ return table_rel->rd_tableam->index_build_range_scan(table_rel,
1821
+ index_rel,
1822
+ index_info,
1823
+ allow_sync,
1824
+ anyvisible,
1825
+ progress,
1826
+ start_blockno,
1827
+ numblocks,
1828
+ callback,
1829
+ callback_state,
1830
+ scan);
1831
+ }
1832
+
1833
+ /*
1834
+ * table_index_validate_scan - second table scan for concurrent index build
1835
+ *
1836
+ * See validate_index() for an explanation.
1837
+ */
1838
+ static inline void
1839
+ table_index_validate_scan(Relation table_rel,
1840
+ Relation index_rel,
1841
+ struct IndexInfo *index_info,
1842
+ Snapshot snapshot,
1843
+ struct ValidateIndexState *state)
1844
+ {
1845
+ table_rel->rd_tableam->index_validate_scan(table_rel,
1846
+ index_rel,
1847
+ index_info,
1848
+ snapshot,
1849
+ state);
1850
+ }
1851
+
1852
+
1853
+ /* ----------------------------------------------------------------------------
1854
+ * Miscellaneous functionality
1855
+ * ----------------------------------------------------------------------------
1856
+ */
1857
+
1858
+ /*
1859
+ * Return the current size of `rel` in bytes. If `forkNumber` is
1860
+ * InvalidForkNumber, return the relation's overall size, otherwise the size
1861
+ * for the indicated fork.
1862
+ *
1863
+ * Note that the overall size might not be the equivalent of the sum of sizes
1864
+ * for the individual forks for some AMs, e.g. because the AMs storage does
1865
+ * not neatly map onto the builtin types of forks.
1866
+ */
1867
+ static inline uint64
1868
+ table_relation_size(Relation rel, ForkNumber forkNumber)
1869
+ {
1870
+ return rel->rd_tableam->relation_size(rel, forkNumber);
1871
+ }
1872
+
1873
+ /*
1874
+ * table_relation_needs_toast_table - does this relation need a toast table?
1875
+ */
1876
+ static inline bool
1877
+ table_relation_needs_toast_table(Relation rel)
1878
+ {
1879
+ return rel->rd_tableam->relation_needs_toast_table(rel);
1880
+ }
1881
+
1882
+ /*
1883
+ * Return the OID of the AM that should be used to implement the TOAST table
1884
+ * for this relation.
1885
+ */
1886
+ static inline Oid
1887
+ table_relation_toast_am(Relation rel)
1888
+ {
1889
+ return rel->rd_tableam->relation_toast_am(rel);
1890
+ }
1891
+
1892
+ /*
1893
+ * Fetch all or part of a TOAST value from a TOAST table.
1894
+ *
1895
+ * If this AM is never used to implement a TOAST table, then this callback
1896
+ * is not needed. But, if toasted values are ever stored in a table of this
1897
+ * type, then you will need this callback.
1898
+ *
1899
+ * toastrel is the relation in which the toasted value is stored.
1900
+ *
1901
+ * valueid identifies which toast value is to be fetched. For the heap,
1902
+ * this corresponds to the values stored in the chunk_id column.
1903
+ *
1904
+ * attrsize is the total size of the toast value to be fetched.
1905
+ *
1906
+ * sliceoffset is the offset within the toast value of the first byte that
1907
+ * should be fetched.
1908
+ *
1909
+ * slicelength is the number of bytes from the toast value that should be
1910
+ * fetched.
1911
+ *
1912
+ * result is caller-allocated space into which the fetched bytes should be
1913
+ * stored.
1914
+ */
1915
+ static inline void
1916
+ table_relation_fetch_toast_slice(Relation toastrel, Oid valueid,
1917
+ int32 attrsize, int32 sliceoffset,
1918
+ int32 slicelength, struct varlena *result)
1919
+ {
1920
+ toastrel->rd_tableam->relation_fetch_toast_slice(toastrel, valueid,
1921
+ attrsize,
1922
+ sliceoffset, slicelength,
1923
+ result);
1924
+ }
1925
+
1926
+
1927
+ /* ----------------------------------------------------------------------------
1928
+ * Planner related functionality
1929
+ * ----------------------------------------------------------------------------
1930
+ */
1931
+
1932
+ /*
1933
+ * Estimate the current size of the relation, as an AM specific workhorse for
1934
+ * estimate_rel_size(). Look there for an explanation of the parameters.
1935
+ */
1936
+ static inline void
1937
+ table_relation_estimate_size(Relation rel, int32 *attr_widths,
1938
+ BlockNumber *pages, double *tuples,
1939
+ double *allvisfrac)
1940
+ {
1941
+ rel->rd_tableam->relation_estimate_size(rel, attr_widths, pages, tuples,
1942
+ allvisfrac);
1943
+ }
1944
+
1945
+
1946
+ /* ----------------------------------------------------------------------------
1947
+ * Executor related functionality
1948
+ * ----------------------------------------------------------------------------
1949
+ */
1950
+
1951
+ /*
1952
+ * Prepare to fetch / check / return tuples from `tbmres->blockno` as part of
1953
+ * a bitmap table scan. `scan` needs to have been started via
1954
+ * table_beginscan_bm(). Returns false if there are no tuples to be found on
1955
+ * the page, true otherwise.
1956
+ *
1957
+ * Note, this is an optionally implemented function, therefore should only be
1958
+ * used after verifying the presence (at plan time or such).
1959
+ */
1960
+ static inline bool
1961
+ table_scan_bitmap_next_block(TableScanDesc scan,
1962
+ struct TBMIterateResult *tbmres)
1963
+ {
1964
+ /*
1965
+ * We don't expect direct calls to table_scan_bitmap_next_block with valid
1966
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
1967
+ * xact.c where these variables are declared.
1968
+ */
1969
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1970
+ elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding");
1971
+
1972
+ return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan,
1973
+ tbmres);
1974
+ }
1975
+
1976
+ /*
1977
+ * Fetch the next tuple of a bitmap table scan into `slot` and return true if
1978
+ * a visible tuple was found, false otherwise.
1979
+ * table_scan_bitmap_next_block() needs to previously have selected a
1980
+ * block (i.e. returned true), and no previous
1981
+ * table_scan_bitmap_next_tuple() for the same block may have
1982
+ * returned false.
1983
+ */
1984
+ static inline bool
1985
+ table_scan_bitmap_next_tuple(TableScanDesc scan,
1986
+ struct TBMIterateResult *tbmres,
1987
+ TupleTableSlot *slot)
1988
+ {
1989
+ /*
1990
+ * We don't expect direct calls to table_scan_bitmap_next_tuple with valid
1991
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
1992
+ * xact.c where these variables are declared.
1993
+ */
1994
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
1995
+ elog(ERROR, "unexpected table_scan_bitmap_next_tuple call during logical decoding");
1996
+
1997
+ return scan->rs_rd->rd_tableam->scan_bitmap_next_tuple(scan,
1998
+ tbmres,
1999
+ slot);
2000
+ }
2001
+
2002
+ /*
2003
+ * Prepare to fetch tuples from the next block in a sample scan. Returns false
2004
+ * if the sample scan is finished, true otherwise. `scan` needs to have been
2005
+ * started via table_beginscan_sampling().
2006
+ *
2007
+ * This will call the TsmRoutine's NextSampleBlock() callback if necessary
2008
+ * (i.e. NextSampleBlock is not NULL), or perform a sequential scan over the
2009
+ * underlying relation.
2010
+ */
2011
+ static inline bool
2012
+ table_scan_sample_next_block(TableScanDesc scan,
2013
+ struct SampleScanState *scanstate)
2014
+ {
2015
+ /*
2016
+ * We don't expect direct calls to table_scan_sample_next_block with valid
2017
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
2018
+ * xact.c where these variables are declared.
2019
+ */
2020
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
2021
+ elog(ERROR, "unexpected table_scan_sample_next_block call during logical decoding");
2022
+ return scan->rs_rd->rd_tableam->scan_sample_next_block(scan, scanstate);
2023
+ }
2024
+
2025
+ /*
2026
+ * Fetch the next sample tuple into `slot` and return true if a visible tuple
2027
+ * was found, false otherwise. table_scan_sample_next_block() needs to
2028
+ * previously have selected a block (i.e. returned true), and no previous
2029
+ * table_scan_sample_next_tuple() for the same block may have returned false.
2030
+ *
2031
+ * This will call the TsmRoutine's NextSampleTuple() callback.
2032
+ */
2033
+ static inline bool
2034
+ table_scan_sample_next_tuple(TableScanDesc scan,
2035
+ struct SampleScanState *scanstate,
2036
+ TupleTableSlot *slot)
2037
+ {
2038
+ /*
2039
+ * We don't expect direct calls to table_scan_sample_next_tuple with valid
2040
+ * CheckXidAlive for catalog or regular tables. See detailed comments in
2041
+ * xact.c where these variables are declared.
2042
+ */
2043
+ if (unlikely(TransactionIdIsValid(CheckXidAlive) && !bsysscan))
2044
+ elog(ERROR, "unexpected table_scan_sample_next_tuple call during logical decoding");
2045
+ return scan->rs_rd->rd_tableam->scan_sample_next_tuple(scan, scanstate,
2046
+ slot);
2047
+ }
2048
+
2049
+
2050
+ /* ----------------------------------------------------------------------------
2051
+ * Functions to make modifications a bit simpler.
2052
+ * ----------------------------------------------------------------------------
2053
+ */
2054
+
2055
+ extern void simple_table_tuple_insert(Relation rel, TupleTableSlot *slot);
2056
+ extern void simple_table_tuple_delete(Relation rel, ItemPointer tid,
2057
+ Snapshot snapshot);
2058
+ extern void simple_table_tuple_update(Relation rel, ItemPointer otid,
2059
+ TupleTableSlot *slot, Snapshot snapshot,
2060
+ TU_UpdateIndexes *update_indexes);
2061
+
2062
+
2063
+ /* ----------------------------------------------------------------------------
2064
+ * Helper functions to implement parallel scans for block oriented AMs.
2065
+ * ----------------------------------------------------------------------------
2066
+ */
2067
+
2068
+ extern Size table_block_parallelscan_estimate(Relation rel);
2069
+ extern Size table_block_parallelscan_initialize(Relation rel,
2070
+ ParallelTableScanDesc pscan);
2071
+ extern void table_block_parallelscan_reinitialize(Relation rel,
2072
+ ParallelTableScanDesc pscan);
2073
+ extern BlockNumber table_block_parallelscan_nextpage(Relation rel,
2074
+ ParallelBlockTableScanWorker pbscanwork,
2075
+ ParallelBlockTableScanDesc pbscan);
2076
+ extern void table_block_parallelscan_startblock_init(Relation rel,
2077
+ ParallelBlockTableScanWorker pbscanwork,
2078
+ ParallelBlockTableScanDesc pbscan);
2079
+
2080
+
2081
+ /* ----------------------------------------------------------------------------
2082
+ * Helper functions to implement relation sizing for block oriented AMs.
2083
+ * ----------------------------------------------------------------------------
2084
+ */
2085
+
2086
+ extern uint64 table_block_relation_size(Relation rel, ForkNumber forkNumber);
2087
+ extern void table_block_relation_estimate_size(Relation rel,
2088
+ int32 *attr_widths,
2089
+ BlockNumber *pages,
2090
+ double *tuples,
2091
+ double *allvisfrac,
2092
+ Size overhead_bytes_per_tuple,
2093
+ Size usable_bytes_per_page);
2094
+
2095
+ /* ----------------------------------------------------------------------------
2096
+ * Functions in tableamapi.c
2097
+ * ----------------------------------------------------------------------------
2098
+ */
2099
+
2100
+ extern const TableAmRoutine *GetTableAmRoutine(Oid amhandler);
2101
+
2102
+ /* ----------------------------------------------------------------------------
2103
+ * Functions in heapam_handler.c
2104
+ * ----------------------------------------------------------------------------
2105
+ */
2106
+
2107
+ extern const TableAmRoutine *GetHeapamTableAmRoutine(void);
2108
+
2109
+ #endif /* TABLEAM_H */