pg_query 4.2.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (901) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +61 -0
  3. data/README.md +7 -9
  4. data/Rakefile +5 -6
  5. data/ext/pg_query/ext_symbols_freebsd.sym +1 -0
  6. data/ext/pg_query/ext_symbols_freebsd_with_ruby_abi_version.sym +2 -0
  7. data/ext/pg_query/ext_symbols_openbsd.sym +1 -0
  8. data/ext/pg_query/ext_symbols_openbsd_with_ruby_abi_version.sym +2 -0
  9. data/ext/pg_query/ext_symbols_with_ruby_abi_version.sym +2 -0
  10. data/ext/pg_query/extconf.rb +33 -9
  11. data/ext/pg_query/include/pg_query.h +28 -3
  12. data/ext/pg_query/include/pg_query_enum_defs.c +599 -167
  13. data/ext/pg_query/include/pg_query_fingerprint_conds.c +640 -520
  14. data/ext/pg_query/include/pg_query_fingerprint_defs.c +6400 -4633
  15. data/ext/pg_query/include/pg_query_outfuncs_conds.c +433 -343
  16. data/ext/pg_query/include/pg_query_outfuncs_defs.c +1472 -1152
  17. data/ext/pg_query/include/pg_query_readfuncs_conds.c +154 -124
  18. data/ext/pg_query/include/pg_query_readfuncs_defs.c +1886 -1506
  19. data/ext/pg_query/include/postgres/access/amapi.h +303 -0
  20. data/ext/pg_query/include/postgres/access/attmap.h +54 -0
  21. data/ext/pg_query/include/postgres/access/attnum.h +64 -0
  22. data/ext/pg_query/include/postgres/access/brin_internal.h +116 -0
  23. data/ext/pg_query/include/postgres/access/brin_tuple.h +112 -0
  24. data/ext/pg_query/include/postgres/access/clog.h +62 -0
  25. data/ext/pg_query/include/postgres/access/commit_ts.h +73 -0
  26. data/ext/pg_query/include/postgres/access/detoast.h +82 -0
  27. data/ext/pg_query/include/postgres/access/genam.h +246 -0
  28. data/ext/pg_query/include/postgres/access/gin.h +91 -0
  29. data/ext/pg_query/include/postgres/access/htup.h +89 -0
  30. data/ext/pg_query/include/postgres/access/htup_details.h +811 -0
  31. data/ext/pg_query/include/postgres/access/itup.h +170 -0
  32. data/ext/pg_query/include/postgres/access/parallel.h +81 -0
  33. data/ext/pg_query/include/postgres/access/printtup.h +35 -0
  34. data/ext/pg_query/include/postgres/access/relation.h +28 -0
  35. data/ext/pg_query/include/postgres/access/relscan.h +191 -0
  36. data/ext/pg_query/include/postgres/access/rmgrlist.h +49 -0
  37. data/ext/pg_query/include/postgres/access/sdir.h +67 -0
  38. data/ext/pg_query/include/postgres/access/skey.h +151 -0
  39. data/ext/pg_query/include/postgres/access/slru.h +218 -0
  40. data/ext/pg_query/include/postgres/access/stratnum.h +85 -0
  41. data/ext/pg_query/include/postgres/access/sysattr.h +29 -0
  42. data/ext/pg_query/include/postgres/access/table.h +28 -0
  43. data/ext/pg_query/include/postgres/access/tableam.h +2110 -0
  44. data/ext/pg_query/include/postgres/access/tidstore.h +50 -0
  45. data/ext/pg_query/include/postgres/access/toast_compression.h +73 -0
  46. data/ext/pg_query/include/postgres/access/transam.h +418 -0
  47. data/ext/pg_query/include/postgres/access/tsmapi.h +82 -0
  48. data/ext/pg_query/include/postgres/access/tupconvert.h +54 -0
  49. data/ext/pg_query/include/postgres/access/tupdesc.h +154 -0
  50. data/ext/pg_query/include/postgres/access/tupmacs.h +207 -0
  51. data/ext/pg_query/include/postgres/access/twophase.h +65 -0
  52. data/ext/pg_query/include/postgres/access/xact.h +530 -0
  53. data/ext/pg_query/include/postgres/access/xlog.h +310 -0
  54. data/ext/pg_query/include/postgres/access/xlog_internal.h +405 -0
  55. data/ext/pg_query/include/postgres/access/xlogbackup.h +43 -0
  56. data/ext/pg_query/include/postgres/access/xlogdefs.h +82 -0
  57. data/ext/pg_query/include/postgres/access/xlogprefetcher.h +55 -0
  58. data/ext/pg_query/include/postgres/access/xlogreader.h +444 -0
  59. data/ext/pg_query/include/postgres/access/xlogrecord.h +248 -0
  60. data/ext/pg_query/include/postgres/access/xlogrecovery.h +158 -0
  61. data/ext/pg_query/include/postgres/archive/archive_module.h +67 -0
  62. data/ext/pg_query/include/postgres/c.h +1374 -0
  63. data/ext/pg_query/include/postgres/catalog/catalog.h +47 -0
  64. data/ext/pg_query/include/postgres/catalog/catversion.h +62 -0
  65. data/ext/pg_query/include/postgres/catalog/dependency.h +228 -0
  66. data/ext/pg_query/include/postgres/catalog/genbki.h +149 -0
  67. data/ext/pg_query/include/postgres/catalog/index.h +218 -0
  68. data/ext/pg_query/include/postgres/catalog/indexing.h +54 -0
  69. data/ext/pg_query/include/postgres/catalog/namespace.h +189 -0
  70. data/ext/pg_query/include/postgres/catalog/objectaccess.h +267 -0
  71. data/ext/pg_query/include/postgres/catalog/objectaddress.h +93 -0
  72. data/ext/pg_query/include/postgres/catalog/pg_aggregate.h +182 -0
  73. data/ext/pg_query/include/postgres/catalog/pg_aggregate_d.h +78 -0
  74. data/ext/pg_query/include/postgres/catalog/pg_am.h +66 -0
  75. data/ext/pg_query/include/postgres/catalog/pg_am_d.h +47 -0
  76. data/ext/pg_query/include/postgres/catalog/pg_attribute.h +240 -0
  77. data/ext/pg_query/include/postgres/catalog/pg_attribute_d.h +62 -0
  78. data/ext/pg_query/include/postgres/catalog/pg_authid.h +66 -0
  79. data/ext/pg_query/include/postgres/catalog/pg_authid_d.h +60 -0
  80. data/ext/pg_query/include/postgres/catalog/pg_class.h +235 -0
  81. data/ext/pg_query/include/postgres/catalog/pg_class_d.h +134 -0
  82. data/ext/pg_query/include/postgres/catalog/pg_collation.h +106 -0
  83. data/ext/pg_query/include/postgres/catalog/pg_collation_d.h +66 -0
  84. data/ext/pg_query/include/postgres/catalog/pg_constraint.h +278 -0
  85. data/ext/pg_query/include/postgres/catalog/pg_constraint_d.h +74 -0
  86. data/ext/pg_query/include/postgres/catalog/pg_control.h +260 -0
  87. data/ext/pg_query/include/postgres/catalog/pg_conversion.h +79 -0
  88. data/ext/pg_query/include/postgres/catalog/pg_conversion_d.h +38 -0
  89. data/ext/pg_query/include/postgres/catalog/pg_database.h +129 -0
  90. data/ext/pg_query/include/postgres/catalog/pg_database_d.h +53 -0
  91. data/ext/pg_query/include/postgres/catalog/pg_depend.h +77 -0
  92. data/ext/pg_query/include/postgres/catalog/pg_depend_d.h +36 -0
  93. data/ext/pg_query/include/postgres/catalog/pg_event_trigger.h +60 -0
  94. data/ext/pg_query/include/postgres/catalog/pg_event_trigger_d.h +36 -0
  95. data/ext/pg_query/include/postgres/catalog/pg_index.h +92 -0
  96. data/ext/pg_query/include/postgres/catalog/pg_index_d.h +59 -0
  97. data/ext/pg_query/include/postgres/catalog/pg_language.h +75 -0
  98. data/ext/pg_query/include/postgres/catalog/pg_language_d.h +41 -0
  99. data/ext/pg_query/include/postgres/catalog/pg_namespace.h +67 -0
  100. data/ext/pg_query/include/postgres/catalog/pg_namespace_d.h +36 -0
  101. data/ext/pg_query/include/postgres/catalog/pg_opclass.h +91 -0
  102. data/ext/pg_query/include/postgres/catalog/pg_opclass_d.h +51 -0
  103. data/ext/pg_query/include/postgres/catalog/pg_operator.h +124 -0
  104. data/ext/pg_query/include/postgres/catalog/pg_operator_d.h +142 -0
  105. data/ext/pg_query/include/postgres/catalog/pg_opfamily.h +67 -0
  106. data/ext/pg_query/include/postgres/catalog/pg_opfamily_d.h +51 -0
  107. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table.h +76 -0
  108. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table_d.h +36 -0
  109. data/ext/pg_query/include/postgres/catalog/pg_proc.h +223 -0
  110. data/ext/pg_query/include/postgres/catalog/pg_proc_d.h +101 -0
  111. data/ext/pg_query/include/postgres/catalog/pg_publication.h +161 -0
  112. data/ext/pg_query/include/postgres/catalog/pg_publication_d.h +38 -0
  113. data/ext/pg_query/include/postgres/catalog/pg_replication_origin.h +65 -0
  114. data/ext/pg_query/include/postgres/catalog/pg_replication_origin_d.h +33 -0
  115. data/ext/pg_query/include/postgres/catalog/pg_statistic.h +288 -0
  116. data/ext/pg_query/include/postgres/catalog/pg_statistic_d.h +199 -0
  117. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext.h +91 -0
  118. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext_d.h +45 -0
  119. data/ext/pg_query/include/postgres/catalog/pg_transform.h +51 -0
  120. data/ext/pg_query/include/postgres/catalog/pg_transform_d.h +34 -0
  121. data/ext/pg_query/include/postgres/catalog/pg_trigger.h +153 -0
  122. data/ext/pg_query/include/postgres/catalog/pg_trigger_d.h +109 -0
  123. data/ext/pg_query/include/postgres/catalog/pg_ts_config.h +56 -0
  124. data/ext/pg_query/include/postgres/catalog/pg_ts_config_d.h +34 -0
  125. data/ext/pg_query/include/postgres/catalog/pg_ts_dict.h +62 -0
  126. data/ext/pg_query/include/postgres/catalog/pg_ts_dict_d.h +35 -0
  127. data/ext/pg_query/include/postgres/catalog/pg_ts_parser.h +63 -0
  128. data/ext/pg_query/include/postgres/catalog/pg_ts_parser_d.h +37 -0
  129. data/ext/pg_query/include/postgres/catalog/pg_ts_template.h +54 -0
  130. data/ext/pg_query/include/postgres/catalog/pg_ts_template_d.h +34 -0
  131. data/ext/pg_query/include/postgres/catalog/pg_type.h +407 -0
  132. data/ext/pg_query/include/postgres/catalog/pg_type_d.h +324 -0
  133. data/ext/pg_query/include/postgres/catalog/storage.h +50 -0
  134. data/ext/pg_query/include/postgres/catalog/syscache_ids.h +104 -0
  135. data/ext/pg_query/include/postgres/commands/async.h +49 -0
  136. data/ext/pg_query/include/postgres/commands/dbcommands.h +37 -0
  137. data/ext/pg_query/include/postgres/commands/defrem.h +161 -0
  138. data/ext/pg_query/include/postgres/commands/event_trigger.h +97 -0
  139. data/ext/pg_query/include/postgres/commands/explain.h +145 -0
  140. data/ext/pg_query/include/postgres/commands/prepare.h +61 -0
  141. data/ext/pg_query/include/postgres/commands/tablespace.h +69 -0
  142. data/ext/pg_query/include/postgres/commands/trigger.h +288 -0
  143. data/ext/pg_query/include/postgres/commands/user.h +43 -0
  144. data/ext/pg_query/include/postgres/commands/vacuum.h +388 -0
  145. data/ext/pg_query/include/postgres/common/cryptohash.h +39 -0
  146. data/ext/pg_query/include/postgres/common/file_perm.h +56 -0
  147. data/ext/pg_query/include/postgres/common/file_utils.h +65 -0
  148. data/ext/pg_query/include/postgres/common/hashfn.h +119 -0
  149. data/ext/pg_query/include/postgres/common/hashfn_unstable.h +407 -0
  150. data/ext/pg_query/include/postgres/common/int.h +512 -0
  151. data/ext/pg_query/include/postgres/common/keywords.h +29 -0
  152. data/ext/pg_query/include/postgres/common/kwlookup.h +44 -0
  153. data/ext/pg_query/include/postgres/common/pg_prng.h +62 -0
  154. data/ext/pg_query/include/postgres/common/relpath.h +97 -0
  155. data/ext/pg_query/include/postgres/common/scram-common.h +70 -0
  156. data/ext/pg_query/include/postgres/common/sha2.h +32 -0
  157. data/ext/pg_query/include/postgres/common/string.h +44 -0
  158. data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +124 -0
  159. data/ext/pg_query/include/postgres/common/unicode_nonspacing_table.h +326 -0
  160. data/ext/pg_query/include/postgres/copyfuncs.funcs.c +5261 -0
  161. data/ext/pg_query/include/postgres/copyfuncs.switch.c +989 -0
  162. data/ext/pg_query/include/postgres/datatype/timestamp.h +269 -0
  163. data/ext/pg_query/include/postgres/equalfuncs.funcs.c +3310 -0
  164. data/ext/pg_query/include/postgres/equalfuncs.switch.c +836 -0
  165. data/ext/pg_query/include/postgres/executor/execdesc.h +70 -0
  166. data/ext/pg_query/include/postgres/executor/executor.h +681 -0
  167. data/ext/pg_query/include/postgres/executor/functions.h +56 -0
  168. data/ext/pg_query/include/postgres/executor/instrument.h +120 -0
  169. data/ext/pg_query/include/postgres/executor/spi.h +207 -0
  170. data/ext/pg_query/include/postgres/executor/tablefunc.h +67 -0
  171. data/ext/pg_query/include/postgres/executor/tuptable.h +523 -0
  172. data/ext/pg_query/include/postgres/fmgr.h +800 -0
  173. data/ext/pg_query/include/postgres/foreign/fdwapi.h +294 -0
  174. data/ext/pg_query/include/postgres/funcapi.h +360 -0
  175. data/ext/pg_query/include/postgres/gram.h +1168 -0
  176. data/ext/pg_query/include/postgres/gramparse.h +75 -0
  177. data/ext/pg_query/include/postgres/jit/jit.h +106 -0
  178. data/ext/pg_query/include/postgres/kwlist_d.h +1164 -0
  179. data/ext/pg_query/include/postgres/lib/dshash.h +130 -0
  180. data/ext/pg_query/include/postgres/lib/ilist.h +1159 -0
  181. data/ext/pg_query/include/postgres/lib/pairingheap.h +102 -0
  182. data/ext/pg_query/include/postgres/lib/simplehash.h +1206 -0
  183. data/ext/pg_query/include/postgres/lib/sort_template.h +445 -0
  184. data/ext/pg_query/include/postgres/lib/stringinfo.h +243 -0
  185. data/ext/pg_query/include/postgres/libpq/auth.h +37 -0
  186. data/ext/pg_query/include/postgres/libpq/crypt.h +47 -0
  187. data/ext/pg_query/include/postgres/libpq/hba.h +186 -0
  188. data/ext/pg_query/include/postgres/libpq/libpq-be.h +361 -0
  189. data/ext/pg_query/include/postgres/libpq/libpq.h +143 -0
  190. data/ext/pg_query/include/postgres/libpq/pqcomm.h +169 -0
  191. data/ext/pg_query/include/postgres/libpq/pqformat.h +209 -0
  192. data/ext/pg_query/include/postgres/libpq/pqsignal.h +54 -0
  193. data/ext/pg_query/include/postgres/libpq/protocol.h +89 -0
  194. data/ext/pg_query/include/postgres/libpq/sasl.h +136 -0
  195. data/ext/pg_query/include/postgres/libpq/scram.h +37 -0
  196. data/ext/pg_query/include/postgres/mb/pg_wchar.h +793 -0
  197. data/ext/pg_query/include/postgres/mb/stringinfo_mb.h +24 -0
  198. data/ext/pg_query/include/postgres/miscadmin.h +527 -0
  199. data/ext/pg_query/include/postgres/nodes/bitmapset.h +140 -0
  200. data/ext/pg_query/include/postgres/nodes/execnodes.h +2855 -0
  201. data/ext/pg_query/include/postgres/nodes/extensible.h +164 -0
  202. data/ext/pg_query/include/postgres/nodes/lockoptions.h +61 -0
  203. data/ext/pg_query/include/postgres/nodes/makefuncs.h +127 -0
  204. data/ext/pg_query/include/postgres/nodes/memnodes.h +152 -0
  205. data/ext/pg_query/include/postgres/nodes/miscnodes.h +56 -0
  206. data/ext/pg_query/include/postgres/nodes/nodeFuncs.h +222 -0
  207. data/ext/pg_query/include/postgres/nodes/nodes.h +435 -0
  208. data/ext/pg_query/include/postgres/nodes/nodetags.h +491 -0
  209. data/ext/pg_query/include/postgres/nodes/params.h +170 -0
  210. data/ext/pg_query/include/postgres/nodes/parsenodes.h +4233 -0
  211. data/ext/pg_query/include/postgres/nodes/pathnodes.h +3438 -0
  212. data/ext/pg_query/include/postgres/nodes/pg_list.h +686 -0
  213. data/ext/pg_query/include/postgres/nodes/plannodes.h +1593 -0
  214. data/ext/pg_query/include/postgres/nodes/primnodes.h +2339 -0
  215. data/ext/pg_query/include/postgres/nodes/print.h +34 -0
  216. data/ext/pg_query/include/postgres/nodes/queryjumble.h +86 -0
  217. data/ext/pg_query/include/postgres/nodes/replnodes.h +132 -0
  218. data/ext/pg_query/include/postgres/nodes/supportnodes.h +346 -0
  219. data/ext/pg_query/include/postgres/nodes/tidbitmap.h +75 -0
  220. data/ext/pg_query/include/postgres/nodes/value.h +90 -0
  221. data/ext/pg_query/include/postgres/optimizer/cost.h +216 -0
  222. data/ext/pg_query/include/postgres/optimizer/geqo.h +90 -0
  223. data/ext/pg_query/include/postgres/optimizer/geqo_gene.h +45 -0
  224. data/ext/pg_query/include/postgres/optimizer/optimizer.h +205 -0
  225. data/ext/pg_query/include/postgres/optimizer/paths.h +271 -0
  226. data/ext/pg_query/include/postgres/optimizer/planmain.h +123 -0
  227. data/ext/pg_query/include/postgres/parser/analyze.h +66 -0
  228. data/ext/pg_query/include/postgres/parser/kwlist.h +518 -0
  229. data/ext/pg_query/include/postgres/parser/parse_agg.h +65 -0
  230. data/ext/pg_query/include/postgres/parser/parse_coerce.h +105 -0
  231. data/ext/pg_query/include/postgres/parser/parse_expr.h +25 -0
  232. data/ext/pg_query/include/postgres/parser/parse_func.h +74 -0
  233. data/ext/pg_query/include/postgres/parser/parse_node.h +358 -0
  234. data/ext/pg_query/include/postgres/parser/parse_oper.h +68 -0
  235. data/ext/pg_query/include/postgres/parser/parse_relation.h +129 -0
  236. data/ext/pg_query/include/postgres/parser/parse_type.h +61 -0
  237. data/ext/pg_query/include/postgres/parser/parser.h +68 -0
  238. data/ext/pg_query/include/postgres/parser/parsetree.h +61 -0
  239. data/ext/pg_query/include/postgres/parser/scanner.h +152 -0
  240. data/ext/pg_query/include/postgres/parser/scansup.h +27 -0
  241. data/ext/pg_query/include/postgres/partitioning/partdefs.h +26 -0
  242. data/ext/pg_query/include/postgres/pg_config.h +985 -0
  243. data/ext/pg_query/include/postgres/pg_config_manual.h +385 -0
  244. data/ext/pg_query/include/postgres/pg_config_os.h +8 -0
  245. data/ext/pg_query/include/postgres/pg_getopt.h +56 -0
  246. data/ext/pg_query/include/postgres/pg_trace.h +17 -0
  247. data/ext/pg_query/include/postgres/pgstat.h +780 -0
  248. data/ext/pg_query/include/postgres/pgtime.h +94 -0
  249. data/ext/pg_query/include/postgres/pl_gram.h +385 -0
  250. data/ext/pg_query/include/postgres/pl_reserved_kwlist.h +52 -0
  251. data/ext/pg_query/include/postgres/pl_reserved_kwlist_d.h +114 -0
  252. data/ext/pg_query/include/postgres/pl_unreserved_kwlist.h +112 -0
  253. data/ext/pg_query/include/postgres/pl_unreserved_kwlist_d.h +246 -0
  254. data/ext/pg_query/include/postgres/plerrcodes.h +998 -0
  255. data/ext/pg_query/include/postgres/plpgsql.h +1342 -0
  256. data/ext/pg_query/include/postgres/port/atomics/arch-arm.h +32 -0
  257. data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +17 -0
  258. data/ext/pg_query/include/postgres/port/atomics/arch-ppc.h +256 -0
  259. data/ext/pg_query/include/postgres/port/atomics/arch-x86.h +254 -0
  260. data/ext/pg_query/include/postgres/port/atomics/fallback.h +170 -0
  261. data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +323 -0
  262. data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +119 -0
  263. data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +121 -0
  264. data/ext/pg_query/include/postgres/port/atomics/generic.h +437 -0
  265. data/ext/pg_query/include/postgres/port/atomics.h +606 -0
  266. data/ext/pg_query/include/postgres/port/pg_bitutils.h +421 -0
  267. data/ext/pg_query/include/postgres/port/pg_bswap.h +161 -0
  268. data/ext/pg_query/include/postgres/port/pg_crc32c.h +110 -0
  269. data/ext/pg_query/include/postgres/port/pg_iovec.h +117 -0
  270. data/ext/pg_query/include/postgres/port/simd.h +422 -0
  271. data/ext/pg_query/include/postgres/port/win32/arpa/inet.h +3 -0
  272. data/ext/pg_query/include/postgres/port/win32/dlfcn.h +1 -0
  273. data/ext/pg_query/include/postgres/port/win32/grp.h +1 -0
  274. data/ext/pg_query/include/postgres/port/win32/netdb.h +7 -0
  275. data/ext/pg_query/include/postgres/port/win32/netinet/in.h +3 -0
  276. data/ext/pg_query/include/postgres/port/win32/netinet/tcp.h +7 -0
  277. data/ext/pg_query/include/postgres/port/win32/pwd.h +3 -0
  278. data/ext/pg_query/include/postgres/port/win32/sys/resource.h +20 -0
  279. data/ext/pg_query/include/postgres/port/win32/sys/select.h +3 -0
  280. data/ext/pg_query/include/postgres/port/win32/sys/socket.h +34 -0
  281. data/ext/pg_query/include/postgres/port/win32/sys/un.h +17 -0
  282. data/ext/pg_query/include/postgres/port/win32/sys/wait.h +3 -0
  283. data/ext/pg_query/include/postgres/port/win32.h +59 -0
  284. data/ext/pg_query/include/postgres/port/win32_msvc/dirent.h +34 -0
  285. data/ext/pg_query/include/postgres/port/win32_msvc/sys/file.h +1 -0
  286. data/ext/pg_query/include/postgres/port/win32_msvc/sys/param.h +1 -0
  287. data/ext/pg_query/include/postgres/port/win32_msvc/sys/time.h +1 -0
  288. data/ext/pg_query/include/postgres/port/win32_msvc/unistd.h +9 -0
  289. data/ext/pg_query/include/postgres/port/win32_msvc/utime.h +3 -0
  290. data/ext/pg_query/include/postgres/port/win32_port.h +582 -0
  291. data/ext/pg_query/include/postgres/port.h +555 -0
  292. data/ext/pg_query/include/postgres/portability/instr_time.h +197 -0
  293. data/ext/pg_query/include/postgres/postgres.h +579 -0
  294. data/ext/pg_query/include/postgres/postgres_ext.h +73 -0
  295. data/ext/pg_query/include/postgres/postmaster/autovacuum.h +69 -0
  296. data/ext/pg_query/include/postgres/postmaster/bgworker.h +164 -0
  297. data/ext/pg_query/include/postgres/postmaster/bgworker_internals.h +60 -0
  298. data/ext/pg_query/include/postgres/postmaster/bgwriter.h +45 -0
  299. data/ext/pg_query/include/postgres/postmaster/interrupt.h +32 -0
  300. data/ext/pg_query/include/postgres/postmaster/pgarch.h +36 -0
  301. data/ext/pg_query/include/postgres/postmaster/postmaster.h +101 -0
  302. data/ext/pg_query/include/postgres/postmaster/startup.h +41 -0
  303. data/ext/pg_query/include/postgres/postmaster/syslogger.h +101 -0
  304. data/ext/pg_query/include/postgres/postmaster/walsummarizer.h +35 -0
  305. data/ext/pg_query/include/postgres/postmaster/walwriter.h +23 -0
  306. data/ext/pg_query/include/postgres/regex/regex.h +272 -0
  307. data/ext/pg_query/include/postgres/replication/logicallauncher.h +34 -0
  308. data/ext/pg_query/include/postgres/replication/logicalproto.h +274 -0
  309. data/ext/pg_query/include/postgres/replication/logicalworker.h +33 -0
  310. data/ext/pg_query/include/postgres/replication/origin.h +73 -0
  311. data/ext/pg_query/include/postgres/replication/reorderbuffer.h +734 -0
  312. data/ext/pg_query/include/postgres/replication/slot.h +289 -0
  313. data/ext/pg_query/include/postgres/replication/slotsync.h +38 -0
  314. data/ext/pg_query/include/postgres/replication/syncrep.h +109 -0
  315. data/ext/pg_query/include/postgres/replication/walreceiver.h +504 -0
  316. data/ext/pg_query/include/postgres/replication/walsender.h +76 -0
  317. data/ext/pg_query/include/postgres/rewrite/prs2lock.h +46 -0
  318. data/ext/pg_query/include/postgres/rewrite/rewriteHandler.h +41 -0
  319. data/ext/pg_query/include/postgres/rewrite/rewriteManip.h +96 -0
  320. data/ext/pg_query/include/postgres/rewrite/rewriteSupport.h +26 -0
  321. data/ext/pg_query/include/postgres/storage/block.h +108 -0
  322. data/ext/pg_query/include/postgres/storage/buf.h +46 -0
  323. data/ext/pg_query/include/postgres/storage/bufmgr.h +411 -0
  324. data/ext/pg_query/include/postgres/storage/bufpage.h +510 -0
  325. data/ext/pg_query/include/postgres/storage/condition_variable.h +73 -0
  326. data/ext/pg_query/include/postgres/storage/dsm.h +61 -0
  327. data/ext/pg_query/include/postgres/storage/dsm_impl.h +79 -0
  328. data/ext/pg_query/include/postgres/storage/fd.h +219 -0
  329. data/ext/pg_query/include/postgres/storage/fileset.h +40 -0
  330. data/ext/pg_query/include/postgres/storage/ipc.h +87 -0
  331. data/ext/pg_query/include/postgres/storage/item.h +19 -0
  332. data/ext/pg_query/include/postgres/storage/itemid.h +184 -0
  333. data/ext/pg_query/include/postgres/storage/itemptr.h +245 -0
  334. data/ext/pg_query/include/postgres/storage/large_object.h +100 -0
  335. data/ext/pg_query/include/postgres/storage/latch.h +196 -0
  336. data/ext/pg_query/include/postgres/storage/lmgr.h +126 -0
  337. data/ext/pg_query/include/postgres/storage/lock.h +624 -0
  338. data/ext/pg_query/include/postgres/storage/lockdefs.h +61 -0
  339. data/ext/pg_query/include/postgres/storage/lwlock.h +228 -0
  340. data/ext/pg_query/include/postgres/storage/lwlocknames.h +47 -0
  341. data/ext/pg_query/include/postgres/storage/off.h +57 -0
  342. data/ext/pg_query/include/postgres/storage/pg_sema.h +61 -0
  343. data/ext/pg_query/include/postgres/storage/pg_shmem.h +93 -0
  344. data/ext/pg_query/include/postgres/storage/pmsignal.h +105 -0
  345. data/ext/pg_query/include/postgres/storage/predicate.h +83 -0
  346. data/ext/pg_query/include/postgres/storage/proc.h +488 -0
  347. data/ext/pg_query/include/postgres/storage/procarray.h +103 -0
  348. data/ext/pg_query/include/postgres/storage/proclist_types.h +53 -0
  349. data/ext/pg_query/include/postgres/storage/procnumber.h +43 -0
  350. data/ext/pg_query/include/postgres/storage/procsignal.h +75 -0
  351. data/ext/pg_query/include/postgres/storage/read_stream.h +65 -0
  352. data/ext/pg_query/include/postgres/storage/relfilelocator.h +100 -0
  353. data/ext/pg_query/include/postgres/storage/s_lock.h +847 -0
  354. data/ext/pg_query/include/postgres/storage/sharedfileset.h +37 -0
  355. data/ext/pg_query/include/postgres/storage/shm_mq.h +86 -0
  356. data/ext/pg_query/include/postgres/storage/shm_toc.h +58 -0
  357. data/ext/pg_query/include/postgres/storage/shmem.h +59 -0
  358. data/ext/pg_query/include/postgres/storage/sinval.h +153 -0
  359. data/ext/pg_query/include/postgres/storage/smgr.h +130 -0
  360. data/ext/pg_query/include/postgres/storage/spin.h +77 -0
  361. data/ext/pg_query/include/postgres/storage/standby.h +109 -0
  362. data/ext/pg_query/include/postgres/storage/standbydefs.h +74 -0
  363. data/ext/pg_query/include/postgres/storage/sync.h +66 -0
  364. data/ext/pg_query/include/postgres/tcop/cmdtag.h +62 -0
  365. data/ext/pg_query/include/postgres/tcop/cmdtaglist.h +219 -0
  366. data/ext/pg_query/include/postgres/tcop/deparse_utility.h +108 -0
  367. data/ext/pg_query/include/postgres/tcop/dest.h +148 -0
  368. data/ext/pg_query/include/postgres/tcop/fastpath.h +20 -0
  369. data/ext/pg_query/include/postgres/tcop/pquery.h +51 -0
  370. data/ext/pg_query/include/postgres/tcop/tcopprot.h +98 -0
  371. data/ext/pg_query/include/postgres/tcop/utility.h +112 -0
  372. data/ext/pg_query/include/postgres/tsearch/ts_cache.h +96 -0
  373. data/ext/pg_query/include/postgres/utils/acl.h +290 -0
  374. data/ext/pg_query/include/postgres/utils/aclchk_internal.h +45 -0
  375. data/ext/pg_query/include/postgres/utils/array.h +481 -0
  376. data/ext/pg_query/include/postgres/utils/ascii.h +84 -0
  377. data/ext/pg_query/include/postgres/utils/backend_progress.h +46 -0
  378. data/ext/pg_query/include/postgres/utils/backend_status.h +340 -0
  379. data/ext/pg_query/include/postgres/utils/builtins.h +139 -0
  380. data/ext/pg_query/include/postgres/utils/bytea.h +28 -0
  381. data/ext/pg_query/include/postgres/utils/catcache.h +231 -0
  382. data/ext/pg_query/include/postgres/utils/date.h +118 -0
  383. data/ext/pg_query/include/postgres/utils/datetime.h +367 -0
  384. data/ext/pg_query/include/postgres/utils/datum.h +76 -0
  385. data/ext/pg_query/include/postgres/utils/dsa.h +166 -0
  386. data/ext/pg_query/include/postgres/utils/elog.h +540 -0
  387. data/ext/pg_query/include/postgres/utils/errcodes.h +352 -0
  388. data/ext/pg_query/include/postgres/utils/expandeddatum.h +170 -0
  389. data/ext/pg_query/include/postgres/utils/expandedrecord.h +241 -0
  390. data/ext/pg_query/include/postgres/utils/float.h +357 -0
  391. data/ext/pg_query/include/postgres/utils/fmgroids.h +3347 -0
  392. data/ext/pg_query/include/postgres/utils/fmgrprotos.h +2904 -0
  393. data/ext/pg_query/include/postgres/utils/fmgrtab.h +49 -0
  394. data/ext/pg_query/include/postgres/utils/guc.h +456 -0
  395. data/ext/pg_query/include/postgres/utils/guc_hooks.h +184 -0
  396. data/ext/pg_query/include/postgres/utils/guc_tables.h +323 -0
  397. data/ext/pg_query/include/postgres/utils/hsearch.h +153 -0
  398. data/ext/pg_query/include/postgres/utils/injection_point.h +44 -0
  399. data/ext/pg_query/include/postgres/utils/inval.h +68 -0
  400. data/ext/pg_query/include/postgres/utils/logtape.h +77 -0
  401. data/ext/pg_query/include/postgres/utils/lsyscache.h +215 -0
  402. data/ext/pg_query/include/postgres/utils/memdebug.h +82 -0
  403. data/ext/pg_query/include/postgres/utils/memutils.h +193 -0
  404. data/ext/pg_query/include/postgres/utils/memutils_internal.h +176 -0
  405. data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +253 -0
  406. data/ext/pg_query/include/postgres/utils/numeric.h +110 -0
  407. data/ext/pg_query/include/postgres/utils/palloc.h +151 -0
  408. data/ext/pg_query/include/postgres/utils/partcache.h +103 -0
  409. data/ext/pg_query/include/postgres/utils/pg_locale.h +136 -0
  410. data/ext/pg_query/include/postgres/utils/pgstat_internal.h +827 -0
  411. data/ext/pg_query/include/postgres/utils/plancache.h +238 -0
  412. data/ext/pg_query/include/postgres/utils/portal.h +252 -0
  413. data/ext/pg_query/include/postgres/utils/probes.h +114 -0
  414. data/ext/pg_query/include/postgres/utils/ps_status.h +47 -0
  415. data/ext/pg_query/include/postgres/utils/queryenvironment.h +74 -0
  416. data/ext/pg_query/include/postgres/utils/regproc.h +39 -0
  417. data/ext/pg_query/include/postgres/utils/rel.h +711 -0
  418. data/ext/pg_query/include/postgres/utils/relcache.h +155 -0
  419. data/ext/pg_query/include/postgres/utils/reltrigger.h +81 -0
  420. data/ext/pg_query/include/postgres/utils/resowner.h +167 -0
  421. data/ext/pg_query/include/postgres/utils/ruleutils.h +52 -0
  422. data/ext/pg_query/include/postgres/utils/sharedtuplestore.h +61 -0
  423. data/ext/pg_query/include/postgres/utils/snapmgr.h +130 -0
  424. data/ext/pg_query/include/postgres/utils/snapshot.h +219 -0
  425. data/ext/pg_query/include/postgres/utils/sortsupport.h +391 -0
  426. data/ext/pg_query/include/postgres/utils/syscache.h +136 -0
  427. data/ext/pg_query/include/postgres/utils/timeout.h +96 -0
  428. data/ext/pg_query/include/postgres/utils/timestamp.h +147 -0
  429. data/ext/pg_query/include/postgres/utils/tuplesort.h +472 -0
  430. data/ext/pg_query/include/postgres/utils/tuplestore.h +88 -0
  431. data/ext/pg_query/include/postgres/utils/typcache.h +210 -0
  432. data/ext/pg_query/include/postgres/utils/varlena.h +53 -0
  433. data/ext/pg_query/include/postgres/utils/wait_event.h +108 -0
  434. data/ext/pg_query/include/postgres/utils/wait_event_types.h +218 -0
  435. data/ext/pg_query/include/postgres/utils/xml.h +94 -0
  436. data/ext/pg_query/include/postgres/varatt.h +358 -0
  437. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +7723 -6368
  438. data/ext/pg_query/include/protobuf/pg_query.pb.h +120022 -87031
  439. data/ext/pg_query/pg_query.c +10 -1
  440. data/ext/pg_query/pg_query.pb-c.c +22595 -17738
  441. data/ext/pg_query/pg_query_deparse.c +1 -10635
  442. data/ext/pg_query/pg_query_fingerprint.c +12 -8
  443. data/ext/pg_query/pg_query_fingerprint.h +1 -1
  444. data/ext/pg_query/pg_query_internal.h +1 -1
  445. data/ext/pg_query/pg_query_json_plpgsql.c +1 -0
  446. data/ext/pg_query/pg_query_normalize.c +43 -2
  447. data/ext/pg_query/pg_query_outfuncs_json.c +9 -1
  448. data/ext/pg_query/pg_query_outfuncs_protobuf.c +3 -2
  449. data/ext/pg_query/pg_query_parse.c +47 -5
  450. data/ext/pg_query/pg_query_parse_plpgsql.c +19 -18
  451. data/ext/pg_query/pg_query_readfuncs_protobuf.c +3 -2
  452. data/ext/pg_query/pg_query_ruby.c +5 -0
  453. data/ext/pg_query/pg_query_scan.c +2 -2
  454. data/ext/pg_query/pg_query_split.c +3 -3
  455. data/ext/pg_query/postgres_deparse.c +11496 -0
  456. data/ext/pg_query/postgres_deparse.h +9 -0
  457. data/ext/pg_query/src_backend_catalog_namespace.c +243 -63
  458. data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -3
  459. data/ext/pg_query/src_backend_commands_define.c +2 -3
  460. data/ext/pg_query/src_backend_nodes_bitmapset.c +140 -156
  461. data/ext/pg_query/src_backend_nodes_copyfuncs.c +96 -6202
  462. data/ext/pg_query/src_backend_nodes_equalfuncs.c +95 -4068
  463. data/ext/pg_query/src_backend_nodes_extensible.c +6 -29
  464. data/ext/pg_query/src_backend_nodes_list.c +16 -8
  465. data/ext/pg_query/src_backend_nodes_makefuncs.c +134 -1
  466. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +391 -133
  467. data/ext/pg_query/src_backend_nodes_value.c +1 -1
  468. data/ext/pg_query/src_backend_parser_gram.c +43710 -39953
  469. data/ext/pg_query/src_backend_parser_parser.c +34 -8
  470. data/ext/pg_query/src_backend_parser_scan.c +6971 -3373
  471. data/ext/pg_query/src_backend_parser_scansup.c +2 -1
  472. data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
  473. data/ext/pg_query/src_backend_tcop_postgres.c +99 -96
  474. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +2 -2
  475. data/ext/pg_query/src_backend_utils_adt_datum.c +2 -2
  476. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  477. data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
  478. data/ext/pg_query/src_backend_utils_adt_numutils.c +488 -0
  479. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +177 -30
  480. data/ext/pg_query/src_backend_utils_error_assert.c +4 -7
  481. data/ext/pg_query/src_backend_utils_error_elog.c +397 -270
  482. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +36 -2
  483. data/ext/pg_query/src_backend_utils_init_globals.c +20 -5
  484. data/ext/pg_query/src_backend_utils_mb_mbutils.c +31 -84
  485. data/ext/pg_query/src_backend_utils_misc_guc_tables.c +502 -0
  486. data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +166 -0
  487. data/ext/pg_query/src_backend_utils_mmgr_aset.c +704 -497
  488. data/ext/pg_query/src_backend_utils_mmgr_bump.c +728 -0
  489. data/ext/pg_query/src_backend_utils_mmgr_generation.c +1115 -0
  490. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +637 -233
  491. data/ext/pg_query/src_backend_utils_mmgr_slab.c +1079 -0
  492. data/ext/pg_query/src_common_encnames.c +46 -44
  493. data/ext/pg_query/src_common_hashfn.c +1 -1
  494. data/ext/pg_query/src_common_keywords.c +1 -1
  495. data/ext/pg_query/src_common_kwlist_d.h +586 -517
  496. data/ext/pg_query/src_common_kwlookup.c +1 -1
  497. data/ext/pg_query/src_common_psprintf.c +3 -3
  498. data/ext/pg_query/src_common_stringinfo.c +21 -4
  499. data/ext/pg_query/src_common_wchar.c +100 -116
  500. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +99 -5
  501. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +3 -1
  502. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +829 -763
  503. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  504. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +1 -1
  505. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +19 -1
  506. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +48 -46
  507. data/ext/pg_query/src_port_pg_bitutils.c +251 -32
  508. data/ext/pg_query/src_port_pgstrcasecmp.c +57 -1
  509. data/ext/pg_query/src_port_snprintf.c +20 -27
  510. data/ext/pg_query/src_port_strerror.c +1 -3
  511. data/ext/pg_query/src_port_strlcpy.c +79 -0
  512. data/lib/pg_query/fingerprint.rb +5 -8
  513. data/lib/pg_query/node.rb +16 -11
  514. data/lib/pg_query/param_refs.rb +2 -2
  515. data/lib/pg_query/parse.rb +6 -8
  516. data/lib/pg_query/parse_error.rb +1 -0
  517. data/lib/pg_query/pg_query_pb.rb +173 -3196
  518. data/lib/pg_query/scan.rb +1 -0
  519. data/lib/pg_query/treewalker.rb +52 -11
  520. data/lib/pg_query/truncate.rb +18 -20
  521. data/lib/pg_query/version.rb +1 -1
  522. metadata +443 -442
  523. data/ext/pg_query/guc-file.c +0 -0
  524. data/ext/pg_query/include/access/amapi.h +0 -290
  525. data/ext/pg_query/include/access/attmap.h +0 -52
  526. data/ext/pg_query/include/access/attnum.h +0 -64
  527. data/ext/pg_query/include/access/clog.h +0 -63
  528. data/ext/pg_query/include/access/commit_ts.h +0 -74
  529. data/ext/pg_query/include/access/detoast.h +0 -82
  530. data/ext/pg_query/include/access/genam.h +0 -231
  531. data/ext/pg_query/include/access/gin.h +0 -78
  532. data/ext/pg_query/include/access/htup.h +0 -89
  533. data/ext/pg_query/include/access/htup_details.h +0 -807
  534. data/ext/pg_query/include/access/itup.h +0 -167
  535. data/ext/pg_query/include/access/parallel.h +0 -82
  536. data/ext/pg_query/include/access/printtup.h +0 -35
  537. data/ext/pg_query/include/access/relation.h +0 -28
  538. data/ext/pg_query/include/access/relscan.h +0 -191
  539. data/ext/pg_query/include/access/rmgrlist.h +0 -49
  540. data/ext/pg_query/include/access/sdir.h +0 -58
  541. data/ext/pg_query/include/access/skey.h +0 -151
  542. data/ext/pg_query/include/access/stratnum.h +0 -85
  543. data/ext/pg_query/include/access/sysattr.h +0 -29
  544. data/ext/pg_query/include/access/table.h +0 -28
  545. data/ext/pg_query/include/access/tableam.h +0 -2077
  546. data/ext/pg_query/include/access/toast_compression.h +0 -73
  547. data/ext/pg_query/include/access/transam.h +0 -375
  548. data/ext/pg_query/include/access/tupconvert.h +0 -51
  549. data/ext/pg_query/include/access/tupdesc.h +0 -154
  550. data/ext/pg_query/include/access/tupmacs.h +0 -247
  551. data/ext/pg_query/include/access/twophase.h +0 -65
  552. data/ext/pg_query/include/access/xact.h +0 -523
  553. data/ext/pg_query/include/access/xlog.h +0 -303
  554. data/ext/pg_query/include/access/xlog_internal.h +0 -366
  555. data/ext/pg_query/include/access/xlogdefs.h +0 -101
  556. data/ext/pg_query/include/access/xlogprefetcher.h +0 -55
  557. data/ext/pg_query/include/access/xlogreader.h +0 -443
  558. data/ext/pg_query/include/access/xlogrecord.h +0 -236
  559. data/ext/pg_query/include/access/xlogrecovery.h +0 -157
  560. data/ext/pg_query/include/c.h +0 -1391
  561. data/ext/pg_query/include/catalog/catalog.h +0 -44
  562. data/ext/pg_query/include/catalog/catversion.h +0 -58
  563. data/ext/pg_query/include/catalog/dependency.h +0 -269
  564. data/ext/pg_query/include/catalog/genbki.h +0 -142
  565. data/ext/pg_query/include/catalog/index.h +0 -214
  566. data/ext/pg_query/include/catalog/indexing.h +0 -54
  567. data/ext/pg_query/include/catalog/namespace.h +0 -190
  568. data/ext/pg_query/include/catalog/objectaccess.h +0 -265
  569. data/ext/pg_query/include/catalog/objectaddress.h +0 -89
  570. data/ext/pg_query/include/catalog/pg_aggregate.h +0 -180
  571. data/ext/pg_query/include/catalog/pg_aggregate_d.h +0 -78
  572. data/ext/pg_query/include/catalog/pg_am.h +0 -63
  573. data/ext/pg_query/include/catalog/pg_am_d.h +0 -47
  574. data/ext/pg_query/include/catalog/pg_attribute.h +0 -221
  575. data/ext/pg_query/include/catalog/pg_attribute_d.h +0 -62
  576. data/ext/pg_query/include/catalog/pg_authid.h +0 -63
  577. data/ext/pg_query/include/catalog/pg_authid_d.h +0 -57
  578. data/ext/pg_query/include/catalog/pg_class.h +0 -230
  579. data/ext/pg_query/include/catalog/pg_class_d.h +0 -132
  580. data/ext/pg_query/include/catalog/pg_collation.h +0 -98
  581. data/ext/pg_query/include/catalog/pg_collation_d.h +0 -62
  582. data/ext/pg_query/include/catalog/pg_constraint.h +0 -273
  583. data/ext/pg_query/include/catalog/pg_constraint_d.h +0 -73
  584. data/ext/pg_query/include/catalog/pg_control.h +0 -250
  585. data/ext/pg_query/include/catalog/pg_conversion.h +0 -75
  586. data/ext/pg_query/include/catalog/pg_conversion_d.h +0 -38
  587. data/ext/pg_query/include/catalog/pg_depend.h +0 -77
  588. data/ext/pg_query/include/catalog/pg_depend_d.h +0 -36
  589. data/ext/pg_query/include/catalog/pg_event_trigger.h +0 -57
  590. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +0 -36
  591. data/ext/pg_query/include/catalog/pg_index.h +0 -90
  592. data/ext/pg_query/include/catalog/pg_index_d.h +0 -59
  593. data/ext/pg_query/include/catalog/pg_language.h +0 -72
  594. data/ext/pg_query/include/catalog/pg_language_d.h +0 -41
  595. data/ext/pg_query/include/catalog/pg_namespace.h +0 -64
  596. data/ext/pg_query/include/catalog/pg_namespace_d.h +0 -36
  597. data/ext/pg_query/include/catalog/pg_opclass.h +0 -88
  598. data/ext/pg_query/include/catalog/pg_opclass_d.h +0 -51
  599. data/ext/pg_query/include/catalog/pg_operator.h +0 -107
  600. data/ext/pg_query/include/catalog/pg_operator_d.h +0 -142
  601. data/ext/pg_query/include/catalog/pg_opfamily.h +0 -63
  602. data/ext/pg_query/include/catalog/pg_opfamily_d.h +0 -49
  603. data/ext/pg_query/include/catalog/pg_parameter_acl.h +0 -60
  604. data/ext/pg_query/include/catalog/pg_parameter_acl_d.h +0 -34
  605. data/ext/pg_query/include/catalog/pg_partitioned_table.h +0 -74
  606. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +0 -36
  607. data/ext/pg_query/include/catalog/pg_proc.h +0 -220
  608. data/ext/pg_query/include/catalog/pg_proc_d.h +0 -101
  609. data/ext/pg_query/include/catalog/pg_publication.h +0 -161
  610. data/ext/pg_query/include/catalog/pg_publication_d.h +0 -38
  611. data/ext/pg_query/include/catalog/pg_replication_origin.h +0 -62
  612. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +0 -33
  613. data/ext/pg_query/include/catalog/pg_statistic.h +0 -282
  614. data/ext/pg_query/include/catalog/pg_statistic_d.h +0 -195
  615. data/ext/pg_query/include/catalog/pg_statistic_ext.h +0 -88
  616. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +0 -45
  617. data/ext/pg_query/include/catalog/pg_transform.h +0 -48
  618. data/ext/pg_query/include/catalog/pg_transform_d.h +0 -34
  619. data/ext/pg_query/include/catalog/pg_trigger.h +0 -153
  620. data/ext/pg_query/include/catalog/pg_trigger_d.h +0 -109
  621. data/ext/pg_query/include/catalog/pg_ts_config.h +0 -53
  622. data/ext/pg_query/include/catalog/pg_ts_config_d.h +0 -34
  623. data/ext/pg_query/include/catalog/pg_ts_dict.h +0 -59
  624. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +0 -35
  625. data/ext/pg_query/include/catalog/pg_ts_parser.h +0 -60
  626. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +0 -37
  627. data/ext/pg_query/include/catalog/pg_ts_template.h +0 -51
  628. data/ext/pg_query/include/catalog/pg_ts_template_d.h +0 -34
  629. data/ext/pg_query/include/catalog/pg_type.h +0 -404
  630. data/ext/pg_query/include/catalog/pg_type_d.h +0 -324
  631. data/ext/pg_query/include/catalog/storage.h +0 -50
  632. data/ext/pg_query/include/commands/async.h +0 -53
  633. data/ext/pg_query/include/commands/dbcommands.h +0 -36
  634. data/ext/pg_query/include/commands/defrem.h +0 -160
  635. data/ext/pg_query/include/commands/event_trigger.h +0 -88
  636. data/ext/pg_query/include/commands/explain.h +0 -127
  637. data/ext/pg_query/include/commands/prepare.h +0 -61
  638. data/ext/pg_query/include/commands/tablespace.h +0 -69
  639. data/ext/pg_query/include/commands/trigger.h +0 -287
  640. data/ext/pg_query/include/commands/user.h +0 -37
  641. data/ext/pg_query/include/commands/vacuum.h +0 -340
  642. data/ext/pg_query/include/commands/variable.h +0 -38
  643. data/ext/pg_query/include/common/file_perm.h +0 -56
  644. data/ext/pg_query/include/common/hashfn.h +0 -104
  645. data/ext/pg_query/include/common/ip.h +0 -31
  646. data/ext/pg_query/include/common/keywords.h +0 -29
  647. data/ext/pg_query/include/common/kwlookup.h +0 -44
  648. data/ext/pg_query/include/common/pg_prng.h +0 -60
  649. data/ext/pg_query/include/common/relpath.h +0 -90
  650. data/ext/pg_query/include/common/string.h +0 -42
  651. data/ext/pg_query/include/common/unicode_combining_table.h +0 -308
  652. data/ext/pg_query/include/common/unicode_east_asian_fw_table.h +0 -125
  653. data/ext/pg_query/include/datatype/timestamp.h +0 -236
  654. data/ext/pg_query/include/executor/execdesc.h +0 -70
  655. data/ext/pg_query/include/executor/executor.h +0 -663
  656. data/ext/pg_query/include/executor/functions.h +0 -55
  657. data/ext/pg_query/include/executor/instrument.h +0 -118
  658. data/ext/pg_query/include/executor/spi.h +0 -213
  659. data/ext/pg_query/include/executor/tablefunc.h +0 -67
  660. data/ext/pg_query/include/executor/tuptable.h +0 -487
  661. data/ext/pg_query/include/fmgr.h +0 -781
  662. data/ext/pg_query/include/funcapi.h +0 -360
  663. data/ext/pg_query/include/getaddrinfo.h +0 -162
  664. data/ext/pg_query/include/jit/jit.h +0 -105
  665. data/ext/pg_query/include/kwlist_d.h +0 -1095
  666. data/ext/pg_query/include/lib/dshash.h +0 -112
  667. data/ext/pg_query/include/lib/ilist.h +0 -746
  668. data/ext/pg_query/include/lib/pairingheap.h +0 -102
  669. data/ext/pg_query/include/lib/simplehash.h +0 -1184
  670. data/ext/pg_query/include/lib/sort_template.h +0 -432
  671. data/ext/pg_query/include/lib/stringinfo.h +0 -161
  672. data/ext/pg_query/include/libpq/auth.h +0 -31
  673. data/ext/pg_query/include/libpq/crypt.h +0 -47
  674. data/ext/pg_query/include/libpq/hba.h +0 -179
  675. data/ext/pg_query/include/libpq/libpq-be.h +0 -343
  676. data/ext/pg_query/include/libpq/libpq.h +0 -144
  677. data/ext/pg_query/include/libpq/pqcomm.h +0 -194
  678. data/ext/pg_query/include/libpq/pqformat.h +0 -210
  679. data/ext/pg_query/include/libpq/pqsignal.h +0 -42
  680. data/ext/pg_query/include/mb/pg_wchar.h +0 -755
  681. data/ext/pg_query/include/mb/stringinfo_mb.h +0 -24
  682. data/ext/pg_query/include/miscadmin.h +0 -495
  683. data/ext/pg_query/include/nodes/bitmapset.h +0 -122
  684. data/ext/pg_query/include/nodes/execnodes.h +0 -2715
  685. data/ext/pg_query/include/nodes/extensible.h +0 -162
  686. data/ext/pg_query/include/nodes/lockoptions.h +0 -61
  687. data/ext/pg_query/include/nodes/makefuncs.h +0 -109
  688. data/ext/pg_query/include/nodes/memnodes.h +0 -110
  689. data/ext/pg_query/include/nodes/nodeFuncs.h +0 -162
  690. data/ext/pg_query/include/nodes/nodes.h +0 -861
  691. data/ext/pg_query/include/nodes/params.h +0 -170
  692. data/ext/pg_query/include/nodes/parsenodes.h +0 -3812
  693. data/ext/pg_query/include/nodes/pathnodes.h +0 -2734
  694. data/ext/pg_query/include/nodes/pg_list.h +0 -612
  695. data/ext/pg_query/include/nodes/plannodes.h +0 -1349
  696. data/ext/pg_query/include/nodes/primnodes.h +0 -1593
  697. data/ext/pg_query/include/nodes/print.h +0 -34
  698. data/ext/pg_query/include/nodes/tidbitmap.h +0 -75
  699. data/ext/pg_query/include/nodes/value.h +0 -80
  700. data/ext/pg_query/include/optimizer/cost.h +0 -213
  701. data/ext/pg_query/include/optimizer/geqo.h +0 -90
  702. data/ext/pg_query/include/optimizer/geqo_gene.h +0 -45
  703. data/ext/pg_query/include/optimizer/optimizer.h +0 -202
  704. data/ext/pg_query/include/optimizer/paths.h +0 -257
  705. data/ext/pg_query/include/optimizer/planmain.h +0 -120
  706. data/ext/pg_query/include/parser/analyze.h +0 -63
  707. data/ext/pg_query/include/parser/gram.h +0 -1101
  708. data/ext/pg_query/include/parser/gramparse.h +0 -75
  709. data/ext/pg_query/include/parser/kwlist.h +0 -487
  710. data/ext/pg_query/include/parser/parse_agg.h +0 -63
  711. data/ext/pg_query/include/parser/parse_coerce.h +0 -100
  712. data/ext/pg_query/include/parser/parse_expr.h +0 -25
  713. data/ext/pg_query/include/parser/parse_func.h +0 -74
  714. data/ext/pg_query/include/parser/parse_node.h +0 -339
  715. data/ext/pg_query/include/parser/parse_oper.h +0 -65
  716. data/ext/pg_query/include/parser/parse_relation.h +0 -124
  717. data/ext/pg_query/include/parser/parse_type.h +0 -60
  718. data/ext/pg_query/include/parser/parser.h +0 -68
  719. data/ext/pg_query/include/parser/parsetree.h +0 -61
  720. data/ext/pg_query/include/parser/scanner.h +0 -152
  721. data/ext/pg_query/include/parser/scansup.h +0 -27
  722. data/ext/pg_query/include/partitioning/partdefs.h +0 -26
  723. data/ext/pg_query/include/pg_config.h +0 -1037
  724. data/ext/pg_query/include/pg_config_manual.h +0 -410
  725. data/ext/pg_query/include/pg_config_os.h +0 -8
  726. data/ext/pg_query/include/pg_getopt.h +0 -56
  727. data/ext/pg_query/include/pg_trace.h +0 -17
  728. data/ext/pg_query/include/pgstat.h +0 -699
  729. data/ext/pg_query/include/pgtime.h +0 -94
  730. data/ext/pg_query/include/pl_gram.h +0 -383
  731. data/ext/pg_query/include/pl_reserved_kwlist.h +0 -52
  732. data/ext/pg_query/include/pl_reserved_kwlist_d.h +0 -114
  733. data/ext/pg_query/include/pl_unreserved_kwlist.h +0 -111
  734. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +0 -244
  735. data/ext/pg_query/include/plerrcodes.h +0 -998
  736. data/ext/pg_query/include/plpgsql.h +0 -1345
  737. data/ext/pg_query/include/port/atomics/arch-arm.h +0 -32
  738. data/ext/pg_query/include/port/atomics/arch-ppc.h +0 -254
  739. data/ext/pg_query/include/port/atomics/arch-x86.h +0 -252
  740. data/ext/pg_query/include/port/atomics/fallback.h +0 -170
  741. data/ext/pg_query/include/port/atomics/generic-gcc.h +0 -286
  742. data/ext/pg_query/include/port/atomics/generic.h +0 -401
  743. data/ext/pg_query/include/port/atomics.h +0 -524
  744. data/ext/pg_query/include/port/pg_bitutils.h +0 -302
  745. data/ext/pg_query/include/port/pg_bswap.h +0 -161
  746. data/ext/pg_query/include/port/pg_crc32c.h +0 -101
  747. data/ext/pg_query/include/port.h +0 -553
  748. data/ext/pg_query/include/portability/instr_time.h +0 -256
  749. data/ext/pg_query/include/postgres.h +0 -808
  750. data/ext/pg_query/include/postgres_ext.h +0 -74
  751. data/ext/pg_query/include/postmaster/autovacuum.h +0 -83
  752. data/ext/pg_query/include/postmaster/auxprocess.h +0 -20
  753. data/ext/pg_query/include/postmaster/bgworker.h +0 -162
  754. data/ext/pg_query/include/postmaster/bgworker_internals.h +0 -64
  755. data/ext/pg_query/include/postmaster/bgwriter.h +0 -45
  756. data/ext/pg_query/include/postmaster/fork_process.h +0 -17
  757. data/ext/pg_query/include/postmaster/interrupt.h +0 -32
  758. data/ext/pg_query/include/postmaster/pgarch.h +0 -73
  759. data/ext/pg_query/include/postmaster/postmaster.h +0 -78
  760. data/ext/pg_query/include/postmaster/startup.h +0 -39
  761. data/ext/pg_query/include/postmaster/syslogger.h +0 -103
  762. data/ext/pg_query/include/postmaster/walwriter.h +0 -21
  763. data/ext/pg_query/include/regex/regex.h +0 -186
  764. data/ext/pg_query/include/replication/logicallauncher.h +0 -29
  765. data/ext/pg_query/include/replication/logicalproto.h +0 -254
  766. data/ext/pg_query/include/replication/logicalworker.h +0 -19
  767. data/ext/pg_query/include/replication/origin.h +0 -73
  768. data/ext/pg_query/include/replication/reorderbuffer.h +0 -685
  769. data/ext/pg_query/include/replication/slot.h +0 -230
  770. data/ext/pg_query/include/replication/syncrep.h +0 -115
  771. data/ext/pg_query/include/replication/walreceiver.h +0 -472
  772. data/ext/pg_query/include/replication/walsender.h +0 -74
  773. data/ext/pg_query/include/rewrite/prs2lock.h +0 -46
  774. data/ext/pg_query/include/rewrite/rewriteHandler.h +0 -38
  775. data/ext/pg_query/include/rewrite/rewriteManip.h +0 -87
  776. data/ext/pg_query/include/rewrite/rewriteSupport.h +0 -26
  777. data/ext/pg_query/include/storage/backendid.h +0 -37
  778. data/ext/pg_query/include/storage/block.h +0 -115
  779. data/ext/pg_query/include/storage/buf.h +0 -46
  780. data/ext/pg_query/include/storage/bufmgr.h +0 -297
  781. data/ext/pg_query/include/storage/bufpage.h +0 -457
  782. data/ext/pg_query/include/storage/condition_variable.h +0 -73
  783. data/ext/pg_query/include/storage/dsm.h +0 -64
  784. data/ext/pg_query/include/storage/dsm_impl.h +0 -76
  785. data/ext/pg_query/include/storage/fd.h +0 -198
  786. data/ext/pg_query/include/storage/fileset.h +0 -40
  787. data/ext/pg_query/include/storage/ipc.h +0 -84
  788. data/ext/pg_query/include/storage/item.h +0 -19
  789. data/ext/pg_query/include/storage/itemid.h +0 -184
  790. data/ext/pg_query/include/storage/itemptr.h +0 -208
  791. data/ext/pg_query/include/storage/large_object.h +0 -100
  792. data/ext/pg_query/include/storage/latch.h +0 -186
  793. data/ext/pg_query/include/storage/lmgr.h +0 -115
  794. data/ext/pg_query/include/storage/lock.h +0 -616
  795. data/ext/pg_query/include/storage/lockdefs.h +0 -59
  796. data/ext/pg_query/include/storage/lwlock.h +0 -206
  797. data/ext/pg_query/include/storage/lwlocknames.h +0 -50
  798. data/ext/pg_query/include/storage/off.h +0 -57
  799. data/ext/pg_query/include/storage/pg_sema.h +0 -61
  800. data/ext/pg_query/include/storage/pg_shmem.h +0 -92
  801. data/ext/pg_query/include/storage/pmsignal.h +0 -105
  802. data/ext/pg_query/include/storage/predicate.h +0 -87
  803. data/ext/pg_query/include/storage/proc.h +0 -461
  804. data/ext/pg_query/include/storage/procarray.h +0 -98
  805. data/ext/pg_query/include/storage/proclist_types.h +0 -51
  806. data/ext/pg_query/include/storage/procsignal.h +0 -71
  807. data/ext/pg_query/include/storage/relfilenode.h +0 -99
  808. data/ext/pg_query/include/storage/s_lock.h +0 -1110
  809. data/ext/pg_query/include/storage/sharedfileset.h +0 -37
  810. data/ext/pg_query/include/storage/shm_mq.h +0 -86
  811. data/ext/pg_query/include/storage/shm_toc.h +0 -58
  812. data/ext/pg_query/include/storage/shmem.h +0 -81
  813. data/ext/pg_query/include/storage/sinval.h +0 -153
  814. data/ext/pg_query/include/storage/sinvaladt.h +0 -43
  815. data/ext/pg_query/include/storage/smgr.h +0 -111
  816. data/ext/pg_query/include/storage/spin.h +0 -77
  817. data/ext/pg_query/include/storage/standby.h +0 -98
  818. data/ext/pg_query/include/storage/standbydefs.h +0 -74
  819. data/ext/pg_query/include/storage/sync.h +0 -66
  820. data/ext/pg_query/include/tcop/cmdtag.h +0 -58
  821. data/ext/pg_query/include/tcop/cmdtaglist.h +0 -218
  822. data/ext/pg_query/include/tcop/deparse_utility.h +0 -108
  823. data/ext/pg_query/include/tcop/dest.h +0 -149
  824. data/ext/pg_query/include/tcop/fastpath.h +0 -20
  825. data/ext/pg_query/include/tcop/pquery.h +0 -51
  826. data/ext/pg_query/include/tcop/tcopprot.h +0 -97
  827. data/ext/pg_query/include/tcop/utility.h +0 -112
  828. data/ext/pg_query/include/tsearch/ts_cache.h +0 -98
  829. data/ext/pg_query/include/utils/acl.h +0 -333
  830. data/ext/pg_query/include/utils/aclchk_internal.h +0 -45
  831. data/ext/pg_query/include/utils/array.h +0 -464
  832. data/ext/pg_query/include/utils/backend_progress.h +0 -44
  833. data/ext/pg_query/include/utils/backend_status.h +0 -321
  834. data/ext/pg_query/include/utils/builtins.h +0 -127
  835. data/ext/pg_query/include/utils/bytea.h +0 -28
  836. data/ext/pg_query/include/utils/catcache.h +0 -231
  837. data/ext/pg_query/include/utils/date.h +0 -90
  838. data/ext/pg_query/include/utils/datetime.h +0 -344
  839. data/ext/pg_query/include/utils/datum.h +0 -76
  840. data/ext/pg_query/include/utils/dsa.h +0 -123
  841. data/ext/pg_query/include/utils/dynahash.h +0 -20
  842. data/ext/pg_query/include/utils/elog.h +0 -470
  843. data/ext/pg_query/include/utils/errcodes.h +0 -354
  844. data/ext/pg_query/include/utils/expandeddatum.h +0 -159
  845. data/ext/pg_query/include/utils/expandedrecord.h +0 -231
  846. data/ext/pg_query/include/utils/float.h +0 -356
  847. data/ext/pg_query/include/utils/fmgroids.h +0 -3261
  848. data/ext/pg_query/include/utils/fmgrprotos.h +0 -2829
  849. data/ext/pg_query/include/utils/fmgrtab.h +0 -49
  850. data/ext/pg_query/include/utils/guc.h +0 -469
  851. data/ext/pg_query/include/utils/guc_tables.h +0 -276
  852. data/ext/pg_query/include/utils/hsearch.h +0 -153
  853. data/ext/pg_query/include/utils/inval.h +0 -68
  854. data/ext/pg_query/include/utils/lsyscache.h +0 -208
  855. data/ext/pg_query/include/utils/memdebug.h +0 -82
  856. data/ext/pg_query/include/utils/memutils.h +0 -230
  857. data/ext/pg_query/include/utils/numeric.h +0 -90
  858. data/ext/pg_query/include/utils/palloc.h +0 -158
  859. data/ext/pg_query/include/utils/partcache.h +0 -102
  860. data/ext/pg_query/include/utils/pg_locale.h +0 -127
  861. data/ext/pg_query/include/utils/pg_lsn.h +0 -29
  862. data/ext/pg_query/include/utils/pgstat_internal.h +0 -784
  863. data/ext/pg_query/include/utils/pidfile.h +0 -56
  864. data/ext/pg_query/include/utils/plancache.h +0 -236
  865. data/ext/pg_query/include/utils/portal.h +0 -252
  866. data/ext/pg_query/include/utils/probes.h +0 -114
  867. data/ext/pg_query/include/utils/ps_status.h +0 -25
  868. data/ext/pg_query/include/utils/queryenvironment.h +0 -74
  869. data/ext/pg_query/include/utils/queryjumble.h +0 -88
  870. data/ext/pg_query/include/utils/regproc.h +0 -39
  871. data/ext/pg_query/include/utils/rel.h +0 -695
  872. data/ext/pg_query/include/utils/relcache.h +0 -153
  873. data/ext/pg_query/include/utils/reltrigger.h +0 -81
  874. data/ext/pg_query/include/utils/resowner.h +0 -86
  875. data/ext/pg_query/include/utils/rls.h +0 -50
  876. data/ext/pg_query/include/utils/ruleutils.h +0 -47
  877. data/ext/pg_query/include/utils/sharedtuplestore.h +0 -61
  878. data/ext/pg_query/include/utils/snapmgr.h +0 -179
  879. data/ext/pg_query/include/utils/snapshot.h +0 -219
  880. data/ext/pg_query/include/utils/sortsupport.h +0 -391
  881. data/ext/pg_query/include/utils/syscache.h +0 -224
  882. data/ext/pg_query/include/utils/timeout.h +0 -95
  883. data/ext/pg_query/include/utils/timestamp.h +0 -117
  884. data/ext/pg_query/include/utils/tuplesort.h +0 -291
  885. data/ext/pg_query/include/utils/tuplestore.h +0 -91
  886. data/ext/pg_query/include/utils/typcache.h +0 -209
  887. data/ext/pg_query/include/utils/tzparser.h +0 -39
  888. data/ext/pg_query/include/utils/varlena.h +0 -41
  889. data/ext/pg_query/include/utils/wait_event.h +0 -289
  890. data/ext/pg_query/include/utils/xml.h +0 -84
  891. data/ext/pg_query/src_backend_postmaster_postmaster.c +0 -2201
  892. data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +0 -371
  893. data/ext/pg_query/src_backend_utils_hash_dynahash.c +0 -1116
  894. data/ext/pg_query/src_backend_utils_misc_guc.c +0 -1993
  895. data/ext/pg_query/src_common_pg_prng.c +0 -152
  896. data/ext/pg_query/src_common_string.c +0 -92
  897. data/ext/pg_query/src_port_pgsleep.c +0 -69
  898. data/ext/pg_query/src_port_strnlen.c +0 -39
  899. /data/ext/pg_query/{pg_query_ruby.sym → ext_symbols.sym} +0 -0
  900. /data/ext/pg_query/include/{access → postgres/access}/rmgr.h +0 -0
  901. /data/ext/pg_query/include/{pg_config_ext.h → postgres/pg_config_ext.h} +0 -0
