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
@@ -0,0 +1,2855 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * execnodes.h
4
+ * definitions for executor state nodes
5
+ *
6
+ * Most plan node types declared in plannodes.h have a corresponding
7
+ * execution-state node type declared here. An exception is that
8
+ * expression nodes (subtypes of Expr) are usually represented by steps
9
+ * of an ExprState, and fully handled within execExpr* - but sometimes
10
+ * their state needs to be shared with other parts of the executor, as
11
+ * for example with SubPlanState, which nodeSubplan.c has to modify.
12
+ *
13
+ * Node types declared in this file do not have any copy/equal/out/read
14
+ * support. (That is currently hard-wired in gen_node_support.pl, rather
15
+ * than being explicitly represented by pg_node_attr decorations here.)
16
+ * There is no need for copy, equal, or read support for executor trees.
17
+ * Output support could be useful for debugging; but there are a lot of
18
+ * specialized fields that would require custom code, so for now it's
19
+ * not provided.
20
+ *
21
+ *
22
+ * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
23
+ * Portions Copyright (c) 1994, Regents of the University of California
24
+ *
25
+ * src/include/nodes/execnodes.h
26
+ *
27
+ *-------------------------------------------------------------------------
28
+ */
29
+ #ifndef EXECNODES_H
30
+ #define EXECNODES_H
31
+
32
+ #include "access/tupconvert.h"
33
+ #include "executor/instrument.h"
34
+ #include "fmgr.h"
35
+ #include "lib/ilist.h"
36
+ #include "lib/pairingheap.h"
37
+ #include "nodes/miscnodes.h"
38
+ #include "nodes/params.h"
39
+ #include "nodes/plannodes.h"
40
+ #include "nodes/tidbitmap.h"
41
+ #include "partitioning/partdefs.h"
42
+ #include "storage/condition_variable.h"
43
+ #include "utils/hsearch.h"
44
+ #include "utils/queryenvironment.h"
45
+ #include "utils/reltrigger.h"
46
+ #include "utils/sharedtuplestore.h"
47
+ #include "utils/snapshot.h"
48
+ #include "utils/sortsupport.h"
49
+ #include "utils/tuplesort.h"
50
+ #include "utils/tuplestore.h"
51
+
52
+ struct PlanState; /* forward references in this file */
53
+ struct ParallelHashJoinState;
54
+ struct ExecRowMark;
55
+ struct ExprState;
56
+ struct ExprContext;
57
+ struct RangeTblEntry; /* avoid including parsenodes.h here */
58
+ struct ExprEvalStep; /* avoid including execExpr.h everywhere */
59
+ struct CopyMultiInsertBuffer;
60
+ struct LogicalTapeSet;
61
+
62
+
63
+ /* ----------------
64
+ * ExprState node
65
+ *
66
+ * ExprState represents the evaluation state for a whole expression tree.
67
+ * It contains instructions (in ->steps) to evaluate the expression.
68
+ * ----------------
69
+ */
70
+ typedef Datum (*ExprStateEvalFunc) (struct ExprState *expression,
71
+ struct ExprContext *econtext,
72
+ bool *isNull);
73
+
74
+ /* Bits in ExprState->flags (see also execExpr.h for private flag bits): */
75
+ /* expression is for use with ExecQual() */
76
+ #define EEO_FLAG_IS_QUAL (1 << 0)
77
+
78
+ typedef struct ExprState
79
+ {
80
+ NodeTag type;
81
+
82
+ uint8 flags; /* bitmask of EEO_FLAG_* bits, see above */
83
+
84
+ /*
85
+ * Storage for result value of a scalar expression, or for individual
86
+ * column results within expressions built by ExecBuildProjectionInfo().
87
+ */
88
+ #define FIELDNO_EXPRSTATE_RESNULL 2
89
+ bool resnull;
90
+ #define FIELDNO_EXPRSTATE_RESVALUE 3
91
+ Datum resvalue;
92
+
93
+ /*
94
+ * If projecting a tuple result, this slot holds the result; else NULL.
95
+ */
96
+ #define FIELDNO_EXPRSTATE_RESULTSLOT 4
97
+ TupleTableSlot *resultslot;
98
+
99
+ /*
100
+ * Instructions to compute expression's return value.
101
+ */
102
+ struct ExprEvalStep *steps;
103
+
104
+ /*
105
+ * Function that actually evaluates the expression. This can be set to
106
+ * different values depending on the complexity of the expression.
107
+ */
108
+ ExprStateEvalFunc evalfunc;
109
+
110
+ /* original expression tree, for debugging only */
111
+ Expr *expr;
112
+
113
+ /* private state for an evalfunc */
114
+ void *evalfunc_private;
115
+
116
+ /*
117
+ * XXX: following fields only needed during "compilation" (ExecInitExpr);
118
+ * could be thrown away afterwards.
119
+ */
120
+
121
+ int steps_len; /* number of steps currently */
122
+ int steps_alloc; /* allocated length of steps array */
123
+
124
+ #define FIELDNO_EXPRSTATE_PARENT 11
125
+ struct PlanState *parent; /* parent PlanState node, if any */
126
+ ParamListInfo ext_params; /* for compiling PARAM_EXTERN nodes */
127
+
128
+ Datum *innermost_caseval;
129
+ bool *innermost_casenull;
130
+
131
+ Datum *innermost_domainval;
132
+ bool *innermost_domainnull;
133
+
134
+ /*
135
+ * For expression nodes that support soft errors. Should be set to NULL if
136
+ * the caller wants errors to be thrown. Callers that do not want errors
137
+ * thrown should set it to a valid ErrorSaveContext before calling
138
+ * ExecInitExprRec().
139
+ */
140
+ ErrorSaveContext *escontext;
141
+ } ExprState;
142
+
143
+
144
+ /* ----------------
145
+ * IndexInfo information
146
+ *
147
+ * this struct holds the information needed to construct new index
148
+ * entries for a particular index. Used for both index_build and
149
+ * retail creation of index entries.
150
+ *
151
+ * NumIndexAttrs total number of columns in this index
152
+ * NumIndexKeyAttrs number of key columns in index
153
+ * IndexAttrNumbers underlying-rel attribute numbers used as keys
154
+ * (zeroes indicate expressions). It also contains
155
+ * info about included columns.
156
+ * Expressions expr trees for expression entries, or NIL if none
157
+ * ExpressionsState exec state for expressions, or NIL if none
158
+ * Predicate partial-index predicate, or NIL if none
159
+ * PredicateState exec state for predicate, or NIL if none
160
+ * ExclusionOps Per-column exclusion operators, or NULL if none
161
+ * ExclusionProcs Underlying function OIDs for ExclusionOps
162
+ * ExclusionStrats Opclass strategy numbers for ExclusionOps
163
+ * UniqueOps These are like Exclusion*, but for unique indexes
164
+ * UniqueProcs
165
+ * UniqueStrats
166
+ * Unique is it a unique index?
167
+ * OpclassOptions opclass-specific options, or NULL if none
168
+ * ReadyForInserts is it valid for inserts?
169
+ * CheckedUnchanged IndexUnchanged status determined yet?
170
+ * IndexUnchanged aminsert hint, cached for retail inserts
171
+ * Concurrent are we doing a concurrent index build?
172
+ * BrokenHotChain did we detect any broken HOT chains?
173
+ * Summarizing is it a summarizing index?
174
+ * ParallelWorkers # of workers requested (excludes leader)
175
+ * Am Oid of index AM
176
+ * AmCache private cache area for index AM
177
+ * Context memory context holding this IndexInfo
178
+ *
179
+ * ii_Concurrent, ii_BrokenHotChain, and ii_ParallelWorkers are used only
180
+ * during index build; they're conventionally zeroed otherwise.
181
+ * ----------------
182
+ */
183
+ typedef struct IndexInfo
184
+ {
185
+ NodeTag type;
186
+ int ii_NumIndexAttrs; /* total number of columns in index */
187
+ int ii_NumIndexKeyAttrs; /* number of key columns in index */
188
+ AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS];
189
+ List *ii_Expressions; /* list of Expr */
190
+ List *ii_ExpressionsState; /* list of ExprState */
191
+ List *ii_Predicate; /* list of Expr */
192
+ ExprState *ii_PredicateState;
193
+ Oid *ii_ExclusionOps; /* array with one entry per column */
194
+ Oid *ii_ExclusionProcs; /* array with one entry per column */
195
+ uint16 *ii_ExclusionStrats; /* array with one entry per column */
196
+ Oid *ii_UniqueOps; /* array with one entry per column */
197
+ Oid *ii_UniqueProcs; /* array with one entry per column */
198
+ uint16 *ii_UniqueStrats; /* array with one entry per column */
199
+ bool ii_Unique;
200
+ bool ii_NullsNotDistinct;
201
+ bool ii_ReadyForInserts;
202
+ bool ii_CheckedUnchanged;
203
+ bool ii_IndexUnchanged;
204
+ bool ii_Concurrent;
205
+ bool ii_BrokenHotChain;
206
+ bool ii_Summarizing;
207
+ int ii_ParallelWorkers;
208
+ Oid ii_Am;
209
+ void *ii_AmCache;
210
+ MemoryContext ii_Context;
211
+ } IndexInfo;
212
+
213
+ /* ----------------
214
+ * ExprContext_CB
215
+ *
216
+ * List of callbacks to be called at ExprContext shutdown.
217
+ * ----------------
218
+ */
219
+ typedef void (*ExprContextCallbackFunction) (Datum arg);
220
+
221
+ typedef struct ExprContext_CB
222
+ {
223
+ struct ExprContext_CB *next;
224
+ ExprContextCallbackFunction function;
225
+ Datum arg;
226
+ } ExprContext_CB;
227
+
228
+ /* ----------------
229
+ * ExprContext
230
+ *
231
+ * This class holds the "current context" information
232
+ * needed to evaluate expressions for doing tuple qualifications
233
+ * and tuple projections. For example, if an expression refers
234
+ * to an attribute in the current inner tuple then we need to know
235
+ * what the current inner tuple is and so we look at the expression
236
+ * context.
237
+ *
238
+ * There are two memory contexts associated with an ExprContext:
239
+ * * ecxt_per_query_memory is a query-lifespan context, typically the same
240
+ * context the ExprContext node itself is allocated in. This context
241
+ * can be used for purposes such as storing function call cache info.
242
+ * * ecxt_per_tuple_memory is a short-term context for expression results.
243
+ * As the name suggests, it will typically be reset once per tuple,
244
+ * before we begin to evaluate expressions for that tuple. Each
245
+ * ExprContext normally has its very own per-tuple memory context.
246
+ *
247
+ * CurrentMemoryContext should be set to ecxt_per_tuple_memory before
248
+ * calling ExecEvalExpr() --- see ExecEvalExprSwitchContext().
249
+ * ----------------
250
+ */
251
+ typedef struct ExprContext
252
+ {
253
+ NodeTag type;
254
+
255
+ /* Tuples that Var nodes in expression may refer to */
256
+ #define FIELDNO_EXPRCONTEXT_SCANTUPLE 1
257
+ TupleTableSlot *ecxt_scantuple;
258
+ #define FIELDNO_EXPRCONTEXT_INNERTUPLE 2
259
+ TupleTableSlot *ecxt_innertuple;
260
+ #define FIELDNO_EXPRCONTEXT_OUTERTUPLE 3
261
+ TupleTableSlot *ecxt_outertuple;
262
+
263
+ /* Memory contexts for expression evaluation --- see notes above */
264
+ MemoryContext ecxt_per_query_memory;
265
+ MemoryContext ecxt_per_tuple_memory;
266
+
267
+ /* Values to substitute for Param nodes in expression */
268
+ ParamExecData *ecxt_param_exec_vals; /* for PARAM_EXEC params */
269
+ ParamListInfo ecxt_param_list_info; /* for other param types */
270
+
271
+ /*
272
+ * Values to substitute for Aggref nodes in the expressions of an Agg
273
+ * node, or for WindowFunc nodes within a WindowAgg node.
274
+ */
275
+ #define FIELDNO_EXPRCONTEXT_AGGVALUES 8
276
+ Datum *ecxt_aggvalues; /* precomputed values for aggs/windowfuncs */
277
+ #define FIELDNO_EXPRCONTEXT_AGGNULLS 9
278
+ bool *ecxt_aggnulls; /* null flags for aggs/windowfuncs */
279
+
280
+ /* Value to substitute for CaseTestExpr nodes in expression */
281
+ #define FIELDNO_EXPRCONTEXT_CASEDATUM 10
282
+ Datum caseValue_datum;
283
+ #define FIELDNO_EXPRCONTEXT_CASENULL 11
284
+ bool caseValue_isNull;
285
+
286
+ /* Value to substitute for CoerceToDomainValue nodes in expression */
287
+ #define FIELDNO_EXPRCONTEXT_DOMAINDATUM 12
288
+ Datum domainValue_datum;
289
+ #define FIELDNO_EXPRCONTEXT_DOMAINNULL 13
290
+ bool domainValue_isNull;
291
+
292
+ /* Link to containing EState (NULL if a standalone ExprContext) */
293
+ struct EState *ecxt_estate;
294
+
295
+ /* Functions to call back when ExprContext is shut down or rescanned */
296
+ ExprContext_CB *ecxt_callbacks;
297
+ } ExprContext;
298
+
299
+ /*
300
+ * Set-result status used when evaluating functions potentially returning a
301
+ * set.
302
+ */
303
+ typedef enum
304
+ {
305
+ ExprSingleResult, /* expression does not return a set */
306
+ ExprMultipleResult, /* this result is an element of a set */
307
+ ExprEndResult, /* there are no more elements in the set */
308
+ } ExprDoneCond;
309
+
310
+ /*
311
+ * Return modes for functions returning sets. Note values must be chosen
312
+ * as separate bits so that a bitmask can be formed to indicate supported
313
+ * modes. SFRM_Materialize_Random and SFRM_Materialize_Preferred are
314
+ * auxiliary flags about SFRM_Materialize mode, rather than separate modes.
315
+ */
316
+ typedef enum
317
+ {
318
+ SFRM_ValuePerCall = 0x01, /* one value returned per call */
319
+ SFRM_Materialize = 0x02, /* result set instantiated in Tuplestore */
320
+ SFRM_Materialize_Random = 0x04, /* Tuplestore needs randomAccess */
321
+ SFRM_Materialize_Preferred = 0x08, /* caller prefers Tuplestore */
322
+ } SetFunctionReturnMode;
323
+
324
+ /*
325
+ * When calling a function that might return a set (multiple rows),
326
+ * a node of this type is passed as fcinfo->resultinfo to allow
327
+ * return status to be passed back. A function returning set should
328
+ * raise an error if no such resultinfo is provided.
329
+ */
330
+ typedef struct ReturnSetInfo
331
+ {
332
+ NodeTag type;
333
+ /* values set by caller: */
334
+ ExprContext *econtext; /* context function is being called in */
335
+ TupleDesc expectedDesc; /* tuple descriptor expected by caller */
336
+ int allowedModes; /* bitmask: return modes caller can handle */
337
+ /* result status from function (but pre-initialized by caller): */
338
+ SetFunctionReturnMode returnMode; /* actual return mode */
339
+ ExprDoneCond isDone; /* status for ValuePerCall mode */
340
+ /* fields filled by function in Materialize return mode: */
341
+ Tuplestorestate *setResult; /* holds the complete returned tuple set */
342
+ TupleDesc setDesc; /* actual descriptor for returned tuples */
343
+ } ReturnSetInfo;
344
+
345
+ /* ----------------
346
+ * ProjectionInfo node information
347
+ *
348
+ * This is all the information needed to perform projections ---
349
+ * that is, form new tuples by evaluation of targetlist expressions.
350
+ * Nodes which need to do projections create one of these.
351
+ *
352
+ * The target tuple slot is kept in ProjectionInfo->pi_state.resultslot.
353
+ * ExecProject() evaluates the tlist, forms a tuple, and stores it
354
+ * in the given slot. Note that the result will be a "virtual" tuple
355
+ * unless ExecMaterializeSlot() is then called to force it to be
356
+ * converted to a physical tuple. The slot must have a tupledesc
357
+ * that matches the output of the tlist!
358
+ * ----------------
359
+ */
360
+ typedef struct ProjectionInfo
361
+ {
362
+ NodeTag type;
363
+ /* instructions to evaluate projection */
364
+ ExprState pi_state;
365
+ /* expression context in which to evaluate expression */
366
+ ExprContext *pi_exprContext;
367
+ } ProjectionInfo;
368
+
369
+ /* ----------------
370
+ * JunkFilter
371
+ *
372
+ * This class is used to store information regarding junk attributes.
373
+ * A junk attribute is an attribute in a tuple that is needed only for
374
+ * storing intermediate information in the executor, and does not belong
375
+ * in emitted tuples. For example, when we do an UPDATE query,
376
+ * the planner adds a "junk" entry to the targetlist so that the tuples
377
+ * returned to ExecutePlan() contain an extra attribute: the ctid of
378
+ * the tuple to be updated. This is needed to do the update, but we
379
+ * don't want the ctid to be part of the stored new tuple! So, we
380
+ * apply a "junk filter" to remove the junk attributes and form the
381
+ * real output tuple. The junkfilter code also provides routines to
382
+ * extract the values of the junk attribute(s) from the input tuple.
383
+ *
384
+ * targetList: the original target list (including junk attributes).
385
+ * cleanTupType: the tuple descriptor for the "clean" tuple (with
386
+ * junk attributes removed).
387
+ * cleanMap: A map with the correspondence between the non-junk
388
+ * attribute numbers of the "original" tuple and the
389
+ * attribute numbers of the "clean" tuple.
390
+ * resultSlot: tuple slot used to hold cleaned tuple.
391
+ * ----------------
392
+ */
393
+ typedef struct JunkFilter
394
+ {
395
+ NodeTag type;
396
+ List *jf_targetList;
397
+ TupleDesc jf_cleanTupType;
398
+ AttrNumber *jf_cleanMap;
399
+ TupleTableSlot *jf_resultSlot;
400
+ } JunkFilter;
401
+
402
+ /*
403
+ * OnConflictSetState
404
+ *
405
+ * Executor state of an ON CONFLICT DO UPDATE operation.
406
+ */
407
+ typedef struct OnConflictSetState
408
+ {
409
+ NodeTag type;
410
+
411
+ TupleTableSlot *oc_Existing; /* slot to store existing target tuple in */
412
+ TupleTableSlot *oc_ProjSlot; /* CONFLICT ... SET ... projection target */
413
+ ProjectionInfo *oc_ProjInfo; /* for ON CONFLICT DO UPDATE SET */
414
+ ExprState *oc_WhereClause; /* state for the WHERE clause */
415
+ } OnConflictSetState;
416
+
417
+ /* ----------------
418
+ * MergeActionState information
419
+ *
420
+ * Executor state for a MERGE action.
421
+ * ----------------
422
+ */
423
+ typedef struct MergeActionState
424
+ {
425
+ NodeTag type;
426
+
427
+ MergeAction *mas_action; /* associated MergeAction node */
428
+ ProjectionInfo *mas_proj; /* projection of the action's targetlist for
429
+ * this rel */
430
+ ExprState *mas_whenqual; /* WHEN [NOT] MATCHED AND conditions */
431
+ } MergeActionState;
432
+
433
+ /*
434
+ * ResultRelInfo
435
+ *
436
+ * Whenever we update an existing relation, we have to update indexes on the
437
+ * relation, and perhaps also fire triggers. ResultRelInfo holds all the
438
+ * information needed about a result relation, including indexes.
439
+ *
440
+ * Normally, a ResultRelInfo refers to a table that is in the query's range
441
+ * table; then ri_RangeTableIndex is the RT index and ri_RelationDesc is
442
+ * just a copy of the relevant es_relations[] entry. However, in some
443
+ * situations we create ResultRelInfos for relations that are not in the
444
+ * range table, namely for targets of tuple routing in a partitioned table,
445
+ * and when firing triggers in tables other than the target tables (See
446
+ * ExecGetTriggerResultRel). In these situations, ri_RangeTableIndex is 0
447
+ * and ri_RelationDesc is a separately-opened relcache pointer that needs to
448
+ * be separately closed.
449
+ */
450
+ typedef struct ResultRelInfo
451
+ {
452
+ NodeTag type;
453
+
454
+ /* result relation's range table index, or 0 if not in range table */
455
+ Index ri_RangeTableIndex;
456
+
457
+ /* relation descriptor for result relation */
458
+ Relation ri_RelationDesc;
459
+
460
+ /* # of indices existing on result relation */
461
+ int ri_NumIndices;
462
+
463
+ /* array of relation descriptors for indices */
464
+ RelationPtr ri_IndexRelationDescs;
465
+
466
+ /* array of key/attr info for indices */
467
+ IndexInfo **ri_IndexRelationInfo;
468
+
469
+ /*
470
+ * For UPDATE/DELETE result relations, the attribute number of the row
471
+ * identity junk attribute in the source plan's output tuples
472
+ */
473
+ AttrNumber ri_RowIdAttNo;
474
+
475
+ /* For UPDATE, attnums of generated columns to be computed */
476
+ Bitmapset *ri_extraUpdatedCols;
477
+
478
+ /* Projection to generate new tuple in an INSERT/UPDATE */
479
+ ProjectionInfo *ri_projectNew;
480
+ /* Slot to hold that tuple */
481
+ TupleTableSlot *ri_newTupleSlot;
482
+ /* Slot to hold the old tuple being updated */
483
+ TupleTableSlot *ri_oldTupleSlot;
484
+ /* Have the projection and the slots above been initialized? */
485
+ bool ri_projectNewInfoValid;
486
+
487
+ /* updates do LockTuple() before oldtup read; see README.tuplock */
488
+ bool ri_needLockTagTuple;
489
+
490
+ /* triggers to be fired, if any */
491
+ TriggerDesc *ri_TrigDesc;
492
+
493
+ /* cached lookup info for trigger functions */
494
+ FmgrInfo *ri_TrigFunctions;
495
+
496
+ /* array of trigger WHEN expr states */
497
+ ExprState **ri_TrigWhenExprs;
498
+
499
+ /* optional runtime measurements for triggers */
500
+ Instrumentation *ri_TrigInstrument;
501
+
502
+ /* On-demand created slots for triggers / returning processing */
503
+ TupleTableSlot *ri_ReturningSlot; /* for trigger output tuples */
504
+ TupleTableSlot *ri_TrigOldSlot; /* for a trigger's old tuple */
505
+ TupleTableSlot *ri_TrigNewSlot; /* for a trigger's new tuple */
506
+
507
+ /* FDW callback functions, if foreign table */
508
+ struct FdwRoutine *ri_FdwRoutine;
509
+
510
+ /* available to save private state of FDW */
511
+ void *ri_FdwState;
512
+
513
+ /* true when modifying foreign table directly */
514
+ bool ri_usesFdwDirectModify;
515
+
516
+ /* batch insert stuff */
517
+ int ri_NumSlots; /* number of slots in the array */
518
+ int ri_NumSlotsInitialized; /* number of initialized slots */
519
+ int ri_BatchSize; /* max slots inserted in a single batch */
520
+ TupleTableSlot **ri_Slots; /* input tuples for batch insert */
521
+ TupleTableSlot **ri_PlanSlots;
522
+
523
+ /* list of WithCheckOption's to be checked */
524
+ List *ri_WithCheckOptions;
525
+
526
+ /* list of WithCheckOption expr states */
527
+ List *ri_WithCheckOptionExprs;
528
+
529
+ /* array of constraint-checking expr states */
530
+ ExprState **ri_ConstraintExprs;
531
+
532
+ /* arrays of stored generated columns expr states, for INSERT and UPDATE */
533
+ ExprState **ri_GeneratedExprsI;
534
+ ExprState **ri_GeneratedExprsU;
535
+
536
+ /* number of stored generated columns we need to compute */
537
+ int ri_NumGeneratedNeededI;
538
+ int ri_NumGeneratedNeededU;
539
+
540
+ /* list of RETURNING expressions */
541
+ List *ri_returningList;
542
+
543
+ /* for computing a RETURNING list */
544
+ ProjectionInfo *ri_projectReturning;
545
+
546
+ /* list of arbiter indexes to use to check conflicts */
547
+ List *ri_onConflictArbiterIndexes;
548
+
549
+ /* ON CONFLICT evaluation state */
550
+ OnConflictSetState *ri_onConflict;
551
+
552
+ /* for MERGE, lists of MergeActionState (one per MergeMatchKind) */
553
+ List *ri_MergeActions[NUM_MERGE_MATCH_KINDS];
554
+
555
+ /* for MERGE, expr state for checking the join condition */
556
+ ExprState *ri_MergeJoinCondition;
557
+
558
+ /* partition check expression state (NULL if not set up yet) */
559
+ ExprState *ri_PartitionCheckExpr;
560
+
561
+ /*
562
+ * Map to convert child result relation tuples to the format of the table
563
+ * actually mentioned in the query (called "root"). Computed only if
564
+ * needed. A NULL map value indicates that no conversion is needed, so we
565
+ * must have a separate flag to show if the map has been computed.
566
+ */
567
+ TupleConversionMap *ri_ChildToRootMap;
568
+ bool ri_ChildToRootMapValid;
569
+
570
+ /*
571
+ * As above, but in the other direction.
572
+ */
573
+ TupleConversionMap *ri_RootToChildMap;
574
+ bool ri_RootToChildMapValid;
575
+
576
+ /*
577
+ * Information needed by tuple routing target relations
578
+ *
579
+ * RootResultRelInfo gives the target relation mentioned in the query, if
580
+ * it's a partitioned table. It is not set if the target relation
581
+ * mentioned in the query is an inherited table, nor when tuple routing is
582
+ * not needed.
583
+ *
584
+ * PartitionTupleSlot is non-NULL if RootToChild conversion is needed and
585
+ * the relation is a partition.
586
+ */
587
+ struct ResultRelInfo *ri_RootResultRelInfo;
588
+ TupleTableSlot *ri_PartitionTupleSlot;
589
+
590
+ /* for use by copyfrom.c when performing multi-inserts */
591
+ struct CopyMultiInsertBuffer *ri_CopyMultiInsertBuffer;
592
+
593
+ /*
594
+ * Used when a leaf partition is involved in a cross-partition update of
595
+ * one of its ancestors; see ExecCrossPartitionUpdateForeignKey().
596
+ */
597
+ List *ri_ancestorResultRels;
598
+ } ResultRelInfo;
599
+
600
+ /* ----------------
601
+ * AsyncRequest
602
+ *
603
+ * State for an asynchronous tuple request.
604
+ * ----------------
605
+ */
606
+ typedef struct AsyncRequest
607
+ {
608
+ struct PlanState *requestor; /* Node that wants a tuple */
609
+ struct PlanState *requestee; /* Node from which a tuple is wanted */
610
+ int request_index; /* Scratch space for requestor */
611
+ bool callback_pending; /* Callback is needed */
612
+ bool request_complete; /* Request complete, result valid */
613
+ TupleTableSlot *result; /* Result (NULL or an empty slot if no more
614
+ * tuples) */
615
+ } AsyncRequest;
616
+
617
+ /* ----------------
618
+ * EState information
619
+ *
620
+ * Working state for an Executor invocation
621
+ * ----------------
622
+ */
623
+ typedef struct EState
624
+ {
625
+ NodeTag type;
626
+
627
+ /* Basic state for all query types: */
628
+ ScanDirection es_direction; /* current scan direction */
629
+ Snapshot es_snapshot; /* time qual to use */
630
+ Snapshot es_crosscheck_snapshot; /* crosscheck time qual for RI */
631
+ List *es_range_table; /* List of RangeTblEntry */
632
+ Index es_range_table_size; /* size of the range table arrays */
633
+ Relation *es_relations; /* Array of per-range-table-entry Relation
634
+ * pointers, or NULL if not yet opened */
635
+ struct ExecRowMark **es_rowmarks; /* Array of per-range-table-entry
636
+ * ExecRowMarks, or NULL if none */
637
+ List *es_rteperminfos; /* List of RTEPermissionInfo */
638
+ PlannedStmt *es_plannedstmt; /* link to top of plan tree */
639
+ const char *es_sourceText; /* Source text from QueryDesc */
640
+
641
+ JunkFilter *es_junkFilter; /* top-level junk filter, if any */
642
+
643
+ /* If query can insert/delete tuples, the command ID to mark them with */
644
+ CommandId es_output_cid;
645
+
646
+ /* Info about target table(s) for insert/update/delete queries: */
647
+ ResultRelInfo **es_result_relations; /* Array of per-range-table-entry
648
+ * ResultRelInfo pointers, or NULL
649
+ * if not a target table */
650
+ List *es_opened_result_relations; /* List of non-NULL entries in
651
+ * es_result_relations in no
652
+ * specific order */
653
+
654
+ PartitionDirectory es_partition_directory; /* for PartitionDesc lookup */
655
+
656
+ /*
657
+ * The following list contains ResultRelInfos created by the tuple routing
658
+ * code for partitions that aren't found in the es_result_relations array.
659
+ */
660
+ List *es_tuple_routing_result_relations;
661
+
662
+ /* Stuff used for firing triggers: */
663
+ List *es_trig_target_relations; /* trigger-only ResultRelInfos */
664
+
665
+ /* Parameter info: */
666
+ ParamListInfo es_param_list_info; /* values of external params */
667
+ ParamExecData *es_param_exec_vals; /* values of internal params */
668
+
669
+ QueryEnvironment *es_queryEnv; /* query environment */
670
+
671
+ /* Other working state: */
672
+ MemoryContext es_query_cxt; /* per-query context in which EState lives */
673
+
674
+ List *es_tupleTable; /* List of TupleTableSlots */
675
+
676
+ uint64 es_processed; /* # of tuples processed during one
677
+ * ExecutorRun() call. */
678
+ uint64 es_total_processed; /* total # of tuples aggregated across all
679
+ * ExecutorRun() calls. */
680
+
681
+ int es_top_eflags; /* eflags passed to ExecutorStart */
682
+ int es_instrument; /* OR of InstrumentOption flags */
683
+ bool es_finished; /* true when ExecutorFinish is done */
684
+
685
+ List *es_exprcontexts; /* List of ExprContexts within EState */
686
+
687
+ List *es_subplanstates; /* List of PlanState for SubPlans */
688
+
689
+ List *es_auxmodifytables; /* List of secondary ModifyTableStates */
690
+
691
+ /*
692
+ * this ExprContext is for per-output-tuple operations, such as constraint
693
+ * checks and index-value computations. It will be reset for each output
694
+ * tuple. Note that it will be created only if needed.
695
+ */
696
+ ExprContext *es_per_tuple_exprcontext;
697
+
698
+ /*
699
+ * If not NULL, this is an EPQState's EState. This is a field in EState
700
+ * both to allow EvalPlanQual aware executor nodes to detect that they
701
+ * need to perform EPQ related work, and to provide necessary information
702
+ * to do so.
703
+ */
704
+ struct EPQState *es_epq_active;
705
+
706
+ bool es_use_parallel_mode; /* can we use parallel workers? */
707
+
708
+ /* The per-query shared memory area to use for parallel execution. */
709
+ struct dsa_area *es_query_dsa;
710
+
711
+ /*
712
+ * JIT information. es_jit_flags indicates whether JIT should be performed
713
+ * and with which options. es_jit is created on-demand when JITing is
714
+ * performed.
715
+ *
716
+ * es_jit_worker_instr is the combined, on demand allocated,
717
+ * instrumentation from all workers. The leader's instrumentation is kept
718
+ * separate, and is combined on demand by ExplainPrintJITSummary().
719
+ */
720
+ int es_jit_flags;
721
+ struct JitContext *es_jit;
722
+ struct JitInstrumentation *es_jit_worker_instr;
723
+
724
+ /*
725
+ * Lists of ResultRelInfos for foreign tables on which batch-inserts are
726
+ * to be executed and owning ModifyTableStates, stored in the same order.
727
+ */
728
+ List *es_insert_pending_result_relations;
729
+ List *es_insert_pending_modifytables;
730
+ } EState;
731
+
732
+
733
+ /*
734
+ * ExecRowMark -
735
+ * runtime representation of FOR [KEY] UPDATE/SHARE clauses
736
+ *
737
+ * When doing UPDATE/DELETE/MERGE/SELECT FOR [KEY] UPDATE/SHARE, we will have
738
+ * an ExecRowMark for each non-target relation in the query (except inheritance
739
+ * parent RTEs, which can be ignored at runtime). Virtual relations such as
740
+ * subqueries-in-FROM will have an ExecRowMark with relation == NULL. See
741
+ * PlanRowMark for details about most of the fields. In addition to fields
742
+ * directly derived from PlanRowMark, we store an activity flag (to denote
743
+ * inactive children of inheritance trees), curCtid, which is used by the
744
+ * WHERE CURRENT OF code, and ermExtra, which is available for use by the plan
745
+ * node that sources the relation (e.g., for a foreign table the FDW can use
746
+ * ermExtra to hold information).
747
+ *
748
+ * EState->es_rowmarks is an array of these structs, indexed by RT index,
749
+ * with NULLs for irrelevant RT indexes. es_rowmarks itself is NULL if
750
+ * there are no rowmarks.
751
+ */
752
+ typedef struct ExecRowMark
753
+ {
754
+ Relation relation; /* opened and suitably locked relation */
755
+ Oid relid; /* its OID (or InvalidOid, if subquery) */
756
+ Index rti; /* its range table index */
757
+ Index prti; /* parent range table index, if child */
758
+ Index rowmarkId; /* unique identifier for resjunk columns */
759
+ RowMarkType markType; /* see enum in nodes/plannodes.h */
760
+ LockClauseStrength strength; /* LockingClause's strength, or LCS_NONE */
761
+ LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
762
+ bool ermActive; /* is this mark relevant for current tuple? */
763
+ ItemPointerData curCtid; /* ctid of currently locked tuple, if any */
764
+ void *ermExtra; /* available for use by relation source node */
765
+ } ExecRowMark;
766
+
767
+ /*
768
+ * ExecAuxRowMark -
769
+ * additional runtime representation of FOR [KEY] UPDATE/SHARE clauses
770
+ *
771
+ * Each LockRows and ModifyTable node keeps a list of the rowmarks it needs to
772
+ * deal with. In addition to a pointer to the related entry in es_rowmarks,
773
+ * this struct carries the column number(s) of the resjunk columns associated
774
+ * with the rowmark (see comments for PlanRowMark for more detail).
775
+ */
776
+ typedef struct ExecAuxRowMark
777
+ {
778
+ ExecRowMark *rowmark; /* related entry in es_rowmarks */
779
+ AttrNumber ctidAttNo; /* resno of ctid junk attribute, if any */
780
+ AttrNumber toidAttNo; /* resno of tableoid junk attribute, if any */
781
+ AttrNumber wholeAttNo; /* resno of whole-row junk attribute, if any */
782
+ } ExecAuxRowMark;
783
+
784
+
785
+ /* ----------------------------------------------------------------
786
+ * Tuple Hash Tables
787
+ *
788
+ * All-in-memory tuple hash tables are used for a number of purposes.
789
+ *
790
+ * Note: tab_hash_funcs are for the key datatype(s) stored in the table,
791
+ * and tab_eq_funcs are non-cross-type equality operators for those types.
792
+ * Normally these are the only functions used, but FindTupleHashEntry()
793
+ * supports searching a hashtable using cross-data-type hashing. For that,
794
+ * the caller must supply hash functions for the LHS datatype as well as
795
+ * the cross-type equality operators to use. in_hash_funcs and cur_eq_func
796
+ * are set to point to the caller's function arrays while doing such a search.
797
+ * During LookupTupleHashEntry(), they point to tab_hash_funcs and
798
+ * tab_eq_func respectively.
799
+ * ----------------------------------------------------------------
800
+ */
801
+ typedef struct TupleHashEntryData *TupleHashEntry;
802
+ typedef struct TupleHashTableData *TupleHashTable;
803
+
804
+ typedef struct TupleHashEntryData
805
+ {
806
+ MinimalTuple firstTuple; /* copy of first tuple in this group */
807
+ void *additional; /* user data */
808
+ uint32 status; /* hash status */
809
+ uint32 hash; /* hash value (cached) */
810
+ } TupleHashEntryData;
811
+
812
+ /* define parameters necessary to generate the tuple hash table interface */
813
+ #define SH_PREFIX tuplehash
814
+ #define SH_ELEMENT_TYPE TupleHashEntryData
815
+ #define SH_KEY_TYPE MinimalTuple
816
+ #define SH_SCOPE extern
817
+ #define SH_DECLARE
818
+ #include "lib/simplehash.h"
819
+
820
+ typedef struct TupleHashTableData
821
+ {
822
+ tuplehash_hash *hashtab; /* underlying hash table */
823
+ int numCols; /* number of columns in lookup key */
824
+ AttrNumber *keyColIdx; /* attr numbers of key columns */
825
+ FmgrInfo *tab_hash_funcs; /* hash functions for table datatype(s) */
826
+ ExprState *tab_eq_func; /* comparator for table datatype(s) */
827
+ Oid *tab_collations; /* collations for hash and comparison */
828
+ MemoryContext tablecxt; /* memory context containing table */
829
+ MemoryContext tempcxt; /* context for function evaluations */
830
+ Size entrysize; /* actual size to make each hash entry */
831
+ TupleTableSlot *tableslot; /* slot for referencing table entries */
832
+ /* The following fields are set transiently for each table search: */
833
+ TupleTableSlot *inputslot; /* current input tuple's slot */
834
+ FmgrInfo *in_hash_funcs; /* hash functions for input datatype(s) */
835
+ ExprState *cur_eq_func; /* comparator for input vs. table */
836
+ uint32 hash_iv; /* hash-function IV */
837
+ ExprContext *exprcontext; /* expression context */
838
+ } TupleHashTableData;
839
+
840
+ typedef tuplehash_iterator TupleHashIterator;
841
+
842
+ /*
843
+ * Use InitTupleHashIterator/TermTupleHashIterator for a read/write scan.
844
+ * Use ResetTupleHashIterator if the table can be frozen (in this case no
845
+ * explicit scan termination is needed).
846
+ */
847
+ #define InitTupleHashIterator(htable, iter) \
848
+ tuplehash_start_iterate(htable->hashtab, iter)
849
+ #define TermTupleHashIterator(iter) \
850
+ ((void) 0)
851
+ #define ResetTupleHashIterator(htable, iter) \
852
+ InitTupleHashIterator(htable, iter)
853
+ #define ScanTupleHashTable(htable, iter) \
854
+ tuplehash_iterate(htable->hashtab, iter)
855
+
856
+
857
+ /* ----------------------------------------------------------------
858
+ * Expression State Nodes
859
+ *
860
+ * Formerly, there was a separate executor expression state node corresponding
861
+ * to each node in a planned expression tree. That's no longer the case; for
862
+ * common expression node types, all the execution info is embedded into
863
+ * step(s) in a single ExprState node. But we still have a few executor state
864
+ * node types for selected expression node types, mostly those in which info
865
+ * has to be shared with other parts of the execution state tree.
866
+ * ----------------------------------------------------------------
867
+ */
868
+
869
+ /* ----------------
870
+ * WindowFuncExprState node
871
+ * ----------------
872
+ */
873
+ typedef struct WindowFuncExprState
874
+ {
875
+ NodeTag type;
876
+ WindowFunc *wfunc; /* expression plan node */
877
+ List *args; /* ExprStates for argument expressions */
878
+ ExprState *aggfilter; /* FILTER expression */
879
+ int wfuncno; /* ID number for wfunc within its plan node */
880
+ } WindowFuncExprState;
881
+
882
+
883
+ /* ----------------
884
+ * SetExprState node
885
+ *
886
+ * State for evaluating a potentially set-returning expression (like FuncExpr
887
+ * or OpExpr). In some cases, like some of the expressions in ROWS FROM(...)
888
+ * the expression might not be a SRF, but nonetheless it uses the same
889
+ * machinery as SRFs; it will be treated as a SRF returning a single row.
890
+ * ----------------
891
+ */
892
+ typedef struct SetExprState
893
+ {
894
+ NodeTag type;
895
+ Expr *expr; /* expression plan node */
896
+ List *args; /* ExprStates for argument expressions */
897
+
898
+ /*
899
+ * In ROWS FROM, functions can be inlined, removing the FuncExpr normally
900
+ * inside. In such a case this is the compiled expression (which cannot
901
+ * return a set), which'll be evaluated using regular ExecEvalExpr().
902
+ */
903
+ ExprState *elidedFuncState;
904
+
905
+ /*
906
+ * Function manager's lookup info for the target function. If func.fn_oid
907
+ * is InvalidOid, we haven't initialized it yet (nor any of the following
908
+ * fields, except funcReturnsSet).
909
+ */
910
+ FmgrInfo func;
911
+
912
+ /*
913
+ * For a set-returning function (SRF) that returns a tuplestore, we keep
914
+ * the tuplestore here and dole out the result rows one at a time. The
915
+ * slot holds the row currently being returned.
916
+ */
917
+ Tuplestorestate *funcResultStore;
918
+ TupleTableSlot *funcResultSlot;
919
+
920
+ /*
921
+ * In some cases we need to compute a tuple descriptor for the function's
922
+ * output. If so, it's stored here.
923
+ */
924
+ TupleDesc funcResultDesc;
925
+ bool funcReturnsTuple; /* valid when funcResultDesc isn't NULL */
926
+
927
+ /*
928
+ * Remember whether the function is declared to return a set. This is set
929
+ * by ExecInitExpr, and is valid even before the FmgrInfo is set up.
930
+ */
931
+ bool funcReturnsSet;
932
+
933
+ /*
934
+ * setArgsValid is true when we are evaluating a set-returning function
935
+ * that uses value-per-call mode and we are in the middle of a call
936
+ * series; we want to pass the same argument values to the function again
937
+ * (and again, until it returns ExprEndResult). This indicates that
938
+ * fcinfo_data already contains valid argument data.
939
+ */
940
+ bool setArgsValid;
941
+
942
+ /*
943
+ * Flag to remember whether we have registered a shutdown callback for
944
+ * this SetExprState. We do so only if funcResultStore or setArgsValid
945
+ * has been set at least once (since all the callback is for is to release
946
+ * the tuplestore or clear setArgsValid).
947
+ */
948
+ bool shutdown_reg; /* a shutdown callback is registered */
949
+
950
+ /*
951
+ * Call parameter structure for the function. This has been initialized
952
+ * (by InitFunctionCallInfoData) if func.fn_oid is valid. It also saves
953
+ * argument values between calls, when setArgsValid is true.
954
+ */
955
+ FunctionCallInfo fcinfo;
956
+ } SetExprState;
957
+
958
+ /* ----------------
959
+ * SubPlanState node
960
+ * ----------------
961
+ */
962
+ typedef struct SubPlanState
963
+ {
964
+ NodeTag type;
965
+ SubPlan *subplan; /* expression plan node */
966
+ struct PlanState *planstate; /* subselect plan's state tree */
967
+ struct PlanState *parent; /* parent plan node's state tree */
968
+ ExprState *testexpr; /* state of combining expression */
969
+ List *args; /* states of argument expression(s) */
970
+ HeapTuple curTuple; /* copy of most recent tuple from subplan */
971
+ Datum curArray; /* most recent array from ARRAY() subplan */
972
+ /* these are used when hashing the subselect's output: */
973
+ TupleDesc descRight; /* subselect desc after projection */
974
+ ProjectionInfo *projLeft; /* for projecting lefthand exprs */
975
+ ProjectionInfo *projRight; /* for projecting subselect output */
976
+ TupleHashTable hashtable; /* hash table for no-nulls subselect rows */
977
+ TupleHashTable hashnulls; /* hash table for rows with null(s) */
978
+ bool havehashrows; /* true if hashtable is not empty */
979
+ bool havenullrows; /* true if hashnulls is not empty */
980
+ MemoryContext hashtablecxt; /* memory context containing hash tables */
981
+ MemoryContext hashtempcxt; /* temp memory context for hash tables */
982
+ ExprContext *innerecontext; /* econtext for computing inner tuples */
983
+ int numCols; /* number of columns being hashed */
984
+ /* each of the remaining fields is an array of length numCols: */
985
+ AttrNumber *keyColIdx; /* control data for hash tables */
986
+ Oid *tab_eq_funcoids; /* equality func oids for table
987
+ * datatype(s) */
988
+ Oid *tab_collations; /* collations for hash and comparison */
989
+ FmgrInfo *tab_hash_funcs; /* hash functions for table datatype(s) */
990
+ FmgrInfo *tab_eq_funcs; /* equality functions for table datatype(s) */
991
+ FmgrInfo *lhs_hash_funcs; /* hash functions for lefthand datatype(s) */
992
+ FmgrInfo *cur_eq_funcs; /* equality functions for LHS vs. table */
993
+ ExprState *cur_eq_comp; /* equality comparator for LHS vs. table */
994
+ } SubPlanState;
995
+
996
+ /*
997
+ * DomainConstraintState - one item to check during CoerceToDomain
998
+ *
999
+ * Note: we consider this to be part of an ExprState tree, so we give it
1000
+ * a name following the xxxState convention. But there's no directly
1001
+ * associated plan-tree node.
1002
+ */
1003
+ typedef enum DomainConstraintType
1004
+ {
1005
+ DOM_CONSTRAINT_NOTNULL,
1006
+ DOM_CONSTRAINT_CHECK,
1007
+ } DomainConstraintType;
1008
+
1009
+ typedef struct DomainConstraintState
1010
+ {
1011
+ NodeTag type;
1012
+ DomainConstraintType constrainttype; /* constraint type */
1013
+ char *name; /* name of constraint (for error msgs) */
1014
+ Expr *check_expr; /* for CHECK, a boolean expression */
1015
+ ExprState *check_exprstate; /* check_expr's eval state, or NULL */
1016
+ } DomainConstraintState;
1017
+
1018
+ /*
1019
+ * State for JsonExpr evaluation, too big to inline.
1020
+ *
1021
+ * This contains the information going into and coming out of the
1022
+ * EEOP_JSONEXPR_PATH eval step.
1023
+ */
1024
+ typedef struct JsonExprState
1025
+ {
1026
+ /* original expression node */
1027
+ JsonExpr *jsexpr;
1028
+
1029
+ /* value/isnull for formatted_expr */
1030
+ NullableDatum formatted_expr;
1031
+
1032
+ /* value/isnull for pathspec */
1033
+ NullableDatum pathspec;
1034
+
1035
+ /* JsonPathVariable entries for passing_values */
1036
+ List *args;
1037
+
1038
+ /*
1039
+ * Output variables that drive the EEOP_JUMP_IF_NOT_TRUE steps that are
1040
+ * added for ON ERROR and ON EMPTY expressions, if any.
1041
+ *
1042
+ * Reset for each evaluation of EEOP_JSONEXPR_PATH.
1043
+ */
1044
+
1045
+ /* Set to true if jsonpath evaluation cause an error. */
1046
+ NullableDatum error;
1047
+
1048
+ /* Set to true if the jsonpath evaluation returned 0 items. */
1049
+ NullableDatum empty;
1050
+
1051
+ /*
1052
+ * Addresses of steps that implement the non-ERROR variant of ON EMPTY and
1053
+ * ON ERROR behaviors, respectively.
1054
+ */
1055
+ int jump_empty;
1056
+ int jump_error;
1057
+
1058
+ /*
1059
+ * Address of the step to coerce the result value of jsonpath evaluation
1060
+ * to the RETURNING type. -1 if no coercion if JsonExpr.use_io_coercion
1061
+ * is true.
1062
+ */
1063
+ int jump_eval_coercion;
1064
+
1065
+ /*
1066
+ * Address to jump to when skipping all the steps after performing
1067
+ * ExecEvalJsonExprPath() so as to return whatever the JsonPath* function
1068
+ * returned as is, that is, in the cases where there's no error and no
1069
+ * coercion is necessary.
1070
+ */
1071
+ int jump_end;
1072
+
1073
+ /*
1074
+ * RETURNING type input function invocation info when
1075
+ * JsonExpr.use_io_coercion is true.
1076
+ */
1077
+ FunctionCallInfo input_fcinfo;
1078
+
1079
+ /*
1080
+ * For error-safe evaluation of coercions. When the ON ERROR behavior is
1081
+ * not ERROR, a pointer to this is passed to ExecInitExprRec() when
1082
+ * initializing the coercion expressions or to ExecInitJsonCoercion().
1083
+ *
1084
+ * Reset for each evaluation of EEOP_JSONEXPR_PATH.
1085
+ */
1086
+ ErrorSaveContext escontext;
1087
+ } JsonExprState;
1088
+
1089
+
1090
+ /* ----------------------------------------------------------------
1091
+ * Executor State Trees
1092
+ *
1093
+ * An executing query has a PlanState tree paralleling the Plan tree
1094
+ * that describes the plan.
1095
+ * ----------------------------------------------------------------
1096
+ */
1097
+
1098
+ /* ----------------
1099
+ * ExecProcNodeMtd
1100
+ *
1101
+ * This is the method called by ExecProcNode to return the next tuple
1102
+ * from an executor node. It returns NULL, or an empty TupleTableSlot,
1103
+ * if no more tuples are available.
1104
+ * ----------------
1105
+ */
1106
+ typedef TupleTableSlot *(*ExecProcNodeMtd) (struct PlanState *pstate);
1107
+
1108
+ /* ----------------
1109
+ * PlanState node
1110
+ *
1111
+ * We never actually instantiate any PlanState nodes; this is just the common
1112
+ * abstract superclass for all PlanState-type nodes.
1113
+ * ----------------
1114
+ */
1115
+ typedef struct PlanState
1116
+ {
1117
+ pg_node_attr(abstract)
1118
+
1119
+ NodeTag type;
1120
+
1121
+ Plan *plan; /* associated Plan node */
1122
+
1123
+ EState *state; /* at execution time, states of individual
1124
+ * nodes point to one EState for the whole
1125
+ * top-level plan */
1126
+
1127
+ ExecProcNodeMtd ExecProcNode; /* function to return next tuple */
1128
+ ExecProcNodeMtd ExecProcNodeReal; /* actual function, if above is a
1129
+ * wrapper */
1130
+
1131
+ Instrumentation *instrument; /* Optional runtime stats for this node */
1132
+ WorkerInstrumentation *worker_instrument; /* per-worker instrumentation */
1133
+
1134
+ /* Per-worker JIT instrumentation */
1135
+ struct SharedJitInstrumentation *worker_jit_instrument;
1136
+
1137
+ /*
1138
+ * Common structural data for all Plan types. These links to subsidiary
1139
+ * state trees parallel links in the associated plan tree (except for the
1140
+ * subPlan list, which does not exist in the plan tree).
1141
+ */
1142
+ ExprState *qual; /* boolean qual condition */
1143
+ struct PlanState *lefttree; /* input plan tree(s) */
1144
+ struct PlanState *righttree;
1145
+
1146
+ List *initPlan; /* Init SubPlanState nodes (un-correlated expr
1147
+ * subselects) */
1148
+ List *subPlan; /* SubPlanState nodes in my expressions */
1149
+
1150
+ /*
1151
+ * State for management of parameter-change-driven rescanning
1152
+ */
1153
+ Bitmapset *chgParam; /* set of IDs of changed Params */
1154
+
1155
+ /*
1156
+ * Other run-time state needed by most if not all node types.
1157
+ */
1158
+ TupleDesc ps_ResultTupleDesc; /* node's return type */
1159
+ TupleTableSlot *ps_ResultTupleSlot; /* slot for my result tuples */
1160
+ ExprContext *ps_ExprContext; /* node's expression-evaluation context */
1161
+ ProjectionInfo *ps_ProjInfo; /* info for doing tuple projection */
1162
+
1163
+ bool async_capable; /* true if node is async-capable */
1164
+
1165
+ /*
1166
+ * Scanslot's descriptor if known. This is a bit of a hack, but otherwise
1167
+ * it's hard for expression compilation to optimize based on the
1168
+ * descriptor, without encoding knowledge about all executor nodes.
1169
+ */
1170
+ TupleDesc scandesc;
1171
+
1172
+ /*
1173
+ * Define the slot types for inner, outer and scanslots for expression
1174
+ * contexts with this state as a parent. If *opsset is set, then
1175
+ * *opsfixed indicates whether *ops is guaranteed to be the type of slot
1176
+ * used. That means that every slot in the corresponding
1177
+ * ExprContext.ecxt_*tuple will point to a slot of that type, while
1178
+ * evaluating the expression. If *opsfixed is false, but *ops is set,
1179
+ * that indicates the most likely type of slot.
1180
+ *
1181
+ * The scan* fields are set by ExecInitScanTupleSlot(). If that's not
1182
+ * called, nodes can initialize the fields themselves.
1183
+ *
1184
+ * If outer/inneropsset is false, the information is inferred on-demand
1185
+ * using ExecGetResultSlotOps() on ->righttree/lefttree, using the
1186
+ * corresponding node's resultops* fields.
1187
+ *
1188
+ * The result* fields are automatically set when ExecInitResultSlot is
1189
+ * used (be it directly or when the slot is created by
1190
+ * ExecAssignScanProjectionInfo() /
1191
+ * ExecConditionalAssignProjectionInfo()). If no projection is necessary
1192
+ * ExecConditionalAssignProjectionInfo() defaults those fields to the scan
1193
+ * operations.
1194
+ */
1195
+ const TupleTableSlotOps *scanops;
1196
+ const TupleTableSlotOps *outerops;
1197
+ const TupleTableSlotOps *innerops;
1198
+ const TupleTableSlotOps *resultops;
1199
+ bool scanopsfixed;
1200
+ bool outeropsfixed;
1201
+ bool inneropsfixed;
1202
+ bool resultopsfixed;
1203
+ bool scanopsset;
1204
+ bool outeropsset;
1205
+ bool inneropsset;
1206
+ bool resultopsset;
1207
+ } PlanState;
1208
+
1209
+ /* ----------------
1210
+ * these are defined to avoid confusion problems with "left"
1211
+ * and "right" and "inner" and "outer". The convention is that
1212
+ * the "left" plan is the "outer" plan and the "right" plan is
1213
+ * the inner plan, but these make the code more readable.
1214
+ * ----------------
1215
+ */
1216
+ #define innerPlanState(node) (((PlanState *)(node))->righttree)
1217
+ #define outerPlanState(node) (((PlanState *)(node))->lefttree)
1218
+
1219
+ /* Macros for inline access to certain instrumentation counters */
1220
+ #define InstrCountTuples2(node, delta) \
1221
+ do { \
1222
+ if (((PlanState *)(node))->instrument) \
1223
+ ((PlanState *)(node))->instrument->ntuples2 += (delta); \
1224
+ } while (0)
1225
+ #define InstrCountFiltered1(node, delta) \
1226
+ do { \
1227
+ if (((PlanState *)(node))->instrument) \
1228
+ ((PlanState *)(node))->instrument->nfiltered1 += (delta); \
1229
+ } while(0)
1230
+ #define InstrCountFiltered2(node, delta) \
1231
+ do { \
1232
+ if (((PlanState *)(node))->instrument) \
1233
+ ((PlanState *)(node))->instrument->nfiltered2 += (delta); \
1234
+ } while(0)
1235
+
1236
+ /*
1237
+ * EPQState is state for executing an EvalPlanQual recheck on a candidate
1238
+ * tuples e.g. in ModifyTable or LockRows.
1239
+ *
1240
+ * To execute EPQ a separate EState is created (stored in ->recheckestate),
1241
+ * which shares some resources, like the rangetable, with the main query's
1242
+ * EState (stored in ->parentestate). The (sub-)tree of the plan that needs to
1243
+ * be rechecked (in ->plan), is separately initialized (into
1244
+ * ->recheckplanstate), but shares plan nodes with the corresponding nodes in
1245
+ * the main query. The scan nodes in that separate executor tree are changed
1246
+ * to return only the current tuple of interest for the respective
1247
+ * table. Those tuples are either provided by the caller (using
1248
+ * EvalPlanQualSlot), and/or found using the rowmark mechanism (non-locking
1249
+ * rowmarks by the EPQ machinery itself, locking ones by the caller).
1250
+ *
1251
+ * While the plan to be checked may be changed using EvalPlanQualSetPlan(),
1252
+ * all such plans need to share the same EState.
1253
+ */
1254
+ typedef struct EPQState
1255
+ {
1256
+ /* These are initialized by EvalPlanQualInit() and do not change later: */
1257
+ EState *parentestate; /* main query's EState */
1258
+ int epqParam; /* ID of Param to force scan node re-eval */
1259
+ List *resultRelations; /* integer list of RT indexes, or NIL */
1260
+
1261
+ /*
1262
+ * relsubs_slot[scanrelid - 1] holds the EPQ test tuple to be returned by
1263
+ * the scan node for the scanrelid'th RT index, in place of performing an
1264
+ * actual table scan. Callers should use EvalPlanQualSlot() to fetch
1265
+ * these slots.
1266
+ */
1267
+ List *tuple_table; /* tuple table for relsubs_slot */
1268
+ TupleTableSlot **relsubs_slot;
1269
+
1270
+ /*
1271
+ * Initialized by EvalPlanQualInit(), may be changed later with
1272
+ * EvalPlanQualSetPlan():
1273
+ */
1274
+
1275
+ Plan *plan; /* plan tree to be executed */
1276
+ List *arowMarks; /* ExecAuxRowMarks (non-locking only) */
1277
+
1278
+
1279
+ /*
1280
+ * The original output tuple to be rechecked. Set by
1281
+ * EvalPlanQualSetSlot(), before EvalPlanQualNext() or EvalPlanQual() may
1282
+ * be called.
1283
+ */
1284
+ TupleTableSlot *origslot;
1285
+
1286
+
1287
+ /* Initialized or reset by EvalPlanQualBegin(): */
1288
+
1289
+ EState *recheckestate; /* EState for EPQ execution, see above */
1290
+
1291
+ /*
1292
+ * Rowmarks that can be fetched on-demand using
1293
+ * EvalPlanQualFetchRowMark(), indexed by scanrelid - 1. Only non-locking
1294
+ * rowmarks.
1295
+ */
1296
+ ExecAuxRowMark **relsubs_rowmark;
1297
+
1298
+ /*
1299
+ * relsubs_done[scanrelid - 1] is true if there is no EPQ tuple for this
1300
+ * target relation or it has already been fetched in the current scan of
1301
+ * this target relation within the current EvalPlanQual test.
1302
+ */
1303
+ bool *relsubs_done;
1304
+
1305
+ /*
1306
+ * relsubs_blocked[scanrelid - 1] is true if there is no EPQ tuple for
1307
+ * this target relation during the current EvalPlanQual test. We keep
1308
+ * these flags set for all relids listed in resultRelations, but
1309
+ * transiently clear the one for the relation whose tuple is actually
1310
+ * passed to EvalPlanQual().
1311
+ */
1312
+ bool *relsubs_blocked;
1313
+
1314
+ PlanState *recheckplanstate; /* EPQ specific exec nodes, for ->plan */
1315
+ } EPQState;
1316
+
1317
+
1318
+ /* ----------------
1319
+ * ResultState information
1320
+ * ----------------
1321
+ */
1322
+ typedef struct ResultState
1323
+ {
1324
+ PlanState ps; /* its first field is NodeTag */
1325
+ ExprState *resconstantqual;
1326
+ bool rs_done; /* are we done? */
1327
+ bool rs_checkqual; /* do we need to check the qual? */
1328
+ } ResultState;
1329
+
1330
+ /* ----------------
1331
+ * ProjectSetState information
1332
+ *
1333
+ * Note: at least one of the "elems" will be a SetExprState; the rest are
1334
+ * regular ExprStates.
1335
+ * ----------------
1336
+ */
1337
+ typedef struct ProjectSetState
1338
+ {
1339
+ PlanState ps; /* its first field is NodeTag */
1340
+ Node **elems; /* array of expression states */
1341
+ ExprDoneCond *elemdone; /* array of per-SRF is-done states */
1342
+ int nelems; /* length of elemdone[] array */
1343
+ bool pending_srf_tuples; /* still evaluating srfs in tlist? */
1344
+ MemoryContext argcontext; /* context for SRF arguments */
1345
+ } ProjectSetState;
1346
+
1347
+
1348
+ /* flags for mt_merge_subcommands */
1349
+ #define MERGE_INSERT 0x01
1350
+ #define MERGE_UPDATE 0x02
1351
+ #define MERGE_DELETE 0x04
1352
+
1353
+ /* ----------------
1354
+ * ModifyTableState information
1355
+ * ----------------
1356
+ */
1357
+ typedef struct ModifyTableState
1358
+ {
1359
+ PlanState ps; /* its first field is NodeTag */
1360
+ CmdType operation; /* INSERT, UPDATE, DELETE, or MERGE */
1361
+ bool canSetTag; /* do we set the command tag/es_processed? */
1362
+ bool mt_done; /* are we done? */
1363
+ int mt_nrels; /* number of entries in resultRelInfo[] */
1364
+ ResultRelInfo *resultRelInfo; /* info about target relation(s) */
1365
+
1366
+ /*
1367
+ * Target relation mentioned in the original statement, used to fire
1368
+ * statement-level triggers and as the root for tuple routing. (This
1369
+ * might point to one of the resultRelInfo[] entries, but it can also be a
1370
+ * distinct struct.)
1371
+ */
1372
+ ResultRelInfo *rootResultRelInfo;
1373
+
1374
+ EPQState mt_epqstate; /* for evaluating EvalPlanQual rechecks */
1375
+ bool fireBSTriggers; /* do we need to fire stmt triggers? */
1376
+
1377
+ /*
1378
+ * These fields are used for inherited UPDATE and DELETE, to track which
1379
+ * target relation a given tuple is from. If there are a lot of target
1380
+ * relations, we use a hash table to translate table OIDs to
1381
+ * resultRelInfo[] indexes; otherwise mt_resultOidHash is NULL.
1382
+ */
1383
+ int mt_resultOidAttno; /* resno of "tableoid" junk attr */
1384
+ Oid mt_lastResultOid; /* last-seen value of tableoid */
1385
+ int mt_lastResultIndex; /* corresponding index in resultRelInfo[] */
1386
+ HTAB *mt_resultOidHash; /* optional hash table to speed lookups */
1387
+
1388
+ /*
1389
+ * Slot for storing tuples in the root partitioned table's rowtype during
1390
+ * an UPDATE of a partitioned table.
1391
+ */
1392
+ TupleTableSlot *mt_root_tuple_slot;
1393
+
1394
+ /* Tuple-routing support info */
1395
+ struct PartitionTupleRouting *mt_partition_tuple_routing;
1396
+
1397
+ /* controls transition table population for specified operation */
1398
+ struct TransitionCaptureState *mt_transition_capture;
1399
+
1400
+ /* controls transition table population for INSERT...ON CONFLICT UPDATE */
1401
+ struct TransitionCaptureState *mt_oc_transition_capture;
1402
+
1403
+ /* Flags showing which subcommands are present INS/UPD/DEL/DO NOTHING */
1404
+ int mt_merge_subcommands;
1405
+
1406
+ /* For MERGE, the action currently being executed */
1407
+ MergeActionState *mt_merge_action;
1408
+
1409
+ /*
1410
+ * For MERGE, if there is a pending NOT MATCHED [BY TARGET] action to be
1411
+ * performed, this will be the last tuple read from the subplan; otherwise
1412
+ * it will be NULL --- see the comments in ExecMerge().
1413
+ */
1414
+ TupleTableSlot *mt_merge_pending_not_matched;
1415
+
1416
+ /* tuple counters for MERGE */
1417
+ double mt_merge_inserted;
1418
+ double mt_merge_updated;
1419
+ double mt_merge_deleted;
1420
+ } ModifyTableState;
1421
+
1422
+ /* ----------------
1423
+ * AppendState information
1424
+ *
1425
+ * nplans how many plans are in the array
1426
+ * whichplan which synchronous plan is being executed (0 .. n-1)
1427
+ * or a special negative value. See nodeAppend.c.
1428
+ * prune_state details required to allow partitions to be
1429
+ * eliminated from the scan, or NULL if not possible.
1430
+ * valid_subplans for runtime pruning, valid synchronous appendplans
1431
+ * indexes to scan.
1432
+ * ----------------
1433
+ */
1434
+
1435
+ struct AppendState;
1436
+ typedef struct AppendState AppendState;
1437
+ struct ParallelAppendState;
1438
+ typedef struct ParallelAppendState ParallelAppendState;
1439
+ struct PartitionPruneState;
1440
+
1441
+ struct AppendState
1442
+ {
1443
+ PlanState ps; /* its first field is NodeTag */
1444
+ PlanState **appendplans; /* array of PlanStates for my inputs */
1445
+ int as_nplans;
1446
+ int as_whichplan;
1447
+ bool as_begun; /* false means need to initialize */
1448
+ Bitmapset *as_asyncplans; /* asynchronous plans indexes */
1449
+ int as_nasyncplans; /* # of asynchronous plans */
1450
+ AsyncRequest **as_asyncrequests; /* array of AsyncRequests */
1451
+ TupleTableSlot **as_asyncresults; /* unreturned results of async plans */
1452
+ int as_nasyncresults; /* # of valid entries in as_asyncresults */
1453
+ bool as_syncdone; /* true if all synchronous plans done in
1454
+ * asynchronous mode, else false */
1455
+ int as_nasyncremain; /* # of remaining asynchronous plans */
1456
+ Bitmapset *as_needrequest; /* asynchronous plans needing a new request */
1457
+ struct WaitEventSet *as_eventset; /* WaitEventSet used to configure file
1458
+ * descriptor wait events */
1459
+ int as_first_partial_plan; /* Index of 'appendplans' containing
1460
+ * the first partial plan */
1461
+ ParallelAppendState *as_pstate; /* parallel coordination info */
1462
+ Size pstate_len; /* size of parallel coordination info */
1463
+ struct PartitionPruneState *as_prune_state;
1464
+ bool as_valid_subplans_identified; /* is as_valid_subplans valid? */
1465
+ Bitmapset *as_valid_subplans;
1466
+ Bitmapset *as_valid_asyncplans; /* valid asynchronous plans indexes */
1467
+ bool (*choose_next_subplan) (AppendState *);
1468
+ };
1469
+
1470
+ /* ----------------
1471
+ * MergeAppendState information
1472
+ *
1473
+ * nplans how many plans are in the array
1474
+ * nkeys number of sort key columns
1475
+ * sortkeys sort keys in SortSupport representation
1476
+ * slots current output tuple of each subplan
1477
+ * heap heap of active tuples
1478
+ * initialized true if we have fetched first tuple from each subplan
1479
+ * prune_state details required to allow partitions to be
1480
+ * eliminated from the scan, or NULL if not possible.
1481
+ * valid_subplans for runtime pruning, valid mergeplans indexes to
1482
+ * scan.
1483
+ * ----------------
1484
+ */
1485
+ typedef struct MergeAppendState
1486
+ {
1487
+ PlanState ps; /* its first field is NodeTag */
1488
+ PlanState **mergeplans; /* array of PlanStates for my inputs */
1489
+ int ms_nplans;
1490
+ int ms_nkeys;
1491
+ SortSupport ms_sortkeys; /* array of length ms_nkeys */
1492
+ TupleTableSlot **ms_slots; /* array of length ms_nplans */
1493
+ struct binaryheap *ms_heap; /* binary heap of slot indices */
1494
+ bool ms_initialized; /* are subplans started? */
1495
+ struct PartitionPruneState *ms_prune_state;
1496
+ Bitmapset *ms_valid_subplans;
1497
+ } MergeAppendState;
1498
+
1499
+ /* ----------------
1500
+ * RecursiveUnionState information
1501
+ *
1502
+ * RecursiveUnionState is used for performing a recursive union.
1503
+ *
1504
+ * recursing T when we're done scanning the non-recursive term
1505
+ * intermediate_empty T if intermediate_table is currently empty
1506
+ * working_table working table (to be scanned by recursive term)
1507
+ * intermediate_table current recursive output (next generation of WT)
1508
+ * ----------------
1509
+ */
1510
+ typedef struct RecursiveUnionState
1511
+ {
1512
+ PlanState ps; /* its first field is NodeTag */
1513
+ bool recursing;
1514
+ bool intermediate_empty;
1515
+ Tuplestorestate *working_table;
1516
+ Tuplestorestate *intermediate_table;
1517
+ /* Remaining fields are unused in UNION ALL case */
1518
+ Oid *eqfuncoids; /* per-grouping-field equality fns */
1519
+ FmgrInfo *hashfunctions; /* per-grouping-field hash fns */
1520
+ MemoryContext tempContext; /* short-term context for comparisons */
1521
+ TupleHashTable hashtable; /* hash table for tuples already seen */
1522
+ MemoryContext tableContext; /* memory context containing hash table */
1523
+ } RecursiveUnionState;
1524
+
1525
+ /* ----------------
1526
+ * BitmapAndState information
1527
+ * ----------------
1528
+ */
1529
+ typedef struct BitmapAndState
1530
+ {
1531
+ PlanState ps; /* its first field is NodeTag */
1532
+ PlanState **bitmapplans; /* array of PlanStates for my inputs */
1533
+ int nplans; /* number of input plans */
1534
+ } BitmapAndState;
1535
+
1536
+ /* ----------------
1537
+ * BitmapOrState information
1538
+ * ----------------
1539
+ */
1540
+ typedef struct BitmapOrState
1541
+ {
1542
+ PlanState ps; /* its first field is NodeTag */
1543
+ PlanState **bitmapplans; /* array of PlanStates for my inputs */
1544
+ int nplans; /* number of input plans */
1545
+ } BitmapOrState;
1546
+
1547
+ /* ----------------------------------------------------------------
1548
+ * Scan State Information
1549
+ * ----------------------------------------------------------------
1550
+ */
1551
+
1552
+ /* ----------------
1553
+ * ScanState information
1554
+ *
1555
+ * ScanState extends PlanState for node types that represent
1556
+ * scans of an underlying relation. It can also be used for nodes
1557
+ * that scan the output of an underlying plan node --- in that case,
1558
+ * only ScanTupleSlot is actually useful, and it refers to the tuple
1559
+ * retrieved from the subplan.
1560
+ *
1561
+ * currentRelation relation being scanned (NULL if none)
1562
+ * currentScanDesc current scan descriptor for scan (NULL if none)
1563
+ * ScanTupleSlot pointer to slot in tuple table holding scan tuple
1564
+ * ----------------
1565
+ */
1566
+ typedef struct ScanState
1567
+ {
1568
+ PlanState ps; /* its first field is NodeTag */
1569
+ Relation ss_currentRelation;
1570
+ struct TableScanDescData *ss_currentScanDesc;
1571
+ TupleTableSlot *ss_ScanTupleSlot;
1572
+ } ScanState;
1573
+
1574
+ /* ----------------
1575
+ * SeqScanState information
1576
+ * ----------------
1577
+ */
1578
+ typedef struct SeqScanState
1579
+ {
1580
+ ScanState ss; /* its first field is NodeTag */
1581
+ Size pscan_len; /* size of parallel heap scan descriptor */
1582
+ } SeqScanState;
1583
+
1584
+ /* ----------------
1585
+ * SampleScanState information
1586
+ * ----------------
1587
+ */
1588
+ typedef struct SampleScanState
1589
+ {
1590
+ ScanState ss;
1591
+ List *args; /* expr states for TABLESAMPLE params */
1592
+ ExprState *repeatable; /* expr state for REPEATABLE expr */
1593
+ /* use struct pointer to avoid including tsmapi.h here */
1594
+ struct TsmRoutine *tsmroutine; /* descriptor for tablesample method */
1595
+ void *tsm_state; /* tablesample method can keep state here */
1596
+ bool use_bulkread; /* use bulkread buffer access strategy? */
1597
+ bool use_pagemode; /* use page-at-a-time visibility checking? */
1598
+ bool begun; /* false means need to call BeginSampleScan */
1599
+ uint32 seed; /* random seed */
1600
+ int64 donetuples; /* number of tuples already returned */
1601
+ bool haveblock; /* has a block for sampling been determined */
1602
+ bool done; /* exhausted all tuples? */
1603
+ } SampleScanState;
1604
+
1605
+ /*
1606
+ * These structs store information about index quals that don't have simple
1607
+ * constant right-hand sides. See comments for ExecIndexBuildScanKeys()
1608
+ * for discussion.
1609
+ */
1610
+ typedef struct
1611
+ {
1612
+ struct ScanKeyData *scan_key; /* scankey to put value into */
1613
+ ExprState *key_expr; /* expr to evaluate to get value */
1614
+ bool key_toastable; /* is expr's result a toastable datatype? */
1615
+ } IndexRuntimeKeyInfo;
1616
+
1617
+ typedef struct
1618
+ {
1619
+ struct ScanKeyData *scan_key; /* scankey to put value into */
1620
+ ExprState *array_expr; /* expr to evaluate to get array value */
1621
+ int next_elem; /* next array element to use */
1622
+ int num_elems; /* number of elems in current array value */
1623
+ Datum *elem_values; /* array of num_elems Datums */
1624
+ bool *elem_nulls; /* array of num_elems is-null flags */
1625
+ } IndexArrayKeyInfo;
1626
+
1627
+ /* ----------------
1628
+ * IndexScanState information
1629
+ *
1630
+ * indexqualorig execution state for indexqualorig expressions
1631
+ * indexorderbyorig execution state for indexorderbyorig expressions
1632
+ * ScanKeys Skey structures for index quals
1633
+ * NumScanKeys number of ScanKeys
1634
+ * OrderByKeys Skey structures for index ordering operators
1635
+ * NumOrderByKeys number of OrderByKeys
1636
+ * RuntimeKeys info about Skeys that must be evaluated at runtime
1637
+ * NumRuntimeKeys number of RuntimeKeys
1638
+ * RuntimeKeysReady true if runtime Skeys have been computed
1639
+ * RuntimeContext expr context for evaling runtime Skeys
1640
+ * RelationDesc index relation descriptor
1641
+ * ScanDesc index scan descriptor
1642
+ *
1643
+ * ReorderQueue tuples that need reordering due to re-check
1644
+ * ReachedEnd have we fetched all tuples from index already?
1645
+ * OrderByValues values of ORDER BY exprs of last fetched tuple
1646
+ * OrderByNulls null flags for OrderByValues
1647
+ * SortSupport for reordering ORDER BY exprs
1648
+ * OrderByTypByVals is the datatype of order by expression pass-by-value?
1649
+ * OrderByTypLens typlens of the datatypes of order by expressions
1650
+ * PscanLen size of parallel index scan descriptor
1651
+ * ----------------
1652
+ */
1653
+ typedef struct IndexScanState
1654
+ {
1655
+ ScanState ss; /* its first field is NodeTag */
1656
+ ExprState *indexqualorig;
1657
+ List *indexorderbyorig;
1658
+ struct ScanKeyData *iss_ScanKeys;
1659
+ int iss_NumScanKeys;
1660
+ struct ScanKeyData *iss_OrderByKeys;
1661
+ int iss_NumOrderByKeys;
1662
+ IndexRuntimeKeyInfo *iss_RuntimeKeys;
1663
+ int iss_NumRuntimeKeys;
1664
+ bool iss_RuntimeKeysReady;
1665
+ ExprContext *iss_RuntimeContext;
1666
+ Relation iss_RelationDesc;
1667
+ struct IndexScanDescData *iss_ScanDesc;
1668
+
1669
+ /* These are needed for re-checking ORDER BY expr ordering */
1670
+ pairingheap *iss_ReorderQueue;
1671
+ bool iss_ReachedEnd;
1672
+ Datum *iss_OrderByValues;
1673
+ bool *iss_OrderByNulls;
1674
+ SortSupport iss_SortSupport;
1675
+ bool *iss_OrderByTypByVals;
1676
+ int16 *iss_OrderByTypLens;
1677
+ Size iss_PscanLen;
1678
+ } IndexScanState;
1679
+
1680
+ /* ----------------
1681
+ * IndexOnlyScanState information
1682
+ *
1683
+ * recheckqual execution state for recheckqual expressions
1684
+ * ScanKeys Skey structures for index quals
1685
+ * NumScanKeys number of ScanKeys
1686
+ * OrderByKeys Skey structures for index ordering operators
1687
+ * NumOrderByKeys number of OrderByKeys
1688
+ * RuntimeKeys info about Skeys that must be evaluated at runtime
1689
+ * NumRuntimeKeys number of RuntimeKeys
1690
+ * RuntimeKeysReady true if runtime Skeys have been computed
1691
+ * RuntimeContext expr context for evaling runtime Skeys
1692
+ * RelationDesc index relation descriptor
1693
+ * ScanDesc index scan descriptor
1694
+ * TableSlot slot for holding tuples fetched from the table
1695
+ * VMBuffer buffer in use for visibility map testing, if any
1696
+ * PscanLen size of parallel index-only scan descriptor
1697
+ * NameCStringAttNums attnums of name typed columns to pad to NAMEDATALEN
1698
+ * NameCStringCount number of elements in the NameCStringAttNums array
1699
+ * ----------------
1700
+ */
1701
+ typedef struct IndexOnlyScanState
1702
+ {
1703
+ ScanState ss; /* its first field is NodeTag */
1704
+ ExprState *recheckqual;
1705
+ struct ScanKeyData *ioss_ScanKeys;
1706
+ int ioss_NumScanKeys;
1707
+ struct ScanKeyData *ioss_OrderByKeys;
1708
+ int ioss_NumOrderByKeys;
1709
+ IndexRuntimeKeyInfo *ioss_RuntimeKeys;
1710
+ int ioss_NumRuntimeKeys;
1711
+ bool ioss_RuntimeKeysReady;
1712
+ ExprContext *ioss_RuntimeContext;
1713
+ Relation ioss_RelationDesc;
1714
+ struct IndexScanDescData *ioss_ScanDesc;
1715
+ TupleTableSlot *ioss_TableSlot;
1716
+ Buffer ioss_VMBuffer;
1717
+ Size ioss_PscanLen;
1718
+ AttrNumber *ioss_NameCStringAttNums;
1719
+ int ioss_NameCStringCount;
1720
+ } IndexOnlyScanState;
1721
+
1722
+ /* ----------------
1723
+ * BitmapIndexScanState information
1724
+ *
1725
+ * result bitmap to return output into, or NULL
1726
+ * ScanKeys Skey structures for index quals
1727
+ * NumScanKeys number of ScanKeys
1728
+ * RuntimeKeys info about Skeys that must be evaluated at runtime
1729
+ * NumRuntimeKeys number of RuntimeKeys
1730
+ * ArrayKeys info about Skeys that come from ScalarArrayOpExprs
1731
+ * NumArrayKeys number of ArrayKeys
1732
+ * RuntimeKeysReady true if runtime Skeys have been computed
1733
+ * RuntimeContext expr context for evaling runtime Skeys
1734
+ * RelationDesc index relation descriptor
1735
+ * ScanDesc index scan descriptor
1736
+ * ----------------
1737
+ */
1738
+ typedef struct BitmapIndexScanState
1739
+ {
1740
+ ScanState ss; /* its first field is NodeTag */
1741
+ TIDBitmap *biss_result;
1742
+ struct ScanKeyData *biss_ScanKeys;
1743
+ int biss_NumScanKeys;
1744
+ IndexRuntimeKeyInfo *biss_RuntimeKeys;
1745
+ int biss_NumRuntimeKeys;
1746
+ IndexArrayKeyInfo *biss_ArrayKeys;
1747
+ int biss_NumArrayKeys;
1748
+ bool biss_RuntimeKeysReady;
1749
+ ExprContext *biss_RuntimeContext;
1750
+ Relation biss_RelationDesc;
1751
+ struct IndexScanDescData *biss_ScanDesc;
1752
+ } BitmapIndexScanState;
1753
+
1754
+ /* ----------------
1755
+ * SharedBitmapState information
1756
+ *
1757
+ * BM_INITIAL TIDBitmap creation is not yet started, so first worker
1758
+ * to see this state will set the state to BM_INPROGRESS
1759
+ * and that process will be responsible for creating
1760
+ * TIDBitmap.
1761
+ * BM_INPROGRESS TIDBitmap creation is in progress; workers need to
1762
+ * sleep until it's finished.
1763
+ * BM_FINISHED TIDBitmap creation is done, so now all workers can
1764
+ * proceed to iterate over TIDBitmap.
1765
+ * ----------------
1766
+ */
1767
+ typedef enum
1768
+ {
1769
+ BM_INITIAL,
1770
+ BM_INPROGRESS,
1771
+ BM_FINISHED,
1772
+ } SharedBitmapState;
1773
+
1774
+ /* ----------------
1775
+ * ParallelBitmapHeapState information
1776
+ * tbmiterator iterator for scanning current pages
1777
+ * prefetch_iterator iterator for prefetching ahead of current page
1778
+ * mutex mutual exclusion for the prefetching variable
1779
+ * and state
1780
+ * prefetch_pages # pages prefetch iterator is ahead of current
1781
+ * prefetch_target current target prefetch distance
1782
+ * state current state of the TIDBitmap
1783
+ * cv conditional wait variable
1784
+ * ----------------
1785
+ */
1786
+ typedef struct ParallelBitmapHeapState
1787
+ {
1788
+ dsa_pointer tbmiterator;
1789
+ dsa_pointer prefetch_iterator;
1790
+ slock_t mutex;
1791
+ int prefetch_pages;
1792
+ int prefetch_target;
1793
+ SharedBitmapState state;
1794
+ ConditionVariable cv;
1795
+ } ParallelBitmapHeapState;
1796
+
1797
+ /* ----------------
1798
+ * BitmapHeapScanState information
1799
+ *
1800
+ * bitmapqualorig execution state for bitmapqualorig expressions
1801
+ * tbm bitmap obtained from child index scan(s)
1802
+ * tbmiterator iterator for scanning current pages
1803
+ * tbmres current-page data
1804
+ * pvmbuffer buffer for visibility-map lookups of prefetched pages
1805
+ * exact_pages total number of exact pages retrieved
1806
+ * lossy_pages total number of lossy pages retrieved
1807
+ * prefetch_iterator iterator for prefetching ahead of current page
1808
+ * prefetch_pages # pages prefetch iterator is ahead of current
1809
+ * prefetch_target current target prefetch distance
1810
+ * prefetch_maximum maximum value for prefetch_target
1811
+ * initialized is node is ready to iterate
1812
+ * shared_tbmiterator shared iterator
1813
+ * shared_prefetch_iterator shared iterator for prefetching
1814
+ * pstate shared state for parallel bitmap scan
1815
+ * ----------------
1816
+ */
1817
+ typedef struct BitmapHeapScanState
1818
+ {
1819
+ ScanState ss; /* its first field is NodeTag */
1820
+ ExprState *bitmapqualorig;
1821
+ TIDBitmap *tbm;
1822
+ TBMIterator *tbmiterator;
1823
+ TBMIterateResult *tbmres;
1824
+ Buffer pvmbuffer;
1825
+ long exact_pages;
1826
+ long lossy_pages;
1827
+ TBMIterator *prefetch_iterator;
1828
+ int prefetch_pages;
1829
+ int prefetch_target;
1830
+ int prefetch_maximum;
1831
+ bool initialized;
1832
+ TBMSharedIterator *shared_tbmiterator;
1833
+ TBMSharedIterator *shared_prefetch_iterator;
1834
+ ParallelBitmapHeapState *pstate;
1835
+ } BitmapHeapScanState;
1836
+
1837
+ /* ----------------
1838
+ * TidScanState information
1839
+ *
1840
+ * tidexprs list of TidExpr structs (see nodeTidscan.c)
1841
+ * isCurrentOf scan has a CurrentOfExpr qual
1842
+ * NumTids number of tids in this scan
1843
+ * TidPtr index of currently fetched tid
1844
+ * TidList evaluated item pointers (array of size NumTids)
1845
+ * ----------------
1846
+ */
1847
+ typedef struct TidScanState
1848
+ {
1849
+ ScanState ss; /* its first field is NodeTag */
1850
+ List *tss_tidexprs;
1851
+ bool tss_isCurrentOf;
1852
+ int tss_NumTids;
1853
+ int tss_TidPtr;
1854
+ ItemPointerData *tss_TidList;
1855
+ } TidScanState;
1856
+
1857
+ /* ----------------
1858
+ * TidRangeScanState information
1859
+ *
1860
+ * trss_tidexprs list of TidOpExpr structs (see nodeTidrangescan.c)
1861
+ * trss_mintid the lowest TID in the scan range
1862
+ * trss_maxtid the highest TID in the scan range
1863
+ * trss_inScan is a scan currently in progress?
1864
+ * ----------------
1865
+ */
1866
+ typedef struct TidRangeScanState
1867
+ {
1868
+ ScanState ss; /* its first field is NodeTag */
1869
+ List *trss_tidexprs;
1870
+ ItemPointerData trss_mintid;
1871
+ ItemPointerData trss_maxtid;
1872
+ bool trss_inScan;
1873
+ } TidRangeScanState;
1874
+
1875
+ /* ----------------
1876
+ * SubqueryScanState information
1877
+ *
1878
+ * SubqueryScanState is used for scanning a sub-query in the range table.
1879
+ * ScanTupleSlot references the current output tuple of the sub-query.
1880
+ * ----------------
1881
+ */
1882
+ typedef struct SubqueryScanState
1883
+ {
1884
+ ScanState ss; /* its first field is NodeTag */
1885
+ PlanState *subplan;
1886
+ } SubqueryScanState;
1887
+
1888
+ /* ----------------
1889
+ * FunctionScanState information
1890
+ *
1891
+ * Function nodes are used to scan the results of a
1892
+ * function appearing in FROM (typically a function returning set).
1893
+ *
1894
+ * eflags node's capability flags
1895
+ * ordinality is this scan WITH ORDINALITY?
1896
+ * simple true if we have 1 function and no ordinality
1897
+ * ordinal current ordinal column value
1898
+ * nfuncs number of functions being executed
1899
+ * funcstates per-function execution states (private in
1900
+ * nodeFunctionscan.c)
1901
+ * argcontext memory context to evaluate function arguments in
1902
+ * ----------------
1903
+ */
1904
+ struct FunctionScanPerFuncState;
1905
+
1906
+ typedef struct FunctionScanState
1907
+ {
1908
+ ScanState ss; /* its first field is NodeTag */
1909
+ int eflags;
1910
+ bool ordinality;
1911
+ bool simple;
1912
+ int64 ordinal;
1913
+ int nfuncs;
1914
+ struct FunctionScanPerFuncState *funcstates; /* array of length nfuncs */
1915
+ MemoryContext argcontext;
1916
+ } FunctionScanState;
1917
+
1918
+ /* ----------------
1919
+ * ValuesScanState information
1920
+ *
1921
+ * ValuesScan nodes are used to scan the results of a VALUES list
1922
+ *
1923
+ * rowcontext per-expression-list context
1924
+ * exprlists array of expression lists being evaluated
1925
+ * exprstatelists array of expression state lists, for SubPlans only
1926
+ * array_len size of above arrays
1927
+ * curr_idx current array index (0-based)
1928
+ *
1929
+ * Note: ss.ps.ps_ExprContext is used to evaluate any qual or projection
1930
+ * expressions attached to the node. We create a second ExprContext,
1931
+ * rowcontext, in which to build the executor expression state for each
1932
+ * Values sublist. Resetting this context lets us get rid of expression
1933
+ * state for each row, avoiding major memory leakage over a long values list.
1934
+ * However, that doesn't work for sublists containing SubPlans, because a
1935
+ * SubPlan has to be connected up to the outer plan tree to work properly.
1936
+ * Therefore, for only those sublists containing SubPlans, we do expression
1937
+ * state construction at executor start, and store those pointers in
1938
+ * exprstatelists[]. NULL entries in that array correspond to simple
1939
+ * subexpressions that are handled as described above.
1940
+ * ----------------
1941
+ */
1942
+ typedef struct ValuesScanState
1943
+ {
1944
+ ScanState ss; /* its first field is NodeTag */
1945
+ ExprContext *rowcontext;
1946
+ List **exprlists;
1947
+ List **exprstatelists;
1948
+ int array_len;
1949
+ int curr_idx;
1950
+ } ValuesScanState;
1951
+
1952
+ /* ----------------
1953
+ * TableFuncScanState node
1954
+ *
1955
+ * Used in table-expression functions like XMLTABLE.
1956
+ * ----------------
1957
+ */
1958
+ typedef struct TableFuncScanState
1959
+ {
1960
+ ScanState ss; /* its first field is NodeTag */
1961
+ ExprState *docexpr; /* state for document expression */
1962
+ ExprState *rowexpr; /* state for row-generating expression */
1963
+ List *colexprs; /* state for column-generating expression */
1964
+ List *coldefexprs; /* state for column default expressions */
1965
+ List *colvalexprs; /* state for column value expressions */
1966
+ List *passingvalexprs; /* state for PASSING argument expressions */
1967
+ List *ns_names; /* same as TableFunc.ns_names */
1968
+ List *ns_uris; /* list of states of namespace URI exprs */
1969
+ Bitmapset *notnulls; /* nullability flag for each output column */
1970
+ void *opaque; /* table builder private space */
1971
+ const struct TableFuncRoutine *routine; /* table builder methods */
1972
+ FmgrInfo *in_functions; /* input function for each column */
1973
+ Oid *typioparams; /* typioparam for each column */
1974
+ int64 ordinal; /* row number to be output next */
1975
+ MemoryContext perTableCxt; /* per-table context */
1976
+ Tuplestorestate *tupstore; /* output tuple store */
1977
+ } TableFuncScanState;
1978
+
1979
+ /* ----------------
1980
+ * CteScanState information
1981
+ *
1982
+ * CteScan nodes are used to scan a CommonTableExpr query.
1983
+ *
1984
+ * Multiple CteScan nodes can read out from the same CTE query. We use
1985
+ * a tuplestore to hold rows that have been read from the CTE query but
1986
+ * not yet consumed by all readers.
1987
+ * ----------------
1988
+ */
1989
+ typedef struct CteScanState
1990
+ {
1991
+ ScanState ss; /* its first field is NodeTag */
1992
+ int eflags; /* capability flags to pass to tuplestore */
1993
+ int readptr; /* index of my tuplestore read pointer */
1994
+ PlanState *cteplanstate; /* PlanState for the CTE query itself */
1995
+ /* Link to the "leader" CteScanState (possibly this same node) */
1996
+ struct CteScanState *leader;
1997
+ /* The remaining fields are only valid in the "leader" CteScanState */
1998
+ Tuplestorestate *cte_table; /* rows already read from the CTE query */
1999
+ bool eof_cte; /* reached end of CTE query? */
2000
+ } CteScanState;
2001
+
2002
+ /* ----------------
2003
+ * NamedTuplestoreScanState information
2004
+ *
2005
+ * NamedTuplestoreScan nodes are used to scan a Tuplestore created and
2006
+ * named prior to execution of the query. An example is a transition
2007
+ * table for an AFTER trigger.
2008
+ *
2009
+ * Multiple NamedTuplestoreScan nodes can read out from the same Tuplestore.
2010
+ * ----------------
2011
+ */
2012
+ typedef struct NamedTuplestoreScanState
2013
+ {
2014
+ ScanState ss; /* its first field is NodeTag */
2015
+ int readptr; /* index of my tuplestore read pointer */
2016
+ TupleDesc tupdesc; /* format of the tuples in the tuplestore */
2017
+ Tuplestorestate *relation; /* the rows */
2018
+ } NamedTuplestoreScanState;
2019
+
2020
+ /* ----------------
2021
+ * WorkTableScanState information
2022
+ *
2023
+ * WorkTableScan nodes are used to scan the work table created by
2024
+ * a RecursiveUnion node. We locate the RecursiveUnion node
2025
+ * during executor startup.
2026
+ * ----------------
2027
+ */
2028
+ typedef struct WorkTableScanState
2029
+ {
2030
+ ScanState ss; /* its first field is NodeTag */
2031
+ RecursiveUnionState *rustate;
2032
+ } WorkTableScanState;
2033
+
2034
+ /* ----------------
2035
+ * ForeignScanState information
2036
+ *
2037
+ * ForeignScan nodes are used to scan foreign-data tables.
2038
+ * ----------------
2039
+ */
2040
+ typedef struct ForeignScanState
2041
+ {
2042
+ ScanState ss; /* its first field is NodeTag */
2043
+ ExprState *fdw_recheck_quals; /* original quals not in ss.ps.qual */
2044
+ Size pscan_len; /* size of parallel coordination information */
2045
+ ResultRelInfo *resultRelInfo; /* result rel info, if UPDATE or DELETE */
2046
+ /* use struct pointer to avoid including fdwapi.h here */
2047
+ struct FdwRoutine *fdwroutine;
2048
+ void *fdw_state; /* foreign-data wrapper can keep state here */
2049
+ } ForeignScanState;
2050
+
2051
+ /* ----------------
2052
+ * CustomScanState information
2053
+ *
2054
+ * CustomScan nodes are used to execute custom code within executor.
2055
+ *
2056
+ * Core code must avoid assuming that the CustomScanState is only as large as
2057
+ * the structure declared here; providers are allowed to make it the first
2058
+ * element in a larger structure, and typically would need to do so. The
2059
+ * struct is actually allocated by the CreateCustomScanState method associated
2060
+ * with the plan node. Any additional fields can be initialized there, or in
2061
+ * the BeginCustomScan method.
2062
+ * ----------------
2063
+ */
2064
+ struct CustomExecMethods;
2065
+
2066
+ typedef struct CustomScanState
2067
+ {
2068
+ ScanState ss;
2069
+ uint32 flags; /* mask of CUSTOMPATH_* flags, see
2070
+ * nodes/extensible.h */
2071
+ List *custom_ps; /* list of child PlanState nodes, if any */
2072
+ Size pscan_len; /* size of parallel coordination information */
2073
+ const struct CustomExecMethods *methods;
2074
+ const struct TupleTableSlotOps *slotOps;
2075
+ } CustomScanState;
2076
+
2077
+ /* ----------------------------------------------------------------
2078
+ * Join State Information
2079
+ * ----------------------------------------------------------------
2080
+ */
2081
+
2082
+ /* ----------------
2083
+ * JoinState information
2084
+ *
2085
+ * Superclass for state nodes of join plans.
2086
+ * ----------------
2087
+ */
2088
+ typedef struct JoinState
2089
+ {
2090
+ PlanState ps;
2091
+ JoinType jointype;
2092
+ bool single_match; /* True if we should skip to next outer tuple
2093
+ * after finding one inner match */
2094
+ ExprState *joinqual; /* JOIN quals (in addition to ps.qual) */
2095
+ } JoinState;
2096
+
2097
+ /* ----------------
2098
+ * NestLoopState information
2099
+ *
2100
+ * NeedNewOuter true if need new outer tuple on next call
2101
+ * MatchedOuter true if found a join match for current outer tuple
2102
+ * NullInnerTupleSlot prepared null tuple for left outer joins
2103
+ * ----------------
2104
+ */
2105
+ typedef struct NestLoopState
2106
+ {
2107
+ JoinState js; /* its first field is NodeTag */
2108
+ bool nl_NeedNewOuter;
2109
+ bool nl_MatchedOuter;
2110
+ TupleTableSlot *nl_NullInnerTupleSlot;
2111
+ } NestLoopState;
2112
+
2113
+ /* ----------------
2114
+ * MergeJoinState information
2115
+ *
2116
+ * NumClauses number of mergejoinable join clauses
2117
+ * Clauses info for each mergejoinable clause
2118
+ * JoinState current state of ExecMergeJoin state machine
2119
+ * SkipMarkRestore true if we may skip Mark and Restore operations
2120
+ * ExtraMarks true to issue extra Mark operations on inner scan
2121
+ * ConstFalseJoin true if we have a constant-false joinqual
2122
+ * FillOuter true if should emit unjoined outer tuples anyway
2123
+ * FillInner true if should emit unjoined inner tuples anyway
2124
+ * MatchedOuter true if found a join match for current outer tuple
2125
+ * MatchedInner true if found a join match for current inner tuple
2126
+ * OuterTupleSlot slot in tuple table for cur outer tuple
2127
+ * InnerTupleSlot slot in tuple table for cur inner tuple
2128
+ * MarkedTupleSlot slot in tuple table for marked tuple
2129
+ * NullOuterTupleSlot prepared null tuple for right outer joins
2130
+ * NullInnerTupleSlot prepared null tuple for left outer joins
2131
+ * OuterEContext workspace for computing outer tuple's join values
2132
+ * InnerEContext workspace for computing inner tuple's join values
2133
+ * ----------------
2134
+ */
2135
+ /* private in nodeMergejoin.c: */
2136
+ typedef struct MergeJoinClauseData *MergeJoinClause;
2137
+
2138
+ typedef struct MergeJoinState
2139
+ {
2140
+ JoinState js; /* its first field is NodeTag */
2141
+ int mj_NumClauses;
2142
+ MergeJoinClause mj_Clauses; /* array of length mj_NumClauses */
2143
+ int mj_JoinState;
2144
+ bool mj_SkipMarkRestore;
2145
+ bool mj_ExtraMarks;
2146
+ bool mj_ConstFalseJoin;
2147
+ bool mj_FillOuter;
2148
+ bool mj_FillInner;
2149
+ bool mj_MatchedOuter;
2150
+ bool mj_MatchedInner;
2151
+ TupleTableSlot *mj_OuterTupleSlot;
2152
+ TupleTableSlot *mj_InnerTupleSlot;
2153
+ TupleTableSlot *mj_MarkedTupleSlot;
2154
+ TupleTableSlot *mj_NullOuterTupleSlot;
2155
+ TupleTableSlot *mj_NullInnerTupleSlot;
2156
+ ExprContext *mj_OuterEContext;
2157
+ ExprContext *mj_InnerEContext;
2158
+ } MergeJoinState;
2159
+
2160
+ /* ----------------
2161
+ * HashJoinState information
2162
+ *
2163
+ * hashclauses original form of the hashjoin condition
2164
+ * hj_OuterHashKeys the outer hash keys in the hashjoin condition
2165
+ * hj_HashOperators the join operators in the hashjoin condition
2166
+ * hj_HashTable hash table for the hashjoin
2167
+ * (NULL if table not built yet)
2168
+ * hj_CurHashValue hash value for current outer tuple
2169
+ * hj_CurBucketNo regular bucket# for current outer tuple
2170
+ * hj_CurSkewBucketNo skew bucket# for current outer tuple
2171
+ * hj_CurTuple last inner tuple matched to current outer
2172
+ * tuple, or NULL if starting search
2173
+ * (hj_CurXXX variables are undefined if
2174
+ * OuterTupleSlot is empty!)
2175
+ * hj_OuterTupleSlot tuple slot for outer tuples
2176
+ * hj_HashTupleSlot tuple slot for inner (hashed) tuples
2177
+ * hj_NullOuterTupleSlot prepared null tuple for right/right-anti/full
2178
+ * outer joins
2179
+ * hj_NullInnerTupleSlot prepared null tuple for left/full outer joins
2180
+ * hj_FirstOuterTupleSlot first tuple retrieved from outer plan
2181
+ * hj_JoinState current state of ExecHashJoin state machine
2182
+ * hj_MatchedOuter true if found a join match for current outer
2183
+ * hj_OuterNotEmpty true if outer relation known not empty
2184
+ * ----------------
2185
+ */
2186
+
2187
+ /* these structs are defined in executor/hashjoin.h: */
2188
+ typedef struct HashJoinTupleData *HashJoinTuple;
2189
+ typedef struct HashJoinTableData *HashJoinTable;
2190
+
2191
+ typedef struct HashJoinState
2192
+ {
2193
+ JoinState js; /* its first field is NodeTag */
2194
+ ExprState *hashclauses;
2195
+ List *hj_OuterHashKeys; /* list of ExprState nodes */
2196
+ List *hj_HashOperators; /* list of operator OIDs */
2197
+ List *hj_Collations;
2198
+ HashJoinTable hj_HashTable;
2199
+ uint32 hj_CurHashValue;
2200
+ int hj_CurBucketNo;
2201
+ int hj_CurSkewBucketNo;
2202
+ HashJoinTuple hj_CurTuple;
2203
+ TupleTableSlot *hj_OuterTupleSlot;
2204
+ TupleTableSlot *hj_HashTupleSlot;
2205
+ TupleTableSlot *hj_NullOuterTupleSlot;
2206
+ TupleTableSlot *hj_NullInnerTupleSlot;
2207
+ TupleTableSlot *hj_FirstOuterTupleSlot;
2208
+ int hj_JoinState;
2209
+ bool hj_MatchedOuter;
2210
+ bool hj_OuterNotEmpty;
2211
+ } HashJoinState;
2212
+
2213
+
2214
+ /* ----------------------------------------------------------------
2215
+ * Materialization State Information
2216
+ * ----------------------------------------------------------------
2217
+ */
2218
+
2219
+ /* ----------------
2220
+ * MaterialState information
2221
+ *
2222
+ * materialize nodes are used to materialize the results
2223
+ * of a subplan into a temporary file.
2224
+ *
2225
+ * ss.ss_ScanTupleSlot refers to output of underlying plan.
2226
+ * ----------------
2227
+ */
2228
+ typedef struct MaterialState
2229
+ {
2230
+ ScanState ss; /* its first field is NodeTag */
2231
+ int eflags; /* capability flags to pass to tuplestore */
2232
+ bool eof_underlying; /* reached end of underlying plan? */
2233
+ Tuplestorestate *tuplestorestate;
2234
+ } MaterialState;
2235
+
2236
+ struct MemoizeEntry;
2237
+ struct MemoizeTuple;
2238
+ struct MemoizeKey;
2239
+
2240
+ typedef struct MemoizeInstrumentation
2241
+ {
2242
+ uint64 cache_hits; /* number of rescans where we've found the
2243
+ * scan parameter values to be cached */
2244
+ uint64 cache_misses; /* number of rescans where we've not found the
2245
+ * scan parameter values to be cached. */
2246
+ uint64 cache_evictions; /* number of cache entries removed due to
2247
+ * the need to free memory */
2248
+ uint64 cache_overflows; /* number of times we've had to bypass the
2249
+ * cache when filling it due to not being
2250
+ * able to free enough space to store the
2251
+ * current scan's tuples. */
2252
+ uint64 mem_peak; /* peak memory usage in bytes */
2253
+ } MemoizeInstrumentation;
2254
+
2255
+ /* ----------------
2256
+ * Shared memory container for per-worker memoize information
2257
+ * ----------------
2258
+ */
2259
+ typedef struct SharedMemoizeInfo
2260
+ {
2261
+ int num_workers;
2262
+ MemoizeInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
2263
+ } SharedMemoizeInfo;
2264
+
2265
+ /* ----------------
2266
+ * MemoizeState information
2267
+ *
2268
+ * memoize nodes are used to cache recent and commonly seen results from
2269
+ * a parameterized scan.
2270
+ * ----------------
2271
+ */
2272
+ typedef struct MemoizeState
2273
+ {
2274
+ ScanState ss; /* its first field is NodeTag */
2275
+ int mstatus; /* value of ExecMemoize state machine */
2276
+ int nkeys; /* number of cache keys */
2277
+ struct memoize_hash *hashtable; /* hash table for cache entries */
2278
+ TupleDesc hashkeydesc; /* tuple descriptor for cache keys */
2279
+ TupleTableSlot *tableslot; /* min tuple slot for existing cache entries */
2280
+ TupleTableSlot *probeslot; /* virtual slot used for hash lookups */
2281
+ ExprState *cache_eq_expr; /* Compare exec params to hash key */
2282
+ ExprState **param_exprs; /* exprs containing the parameters to this
2283
+ * node */
2284
+ FmgrInfo *hashfunctions; /* lookup data for hash funcs nkeys in size */
2285
+ Oid *collations; /* collation for comparisons nkeys in size */
2286
+ uint64 mem_used; /* bytes of memory used by cache */
2287
+ uint64 mem_limit; /* memory limit in bytes for the cache */
2288
+ MemoryContext tableContext; /* memory context to store cache data */
2289
+ dlist_head lru_list; /* least recently used entry list */
2290
+ struct MemoizeTuple *last_tuple; /* Used to point to the last tuple
2291
+ * returned during a cache hit and the
2292
+ * tuple we last stored when
2293
+ * populating the cache. */
2294
+ struct MemoizeEntry *entry; /* the entry that 'last_tuple' belongs to or
2295
+ * NULL if 'last_tuple' is NULL. */
2296
+ bool singlerow; /* true if the cache entry is to be marked as
2297
+ * complete after caching the first tuple. */
2298
+ bool binary_mode; /* true when cache key should be compared bit
2299
+ * by bit, false when using hash equality ops */
2300
+ MemoizeInstrumentation stats; /* execution statistics */
2301
+ SharedMemoizeInfo *shared_info; /* statistics for parallel workers */
2302
+ Bitmapset *keyparamids; /* Param->paramids of expressions belonging to
2303
+ * param_exprs */
2304
+ } MemoizeState;
2305
+
2306
+ /* ----------------
2307
+ * When performing sorting by multiple keys, it's possible that the input
2308
+ * dataset is already sorted on a prefix of those keys. We call these
2309
+ * "presorted keys".
2310
+ * PresortedKeyData represents information about one such key.
2311
+ * ----------------
2312
+ */
2313
+ typedef struct PresortedKeyData
2314
+ {
2315
+ FmgrInfo flinfo; /* comparison function info */
2316
+ FunctionCallInfo fcinfo; /* comparison function call info */
2317
+ OffsetNumber attno; /* attribute number in tuple */
2318
+ } PresortedKeyData;
2319
+
2320
+ /* ----------------
2321
+ * Shared memory container for per-worker sort information
2322
+ * ----------------
2323
+ */
2324
+ typedef struct SharedSortInfo
2325
+ {
2326
+ int num_workers;
2327
+ TuplesortInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
2328
+ } SharedSortInfo;
2329
+
2330
+ /* ----------------
2331
+ * SortState information
2332
+ * ----------------
2333
+ */
2334
+ typedef struct SortState
2335
+ {
2336
+ ScanState ss; /* its first field is NodeTag */
2337
+ bool randomAccess; /* need random access to sort output? */
2338
+ bool bounded; /* is the result set bounded? */
2339
+ int64 bound; /* if bounded, how many tuples are needed */
2340
+ bool sort_Done; /* sort completed yet? */
2341
+ bool bounded_Done; /* value of bounded we did the sort with */
2342
+ int64 bound_Done; /* value of bound we did the sort with */
2343
+ void *tuplesortstate; /* private state of tuplesort.c */
2344
+ bool am_worker; /* are we a worker? */
2345
+ bool datumSort; /* Datum sort instead of tuple sort? */
2346
+ SharedSortInfo *shared_info; /* one entry per worker */
2347
+ } SortState;
2348
+
2349
+ /* ----------------
2350
+ * Instrumentation information for IncrementalSort
2351
+ * ----------------
2352
+ */
2353
+ typedef struct IncrementalSortGroupInfo
2354
+ {
2355
+ int64 groupCount;
2356
+ int64 maxDiskSpaceUsed;
2357
+ int64 totalDiskSpaceUsed;
2358
+ int64 maxMemorySpaceUsed;
2359
+ int64 totalMemorySpaceUsed;
2360
+ bits32 sortMethods; /* bitmask of TuplesortMethod */
2361
+ } IncrementalSortGroupInfo;
2362
+
2363
+ typedef struct IncrementalSortInfo
2364
+ {
2365
+ IncrementalSortGroupInfo fullsortGroupInfo;
2366
+ IncrementalSortGroupInfo prefixsortGroupInfo;
2367
+ } IncrementalSortInfo;
2368
+
2369
+ /* ----------------
2370
+ * Shared memory container for per-worker incremental sort information
2371
+ * ----------------
2372
+ */
2373
+ typedef struct SharedIncrementalSortInfo
2374
+ {
2375
+ int num_workers;
2376
+ IncrementalSortInfo sinfo[FLEXIBLE_ARRAY_MEMBER];
2377
+ } SharedIncrementalSortInfo;
2378
+
2379
+ /* ----------------
2380
+ * IncrementalSortState information
2381
+ * ----------------
2382
+ */
2383
+ typedef enum
2384
+ {
2385
+ INCSORT_LOADFULLSORT,
2386
+ INCSORT_LOADPREFIXSORT,
2387
+ INCSORT_READFULLSORT,
2388
+ INCSORT_READPREFIXSORT,
2389
+ } IncrementalSortExecutionStatus;
2390
+
2391
+ typedef struct IncrementalSortState
2392
+ {
2393
+ ScanState ss; /* its first field is NodeTag */
2394
+ bool bounded; /* is the result set bounded? */
2395
+ int64 bound; /* if bounded, how many tuples are needed */
2396
+ bool outerNodeDone; /* finished fetching tuples from outer node */
2397
+ int64 bound_Done; /* value of bound we did the sort with */
2398
+ IncrementalSortExecutionStatus execution_status;
2399
+ int64 n_fullsort_remaining;
2400
+ Tuplesortstate *fullsort_state; /* private state of tuplesort.c */
2401
+ Tuplesortstate *prefixsort_state; /* private state of tuplesort.c */
2402
+ /* the keys by which the input path is already sorted */
2403
+ PresortedKeyData *presorted_keys;
2404
+
2405
+ IncrementalSortInfo incsort_info;
2406
+
2407
+ /* slot for pivot tuple defining values of presorted keys within group */
2408
+ TupleTableSlot *group_pivot;
2409
+ TupleTableSlot *transfer_tuple;
2410
+ bool am_worker; /* are we a worker? */
2411
+ SharedIncrementalSortInfo *shared_info; /* one entry per worker */
2412
+ } IncrementalSortState;
2413
+
2414
+ /* ---------------------
2415
+ * GroupState information
2416
+ * ---------------------
2417
+ */
2418
+ typedef struct GroupState
2419
+ {
2420
+ ScanState ss; /* its first field is NodeTag */
2421
+ ExprState *eqfunction; /* equality function */
2422
+ bool grp_done; /* indicates completion of Group scan */
2423
+ } GroupState;
2424
+
2425
+ /* ---------------------
2426
+ * per-worker aggregate information
2427
+ * ---------------------
2428
+ */
2429
+ typedef struct AggregateInstrumentation
2430
+ {
2431
+ Size hash_mem_peak; /* peak hash table memory usage */
2432
+ uint64 hash_disk_used; /* kB of disk space used */
2433
+ int hash_batches_used; /* batches used during entire execution */
2434
+ } AggregateInstrumentation;
2435
+
2436
+ /* ----------------
2437
+ * Shared memory container for per-worker aggregate information
2438
+ * ----------------
2439
+ */
2440
+ typedef struct SharedAggInfo
2441
+ {
2442
+ int num_workers;
2443
+ AggregateInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
2444
+ } SharedAggInfo;
2445
+
2446
+ /* ---------------------
2447
+ * AggState information
2448
+ *
2449
+ * ss.ss_ScanTupleSlot refers to output of underlying plan.
2450
+ *
2451
+ * Note: ss.ps.ps_ExprContext contains ecxt_aggvalues and
2452
+ * ecxt_aggnulls arrays, which hold the computed agg values for the current
2453
+ * input group during evaluation of an Agg node's output tuple(s). We
2454
+ * create a second ExprContext, tmpcontext, in which to evaluate input
2455
+ * expressions and run the aggregate transition functions.
2456
+ * ---------------------
2457
+ */
2458
+ /* these structs are private in nodeAgg.c: */
2459
+ typedef struct AggStatePerAggData *AggStatePerAgg;
2460
+ typedef struct AggStatePerTransData *AggStatePerTrans;
2461
+ typedef struct AggStatePerGroupData *AggStatePerGroup;
2462
+ typedef struct AggStatePerPhaseData *AggStatePerPhase;
2463
+ typedef struct AggStatePerHashData *AggStatePerHash;
2464
+
2465
+ typedef struct AggState
2466
+ {
2467
+ ScanState ss; /* its first field is NodeTag */
2468
+ List *aggs; /* all Aggref nodes in targetlist & quals */
2469
+ int numaggs; /* length of list (could be zero!) */
2470
+ int numtrans; /* number of pertrans items */
2471
+ AggStrategy aggstrategy; /* strategy mode */
2472
+ AggSplit aggsplit; /* agg-splitting mode, see nodes.h */
2473
+ AggStatePerPhase phase; /* pointer to current phase data */
2474
+ int numphases; /* number of phases (including phase 0) */
2475
+ int current_phase; /* current phase number */
2476
+ AggStatePerAgg peragg; /* per-Aggref information */
2477
+ AggStatePerTrans pertrans; /* per-Trans state information */
2478
+ ExprContext *hashcontext; /* econtexts for long-lived data (hashtable) */
2479
+ ExprContext **aggcontexts; /* econtexts for long-lived data (per GS) */
2480
+ ExprContext *tmpcontext; /* econtext for input expressions */
2481
+ #define FIELDNO_AGGSTATE_CURAGGCONTEXT 14
2482
+ ExprContext *curaggcontext; /* currently active aggcontext */
2483
+ AggStatePerAgg curperagg; /* currently active aggregate, if any */
2484
+ #define FIELDNO_AGGSTATE_CURPERTRANS 16
2485
+ AggStatePerTrans curpertrans; /* currently active trans state, if any */
2486
+ bool input_done; /* indicates end of input */
2487
+ bool agg_done; /* indicates completion of Agg scan */
2488
+ int projected_set; /* The last projected grouping set */
2489
+ #define FIELDNO_AGGSTATE_CURRENT_SET 20
2490
+ int current_set; /* The current grouping set being evaluated */
2491
+ Bitmapset *grouped_cols; /* grouped cols in current projection */
2492
+ List *all_grouped_cols; /* list of all grouped cols in DESC order */
2493
+ Bitmapset *colnos_needed; /* all columns needed from the outer plan */
2494
+ int max_colno_needed; /* highest colno needed from outer plan */
2495
+ bool all_cols_needed; /* are all cols from outer plan needed? */
2496
+ /* These fields are for grouping set phase data */
2497
+ int maxsets; /* The max number of sets in any phase */
2498
+ AggStatePerPhase phases; /* array of all phases */
2499
+ Tuplesortstate *sort_in; /* sorted input to phases > 1 */
2500
+ Tuplesortstate *sort_out; /* input is copied here for next phase */
2501
+ TupleTableSlot *sort_slot; /* slot for sort results */
2502
+ /* these fields are used in AGG_PLAIN and AGG_SORTED modes: */
2503
+ AggStatePerGroup *pergroups; /* grouping set indexed array of per-group
2504
+ * pointers */
2505
+ HeapTuple grp_firstTuple; /* copy of first tuple of current group */
2506
+ /* these fields are used in AGG_HASHED and AGG_MIXED modes: */
2507
+ bool table_filled; /* hash table filled yet? */
2508
+ int num_hashes;
2509
+ MemoryContext hash_metacxt; /* memory for hash table itself */
2510
+ struct LogicalTapeSet *hash_tapeset; /* tape set for hash spill tapes */
2511
+ struct HashAggSpill *hash_spills; /* HashAggSpill for each grouping set,
2512
+ * exists only during first pass */
2513
+ TupleTableSlot *hash_spill_rslot; /* for reading spill files */
2514
+ TupleTableSlot *hash_spill_wslot; /* for writing spill files */
2515
+ List *hash_batches; /* hash batches remaining to be processed */
2516
+ bool hash_ever_spilled; /* ever spilled during this execution? */
2517
+ bool hash_spill_mode; /* we hit a limit during the current batch
2518
+ * and we must not create new groups */
2519
+ Size hash_mem_limit; /* limit before spilling hash table */
2520
+ uint64 hash_ngroups_limit; /* limit before spilling hash table */
2521
+ int hash_planned_partitions; /* number of partitions planned
2522
+ * for first pass */
2523
+ double hashentrysize; /* estimate revised during execution */
2524
+ Size hash_mem_peak; /* peak hash table memory usage */
2525
+ uint64 hash_ngroups_current; /* number of groups currently in
2526
+ * memory in all hash tables */
2527
+ uint64 hash_disk_used; /* kB of disk space used */
2528
+ int hash_batches_used; /* batches used during entire execution */
2529
+
2530
+ AggStatePerHash perhash; /* array of per-hashtable data */
2531
+ AggStatePerGroup *hash_pergroup; /* grouping set indexed array of
2532
+ * per-group pointers */
2533
+
2534
+ /* support for evaluation of agg input expressions: */
2535
+ #define FIELDNO_AGGSTATE_ALL_PERGROUPS 53
2536
+ AggStatePerGroup *all_pergroups; /* array of first ->pergroups, than
2537
+ * ->hash_pergroup */
2538
+ SharedAggInfo *shared_info; /* one entry per worker */
2539
+ } AggState;
2540
+
2541
+ /* ----------------
2542
+ * WindowAggState information
2543
+ * ----------------
2544
+ */
2545
+ /* these structs are private in nodeWindowAgg.c: */
2546
+ typedef struct WindowStatePerFuncData *WindowStatePerFunc;
2547
+ typedef struct WindowStatePerAggData *WindowStatePerAgg;
2548
+
2549
+ /*
2550
+ * WindowAggStatus -- Used to track the status of WindowAggState
2551
+ */
2552
+ typedef enum WindowAggStatus
2553
+ {
2554
+ WINDOWAGG_DONE, /* No more processing to do */
2555
+ WINDOWAGG_RUN, /* Normal processing of window funcs */
2556
+ WINDOWAGG_PASSTHROUGH, /* Don't eval window funcs */
2557
+ WINDOWAGG_PASSTHROUGH_STRICT, /* Pass-through plus don't store new
2558
+ * tuples during spool */
2559
+ } WindowAggStatus;
2560
+
2561
+ typedef struct WindowAggState
2562
+ {
2563
+ ScanState ss; /* its first field is NodeTag */
2564
+
2565
+ /* these fields are filled in by ExecInitExpr: */
2566
+ List *funcs; /* all WindowFunc nodes in targetlist */
2567
+ int numfuncs; /* total number of window functions */
2568
+ int numaggs; /* number that are plain aggregates */
2569
+
2570
+ WindowStatePerFunc perfunc; /* per-window-function information */
2571
+ WindowStatePerAgg peragg; /* per-plain-aggregate information */
2572
+ ExprState *partEqfunction; /* equality funcs for partition columns */
2573
+ ExprState *ordEqfunction; /* equality funcs for ordering columns */
2574
+ Tuplestorestate *buffer; /* stores rows of current partition */
2575
+ int current_ptr; /* read pointer # for current row */
2576
+ int framehead_ptr; /* read pointer # for frame head, if used */
2577
+ int frametail_ptr; /* read pointer # for frame tail, if used */
2578
+ int grouptail_ptr; /* read pointer # for group tail, if used */
2579
+ int64 spooled_rows; /* total # of rows in buffer */
2580
+ int64 currentpos; /* position of current row in partition */
2581
+ int64 frameheadpos; /* current frame head position */
2582
+ int64 frametailpos; /* current frame tail position (frame end+1) */
2583
+ /* use struct pointer to avoid including windowapi.h here */
2584
+ struct WindowObjectData *agg_winobj; /* winobj for aggregate fetches */
2585
+ int64 aggregatedbase; /* start row for current aggregates */
2586
+ int64 aggregatedupto; /* rows before this one are aggregated */
2587
+ WindowAggStatus status; /* run status of WindowAggState */
2588
+
2589
+ int frameOptions; /* frame_clause options, see WindowDef */
2590
+ ExprState *startOffset; /* expression for starting bound offset */
2591
+ ExprState *endOffset; /* expression for ending bound offset */
2592
+ Datum startOffsetValue; /* result of startOffset evaluation */
2593
+ Datum endOffsetValue; /* result of endOffset evaluation */
2594
+
2595
+ /* these fields are used with RANGE offset PRECEDING/FOLLOWING: */
2596
+ FmgrInfo startInRangeFunc; /* in_range function for startOffset */
2597
+ FmgrInfo endInRangeFunc; /* in_range function for endOffset */
2598
+ Oid inRangeColl; /* collation for in_range tests */
2599
+ bool inRangeAsc; /* use ASC sort order for in_range tests? */
2600
+ bool inRangeNullsFirst; /* nulls sort first for in_range tests? */
2601
+
2602
+ /* these fields are used in GROUPS mode: */
2603
+ int64 currentgroup; /* peer group # of current row in partition */
2604
+ int64 frameheadgroup; /* peer group # of frame head row */
2605
+ int64 frametailgroup; /* peer group # of frame tail row */
2606
+ int64 groupheadpos; /* current row's peer group head position */
2607
+ int64 grouptailpos; /* " " " " tail position (group end+1) */
2608
+
2609
+ MemoryContext partcontext; /* context for partition-lifespan data */
2610
+ MemoryContext aggcontext; /* shared context for aggregate working data */
2611
+ MemoryContext curaggcontext; /* current aggregate's working data */
2612
+ ExprContext *tmpcontext; /* short-term evaluation context */
2613
+
2614
+ ExprState *runcondition; /* Condition which must remain true otherwise
2615
+ * execution of the WindowAgg will finish or
2616
+ * go into pass-through mode. NULL when there
2617
+ * is no such condition. */
2618
+
2619
+ bool use_pass_through; /* When false, stop execution when
2620
+ * runcondition is no longer true. Else
2621
+ * just stop evaluating window funcs. */
2622
+ bool top_window; /* true if this is the top-most WindowAgg or
2623
+ * the only WindowAgg in this query level */
2624
+ bool all_first; /* true if the scan is starting */
2625
+ bool partition_spooled; /* true if all tuples in current partition
2626
+ * have been spooled into tuplestore */
2627
+ bool more_partitions; /* true if there's more partitions after
2628
+ * this one */
2629
+ bool framehead_valid; /* true if frameheadpos is known up to
2630
+ * date for current row */
2631
+ bool frametail_valid; /* true if frametailpos is known up to
2632
+ * date for current row */
2633
+ bool grouptail_valid; /* true if grouptailpos is known up to
2634
+ * date for current row */
2635
+
2636
+ TupleTableSlot *first_part_slot; /* first tuple of current or next
2637
+ * partition */
2638
+ TupleTableSlot *framehead_slot; /* first tuple of current frame */
2639
+ TupleTableSlot *frametail_slot; /* first tuple after current frame */
2640
+
2641
+ /* temporary slots for tuples fetched back from tuplestore */
2642
+ TupleTableSlot *agg_row_slot;
2643
+ TupleTableSlot *temp_slot_1;
2644
+ TupleTableSlot *temp_slot_2;
2645
+ } WindowAggState;
2646
+
2647
+ /* ----------------
2648
+ * UniqueState information
2649
+ *
2650
+ * Unique nodes are used "on top of" sort nodes to discard
2651
+ * duplicate tuples returned from the sort phase. Basically
2652
+ * all it does is compare the current tuple from the subplan
2653
+ * with the previously fetched tuple (stored in its result slot).
2654
+ * If the two are identical in all interesting fields, then
2655
+ * we just fetch another tuple from the sort and try again.
2656
+ * ----------------
2657
+ */
2658
+ typedef struct UniqueState
2659
+ {
2660
+ PlanState ps; /* its first field is NodeTag */
2661
+ ExprState *eqfunction; /* tuple equality qual */
2662
+ } UniqueState;
2663
+
2664
+ /* ----------------
2665
+ * GatherState information
2666
+ *
2667
+ * Gather nodes launch 1 or more parallel workers, run a subplan
2668
+ * in those workers, and collect the results.
2669
+ * ----------------
2670
+ */
2671
+ typedef struct GatherState
2672
+ {
2673
+ PlanState ps; /* its first field is NodeTag */
2674
+ bool initialized; /* workers launched? */
2675
+ bool need_to_scan_locally; /* need to read from local plan? */
2676
+ int64 tuples_needed; /* tuple bound, see ExecSetTupleBound */
2677
+ /* these fields are set up once: */
2678
+ TupleTableSlot *funnel_slot;
2679
+ struct ParallelExecutorInfo *pei;
2680
+ /* all remaining fields are reinitialized during a rescan: */
2681
+ int nworkers_launched; /* original number of workers */
2682
+ int nreaders; /* number of still-active workers */
2683
+ int nextreader; /* next one to try to read from */
2684
+ struct TupleQueueReader **reader; /* array with nreaders active entries */
2685
+ } GatherState;
2686
+
2687
+ /* ----------------
2688
+ * GatherMergeState information
2689
+ *
2690
+ * Gather merge nodes launch 1 or more parallel workers, run a
2691
+ * subplan which produces sorted output in each worker, and then
2692
+ * merge the results into a single sorted stream.
2693
+ * ----------------
2694
+ */
2695
+ struct GMReaderTupleBuffer; /* private in nodeGatherMerge.c */
2696
+
2697
+ typedef struct GatherMergeState
2698
+ {
2699
+ PlanState ps; /* its first field is NodeTag */
2700
+ bool initialized; /* workers launched? */
2701
+ bool gm_initialized; /* gather_merge_init() done? */
2702
+ bool need_to_scan_locally; /* need to read from local plan? */
2703
+ int64 tuples_needed; /* tuple bound, see ExecSetTupleBound */
2704
+ /* these fields are set up once: */
2705
+ TupleDesc tupDesc; /* descriptor for subplan result tuples */
2706
+ int gm_nkeys; /* number of sort columns */
2707
+ SortSupport gm_sortkeys; /* array of length gm_nkeys */
2708
+ struct ParallelExecutorInfo *pei;
2709
+ /* all remaining fields are reinitialized during a rescan */
2710
+ /* (but the arrays are not reallocated, just cleared) */
2711
+ int nworkers_launched; /* original number of workers */
2712
+ int nreaders; /* number of active workers */
2713
+ TupleTableSlot **gm_slots; /* array with nreaders+1 entries */
2714
+ struct TupleQueueReader **reader; /* array with nreaders active entries */
2715
+ struct GMReaderTupleBuffer *gm_tuple_buffers; /* nreaders tuple buffers */
2716
+ struct binaryheap *gm_heap; /* binary heap of slot indices */
2717
+ } GatherMergeState;
2718
+
2719
+ /* ----------------
2720
+ * Values displayed by EXPLAIN ANALYZE
2721
+ * ----------------
2722
+ */
2723
+ typedef struct HashInstrumentation
2724
+ {
2725
+ int nbuckets; /* number of buckets at end of execution */
2726
+ int nbuckets_original; /* planned number of buckets */
2727
+ int nbatch; /* number of batches at end of execution */
2728
+ int nbatch_original; /* planned number of batches */
2729
+ Size space_peak; /* peak memory usage in bytes */
2730
+ } HashInstrumentation;
2731
+
2732
+ /* ----------------
2733
+ * Shared memory container for per-worker hash information
2734
+ * ----------------
2735
+ */
2736
+ typedef struct SharedHashInfo
2737
+ {
2738
+ int num_workers;
2739
+ HashInstrumentation hinstrument[FLEXIBLE_ARRAY_MEMBER];
2740
+ } SharedHashInfo;
2741
+
2742
+ /* ----------------
2743
+ * HashState information
2744
+ * ----------------
2745
+ */
2746
+ typedef struct HashState
2747
+ {
2748
+ PlanState ps; /* its first field is NodeTag */
2749
+ HashJoinTable hashtable; /* hash table for the hashjoin */
2750
+ List *hashkeys; /* list of ExprState nodes */
2751
+
2752
+ /*
2753
+ * In a parallelized hash join, the leader retains a pointer to the
2754
+ * shared-memory stats area in its shared_info field, and then copies the
2755
+ * shared-memory info back to local storage before DSM shutdown. The
2756
+ * shared_info field remains NULL in workers, or in non-parallel joins.
2757
+ */
2758
+ SharedHashInfo *shared_info;
2759
+
2760
+ /*
2761
+ * If we are collecting hash stats, this points to an initially-zeroed
2762
+ * collection area, which could be either local storage or in shared
2763
+ * memory; either way it's for just one process.
2764
+ */
2765
+ HashInstrumentation *hinstrument;
2766
+
2767
+ /* Parallel hash state. */
2768
+ struct ParallelHashJoinState *parallel_state;
2769
+ } HashState;
2770
+
2771
+ /* ----------------
2772
+ * SetOpState information
2773
+ *
2774
+ * Even in "sorted" mode, SetOp nodes are more complex than a simple
2775
+ * Unique, since we have to count how many duplicates to return. But
2776
+ * we also support hashing, so this is really more like a cut-down
2777
+ * form of Agg.
2778
+ * ----------------
2779
+ */
2780
+ /* this struct is private in nodeSetOp.c: */
2781
+ typedef struct SetOpStatePerGroupData *SetOpStatePerGroup;
2782
+
2783
+ typedef struct SetOpState
2784
+ {
2785
+ PlanState ps; /* its first field is NodeTag */
2786
+ ExprState *eqfunction; /* equality comparator */
2787
+ Oid *eqfuncoids; /* per-grouping-field equality fns */
2788
+ FmgrInfo *hashfunctions; /* per-grouping-field hash fns */
2789
+ bool setop_done; /* indicates completion of output scan */
2790
+ long numOutput; /* number of dups left to output */
2791
+ /* these fields are used in SETOP_SORTED mode: */
2792
+ SetOpStatePerGroup pergroup; /* per-group working state */
2793
+ HeapTuple grp_firstTuple; /* copy of first tuple of current group */
2794
+ /* these fields are used in SETOP_HASHED mode: */
2795
+ TupleHashTable hashtable; /* hash table with one entry per group */
2796
+ MemoryContext tableContext; /* memory context containing hash table */
2797
+ bool table_filled; /* hash table filled yet? */
2798
+ TupleHashIterator hashiter; /* for iterating through hash table */
2799
+ } SetOpState;
2800
+
2801
+ /* ----------------
2802
+ * LockRowsState information
2803
+ *
2804
+ * LockRows nodes are used to enforce FOR [KEY] UPDATE/SHARE locking.
2805
+ * ----------------
2806
+ */
2807
+ typedef struct LockRowsState
2808
+ {
2809
+ PlanState ps; /* its first field is NodeTag */
2810
+ List *lr_arowMarks; /* List of ExecAuxRowMarks */
2811
+ EPQState lr_epqstate; /* for evaluating EvalPlanQual rechecks */
2812
+ } LockRowsState;
2813
+
2814
+ /* ----------------
2815
+ * LimitState information
2816
+ *
2817
+ * Limit nodes are used to enforce LIMIT/OFFSET clauses.
2818
+ * They just select the desired subrange of their subplan's output.
2819
+ *
2820
+ * offset is the number of initial tuples to skip (0 does nothing).
2821
+ * count is the number of tuples to return after skipping the offset tuples.
2822
+ * If no limit count was specified, count is undefined and noCount is true.
2823
+ * When lstate == LIMIT_INITIAL, offset/count/noCount haven't been set yet.
2824
+ * ----------------
2825
+ */
2826
+ typedef enum
2827
+ {
2828
+ LIMIT_INITIAL, /* initial state for LIMIT node */
2829
+ LIMIT_RESCAN, /* rescan after recomputing parameters */
2830
+ LIMIT_EMPTY, /* there are no returnable rows */
2831
+ LIMIT_INWINDOW, /* have returned a row in the window */
2832
+ LIMIT_WINDOWEND_TIES, /* have returned a tied row */
2833
+ LIMIT_SUBPLANEOF, /* at EOF of subplan (within window) */
2834
+ LIMIT_WINDOWEND, /* stepped off end of window */
2835
+ LIMIT_WINDOWSTART, /* stepped off beginning of window */
2836
+ } LimitStateCond;
2837
+
2838
+ typedef struct LimitState
2839
+ {
2840
+ PlanState ps; /* its first field is NodeTag */
2841
+ ExprState *limitOffset; /* OFFSET parameter, or NULL if none */
2842
+ ExprState *limitCount; /* COUNT parameter, or NULL if none */
2843
+ LimitOption limitOption; /* limit specification type */
2844
+ int64 offset; /* current OFFSET value */
2845
+ int64 count; /* current COUNT, if any */
2846
+ bool noCount; /* if true, ignore count */
2847
+ LimitStateCond lstate; /* state machine status, as above */
2848
+ int64 position; /* 1-based index of last tuple returned */
2849
+ TupleTableSlot *subSlot; /* tuple last obtained from subplan */
2850
+ ExprState *eqfunction; /* tuple equality qual in case of WITH TIES
2851
+ * option */
2852
+ TupleTableSlot *last_slot; /* slot for evaluation of ties */
2853
+ } LimitState;
2854
+
2855
+ #endif /* EXECNODES_H */