pg_query 2.2.0 → 6.1.0

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