pg_query 2.2.0 → 6.1.0

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