pg_query 2.2.0 → 6.1.0

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