@@ -1,2734 +0,0 @@
1
- /*-------------------------------------------------------------------------
2
- *
3
- * pathnodes.h
4
- * Definitions for planner's internal data structures, especially Paths.
5
- *
6
- *
7
- * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8
- * Portions Copyright (c) 1994, Regents of the University of California
9
- *
10
- * src/include/nodes/pathnodes.h
11
- *
12
- *-------------------------------------------------------------------------
13
- */
14
- #ifndef PATHNODES_H
15
- #define PATHNODES_H
16
-
17
- #include "access/sdir.h"
18
- #include "lib/stringinfo.h"
19
- #include "nodes/params.h"
20
- #include "nodes/parsenodes.h"
21
- #include "storage/block.h"
22
-
23
-
24
- /*
25
- * Relids
26
- * Set of relation identifiers (indexes into the rangetable).
27
- */
28
- typedef Bitmapset *Relids;
29
-
30
- /*
31
- * When looking for a "cheapest path", this enum specifies whether we want
32
- * cheapest startup cost or cheapest total cost.
33
- */
34
- typedef enum CostSelector
35
- {
36
- STARTUP_COST, TOTAL_COST
37
- } CostSelector;
38
-
39
- /*
40
- * The cost estimate produced by cost_qual_eval() includes both a one-time
41
- * (startup) cost, and a per-tuple cost.
42
- */
43
- typedef struct QualCost
44
- {
45
- Cost startup; /* one-time cost */
46
- Cost per_tuple; /* per-evaluation cost */
47
- } QualCost;
48
-
49
- /*
50
- * Costing aggregate function execution requires these statistics about
51
- * the aggregates to be executed by a given Agg node. Note that the costs
52
- * include the execution costs of the aggregates' argument expressions as
53
- * well as the aggregate functions themselves. Also, the fields must be
54
- * defined so that initializing the struct to zeroes with memset is correct.
55
- */
56
- typedef struct AggClauseCosts
57
- {
58
- QualCost transCost; /* total per-input-row execution costs */
59
- QualCost finalCost; /* total per-aggregated-row costs */
60
- Size transitionSpace; /* space for pass-by-ref transition data */
61
- } AggClauseCosts;
62
-
63
- /*
64
- * This enum identifies the different types of "upper" (post-scan/join)
65
- * relations that we might deal with during planning.
66
- */
67
- typedef enum UpperRelationKind
68
- {
69
- UPPERREL_SETOP, /* result of UNION/INTERSECT/EXCEPT, if any */
70
- UPPERREL_PARTIAL_GROUP_AGG, /* result of partial grouping/aggregation, if
71
- * any */
72
- UPPERREL_GROUP_AGG, /* result of grouping/aggregation, if any */
73
- UPPERREL_WINDOW, /* result of window functions, if any */
74
- UPPERREL_PARTIAL_DISTINCT, /* result of partial "SELECT DISTINCT", if any */
75
- UPPERREL_DISTINCT, /* result of "SELECT DISTINCT", if any */
76
- UPPERREL_ORDERED, /* result of ORDER BY, if any */
77
- UPPERREL_FINAL /* result of any remaining top-level actions */
78
- /* NB: UPPERREL_FINAL must be last enum entry; it's used to size arrays */
79
- } UpperRelationKind;
80
-
81
- /*----------
82
- * PlannerGlobal
83
- * Global information for planning/optimization
84
- *
85
- * PlannerGlobal holds state for an entire planner invocation; this state
86
- * is shared across all levels of sub-Queries that exist in the command being
87
- * planned.
88
- *----------
89
- */
90
- typedef struct PlannerGlobal
91
- {
92
- NodeTag type;
93
-
94
- ParamListInfo boundParams; /* Param values provided to planner() */
95
-
96
- List *subplans; /* Plans for SubPlan nodes */
97
-
98
- List *subroots; /* PlannerInfos for SubPlan nodes */
99
-
100
- Bitmapset *rewindPlanIDs; /* indices of subplans that require REWIND */
101
-
102
- List *finalrtable; /* "flat" rangetable for executor */
103
-
104
- List *finalrowmarks; /* "flat" list of PlanRowMarks */
105
-
106
- List *resultRelations; /* "flat" list of integer RT indexes */
107
-
108
- List *appendRelations; /* "flat" list of AppendRelInfos */
109
-
110
- List *relationOids; /* OIDs of relations the plan depends on */
111
-
112
- List *invalItems; /* other dependencies, as PlanInvalItems */
113
-
114
- List *paramExecTypes; /* type OIDs for PARAM_EXEC Params */
115
-
116
- Index lastPHId; /* highest PlaceHolderVar ID assigned */
117
-
118
- Index lastRowMarkId; /* highest PlanRowMark ID assigned */
119
-
120
- int lastPlanNodeId; /* highest plan node ID assigned */
121
-
122
- bool transientPlan; /* redo plan when TransactionXmin changes? */
123
-
124
- bool dependsOnRole; /* is plan specific to current role? */
125
-
126
- bool parallelModeOK; /* parallel mode potentially OK? */
127
-
128
- bool parallelModeNeeded; /* parallel mode actually required? */
129
-
130
- char maxParallelHazard; /* worst PROPARALLEL hazard level */
131
-
132
- PartitionDirectory partition_directory; /* partition descriptors */
133
- } PlannerGlobal;
134
-
135
- /* macro for fetching the Plan associated with a SubPlan node */
136
- #define planner_subplan_get_plan(root, subplan) \
137
- ((Plan *) list_nth((root)->glob->subplans, (subplan)->plan_id - 1))
138
-
139
-
140
- /*----------
141
- * PlannerInfo
142
- * Per-query information for planning/optimization
143
- *
144
- * This struct is conventionally called "root" in all the planner routines.
145
- * It holds links to all of the planner's working state, in addition to the
146
- * original Query. Note that at present the planner extensively modifies
147
- * the passed-in Query data structure; someday that should stop.
148
- *
149
- * For reasons explained in optimizer/optimizer.h, we define the typedef
150
- * either here or in that header, whichever is read first.
151
- *----------
152
- */
153
- #ifndef HAVE_PLANNERINFO_TYPEDEF
154
- typedef struct PlannerInfo PlannerInfo;
155
- #define HAVE_PLANNERINFO_TYPEDEF 1
156
- #endif
157
-
158
- struct PlannerInfo
159
- {
160
- NodeTag type;
161
-
162
- Query *parse; /* the Query being planned */
163
-
164
- PlannerGlobal *glob; /* global info for current planner run */
165
-
166
- Index query_level; /* 1 at the outermost Query */
167
-
168
- PlannerInfo *parent_root; /* NULL at outermost Query */
169
-
170
- /*
171
- * plan_params contains the expressions that this query level needs to
172
- * make available to a lower query level that is currently being planned.
173
- * outer_params contains the paramIds of PARAM_EXEC Params that outer
174
- * query levels will make available to this query level.
175
- */
176
- List *plan_params; /* list of PlannerParamItems, see below */
177
- Bitmapset *outer_params;
178
-
179
- /*
180
- * simple_rel_array holds pointers to "base rels" and "other rels" (see
181
- * comments for RelOptInfo for more info). It is indexed by rangetable
182
- * index (so entry 0 is always wasted). Entries can be NULL when an RTE
183
- * does not correspond to a base relation, such as a join RTE or an
184
- * unreferenced view RTE; or if the RelOptInfo hasn't been made yet.
185
- */
186
- struct RelOptInfo **simple_rel_array; /* All 1-rel RelOptInfos */
187
- int simple_rel_array_size; /* allocated size of array */
188
-
189
- /*
190
- * simple_rte_array is the same length as simple_rel_array and holds
191
- * pointers to the associated rangetable entries. Using this is a shade
192
- * faster than using rt_fetch(), mostly due to fewer indirections.
193
- */
194
- RangeTblEntry **simple_rte_array; /* rangetable as an array */
195
-
196
- /*
197
- * append_rel_array is the same length as the above arrays, and holds
198
- * pointers to the corresponding AppendRelInfo entry indexed by
199
- * child_relid, or NULL if the rel is not an appendrel child. The array
200
- * itself is not allocated if append_rel_list is empty.
201
- */
202
- struct AppendRelInfo **append_rel_array;
203
-
204
- /*
205
- * all_baserels is a Relids set of all base relids (but not "other"
206
- * relids) in the query; that is, the Relids identifier of the final join
207
- * we need to form. This is computed in make_one_rel, just before we
208
- * start making Paths.
209
- */
210
- Relids all_baserels;
211
-
212
- /*
213
- * nullable_baserels is a Relids set of base relids that are nullable by
214
- * some outer join in the jointree; these are rels that are potentially
215
- * nullable below the WHERE clause, SELECT targetlist, etc. This is
216
- * computed in deconstruct_jointree.
217
- */
218
- Relids nullable_baserels;
219
-
220
- /*
221
- * join_rel_list is a list of all join-relation RelOptInfos we have
222
- * considered in this planning run. For small problems we just scan the
223
- * list to do lookups, but when there are many join relations we build a
224
- * hash table for faster lookups. The hash table is present and valid
225
- * when join_rel_hash is not NULL. Note that we still maintain the list
226
- * even when using the hash table for lookups; this simplifies life for
227
- * GEQO.
228
- */
229
- List *join_rel_list; /* list of join-relation RelOptInfos */
230
- struct HTAB *join_rel_hash; /* optional hashtable for join relations */
231
-
232
- /*
233
- * When doing a dynamic-programming-style join search, join_rel_level[k]
234
- * is a list of all join-relation RelOptInfos of level k, and
235
- * join_cur_level is the current level. New join-relation RelOptInfos are
236
- * automatically added to the join_rel_level[join_cur_level] list.
237
- * join_rel_level is NULL if not in use.
238
- */
239
- List **join_rel_level; /* lists of join-relation RelOptInfos */
240
- int join_cur_level; /* index of list being extended */
241
-
242
- List *init_plans; /* init SubPlans for query */
243
-
244
- List *cte_plan_ids; /* per-CTE-item list of subplan IDs (or -1 if
245
- * no subplan was made for that CTE) */
246
-
247
- List *multiexpr_params; /* List of Lists of Params for MULTIEXPR
248
- * subquery outputs */
249
-
250
- List *eq_classes; /* list of active EquivalenceClasses */
251
-
252
- bool ec_merging_done; /* set true once ECs are canonical */
253
-
254
- List *canon_pathkeys; /* list of "canonical" PathKeys */
255
-
256
- List *left_join_clauses; /* list of RestrictInfos for mergejoinable
257
- * outer join clauses w/nonnullable var on
258
- * left */
259
-
260
- List *right_join_clauses; /* list of RestrictInfos for mergejoinable
261
- * outer join clauses w/nonnullable var on
262
- * right */
263
-
264
- List *full_join_clauses; /* list of RestrictInfos for mergejoinable
265
- * full join clauses */
266
-
267
- List *join_info_list; /* list of SpecialJoinInfos */
268
-
269
- /*
270
- * all_result_relids is empty for SELECT, otherwise it contains at least
271
- * parse->resultRelation. For UPDATE/DELETE/MERGE across an inheritance
272
- * or partitioning tree, the result rel's child relids are added. When
273
- * using multi-level partitioning, intermediate partitioned rels are
274
- * included. leaf_result_relids is similar except that only actual result
275
- * tables, not partitioned tables, are included in it.
276
- */
277
- Relids all_result_relids; /* set of all result relids */
278
- Relids leaf_result_relids; /* set of all leaf relids */
279
-
280
- /*
281
- * Note: for AppendRelInfos describing partitions of a partitioned table,
282
- * we guarantee that partitions that come earlier in the partitioned
283
- * table's PartitionDesc will appear earlier in append_rel_list.
284
- */
285
- List *append_rel_list; /* list of AppendRelInfos */
286
-
287
- List *row_identity_vars; /* list of RowIdentityVarInfos */
288
-
289
- List *rowMarks; /* list of PlanRowMarks */
290
-
291
- List *placeholder_list; /* list of PlaceHolderInfos */
292
-
293
- List *fkey_list; /* list of ForeignKeyOptInfos */
294
-
295
- List *query_pathkeys; /* desired pathkeys for query_planner() */
296
-
297
- List *group_pathkeys; /* groupClause pathkeys, if any */
298
- List *window_pathkeys; /* pathkeys of bottom window, if any */
299
- List *distinct_pathkeys; /* distinctClause pathkeys, if any */
300
- List *sort_pathkeys; /* sortClause pathkeys, if any */
301
-
302
- List *part_schemes; /* Canonicalised partition schemes used in the
303
- * query. */
304
-
305
- List *initial_rels; /* RelOptInfos we are now trying to join */
306
-
307
- /* Use fetch_upper_rel() to get any particular upper rel */
308
- List *upper_rels[UPPERREL_FINAL + 1]; /* upper-rel RelOptInfos */
309
-
310
- /* Result tlists chosen by grouping_planner for upper-stage processing */
311
- struct PathTarget *upper_targets[UPPERREL_FINAL + 1];
312
-
313
- /*
314
- * The fully-processed targetlist is kept here. It differs from
315
- * parse->targetList in that (for INSERT) it's been reordered to match the
316
- * target table, and defaults have been filled in. Also, additional
317
- * resjunk targets may be present. preprocess_targetlist() does most of
318
- * that work, but note that more resjunk targets can get added during
319
- * appendrel expansion. (Hence, upper_targets mustn't get set up till
320
- * after that.)
321
- */
322
- List *processed_tlist;
323
-
324
- /*
325
- * For UPDATE, this list contains the target table's attribute numbers to
326
- * which the first N entries of processed_tlist are to be assigned. (Any
327
- * additional entries in processed_tlist must be resjunk.) DO NOT use the
328
- * resnos in processed_tlist to identify the UPDATE target columns.
329
- */
330
- List *update_colnos;
331
-
332
- /* Fields filled during create_plan() for use in setrefs.c */
333
- AttrNumber *grouping_map; /* for GroupingFunc fixup */
334
- List *minmax_aggs; /* List of MinMaxAggInfos */
335
-
336
- MemoryContext planner_cxt; /* context holding PlannerInfo */
337
-
338
- Cardinality total_table_pages; /* # of pages in all non-dummy tables of
339
- * query */
340
-
341
- Selectivity tuple_fraction; /* tuple_fraction passed to query_planner */
342
- Cardinality limit_tuples; /* limit_tuples passed to query_planner */
343
-
344
- Index qual_security_level; /* minimum security_level for quals */
345
- /* Note: qual_security_level is zero if there are no securityQuals */
346
-
347
- bool hasJoinRTEs; /* true if any RTEs are RTE_JOIN kind */
348
- bool hasLateralRTEs; /* true if any RTEs are marked LATERAL */
349
- bool hasHavingQual; /* true if havingQual was non-null */
350
- bool hasPseudoConstantQuals; /* true if any RestrictInfo has
351
- * pseudoconstant = true */
352
- bool hasAlternativeSubPlans; /* true if we've made any of those */
353
- bool hasRecursion; /* true if planning a recursive WITH item */
354
-
355
- /*
356
- * Information about aggregates. Filled by preprocess_aggrefs().
357
- */
358
- List *agginfos; /* AggInfo structs */
359
- List *aggtransinfos; /* AggTransInfo structs */
360
- int numOrderedAggs; /* number w/ DISTINCT/ORDER BY/WITHIN GROUP */
361
- bool hasNonPartialAggs; /* does any agg not support partial mode? */
362
- bool hasNonSerialAggs; /* is any partial agg non-serializable? */
363
-
364
- /* These fields are used only when hasRecursion is true: */
365
- int wt_param_id; /* PARAM_EXEC ID for the work table */
366
- struct Path *non_recursive_path; /* a path for non-recursive term */
367
-
368
- /* These fields are workspace for createplan.c */
369
- Relids curOuterRels; /* outer rels above current node */
370
- List *curOuterParams; /* not-yet-assigned NestLoopParams */
371
-
372
- /* These fields are workspace for setrefs.c */
373
- bool *isAltSubplan; /* array corresponding to glob->subplans */
374
- bool *isUsedSubplan; /* array corresponding to glob->subplans */
375
-
376
- /* optional private data for join_search_hook, e.g., GEQO */
377
- void *join_search_private;
378
-
379
- /* Does this query modify any partition key columns? */
380
- bool partColsUpdated;
381
- };
382
-
383
-
384
- /*
385
- * In places where it's known that simple_rte_array[] must have been prepared
386
- * already, we just index into it to fetch RTEs. In code that might be
387
- * executed before or after entering query_planner(), use this macro.
388
- */
389
- #define planner_rt_fetch(rti, root) \
390
- ((root)->simple_rte_array ? (root)->simple_rte_array[rti] : \
391
- rt_fetch(rti, (root)->parse->rtable))
392
-
393
- /*
394
- * If multiple relations are partitioned the same way, all such partitions
395
- * will have a pointer to the same PartitionScheme. A list of PartitionScheme
396
- * objects is attached to the PlannerInfo. By design, the partition scheme
397
- * incorporates only the general properties of the partition method (LIST vs.
398
- * RANGE, number of partitioning columns and the type information for each)
399
- * and not the specific bounds.
400
- *
401
- * We store the opclass-declared input data types instead of the partition key
402
- * datatypes since the former rather than the latter are used to compare
403
- * partition bounds. Since partition key data types and the opclass declared
404
- * input data types are expected to be binary compatible (per ResolveOpClass),
405
- * both of those should have same byval and length properties.
406
- */
407
- typedef struct PartitionSchemeData
408
- {
409
- char strategy; /* partition strategy */
410
- int16 partnatts; /* number of partition attributes */
411
- Oid *partopfamily; /* OIDs of operator families */
412
- Oid *partopcintype; /* OIDs of opclass declared input data types */
413
- Oid *partcollation; /* OIDs of partitioning collations */
414
-
415
- /* Cached information about partition key data types. */
416
- int16 *parttyplen;
417
- bool *parttypbyval;
418
-
419
- /* Cached information about partition comparison functions. */
420
- struct FmgrInfo *partsupfunc;
421
- } PartitionSchemeData;
422
-
423
- typedef struct PartitionSchemeData *PartitionScheme;
424
-
425
- /*----------
426
- * RelOptInfo
427
- * Per-relation information for planning/optimization
428
- *
429
- * For planning purposes, a "base rel" is either a plain relation (a table)
430
- * or the output of a sub-SELECT or function that appears in the range table.
431
- * In either case it is uniquely identified by an RT index. A "joinrel"
432
- * is the joining of two or more base rels. A joinrel is identified by
433
- * the set of RT indexes for its component baserels. We create RelOptInfo
434
- * nodes for each baserel and joinrel, and store them in the PlannerInfo's
435
- * simple_rel_array and join_rel_list respectively.
436
- *
437
- * Note that there is only one joinrel for any given set of component
438
- * baserels, no matter what order we assemble them in; so an unordered
439
- * set is the right datatype to identify it with.
440
- *
441
- * We also have "other rels", which are like base rels in that they refer to
442
- * single RT indexes; but they are not part of the join tree, and are given
443
- * a different RelOptKind to identify them.
444
- * Currently the only kind of otherrels are those made for member relations
445
- * of an "append relation", that is an inheritance set or UNION ALL subquery.
446
- * An append relation has a parent RTE that is a base rel, which represents
447
- * the entire append relation. The member RTEs are otherrels. The parent
448
- * is present in the query join tree but the members are not. The member
449
- * RTEs and otherrels are used to plan the scans of the individual tables or
450
- * subqueries of the append set; then the parent baserel is given Append
451
- * and/or MergeAppend paths comprising the best paths for the individual
452
- * member rels. (See comments for AppendRelInfo for more information.)
453
- *
454
- * At one time we also made otherrels to represent join RTEs, for use in
455
- * handling join alias Vars. Currently this is not needed because all join
456
- * alias Vars are expanded to non-aliased form during preprocess_expression.
457
- *
458
- * We also have relations representing joins between child relations of
459
- * different partitioned tables. These relations are not added to
460
- * join_rel_level lists as they are not joined directly by the dynamic
461
- * programming algorithm.
462
- *
463
- * There is also a RelOptKind for "upper" relations, which are RelOptInfos
464
- * that describe post-scan/join processing steps, such as aggregation.
465
- * Many of the fields in these RelOptInfos are meaningless, but their Path
466
- * fields always hold Paths showing ways to do that processing step.
467
- *
468
- * Lastly, there is a RelOptKind for "dead" relations, which are base rels
469
- * that we have proven we don't need to join after all.
470
- *
471
- * Parts of this data structure are specific to various scan and join
472
- * mechanisms. It didn't seem worth creating new node types for them.
473
- *
474
- * relids - Set of base-relation identifiers; it is a base relation
475
- * if there is just one, a join relation if more than one
476
- * rows - estimated number of tuples in the relation after restriction
477
- * clauses have been applied (ie, output rows of a plan for it)
478
- * consider_startup - true if there is any value in keeping plain paths for
479
- * this rel on the basis of having cheap startup cost
480
- * consider_param_startup - the same for parameterized paths
481
- * reltarget - Default Path output tlist for this rel; normally contains
482
- * Var and PlaceHolderVar nodes for the values we need to
483
- * output from this relation.
484
- * List is in no particular order, but all rels of an
485
- * appendrel set must use corresponding orders.
486
- * NOTE: in an appendrel child relation, may contain
487
- * arbitrary expressions pulled up from a subquery!
488
- * pathlist - List of Path nodes, one for each potentially useful
489
- * method of generating the relation
490
- * ppilist - ParamPathInfo nodes for parameterized Paths, if any
491
- * cheapest_startup_path - the pathlist member with lowest startup cost
492
- * (regardless of ordering) among the unparameterized paths;
493
- * or NULL if there is no unparameterized path
494
- * cheapest_total_path - the pathlist member with lowest total cost
495
- * (regardless of ordering) among the unparameterized paths;
496
- * or if there is no unparameterized path, the path with lowest
497
- * total cost among the paths with minimum parameterization
498
- * cheapest_unique_path - for caching cheapest path to produce unique
499
- * (no duplicates) output from relation; NULL if not yet requested
500
- * cheapest_parameterized_paths - best paths for their parameterizations;
501
- * always includes cheapest_total_path, even if that's unparameterized
502
- * direct_lateral_relids - rels this rel has direct LATERAL references to
503
- * lateral_relids - required outer rels for LATERAL, as a Relids set
504
- * (includes both direct and indirect lateral references)
505
- *
506
- * If the relation is a base relation it will have these fields set:
507
- *
508
- * relid - RTE index (this is redundant with the relids field, but
509
- * is provided for convenience of access)
510
- * rtekind - copy of RTE's rtekind field
511
- * min_attr, max_attr - range of valid AttrNumbers for rel
512
- * attr_needed - array of bitmapsets indicating the highest joinrel
513
- * in which each attribute is needed; if bit 0 is set then
514
- * the attribute is needed as part of final targetlist
515
- * attr_widths - cache space for per-attribute width estimates;
516
- * zero means not computed yet
517
- * lateral_vars - lateral cross-references of rel, if any (list of
518
- * Vars and PlaceHolderVars)
519
- * lateral_referencers - relids of rels that reference this one laterally
520
- * (includes both direct and indirect lateral references)
521
- * indexlist - list of IndexOptInfo nodes for relation's indexes
522
- * (always NIL if it's not a table)
523
- * pages - number of disk pages in relation (zero if not a table)
524
- * tuples - number of tuples in relation (not considering restrictions)
525
- * allvisfrac - fraction of disk pages that are marked all-visible
526
- * eclass_indexes - EquivalenceClasses that mention this rel (filled
527
- * only after EC merging is complete)
528
- * subroot - PlannerInfo for subquery (NULL if it's not a subquery)
529
- * subplan_params - list of PlannerParamItems to be passed to subquery
530
- *
531
- * Note: for a subquery, tuples and subroot are not set immediately
532
- * upon creation of the RelOptInfo object; they are filled in when
533
- * set_subquery_pathlist processes the object.
534
- *
535
- * For otherrels that are appendrel members, these fields are filled
536
- * in just as for a baserel, except we don't bother with lateral_vars.
537
- *
538
- * If the relation is either a foreign table or a join of foreign tables that
539
- * all belong to the same foreign server and are assigned to the same user to
540
- * check access permissions as (cf checkAsUser), these fields will be set:
541
- *
542
- * serverid - OID of foreign server, if foreign table (else InvalidOid)
543
- * userid - OID of user to check access as (InvalidOid means current user)
544
- * useridiscurrent - we've assumed that userid equals current user
545
- * fdwroutine - function hooks for FDW, if foreign table (else NULL)
546
- * fdw_private - private state for FDW, if foreign table (else NULL)
547
- *
548
- * Two fields are used to cache knowledge acquired during the join search
549
- * about whether this rel is provably unique when being joined to given other
550
- * relation(s), ie, it can have at most one row matching any given row from
551
- * that join relation. Currently we only attempt such proofs, and thus only
552
- * populate these fields, for base rels; but someday they might be used for
553
- * join rels too:
554
- *
555
- * unique_for_rels - list of Relid sets, each one being a set of other
556
- * rels for which this one has been proven unique
557
- * non_unique_for_rels - list of Relid sets, each one being a set of
558
- * other rels for which we have tried and failed to prove
559
- * this one unique
560
- *
561
- * The presence of the following fields depends on the restrictions
562
- * and joins that the relation participates in:
563
- *
564
- * baserestrictinfo - List of RestrictInfo nodes, containing info about
565
- * each non-join qualification clause in which this relation
566
- * participates (only used for base rels)
567
- * baserestrictcost - Estimated cost of evaluating the baserestrictinfo
568
- * clauses at a single tuple (only used for base rels)
569
- * baserestrict_min_security - Smallest security_level found among
570
- * clauses in baserestrictinfo
571
- * joininfo - List of RestrictInfo nodes, containing info about each
572
- * join clause in which this relation participates (but
573
- * note this excludes clauses that might be derivable from
574
- * EquivalenceClasses)
575
- * has_eclass_joins - flag that EquivalenceClass joins are possible
576
- *
577
- * Note: Keeping a restrictinfo list in the RelOptInfo is useful only for
578
- * base rels, because for a join rel the set of clauses that are treated as
579
- * restrict clauses varies depending on which sub-relations we choose to join.
580
- * (For example, in a 3-base-rel join, a clause relating rels 1 and 2 must be
581
- * treated as a restrictclause if we join {1} and {2 3} to make {1 2 3}; but
582
- * if we join {1 2} and {3} then that clause will be a restrictclause in {1 2}
583
- * and should not be processed again at the level of {1 2 3}.) Therefore,
584
- * the restrictinfo list in the join case appears in individual JoinPaths
585
- * (field joinrestrictinfo), not in the parent relation. But it's OK for
586
- * the RelOptInfo to store the joininfo list, because that is the same
587
- * for a given rel no matter how we form it.
588
- *
589
- * We store baserestrictcost in the RelOptInfo (for base relations) because
590
- * we know we will need it at least once (to price the sequential scan)
591
- * and may need it multiple times to price index scans.
592
- *
593
- * A join relation is considered to be partitioned if it is formed from a
594
- * join of two relations that are partitioned, have matching partitioning
595
- * schemes, and are joined on an equijoin of the partitioning columns.
596
- * Under those conditions we can consider the join relation to be partitioned
597
- * by either relation's partitioning keys, though some care is needed if
598
- * either relation can be forced to null by outer-joining. For example, an
599
- * outer join like (A LEFT JOIN B ON A.a = B.b) may produce rows with B.b
600
- * NULL. These rows may not fit the partitioning conditions imposed on B.
601
- * Hence, strictly speaking, the join is not partitioned by B.b and thus
602
- * partition keys of an outer join should include partition key expressions
603
- * from the non-nullable side only. However, if a subsequent join uses
604
- * strict comparison operators (and all commonly-used equijoin operators are
605
- * strict), the presence of nulls doesn't cause a problem: such rows couldn't
606
- * match anything on the other side and thus they don't create a need to do
607
- * any cross-partition sub-joins. Hence we can treat such values as still
608
- * partitioning the join output for the purpose of additional partitionwise
609
- * joining, so long as a strict join operator is used by the next join.
610
- *
611
- * If the relation is partitioned, these fields will be set:
612
- *
613
- * part_scheme - Partitioning scheme of the relation
614
- * nparts - Number of partitions
615
- * boundinfo - Partition bounds
616
- * partbounds_merged - true if partition bounds are merged ones
617
- * partition_qual - Partition constraint if not the root
618
- * part_rels - RelOptInfos for each partition
619
- * all_partrels - Relids set of all partition relids
620
- * partexprs, nullable_partexprs - Partition key expressions
621
- *
622
- * The partexprs and nullable_partexprs arrays each contain
623
- * part_scheme->partnatts elements. Each of the elements is a list of
624
- * partition key expressions. For partitioned base relations, there is one
625
- * expression in each partexprs element, and nullable_partexprs is empty.
626
- * For partitioned join relations, each base relation within the join
627
- * contributes one partition key expression per partitioning column;
628
- * that expression goes in the partexprs[i] list if the base relation
629
- * is not nullable by this join or any lower outer join, or in the
630
- * nullable_partexprs[i] list if the base relation is nullable.
631
- * Furthermore, FULL JOINs add extra nullable_partexprs expressions
632
- * corresponding to COALESCE expressions of the left and right join columns,
633
- * to simplify matching join clauses to those lists.
634
- *----------
635
- */
636
-
637
- /* Bitmask of flags supported by table AMs */
638
- #define AMFLAG_HAS_TID_RANGE (1 << 0)
639
-
640
- typedef enum RelOptKind
641
- {
642
- RELOPT_BASEREL,
643
- RELOPT_JOINREL,
644
- RELOPT_OTHER_MEMBER_REL,
645
- RELOPT_OTHER_JOINREL,
646
- RELOPT_UPPER_REL,
647
- RELOPT_OTHER_UPPER_REL,
648
- RELOPT_DEADREL
649
- } RelOptKind;
650
-
651
- /*
652
- * Is the given relation a simple relation i.e a base or "other" member
653
- * relation?
654
- */
655
- #define IS_SIMPLE_REL(rel) \
656
- ((rel)->reloptkind == RELOPT_BASEREL || \
657
- (rel)->reloptkind == RELOPT_OTHER_MEMBER_REL)
658
-
659
- /* Is the given relation a join relation? */
660
- #define IS_JOIN_REL(rel) \
661
- ((rel)->reloptkind == RELOPT_JOINREL || \
662
- (rel)->reloptkind == RELOPT_OTHER_JOINREL)
663
-
664
- /* Is the given relation an upper relation? */
665
- #define IS_UPPER_REL(rel) \
666
- ((rel)->reloptkind == RELOPT_UPPER_REL || \
667
- (rel)->reloptkind == RELOPT_OTHER_UPPER_REL)
668
-
669
- /* Is the given relation an "other" relation? */
670
- #define IS_OTHER_REL(rel) \
671
- ((rel)->reloptkind == RELOPT_OTHER_MEMBER_REL || \
672
- (rel)->reloptkind == RELOPT_OTHER_JOINREL || \
673
- (rel)->reloptkind == RELOPT_OTHER_UPPER_REL)
674
-
675
- typedef struct RelOptInfo
676
- {
677
- NodeTag type;
678
-
679
- RelOptKind reloptkind;
680
-
681
- /* all relations included in this RelOptInfo */
682
- Relids relids; /* set of base relids (rangetable indexes) */
683
-
684
- /* size estimates generated by planner */
685
- Cardinality rows; /* estimated number of result tuples */
686
-
687
- /* per-relation planner control flags */
688
- bool consider_startup; /* keep cheap-startup-cost paths? */
689
- bool consider_param_startup; /* ditto, for parameterized paths? */
690
- bool consider_parallel; /* consider parallel paths? */
691
-
692
- /* default result targetlist for Paths scanning this relation */
693
- struct PathTarget *reltarget; /* list of Vars/Exprs, cost, width */
694
-
695
- /* materialization information */
696
- List *pathlist; /* Path structures */
697
- List *ppilist; /* ParamPathInfos used in pathlist */
698
- List *partial_pathlist; /* partial Paths */
699
- struct Path *cheapest_startup_path;
700
- struct Path *cheapest_total_path;
701
- struct Path *cheapest_unique_path;
702
- List *cheapest_parameterized_paths;
703
-
704
- /* parameterization information needed for both base rels and join rels */
705
- /* (see also lateral_vars and lateral_referencers) */
706
- Relids direct_lateral_relids; /* rels directly laterally referenced */
707
- Relids lateral_relids; /* minimum parameterization of rel */
708
-
709
- /* information about a base rel (not set for join rels!) */
710
- Index relid;
711
- Oid reltablespace; /* containing tablespace */
712
- RTEKind rtekind; /* RELATION, SUBQUERY, FUNCTION, etc */
713
- AttrNumber min_attr; /* smallest attrno of rel (often <0) */
714
- AttrNumber max_attr; /* largest attrno of rel */
715
- Relids *attr_needed; /* array indexed [min_attr .. max_attr] */
716
- int32 *attr_widths; /* array indexed [min_attr .. max_attr] */
717
- List *lateral_vars; /* LATERAL Vars and PHVs referenced by rel */
718
- Relids lateral_referencers; /* rels that reference me laterally */
719
- List *indexlist; /* list of IndexOptInfo */
720
- List *statlist; /* list of StatisticExtInfo */
721
- BlockNumber pages; /* size estimates derived from pg_class */
722
- Cardinality tuples;
723
- double allvisfrac;
724
- Bitmapset *eclass_indexes; /* Indexes in PlannerInfo's eq_classes list of
725
- * ECs that mention this rel */
726
- PlannerInfo *subroot; /* if subquery */
727
- List *subplan_params; /* if subquery */
728
- int rel_parallel_workers; /* wanted number of parallel workers */
729
- uint32 amflags; /* Bitmask of optional features supported by
730
- * the table AM */
731
-
732
- /* Information about foreign tables and foreign joins */
733
- Oid serverid; /* identifies server for the table or join */
734
- Oid userid; /* identifies user to check access as */
735
- bool useridiscurrent; /* join is only valid for current user */
736
- /* use "struct FdwRoutine" to avoid including fdwapi.h here */
737
- struct FdwRoutine *fdwroutine;
738
- void *fdw_private;
739
-
740
- /* cache space for remembering if we have proven this relation unique */
741
- List *unique_for_rels; /* known unique for these other relid
742
- * set(s) */
743
- List *non_unique_for_rels; /* known not unique for these set(s) */
744
-
745
- /* used by various scans and joins: */
746
- List *baserestrictinfo; /* RestrictInfo structures (if base rel) */
747
- QualCost baserestrictcost; /* cost of evaluating the above */
748
- Index baserestrict_min_security; /* min security_level found in
749
- * baserestrictinfo */
750
- List *joininfo; /* RestrictInfo structures for join clauses
751
- * involving this rel */
752
- bool has_eclass_joins; /* T means joininfo is incomplete */
753
-
754
- /* used by partitionwise joins: */
755
- bool consider_partitionwise_join; /* consider partitionwise join
756
- * paths? (if partitioned rel) */
757
- Relids top_parent_relids; /* Relids of topmost parents (if "other"
758
- * rel) */
759
-
760
- /* used for partitioned relations: */
761
- PartitionScheme part_scheme; /* Partitioning scheme */
762
- int nparts; /* Number of partitions; -1 if not yet set; in
763
- * case of a join relation 0 means it's
764
- * considered unpartitioned */
765
- struct PartitionBoundInfoData *boundinfo; /* Partition bounds */
766
- bool partbounds_merged; /* True if partition bounds were created
767
- * by partition_bounds_merge() */
768
- List *partition_qual; /* Partition constraint, if not the root */
769
- struct RelOptInfo **part_rels; /* Array of RelOptInfos of partitions,
770
- * stored in the same order as bounds */
771
- Bitmapset *live_parts; /* Bitmap with members acting as indexes into
772
- * the part_rels[] array to indicate which
773
- * partitions survived partition pruning. */
774
- Relids all_partrels; /* Relids set of all partition relids */
775
- List **partexprs; /* Non-nullable partition key expressions */
776
- List **nullable_partexprs; /* Nullable partition key expressions */
777
- } RelOptInfo;
778
-
779
- /*
780
- * Is given relation partitioned?
781
- *
782
- * It's not enough to test whether rel->part_scheme is set, because it might
783
- * be that the basic partitioning properties of the input relations matched
784
- * but the partition bounds did not. Also, if we are able to prove a rel
785
- * dummy (empty), we should henceforth treat it as unpartitioned.
786
- */
787
- #define IS_PARTITIONED_REL(rel) \
788
- ((rel)->part_scheme && (rel)->boundinfo && (rel)->nparts > 0 && \
789
- (rel)->part_rels && !IS_DUMMY_REL(rel))
790
-
791
- /*
792
- * Convenience macro to make sure that a partitioned relation has all the
793
- * required members set.
794
- */
795
- #define REL_HAS_ALL_PART_PROPS(rel) \
796
- ((rel)->part_scheme && (rel)->boundinfo && (rel)->nparts > 0 && \
797
- (rel)->part_rels && (rel)->partexprs && (rel)->nullable_partexprs)
798
-
799
- /*
800
- * IndexOptInfo
801
- * Per-index information for planning/optimization
802
- *
803
- * indexkeys[], indexcollations[] each have ncolumns entries.
804
- * opfamily[], and opcintype[] each have nkeycolumns entries. They do
805
- * not contain any information about included attributes.
806
- *
807
- * sortopfamily[], reverse_sort[], and nulls_first[] have
808
- * nkeycolumns entries, if the index is ordered; but if it is unordered,
809
- * those pointers are NULL.
810
- *
811
- * Zeroes in the indexkeys[] array indicate index columns that are
812
- * expressions; there is one element in indexprs for each such column.
813
- *
814
- * For an ordered index, reverse_sort[] and nulls_first[] describe the
815
- * sort ordering of a forward indexscan; we can also consider a backward
816
- * indexscan, which will generate the reverse ordering.
817
- *
818
- * The indexprs and indpred expressions have been run through
819
- * prepqual.c and eval_const_expressions() for ease of matching to
820
- * WHERE clauses. indpred is in implicit-AND form.
821
- *
822
- * indextlist is a TargetEntry list representing the index columns.
823
- * It provides an equivalent base-relation Var for each simple column,
824
- * and links to the matching indexprs element for each expression column.
825
- *
826
- * While most of these fields are filled when the IndexOptInfo is created
827
- * (by plancat.c), indrestrictinfo and predOK are set later, in
828
- * check_index_predicates().
829
- */
830
- #ifndef HAVE_INDEXOPTINFO_TYPEDEF
831
- typedef struct IndexOptInfo IndexOptInfo;
832
- #define HAVE_INDEXOPTINFO_TYPEDEF 1
833
- #endif
834
-
835
- struct IndexOptInfo
836
- {
837
- NodeTag type;
838
-
839
- Oid indexoid; /* OID of the index relation */
840
- Oid reltablespace; /* tablespace of index (not table) */
841
- RelOptInfo *rel; /* back-link to index's table */
842
-
843
- /* index-size statistics (from pg_class and elsewhere) */
844
- BlockNumber pages; /* number of disk pages in index */
845
- Cardinality tuples; /* number of index tuples in index */
846
- int tree_height; /* index tree height, or -1 if unknown */
847
-
848
- /* index descriptor information */
849
- int ncolumns; /* number of columns in index */
850
- int nkeycolumns; /* number of key columns in index */
851
- int *indexkeys; /* column numbers of index's attributes both
852
- * key and included columns, or 0 */
853
- Oid *indexcollations; /* OIDs of collations of index columns */
854
- Oid *opfamily; /* OIDs of operator families for columns */
855
- Oid *opcintype; /* OIDs of opclass declared input data types */
856
- Oid *sortopfamily; /* OIDs of btree opfamilies, if orderable */
857
- bool *reverse_sort; /* is sort order descending? */
858
- bool *nulls_first; /* do NULLs come first in the sort order? */
859
- bytea **opclassoptions; /* opclass-specific options for columns */
860
- bool *canreturn; /* which index cols can be returned in an
861
- * index-only scan? */
862
- Oid relam; /* OID of the access method (in pg_am) */
863
-
864
- List *indexprs; /* expressions for non-simple index columns */
865
- List *indpred; /* predicate if a partial index, else NIL */
866
-
867
- List *indextlist; /* targetlist representing index columns */
868
-
869
- List *indrestrictinfo; /* parent relation's baserestrictinfo
870
- * list, less any conditions implied by
871
- * the index's predicate (unless it's a
872
- * target rel, see comments in
873
- * check_index_predicates()) */
874
-
875
- bool predOK; /* true if index predicate matches query */
876
- bool unique; /* true if a unique index */
877
- bool immediate; /* is uniqueness enforced immediately? */
878
- bool hypothetical; /* true if index doesn't really exist */
879
-
880
- /* Remaining fields are copied from the index AM's API struct: */
881
- bool amcanorderbyop; /* does AM support order by operator result? */
882
- bool amoptionalkey; /* can query omit key for the first column? */
883
- bool amsearcharray; /* can AM handle ScalarArrayOpExpr quals? */
884
- bool amsearchnulls; /* can AM search for NULL/NOT NULL entries? */
885
- bool amhasgettuple; /* does AM have amgettuple interface? */
886
- bool amhasgetbitmap; /* does AM have amgetbitmap interface? */
887
- bool amcanparallel; /* does AM support parallel scan? */
888
- bool amcanmarkpos; /* does AM support mark/restore? */
889
- /* Rather than include amapi.h here, we declare amcostestimate like this */
890
- void (*amcostestimate) (); /* AM's cost estimator */
891
- };
892
-
893
- /*
894
- * ForeignKeyOptInfo
895
- * Per-foreign-key information for planning/optimization
896
- *
897
- * The per-FK-column arrays can be fixed-size because we allow at most
898
- * INDEX_MAX_KEYS columns in a foreign key constraint. Each array has
899
- * nkeys valid entries.
900
- */
901
- typedef struct ForeignKeyOptInfo
902
- {
903
- NodeTag type;
904
-
905
- /* Basic data about the foreign key (fetched from catalogs): */
906
- Index con_relid; /* RT index of the referencing table */
907
- Index ref_relid; /* RT index of the referenced table */
908
- int nkeys; /* number of columns in the foreign key */
909
- AttrNumber conkey[INDEX_MAX_KEYS]; /* cols in referencing table */
910
- AttrNumber confkey[INDEX_MAX_KEYS]; /* cols in referenced table */
911
- Oid conpfeqop[INDEX_MAX_KEYS]; /* PK = FK operator OIDs */
912
-
913
- /* Derived info about whether FK's equality conditions match the query: */
914
- int nmatched_ec; /* # of FK cols matched by ECs */
915
- int nconst_ec; /* # of these ECs that are ec_has_const */
916
- int nmatched_rcols; /* # of FK cols matched by non-EC rinfos */
917
- int nmatched_ri; /* total # of non-EC rinfos matched to FK */
918
- /* Pointer to eclass matching each column's condition, if there is one */
919
- struct EquivalenceClass *eclass[INDEX_MAX_KEYS];
920
- /* Pointer to eclass member for the referencing Var, if there is one */
921
- struct EquivalenceMember *fk_eclass_member[INDEX_MAX_KEYS];
922
- /* List of non-EC RestrictInfos matching each column's condition */
923
- List *rinfos[INDEX_MAX_KEYS];
924
- } ForeignKeyOptInfo;
925
-
926
- /*
927
- * StatisticExtInfo
928
- * Information about extended statistics for planning/optimization
929
- *
930
- * Each pg_statistic_ext row is represented by one or more nodes of this
931
- * type, or even zero if ANALYZE has not computed them.
932
- */
933
- typedef struct StatisticExtInfo
934
- {
935
- NodeTag type;
936
-
937
- Oid statOid; /* OID of the statistics row */
938
- bool inherit; /* includes child relations */
939
- RelOptInfo *rel; /* back-link to statistic's table */
940
- char kind; /* statistics kind of this entry */
941
- Bitmapset *keys; /* attnums of the columns covered */
942
- List *exprs; /* expressions */
943
- } StatisticExtInfo;
944
-
945
- /*
946
- * EquivalenceClasses
947
- *
948
- * Whenever we can determine that a mergejoinable equality clause A = B is
949
- * not delayed by any outer join, we create an EquivalenceClass containing
950
- * the expressions A and B to record this knowledge. If we later find another
951
- * equivalence B = C, we add C to the existing EquivalenceClass; this may
952
- * require merging two existing EquivalenceClasses. At the end of the qual
953
- * distribution process, we have sets of values that are known all transitively
954
- * equal to each other, where "equal" is according to the rules of the btree
955
- * operator family(s) shown in ec_opfamilies, as well as the collation shown
956
- * by ec_collation. (We restrict an EC to contain only equalities whose
957
- * operators belong to the same set of opfamilies. This could probably be
958
- * relaxed, but for now it's not worth the trouble, since nearly all equality
959
- * operators belong to only one btree opclass anyway. Similarly, we suppose
960
- * that all or none of the input datatypes are collatable, so that a single
961
- * collation value is sufficient.)
962
- *
963
- * We also use EquivalenceClasses as the base structure for PathKeys, letting
964
- * us represent knowledge about different sort orderings being equivalent.
965
- * Since every PathKey must reference an EquivalenceClass, we will end up
966
- * with single-member EquivalenceClasses whenever a sort key expression has
967
- * not been equivalenced to anything else. It is also possible that such an
968
- * EquivalenceClass will contain a volatile expression ("ORDER BY random()"),
969
- * which is a case that can't arise otherwise since clauses containing
970
- * volatile functions are never considered mergejoinable. We mark such
971
- * EquivalenceClasses specially to prevent them from being merged with
972
- * ordinary EquivalenceClasses. Also, for volatile expressions we have
973
- * to be careful to match the EquivalenceClass to the correct targetlist
974
- * entry: consider SELECT random() AS a, random() AS b ... ORDER BY b,a.
975
- * So we record the SortGroupRef of the originating sort clause.
976
- *
977
- * We allow equality clauses appearing below the nullable side of an outer join
978
- * to form EquivalenceClasses, but these have a slightly different meaning:
979
- * the included values might be all NULL rather than all the same non-null
980
- * values. See src/backend/optimizer/README for more on that point.
981
- *
982
- * NB: if ec_merged isn't NULL, this class has been merged into another, and
983
- * should be ignored in favor of using the pointed-to class.
984
- */
985
- typedef struct EquivalenceClass
986
- {
987
- NodeTag type;
988
-
989
- List *ec_opfamilies; /* btree operator family OIDs */
990
- Oid ec_collation; /* collation, if datatypes are collatable */
991
- List *ec_members; /* list of EquivalenceMembers */
992
- List *ec_sources; /* list of generating RestrictInfos */
993
- List *ec_derives; /* list of derived RestrictInfos */
994
- Relids ec_relids; /* all relids appearing in ec_members, except
995
- * for child members (see below) */
996
- bool ec_has_const; /* any pseudoconstants in ec_members? */
997
- bool ec_has_volatile; /* the (sole) member is a volatile expr */
998
- bool ec_below_outer_join; /* equivalence applies below an OJ */
999
- bool ec_broken; /* failed to generate needed clauses? */
1000
- Index ec_sortref; /* originating sortclause label, or 0 */
1001
- Index ec_min_security; /* minimum security_level in ec_sources */
1002
- Index ec_max_security; /* maximum security_level in ec_sources */
1003
- struct EquivalenceClass *ec_merged; /* set if merged into another EC */
1004
- } EquivalenceClass;
1005
-
1006
- /*
1007
- * If an EC contains a const and isn't below-outer-join, any PathKey depending
1008
- * on it must be redundant, since there's only one possible value of the key.
1009
- */
1010
- #define EC_MUST_BE_REDUNDANT(eclass) \
1011
- ((eclass)->ec_has_const && !(eclass)->ec_below_outer_join)
1012
-
1013
- /*
1014
- * EquivalenceMember - one member expression of an EquivalenceClass
1015
- *
1016
- * em_is_child signifies that this element was built by transposing a member
1017
- * for an appendrel parent relation to represent the corresponding expression
1018
- * for an appendrel child. These members are used for determining the
1019
- * pathkeys of scans on the child relation and for explicitly sorting the
1020
- * child when necessary to build a MergeAppend path for the whole appendrel
1021
- * tree. An em_is_child member has no impact on the properties of the EC as a
1022
- * whole; in particular the EC's ec_relids field does NOT include the child
1023
- * relation. An em_is_child member should never be marked em_is_const nor
1024
- * cause ec_has_const or ec_has_volatile to be set, either. Thus, em_is_child
1025
- * members are not really full-fledged members of the EC, but just reflections
1026
- * or doppelgangers of real members. Most operations on EquivalenceClasses
1027
- * should ignore em_is_child members, and those that don't should test
1028
- * em_relids to make sure they only consider relevant members.
1029
- *
1030
- * em_datatype is usually the same as exprType(em_expr), but can be
1031
- * different when dealing with a binary-compatible opfamily; in particular
1032
- * anyarray_ops would never work without this. Use em_datatype when
1033
- * looking up a specific btree operator to work with this expression.
1034
- */
1035
- typedef struct EquivalenceMember
1036
- {
1037
- NodeTag type;
1038
-
1039
- Expr *em_expr; /* the expression represented */
1040
- Relids em_relids; /* all relids appearing in em_expr */
1041
- Relids em_nullable_relids; /* nullable by lower outer joins */
1042
- bool em_is_const; /* expression is pseudoconstant? */
1043
- bool em_is_child; /* derived version for a child relation? */
1044
- Oid em_datatype; /* the "nominal type" used by the opfamily */
1045
- } EquivalenceMember;
1046
-
1047
- /*
1048
- * PathKeys
1049
- *
1050
- * The sort ordering of a path is represented by a list of PathKey nodes.
1051
- * An empty list implies no known ordering. Otherwise the first item
1052
- * represents the primary sort key, the second the first secondary sort key,
1053
- * etc. The value being sorted is represented by linking to an
1054
- * EquivalenceClass containing that value and including pk_opfamily among its
1055
- * ec_opfamilies. The EquivalenceClass tells which collation to use, too.
1056
- * This is a convenient method because it makes it trivial to detect
1057
- * equivalent and closely-related orderings. (See optimizer/README for more
1058
- * information.)
1059
- *
1060
- * Note: pk_strategy is either BTLessStrategyNumber (for ASC) or
1061
- * BTGreaterStrategyNumber (for DESC). We assume that all ordering-capable
1062
- * index types will use btree-compatible strategy numbers.
1063
- */
1064
- typedef struct PathKey
1065
- {
1066
- NodeTag type;
1067
-
1068
- EquivalenceClass *pk_eclass; /* the value that is ordered */
1069
- Oid pk_opfamily; /* btree opfamily defining the ordering */
1070
- int pk_strategy; /* sort direction (ASC or DESC) */
1071
- bool pk_nulls_first; /* do NULLs come before normal values? */
1072
- } PathKey;
1073
-
1074
- /*
1075
- * VolatileFunctionStatus -- allows nodes to cache their
1076
- * contain_volatile_functions properties. VOLATILITY_UNKNOWN means not yet
1077
- * determined.
1078
- */
1079
- typedef enum VolatileFunctionStatus
1080
- {
1081
- VOLATILITY_UNKNOWN = 0,
1082
- VOLATILITY_VOLATILE,
1083
- VOLATILITY_NOVOLATILE
1084
- } VolatileFunctionStatus;
1085
-
1086
- /*
1087
- * PathTarget
1088
- *
1089
- * This struct contains what we need to know during planning about the
1090
- * targetlist (output columns) that a Path will compute. Each RelOptInfo
1091
- * includes a default PathTarget, which its individual Paths may simply
1092
- * reference. However, in some cases a Path may compute outputs different
1093
- * from other Paths, and in that case we make a custom PathTarget for it.
1094
- * For example, an indexscan might return index expressions that would
1095
- * otherwise need to be explicitly calculated. (Note also that "upper"
1096
- * relations generally don't have useful default PathTargets.)
1097
- *
1098
- * exprs contains bare expressions; they do not have TargetEntry nodes on top,
1099
- * though those will appear in finished Plans.
1100
- *
1101
- * sortgrouprefs[] is an array of the same length as exprs, containing the
1102
- * corresponding sort/group refnos, or zeroes for expressions not referenced
1103
- * by sort/group clauses. If sortgrouprefs is NULL (which it generally is in
1104
- * RelOptInfo.reltarget targets; only upper-level Paths contain this info),
1105
- * we have not identified sort/group columns in this tlist. This allows us to
1106
- * deal with sort/group refnos when needed with less expense than including
1107
- * TargetEntry nodes in the exprs list.
1108
- */
1109
- typedef struct PathTarget
1110
- {
1111
- NodeTag type;
1112
- List *exprs; /* list of expressions to be computed */
1113
- Index *sortgrouprefs; /* corresponding sort/group refnos, or 0 */
1114
- QualCost cost; /* cost of evaluating the expressions */
1115
- int width; /* estimated avg width of result tuples */
1116
- VolatileFunctionStatus has_volatile_expr; /* indicates if exprs contain
1117
- * any volatile functions. */
1118
- } PathTarget;
1119
-
1120
- /* Convenience macro to get a sort/group refno from a PathTarget */
1121
- #define get_pathtarget_sortgroupref(target, colno) \
1122
- ((target)->sortgrouprefs ? (target)->sortgrouprefs[colno] : (Index) 0)
1123
-
1124
-
1125
- /*
1126
- * ParamPathInfo
1127
- *
1128
- * All parameterized paths for a given relation with given required outer rels
1129
- * link to a single ParamPathInfo, which stores common information such as
1130
- * the estimated rowcount for this parameterization. We do this partly to
1131
- * avoid recalculations, but mostly to ensure that the estimated rowcount
1132
- * is in fact the same for every such path.
1133
- *
1134
- * Note: ppi_clauses is only used in ParamPathInfos for base relation paths;
1135
- * in join cases it's NIL because the set of relevant clauses varies depending
1136
- * on how the join is formed. The relevant clauses will appear in each
1137
- * parameterized join path's joinrestrictinfo list, instead.
1138
- */
1139
- typedef struct ParamPathInfo
1140
- {
1141
- NodeTag type;
1142
-
1143
- Relids ppi_req_outer; /* rels supplying parameters used by path */
1144
- Cardinality ppi_rows; /* estimated number of result tuples */
1145
- List *ppi_clauses; /* join clauses available from outer rels */
1146
- } ParamPathInfo;
1147
-
1148
-
1149
- /*
1150
- * Type "Path" is used as-is for sequential-scan paths, as well as some other
1151
- * simple plan types that we don't need any extra information in the path for.
1152
- * For other path types it is the first component of a larger struct.
1153
- *
1154
- * "pathtype" is the NodeTag of the Plan node we could build from this Path.
1155
- * It is partially redundant with the Path's NodeTag, but allows us to use
1156
- * the same Path type for multiple Plan types when there is no need to
1157
- * distinguish the Plan type during path processing.
1158
- *
1159
- * "parent" identifies the relation this Path scans, and "pathtarget"
1160
- * describes the precise set of output columns the Path would compute.
1161
- * In simple cases all Paths for a given rel share the same targetlist,
1162
- * which we represent by having path->pathtarget equal to parent->reltarget.
1163
- *
1164
- * "param_info", if not NULL, links to a ParamPathInfo that identifies outer
1165
- * relation(s) that provide parameter values to each scan of this path.
1166
- * That means this path can only be joined to those rels by means of nestloop
1167
- * joins with this path on the inside. Also note that a parameterized path
1168
- * is responsible for testing all "movable" joinclauses involving this rel
1169
- * and the specified outer rel(s).
1170
- *
1171
- * "rows" is the same as parent->rows in simple paths, but in parameterized
1172
- * paths and UniquePaths it can be less than parent->rows, reflecting the
1173
- * fact that we've filtered by extra join conditions or removed duplicates.
1174
- *
1175
- * "pathkeys" is a List of PathKey nodes (see above), describing the sort
1176
- * ordering of the path's output rows.
1177
- */
1178
- typedef struct Path
1179
- {
1180
- NodeTag type;
1181
-
1182
- NodeTag pathtype; /* tag identifying scan/join method */
1183
-
1184
- RelOptInfo *parent; /* the relation this path can build */
1185
- PathTarget *pathtarget; /* list of Vars/Exprs, cost, width */
1186
-
1187
- ParamPathInfo *param_info; /* parameterization info, or NULL if none */
1188
-
1189
- bool parallel_aware; /* engage parallel-aware logic? */
1190
- bool parallel_safe; /* OK to use as part of parallel plan? */
1191
- int parallel_workers; /* desired # of workers; 0 = not parallel */
1192
-
1193
- /* estimated size/costs for path (see costsize.c for more info) */
1194
- Cardinality rows; /* estimated number of result tuples */
1195
- Cost startup_cost; /* cost expended before fetching any tuples */
1196
- Cost total_cost; /* total cost (assuming all tuples fetched) */
1197
-
1198
- List *pathkeys; /* sort ordering of path's output */
1199
- /* pathkeys is a List of PathKey nodes; see above */
1200
- } Path;
1201
-
1202
- /* Macro for extracting a path's parameterization relids; beware double eval */
1203
- #define PATH_REQ_OUTER(path) \
1204
- ((path)->param_info ? (path)->param_info->ppi_req_outer : (Relids) NULL)
1205
-
1206
- /*----------
1207
- * IndexPath represents an index scan over a single index.
1208
- *
1209
- * This struct is used for both regular indexscans and index-only scans;
1210
- * path.pathtype is T_IndexScan or T_IndexOnlyScan to show which is meant.
1211
- *
1212
- * 'indexinfo' is the index to be scanned.
1213
- *
1214
- * 'indexclauses' is a list of IndexClause nodes, each representing one
1215
- * index-checkable restriction, with implicit AND semantics across the list.
1216
- * An empty list implies a full index scan.
1217
- *
1218
- * 'indexorderbys', if not NIL, is a list of ORDER BY expressions that have
1219
- * been found to be usable as ordering operators for an amcanorderbyop index.
1220
- * The list must match the path's pathkeys, ie, one expression per pathkey
1221
- * in the same order. These are not RestrictInfos, just bare expressions,
1222
- * since they generally won't yield booleans. It's guaranteed that each
1223
- * expression has the index key on the left side of the operator.
1224
- *
1225
- * 'indexorderbycols' is an integer list of index column numbers (zero-based)
1226
- * of the same length as 'indexorderbys', showing which index column each
1227
- * ORDER BY expression is meant to be used with. (There is no restriction
1228
- * on which index column each ORDER BY can be used with.)
1229
- *
1230
- * 'indexscandir' is one of:
1231
- * ForwardScanDirection: forward scan of an ordered index
1232
- * BackwardScanDirection: backward scan of an ordered index
1233
- * NoMovementScanDirection: scan of an unordered index, or don't care
1234
- * (The executor doesn't care whether it gets ForwardScanDirection or
1235
- * NoMovementScanDirection for an indexscan, but the planner wants to
1236
- * distinguish ordered from unordered indexes for building pathkeys.)
1237
- *
1238
- * 'indextotalcost' and 'indexselectivity' are saved in the IndexPath so that
1239
- * we need not recompute them when considering using the same index in a
1240
- * bitmap index/heap scan (see BitmapHeapPath). The costs of the IndexPath
1241
- * itself represent the costs of an IndexScan or IndexOnlyScan plan type.
1242
- *----------
1243
- */
1244
- typedef struct IndexPath
1245
- {
1246
- Path path;
1247
- IndexOptInfo *indexinfo;
1248
- List *indexclauses;
1249
- List *indexorderbys;
1250
- List *indexorderbycols;
1251
- ScanDirection indexscandir;
1252
- Cost indextotalcost;
1253
- Selectivity indexselectivity;
1254
- } IndexPath;
1255
-
1256
- /*
1257
- * Each IndexClause references a RestrictInfo node from the query's WHERE
1258
- * or JOIN conditions, and shows how that restriction can be applied to
1259
- * the particular index. We support both indexclauses that are directly
1260
- * usable by the index machinery, which are typically of the form
1261
- * "indexcol OP pseudoconstant", and those from which an indexable qual
1262
- * can be derived. The simplest such transformation is that a clause
1263
- * of the form "pseudoconstant OP indexcol" can be commuted to produce an
1264
- * indexable qual (the index machinery expects the indexcol to be on the
1265
- * left always). Another example is that we might be able to extract an
1266
- * indexable range condition from a LIKE condition, as in "x LIKE 'foo%bar'"
1267
- * giving rise to "x >= 'foo' AND x < 'fop'". Derivation of such lossy
1268
- * conditions is done by a planner support function attached to the
1269
- * indexclause's top-level function or operator.
1270
- *
1271
- * indexquals is a list of RestrictInfos for the directly-usable index
1272
- * conditions associated with this IndexClause. In the simplest case
1273
- * it's a one-element list whose member is iclause->rinfo. Otherwise,
1274
- * it contains one or more directly-usable indexqual conditions extracted
1275
- * from the given clause. The 'lossy' flag indicates whether the
1276
- * indexquals are semantically equivalent to the original clause, or
1277
- * represent a weaker condition.
1278
- *
1279
- * Normally, indexcol is the index of the single index column the clause
1280
- * works on, and indexcols is NIL. But if the clause is a RowCompareExpr,
1281
- * indexcol is the index of the leading column, and indexcols is a list of
1282
- * all the affected columns. (Note that indexcols matches up with the
1283
- * columns of the actual indexable RowCompareExpr in indexquals, which
1284
- * might be different from the original in rinfo.)
1285
- *
1286
- * An IndexPath's IndexClause list is required to be ordered by index
1287
- * column, i.e. the indexcol values must form a nondecreasing sequence.
1288
- * (The order of multiple clauses for the same index column is unspecified.)
1289
- */
1290
- typedef struct IndexClause
1291
- {
1292
- NodeTag type;
1293
- struct RestrictInfo *rinfo; /* original restriction or join clause */
1294
- List *indexquals; /* indexqual(s) derived from it */
1295
- bool lossy; /* are indexquals a lossy version of clause? */
1296
- AttrNumber indexcol; /* index column the clause uses (zero-based) */
1297
- List *indexcols; /* multiple index columns, if RowCompare */
1298
- } IndexClause;
1299
-
1300
- /*
1301
- * BitmapHeapPath represents one or more indexscans that generate TID bitmaps
1302
- * instead of directly accessing the heap, followed by AND/OR combinations
1303
- * to produce a single bitmap, followed by a heap scan that uses the bitmap.
1304
- * Note that the output is always considered unordered, since it will come
1305
- * out in physical heap order no matter what the underlying indexes did.
1306
- *
1307
- * The individual indexscans are represented by IndexPath nodes, and any
1308
- * logic on top of them is represented by a tree of BitmapAndPath and
1309
- * BitmapOrPath nodes. Notice that we can use the same IndexPath node both
1310
- * to represent a regular (or index-only) index scan plan, and as the child
1311
- * of a BitmapHeapPath that represents scanning the same index using a
1312
- * BitmapIndexScan. The startup_cost and total_cost figures of an IndexPath
1313
- * always represent the costs to use it as a regular (or index-only)
1314
- * IndexScan. The costs of a BitmapIndexScan can be computed using the
1315
- * IndexPath's indextotalcost and indexselectivity.
1316
- */
1317
- typedef struct BitmapHeapPath
1318
- {
1319
- Path path;
1320
- Path *bitmapqual; /* IndexPath, BitmapAndPath, BitmapOrPath */
1321
- } BitmapHeapPath;
1322
-
1323
- /*
1324
- * BitmapAndPath represents a BitmapAnd plan node; it can only appear as
1325
- * part of the substructure of a BitmapHeapPath. The Path structure is
1326
- * a bit more heavyweight than we really need for this, but for simplicity
1327
- * we make it a derivative of Path anyway.
1328
- */
1329
- typedef struct BitmapAndPath
1330
- {
1331
- Path path;
1332
- List *bitmapquals; /* IndexPaths and BitmapOrPaths */
1333
- Selectivity bitmapselectivity;
1334
- } BitmapAndPath;
1335
-
1336
- /*
1337
- * BitmapOrPath represents a BitmapOr plan node; it can only appear as
1338
- * part of the substructure of a BitmapHeapPath. The Path structure is
1339
- * a bit more heavyweight than we really need for this, but for simplicity
1340
- * we make it a derivative of Path anyway.
1341
- */
1342
- typedef struct BitmapOrPath
1343
- {
1344
- Path path;
1345
- List *bitmapquals; /* IndexPaths and BitmapAndPaths */
1346
- Selectivity bitmapselectivity;
1347
- } BitmapOrPath;
1348
-
1349
- /*
1350
- * TidPath represents a scan by TID
1351
- *
1352
- * tidquals is an implicitly OR'ed list of qual expressions of the form
1353
- * "CTID = pseudoconstant", or "CTID = ANY(pseudoconstant_array)",
1354
- * or a CurrentOfExpr for the relation.
1355
- */
1356
- typedef struct TidPath
1357
- {
1358
- Path path;
1359
- List *tidquals; /* qual(s) involving CTID = something */
1360
- } TidPath;
1361
-
1362
- /*
1363
- * TidRangePath represents a scan by a contiguous range of TIDs
1364
- *
1365
- * tidrangequals is an implicitly AND'ed list of qual expressions of the form
1366
- * "CTID relop pseudoconstant", where relop is one of >,>=,<,<=.
1367
- */
1368
- typedef struct TidRangePath
1369
- {
1370
- Path path;
1371
- List *tidrangequals;
1372
- } TidRangePath;
1373
-
1374
- /*
1375
- * SubqueryScanPath represents a scan of an unflattened subquery-in-FROM
1376
- *
1377
- * Note that the subpath comes from a different planning domain; for example
1378
- * RTE indexes within it mean something different from those known to the
1379
- * SubqueryScanPath. path.parent->subroot is the planning context needed to
1380
- * interpret the subpath.
1381
- */
1382
- typedef struct SubqueryScanPath
1383
- {
1384
- Path path;
1385
- Path *subpath; /* path representing subquery execution */
1386
- } SubqueryScanPath;
1387
-
1388
- /*
1389
- * ForeignPath represents a potential scan of a foreign table, foreign join
1390
- * or foreign upper-relation.
1391
- *
1392
- * fdw_private stores FDW private data about the scan. While fdw_private is
1393
- * not actually touched by the core code during normal operations, it's
1394
- * generally a good idea to use a representation that can be dumped by
1395
- * nodeToString(), so that you can examine the structure during debugging
1396
- * with tools like pprint().
1397
- */
1398
- typedef struct ForeignPath
1399
- {
1400
- Path path;
1401
- Path *fdw_outerpath;
1402
- List *fdw_private;
1403
- } ForeignPath;
1404
-
1405
- /*
1406
- * CustomPath represents a table scan done by some out-of-core extension.
1407
- *
1408
- * We provide a set of hooks here - which the provider must take care to set
1409
- * up correctly - to allow extensions to supply their own methods of scanning
1410
- * a relation. For example, a provider might provide GPU acceleration, a
1411
- * cache-based scan, or some other kind of logic we haven't dreamed up yet.
1412
- *
1413
- * CustomPaths can be injected into the planning process for a relation by
1414
- * set_rel_pathlist_hook functions.
1415
- *
1416
- * Core code must avoid assuming that the CustomPath is only as large as
1417
- * the structure declared here; providers are allowed to make it the first
1418
- * element in a larger structure. (Since the planner never copies Paths,
1419
- * this doesn't add any complication.) However, for consistency with the
1420
- * FDW case, we provide a "custom_private" field in CustomPath; providers
1421
- * may prefer to use that rather than define another struct type.
1422
- */
1423
-
1424
- struct CustomPathMethods;
1425
-
1426
- typedef struct CustomPath
1427
- {
1428
- Path path;
1429
- uint32 flags; /* mask of CUSTOMPATH_* flags, see
1430
- * nodes/extensible.h */
1431
- List *custom_paths; /* list of child Path nodes, if any */
1432
- List *custom_private;
1433
- const struct CustomPathMethods *methods;
1434
- } CustomPath;
1435
-
1436
- /*
1437
- * AppendPath represents an Append plan, ie, successive execution of
1438
- * several member plans.
1439
- *
1440
- * For partial Append, 'subpaths' contains non-partial subpaths followed by
1441
- * partial subpaths.
1442
- *
1443
- * Note: it is possible for "subpaths" to contain only one, or even no,
1444
- * elements. These cases are optimized during create_append_plan.
1445
- * In particular, an AppendPath with no subpaths is a "dummy" path that
1446
- * is created to represent the case that a relation is provably empty.
1447
- * (This is a convenient representation because it means that when we build
1448
- * an appendrel and find that all its children have been excluded, no extra
1449
- * action is needed to recognize the relation as dummy.)
1450
- */
1451
- typedef struct AppendPath
1452
- {
1453
- Path path;
1454
- List *subpaths; /* list of component Paths */
1455
- /* Index of first partial path in subpaths; list_length(subpaths) if none */
1456
- int first_partial_path;
1457
- Cardinality limit_tuples; /* hard limit on output tuples, or -1 */
1458
- } AppendPath;
1459
-
1460
- #define IS_DUMMY_APPEND(p) \
1461
- (IsA((p), AppendPath) && ((AppendPath *) (p))->subpaths == NIL)
1462
-
1463
- /*
1464
- * A relation that's been proven empty will have one path that is dummy
1465
- * (but might have projection paths on top). For historical reasons,
1466
- * this is provided as a macro that wraps is_dummy_rel().
1467
- */
1468
- #define IS_DUMMY_REL(r) is_dummy_rel(r)
1469
- extern bool is_dummy_rel(RelOptInfo *rel);
1470
-
1471
- /*
1472
- * MergeAppendPath represents a MergeAppend plan, ie, the merging of sorted
1473
- * results from several member plans to produce similarly-sorted output.
1474
- */
1475
- typedef struct MergeAppendPath
1476
- {
1477
- Path path;
1478
- List *subpaths; /* list of component Paths */
1479
- Cardinality limit_tuples; /* hard limit on output tuples, or -1 */
1480
- } MergeAppendPath;
1481
-
1482
- /*
1483
- * GroupResultPath represents use of a Result plan node to compute the
1484
- * output of a degenerate GROUP BY case, wherein we know we should produce
1485
- * exactly one row, which might then be filtered by a HAVING qual.
1486
- *
1487
- * Note that quals is a list of bare clauses, not RestrictInfos.
1488
- */
1489
- typedef struct GroupResultPath
1490
- {
1491
- Path path;
1492
- List *quals;
1493
- } GroupResultPath;
1494
-
1495
- /*
1496
- * MaterialPath represents use of a Material plan node, i.e., caching of
1497
- * the output of its subpath. This is used when the subpath is expensive
1498
- * and needs to be scanned repeatedly, or when we need mark/restore ability
1499
- * and the subpath doesn't have it.
1500
- */
1501
- typedef struct MaterialPath
1502
- {
1503
- Path path;
1504
- Path *subpath;
1505
- } MaterialPath;
1506
-
1507
- /*
1508
- * MemoizePath represents a Memoize plan node, i.e., a cache that caches
1509
- * tuples from parameterized paths to save the underlying node from having to
1510
- * be rescanned for parameter values which are already cached.
1511
- */
1512
- typedef struct MemoizePath
1513
- {
1514
- Path path;
1515
- Path *subpath; /* outerpath to cache tuples from */
1516
- List *hash_operators; /* hash operators for each key */
1517
- List *param_exprs; /* cache keys */
1518
- bool singlerow; /* true if the cache entry is to be marked as
1519
- * complete after caching the first record. */
1520
- bool binary_mode; /* true when cache key should be compared bit
1521
- * by bit, false when using hash equality ops */
1522
- Cardinality calls; /* expected number of rescans */
1523
- uint32 est_entries; /* The maximum number of entries that the
1524
- * planner expects will fit in the cache, or 0
1525
- * if unknown */
1526
- } MemoizePath;
1527
-
1528
- /*
1529
- * UniquePath represents elimination of distinct rows from the output of
1530
- * its subpath.
1531
- *
1532
- * This can represent significantly different plans: either hash-based or
1533
- * sort-based implementation, or a no-op if the input path can be proven
1534
- * distinct already. The decision is sufficiently localized that it's not
1535
- * worth having separate Path node types. (Note: in the no-op case, we could
1536
- * eliminate the UniquePath node entirely and just return the subpath; but
1537
- * it's convenient to have a UniquePath in the path tree to signal upper-level
1538
- * routines that the input is known distinct.)
1539
- */
1540
- typedef enum UniquePathMethod
1541
- {
1542
- UNIQUE_PATH_NOOP, /* input is known unique already */
1543
- UNIQUE_PATH_HASH, /* use hashing */
1544
- UNIQUE_PATH_SORT /* use sorting */
1545
- } UniquePathMethod;
1546
-
1547
- typedef struct UniquePath
1548
- {
1549
- Path path;
1550
- Path *subpath;
1551
- UniquePathMethod umethod;
1552
- List *in_operators; /* equality operators of the IN clause */
1553
- List *uniq_exprs; /* expressions to be made unique */
1554
- } UniquePath;
1555
-
1556
- /*
1557
- * GatherPath runs several copies of a plan in parallel and collects the
1558
- * results. The parallel leader may also execute the plan, unless the
1559
- * single_copy flag is set.
1560
- */
1561
- typedef struct GatherPath
1562
- {
1563
- Path path;
1564
- Path *subpath; /* path for each worker */
1565
- bool single_copy; /* don't execute path more than once */
1566
- int num_workers; /* number of workers sought to help */
1567
- } GatherPath;
1568
-
1569
- /*
1570
- * GatherMergePath runs several copies of a plan in parallel and collects
1571
- * the results, preserving their common sort order.
1572
- */
1573
- typedef struct GatherMergePath
1574
- {
1575
- Path path;
1576
- Path *subpath; /* path for each worker */
1577
- int num_workers; /* number of workers sought to help */
1578
- } GatherMergePath;
1579
-
1580
-
1581
- /*
1582
- * All join-type paths share these fields.
1583
- */
1584
-
1585
- typedef struct JoinPath
1586
- {
1587
- Path path;
1588
-
1589
- JoinType jointype;
1590
-
1591
- bool inner_unique; /* each outer tuple provably matches no more
1592
- * than one inner tuple */
1593
-
1594
- Path *outerjoinpath; /* path for the outer side of the join */
1595
- Path *innerjoinpath; /* path for the inner side of the join */
1596
-
1597
- List *joinrestrictinfo; /* RestrictInfos to apply to join */
1598
-
1599
- /*
1600
- * See the notes for RelOptInfo and ParamPathInfo to understand why
1601
- * joinrestrictinfo is needed in JoinPath, and can't be merged into the
1602
- * parent RelOptInfo.
1603
- */
1604
- } JoinPath;
1605
-
1606
- /*
1607
- * A nested-loop path needs no special fields.
1608
- */
1609
-
1610
- typedef struct NestPath
1611
- {
1612
- JoinPath jpath;
1613
- } NestPath;
1614
-
1615
- /*
1616
- * A mergejoin path has these fields.
1617
- *
1618
- * Unlike other path types, a MergePath node doesn't represent just a single
1619
- * run-time plan node: it can represent up to four. Aside from the MergeJoin
1620
- * node itself, there can be a Sort node for the outer input, a Sort node
1621
- * for the inner input, and/or a Material node for the inner input. We could
1622
- * represent these nodes by separate path nodes, but considering how many
1623
- * different merge paths are investigated during a complex join problem,
1624
- * it seems better to avoid unnecessary palloc overhead.
1625
- *
1626
- * path_mergeclauses lists the clauses (in the form of RestrictInfos)
1627
- * that will be used in the merge.
1628
- *
1629
- * Note that the mergeclauses are a subset of the parent relation's
1630
- * restriction-clause list. Any join clauses that are not mergejoinable
1631
- * appear only in the parent's restrict list, and must be checked by a
1632
- * qpqual at execution time.
1633
- *
1634
- * outersortkeys (resp. innersortkeys) is NIL if the outer path
1635
- * (resp. inner path) is already ordered appropriately for the
1636
- * mergejoin. If it is not NIL then it is a PathKeys list describing
1637
- * the ordering that must be created by an explicit Sort node.
1638
- *
1639
- * skip_mark_restore is true if the executor need not do mark/restore calls.
1640
- * Mark/restore overhead is usually required, but can be skipped if we know
1641
- * that the executor need find only one match per outer tuple, and that the
1642
- * mergeclauses are sufficient to identify a match. In such cases the
1643
- * executor can immediately advance the outer relation after processing a
1644
- * match, and therefore it need never back up the inner relation.
1645
- *
1646
- * materialize_inner is true if a Material node should be placed atop the
1647
- * inner input. This may appear with or without an inner Sort step.
1648
- */
1649
-
1650
- typedef struct MergePath
1651
- {
1652
- JoinPath jpath;
1653
- List *path_mergeclauses; /* join clauses to be used for merge */
1654
- List *outersortkeys; /* keys for explicit sort, if any */
1655
- List *innersortkeys; /* keys for explicit sort, if any */
1656
- bool skip_mark_restore; /* can executor skip mark/restore? */
1657
- bool materialize_inner; /* add Materialize to inner? */
1658
- } MergePath;
1659
-
1660
- /*
1661
- * A hashjoin path has these fields.
1662
- *
1663
- * The remarks above for mergeclauses apply for hashclauses as well.
1664
- *
1665
- * Hashjoin does not care what order its inputs appear in, so we have
1666
- * no need for sortkeys.
1667
- */
1668
-
1669
- typedef struct HashPath
1670
- {
1671
- JoinPath jpath;
1672
- List *path_hashclauses; /* join clauses used for hashing */
1673
- int num_batches; /* number of batches expected */
1674
- Cardinality inner_rows_total; /* total inner rows expected */
1675
- } HashPath;
1676
-
1677
- /*
1678
- * ProjectionPath represents a projection (that is, targetlist computation)
1679
- *
1680
- * Nominally, this path node represents using a Result plan node to do a
1681
- * projection step. However, if the input plan node supports projection,
1682
- * we can just modify its output targetlist to do the required calculations
1683
- * directly, and not need a Result. In some places in the planner we can just
1684
- * jam the desired PathTarget into the input path node (and adjust its cost
1685
- * accordingly), so we don't need a ProjectionPath. But in other places
1686
- * it's necessary to not modify the input path node, so we need a separate
1687
- * ProjectionPath node, which is marked dummy to indicate that we intend to
1688
- * assign the work to the input plan node. The estimated cost for the
1689
- * ProjectionPath node will account for whether a Result will be used or not.
1690
- */
1691
- typedef struct ProjectionPath
1692
- {
1693
- Path path;
1694
- Path *subpath; /* path representing input source */
1695
- bool dummypp; /* true if no separate Result is needed */
1696
- } ProjectionPath;
1697
-
1698
- /*
1699
- * ProjectSetPath represents evaluation of a targetlist that includes
1700
- * set-returning function(s), which will need to be implemented by a
1701
- * ProjectSet plan node.
1702
- */
1703
- typedef struct ProjectSetPath
1704
- {
1705
- Path path;
1706
- Path *subpath; /* path representing input source */
1707
- } ProjectSetPath;
1708
-
1709
- /*
1710
- * SortPath represents an explicit sort step
1711
- *
1712
- * The sort keys are, by definition, the same as path.pathkeys.
1713
- *
1714
- * Note: the Sort plan node cannot project, so path.pathtarget must be the
1715
- * same as the input's pathtarget.
1716
- */
1717
- typedef struct SortPath
1718
- {
1719
- Path path;
1720
- Path *subpath; /* path representing input source */
1721
- } SortPath;
1722
-
1723
- /*
1724
- * IncrementalSortPath represents an incremental sort step
1725
- *
1726
- * This is like a regular sort, except some leading key columns are assumed
1727
- * to be ordered already.
1728
- */
1729
- typedef struct IncrementalSortPath
1730
- {
1731
- SortPath spath;
1732
- int nPresortedCols; /* number of presorted columns */
1733
- } IncrementalSortPath;
1734
-
1735
- /*
1736
- * GroupPath represents grouping (of presorted input)
1737
- *
1738
- * groupClause represents the columns to be grouped on; the input path
1739
- * must be at least that well sorted.
1740
- *
1741
- * We can also apply a qual to the grouped rows (equivalent of HAVING)
1742
- */
1743
- typedef struct GroupPath
1744
- {
1745
- Path path;
1746
- Path *subpath; /* path representing input source */
1747
- List *groupClause; /* a list of SortGroupClause's */
1748
- List *qual; /* quals (HAVING quals), if any */
1749
- } GroupPath;
1750
-
1751
- /*
1752
- * UpperUniquePath represents adjacent-duplicate removal (in presorted input)
1753
- *
1754
- * The columns to be compared are the first numkeys columns of the path's
1755
- * pathkeys. The input is presumed already sorted that way.
1756
- */
1757
- typedef struct UpperUniquePath
1758
- {
1759
- Path path;
1760
- Path *subpath; /* path representing input source */
1761
- int numkeys; /* number of pathkey columns to compare */
1762
- } UpperUniquePath;
1763
-
1764
- /*
1765
- * AggPath represents generic computation of aggregate functions
1766
- *
1767
- * This may involve plain grouping (but not grouping sets), using either
1768
- * sorted or hashed grouping; for the AGG_SORTED case, the input must be
1769
- * appropriately presorted.
1770
- */
1771
- typedef struct AggPath
1772
- {
1773
- Path path;
1774
- Path *subpath; /* path representing input source */
1775
- AggStrategy aggstrategy; /* basic strategy, see nodes.h */
1776
- AggSplit aggsplit; /* agg-splitting mode, see nodes.h */
1777
- Cardinality numGroups; /* estimated number of groups in input */
1778
- uint64 transitionSpace; /* for pass-by-ref transition data */
1779
- List *groupClause; /* a list of SortGroupClause's */
1780
- List *qual; /* quals (HAVING quals), if any */
1781
- } AggPath;
1782
-
1783
- /*
1784
- * Various annotations used for grouping sets in the planner.
1785
- */
1786
-
1787
- typedef struct GroupingSetData
1788
- {
1789
- NodeTag type;
1790
- List *set; /* grouping set as list of sortgrouprefs */
1791
- Cardinality numGroups; /* est. number of result groups */
1792
- } GroupingSetData;
1793
-
1794
- typedef struct RollupData
1795
- {
1796
- NodeTag type;
1797
- List *groupClause; /* applicable subset of parse->groupClause */
1798
- List *gsets; /* lists of integer indexes into groupClause */
1799
- List *gsets_data; /* list of GroupingSetData */
1800
- Cardinality numGroups; /* est. number of result groups */
1801
- bool hashable; /* can be hashed */
1802
- bool is_hashed; /* to be implemented as a hashagg */
1803
- } RollupData;
1804
-
1805
- /*
1806
- * GroupingSetsPath represents a GROUPING SETS aggregation
1807
- */
1808
-
1809
- typedef struct GroupingSetsPath
1810
- {
1811
- Path path;
1812
- Path *subpath; /* path representing input source */
1813
- AggStrategy aggstrategy; /* basic strategy */
1814
- List *rollups; /* list of RollupData */
1815
- List *qual; /* quals (HAVING quals), if any */
1816
- uint64 transitionSpace; /* for pass-by-ref transition data */
1817
- } GroupingSetsPath;
1818
-
1819
- /*
1820
- * MinMaxAggPath represents computation of MIN/MAX aggregates from indexes
1821
- */
1822
- typedef struct MinMaxAggPath
1823
- {
1824
- Path path;
1825
- List *mmaggregates; /* list of MinMaxAggInfo */
1826
- List *quals; /* HAVING quals, if any */
1827
- } MinMaxAggPath;
1828
-
1829
- /*
1830
- * WindowAggPath represents generic computation of window functions
1831
- */
1832
- typedef struct WindowAggPath
1833
- {
1834
- Path path;
1835
- Path *subpath; /* path representing input source */
1836
- WindowClause *winclause; /* WindowClause we'll be using */
1837
- List *qual; /* lower-level WindowAgg runconditions */
1838
- bool topwindow; /* false for all apart from the WindowAgg
1839
- * that's closest to the root of the plan */
1840
- } WindowAggPath;
1841
-
1842
- /*
1843
- * SetOpPath represents a set-operation, that is INTERSECT or EXCEPT
1844
- */
1845
- typedef struct SetOpPath
1846
- {
1847
- Path path;
1848
- Path *subpath; /* path representing input source */
1849
- SetOpCmd cmd; /* what to do, see nodes.h */
1850
- SetOpStrategy strategy; /* how to do it, see nodes.h */
1851
- List *distinctList; /* SortGroupClauses identifying target cols */
1852
- AttrNumber flagColIdx; /* where is the flag column, if any */
1853
- int firstFlag; /* flag value for first input relation */
1854
- Cardinality numGroups; /* estimated number of groups in input */
1855
- } SetOpPath;
1856
-
1857
- /*
1858
- * RecursiveUnionPath represents a recursive UNION node
1859
- */
1860
- typedef struct RecursiveUnionPath
1861
- {
1862
- Path path;
1863
- Path *leftpath; /* paths representing input sources */
1864
- Path *rightpath;
1865
- List *distinctList; /* SortGroupClauses identifying target cols */
1866
- int wtParam; /* ID of Param representing work table */
1867
- Cardinality numGroups; /* estimated number of groups in input */
1868
- } RecursiveUnionPath;
1869
-
1870
- /*
1871
- * LockRowsPath represents acquiring row locks for SELECT FOR UPDATE/SHARE
1872
- */
1873
- typedef struct LockRowsPath
1874
- {
1875
- Path path;
1876
- Path *subpath; /* path representing input source */
1877
- List *rowMarks; /* a list of PlanRowMark's */
1878
- int epqParam; /* ID of Param for EvalPlanQual re-eval */
1879
- } LockRowsPath;
1880
-
1881
- /*
1882
- * ModifyTablePath represents performing INSERT/UPDATE/DELETE/MERGE
1883
- *
1884
- * We represent most things that will be in the ModifyTable plan node
1885
- * literally, except we have a child Path not Plan. But analysis of the
1886
- * OnConflictExpr is deferred to createplan.c, as is collection of FDW data.
1887
- */
1888
- typedef struct ModifyTablePath
1889
- {
1890
- Path path;
1891
- Path *subpath; /* Path producing source data */
1892
- CmdType operation; /* INSERT, UPDATE, DELETE, or MERGE */
1893
- bool canSetTag; /* do we set the command tag/es_processed? */
1894
- Index nominalRelation; /* Parent RT index for use of EXPLAIN */
1895
- Index rootRelation; /* Root RT index, if target is partitioned */
1896
- bool partColsUpdated; /* some part key in hierarchy updated? */
1897
- List *resultRelations; /* integer list of RT indexes */
1898
- List *updateColnosLists; /* per-target-table update_colnos lists */
1899
- List *withCheckOptionLists; /* per-target-table WCO lists */
1900
- List *returningLists; /* per-target-table RETURNING tlists */
1901
- List *rowMarks; /* PlanRowMarks (non-locking only) */
1902
- OnConflictExpr *onconflict; /* ON CONFLICT clause, or NULL */
1903
- int epqParam; /* ID of Param for EvalPlanQual re-eval */
1904
- List *mergeActionLists; /* per-target-table lists of actions for
1905
- * MERGE */
1906
- } ModifyTablePath;
1907
-
1908
- /*
1909
- * LimitPath represents applying LIMIT/OFFSET restrictions
1910
- */
1911
- typedef struct LimitPath
1912
- {
1913
- Path path;
1914
- Path *subpath; /* path representing input source */
1915
- Node *limitOffset; /* OFFSET parameter, or NULL if none */
1916
- Node *limitCount; /* COUNT parameter, or NULL if none */
1917
- LimitOption limitOption; /* FETCH FIRST with ties or exact number */
1918
- } LimitPath;
1919
-
1920
-
1921
- /*
1922
- * Restriction clause info.
1923
- *
1924
- * We create one of these for each AND sub-clause of a restriction condition
1925
- * (WHERE or JOIN/ON clause). Since the restriction clauses are logically
1926
- * ANDed, we can use any one of them or any subset of them to filter out
1927
- * tuples, without having to evaluate the rest. The RestrictInfo node itself
1928
- * stores data used by the optimizer while choosing the best query plan.
1929
- *
1930
- * If a restriction clause references a single base relation, it will appear
1931
- * in the baserestrictinfo list of the RelOptInfo for that base rel.
1932
- *
1933
- * If a restriction clause references more than one base rel, it will
1934
- * appear in the joininfo list of every RelOptInfo that describes a strict
1935
- * subset of the base rels mentioned in the clause. The joininfo lists are
1936
- * used to drive join tree building by selecting plausible join candidates.
1937
- * The clause cannot actually be applied until we have built a join rel
1938
- * containing all the base rels it references, however.
1939
- *
1940
- * When we construct a join rel that includes all the base rels referenced
1941
- * in a multi-relation restriction clause, we place that clause into the
1942
- * joinrestrictinfo lists of paths for the join rel, if neither left nor
1943
- * right sub-path includes all base rels referenced in the clause. The clause
1944
- * will be applied at that join level, and will not propagate any further up
1945
- * the join tree. (Note: the "predicate migration" code was once intended to
1946
- * push restriction clauses up and down the plan tree based on evaluation
1947
- * costs, but it's dead code and is unlikely to be resurrected in the
1948
- * foreseeable future.)
1949
- *
1950
- * Note that in the presence of more than two rels, a multi-rel restriction
1951
- * might reach different heights in the join tree depending on the join
1952
- * sequence we use. So, these clauses cannot be associated directly with
1953
- * the join RelOptInfo, but must be kept track of on a per-join-path basis.
1954
- *
1955
- * RestrictInfos that represent equivalence conditions (i.e., mergejoinable
1956
- * equalities that are not outerjoin-delayed) are handled a bit differently.
1957
- * Initially we attach them to the EquivalenceClasses that are derived from
1958
- * them. When we construct a scan or join path, we look through all the
1959
- * EquivalenceClasses and generate derived RestrictInfos representing the
1960
- * minimal set of conditions that need to be checked for this particular scan
1961
- * or join to enforce that all members of each EquivalenceClass are in fact
1962
- * equal in all rows emitted by the scan or join.
1963
- *
1964
- * When dealing with outer joins we have to be very careful about pushing qual
1965
- * clauses up and down the tree. An outer join's own JOIN/ON conditions must
1966
- * be evaluated exactly at that join node, unless they are "degenerate"
1967
- * conditions that reference only Vars from the nullable side of the join.
1968
- * Quals appearing in WHERE or in a JOIN above the outer join cannot be pushed
1969
- * down below the outer join, if they reference any nullable Vars.
1970
- * RestrictInfo nodes contain a flag to indicate whether a qual has been
1971
- * pushed down to a lower level than its original syntactic placement in the
1972
- * join tree would suggest. If an outer join prevents us from pushing a qual
1973
- * down to its "natural" semantic level (the level associated with just the
1974
- * base rels used in the qual) then we mark the qual with a "required_relids"
1975
- * value including more than just the base rels it actually uses. By
1976
- * pretending that the qual references all the rels required to form the outer
1977
- * join, we prevent it from being evaluated below the outer join's joinrel.
1978
- * When we do form the outer join's joinrel, we still need to distinguish
1979
- * those quals that are actually in that join's JOIN/ON condition from those
1980
- * that appeared elsewhere in the tree and were pushed down to the join rel
1981
- * because they used no other rels. That's what the is_pushed_down flag is
1982
- * for; it tells us that a qual is not an OUTER JOIN qual for the set of base
1983
- * rels listed in required_relids. A clause that originally came from WHERE
1984
- * or an INNER JOIN condition will *always* have its is_pushed_down flag set.
1985
- * It's possible for an OUTER JOIN clause to be marked is_pushed_down too,
1986
- * if we decide that it can be pushed down into the nullable side of the join.
1987
- * In that case it acts as a plain filter qual for wherever it gets evaluated.
1988
- * (In short, is_pushed_down is only false for non-degenerate outer join
1989
- * conditions. Possibly we should rename it to reflect that meaning? But
1990
- * see also the comments for RINFO_IS_PUSHED_DOWN, below.)
1991
- *
1992
- * RestrictInfo nodes also contain an outerjoin_delayed flag, which is true
1993
- * if the clause's applicability must be delayed due to any outer joins
1994
- * appearing below it (ie, it has to be postponed to some join level higher
1995
- * than the set of relations it actually references).
1996
- *
1997
- * There is also an outer_relids field, which is NULL except for outer join
1998
- * clauses; for those, it is the set of relids on the outer side of the
1999
- * clause's outer join. (These are rels that the clause cannot be applied to
2000
- * in parameterized scans, since pushing it into the join's outer side would
2001
- * lead to wrong answers.)
2002
- *
2003
- * There is also a nullable_relids field, which is the set of rels the clause
2004
- * references that can be forced null by some outer join below the clause.
2005
- *
2006
- * outerjoin_delayed = true is subtly different from nullable_relids != NULL:
2007
- * a clause might reference some nullable rels and yet not be
2008
- * outerjoin_delayed because it also references all the other rels of the
2009
- * outer join(s). A clause that is not outerjoin_delayed can be enforced
2010
- * anywhere it is computable.
2011
- *
2012
- * To handle security-barrier conditions efficiently, we mark RestrictInfo
2013
- * nodes with a security_level field, in which higher values identify clauses
2014
- * coming from less-trusted sources. The exact semantics are that a clause
2015
- * cannot be evaluated before another clause with a lower security_level value
2016
- * unless the first clause is leakproof. As with outer-join clauses, this
2017
- * creates a reason for clauses to sometimes need to be evaluated higher in
2018
- * the join tree than their contents would suggest; and even at a single plan
2019
- * node, this rule constrains the order of application of clauses.
2020
- *
2021
- * In general, the referenced clause might be arbitrarily complex. The
2022
- * kinds of clauses we can handle as indexscan quals, mergejoin clauses,
2023
- * or hashjoin clauses are limited (e.g., no volatile functions). The code
2024
- * for each kind of path is responsible for identifying the restrict clauses
2025
- * it can use and ignoring the rest. Clauses not implemented by an indexscan,
2026
- * mergejoin, or hashjoin will be placed in the plan qual or joinqual field
2027
- * of the finished Plan node, where they will be enforced by general-purpose
2028
- * qual-expression-evaluation code. (But we are still entitled to count
2029
- * their selectivity when estimating the result tuple count, if we
2030
- * can guess what it is...)
2031
- *
2032
- * When the referenced clause is an OR clause, we generate a modified copy
2033
- * in which additional RestrictInfo nodes are inserted below the top-level
2034
- * OR/AND structure. This is a convenience for OR indexscan processing:
2035
- * indexquals taken from either the top level or an OR subclause will have
2036
- * associated RestrictInfo nodes.
2037
- *
2038
- * The can_join flag is set true if the clause looks potentially useful as
2039
- * a merge or hash join clause, that is if it is a binary opclause with
2040
- * nonoverlapping sets of relids referenced in the left and right sides.
2041
- * (Whether the operator is actually merge or hash joinable isn't checked,
2042
- * however.)
2043
- *
2044
- * The pseudoconstant flag is set true if the clause contains no Vars of
2045
- * the current query level and no volatile functions. Such a clause can be
2046
- * pulled out and used as a one-time qual in a gating Result node. We keep
2047
- * pseudoconstant clauses in the same lists as other RestrictInfos so that
2048
- * the regular clause-pushing machinery can assign them to the correct join
2049
- * level, but they need to be treated specially for cost and selectivity
2050
- * estimates. Note that a pseudoconstant clause can never be an indexqual
2051
- * or merge or hash join clause, so it's of no interest to large parts of
2052
- * the planner.
2053
- *
2054
- * When join clauses are generated from EquivalenceClasses, there may be
2055
- * several equally valid ways to enforce join equivalence, of which we need
2056
- * apply only one. We mark clauses of this kind by setting parent_ec to
2057
- * point to the generating EquivalenceClass. Multiple clauses with the same
2058
- * parent_ec in the same join are redundant.
2059
- */
2060
-
2061
- typedef struct RestrictInfo
2062
- {
2063
- NodeTag type;
2064
-
2065
- Expr *clause; /* the represented clause of WHERE or JOIN */
2066
-
2067
- bool is_pushed_down; /* true if clause was pushed down in level */
2068
-
2069
- bool outerjoin_delayed; /* true if delayed by lower outer join */
2070
-
2071
- bool can_join; /* see comment above */
2072
-
2073
- bool pseudoconstant; /* see comment above */
2074
-
2075
- bool leakproof; /* true if known to contain no leaked Vars */
2076
-
2077
- VolatileFunctionStatus has_volatile; /* to indicate if clause contains
2078
- * any volatile functions. */
2079
-
2080
- Index security_level; /* see comment above */
2081
-
2082
- /* The set of relids (varnos) actually referenced in the clause: */
2083
- Relids clause_relids;
2084
-
2085
- /* The set of relids required to evaluate the clause: */
2086
- Relids required_relids;
2087
-
2088
- /* If an outer-join clause, the outer-side relations, else NULL: */
2089
- Relids outer_relids;
2090
-
2091
- /* The relids used in the clause that are nullable by lower outer joins: */
2092
- Relids nullable_relids;
2093
-
2094
- /* These fields are set for any binary opclause: */
2095
- Relids left_relids; /* relids in left side of clause */
2096
- Relids right_relids; /* relids in right side of clause */
2097
-
2098
- /* This field is NULL unless clause is an OR clause: */
2099
- Expr *orclause; /* modified clause with RestrictInfos */
2100
-
2101
- /* This field is NULL unless clause is potentially redundant: */
2102
- EquivalenceClass *parent_ec; /* generating EquivalenceClass */
2103
-
2104
- /* cache space for cost and selectivity */
2105
- QualCost eval_cost; /* eval cost of clause; -1 if not yet set */
2106
- Selectivity norm_selec; /* selectivity for "normal" (JOIN_INNER)
2107
- * semantics; -1 if not yet set; >1 means a
2108
- * redundant clause */
2109
- Selectivity outer_selec; /* selectivity for outer join semantics; -1 if
2110
- * not yet set */
2111
-
2112
- /* valid if clause is mergejoinable, else NIL */
2113
- List *mergeopfamilies; /* opfamilies containing clause operator */
2114
-
2115
- /* cache space for mergeclause processing; NULL if not yet set */
2116
- EquivalenceClass *left_ec; /* EquivalenceClass containing lefthand */
2117
- EquivalenceClass *right_ec; /* EquivalenceClass containing righthand */
2118
- EquivalenceMember *left_em; /* EquivalenceMember for lefthand */
2119
- EquivalenceMember *right_em; /* EquivalenceMember for righthand */
2120
- List *scansel_cache; /* list of MergeScanSelCache structs */
2121
-
2122
- /* transient workspace for use while considering a specific join path */
2123
- bool outer_is_left; /* T = outer var on left, F = on right */
2124
-
2125
- /* valid if clause is hashjoinable, else InvalidOid: */
2126
- Oid hashjoinoperator; /* copy of clause operator */
2127
-
2128
- /* cache space for hashclause processing; -1 if not yet set */
2129
- Selectivity left_bucketsize; /* avg bucketsize of left side */
2130
- Selectivity right_bucketsize; /* avg bucketsize of right side */
2131
- Selectivity left_mcvfreq; /* left side's most common val's freq */
2132
- Selectivity right_mcvfreq; /* right side's most common val's freq */
2133
-
2134
- /* hash equality operators used for memoize nodes, else InvalidOid */
2135
- Oid left_hasheqoperator;
2136
- Oid right_hasheqoperator;
2137
- } RestrictInfo;
2138
-
2139
- /*
2140
- * This macro embodies the correct way to test whether a RestrictInfo is
2141
- * "pushed down" to a given outer join, that is, should be treated as a filter
2142
- * clause rather than a join clause at that outer join. This is certainly so
2143
- * if is_pushed_down is true; but examining that is not sufficient anymore,
2144
- * because outer-join clauses will get pushed down to lower outer joins when
2145
- * we generate a path for the lower outer join that is parameterized by the
2146
- * LHS of the upper one. We can detect such a clause by noting that its
2147
- * required_relids exceed the scope of the join.
2148
- */
2149
- #define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids) \
2150
- ((rinfo)->is_pushed_down || \
2151
- !bms_is_subset((rinfo)->required_relids, joinrelids))
2152
-
2153
- /*
2154
- * Since mergejoinscansel() is a relatively expensive function, and would
2155
- * otherwise be invoked many times while planning a large join tree,
2156
- * we go out of our way to cache its results. Each mergejoinable
2157
- * RestrictInfo carries a list of the specific sort orderings that have
2158
- * been considered for use with it, and the resulting selectivities.
2159
- */
2160
- typedef struct MergeScanSelCache
2161
- {
2162
- /* Ordering details (cache lookup key) */
2163
- Oid opfamily; /* btree opfamily defining the ordering */
2164
- Oid collation; /* collation for the ordering */
2165
- int strategy; /* sort direction (ASC or DESC) */
2166
- bool nulls_first; /* do NULLs come before normal values? */
2167
- /* Results */
2168
- Selectivity leftstartsel; /* first-join fraction for clause left side */
2169
- Selectivity leftendsel; /* last-join fraction for clause left side */
2170
- Selectivity rightstartsel; /* first-join fraction for clause right side */
2171
- Selectivity rightendsel; /* last-join fraction for clause right side */
2172
- } MergeScanSelCache;
2173
-
2174
- /*
2175
- * Placeholder node for an expression to be evaluated below the top level
2176
- * of a plan tree. This is used during planning to represent the contained
2177
- * expression. At the end of the planning process it is replaced by either
2178
- * the contained expression or a Var referring to a lower-level evaluation of
2179
- * the contained expression. Typically the evaluation occurs below an outer
2180
- * join, and Var references above the outer join might thereby yield NULL
2181
- * instead of the expression value.
2182
- *
2183
- * Although the planner treats this as an expression node type, it is not
2184
- * recognized by the parser or executor, so we declare it here rather than
2185
- * in primnodes.h.
2186
- */
2187
-
2188
- typedef struct PlaceHolderVar
2189
- {
2190
- Expr xpr;
2191
- Expr *phexpr; /* the represented expression */
2192
- Relids phrels; /* base relids syntactically within expr src */
2193
- Index phid; /* ID for PHV (unique within planner run) */
2194
- Index phlevelsup; /* > 0 if PHV belongs to outer query */
2195
- } PlaceHolderVar;
2196
-
2197
- /*
2198
- * "Special join" info.
2199
- *
2200
- * One-sided outer joins constrain the order of joining partially but not
2201
- * completely. We flatten such joins into the planner's top-level list of
2202
- * relations to join, but record information about each outer join in a
2203
- * SpecialJoinInfo struct. These structs are kept in the PlannerInfo node's
2204
- * join_info_list.
2205
- *
2206
- * Similarly, semijoins and antijoins created by flattening IN (subselect)
2207
- * and EXISTS(subselect) clauses create partial constraints on join order.
2208
- * These are likewise recorded in SpecialJoinInfo structs.
2209
- *
2210
- * We make SpecialJoinInfos for FULL JOINs even though there is no flexibility
2211
- * of planning for them, because this simplifies make_join_rel()'s API.
2212
- *
2213
- * min_lefthand and min_righthand are the sets of base relids that must be
2214
- * available on each side when performing the special join. lhs_strict is
2215
- * true if the special join's condition cannot succeed when the LHS variables
2216
- * are all NULL (this means that an outer join can commute with upper-level
2217
- * outer joins even if it appears in their RHS). We don't bother to set
2218
- * lhs_strict for FULL JOINs, however.
2219
- *
2220
- * It is not valid for either min_lefthand or min_righthand to be empty sets;
2221
- * if they were, this would break the logic that enforces join order.
2222
- *
2223
- * syn_lefthand and syn_righthand are the sets of base relids that are
2224
- * syntactically below this special join. (These are needed to help compute
2225
- * min_lefthand and min_righthand for higher joins.)
2226
- *
2227
- * delay_upper_joins is set true if we detect a pushed-down clause that has
2228
- * to be evaluated after this join is formed (because it references the RHS).
2229
- * Any outer joins that have such a clause and this join in their RHS cannot
2230
- * commute with this join, because that would leave noplace to check the
2231
- * pushed-down clause. (We don't track this for FULL JOINs, either.)
2232
- *
2233
- * For a semijoin, we also extract the join operators and their RHS arguments
2234
- * and set semi_operators, semi_rhs_exprs, semi_can_btree, and semi_can_hash.
2235
- * This is done in support of possibly unique-ifying the RHS, so we don't
2236
- * bother unless at least one of semi_can_btree and semi_can_hash can be set
2237
- * true. (You might expect that this information would be computed during
2238
- * join planning; but it's helpful to have it available during planning of
2239
- * parameterized table scans, so we store it in the SpecialJoinInfo structs.)
2240
- *
2241
- * jointype is never JOIN_RIGHT; a RIGHT JOIN is handled by switching
2242
- * the inputs to make it a LEFT JOIN. So the allowed values of jointype
2243
- * in a join_info_list member are only LEFT, FULL, SEMI, or ANTI.
2244
- *
2245
- * For purposes of join selectivity estimation, we create transient
2246
- * SpecialJoinInfo structures for regular inner joins; so it is possible
2247
- * to have jointype == JOIN_INNER in such a structure, even though this is
2248
- * not allowed within join_info_list. We also create transient
2249
- * SpecialJoinInfos with jointype == JOIN_INNER for outer joins, since for
2250
- * cost estimation purposes it is sometimes useful to know the join size under
2251
- * plain innerjoin semantics. Note that lhs_strict, delay_upper_joins, and
2252
- * of course the semi_xxx fields are not set meaningfully within such structs.
2253
- */
2254
- #ifndef HAVE_SPECIALJOININFO_TYPEDEF
2255
- typedef struct SpecialJoinInfo SpecialJoinInfo;
2256
- #define HAVE_SPECIALJOININFO_TYPEDEF 1
2257
- #endif
2258
-
2259
- struct SpecialJoinInfo
2260
- {
2261
- NodeTag type;
2262
- Relids min_lefthand; /* base relids in minimum LHS for join */
2263
- Relids min_righthand; /* base relids in minimum RHS for join */
2264
- Relids syn_lefthand; /* base relids syntactically within LHS */
2265
- Relids syn_righthand; /* base relids syntactically within RHS */
2266
- JoinType jointype; /* always INNER, LEFT, FULL, SEMI, or ANTI */
2267
- bool lhs_strict; /* joinclause is strict for some LHS rel */
2268
- bool delay_upper_joins; /* can't commute with upper RHS */
2269
- /* Remaining fields are set only for JOIN_SEMI jointype: */
2270
- bool semi_can_btree; /* true if semi_operators are all btree */
2271
- bool semi_can_hash; /* true if semi_operators are all hash */
2272
- List *semi_operators; /* OIDs of equality join operators */
2273
- List *semi_rhs_exprs; /* righthand-side expressions of these ops */
2274
- };
2275
-
2276
- /*
2277
- * Append-relation info.
2278
- *
2279
- * When we expand an inheritable table or a UNION-ALL subselect into an
2280
- * "append relation" (essentially, a list of child RTEs), we build an
2281
- * AppendRelInfo for each child RTE. The list of AppendRelInfos indicates
2282
- * which child RTEs must be included when expanding the parent, and each node
2283
- * carries information needed to translate between columns of the parent and
2284
- * columns of the child.
2285
- *
2286
- * These structs are kept in the PlannerInfo node's append_rel_list, with
2287
- * append_rel_array[] providing a convenient lookup method for the struct
2288
- * associated with a particular child relid (there can be only one, though
2289
- * parent rels may have many entries in append_rel_list).
2290
- *
2291
- * Note: after completion of the planner prep phase, any given RTE is an
2292
- * append parent having entries in append_rel_list if and only if its
2293
- * "inh" flag is set. We clear "inh" for plain tables that turn out not
2294
- * to have inheritance children, and (in an abuse of the original meaning
2295
- * of the flag) we set "inh" for subquery RTEs that turn out to be
2296
- * flattenable UNION ALL queries. This lets us avoid useless searches
2297
- * of append_rel_list.
2298
- *
2299
- * Note: the data structure assumes that append-rel members are single
2300
- * baserels. This is OK for inheritance, but it prevents us from pulling
2301
- * up a UNION ALL member subquery if it contains a join. While that could
2302
- * be fixed with a more complex data structure, at present there's not much
2303
- * point because no improvement in the plan could result.
2304
- */
2305
-
2306
- typedef struct AppendRelInfo
2307
- {
2308
- NodeTag type;
2309
-
2310
- /*
2311
- * These fields uniquely identify this append relationship. There can be
2312
- * (in fact, always should be) multiple AppendRelInfos for the same
2313
- * parent_relid, but never more than one per child_relid, since a given
2314
- * RTE cannot be a child of more than one append parent.
2315
- */
2316
- Index parent_relid; /* RT index of append parent rel */
2317
- Index child_relid; /* RT index of append child rel */
2318
-
2319
- /*
2320
- * For an inheritance appendrel, the parent and child are both regular
2321
- * relations, and we store their rowtype OIDs here for use in translating
2322
- * whole-row Vars. For a UNION-ALL appendrel, the parent and child are
2323
- * both subqueries with no named rowtype, and we store InvalidOid here.
2324
- */
2325
- Oid parent_reltype; /* OID of parent's composite type */
2326
- Oid child_reltype; /* OID of child's composite type */
2327
-
2328
- /*
2329
- * The N'th element of this list is a Var or expression representing the
2330
- * child column corresponding to the N'th column of the parent. This is
2331
- * used to translate Vars referencing the parent rel into references to
2332
- * the child. A list element is NULL if it corresponds to a dropped
2333
- * column of the parent (this is only possible for inheritance cases, not
2334
- * UNION ALL). The list elements are always simple Vars for inheritance
2335
- * cases, but can be arbitrary expressions in UNION ALL cases.
2336
- *
2337
- * Notice we only store entries for user columns (attno > 0). Whole-row
2338
- * Vars are special-cased, and system columns (attno < 0) need no special
2339
- * translation since their attnos are the same for all tables.
2340
- *
2341
- * Caution: the Vars have varlevelsup = 0. Be careful to adjust as needed
2342
- * when copying into a subquery.
2343
- */
2344
- List *translated_vars; /* Expressions in the child's Vars */
2345
-
2346
- /*
2347
- * This array simplifies translations in the reverse direction, from
2348
- * child's column numbers to parent's. The entry at [ccolno - 1] is the
2349
- * 1-based parent column number for child column ccolno, or zero if that
2350
- * child column is dropped or doesn't exist in the parent.
2351
- */
2352
- int num_child_cols; /* length of array */
2353
- AttrNumber *parent_colnos; /* array of parent attnos, or zeroes */
2354
-
2355
- /*
2356
- * We store the parent table's OID here for inheritance, or InvalidOid for
2357
- * UNION ALL. This is only needed to help in generating error messages if
2358
- * an attempt is made to reference a dropped parent column.
2359
- */
2360
- Oid parent_reloid; /* OID of parent relation */
2361
- } AppendRelInfo;
2362
-
2363
- /*
2364
- * Information about a row-identity "resjunk" column in UPDATE/DELETE/MERGE.
2365
- *
2366
- * In partitioned UPDATE/DELETE/MERGE it's important for child partitions to
2367
- * share row-identity columns whenever possible, so as not to chew up too many
2368
- * targetlist columns. We use these structs to track which identity columns
2369
- * have been requested. In the finished plan, each of these will give rise
2370
- * to one resjunk entry in the targetlist of the ModifyTable's subplan node.
2371
- *
2372
- * All the Vars stored in RowIdentityVarInfos must have varno ROWID_VAR, for
2373
- * convenience of detecting duplicate requests. We'll replace that, in the
2374
- * final plan, with the varno of the generating rel.
2375
- *
2376
- * Outside this list, a Var with varno ROWID_VAR and varattno k is a reference
2377
- * to the k-th element of the row_identity_vars list (k counting from 1).
2378
- * We add such a reference to root->processed_tlist when creating the entry,
2379
- * and it propagates into the plan tree from there.
2380
- */
2381
- typedef struct RowIdentityVarInfo
2382
- {
2383
- NodeTag type;
2384
-
2385
- Var *rowidvar; /* Var to be evaluated (but varno=ROWID_VAR) */
2386
- int32 rowidwidth; /* estimated average width */
2387
- char *rowidname; /* name of the resjunk column */
2388
- Relids rowidrels; /* RTE indexes of target rels using this */
2389
- } RowIdentityVarInfo;
2390
-
2391
- /*
2392
- * For each distinct placeholder expression generated during planning, we
2393
- * store a PlaceHolderInfo node in the PlannerInfo node's placeholder_list.
2394
- * This stores info that is needed centrally rather than in each copy of the
2395
- * PlaceHolderVar. The phid fields identify which PlaceHolderInfo goes with
2396
- * each PlaceHolderVar. Note that phid is unique throughout a planner run,
2397
- * not just within a query level --- this is so that we need not reassign ID's
2398
- * when pulling a subquery into its parent.
2399
- *
2400
- * The idea is to evaluate the expression at (only) the ph_eval_at join level,
2401
- * then allow it to bubble up like a Var until the ph_needed join level.
2402
- * ph_needed has the same definition as attr_needed for a regular Var.
2403
- *
2404
- * The PlaceHolderVar's expression might contain LATERAL references to vars
2405
- * coming from outside its syntactic scope. If so, those rels are *not*
2406
- * included in ph_eval_at, but they are recorded in ph_lateral.
2407
- *
2408
- * Notice that when ph_eval_at is a join rather than a single baserel, the
2409
- * PlaceHolderInfo may create constraints on join order: the ph_eval_at join
2410
- * has to be formed below any outer joins that should null the PlaceHolderVar.
2411
- *
2412
- * We create a PlaceHolderInfo only after determining that the PlaceHolderVar
2413
- * is actually referenced in the plan tree, so that unreferenced placeholders
2414
- * don't result in unnecessary constraints on join order.
2415
- */
2416
-
2417
- typedef struct PlaceHolderInfo
2418
- {
2419
- NodeTag type;
2420
-
2421
- Index phid; /* ID for PH (unique within planner run) */
2422
- PlaceHolderVar *ph_var; /* copy of PlaceHolderVar tree */
2423
- Relids ph_eval_at; /* lowest level we can evaluate value at */
2424
- Relids ph_lateral; /* relids of contained lateral refs, if any */
2425
- Relids ph_needed; /* highest level the value is needed at */
2426
- int32 ph_width; /* estimated attribute width */
2427
- } PlaceHolderInfo;
2428
-
2429
- /*
2430
- * This struct describes one potentially index-optimizable MIN/MAX aggregate
2431
- * function. MinMaxAggPath contains a list of these, and if we accept that
2432
- * path, the list is stored into root->minmax_aggs for use during setrefs.c.
2433
- */
2434
- typedef struct MinMaxAggInfo
2435
- {
2436
- NodeTag type;
2437
-
2438
- Oid aggfnoid; /* pg_proc Oid of the aggregate */
2439
- Oid aggsortop; /* Oid of its sort operator */
2440
- Expr *target; /* expression we are aggregating on */
2441
- PlannerInfo *subroot; /* modified "root" for planning the subquery */
2442
- Path *path; /* access path for subquery */
2443
- Cost pathcost; /* estimated cost to fetch first row */
2444
- Param *param; /* param for subplan's output */
2445
- } MinMaxAggInfo;
2446
-
2447
- /*
2448
- * At runtime, PARAM_EXEC slots are used to pass values around from one plan
2449
- * node to another. They can be used to pass values down into subqueries (for
2450
- * outer references in subqueries), or up out of subqueries (for the results
2451
- * of a subplan), or from a NestLoop plan node into its inner relation (when
2452
- * the inner scan is parameterized with values from the outer relation).
2453
- * The planner is responsible for assigning nonconflicting PARAM_EXEC IDs to
2454
- * the PARAM_EXEC Params it generates.
2455
- *
2456
- * Outer references are managed via root->plan_params, which is a list of
2457
- * PlannerParamItems. While planning a subquery, each parent query level's
2458
- * plan_params contains the values required from it by the current subquery.
2459
- * During create_plan(), we use plan_params to track values that must be
2460
- * passed from outer to inner sides of NestLoop plan nodes.
2461
- *
2462
- * The item a PlannerParamItem represents can be one of three kinds:
2463
- *
2464
- * A Var: the slot represents a variable of this level that must be passed
2465
- * down because subqueries have outer references to it, or must be passed
2466
- * from a NestLoop node to its inner scan. The varlevelsup value in the Var
2467
- * will always be zero.
2468
- *
2469
- * A PlaceHolderVar: this works much like the Var case, except that the
2470
- * entry is a PlaceHolderVar node with a contained expression. The PHV
2471
- * will have phlevelsup = 0, and the contained expression is adjusted
2472
- * to match in level.
2473
- *
2474
- * An Aggref (with an expression tree representing its argument): the slot
2475
- * represents an aggregate expression that is an outer reference for some
2476
- * subquery. The Aggref itself has agglevelsup = 0, and its argument tree
2477
- * is adjusted to match in level.
2478
- *
2479
- * Note: we detect duplicate Var and PlaceHolderVar parameters and coalesce
2480
- * them into one slot, but we do not bother to do that for Aggrefs.
2481
- * The scope of duplicate-elimination only extends across the set of
2482
- * parameters passed from one query level into a single subquery, or for
2483
- * nestloop parameters across the set of nestloop parameters used in a single
2484
- * query level. So there is no possibility of a PARAM_EXEC slot being used
2485
- * for conflicting purposes.
2486
- *
2487
- * In addition, PARAM_EXEC slots are assigned for Params representing outputs
2488
- * from subplans (values that are setParam items for those subplans). These
2489
- * IDs need not be tracked via PlannerParamItems, since we do not need any
2490
- * duplicate-elimination nor later processing of the represented expressions.
2491
- * Instead, we just record the assignment of the slot number by appending to
2492
- * root->glob->paramExecTypes.
2493
- */
2494
- typedef struct PlannerParamItem
2495
- {
2496
- NodeTag type;
2497
-
2498
- Node *item; /* the Var, PlaceHolderVar, or Aggref */
2499
- int paramId; /* its assigned PARAM_EXEC slot number */
2500
- } PlannerParamItem;
2501
-
2502
- /*
2503
- * When making cost estimates for a SEMI/ANTI/inner_unique join, there are
2504
- * some correction factors that are needed in both nestloop and hash joins
2505
- * to account for the fact that the executor can stop scanning inner rows
2506
- * as soon as it finds a match to the current outer row. These numbers
2507
- * depend only on the selected outer and inner join relations, not on the
2508
- * particular paths used for them, so it's worthwhile to calculate them
2509
- * just once per relation pair not once per considered path. This struct
2510
- * is filled by compute_semi_anti_join_factors and must be passed along
2511
- * to the join cost estimation functions.
2512
- *
2513
- * outer_match_frac is the fraction of the outer tuples that are
2514
- * expected to have at least one match.
2515
- * match_count is the average number of matches expected for
2516
- * outer tuples that have at least one match.
2517
- */
2518
- typedef struct SemiAntiJoinFactors
2519
- {
2520
- Selectivity outer_match_frac;
2521
- Selectivity match_count;
2522
- } SemiAntiJoinFactors;
2523
-
2524
- /*
2525
- * Struct for extra information passed to subroutines of add_paths_to_joinrel
2526
- *
2527
- * restrictlist contains all of the RestrictInfo nodes for restriction
2528
- * clauses that apply to this join
2529
- * mergeclause_list is a list of RestrictInfo nodes for available
2530
- * mergejoin clauses in this join
2531
- * inner_unique is true if each outer tuple provably matches no more
2532
- * than one inner tuple
2533
- * sjinfo is extra info about special joins for selectivity estimation
2534
- * semifactors is as shown above (only valid for SEMI/ANTI/inner_unique joins)
2535
- * param_source_rels are OK targets for parameterization of result paths
2536
- */
2537
- typedef struct JoinPathExtraData
2538
- {
2539
- List *restrictlist;
2540
- List *mergeclause_list;
2541
- bool inner_unique;
2542
- SpecialJoinInfo *sjinfo;
2543
- SemiAntiJoinFactors semifactors;
2544
- Relids param_source_rels;
2545
- } JoinPathExtraData;
2546
-
2547
- /*
2548
- * Various flags indicating what kinds of grouping are possible.
2549
- *
2550
- * GROUPING_CAN_USE_SORT should be set if it's possible to perform
2551
- * sort-based implementations of grouping. When grouping sets are in use,
2552
- * this will be true if sorting is potentially usable for any of the grouping
2553
- * sets, even if it's not usable for all of them.
2554
- *
2555
- * GROUPING_CAN_USE_HASH should be set if it's possible to perform
2556
- * hash-based implementations of grouping.
2557
- *
2558
- * GROUPING_CAN_PARTIAL_AGG should be set if the aggregation is of a type
2559
- * for which we support partial aggregation (not, for example, grouping sets).
2560
- * It says nothing about parallel-safety or the availability of suitable paths.
2561
- */
2562
- #define GROUPING_CAN_USE_SORT 0x0001
2563
- #define GROUPING_CAN_USE_HASH 0x0002
2564
- #define GROUPING_CAN_PARTIAL_AGG 0x0004
2565
-
2566
- /*
2567
- * What kind of partitionwise aggregation is in use?
2568
- *
2569
- * PARTITIONWISE_AGGREGATE_NONE: Not used.
2570
- *
2571
- * PARTITIONWISE_AGGREGATE_FULL: Aggregate each partition separately, and
2572
- * append the results.
2573
- *
2574
- * PARTITIONWISE_AGGREGATE_PARTIAL: Partially aggregate each partition
2575
- * separately, append the results, and then finalize aggregation.
2576
- */
2577
- typedef enum
2578
- {
2579
- PARTITIONWISE_AGGREGATE_NONE,
2580
- PARTITIONWISE_AGGREGATE_FULL,
2581
- PARTITIONWISE_AGGREGATE_PARTIAL
2582
- } PartitionwiseAggregateType;
2583
-
2584
- /*
2585
- * Struct for extra information passed to subroutines of create_grouping_paths
2586
- *
2587
- * flags indicating what kinds of grouping are possible.
2588
- * partial_costs_set is true if the agg_partial_costs and agg_final_costs
2589
- * have been initialized.
2590
- * agg_partial_costs gives partial aggregation costs.
2591
- * agg_final_costs gives finalization costs.
2592
- * target_parallel_safe is true if target is parallel safe.
2593
- * havingQual gives list of quals to be applied after aggregation.
2594
- * targetList gives list of columns to be projected.
2595
- * patype is the type of partitionwise aggregation that is being performed.
2596
- */
2597
- typedef struct
2598
- {
2599
- /* Data which remains constant once set. */
2600
- int flags;
2601
- bool partial_costs_set;
2602
- AggClauseCosts agg_partial_costs;
2603
- AggClauseCosts agg_final_costs;
2604
-
2605
- /* Data which may differ across partitions. */
2606
- bool target_parallel_safe;
2607
- Node *havingQual;
2608
- List *targetList;
2609
- PartitionwiseAggregateType patype;
2610
- } GroupPathExtraData;
2611
-
2612
- /*
2613
- * Struct for extra information passed to subroutines of grouping_planner
2614
- *
2615
- * limit_needed is true if we actually need a Limit plan node.
2616
- * limit_tuples is an estimated bound on the number of output tuples,
2617
- * or -1 if no LIMIT or couldn't estimate.
2618
- * count_est and offset_est are the estimated values of the LIMIT and OFFSET
2619
- * expressions computed by preprocess_limit() (see comments for
2620
- * preprocess_limit() for more information).
2621
- */
2622
- typedef struct
2623
- {
2624
- bool limit_needed;
2625
- Cardinality limit_tuples;
2626
- int64 count_est;
2627
- int64 offset_est;
2628
- } FinalPathExtraData;
2629
-
2630
- /*
2631
- * For speed reasons, cost estimation for join paths is performed in two
2632
- * phases: the first phase tries to quickly derive a lower bound for the
2633
- * join cost, and then we check if that's sufficient to reject the path.
2634
- * If not, we come back for a more refined cost estimate. The first phase
2635
- * fills a JoinCostWorkspace struct with its preliminary cost estimates
2636
- * and possibly additional intermediate values. The second phase takes
2637
- * these values as inputs to avoid repeating work.
2638
- *
2639
- * (Ideally we'd declare this in cost.h, but it's also needed in pathnode.h,
2640
- * so seems best to put it here.)
2641
- */
2642
- typedef struct JoinCostWorkspace
2643
- {
2644
- /* Preliminary cost estimates --- must not be larger than final ones! */
2645
- Cost startup_cost; /* cost expended before fetching any tuples */
2646
- Cost total_cost; /* total cost (assuming all tuples fetched) */
2647
-
2648
- /* Fields below here should be treated as private to costsize.c */
2649
- Cost run_cost; /* non-startup cost components */
2650
-
2651
- /* private for cost_nestloop code */
2652
- Cost inner_run_cost; /* also used by cost_mergejoin code */
2653
- Cost inner_rescan_run_cost;
2654
-
2655
- /* private for cost_mergejoin code */
2656
- Cardinality outer_rows;
2657
- Cardinality inner_rows;
2658
- Cardinality outer_skip_rows;
2659
- Cardinality inner_skip_rows;
2660
-
2661
- /* private for cost_hashjoin code */
2662
- int numbuckets;
2663
- int numbatches;
2664
- Cardinality inner_rows_total;
2665
- } JoinCostWorkspace;
2666
-
2667
- /*
2668
- * AggInfo holds information about an aggregate that needs to be computed.
2669
- * Multiple Aggrefs in a query can refer to the same AggInfo by having the
2670
- * same 'aggno' value, so that the aggregate is computed only once.
2671
- */
2672
- typedef struct AggInfo
2673
- {
2674
- /*
2675
- * Link to an Aggref expr this state value is for.
2676
- *
2677
- * There can be multiple identical Aggref's sharing the same per-agg. This
2678
- * points to the first one of them.
2679
- */
2680
- Aggref *representative_aggref;
2681
-
2682
- int transno;
2683
-
2684
- /*
2685
- * "shareable" is false if this agg cannot share state values with other
2686
- * aggregates because the final function is read-write.
2687
- */
2688
- bool shareable;
2689
-
2690
- /* Oid of the final function or InvalidOid */
2691
- Oid finalfn_oid;
2692
-
2693
- } AggInfo;
2694
-
2695
- /*
2696
- * AggTransInfo holds information about transition state that is used by one
2697
- * or more aggregates in the query. Multiple aggregates can share the same
2698
- * transition state, if they have the same inputs and the same transition
2699
- * function. Aggrefs that share the same transition info have the same
2700
- * 'aggtransno' value.
2701
- */
2702
- typedef struct AggTransInfo
2703
- {
2704
- List *args;
2705
- Expr *aggfilter;
2706
-
2707
- /* Oid of the state transition function */
2708
- Oid transfn_oid;
2709
-
2710
- /* Oid of the serialization function or InvalidOid */
2711
- Oid serialfn_oid;
2712
-
2713
- /* Oid of the deserialization function or InvalidOid */
2714
- Oid deserialfn_oid;
2715
-
2716
- /* Oid of the combine function or InvalidOid */
2717
- Oid combinefn_oid;
2718
-
2719
- /* Oid of state value's datatype */
2720
- Oid aggtranstype;
2721
- int32 aggtranstypmod;
2722
- int transtypeLen;
2723
- bool transtypeByVal;
2724
- int32 aggtransspace;
2725
-
2726
- /*
2727
- * initial value from pg_aggregate entry
2728
- */
2729
- Datum initValue;
2730
- bool initValueIsNull;
2731
-
2732
- } AggTransInfo;
2733
-
2734
- #endif /* PATHNODES_H */