pg_query 1.1.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +163 -52
- data/README.md +80 -69
- data/Rakefile +82 -1
- data/ext/pg_query/extconf.rb +3 -31
- data/ext/pg_query/guc-file.c +0 -0
- data/ext/pg_query/include/access/amapi.h +246 -0
- data/ext/pg_query/include/access/attmap.h +52 -0
- data/ext/pg_query/include/access/attnum.h +64 -0
- data/ext/pg_query/include/access/clog.h +61 -0
- data/ext/pg_query/include/access/commit_ts.h +77 -0
- data/ext/pg_query/include/access/detoast.h +92 -0
- data/ext/pg_query/include/access/genam.h +228 -0
- data/ext/pg_query/include/access/gin.h +78 -0
- data/ext/pg_query/include/access/htup.h +89 -0
- data/ext/pg_query/include/access/htup_details.h +819 -0
- data/ext/pg_query/include/access/itup.h +161 -0
- data/ext/pg_query/include/access/parallel.h +82 -0
- data/ext/pg_query/include/access/printtup.h +35 -0
- data/ext/pg_query/include/access/relation.h +28 -0
- data/ext/pg_query/include/access/relscan.h +176 -0
- data/ext/pg_query/include/access/rmgr.h +35 -0
- data/ext/pg_query/include/access/rmgrlist.h +49 -0
- data/ext/pg_query/include/access/sdir.h +58 -0
- data/ext/pg_query/include/access/skey.h +151 -0
- data/ext/pg_query/include/access/stratnum.h +83 -0
- data/ext/pg_query/include/access/sysattr.h +29 -0
- data/ext/pg_query/include/access/table.h +27 -0
- data/ext/pg_query/include/access/tableam.h +1825 -0
- data/ext/pg_query/include/access/transam.h +265 -0
- data/ext/pg_query/include/access/tupconvert.h +51 -0
- data/ext/pg_query/include/access/tupdesc.h +154 -0
- data/ext/pg_query/include/access/tupmacs.h +247 -0
- data/ext/pg_query/include/access/twophase.h +61 -0
- data/ext/pg_query/include/access/xact.h +463 -0
- data/ext/pg_query/include/access/xlog.h +398 -0
- data/ext/pg_query/include/access/xlog_internal.h +330 -0
- data/ext/pg_query/include/access/xlogdefs.h +109 -0
- data/ext/pg_query/include/access/xloginsert.h +64 -0
- data/ext/pg_query/include/access/xlogreader.h +327 -0
- data/ext/pg_query/include/access/xlogrecord.h +227 -0
- data/ext/pg_query/include/bootstrap/bootstrap.h +62 -0
- data/ext/pg_query/include/c.h +1322 -0
- data/ext/pg_query/include/catalog/catalog.h +42 -0
- data/ext/pg_query/include/catalog/catversion.h +58 -0
- data/ext/pg_query/include/catalog/dependency.h +275 -0
- data/ext/pg_query/include/catalog/genbki.h +64 -0
- data/ext/pg_query/include/catalog/index.h +199 -0
- data/ext/pg_query/include/catalog/indexing.h +366 -0
- data/ext/pg_query/include/catalog/namespace.h +188 -0
- data/ext/pg_query/include/catalog/objectaccess.h +197 -0
- data/ext/pg_query/include/catalog/objectaddress.h +84 -0
- data/ext/pg_query/include/catalog/pg_aggregate.h +176 -0
- data/ext/pg_query/include/catalog/pg_aggregate_d.h +77 -0
- data/ext/pg_query/include/catalog/pg_am.h +60 -0
- data/ext/pg_query/include/catalog/pg_am_d.h +45 -0
- data/ext/pg_query/include/catalog/pg_attribute.h +204 -0
- data/ext/pg_query/include/catalog/pg_attribute_d.h +59 -0
- data/ext/pg_query/include/catalog/pg_authid.h +58 -0
- data/ext/pg_query/include/catalog/pg_authid_d.h +49 -0
- data/ext/pg_query/include/catalog/pg_class.h +200 -0
- data/ext/pg_query/include/catalog/pg_class_d.h +103 -0
- data/ext/pg_query/include/catalog/pg_collation.h +73 -0
- data/ext/pg_query/include/catalog/pg_collation_d.h +45 -0
- data/ext/pg_query/include/catalog/pg_constraint.h +247 -0
- data/ext/pg_query/include/catalog/pg_constraint_d.h +67 -0
- data/ext/pg_query/include/catalog/pg_control.h +250 -0
- data/ext/pg_query/include/catalog/pg_conversion.h +72 -0
- data/ext/pg_query/include/catalog/pg_conversion_d.h +35 -0
- data/ext/pg_query/include/catalog/pg_depend.h +73 -0
- data/ext/pg_query/include/catalog/pg_depend_d.h +34 -0
- data/ext/pg_query/include/catalog/pg_event_trigger.h +51 -0
- data/ext/pg_query/include/catalog/pg_event_trigger_d.h +34 -0
- data/ext/pg_query/include/catalog/pg_index.h +80 -0
- data/ext/pg_query/include/catalog/pg_index_d.h +56 -0
- data/ext/pg_query/include/catalog/pg_language.h +67 -0
- data/ext/pg_query/include/catalog/pg_language_d.h +39 -0
- data/ext/pg_query/include/catalog/pg_namespace.h +59 -0
- data/ext/pg_query/include/catalog/pg_namespace_d.h +34 -0
- data/ext/pg_query/include/catalog/pg_opclass.h +85 -0
- data/ext/pg_query/include/catalog/pg_opclass_d.h +49 -0
- data/ext/pg_query/include/catalog/pg_operator.h +102 -0
- data/ext/pg_query/include/catalog/pg_operator_d.h +106 -0
- data/ext/pg_query/include/catalog/pg_opfamily.h +60 -0
- data/ext/pg_query/include/catalog/pg_opfamily_d.h +47 -0
- data/ext/pg_query/include/catalog/pg_partitioned_table.h +63 -0
- data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +35 -0
- data/ext/pg_query/include/catalog/pg_proc.h +211 -0
- data/ext/pg_query/include/catalog/pg_proc_d.h +99 -0
- data/ext/pg_query/include/catalog/pg_publication.h +115 -0
- data/ext/pg_query/include/catalog/pg_publication_d.h +36 -0
- data/ext/pg_query/include/catalog/pg_replication_origin.h +57 -0
- data/ext/pg_query/include/catalog/pg_replication_origin_d.h +29 -0
- data/ext/pg_query/include/catalog/pg_statistic.h +275 -0
- data/ext/pg_query/include/catalog/pg_statistic_d.h +194 -0
- data/ext/pg_query/include/catalog/pg_statistic_ext.h +74 -0
- data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +40 -0
- data/ext/pg_query/include/catalog/pg_transform.h +45 -0
- data/ext/pg_query/include/catalog/pg_transform_d.h +32 -0
- data/ext/pg_query/include/catalog/pg_trigger.h +137 -0
- data/ext/pg_query/include/catalog/pg_trigger_d.h +106 -0
- data/ext/pg_query/include/catalog/pg_ts_config.h +50 -0
- data/ext/pg_query/include/catalog/pg_ts_config_d.h +32 -0
- data/ext/pg_query/include/catalog/pg_ts_dict.h +54 -0
- data/ext/pg_query/include/catalog/pg_ts_dict_d.h +33 -0
- data/ext/pg_query/include/catalog/pg_ts_parser.h +57 -0
- data/ext/pg_query/include/catalog/pg_ts_parser_d.h +35 -0
- data/ext/pg_query/include/catalog/pg_ts_template.h +48 -0
- data/ext/pg_query/include/catalog/pg_ts_template_d.h +32 -0
- data/ext/pg_query/include/catalog/pg_type.h +372 -0
- data/ext/pg_query/include/catalog/pg_type_d.h +285 -0
- data/ext/pg_query/include/catalog/storage.h +48 -0
- data/ext/pg_query/include/commands/async.h +54 -0
- data/ext/pg_query/include/commands/dbcommands.h +35 -0
- data/ext/pg_query/include/commands/defrem.h +173 -0
- data/ext/pg_query/include/commands/event_trigger.h +88 -0
- data/ext/pg_query/include/commands/explain.h +127 -0
- data/ext/pg_query/include/commands/prepare.h +61 -0
- data/ext/pg_query/include/commands/tablespace.h +67 -0
- data/ext/pg_query/include/commands/trigger.h +277 -0
- data/ext/pg_query/include/commands/user.h +37 -0
- data/ext/pg_query/include/commands/vacuum.h +293 -0
- data/ext/pg_query/include/commands/variable.h +38 -0
- data/ext/pg_query/include/common/file_perm.h +56 -0
- data/ext/pg_query/include/common/hashfn.h +104 -0
- data/ext/pg_query/include/common/ip.h +37 -0
- data/ext/pg_query/include/common/keywords.h +33 -0
- data/ext/pg_query/include/common/kwlookup.h +44 -0
- data/ext/pg_query/include/common/relpath.h +90 -0
- data/ext/pg_query/include/common/string.h +19 -0
- data/ext/pg_query/include/common/unicode_combining_table.h +196 -0
- data/ext/pg_query/include/datatype/timestamp.h +197 -0
- data/ext/pg_query/include/executor/execdesc.h +70 -0
- data/ext/pg_query/include/executor/executor.h +614 -0
- data/ext/pg_query/include/executor/functions.h +41 -0
- data/ext/pg_query/include/executor/instrument.h +101 -0
- data/ext/pg_query/include/executor/spi.h +175 -0
- data/ext/pg_query/include/executor/tablefunc.h +67 -0
- data/ext/pg_query/include/executor/tuptable.h +487 -0
- data/ext/pg_query/include/fmgr.h +775 -0
- data/ext/pg_query/include/funcapi.h +348 -0
- data/ext/pg_query/include/getaddrinfo.h +162 -0
- data/ext/pg_query/include/jit/jit.h +105 -0
- data/ext/pg_query/include/kwlist_d.h +1072 -0
- data/ext/pg_query/include/lib/ilist.h +727 -0
- data/ext/pg_query/include/lib/pairingheap.h +102 -0
- data/ext/pg_query/include/lib/simplehash.h +1059 -0
- data/ext/pg_query/include/lib/stringinfo.h +161 -0
- data/ext/pg_query/include/libpq/auth.h +29 -0
- data/ext/pg_query/include/libpq/crypt.h +46 -0
- data/ext/pg_query/include/libpq/hba.h +140 -0
- data/ext/pg_query/include/libpq/libpq-be.h +326 -0
- data/ext/pg_query/include/libpq/libpq.h +133 -0
- data/ext/pg_query/include/libpq/pqcomm.h +208 -0
- data/ext/pg_query/include/libpq/pqformat.h +210 -0
- data/ext/pg_query/include/libpq/pqsignal.h +42 -0
- data/ext/pg_query/include/mb/pg_wchar.h +672 -0
- data/ext/pg_query/include/mb/stringinfo_mb.h +24 -0
- data/ext/pg_query/include/miscadmin.h +476 -0
- data/ext/pg_query/include/nodes/bitmapset.h +122 -0
- data/ext/pg_query/include/nodes/execnodes.h +2520 -0
- data/ext/pg_query/include/nodes/extensible.h +160 -0
- data/ext/pg_query/include/nodes/lockoptions.h +61 -0
- data/ext/pg_query/include/nodes/makefuncs.h +108 -0
- data/ext/pg_query/include/nodes/memnodes.h +108 -0
- data/ext/pg_query/include/nodes/nodeFuncs.h +162 -0
- data/ext/pg_query/include/nodes/nodes.h +842 -0
- data/ext/pg_query/include/nodes/params.h +170 -0
- data/ext/pg_query/include/nodes/parsenodes.h +3579 -0
- data/ext/pg_query/include/nodes/pathnodes.h +2556 -0
- data/ext/pg_query/include/nodes/pg_list.h +605 -0
- data/ext/pg_query/include/nodes/plannodes.h +1251 -0
- data/ext/pg_query/include/nodes/primnodes.h +1541 -0
- data/ext/pg_query/include/nodes/print.h +34 -0
- data/ext/pg_query/include/nodes/tidbitmap.h +75 -0
- data/ext/pg_query/include/nodes/value.h +61 -0
- data/ext/pg_query/include/optimizer/cost.h +206 -0
- data/ext/pg_query/include/optimizer/geqo.h +88 -0
- data/ext/pg_query/include/optimizer/geqo_gene.h +45 -0
- data/ext/pg_query/include/optimizer/optimizer.h +199 -0
- data/ext/pg_query/include/optimizer/paths.h +249 -0
- data/ext/pg_query/include/optimizer/planmain.h +119 -0
- data/ext/pg_query/include/parser/analyze.h +49 -0
- data/ext/pg_query/include/parser/gram.h +1067 -0
- data/ext/pg_query/include/parser/gramparse.h +75 -0
- data/ext/pg_query/include/parser/kwlist.h +477 -0
- data/ext/pg_query/include/parser/parse_agg.h +68 -0
- data/ext/pg_query/include/parser/parse_clause.h +54 -0
- data/ext/pg_query/include/parser/parse_coerce.h +97 -0
- data/ext/pg_query/include/parser/parse_collate.h +27 -0
- data/ext/pg_query/include/parser/parse_expr.h +26 -0
- data/ext/pg_query/include/parser/parse_func.h +73 -0
- data/ext/pg_query/include/parser/parse_node.h +327 -0
- data/ext/pg_query/include/parser/parse_oper.h +67 -0
- data/ext/pg_query/include/parser/parse_relation.h +123 -0
- data/ext/pg_query/include/parser/parse_target.h +46 -0
- data/ext/pg_query/include/parser/parse_type.h +60 -0
- data/ext/pg_query/include/parser/parser.h +41 -0
- data/ext/pg_query/include/parser/parsetree.h +61 -0
- data/ext/pg_query/include/parser/scanner.h +152 -0
- data/ext/pg_query/include/parser/scansup.h +30 -0
- data/ext/pg_query/include/partitioning/partdefs.h +26 -0
- data/ext/pg_query/include/pg_config.h +988 -0
- data/ext/pg_query/include/pg_config_ext.h +8 -0
- data/ext/pg_query/include/pg_config_manual.h +350 -0
- data/ext/pg_query/include/pg_config_os.h +8 -0
- data/ext/pg_query/include/pg_getopt.h +56 -0
- data/ext/pg_query/include/pg_query.h +121 -0
- data/ext/pg_query/include/pg_query_enum_defs.c +2454 -0
- data/ext/pg_query/include/pg_query_fingerprint_conds.c +875 -0
- data/ext/pg_query/include/pg_query_fingerprint_defs.c +12413 -0
- data/ext/pg_query/include/pg_query_json_helper.c +61 -0
- data/ext/pg_query/include/pg_query_outfuncs_conds.c +686 -0
- data/ext/pg_query/include/pg_query_outfuncs_defs.c +2437 -0
- data/ext/pg_query/include/pg_query_readfuncs_conds.c +222 -0
- data/ext/pg_query/include/pg_query_readfuncs_defs.c +2878 -0
- data/ext/pg_query/include/pg_trace.h +17 -0
- data/ext/pg_query/include/pgstat.h +1487 -0
- data/ext/pg_query/include/pgtime.h +84 -0
- data/ext/pg_query/include/pl_gram.h +385 -0
- data/ext/pg_query/include/pl_reserved_kwlist.h +52 -0
- data/ext/pg_query/include/pl_reserved_kwlist_d.h +114 -0
- data/ext/pg_query/include/pl_unreserved_kwlist.h +112 -0
- data/ext/pg_query/include/pl_unreserved_kwlist_d.h +246 -0
- data/ext/pg_query/include/plerrcodes.h +990 -0
- data/ext/pg_query/include/plpgsql.h +1347 -0
- data/ext/pg_query/include/port.h +524 -0
- data/ext/pg_query/include/port/atomics.h +524 -0
- data/ext/pg_query/include/port/atomics/arch-arm.h +26 -0
- data/ext/pg_query/include/port/atomics/arch-ppc.h +254 -0
- data/ext/pg_query/include/port/atomics/arch-x86.h +252 -0
- data/ext/pg_query/include/port/atomics/fallback.h +170 -0
- data/ext/pg_query/include/port/atomics/generic-gcc.h +286 -0
- data/ext/pg_query/include/port/atomics/generic.h +401 -0
- data/ext/pg_query/include/port/pg_bitutils.h +226 -0
- data/ext/pg_query/include/port/pg_bswap.h +161 -0
- data/ext/pg_query/include/port/pg_crc32c.h +101 -0
- data/ext/pg_query/include/portability/instr_time.h +256 -0
- data/ext/pg_query/include/postgres.h +764 -0
- data/ext/pg_query/include/postgres_ext.h +74 -0
- data/ext/pg_query/include/postmaster/autovacuum.h +83 -0
- data/ext/pg_query/include/postmaster/bgworker.h +161 -0
- data/ext/pg_query/include/postmaster/bgworker_internals.h +64 -0
- data/ext/pg_query/include/postmaster/bgwriter.h +45 -0
- data/ext/pg_query/include/postmaster/fork_process.h +17 -0
- data/ext/pg_query/include/postmaster/interrupt.h +32 -0
- data/ext/pg_query/include/postmaster/pgarch.h +39 -0
- data/ext/pg_query/include/postmaster/postmaster.h +77 -0
- data/ext/pg_query/include/postmaster/syslogger.h +98 -0
- data/ext/pg_query/include/postmaster/walwriter.h +21 -0
- data/ext/pg_query/include/protobuf-c.h +1106 -0
- data/ext/pg_query/include/protobuf-c/protobuf-c.h +1106 -0
- data/ext/pg_query/include/protobuf/pg_query.pb-c.h +10846 -0
- data/ext/pg_query/include/protobuf/pg_query.pb.h +124718 -0
- data/ext/pg_query/include/regex/regex.h +184 -0
- data/ext/pg_query/include/replication/logicallauncher.h +31 -0
- data/ext/pg_query/include/replication/logicalproto.h +110 -0
- data/ext/pg_query/include/replication/logicalworker.h +19 -0
- data/ext/pg_query/include/replication/origin.h +73 -0
- data/ext/pg_query/include/replication/reorderbuffer.h +467 -0
- data/ext/pg_query/include/replication/slot.h +219 -0
- data/ext/pg_query/include/replication/syncrep.h +115 -0
- data/ext/pg_query/include/replication/walreceiver.h +340 -0
- data/ext/pg_query/include/replication/walsender.h +74 -0
- data/ext/pg_query/include/rewrite/prs2lock.h +46 -0
- data/ext/pg_query/include/rewrite/rewriteHandler.h +40 -0
- data/ext/pg_query/include/rewrite/rewriteManip.h +87 -0
- data/ext/pg_query/include/rewrite/rewriteSupport.h +26 -0
- data/ext/pg_query/include/storage/backendid.h +37 -0
- data/ext/pg_query/include/storage/block.h +121 -0
- data/ext/pg_query/include/storage/buf.h +46 -0
- data/ext/pg_query/include/storage/bufmgr.h +292 -0
- data/ext/pg_query/include/storage/bufpage.h +459 -0
- data/ext/pg_query/include/storage/condition_variable.h +62 -0
- data/ext/pg_query/include/storage/dsm.h +61 -0
- data/ext/pg_query/include/storage/dsm_impl.h +75 -0
- data/ext/pg_query/include/storage/fd.h +168 -0
- data/ext/pg_query/include/storage/ipc.h +81 -0
- data/ext/pg_query/include/storage/item.h +19 -0
- data/ext/pg_query/include/storage/itemid.h +184 -0
- data/ext/pg_query/include/storage/itemptr.h +206 -0
- data/ext/pg_query/include/storage/large_object.h +100 -0
- data/ext/pg_query/include/storage/latch.h +190 -0
- data/ext/pg_query/include/storage/lmgr.h +114 -0
- data/ext/pg_query/include/storage/lock.h +612 -0
- data/ext/pg_query/include/storage/lockdefs.h +59 -0
- data/ext/pg_query/include/storage/lwlock.h +232 -0
- data/ext/pg_query/include/storage/lwlocknames.h +51 -0
- data/ext/pg_query/include/storage/off.h +57 -0
- data/ext/pg_query/include/storage/pg_sema.h +61 -0
- data/ext/pg_query/include/storage/pg_shmem.h +90 -0
- data/ext/pg_query/include/storage/pmsignal.h +94 -0
- data/ext/pg_query/include/storage/predicate.h +87 -0
- data/ext/pg_query/include/storage/proc.h +333 -0
- data/ext/pg_query/include/storage/proclist_types.h +51 -0
- data/ext/pg_query/include/storage/procsignal.h +75 -0
- data/ext/pg_query/include/storage/relfilenode.h +99 -0
- data/ext/pg_query/include/storage/s_lock.h +1047 -0
- data/ext/pg_query/include/storage/sharedfileset.h +45 -0
- data/ext/pg_query/include/storage/shm_mq.h +85 -0
- data/ext/pg_query/include/storage/shm_toc.h +58 -0
- data/ext/pg_query/include/storage/shmem.h +81 -0
- data/ext/pg_query/include/storage/sinval.h +153 -0
- data/ext/pg_query/include/storage/sinvaladt.h +43 -0
- data/ext/pg_query/include/storage/smgr.h +109 -0
- data/ext/pg_query/include/storage/spin.h +77 -0
- data/ext/pg_query/include/storage/standby.h +91 -0
- data/ext/pg_query/include/storage/standbydefs.h +74 -0
- data/ext/pg_query/include/storage/sync.h +62 -0
- data/ext/pg_query/include/tcop/cmdtag.h +58 -0
- data/ext/pg_query/include/tcop/cmdtaglist.h +217 -0
- data/ext/pg_query/include/tcop/deparse_utility.h +108 -0
- data/ext/pg_query/include/tcop/dest.h +149 -0
- data/ext/pg_query/include/tcop/fastpath.h +21 -0
- data/ext/pg_query/include/tcop/pquery.h +45 -0
- data/ext/pg_query/include/tcop/tcopprot.h +89 -0
- data/ext/pg_query/include/tcop/utility.h +108 -0
- data/ext/pg_query/include/tsearch/ts_cache.h +98 -0
- data/ext/pg_query/include/utils/acl.h +312 -0
- data/ext/pg_query/include/utils/aclchk_internal.h +45 -0
- data/ext/pg_query/include/utils/array.h +458 -0
- data/ext/pg_query/include/utils/builtins.h +127 -0
- data/ext/pg_query/include/utils/bytea.h +27 -0
- data/ext/pg_query/include/utils/catcache.h +231 -0
- data/ext/pg_query/include/utils/date.h +90 -0
- data/ext/pg_query/include/utils/datetime.h +343 -0
- data/ext/pg_query/include/utils/datum.h +68 -0
- data/ext/pg_query/include/utils/dsa.h +123 -0
- data/ext/pg_query/include/utils/dynahash.h +19 -0
- data/ext/pg_query/include/utils/elog.h +439 -0
- data/ext/pg_query/include/utils/errcodes.h +352 -0
- data/ext/pg_query/include/utils/expandeddatum.h +159 -0
- data/ext/pg_query/include/utils/expandedrecord.h +231 -0
- data/ext/pg_query/include/utils/float.h +356 -0
- data/ext/pg_query/include/utils/fmgroids.h +2657 -0
- data/ext/pg_query/include/utils/fmgrprotos.h +2646 -0
- data/ext/pg_query/include/utils/fmgrtab.h +48 -0
- data/ext/pg_query/include/utils/guc.h +443 -0
- data/ext/pg_query/include/utils/guc_tables.h +272 -0
- data/ext/pg_query/include/utils/hsearch.h +149 -0
- data/ext/pg_query/include/utils/inval.h +64 -0
- data/ext/pg_query/include/utils/lsyscache.h +197 -0
- data/ext/pg_query/include/utils/memdebug.h +82 -0
- data/ext/pg_query/include/utils/memutils.h +225 -0
- data/ext/pg_query/include/utils/numeric.h +76 -0
- data/ext/pg_query/include/utils/palloc.h +136 -0
- data/ext/pg_query/include/utils/partcache.h +102 -0
- data/ext/pg_query/include/utils/pg_locale.h +119 -0
- data/ext/pg_query/include/utils/pg_lsn.h +29 -0
- data/ext/pg_query/include/utils/pidfile.h +56 -0
- data/ext/pg_query/include/utils/plancache.h +235 -0
- data/ext/pg_query/include/utils/portal.h +241 -0
- data/ext/pg_query/include/utils/probes.h +114 -0
- data/ext/pg_query/include/utils/ps_status.h +25 -0
- data/ext/pg_query/include/utils/queryenvironment.h +74 -0
- data/ext/pg_query/include/utils/regproc.h +28 -0
- data/ext/pg_query/include/utils/rel.h +644 -0
- data/ext/pg_query/include/utils/relcache.h +151 -0
- data/ext/pg_query/include/utils/reltrigger.h +81 -0
- data/ext/pg_query/include/utils/resowner.h +86 -0
- data/ext/pg_query/include/utils/rls.h +50 -0
- data/ext/pg_query/include/utils/ruleutils.h +44 -0
- data/ext/pg_query/include/utils/sharedtuplestore.h +61 -0
- data/ext/pg_query/include/utils/snapmgr.h +158 -0
- data/ext/pg_query/include/utils/snapshot.h +206 -0
- data/ext/pg_query/include/utils/sortsupport.h +276 -0
- data/ext/pg_query/include/utils/syscache.h +219 -0
- data/ext/pg_query/include/utils/timeout.h +88 -0
- data/ext/pg_query/include/utils/timestamp.h +116 -0
- data/ext/pg_query/include/utils/tuplesort.h +277 -0
- data/ext/pg_query/include/utils/tuplestore.h +91 -0
- data/ext/pg_query/include/utils/typcache.h +202 -0
- data/ext/pg_query/include/utils/tzparser.h +39 -0
- data/ext/pg_query/include/utils/varlena.h +39 -0
- data/ext/pg_query/include/utils/xml.h +84 -0
- data/ext/pg_query/include/xxhash.h +5445 -0
- data/ext/pg_query/include/xxhash/xxhash.h +5445 -0
- data/ext/pg_query/pg_query.c +104 -0
- data/ext/pg_query/pg_query.pb-c.c +37628 -0
- data/ext/pg_query/pg_query_deparse.c +9953 -0
- data/ext/pg_query/pg_query_fingerprint.c +292 -0
- data/ext/pg_query/pg_query_fingerprint.h +8 -0
- data/ext/pg_query/pg_query_internal.h +24 -0
- data/ext/pg_query/pg_query_json_plpgsql.c +738 -0
- data/ext/pg_query/pg_query_json_plpgsql.h +9 -0
- data/ext/pg_query/pg_query_normalize.c +437 -0
- data/ext/pg_query/pg_query_outfuncs.h +10 -0
- data/ext/pg_query/pg_query_outfuncs_json.c +297 -0
- data/ext/pg_query/pg_query_outfuncs_protobuf.c +237 -0
- data/ext/pg_query/pg_query_parse.c +148 -0
- data/ext/pg_query/pg_query_parse_plpgsql.c +460 -0
- data/ext/pg_query/pg_query_readfuncs.h +11 -0
- data/ext/pg_query/pg_query_readfuncs_protobuf.c +142 -0
- data/ext/pg_query/pg_query_ruby.c +108 -12
- data/ext/pg_query/pg_query_scan.c +173 -0
- data/ext/pg_query/pg_query_split.c +221 -0
- data/ext/pg_query/protobuf-c.c +3660 -0
- data/ext/pg_query/src_backend_catalog_namespace.c +1051 -0
- data/ext/pg_query/src_backend_catalog_pg_proc.c +142 -0
- data/ext/pg_query/src_backend_commands_define.c +117 -0
- data/ext/pg_query/src_backend_libpq_pqcomm.c +651 -0
- data/ext/pg_query/src_backend_nodes_bitmapset.c +513 -0
- data/ext/pg_query/src_backend_nodes_copyfuncs.c +6013 -0
- data/ext/pg_query/src_backend_nodes_equalfuncs.c +4003 -0
- data/ext/pg_query/src_backend_nodes_extensible.c +99 -0
- data/ext/pg_query/src_backend_nodes_list.c +922 -0
- data/ext/pg_query/src_backend_nodes_makefuncs.c +417 -0
- data/ext/pg_query/src_backend_nodes_nodeFuncs.c +1363 -0
- data/ext/pg_query/src_backend_nodes_value.c +84 -0
- data/ext/pg_query/src_backend_parser_gram.c +47456 -0
- data/ext/pg_query/src_backend_parser_parse_expr.c +313 -0
- data/ext/pg_query/src_backend_parser_parser.c +497 -0
- data/ext/pg_query/src_backend_parser_scan.c +7091 -0
- data/ext/pg_query/src_backend_parser_scansup.c +160 -0
- data/ext/pg_query/src_backend_postmaster_postmaster.c +2230 -0
- data/ext/pg_query/src_backend_storage_ipc_ipc.c +192 -0
- data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +370 -0
- data/ext/pg_query/src_backend_tcop_postgres.c +776 -0
- data/ext/pg_query/src_backend_utils_adt_datum.c +326 -0
- data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +98 -0
- data/ext/pg_query/src_backend_utils_adt_format_type.c +136 -0
- data/ext/pg_query/src_backend_utils_adt_ruleutils.c +1683 -0
- data/ext/pg_query/src_backend_utils_error_assert.c +74 -0
- data/ext/pg_query/src_backend_utils_error_elog.c +1748 -0
- data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +570 -0
- data/ext/pg_query/src_backend_utils_hash_dynahash.c +1086 -0
- data/ext/pg_query/src_backend_utils_init_globals.c +168 -0
- data/ext/pg_query/src_backend_utils_mb_mbutils.c +839 -0
- data/ext/pg_query/src_backend_utils_misc_guc.c +1831 -0
- data/ext/pg_query/src_backend_utils_mmgr_aset.c +1560 -0
- data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +1006 -0
- data/ext/pg_query/src_common_encnames.c +158 -0
- data/ext/pg_query/src_common_keywords.c +39 -0
- data/ext/pg_query/src_common_kwlist_d.h +1081 -0
- data/ext/pg_query/src_common_kwlookup.c +91 -0
- data/ext/pg_query/src_common_psprintf.c +158 -0
- data/ext/pg_query/src_common_string.c +86 -0
- data/ext/pg_query/src_common_stringinfo.c +336 -0
- data/ext/pg_query/src_common_wchar.c +1651 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +1133 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +877 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +6533 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +107 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +123 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +671 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +255 -0
- data/ext/pg_query/src_port_erand48.c +127 -0
- data/ext/pg_query/src_port_pg_bitutils.c +246 -0
- data/ext/pg_query/src_port_pgsleep.c +69 -0
- data/ext/pg_query/src_port_pgstrcasecmp.c +83 -0
- data/ext/pg_query/src_port_qsort.c +240 -0
- data/ext/pg_query/src_port_random.c +31 -0
- data/ext/pg_query/src_port_snprintf.c +1449 -0
- data/ext/pg_query/src_port_strerror.c +324 -0
- data/ext/pg_query/src_port_strnlen.c +39 -0
- data/ext/pg_query/xxhash.c +43 -0
- data/lib/pg_query.rb +7 -4
- data/lib/pg_query/constants.rb +21 -0
- data/lib/pg_query/deparse.rb +16 -1117
- data/lib/pg_query/filter_columns.rb +86 -85
- data/lib/pg_query/fingerprint.rb +122 -87
- data/lib/pg_query/json_field_names.rb +1402 -0
- data/lib/pg_query/node.rb +31 -0
- data/lib/pg_query/param_refs.rb +42 -37
- data/lib/pg_query/parse.rb +220 -200
- data/lib/pg_query/parse_error.rb +1 -1
- data/lib/pg_query/pg_query_pb.rb +3211 -0
- data/lib/pg_query/scan.rb +23 -0
- data/lib/pg_query/treewalker.rb +24 -40
- data/lib/pg_query/truncate.rb +64 -43
- data/lib/pg_query/version.rb +2 -2
- metadata +473 -11
- data/ext/pg_query/pg_query_ruby.h +0 -10
- data/lib/pg_query/deep_dup.rb +0 -16
- data/lib/pg_query/deparse/alter_table.rb +0 -42
- data/lib/pg_query/deparse/interval.rb +0 -105
- data/lib/pg_query/legacy_parsetree.rb +0 -109
- data/lib/pg_query/node_types.rb +0 -284
@@ -0,0 +1,41 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* functions.h
|
4
|
+
* Declarations for execution of SQL-language functions.
|
5
|
+
*
|
6
|
+
*
|
7
|
+
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
8
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
9
|
+
*
|
10
|
+
* src/include/executor/functions.h
|
11
|
+
*
|
12
|
+
*-------------------------------------------------------------------------
|
13
|
+
*/
|
14
|
+
#ifndef FUNCTIONS_H
|
15
|
+
#define FUNCTIONS_H
|
16
|
+
|
17
|
+
#include "nodes/execnodes.h"
|
18
|
+
#include "tcop/dest.h"
|
19
|
+
|
20
|
+
/* This struct is known only within executor/functions.c */
|
21
|
+
typedef struct SQLFunctionParseInfo *SQLFunctionParseInfoPtr;
|
22
|
+
|
23
|
+
extern Datum fmgr_sql(PG_FUNCTION_ARGS);
|
24
|
+
|
25
|
+
extern SQLFunctionParseInfoPtr prepare_sql_fn_parse_info(HeapTuple procedureTuple,
|
26
|
+
Node *call_expr,
|
27
|
+
Oid inputCollation);
|
28
|
+
|
29
|
+
extern void sql_fn_parser_setup(struct ParseState *pstate,
|
30
|
+
SQLFunctionParseInfoPtr pinfo);
|
31
|
+
|
32
|
+
extern void check_sql_fn_statements(List *queryTreeLists);
|
33
|
+
|
34
|
+
extern bool check_sql_fn_retval(List *queryTreeLists,
|
35
|
+
Oid rettype, TupleDesc rettupdesc,
|
36
|
+
bool insertDroppedCols,
|
37
|
+
List **resultTargetList);
|
38
|
+
|
39
|
+
extern DestReceiver *CreateSQLFunctionDestReceiver(void);
|
40
|
+
|
41
|
+
#endif /* FUNCTIONS_H */
|
@@ -0,0 +1,101 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* instrument.h
|
4
|
+
* definitions for run-time statistics collection
|
5
|
+
*
|
6
|
+
*
|
7
|
+
* Copyright (c) 2001-2020, PostgreSQL Global Development Group
|
8
|
+
*
|
9
|
+
* src/include/executor/instrument.h
|
10
|
+
*
|
11
|
+
*-------------------------------------------------------------------------
|
12
|
+
*/
|
13
|
+
#ifndef INSTRUMENT_H
|
14
|
+
#define INSTRUMENT_H
|
15
|
+
|
16
|
+
#include "portability/instr_time.h"
|
17
|
+
|
18
|
+
|
19
|
+
typedef struct BufferUsage
|
20
|
+
{
|
21
|
+
long shared_blks_hit; /* # of shared buffer hits */
|
22
|
+
long shared_blks_read; /* # of shared disk blocks read */
|
23
|
+
long shared_blks_dirtied; /* # of shared blocks dirtied */
|
24
|
+
long shared_blks_written; /* # of shared disk blocks written */
|
25
|
+
long local_blks_hit; /* # of local buffer hits */
|
26
|
+
long local_blks_read; /* # of local disk blocks read */
|
27
|
+
long local_blks_dirtied; /* # of shared blocks dirtied */
|
28
|
+
long local_blks_written; /* # of local disk blocks written */
|
29
|
+
long temp_blks_read; /* # of temp blocks read */
|
30
|
+
long temp_blks_written; /* # of temp blocks written */
|
31
|
+
instr_time blk_read_time; /* time spent reading */
|
32
|
+
instr_time blk_write_time; /* time spent writing */
|
33
|
+
} BufferUsage;
|
34
|
+
|
35
|
+
typedef struct WalUsage
|
36
|
+
{
|
37
|
+
long wal_records; /* # of WAL records produced */
|
38
|
+
long wal_fpi; /* # of WAL full page images produced */
|
39
|
+
uint64 wal_bytes; /* size of WAL records produced */
|
40
|
+
} WalUsage;
|
41
|
+
|
42
|
+
/* Flag bits included in InstrAlloc's instrument_options bitmask */
|
43
|
+
typedef enum InstrumentOption
|
44
|
+
{
|
45
|
+
INSTRUMENT_TIMER = 1 << 0, /* needs timer (and row counts) */
|
46
|
+
INSTRUMENT_BUFFERS = 1 << 1, /* needs buffer usage */
|
47
|
+
INSTRUMENT_ROWS = 1 << 2, /* needs row count */
|
48
|
+
INSTRUMENT_WAL = 1 << 3, /* needs WAL usage */
|
49
|
+
INSTRUMENT_ALL = PG_INT32_MAX
|
50
|
+
} InstrumentOption;
|
51
|
+
|
52
|
+
typedef struct Instrumentation
|
53
|
+
{
|
54
|
+
/* Parameters set at node creation: */
|
55
|
+
bool need_timer; /* true if we need timer data */
|
56
|
+
bool need_bufusage; /* true if we need buffer usage data */
|
57
|
+
bool need_walusage; /* true if we need WAL usage data */
|
58
|
+
/* Info about current plan cycle: */
|
59
|
+
bool running; /* true if we've completed first tuple */
|
60
|
+
instr_time starttime; /* start time of current iteration of node */
|
61
|
+
instr_time counter; /* accumulated runtime for this node */
|
62
|
+
double firsttuple; /* time for first tuple of this cycle */
|
63
|
+
double tuplecount; /* # of tuples emitted so far this cycle */
|
64
|
+
BufferUsage bufusage_start; /* buffer usage at start */
|
65
|
+
WalUsage walusage_start; /* WAL usage at start */
|
66
|
+
/* Accumulated statistics across all completed cycles: */
|
67
|
+
double startup; /* total startup time (in seconds) */
|
68
|
+
double total; /* total time (in seconds) */
|
69
|
+
double ntuples; /* total tuples produced */
|
70
|
+
double ntuples2; /* secondary node-specific tuple counter */
|
71
|
+
double nloops; /* # of run cycles for this node */
|
72
|
+
double nfiltered1; /* # of tuples removed by scanqual or joinqual */
|
73
|
+
double nfiltered2; /* # of tuples removed by "other" quals */
|
74
|
+
BufferUsage bufusage; /* total buffer usage */
|
75
|
+
WalUsage walusage; /* total WAL usage */
|
76
|
+
} Instrumentation;
|
77
|
+
|
78
|
+
typedef struct WorkerInstrumentation
|
79
|
+
{
|
80
|
+
int num_workers; /* # of structures that follow */
|
81
|
+
Instrumentation instrument[FLEXIBLE_ARRAY_MEMBER];
|
82
|
+
} WorkerInstrumentation;
|
83
|
+
|
84
|
+
extern PGDLLIMPORT BufferUsage pgBufferUsage;
|
85
|
+
extern PGDLLIMPORT WalUsage pgWalUsage;
|
86
|
+
|
87
|
+
extern Instrumentation *InstrAlloc(int n, int instrument_options);
|
88
|
+
extern void InstrInit(Instrumentation *instr, int instrument_options);
|
89
|
+
extern void InstrStartNode(Instrumentation *instr);
|
90
|
+
extern void InstrStopNode(Instrumentation *instr, double nTuples);
|
91
|
+
extern void InstrEndLoop(Instrumentation *instr);
|
92
|
+
extern void InstrAggNode(Instrumentation *dst, Instrumentation *add);
|
93
|
+
extern void InstrStartParallelQuery(void);
|
94
|
+
extern void InstrEndParallelQuery(BufferUsage *bufusage, WalUsage *walusage);
|
95
|
+
extern void InstrAccumParallelQuery(BufferUsage *bufusage, WalUsage *walusage);
|
96
|
+
extern void BufferUsageAccumDiff(BufferUsage *dst,
|
97
|
+
const BufferUsage *add, const BufferUsage *sub);
|
98
|
+
extern void WalUsageAccumDiff(WalUsage *dst, const WalUsage *add,
|
99
|
+
const WalUsage *sub);
|
100
|
+
|
101
|
+
#endif /* INSTRUMENT_H */
|
@@ -0,0 +1,175 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* spi.h
|
4
|
+
* Server Programming Interface public declarations
|
5
|
+
*
|
6
|
+
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
7
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
8
|
+
*
|
9
|
+
* src/include/executor/spi.h
|
10
|
+
*
|
11
|
+
*-------------------------------------------------------------------------
|
12
|
+
*/
|
13
|
+
#ifndef SPI_H
|
14
|
+
#define SPI_H
|
15
|
+
|
16
|
+
#include "commands/trigger.h"
|
17
|
+
#include "lib/ilist.h"
|
18
|
+
#include "nodes/parsenodes.h"
|
19
|
+
#include "utils/portal.h"
|
20
|
+
|
21
|
+
|
22
|
+
typedef struct SPITupleTable
|
23
|
+
{
|
24
|
+
/* Public members */
|
25
|
+
TupleDesc tupdesc; /* tuple descriptor */
|
26
|
+
HeapTuple *vals; /* array of tuples */
|
27
|
+
uint64 numvals; /* number of valid tuples */
|
28
|
+
|
29
|
+
/* Private members, not intended for external callers */
|
30
|
+
uint64 alloced; /* allocated length of vals array */
|
31
|
+
MemoryContext tuptabcxt; /* memory context of result table */
|
32
|
+
slist_node next; /* link for internal bookkeeping */
|
33
|
+
SubTransactionId subid; /* subxact in which tuptable was created */
|
34
|
+
} SPITupleTable;
|
35
|
+
|
36
|
+
/* Plans are opaque structs for standard users of SPI */
|
37
|
+
typedef struct _SPI_plan *SPIPlanPtr;
|
38
|
+
|
39
|
+
#define SPI_ERROR_CONNECT (-1)
|
40
|
+
#define SPI_ERROR_COPY (-2)
|
41
|
+
#define SPI_ERROR_OPUNKNOWN (-3)
|
42
|
+
#define SPI_ERROR_UNCONNECTED (-4)
|
43
|
+
#define SPI_ERROR_CURSOR (-5) /* not used anymore */
|
44
|
+
#define SPI_ERROR_ARGUMENT (-6)
|
45
|
+
#define SPI_ERROR_PARAM (-7)
|
46
|
+
#define SPI_ERROR_TRANSACTION (-8)
|
47
|
+
#define SPI_ERROR_NOATTRIBUTE (-9)
|
48
|
+
#define SPI_ERROR_NOOUTFUNC (-10)
|
49
|
+
#define SPI_ERROR_TYPUNKNOWN (-11)
|
50
|
+
#define SPI_ERROR_REL_DUPLICATE (-12)
|
51
|
+
#define SPI_ERROR_REL_NOT_FOUND (-13)
|
52
|
+
|
53
|
+
#define SPI_OK_CONNECT 1
|
54
|
+
#define SPI_OK_FINISH 2
|
55
|
+
#define SPI_OK_FETCH 3
|
56
|
+
#define SPI_OK_UTILITY 4
|
57
|
+
#define SPI_OK_SELECT 5
|
58
|
+
#define SPI_OK_SELINTO 6
|
59
|
+
#define SPI_OK_INSERT 7
|
60
|
+
#define SPI_OK_DELETE 8
|
61
|
+
#define SPI_OK_UPDATE 9
|
62
|
+
#define SPI_OK_CURSOR 10
|
63
|
+
#define SPI_OK_INSERT_RETURNING 11
|
64
|
+
#define SPI_OK_DELETE_RETURNING 12
|
65
|
+
#define SPI_OK_UPDATE_RETURNING 13
|
66
|
+
#define SPI_OK_REWRITTEN 14
|
67
|
+
#define SPI_OK_REL_REGISTER 15
|
68
|
+
#define SPI_OK_REL_UNREGISTER 16
|
69
|
+
#define SPI_OK_TD_REGISTER 17
|
70
|
+
|
71
|
+
#define SPI_OPT_NONATOMIC (1 << 0)
|
72
|
+
|
73
|
+
/* These used to be functions, now just no-ops for backwards compatibility */
|
74
|
+
#define SPI_push() ((void) 0)
|
75
|
+
#define SPI_pop() ((void) 0)
|
76
|
+
#define SPI_push_conditional() false
|
77
|
+
#define SPI_pop_conditional(pushed) ((void) 0)
|
78
|
+
#define SPI_restore_connection() ((void) 0)
|
79
|
+
|
80
|
+
extern PGDLLIMPORT uint64 SPI_processed;
|
81
|
+
extern PGDLLIMPORT SPITupleTable *SPI_tuptable;
|
82
|
+
extern PGDLLIMPORT int SPI_result;
|
83
|
+
|
84
|
+
extern int SPI_connect(void);
|
85
|
+
extern int SPI_connect_ext(int options);
|
86
|
+
extern int SPI_finish(void);
|
87
|
+
extern int SPI_execute(const char *src, bool read_only, long tcount);
|
88
|
+
extern int SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls,
|
89
|
+
bool read_only, long tcount);
|
90
|
+
extern int SPI_execute_plan_with_paramlist(SPIPlanPtr plan,
|
91
|
+
ParamListInfo params,
|
92
|
+
bool read_only, long tcount);
|
93
|
+
extern int SPI_exec(const char *src, long tcount);
|
94
|
+
extern int SPI_execp(SPIPlanPtr plan, Datum *Values, const char *Nulls,
|
95
|
+
long tcount);
|
96
|
+
extern int SPI_execute_snapshot(SPIPlanPtr plan,
|
97
|
+
Datum *Values, const char *Nulls,
|
98
|
+
Snapshot snapshot,
|
99
|
+
Snapshot crosscheck_snapshot,
|
100
|
+
bool read_only, bool fire_triggers, long tcount);
|
101
|
+
extern int SPI_execute_with_args(const char *src,
|
102
|
+
int nargs, Oid *argtypes,
|
103
|
+
Datum *Values, const char *Nulls,
|
104
|
+
bool read_only, long tcount);
|
105
|
+
extern SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes);
|
106
|
+
extern SPIPlanPtr SPI_prepare_cursor(const char *src, int nargs, Oid *argtypes,
|
107
|
+
int cursorOptions);
|
108
|
+
extern SPIPlanPtr SPI_prepare_params(const char *src,
|
109
|
+
ParserSetupHook parserSetup,
|
110
|
+
void *parserSetupArg,
|
111
|
+
int cursorOptions);
|
112
|
+
extern int SPI_keepplan(SPIPlanPtr plan);
|
113
|
+
extern SPIPlanPtr SPI_saveplan(SPIPlanPtr plan);
|
114
|
+
extern int SPI_freeplan(SPIPlanPtr plan);
|
115
|
+
|
116
|
+
extern Oid SPI_getargtypeid(SPIPlanPtr plan, int argIndex);
|
117
|
+
extern int SPI_getargcount(SPIPlanPtr plan);
|
118
|
+
extern bool SPI_is_cursor_plan(SPIPlanPtr plan);
|
119
|
+
extern bool SPI_plan_is_valid(SPIPlanPtr plan);
|
120
|
+
extern const char *SPI_result_code_string(int code);
|
121
|
+
|
122
|
+
extern List *SPI_plan_get_plan_sources(SPIPlanPtr plan);
|
123
|
+
extern CachedPlan *SPI_plan_get_cached_plan(SPIPlanPtr plan);
|
124
|
+
|
125
|
+
extern HeapTuple SPI_copytuple(HeapTuple tuple);
|
126
|
+
extern HeapTupleHeader SPI_returntuple(HeapTuple tuple, TupleDesc tupdesc);
|
127
|
+
extern HeapTuple SPI_modifytuple(Relation rel, HeapTuple tuple, int natts,
|
128
|
+
int *attnum, Datum *Values, const char *Nulls);
|
129
|
+
extern int SPI_fnumber(TupleDesc tupdesc, const char *fname);
|
130
|
+
extern char *SPI_fname(TupleDesc tupdesc, int fnumber);
|
131
|
+
extern char *SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber);
|
132
|
+
extern Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull);
|
133
|
+
extern char *SPI_gettype(TupleDesc tupdesc, int fnumber);
|
134
|
+
extern Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber);
|
135
|
+
extern char *SPI_getrelname(Relation rel);
|
136
|
+
extern char *SPI_getnspname(Relation rel);
|
137
|
+
extern void *SPI_palloc(Size size);
|
138
|
+
extern void *SPI_repalloc(void *pointer, Size size);
|
139
|
+
extern void SPI_pfree(void *pointer);
|
140
|
+
extern Datum SPI_datumTransfer(Datum value, bool typByVal, int typLen);
|
141
|
+
extern void SPI_freetuple(HeapTuple pointer);
|
142
|
+
extern void SPI_freetuptable(SPITupleTable *tuptable);
|
143
|
+
|
144
|
+
extern Portal SPI_cursor_open(const char *name, SPIPlanPtr plan,
|
145
|
+
Datum *Values, const char *Nulls, bool read_only);
|
146
|
+
extern Portal SPI_cursor_open_with_args(const char *name,
|
147
|
+
const char *src,
|
148
|
+
int nargs, Oid *argtypes,
|
149
|
+
Datum *Values, const char *Nulls,
|
150
|
+
bool read_only, int cursorOptions);
|
151
|
+
extern Portal SPI_cursor_open_with_paramlist(const char *name, SPIPlanPtr plan,
|
152
|
+
ParamListInfo params, bool read_only);
|
153
|
+
extern Portal SPI_cursor_find(const char *name);
|
154
|
+
extern void SPI_cursor_fetch(Portal portal, bool forward, long count);
|
155
|
+
extern void SPI_cursor_move(Portal portal, bool forward, long count);
|
156
|
+
extern void SPI_scroll_cursor_fetch(Portal, FetchDirection direction, long count);
|
157
|
+
extern void SPI_scroll_cursor_move(Portal, FetchDirection direction, long count);
|
158
|
+
extern void SPI_cursor_close(Portal portal);
|
159
|
+
|
160
|
+
extern int SPI_register_relation(EphemeralNamedRelation enr);
|
161
|
+
extern int SPI_unregister_relation(const char *name);
|
162
|
+
extern int SPI_register_trigger_data(TriggerData *tdata);
|
163
|
+
|
164
|
+
extern void SPI_start_transaction(void);
|
165
|
+
extern void SPI_commit(void);
|
166
|
+
extern void SPI_commit_and_chain(void);
|
167
|
+
extern void SPI_rollback(void);
|
168
|
+
extern void SPI_rollback_and_chain(void);
|
169
|
+
|
170
|
+
extern void SPICleanup(void);
|
171
|
+
extern void AtEOXact_SPI(bool isCommit);
|
172
|
+
extern void AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid);
|
173
|
+
extern bool SPI_inside_nonatomic_context(void);
|
174
|
+
|
175
|
+
#endif /* SPI_H */
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* tablefunc.h
|
4
|
+
* interface for TableFunc executor node
|
5
|
+
*
|
6
|
+
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
7
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
8
|
+
*
|
9
|
+
* src/include/executor/tablefunc.h
|
10
|
+
*
|
11
|
+
*-------------------------------------------------------------------------
|
12
|
+
*/
|
13
|
+
#ifndef _TABLEFUNC_H
|
14
|
+
#define _TABLEFUNC_H
|
15
|
+
|
16
|
+
/* Forward-declare this to avoid including execnodes.h here */
|
17
|
+
struct TableFuncScanState;
|
18
|
+
|
19
|
+
/*
|
20
|
+
* TableFuncRoutine holds function pointers used for generating content of
|
21
|
+
* table-producer functions, such as XMLTABLE.
|
22
|
+
*
|
23
|
+
* InitOpaque initializes table builder private objects. The output tuple
|
24
|
+
* descriptor, input functions for the columns, and typioparams are passed
|
25
|
+
* from executor state.
|
26
|
+
*
|
27
|
+
* SetDocument is called to define the input document. The table builder may
|
28
|
+
* apply additional transformations not exposed outside the table builder
|
29
|
+
* context.
|
30
|
+
*
|
31
|
+
* SetNamespace is called to pass namespace declarations from the table
|
32
|
+
* expression. This function may be NULL if namespaces are not supported by
|
33
|
+
* the table builder. Namespaces must be given before setting the row and
|
34
|
+
* column filters. If the name is given as NULL, the entry shall be for the
|
35
|
+
* default namespace.
|
36
|
+
*
|
37
|
+
* SetRowFilter is called do define the row-generating filter, which shall be
|
38
|
+
* used to extract each row from the input document.
|
39
|
+
*
|
40
|
+
* SetColumnFilter is called once for each column, to define the column-
|
41
|
+
* generating filter for the given column.
|
42
|
+
*
|
43
|
+
* FetchRow shall be called repeatedly until it returns that no more rows are
|
44
|
+
* found in the document. On each invocation it shall set state in the table
|
45
|
+
* builder context such that each subsequent GetValue call returns the values
|
46
|
+
* for the indicated column for the row being processed.
|
47
|
+
*
|
48
|
+
* DestroyOpaque shall release all resources associated with a table builder
|
49
|
+
* context. It may be called either because all rows have been consumed, or
|
50
|
+
* because an error occurred while processing the table expression.
|
51
|
+
*/
|
52
|
+
typedef struct TableFuncRoutine
|
53
|
+
{
|
54
|
+
void (*InitOpaque) (struct TableFuncScanState *state, int natts);
|
55
|
+
void (*SetDocument) (struct TableFuncScanState *state, Datum value);
|
56
|
+
void (*SetNamespace) (struct TableFuncScanState *state, const char *name,
|
57
|
+
const char *uri);
|
58
|
+
void (*SetRowFilter) (struct TableFuncScanState *state, const char *path);
|
59
|
+
void (*SetColumnFilter) (struct TableFuncScanState *state,
|
60
|
+
const char *path, int colnum);
|
61
|
+
bool (*FetchRow) (struct TableFuncScanState *state);
|
62
|
+
Datum (*GetValue) (struct TableFuncScanState *state, int colnum,
|
63
|
+
Oid typid, int32 typmod, bool *isnull);
|
64
|
+
void (*DestroyOpaque) (struct TableFuncScanState *state);
|
65
|
+
} TableFuncRoutine;
|
66
|
+
|
67
|
+
#endif /* _TABLEFUNC_H */
|
@@ -0,0 +1,487 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* tuptable.h
|
4
|
+
* tuple table support stuff
|
5
|
+
*
|
6
|
+
*
|
7
|
+
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
8
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
9
|
+
*
|
10
|
+
* src/include/executor/tuptable.h
|
11
|
+
*
|
12
|
+
*-------------------------------------------------------------------------
|
13
|
+
*/
|
14
|
+
#ifndef TUPTABLE_H
|
15
|
+
#define TUPTABLE_H
|
16
|
+
|
17
|
+
#include "access/htup.h"
|
18
|
+
#include "access/htup_details.h"
|
19
|
+
#include "access/sysattr.h"
|
20
|
+
#include "access/tupdesc.h"
|
21
|
+
#include "storage/buf.h"
|
22
|
+
|
23
|
+
/*----------
|
24
|
+
* The executor stores tuples in a "tuple table" which is a List of
|
25
|
+
* independent TupleTableSlots.
|
26
|
+
*
|
27
|
+
* There's various different types of tuple table slots, each being able to
|
28
|
+
* store different types of tuples. Additional types of slots can be added
|
29
|
+
* without modifying core code. The type of a slot is determined by the
|
30
|
+
* TupleTableSlotOps* passed to the slot creation routine. The builtin types
|
31
|
+
* of slots are
|
32
|
+
*
|
33
|
+
* 1. physical tuple in a disk buffer page (TTSOpsBufferHeapTuple)
|
34
|
+
* 2. physical tuple constructed in palloc'ed memory (TTSOpsHeapTuple)
|
35
|
+
* 3. "minimal" physical tuple constructed in palloc'ed memory
|
36
|
+
* (TTSOpsMinimalTuple)
|
37
|
+
* 4. "virtual" tuple consisting of Datum/isnull arrays (TTSOpsVirtual)
|
38
|
+
*
|
39
|
+
*
|
40
|
+
* The first two cases are similar in that they both deal with "materialized"
|
41
|
+
* tuples, but resource management is different. For a tuple in a disk page
|
42
|
+
* we need to hold a pin on the buffer until the TupleTableSlot's reference
|
43
|
+
* to the tuple is dropped; while for a palloc'd tuple we usually want the
|
44
|
+
* tuple pfree'd when the TupleTableSlot's reference is dropped.
|
45
|
+
*
|
46
|
+
* A "minimal" tuple is handled similarly to a palloc'd regular tuple.
|
47
|
+
* At present, minimal tuples never are stored in buffers, so there is no
|
48
|
+
* parallel to case 1. Note that a minimal tuple has no "system columns".
|
49
|
+
* (Actually, it could have an OID, but we have no need to access the OID.)
|
50
|
+
*
|
51
|
+
* A "virtual" tuple is an optimization used to minimize physical data copying
|
52
|
+
* in a nest of plan nodes. Until materialized pass-by-reference Datums in
|
53
|
+
* the slot point to storage that is not directly associated with the
|
54
|
+
* TupleTableSlot; generally they will point to part of a tuple stored in a
|
55
|
+
* lower plan node's output TupleTableSlot, or to a function result
|
56
|
+
* constructed in a plan node's per-tuple econtext. It is the responsibility
|
57
|
+
* of the generating plan node to be sure these resources are not released for
|
58
|
+
* as long as the virtual tuple needs to be valid or is materialized. Note
|
59
|
+
* also that a virtual tuple does not have any "system columns".
|
60
|
+
*
|
61
|
+
* The Datum/isnull arrays of a TupleTableSlot serve double duty. For virtual
|
62
|
+
* slots they are the authoritative data. For the other builtin slots,
|
63
|
+
* the arrays contain data extracted from the tuple. (In this state, any
|
64
|
+
* pass-by-reference Datums point into the physical tuple.) The extracted
|
65
|
+
* information is built "lazily", ie, only as needed. This serves to avoid
|
66
|
+
* repeated extraction of data from the physical tuple.
|
67
|
+
*
|
68
|
+
* A TupleTableSlot can also be "empty", indicated by flag TTS_FLAG_EMPTY set
|
69
|
+
* in tts_flags, holding no valid data. This is the only valid state for a
|
70
|
+
* freshly-created slot that has not yet had a tuple descriptor assigned to
|
71
|
+
* it. In this state, TTS_SHOULDFREE should not be set in tts_flags, tts_tuple
|
72
|
+
* must be NULL and tts_nvalid zero.
|
73
|
+
*
|
74
|
+
* The tupleDescriptor is simply referenced, not copied, by the TupleTableSlot
|
75
|
+
* code. The caller of ExecSetSlotDescriptor() is responsible for providing
|
76
|
+
* a descriptor that will live as long as the slot does. (Typically, both
|
77
|
+
* slots and descriptors are in per-query memory and are freed by memory
|
78
|
+
* context deallocation at query end; so it's not worth providing any extra
|
79
|
+
* mechanism to do more. However, the slot will increment the tupdesc
|
80
|
+
* reference count if a reference-counted tupdesc is supplied.)
|
81
|
+
*
|
82
|
+
* When TTS_SHOULDFREE is set in tts_flags, the physical tuple is "owned" by
|
83
|
+
* the slot and should be freed when the slot's reference to the tuple is
|
84
|
+
* dropped.
|
85
|
+
*
|
86
|
+
* tts_values/tts_isnull are allocated either when the slot is created (when
|
87
|
+
* the descriptor is provided), or when a descriptor is assigned to the slot;
|
88
|
+
* they are of length equal to the descriptor's natts.
|
89
|
+
*
|
90
|
+
* The TTS_FLAG_SLOW flag is saved state for
|
91
|
+
* slot_deform_heap_tuple, and should not be touched by any other code.
|
92
|
+
*----------
|
93
|
+
*/
|
94
|
+
|
95
|
+
/* true = slot is empty */
|
96
|
+
#define TTS_FLAG_EMPTY (1 << 1)
|
97
|
+
#define TTS_EMPTY(slot) (((slot)->tts_flags & TTS_FLAG_EMPTY) != 0)
|
98
|
+
|
99
|
+
/* should pfree tuple "owned" by the slot? */
|
100
|
+
#define TTS_FLAG_SHOULDFREE (1 << 2)
|
101
|
+
#define TTS_SHOULDFREE(slot) (((slot)->tts_flags & TTS_FLAG_SHOULDFREE) != 0)
|
102
|
+
|
103
|
+
/* saved state for slot_deform_heap_tuple */
|
104
|
+
#define TTS_FLAG_SLOW (1 << 3)
|
105
|
+
#define TTS_SLOW(slot) (((slot)->tts_flags & TTS_FLAG_SLOW) != 0)
|
106
|
+
|
107
|
+
/* fixed tuple descriptor */
|
108
|
+
#define TTS_FLAG_FIXED (1 << 4)
|
109
|
+
#define TTS_FIXED(slot) (((slot)->tts_flags & TTS_FLAG_FIXED) != 0)
|
110
|
+
|
111
|
+
struct TupleTableSlotOps;
|
112
|
+
typedef struct TupleTableSlotOps TupleTableSlotOps;
|
113
|
+
|
114
|
+
/* base tuple table slot type */
|
115
|
+
typedef struct TupleTableSlot
|
116
|
+
{
|
117
|
+
NodeTag type;
|
118
|
+
#define FIELDNO_TUPLETABLESLOT_FLAGS 1
|
119
|
+
uint16 tts_flags; /* Boolean states */
|
120
|
+
#define FIELDNO_TUPLETABLESLOT_NVALID 2
|
121
|
+
AttrNumber tts_nvalid; /* # of valid values in tts_values */
|
122
|
+
const TupleTableSlotOps *const tts_ops; /* implementation of slot */
|
123
|
+
#define FIELDNO_TUPLETABLESLOT_TUPLEDESCRIPTOR 4
|
124
|
+
TupleDesc tts_tupleDescriptor; /* slot's tuple descriptor */
|
125
|
+
#define FIELDNO_TUPLETABLESLOT_VALUES 5
|
126
|
+
Datum *tts_values; /* current per-attribute values */
|
127
|
+
#define FIELDNO_TUPLETABLESLOT_ISNULL 6
|
128
|
+
bool *tts_isnull; /* current per-attribute isnull flags */
|
129
|
+
MemoryContext tts_mcxt; /* slot itself is in this context */
|
130
|
+
ItemPointerData tts_tid; /* stored tuple's tid */
|
131
|
+
Oid tts_tableOid; /* table oid of tuple */
|
132
|
+
} TupleTableSlot;
|
133
|
+
|
134
|
+
/* routines for a TupleTableSlot implementation */
|
135
|
+
struct TupleTableSlotOps
|
136
|
+
{
|
137
|
+
/* Minimum size of the slot */
|
138
|
+
size_t base_slot_size;
|
139
|
+
|
140
|
+
/* Initialization. */
|
141
|
+
void (*init) (TupleTableSlot *slot);
|
142
|
+
|
143
|
+
/* Destruction. */
|
144
|
+
void (*release) (TupleTableSlot *slot);
|
145
|
+
|
146
|
+
/*
|
147
|
+
* Clear the contents of the slot. Only the contents are expected to be
|
148
|
+
* cleared and not the tuple descriptor. Typically an implementation of
|
149
|
+
* this callback should free the memory allocated for the tuple contained
|
150
|
+
* in the slot.
|
151
|
+
*/
|
152
|
+
void (*clear) (TupleTableSlot *slot);
|
153
|
+
|
154
|
+
/*
|
155
|
+
* Fill up first natts entries of tts_values and tts_isnull arrays with
|
156
|
+
* values from the tuple contained in the slot. The function may be called
|
157
|
+
* with natts more than the number of attributes available in the tuple,
|
158
|
+
* in which case it should set tts_nvalid to the number of returned
|
159
|
+
* columns.
|
160
|
+
*/
|
161
|
+
void (*getsomeattrs) (TupleTableSlot *slot, int natts);
|
162
|
+
|
163
|
+
/*
|
164
|
+
* Returns value of the given system attribute as a datum and sets isnull
|
165
|
+
* to false, if it's not NULL. Throws an error if the slot type does not
|
166
|
+
* support system attributes.
|
167
|
+
*/
|
168
|
+
Datum (*getsysattr) (TupleTableSlot *slot, int attnum, bool *isnull);
|
169
|
+
|
170
|
+
/*
|
171
|
+
* Make the contents of the slot solely depend on the slot, and not on
|
172
|
+
* underlying resources (like another memory context, buffers, etc).
|
173
|
+
*/
|
174
|
+
void (*materialize) (TupleTableSlot *slot);
|
175
|
+
|
176
|
+
/*
|
177
|
+
* Copy the contents of the source slot into the destination slot's own
|
178
|
+
* context. Invoked using callback of the destination slot.
|
179
|
+
*/
|
180
|
+
void (*copyslot) (TupleTableSlot *dstslot, TupleTableSlot *srcslot);
|
181
|
+
|
182
|
+
/*
|
183
|
+
* Return a heap tuple "owned" by the slot. It is slot's responsibility to
|
184
|
+
* free the memory consumed by the heap tuple. If the slot can not "own" a
|
185
|
+
* heap tuple, it should not implement this callback and should set it as
|
186
|
+
* NULL.
|
187
|
+
*/
|
188
|
+
HeapTuple (*get_heap_tuple) (TupleTableSlot *slot);
|
189
|
+
|
190
|
+
/*
|
191
|
+
* Return a minimal tuple "owned" by the slot. It is slot's responsibility
|
192
|
+
* to free the memory consumed by the minimal tuple. If the slot can not
|
193
|
+
* "own" a minimal tuple, it should not implement this callback and should
|
194
|
+
* set it as NULL.
|
195
|
+
*/
|
196
|
+
MinimalTuple (*get_minimal_tuple) (TupleTableSlot *slot);
|
197
|
+
|
198
|
+
/*
|
199
|
+
* Return a copy of heap tuple representing the contents of the slot. The
|
200
|
+
* copy needs to be palloc'd in the current memory context. The slot
|
201
|
+
* itself is expected to remain unaffected. It is *not* expected to have
|
202
|
+
* meaningful "system columns" in the copy. The copy is not be "owned" by
|
203
|
+
* the slot i.e. the caller has to take responsibility to free memory
|
204
|
+
* consumed by the slot.
|
205
|
+
*/
|
206
|
+
HeapTuple (*copy_heap_tuple) (TupleTableSlot *slot);
|
207
|
+
|
208
|
+
/*
|
209
|
+
* Return a copy of minimal tuple representing the contents of the slot.
|
210
|
+
* The copy needs to be palloc'd in the current memory context. The slot
|
211
|
+
* itself is expected to remain unaffected. It is *not* expected to have
|
212
|
+
* meaningful "system columns" in the copy. The copy is not be "owned" by
|
213
|
+
* the slot i.e. the caller has to take responsibility to free memory
|
214
|
+
* consumed by the slot.
|
215
|
+
*/
|
216
|
+
MinimalTuple (*copy_minimal_tuple) (TupleTableSlot *slot);
|
217
|
+
};
|
218
|
+
|
219
|
+
/*
|
220
|
+
* Predefined TupleTableSlotOps for various types of TupleTableSlotOps. The
|
221
|
+
* same are used to identify the type of a given slot.
|
222
|
+
*/
|
223
|
+
extern PGDLLIMPORT const TupleTableSlotOps TTSOpsVirtual;
|
224
|
+
extern PGDLLIMPORT const TupleTableSlotOps TTSOpsHeapTuple;
|
225
|
+
extern PGDLLIMPORT const TupleTableSlotOps TTSOpsMinimalTuple;
|
226
|
+
extern PGDLLIMPORT const TupleTableSlotOps TTSOpsBufferHeapTuple;
|
227
|
+
|
228
|
+
#define TTS_IS_VIRTUAL(slot) ((slot)->tts_ops == &TTSOpsVirtual)
|
229
|
+
#define TTS_IS_HEAPTUPLE(slot) ((slot)->tts_ops == &TTSOpsHeapTuple)
|
230
|
+
#define TTS_IS_MINIMALTUPLE(slot) ((slot)->tts_ops == &TTSOpsMinimalTuple)
|
231
|
+
#define TTS_IS_BUFFERTUPLE(slot) ((slot)->tts_ops == &TTSOpsBufferHeapTuple)
|
232
|
+
|
233
|
+
|
234
|
+
/*
|
235
|
+
* Tuple table slot implementations.
|
236
|
+
*/
|
237
|
+
|
238
|
+
typedef struct VirtualTupleTableSlot
|
239
|
+
{
|
240
|
+
TupleTableSlot base;
|
241
|
+
|
242
|
+
char *data; /* data for materialized slots */
|
243
|
+
} VirtualTupleTableSlot;
|
244
|
+
|
245
|
+
typedef struct HeapTupleTableSlot
|
246
|
+
{
|
247
|
+
TupleTableSlot base;
|
248
|
+
|
249
|
+
#define FIELDNO_HEAPTUPLETABLESLOT_TUPLE 1
|
250
|
+
HeapTuple tuple; /* physical tuple */
|
251
|
+
#define FIELDNO_HEAPTUPLETABLESLOT_OFF 2
|
252
|
+
uint32 off; /* saved state for slot_deform_heap_tuple */
|
253
|
+
HeapTupleData tupdata; /* optional workspace for storing tuple */
|
254
|
+
} HeapTupleTableSlot;
|
255
|
+
|
256
|
+
/* heap tuple residing in a buffer */
|
257
|
+
typedef struct BufferHeapTupleTableSlot
|
258
|
+
{
|
259
|
+
HeapTupleTableSlot base;
|
260
|
+
|
261
|
+
/*
|
262
|
+
* If buffer is not InvalidBuffer, then the slot is holding a pin on the
|
263
|
+
* indicated buffer page; drop the pin when we release the slot's
|
264
|
+
* reference to that buffer. (TTS_FLAG_SHOULDFREE should not be set in
|
265
|
+
* such a case, since presumably tts_tuple is pointing into the buffer.)
|
266
|
+
*/
|
267
|
+
Buffer buffer; /* tuple's buffer, or InvalidBuffer */
|
268
|
+
} BufferHeapTupleTableSlot;
|
269
|
+
|
270
|
+
typedef struct MinimalTupleTableSlot
|
271
|
+
{
|
272
|
+
TupleTableSlot base;
|
273
|
+
|
274
|
+
/*
|
275
|
+
* In a minimal slot tuple points at minhdr and the fields of that struct
|
276
|
+
* are set correctly for access to the minimal tuple; in particular,
|
277
|
+
* minhdr.t_data points MINIMAL_TUPLE_OFFSET bytes before mintuple. This
|
278
|
+
* allows column extraction to treat the case identically to regular
|
279
|
+
* physical tuples.
|
280
|
+
*/
|
281
|
+
#define FIELDNO_MINIMALTUPLETABLESLOT_TUPLE 1
|
282
|
+
HeapTuple tuple; /* tuple wrapper */
|
283
|
+
MinimalTuple mintuple; /* minimal tuple, or NULL if none */
|
284
|
+
HeapTupleData minhdr; /* workspace for minimal-tuple-only case */
|
285
|
+
#define FIELDNO_MINIMALTUPLETABLESLOT_OFF 4
|
286
|
+
uint32 off; /* saved state for slot_deform_heap_tuple */
|
287
|
+
} MinimalTupleTableSlot;
|
288
|
+
|
289
|
+
/*
|
290
|
+
* TupIsNull -- is a TupleTableSlot empty?
|
291
|
+
*/
|
292
|
+
#define TupIsNull(slot) \
|
293
|
+
((slot) == NULL || TTS_EMPTY(slot))
|
294
|
+
|
295
|
+
/* in executor/execTuples.c */
|
296
|
+
extern TupleTableSlot *MakeTupleTableSlot(TupleDesc tupleDesc,
|
297
|
+
const TupleTableSlotOps *tts_ops);
|
298
|
+
extern TupleTableSlot *ExecAllocTableSlot(List **tupleTable, TupleDesc desc,
|
299
|
+
const TupleTableSlotOps *tts_ops);
|
300
|
+
extern void ExecResetTupleTable(List *tupleTable, bool shouldFree);
|
301
|
+
extern TupleTableSlot *MakeSingleTupleTableSlot(TupleDesc tupdesc,
|
302
|
+
const TupleTableSlotOps *tts_ops);
|
303
|
+
extern void ExecDropSingleTupleTableSlot(TupleTableSlot *slot);
|
304
|
+
extern void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc);
|
305
|
+
extern TupleTableSlot *ExecStoreHeapTuple(HeapTuple tuple,
|
306
|
+
TupleTableSlot *slot,
|
307
|
+
bool shouldFree);
|
308
|
+
extern void ExecForceStoreHeapTuple(HeapTuple tuple,
|
309
|
+
TupleTableSlot *slot,
|
310
|
+
bool shouldFree);
|
311
|
+
extern TupleTableSlot *ExecStoreBufferHeapTuple(HeapTuple tuple,
|
312
|
+
TupleTableSlot *slot,
|
313
|
+
Buffer buffer);
|
314
|
+
extern TupleTableSlot *ExecStorePinnedBufferHeapTuple(HeapTuple tuple,
|
315
|
+
TupleTableSlot *slot,
|
316
|
+
Buffer buffer);
|
317
|
+
extern TupleTableSlot *ExecStoreMinimalTuple(MinimalTuple mtup,
|
318
|
+
TupleTableSlot *slot,
|
319
|
+
bool shouldFree);
|
320
|
+
extern void ExecForceStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot,
|
321
|
+
bool shouldFree);
|
322
|
+
extern TupleTableSlot *ExecStoreVirtualTuple(TupleTableSlot *slot);
|
323
|
+
extern TupleTableSlot *ExecStoreAllNullTuple(TupleTableSlot *slot);
|
324
|
+
extern void ExecStoreHeapTupleDatum(Datum data, TupleTableSlot *slot);
|
325
|
+
extern HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree);
|
326
|
+
extern MinimalTuple ExecFetchSlotMinimalTuple(TupleTableSlot *slot,
|
327
|
+
bool *shouldFree);
|
328
|
+
extern Datum ExecFetchSlotHeapTupleDatum(TupleTableSlot *slot);
|
329
|
+
extern void slot_getmissingattrs(TupleTableSlot *slot, int startAttNum,
|
330
|
+
int lastAttNum);
|
331
|
+
extern void slot_getsomeattrs_int(TupleTableSlot *slot, int attnum);
|
332
|
+
|
333
|
+
|
334
|
+
#ifndef FRONTEND
|
335
|
+
|
336
|
+
/*
|
337
|
+
* This function forces the entries of the slot's Datum/isnull arrays to be
|
338
|
+
* valid at least up through the attnum'th entry.
|
339
|
+
*/
|
340
|
+
static inline void
|
341
|
+
slot_getsomeattrs(TupleTableSlot *slot, int attnum)
|
342
|
+
{
|
343
|
+
if (slot->tts_nvalid < attnum)
|
344
|
+
slot_getsomeattrs_int(slot, attnum);
|
345
|
+
}
|
346
|
+
|
347
|
+
/*
|
348
|
+
* slot_getallattrs
|
349
|
+
* This function forces all the entries of the slot's Datum/isnull
|
350
|
+
* arrays to be valid. The caller may then extract data directly
|
351
|
+
* from those arrays instead of using slot_getattr.
|
352
|
+
*/
|
353
|
+
static inline void
|
354
|
+
slot_getallattrs(TupleTableSlot *slot)
|
355
|
+
{
|
356
|
+
slot_getsomeattrs(slot, slot->tts_tupleDescriptor->natts);
|
357
|
+
}
|
358
|
+
|
359
|
+
|
360
|
+
/*
|
361
|
+
* slot_attisnull
|
362
|
+
*
|
363
|
+
* Detect whether an attribute of the slot is null, without actually fetching
|
364
|
+
* it.
|
365
|
+
*/
|
366
|
+
static inline bool
|
367
|
+
slot_attisnull(TupleTableSlot *slot, int attnum)
|
368
|
+
{
|
369
|
+
AssertArg(attnum > 0);
|
370
|
+
|
371
|
+
if (attnum > slot->tts_nvalid)
|
372
|
+
slot_getsomeattrs(slot, attnum);
|
373
|
+
|
374
|
+
return slot->tts_isnull[attnum - 1];
|
375
|
+
}
|
376
|
+
|
377
|
+
/*
|
378
|
+
* slot_getattr - fetch one attribute of the slot's contents.
|
379
|
+
*/
|
380
|
+
static inline Datum
|
381
|
+
slot_getattr(TupleTableSlot *slot, int attnum,
|
382
|
+
bool *isnull)
|
383
|
+
{
|
384
|
+
AssertArg(attnum > 0);
|
385
|
+
|
386
|
+
if (attnum > slot->tts_nvalid)
|
387
|
+
slot_getsomeattrs(slot, attnum);
|
388
|
+
|
389
|
+
*isnull = slot->tts_isnull[attnum - 1];
|
390
|
+
|
391
|
+
return slot->tts_values[attnum - 1];
|
392
|
+
}
|
393
|
+
|
394
|
+
/*
|
395
|
+
* slot_getsysattr - fetch a system attribute of the slot's current tuple.
|
396
|
+
*
|
397
|
+
* If the slot type does not contain system attributes, this will throw an
|
398
|
+
* error. Hence before calling this function, callers should make sure that
|
399
|
+
* the slot type is the one that supports system attributes.
|
400
|
+
*/
|
401
|
+
static inline Datum
|
402
|
+
slot_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
|
403
|
+
{
|
404
|
+
AssertArg(attnum < 0); /* caller error */
|
405
|
+
|
406
|
+
if (attnum == TableOidAttributeNumber)
|
407
|
+
{
|
408
|
+
*isnull = false;
|
409
|
+
return ObjectIdGetDatum(slot->tts_tableOid);
|
410
|
+
}
|
411
|
+
else if (attnum == SelfItemPointerAttributeNumber)
|
412
|
+
{
|
413
|
+
*isnull = false;
|
414
|
+
return PointerGetDatum(&slot->tts_tid);
|
415
|
+
}
|
416
|
+
|
417
|
+
/* Fetch the system attribute from the underlying tuple. */
|
418
|
+
return slot->tts_ops->getsysattr(slot, attnum, isnull);
|
419
|
+
}
|
420
|
+
|
421
|
+
/*
|
422
|
+
* ExecClearTuple - clear the slot's contents
|
423
|
+
*/
|
424
|
+
static inline TupleTableSlot *
|
425
|
+
ExecClearTuple(TupleTableSlot *slot)
|
426
|
+
{
|
427
|
+
slot->tts_ops->clear(slot);
|
428
|
+
|
429
|
+
return slot;
|
430
|
+
}
|
431
|
+
|
432
|
+
/* ExecMaterializeSlot - force a slot into the "materialized" state.
|
433
|
+
*
|
434
|
+
* This causes the slot's tuple to be a local copy not dependent on any
|
435
|
+
* external storage (i.e. pointing into a Buffer, or having allocations in
|
436
|
+
* another memory context).
|
437
|
+
*
|
438
|
+
* A typical use for this operation is to prepare a computed tuple for being
|
439
|
+
* stored on disk. The original data may or may not be virtual, but in any
|
440
|
+
* case we need a private copy for heap_insert to scribble on.
|
441
|
+
*/
|
442
|
+
static inline void
|
443
|
+
ExecMaterializeSlot(TupleTableSlot *slot)
|
444
|
+
{
|
445
|
+
slot->tts_ops->materialize(slot);
|
446
|
+
}
|
447
|
+
|
448
|
+
/*
|
449
|
+
* ExecCopySlotHeapTuple - return HeapTuple allocated in caller's context
|
450
|
+
*/
|
451
|
+
static inline HeapTuple
|
452
|
+
ExecCopySlotHeapTuple(TupleTableSlot *slot)
|
453
|
+
{
|
454
|
+
Assert(!TTS_EMPTY(slot));
|
455
|
+
|
456
|
+
return slot->tts_ops->copy_heap_tuple(slot);
|
457
|
+
}
|
458
|
+
|
459
|
+
/*
|
460
|
+
* ExecCopySlotMinimalTuple - return MinimalTuple allocated in caller's context
|
461
|
+
*/
|
462
|
+
static inline MinimalTuple
|
463
|
+
ExecCopySlotMinimalTuple(TupleTableSlot *slot)
|
464
|
+
{
|
465
|
+
return slot->tts_ops->copy_minimal_tuple(slot);
|
466
|
+
}
|
467
|
+
|
468
|
+
/*
|
469
|
+
* ExecCopySlot - copy one slot's contents into another.
|
470
|
+
*
|
471
|
+
* If a source's system attributes are supposed to be accessed in the target
|
472
|
+
* slot, the target slot and source slot types need to match.
|
473
|
+
*/
|
474
|
+
static inline TupleTableSlot *
|
475
|
+
ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
|
476
|
+
{
|
477
|
+
Assert(!TTS_EMPTY(srcslot));
|
478
|
+
AssertArg(srcslot != dstslot);
|
479
|
+
|
480
|
+
dstslot->tts_ops->copyslot(dstslot, srcslot);
|
481
|
+
|
482
|
+
return dstslot;
|
483
|
+
}
|
484
|
+
|
485
|
+
#endif /* FRONTEND */
|
486
|
+
|
487
|
+
#endif /* TUPTABLE_H */
|