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