pg_query 4.2.1 → 6.1.0

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