gitlab-pg_query 1.3.1 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +217 -99
- data/README.md +92 -69
- data/Rakefile +85 -5
- data/ext/pg_query/extconf.rb +3 -40
- 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 +989 -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 +9959 -0
- data/ext/pg_query/pg_query_fingerprint.c +295 -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 +439 -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 +15 -1581
- data/lib/pg_query/filter_columns.rb +88 -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 -203
- 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 +71 -42
- data/lib/pg_query/version.rb +2 -2
- metadata +472 -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/deparse/keywords.rb +0 -159
- data/lib/pg_query/deparse/rename.rb +0 -41
- data/lib/pg_query/legacy_parsetree.rb +0 -109
- data/lib/pg_query/node_types.rb +0 -296
@@ -0,0 +1,158 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* snapmgr.h
|
4
|
+
* POSTGRES snapshot manager
|
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/utils/snapmgr.h
|
10
|
+
*
|
11
|
+
*-------------------------------------------------------------------------
|
12
|
+
*/
|
13
|
+
#ifndef SNAPMGR_H
|
14
|
+
#define SNAPMGR_H
|
15
|
+
|
16
|
+
#include "access/transam.h"
|
17
|
+
#include "utils/relcache.h"
|
18
|
+
#include "utils/resowner.h"
|
19
|
+
#include "utils/snapshot.h"
|
20
|
+
|
21
|
+
|
22
|
+
/*
|
23
|
+
* The structure used to map times to TransactionId values for the "snapshot
|
24
|
+
* too old" feature must have a few entries at the tail to hold old values;
|
25
|
+
* otherwise the lookup will often fail and the expected early pruning or
|
26
|
+
* vacuum will not usually occur. It is best if this padding is for a number
|
27
|
+
* of minutes greater than a thread would normally be stalled, but it's OK if
|
28
|
+
* early vacuum opportunities are occasionally missed, so there's no need to
|
29
|
+
* use an extreme value or get too fancy. 10 minutes seems plenty.
|
30
|
+
*/
|
31
|
+
#define OLD_SNAPSHOT_PADDING_ENTRIES 10
|
32
|
+
#define OLD_SNAPSHOT_TIME_MAP_ENTRIES (old_snapshot_threshold + OLD_SNAPSHOT_PADDING_ENTRIES)
|
33
|
+
|
34
|
+
/*
|
35
|
+
* Common definition of relation properties that allow early pruning/vacuuming
|
36
|
+
* when old_snapshot_threshold >= 0.
|
37
|
+
*/
|
38
|
+
#define RelationAllowsEarlyPruning(rel) \
|
39
|
+
( \
|
40
|
+
(rel)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT \
|
41
|
+
&& !IsCatalogRelation(rel) \
|
42
|
+
&& !RelationIsAccessibleInLogicalDecoding(rel) \
|
43
|
+
)
|
44
|
+
|
45
|
+
#define EarlyPruningEnabled(rel) (old_snapshot_threshold >= 0 && RelationAllowsEarlyPruning(rel))
|
46
|
+
|
47
|
+
/* GUC variables */
|
48
|
+
extern PGDLLIMPORT int old_snapshot_threshold;
|
49
|
+
|
50
|
+
|
51
|
+
extern Size SnapMgrShmemSize(void);
|
52
|
+
extern void SnapMgrInit(void);
|
53
|
+
extern TimestampTz GetSnapshotCurrentTimestamp(void);
|
54
|
+
extern TimestampTz GetOldSnapshotThresholdTimestamp(void);
|
55
|
+
|
56
|
+
extern bool FirstSnapshotSet;
|
57
|
+
|
58
|
+
extern PGDLLIMPORT TransactionId TransactionXmin;
|
59
|
+
extern PGDLLIMPORT TransactionId RecentXmin;
|
60
|
+
extern PGDLLIMPORT TransactionId RecentGlobalXmin;
|
61
|
+
extern PGDLLIMPORT TransactionId RecentGlobalDataXmin;
|
62
|
+
|
63
|
+
/* Variables representing various special snapshot semantics */
|
64
|
+
extern PGDLLIMPORT SnapshotData SnapshotSelfData;
|
65
|
+
extern PGDLLIMPORT SnapshotData SnapshotAnyData;
|
66
|
+
extern PGDLLIMPORT SnapshotData CatalogSnapshotData;
|
67
|
+
|
68
|
+
#define SnapshotSelf (&SnapshotSelfData)
|
69
|
+
#define SnapshotAny (&SnapshotAnyData)
|
70
|
+
|
71
|
+
/*
|
72
|
+
* We don't provide a static SnapshotDirty variable because it would be
|
73
|
+
* non-reentrant. Instead, users of that snapshot type should declare a
|
74
|
+
* local variable of type SnapshotData, and initialize it with this macro.
|
75
|
+
*/
|
76
|
+
#define InitDirtySnapshot(snapshotdata) \
|
77
|
+
((snapshotdata).snapshot_type = SNAPSHOT_DIRTY)
|
78
|
+
|
79
|
+
/*
|
80
|
+
* Similarly, some initialization is required for a NonVacuumable snapshot.
|
81
|
+
* The caller must supply the xmin horizon to use (e.g., RecentGlobalXmin).
|
82
|
+
*/
|
83
|
+
#define InitNonVacuumableSnapshot(snapshotdata, xmin_horizon) \
|
84
|
+
((snapshotdata).snapshot_type = SNAPSHOT_NON_VACUUMABLE, \
|
85
|
+
(snapshotdata).xmin = (xmin_horizon))
|
86
|
+
|
87
|
+
/*
|
88
|
+
* Similarly, some initialization is required for SnapshotToast. We need
|
89
|
+
* to set lsn and whenTaken correctly to support snapshot_too_old.
|
90
|
+
*/
|
91
|
+
#define InitToastSnapshot(snapshotdata, l, w) \
|
92
|
+
((snapshotdata).snapshot_type = SNAPSHOT_TOAST, \
|
93
|
+
(snapshotdata).lsn = (l), \
|
94
|
+
(snapshotdata).whenTaken = (w))
|
95
|
+
|
96
|
+
/* This macro encodes the knowledge of which snapshots are MVCC-safe */
|
97
|
+
#define IsMVCCSnapshot(snapshot) \
|
98
|
+
((snapshot)->snapshot_type == SNAPSHOT_MVCC || \
|
99
|
+
(snapshot)->snapshot_type == SNAPSHOT_HISTORIC_MVCC)
|
100
|
+
|
101
|
+
|
102
|
+
extern Snapshot GetTransactionSnapshot(void);
|
103
|
+
extern Snapshot GetLatestSnapshot(void);
|
104
|
+
extern void SnapshotSetCommandId(CommandId curcid);
|
105
|
+
extern Snapshot GetOldestSnapshot(void);
|
106
|
+
|
107
|
+
extern Snapshot GetCatalogSnapshot(Oid relid);
|
108
|
+
extern Snapshot GetNonHistoricCatalogSnapshot(Oid relid);
|
109
|
+
extern void InvalidateCatalogSnapshot(void);
|
110
|
+
extern void InvalidateCatalogSnapshotConditionally(void);
|
111
|
+
|
112
|
+
extern void PushActiveSnapshot(Snapshot snapshot);
|
113
|
+
extern void PushCopiedSnapshot(Snapshot snapshot);
|
114
|
+
extern void UpdateActiveSnapshotCommandId(void);
|
115
|
+
extern void PopActiveSnapshot(void);
|
116
|
+
extern Snapshot GetActiveSnapshot(void);
|
117
|
+
extern bool ActiveSnapshotSet(void);
|
118
|
+
|
119
|
+
extern Snapshot RegisterSnapshot(Snapshot snapshot);
|
120
|
+
extern void UnregisterSnapshot(Snapshot snapshot);
|
121
|
+
extern Snapshot RegisterSnapshotOnOwner(Snapshot snapshot, ResourceOwner owner);
|
122
|
+
extern void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner);
|
123
|
+
|
124
|
+
extern FullTransactionId GetFullRecentGlobalXmin(void);
|
125
|
+
|
126
|
+
extern void AtSubCommit_Snapshot(int level);
|
127
|
+
extern void AtSubAbort_Snapshot(int level);
|
128
|
+
extern void AtEOXact_Snapshot(bool isCommit, bool resetXmin);
|
129
|
+
|
130
|
+
extern void ImportSnapshot(const char *idstr);
|
131
|
+
extern bool XactHasExportedSnapshots(void);
|
132
|
+
extern void DeleteAllExportedSnapshotFiles(void);
|
133
|
+
extern bool ThereAreNoPriorRegisteredSnapshots(void);
|
134
|
+
extern TransactionId TransactionIdLimitedForOldSnapshots(TransactionId recentXmin,
|
135
|
+
Relation relation);
|
136
|
+
extern void MaintainOldSnapshotTimeMapping(TimestampTz whenTaken,
|
137
|
+
TransactionId xmin);
|
138
|
+
|
139
|
+
extern char *ExportSnapshot(Snapshot snapshot);
|
140
|
+
|
141
|
+
/*
|
142
|
+
* Utility functions for implementing visibility routines in table AMs.
|
143
|
+
*/
|
144
|
+
extern bool XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot);
|
145
|
+
|
146
|
+
/* Support for catalog timetravel for logical decoding */
|
147
|
+
struct HTAB;
|
148
|
+
extern struct HTAB *HistoricSnapshotGetTupleCids(void);
|
149
|
+
extern void SetupHistoricSnapshot(Snapshot snapshot_now, struct HTAB *tuplecids);
|
150
|
+
extern void TeardownHistoricSnapshot(bool is_error);
|
151
|
+
extern bool HistoricSnapshotActive(void);
|
152
|
+
|
153
|
+
extern Size EstimateSnapshotSpace(Snapshot snapshot);
|
154
|
+
extern void SerializeSnapshot(Snapshot snapshot, char *start_address);
|
155
|
+
extern Snapshot RestoreSnapshot(char *start_address);
|
156
|
+
extern void RestoreTransactionSnapshot(Snapshot snapshot, void *master_pgproc);
|
157
|
+
|
158
|
+
#endif /* SNAPMGR_H */
|
@@ -0,0 +1,206 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* snapshot.h
|
4
|
+
* POSTGRES snapshot definition
|
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/utils/snapshot.h
|
10
|
+
*
|
11
|
+
*-------------------------------------------------------------------------
|
12
|
+
*/
|
13
|
+
#ifndef SNAPSHOT_H
|
14
|
+
#define SNAPSHOT_H
|
15
|
+
|
16
|
+
#include "access/htup.h"
|
17
|
+
#include "access/xlogdefs.h"
|
18
|
+
#include "datatype/timestamp.h"
|
19
|
+
#include "lib/pairingheap.h"
|
20
|
+
#include "storage/buf.h"
|
21
|
+
|
22
|
+
|
23
|
+
/*
|
24
|
+
* The different snapshot types. We use SnapshotData structures to represent
|
25
|
+
* both "regular" (MVCC) snapshots and "special" snapshots that have non-MVCC
|
26
|
+
* semantics. The specific semantics of a snapshot are encoded by its type.
|
27
|
+
*
|
28
|
+
* The behaviour of each type of snapshot should be documented alongside its
|
29
|
+
* enum value, best in terms that are not specific to an individual table AM.
|
30
|
+
*
|
31
|
+
* The reason the snapshot type rather than a callback as it used to be is
|
32
|
+
* that that allows to use the same snapshot for different table AMs without
|
33
|
+
* having one callback per AM.
|
34
|
+
*/
|
35
|
+
typedef enum SnapshotType
|
36
|
+
{
|
37
|
+
/*-------------------------------------------------------------------------
|
38
|
+
* A tuple is visible iff the tuple is valid for the given MVCC snapshot.
|
39
|
+
*
|
40
|
+
* Here, we consider the effects of:
|
41
|
+
* - all transactions committed as of the time of the given snapshot
|
42
|
+
* - previous commands of this transaction
|
43
|
+
*
|
44
|
+
* Does _not_ include:
|
45
|
+
* - transactions shown as in-progress by the snapshot
|
46
|
+
* - transactions started after the snapshot was taken
|
47
|
+
* - changes made by the current command
|
48
|
+
* -------------------------------------------------------------------------
|
49
|
+
*/
|
50
|
+
SNAPSHOT_MVCC = 0,
|
51
|
+
|
52
|
+
/*-------------------------------------------------------------------------
|
53
|
+
* A tuple is visible iff the tuple is valid "for itself".
|
54
|
+
*
|
55
|
+
* Here, we consider the effects of:
|
56
|
+
* - all committed transactions (as of the current instant)
|
57
|
+
* - previous commands of this transaction
|
58
|
+
* - changes made by the current command
|
59
|
+
*
|
60
|
+
* Does _not_ include:
|
61
|
+
* - in-progress transactions (as of the current instant)
|
62
|
+
* -------------------------------------------------------------------------
|
63
|
+
*/
|
64
|
+
SNAPSHOT_SELF,
|
65
|
+
|
66
|
+
/*
|
67
|
+
* Any tuple is visible.
|
68
|
+
*/
|
69
|
+
SNAPSHOT_ANY,
|
70
|
+
|
71
|
+
/*
|
72
|
+
* A tuple is visible iff the tuple is valid as a TOAST row.
|
73
|
+
*/
|
74
|
+
SNAPSHOT_TOAST,
|
75
|
+
|
76
|
+
/*-------------------------------------------------------------------------
|
77
|
+
* A tuple is visible iff the tuple is valid including effects of open
|
78
|
+
* transactions.
|
79
|
+
*
|
80
|
+
* Here, we consider the effects of:
|
81
|
+
* - all committed and in-progress transactions (as of the current instant)
|
82
|
+
* - previous commands of this transaction
|
83
|
+
* - changes made by the current command
|
84
|
+
*
|
85
|
+
* This is essentially like SNAPSHOT_SELF as far as effects of the current
|
86
|
+
* transaction and committed/aborted xacts are concerned. However, it
|
87
|
+
* also includes the effects of other xacts still in progress.
|
88
|
+
*
|
89
|
+
* A special hack is that when a snapshot of this type is used to
|
90
|
+
* determine tuple visibility, the passed-in snapshot struct is used as an
|
91
|
+
* output argument to return the xids of concurrent xacts that affected
|
92
|
+
* the tuple. snapshot->xmin is set to the tuple's xmin if that is
|
93
|
+
* another transaction that's still in progress; or to
|
94
|
+
* InvalidTransactionId if the tuple's xmin is committed good, committed
|
95
|
+
* dead, or my own xact. Similarly for snapshot->xmax and the tuple's
|
96
|
+
* xmax. If the tuple was inserted speculatively, meaning that the
|
97
|
+
* inserter might still back down on the insertion without aborting the
|
98
|
+
* whole transaction, the associated token is also returned in
|
99
|
+
* snapshot->speculativeToken. See also InitDirtySnapshot().
|
100
|
+
* -------------------------------------------------------------------------
|
101
|
+
*/
|
102
|
+
SNAPSHOT_DIRTY,
|
103
|
+
|
104
|
+
/*
|
105
|
+
* A tuple is visible iff it follows the rules of SNAPSHOT_MVCC, but
|
106
|
+
* supports being called in timetravel context (for decoding catalog
|
107
|
+
* contents in the context of logical decoding).
|
108
|
+
*/
|
109
|
+
SNAPSHOT_HISTORIC_MVCC,
|
110
|
+
|
111
|
+
/*
|
112
|
+
* A tuple is visible iff the tuple might be visible to some transaction;
|
113
|
+
* false if it's surely dead to everyone, i.e., vacuumable.
|
114
|
+
*
|
115
|
+
* For visibility checks snapshot->min must have been set up with the xmin
|
116
|
+
* horizon to use.
|
117
|
+
*/
|
118
|
+
SNAPSHOT_NON_VACUUMABLE
|
119
|
+
} SnapshotType;
|
120
|
+
|
121
|
+
typedef struct SnapshotData *Snapshot;
|
122
|
+
|
123
|
+
#define InvalidSnapshot ((Snapshot) NULL)
|
124
|
+
|
125
|
+
/*
|
126
|
+
* Struct representing all kind of possible snapshots.
|
127
|
+
*
|
128
|
+
* There are several different kinds of snapshots:
|
129
|
+
* * Normal MVCC snapshots
|
130
|
+
* * MVCC snapshots taken during recovery (in Hot-Standby mode)
|
131
|
+
* * Historic MVCC snapshots used during logical decoding
|
132
|
+
* * snapshots passed to HeapTupleSatisfiesDirty()
|
133
|
+
* * snapshots passed to HeapTupleSatisfiesNonVacuumable()
|
134
|
+
* * snapshots used for SatisfiesAny, Toast, Self where no members are
|
135
|
+
* accessed.
|
136
|
+
*
|
137
|
+
* TODO: It's probably a good idea to split this struct using a NodeTag
|
138
|
+
* similar to how parser and executor nodes are handled, with one type for
|
139
|
+
* each different kind of snapshot to avoid overloading the meaning of
|
140
|
+
* individual fields.
|
141
|
+
*/
|
142
|
+
typedef struct SnapshotData
|
143
|
+
{
|
144
|
+
SnapshotType snapshot_type; /* type of snapshot */
|
145
|
+
|
146
|
+
/*
|
147
|
+
* The remaining fields are used only for MVCC snapshots, and are normally
|
148
|
+
* just zeroes in special snapshots. (But xmin and xmax are used
|
149
|
+
* specially by HeapTupleSatisfiesDirty, and xmin is used specially by
|
150
|
+
* HeapTupleSatisfiesNonVacuumable.)
|
151
|
+
*
|
152
|
+
* An MVCC snapshot can never see the effects of XIDs >= xmax. It can see
|
153
|
+
* the effects of all older XIDs except those listed in the snapshot. xmin
|
154
|
+
* is stored as an optimization to avoid needing to search the XID arrays
|
155
|
+
* for most tuples.
|
156
|
+
*/
|
157
|
+
TransactionId xmin; /* all XID < xmin are visible to me */
|
158
|
+
TransactionId xmax; /* all XID >= xmax are invisible to me */
|
159
|
+
|
160
|
+
/*
|
161
|
+
* For normal MVCC snapshot this contains the all xact IDs that are in
|
162
|
+
* progress, unless the snapshot was taken during recovery in which case
|
163
|
+
* it's empty. For historic MVCC snapshots, the meaning is inverted, i.e.
|
164
|
+
* it contains *committed* transactions between xmin and xmax.
|
165
|
+
*
|
166
|
+
* note: all ids in xip[] satisfy xmin <= xip[i] < xmax
|
167
|
+
*/
|
168
|
+
TransactionId *xip;
|
169
|
+
uint32 xcnt; /* # of xact ids in xip[] */
|
170
|
+
|
171
|
+
/*
|
172
|
+
* For non-historic MVCC snapshots, this contains subxact IDs that are in
|
173
|
+
* progress (and other transactions that are in progress if taken during
|
174
|
+
* recovery). For historic snapshot it contains *all* xids assigned to the
|
175
|
+
* replayed transaction, including the toplevel xid.
|
176
|
+
*
|
177
|
+
* note: all ids in subxip[] are >= xmin, but we don't bother filtering
|
178
|
+
* out any that are >= xmax
|
179
|
+
*/
|
180
|
+
TransactionId *subxip;
|
181
|
+
int32 subxcnt; /* # of xact ids in subxip[] */
|
182
|
+
bool suboverflowed; /* has the subxip array overflowed? */
|
183
|
+
|
184
|
+
bool takenDuringRecovery; /* recovery-shaped snapshot? */
|
185
|
+
bool copied; /* false if it's a static snapshot */
|
186
|
+
|
187
|
+
CommandId curcid; /* in my xact, CID < curcid are visible */
|
188
|
+
|
189
|
+
/*
|
190
|
+
* An extra return value for HeapTupleSatisfiesDirty, not used in MVCC
|
191
|
+
* snapshots.
|
192
|
+
*/
|
193
|
+
uint32 speculativeToken;
|
194
|
+
|
195
|
+
/*
|
196
|
+
* Book-keeping information, used by the snapshot manager
|
197
|
+
*/
|
198
|
+
uint32 active_count; /* refcount on ActiveSnapshot stack */
|
199
|
+
uint32 regd_count; /* refcount on RegisteredSnapshots */
|
200
|
+
pairingheap_node ph_node; /* link in the RegisteredSnapshots heap */
|
201
|
+
|
202
|
+
TimestampTz whenTaken; /* timestamp when snapshot was taken */
|
203
|
+
XLogRecPtr lsn; /* position in the WAL stream when taken */
|
204
|
+
} SnapshotData;
|
205
|
+
|
206
|
+
#endif /* SNAPSHOT_H */
|
@@ -0,0 +1,276 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* sortsupport.h
|
4
|
+
* Framework for accelerated sorting.
|
5
|
+
*
|
6
|
+
* Traditionally, PostgreSQL has implemented sorting by repeatedly invoking
|
7
|
+
* an SQL-callable comparison function "cmp(x, y) returns int" on pairs of
|
8
|
+
* values to be compared, where the comparison function is the BTORDER_PROC
|
9
|
+
* pg_amproc support function of the appropriate btree index opclass.
|
10
|
+
*
|
11
|
+
* This file defines alternative APIs that allow sorting to be performed with
|
12
|
+
* reduced overhead. To support lower-overhead sorting, a btree opclass may
|
13
|
+
* provide a BTSORTSUPPORT_PROC pg_amproc entry, which must take a single
|
14
|
+
* argument of type internal and return void. The argument is actually a
|
15
|
+
* pointer to a SortSupportData struct, which is defined below.
|
16
|
+
*
|
17
|
+
* If provided, the BTSORTSUPPORT function will be called during sort setup,
|
18
|
+
* and it must initialize the provided struct with pointers to function(s)
|
19
|
+
* that can be called to perform sorting. This API is defined to allow
|
20
|
+
* multiple acceleration mechanisms to be supported, but no opclass is
|
21
|
+
* required to provide all of them. The BTSORTSUPPORT function should
|
22
|
+
* simply not set any function pointers for mechanisms it doesn't support.
|
23
|
+
* Opclasses that provide BTSORTSUPPORT and don't provide a comparator
|
24
|
+
* function will have a shim set up by sort support automatically. However,
|
25
|
+
* opclasses that support the optional additional abbreviated key capability
|
26
|
+
* must always provide an authoritative comparator used to tie-break
|
27
|
+
* inconclusive abbreviated comparisons and also used when aborting
|
28
|
+
* abbreviation. Furthermore, a converter and abort/costing function must be
|
29
|
+
* provided.
|
30
|
+
*
|
31
|
+
* All sort support functions will be passed the address of the
|
32
|
+
* SortSupportData struct when called, so they can use it to store
|
33
|
+
* additional private data as needed. In particular, for collation-aware
|
34
|
+
* datatypes, the ssup_collation field is set before calling BTSORTSUPPORT
|
35
|
+
* and is available to all support functions. Additional opclass-dependent
|
36
|
+
* data can be stored using the ssup_extra field. Any such data
|
37
|
+
* should be allocated in the ssup_cxt memory context.
|
38
|
+
*
|
39
|
+
* Note: since pg_amproc functions are indexed by (lefttype, righttype)
|
40
|
+
* it is possible to associate a BTSORTSUPPORT function with a cross-type
|
41
|
+
* comparison. This could sensibly be used to provide a fast comparator
|
42
|
+
* function for such cases, but probably not any other acceleration method.
|
43
|
+
*
|
44
|
+
*
|
45
|
+
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
46
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
47
|
+
*
|
48
|
+
* src/include/utils/sortsupport.h
|
49
|
+
*
|
50
|
+
*-------------------------------------------------------------------------
|
51
|
+
*/
|
52
|
+
#ifndef SORTSUPPORT_H
|
53
|
+
#define SORTSUPPORT_H
|
54
|
+
|
55
|
+
#include "access/attnum.h"
|
56
|
+
#include "utils/relcache.h"
|
57
|
+
|
58
|
+
typedef struct SortSupportData *SortSupport;
|
59
|
+
|
60
|
+
typedef struct SortSupportData
|
61
|
+
{
|
62
|
+
/*
|
63
|
+
* These fields are initialized before calling the BTSORTSUPPORT function
|
64
|
+
* and should not be changed later.
|
65
|
+
*/
|
66
|
+
MemoryContext ssup_cxt; /* Context containing sort info */
|
67
|
+
Oid ssup_collation; /* Collation to use, or InvalidOid */
|
68
|
+
|
69
|
+
/*
|
70
|
+
* Additional sorting parameters; but unlike ssup_collation, these can be
|
71
|
+
* changed after BTSORTSUPPORT is called, so don't use them in selecting
|
72
|
+
* sort support functions.
|
73
|
+
*/
|
74
|
+
bool ssup_reverse; /* descending-order sort? */
|
75
|
+
bool ssup_nulls_first; /* sort nulls first? */
|
76
|
+
|
77
|
+
/*
|
78
|
+
* These fields are workspace for callers, and should not be touched by
|
79
|
+
* opclass-specific functions.
|
80
|
+
*/
|
81
|
+
AttrNumber ssup_attno; /* column number to sort */
|
82
|
+
|
83
|
+
/*
|
84
|
+
* ssup_extra is zeroed before calling the BTSORTSUPPORT function, and is
|
85
|
+
* not touched subsequently by callers.
|
86
|
+
*/
|
87
|
+
void *ssup_extra; /* Workspace for opclass functions */
|
88
|
+
|
89
|
+
/*
|
90
|
+
* Function pointers are zeroed before calling the BTSORTSUPPORT function,
|
91
|
+
* and must be set by it for any acceleration methods it wants to supply.
|
92
|
+
* The comparator pointer must be set, others are optional.
|
93
|
+
*/
|
94
|
+
|
95
|
+
/*
|
96
|
+
* Comparator function has the same API as the traditional btree
|
97
|
+
* comparison function, ie, return <0, 0, or >0 according as x is less
|
98
|
+
* than, equal to, or greater than y. Note that x and y are guaranteed
|
99
|
+
* not null, and there is no way to return null either.
|
100
|
+
*
|
101
|
+
* This may be either the authoritative comparator, or the abbreviated
|
102
|
+
* comparator. Core code may switch this over the initial preference of
|
103
|
+
* an opclass support function despite originally indicating abbreviation
|
104
|
+
* was applicable, by assigning the authoritative comparator back.
|
105
|
+
*/
|
106
|
+
int (*comparator) (Datum x, Datum y, SortSupport ssup);
|
107
|
+
|
108
|
+
/*
|
109
|
+
* "Abbreviated key" infrastructure follows.
|
110
|
+
*
|
111
|
+
* All callbacks must be set by sortsupport opclasses that make use of
|
112
|
+
* this optional additional infrastructure (unless for whatever reasons
|
113
|
+
* the opclass doesn't proceed with abbreviation, in which case
|
114
|
+
* abbrev_converter must not be set).
|
115
|
+
*
|
116
|
+
* This allows opclass authors to supply a conversion routine, used to
|
117
|
+
* create an alternative representation of the underlying type (an
|
118
|
+
* "abbreviated key"). This representation must be pass-by-value and
|
119
|
+
* typically will use some ad-hoc format that only the opclass has
|
120
|
+
* knowledge of. An alternative comparator, used only with this
|
121
|
+
* alternative representation must also be provided (which is assigned to
|
122
|
+
* "comparator"). This representation is a simple approximation of the
|
123
|
+
* original Datum. It must be possible to compare datums of this
|
124
|
+
* representation with each other using the supplied alternative
|
125
|
+
* comparator, and have any non-zero return value be a reliable proxy for
|
126
|
+
* what a proper comparison would indicate. Returning zero from the
|
127
|
+
* alternative comparator does not indicate equality, as with a
|
128
|
+
* conventional support routine 1, though -- it indicates that it wasn't
|
129
|
+
* possible to determine how the two abbreviated values compared. A
|
130
|
+
* proper comparison, using "abbrev_full_comparator"/
|
131
|
+
* ApplySortAbbrevFullComparator() is therefore required. In many cases
|
132
|
+
* this results in most or all comparisons only using the cheap
|
133
|
+
* alternative comparison func, which is typically implemented as code
|
134
|
+
* that compiles to just a few CPU instructions. CPU cache miss penalties
|
135
|
+
* are expensive; to get good overall performance, sort infrastructure
|
136
|
+
* must heavily weigh cache performance.
|
137
|
+
*
|
138
|
+
* Opclass authors must consider the final cardinality of abbreviated keys
|
139
|
+
* when devising an encoding scheme. It's possible for a strategy to work
|
140
|
+
* better than an alternative strategy with one usage pattern, while the
|
141
|
+
* reverse might be true for another usage pattern. All of these factors
|
142
|
+
* must be considered.
|
143
|
+
*/
|
144
|
+
|
145
|
+
/*
|
146
|
+
* "abbreviate" concerns whether or not the abbreviated key optimization
|
147
|
+
* is applicable in principle (that is, the sortsupport routine needs to
|
148
|
+
* know if its dealing with a key where an abbreviated representation can
|
149
|
+
* usefully be packed together. Conventionally, this is the leading
|
150
|
+
* attribute key). Note, however, that in order to determine that
|
151
|
+
* abbreviation is not in play, the core code always checks whether or not
|
152
|
+
* the opclass has set abbrev_converter. This is a one way, one time
|
153
|
+
* message to the opclass.
|
154
|
+
*/
|
155
|
+
bool abbreviate;
|
156
|
+
|
157
|
+
/*
|
158
|
+
* Converter to abbreviated format, from original representation. Core
|
159
|
+
* code uses this callback to convert from a pass-by-reference "original"
|
160
|
+
* Datum to a pass-by-value abbreviated key Datum. Note that original is
|
161
|
+
* guaranteed NOT NULL, because it doesn't make sense to factor NULLness
|
162
|
+
* into ad-hoc cost model.
|
163
|
+
*
|
164
|
+
* abbrev_converter is tested to see if abbreviation is in play. Core
|
165
|
+
* code may set it to NULL to indicate abbreviation should not be used
|
166
|
+
* (which is something sortsupport routines need not concern themselves
|
167
|
+
* with). However, sortsupport routines must not set it when it is
|
168
|
+
* immediately established that abbreviation should not proceed (e.g., for
|
169
|
+
* !abbreviate calls, or due to platform-specific impediments to using
|
170
|
+
* abbreviation).
|
171
|
+
*/
|
172
|
+
Datum (*abbrev_converter) (Datum original, SortSupport ssup);
|
173
|
+
|
174
|
+
/*
|
175
|
+
* abbrev_abort callback allows clients to verify that the current
|
176
|
+
* strategy is working out, using a sortsupport routine defined ad-hoc
|
177
|
+
* cost model. If there is a lot of duplicate abbreviated keys in
|
178
|
+
* practice, it's useful to be able to abandon the strategy before paying
|
179
|
+
* too high a cost in conversion (perhaps certain opclass-specific
|
180
|
+
* adaptations are useful too).
|
181
|
+
*/
|
182
|
+
bool (*abbrev_abort) (int memtupcount, SortSupport ssup);
|
183
|
+
|
184
|
+
/*
|
185
|
+
* Full, authoritative comparator for key that an abbreviated
|
186
|
+
* representation was generated for, used when an abbreviated comparison
|
187
|
+
* was inconclusive (by calling ApplySortAbbrevFullComparator()), or used
|
188
|
+
* to replace "comparator" when core system ultimately decides against
|
189
|
+
* abbreviation.
|
190
|
+
*/
|
191
|
+
int (*abbrev_full_comparator) (Datum x, Datum y, SortSupport ssup);
|
192
|
+
} SortSupportData;
|
193
|
+
|
194
|
+
|
195
|
+
/*
|
196
|
+
* Apply a sort comparator function and return a 3-way comparison result.
|
197
|
+
* This takes care of handling reverse-sort and NULLs-ordering properly.
|
198
|
+
*/
|
199
|
+
static inline int
|
200
|
+
ApplySortComparator(Datum datum1, bool isNull1,
|
201
|
+
Datum datum2, bool isNull2,
|
202
|
+
SortSupport ssup)
|
203
|
+
{
|
204
|
+
int compare;
|
205
|
+
|
206
|
+
if (isNull1)
|
207
|
+
{
|
208
|
+
if (isNull2)
|
209
|
+
compare = 0; /* NULL "=" NULL */
|
210
|
+
else if (ssup->ssup_nulls_first)
|
211
|
+
compare = -1; /* NULL "<" NOT_NULL */
|
212
|
+
else
|
213
|
+
compare = 1; /* NULL ">" NOT_NULL */
|
214
|
+
}
|
215
|
+
else if (isNull2)
|
216
|
+
{
|
217
|
+
if (ssup->ssup_nulls_first)
|
218
|
+
compare = 1; /* NOT_NULL ">" NULL */
|
219
|
+
else
|
220
|
+
compare = -1; /* NOT_NULL "<" NULL */
|
221
|
+
}
|
222
|
+
else
|
223
|
+
{
|
224
|
+
compare = ssup->comparator(datum1, datum2, ssup);
|
225
|
+
if (ssup->ssup_reverse)
|
226
|
+
INVERT_COMPARE_RESULT(compare);
|
227
|
+
}
|
228
|
+
|
229
|
+
return compare;
|
230
|
+
}
|
231
|
+
|
232
|
+
/*
|
233
|
+
* Apply a sort comparator function and return a 3-way comparison using full,
|
234
|
+
* authoritative comparator. This takes care of handling reverse-sort and
|
235
|
+
* NULLs-ordering properly.
|
236
|
+
*/
|
237
|
+
static inline int
|
238
|
+
ApplySortAbbrevFullComparator(Datum datum1, bool isNull1,
|
239
|
+
Datum datum2, bool isNull2,
|
240
|
+
SortSupport ssup)
|
241
|
+
{
|
242
|
+
int compare;
|
243
|
+
|
244
|
+
if (isNull1)
|
245
|
+
{
|
246
|
+
if (isNull2)
|
247
|
+
compare = 0; /* NULL "=" NULL */
|
248
|
+
else if (ssup->ssup_nulls_first)
|
249
|
+
compare = -1; /* NULL "<" NOT_NULL */
|
250
|
+
else
|
251
|
+
compare = 1; /* NULL ">" NOT_NULL */
|
252
|
+
}
|
253
|
+
else if (isNull2)
|
254
|
+
{
|
255
|
+
if (ssup->ssup_nulls_first)
|
256
|
+
compare = 1; /* NOT_NULL ">" NULL */
|
257
|
+
else
|
258
|
+
compare = -1; /* NOT_NULL "<" NULL */
|
259
|
+
}
|
260
|
+
else
|
261
|
+
{
|
262
|
+
compare = ssup->abbrev_full_comparator(datum1, datum2, ssup);
|
263
|
+
if (ssup->ssup_reverse)
|
264
|
+
INVERT_COMPARE_RESULT(compare);
|
265
|
+
}
|
266
|
+
|
267
|
+
return compare;
|
268
|
+
}
|
269
|
+
|
270
|
+
/* Other functions in utils/sort/sortsupport.c */
|
271
|
+
extern void PrepareSortSupportComparisonShim(Oid cmpFunc, SortSupport ssup);
|
272
|
+
extern void PrepareSortSupportFromOrderingOp(Oid orderingOp, SortSupport ssup);
|
273
|
+
extern void PrepareSortSupportFromIndexRel(Relation indexRel, int16 strategy,
|
274
|
+
SortSupport ssup);
|
275
|
+
|
276
|
+
#endif /* SORTSUPPORT_H */
|