gitlab-pg_query 1.3.1 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,292 @@
|
|
|
1
|
+
/*-------------------------------------------------------------------------
|
|
2
|
+
*
|
|
3
|
+
* bufmgr.h
|
|
4
|
+
* POSTGRES buffer manager definitions.
|
|
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/storage/bufmgr.h
|
|
11
|
+
*
|
|
12
|
+
*-------------------------------------------------------------------------
|
|
13
|
+
*/
|
|
14
|
+
#ifndef BUFMGR_H
|
|
15
|
+
#define BUFMGR_H
|
|
16
|
+
|
|
17
|
+
#include "storage/block.h"
|
|
18
|
+
#include "storage/buf.h"
|
|
19
|
+
#include "storage/bufpage.h"
|
|
20
|
+
#include "storage/relfilenode.h"
|
|
21
|
+
#include "utils/relcache.h"
|
|
22
|
+
#include "utils/snapmgr.h"
|
|
23
|
+
|
|
24
|
+
typedef void *Block;
|
|
25
|
+
|
|
26
|
+
/* Possible arguments for GetAccessStrategy() */
|
|
27
|
+
typedef enum BufferAccessStrategyType
|
|
28
|
+
{
|
|
29
|
+
BAS_NORMAL, /* Normal random access */
|
|
30
|
+
BAS_BULKREAD, /* Large read-only scan (hint bit updates are
|
|
31
|
+
* ok) */
|
|
32
|
+
BAS_BULKWRITE, /* Large multi-block write (e.g. COPY IN) */
|
|
33
|
+
BAS_VACUUM /* VACUUM */
|
|
34
|
+
} BufferAccessStrategyType;
|
|
35
|
+
|
|
36
|
+
/* Possible modes for ReadBufferExtended() */
|
|
37
|
+
typedef enum
|
|
38
|
+
{
|
|
39
|
+
RBM_NORMAL, /* Normal read */
|
|
40
|
+
RBM_ZERO_AND_LOCK, /* Don't read from disk, caller will
|
|
41
|
+
* initialize. Also locks the page. */
|
|
42
|
+
RBM_ZERO_AND_CLEANUP_LOCK, /* Like RBM_ZERO_AND_LOCK, but locks the page
|
|
43
|
+
* in "cleanup" mode */
|
|
44
|
+
RBM_ZERO_ON_ERROR, /* Read, but return an all-zeros page on error */
|
|
45
|
+
RBM_NORMAL_NO_LOG /* Don't log page as invalid during WAL
|
|
46
|
+
* replay; otherwise same as RBM_NORMAL */
|
|
47
|
+
} ReadBufferMode;
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* Type returned by PrefetchBuffer().
|
|
51
|
+
*/
|
|
52
|
+
typedef struct PrefetchBufferResult
|
|
53
|
+
{
|
|
54
|
+
Buffer recent_buffer; /* If valid, a hit (recheck needed!) */
|
|
55
|
+
bool initiated_io; /* If true, a miss resulting in async I/O */
|
|
56
|
+
} PrefetchBufferResult;
|
|
57
|
+
|
|
58
|
+
/* forward declared, to avoid having to expose buf_internals.h here */
|
|
59
|
+
struct WritebackContext;
|
|
60
|
+
|
|
61
|
+
/* forward declared, to avoid including smgr.h here */
|
|
62
|
+
struct SMgrRelationData;
|
|
63
|
+
|
|
64
|
+
/* in globals.c ... this duplicates miscadmin.h */
|
|
65
|
+
extern PGDLLIMPORT int NBuffers;
|
|
66
|
+
|
|
67
|
+
/* in bufmgr.c */
|
|
68
|
+
extern bool zero_damaged_pages;
|
|
69
|
+
extern int bgwriter_lru_maxpages;
|
|
70
|
+
extern double bgwriter_lru_multiplier;
|
|
71
|
+
extern bool track_io_timing;
|
|
72
|
+
extern int effective_io_concurrency;
|
|
73
|
+
extern int maintenance_io_concurrency;
|
|
74
|
+
|
|
75
|
+
extern int checkpoint_flush_after;
|
|
76
|
+
extern int backend_flush_after;
|
|
77
|
+
extern int bgwriter_flush_after;
|
|
78
|
+
|
|
79
|
+
/* in buf_init.c */
|
|
80
|
+
extern PGDLLIMPORT char *BufferBlocks;
|
|
81
|
+
|
|
82
|
+
/* in localbuf.c */
|
|
83
|
+
extern PGDLLIMPORT int NLocBuffer;
|
|
84
|
+
extern PGDLLIMPORT Block *LocalBufferBlockPointers;
|
|
85
|
+
extern PGDLLIMPORT int32 *LocalRefCount;
|
|
86
|
+
|
|
87
|
+
/* upper limit for effective_io_concurrency */
|
|
88
|
+
#define MAX_IO_CONCURRENCY 1000
|
|
89
|
+
|
|
90
|
+
/* special block number for ReadBuffer() */
|
|
91
|
+
#define P_NEW InvalidBlockNumber /* grow the file to get a new page */
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
* Buffer content lock modes (mode argument for LockBuffer())
|
|
95
|
+
*/
|
|
96
|
+
#define BUFFER_LOCK_UNLOCK 0
|
|
97
|
+
#define BUFFER_LOCK_SHARE 1
|
|
98
|
+
#define BUFFER_LOCK_EXCLUSIVE 2
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
* These routines are beaten on quite heavily, hence the macroization.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* BufferIsValid
|
|
106
|
+
* True iff the given buffer number is valid (either as a shared
|
|
107
|
+
* or local buffer).
|
|
108
|
+
*
|
|
109
|
+
* Note: For a long time this was defined the same as BufferIsPinned,
|
|
110
|
+
* that is it would say False if you didn't hold a pin on the buffer.
|
|
111
|
+
* I believe this was bogus and served only to mask logic errors.
|
|
112
|
+
* Code should always know whether it has a buffer reference,
|
|
113
|
+
* independently of the pin state.
|
|
114
|
+
*
|
|
115
|
+
* Note: For a further long time this was not quite the inverse of the
|
|
116
|
+
* BufferIsInvalid() macro, in that it also did sanity checks to verify
|
|
117
|
+
* that the buffer number was in range. Most likely, this macro was
|
|
118
|
+
* originally intended only to be used in assertions, but its use has
|
|
119
|
+
* since expanded quite a bit, and the overhead of making those checks
|
|
120
|
+
* even in non-assert-enabled builds can be significant. Thus, we've
|
|
121
|
+
* now demoted the range checks to assertions within the macro itself.
|
|
122
|
+
*/
|
|
123
|
+
#define BufferIsValid(bufnum) \
|
|
124
|
+
( \
|
|
125
|
+
AssertMacro((bufnum) <= NBuffers && (bufnum) >= -NLocBuffer), \
|
|
126
|
+
(bufnum) != InvalidBuffer \
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* BufferGetBlock
|
|
131
|
+
* Returns a reference to a disk page image associated with a buffer.
|
|
132
|
+
*
|
|
133
|
+
* Note:
|
|
134
|
+
* Assumes buffer is valid.
|
|
135
|
+
*/
|
|
136
|
+
#define BufferGetBlock(buffer) \
|
|
137
|
+
( \
|
|
138
|
+
AssertMacro(BufferIsValid(buffer)), \
|
|
139
|
+
BufferIsLocal(buffer) ? \
|
|
140
|
+
LocalBufferBlockPointers[-(buffer) - 1] \
|
|
141
|
+
: \
|
|
142
|
+
(Block) (BufferBlocks + ((Size) ((buffer) - 1)) * BLCKSZ) \
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
/*
|
|
146
|
+
* BufferGetPageSize
|
|
147
|
+
* Returns the page size within a buffer.
|
|
148
|
+
*
|
|
149
|
+
* Notes:
|
|
150
|
+
* Assumes buffer is valid.
|
|
151
|
+
*
|
|
152
|
+
* The buffer can be a raw disk block and need not contain a valid
|
|
153
|
+
* (formatted) disk page.
|
|
154
|
+
*/
|
|
155
|
+
/* XXX should dig out of buffer descriptor */
|
|
156
|
+
#define BufferGetPageSize(buffer) \
|
|
157
|
+
( \
|
|
158
|
+
AssertMacro(BufferIsValid(buffer)), \
|
|
159
|
+
(Size)BLCKSZ \
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
/*
|
|
163
|
+
* BufferGetPage
|
|
164
|
+
* Returns the page associated with a buffer.
|
|
165
|
+
*
|
|
166
|
+
* When this is called as part of a scan, there may be a need for a nearby
|
|
167
|
+
* call to TestForOldSnapshot(). See the definition of that for details.
|
|
168
|
+
*/
|
|
169
|
+
#define BufferGetPage(buffer) ((Page)BufferGetBlock(buffer))
|
|
170
|
+
|
|
171
|
+
/*
|
|
172
|
+
* prototypes for functions in bufmgr.c
|
|
173
|
+
*/
|
|
174
|
+
extern PrefetchBufferResult PrefetchSharedBuffer(struct SMgrRelationData *smgr_reln,
|
|
175
|
+
ForkNumber forkNum,
|
|
176
|
+
BlockNumber blockNum);
|
|
177
|
+
extern PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum,
|
|
178
|
+
BlockNumber blockNum);
|
|
179
|
+
extern Buffer ReadBuffer(Relation reln, BlockNumber blockNum);
|
|
180
|
+
extern Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum,
|
|
181
|
+
BlockNumber blockNum, ReadBufferMode mode,
|
|
182
|
+
BufferAccessStrategy strategy);
|
|
183
|
+
extern Buffer ReadBufferWithoutRelcache(RelFileNode rnode,
|
|
184
|
+
ForkNumber forkNum, BlockNumber blockNum,
|
|
185
|
+
ReadBufferMode mode, BufferAccessStrategy strategy);
|
|
186
|
+
extern void ReleaseBuffer(Buffer buffer);
|
|
187
|
+
extern void UnlockReleaseBuffer(Buffer buffer);
|
|
188
|
+
extern void MarkBufferDirty(Buffer buffer);
|
|
189
|
+
extern void IncrBufferRefCount(Buffer buffer);
|
|
190
|
+
extern Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation,
|
|
191
|
+
BlockNumber blockNum);
|
|
192
|
+
|
|
193
|
+
extern void InitBufferPool(void);
|
|
194
|
+
extern void InitBufferPoolAccess(void);
|
|
195
|
+
extern void InitBufferPoolBackend(void);
|
|
196
|
+
extern void AtEOXact_Buffers(bool isCommit);
|
|
197
|
+
extern void PrintBufferLeakWarning(Buffer buffer);
|
|
198
|
+
extern void CheckPointBuffers(int flags);
|
|
199
|
+
extern BlockNumber BufferGetBlockNumber(Buffer buffer);
|
|
200
|
+
extern BlockNumber RelationGetNumberOfBlocksInFork(Relation relation,
|
|
201
|
+
ForkNumber forkNum);
|
|
202
|
+
extern void FlushOneBuffer(Buffer buffer);
|
|
203
|
+
extern void FlushRelationBuffers(Relation rel);
|
|
204
|
+
extern void FlushRelationsAllBuffers(struct SMgrRelationData **smgrs, int nrels);
|
|
205
|
+
extern void FlushDatabaseBuffers(Oid dbid);
|
|
206
|
+
extern void DropRelFileNodeBuffers(RelFileNodeBackend rnode, ForkNumber *forkNum,
|
|
207
|
+
int nforks, BlockNumber *firstDelBlock);
|
|
208
|
+
extern void DropRelFileNodesAllBuffers(RelFileNodeBackend *rnodes, int nnodes);
|
|
209
|
+
extern void DropDatabaseBuffers(Oid dbid);
|
|
210
|
+
|
|
211
|
+
#define RelationGetNumberOfBlocks(reln) \
|
|
212
|
+
RelationGetNumberOfBlocksInFork(reln, MAIN_FORKNUM)
|
|
213
|
+
|
|
214
|
+
extern bool BufferIsPermanent(Buffer buffer);
|
|
215
|
+
extern XLogRecPtr BufferGetLSNAtomic(Buffer buffer);
|
|
216
|
+
|
|
217
|
+
#ifdef NOT_USED
|
|
218
|
+
extern void PrintPinnedBufs(void);
|
|
219
|
+
#endif
|
|
220
|
+
extern Size BufferShmemSize(void);
|
|
221
|
+
extern void BufferGetTag(Buffer buffer, RelFileNode *rnode,
|
|
222
|
+
ForkNumber *forknum, BlockNumber *blknum);
|
|
223
|
+
|
|
224
|
+
extern void MarkBufferDirtyHint(Buffer buffer, bool buffer_std);
|
|
225
|
+
|
|
226
|
+
extern void UnlockBuffers(void);
|
|
227
|
+
extern void LockBuffer(Buffer buffer, int mode);
|
|
228
|
+
extern bool ConditionalLockBuffer(Buffer buffer);
|
|
229
|
+
extern void LockBufferForCleanup(Buffer buffer);
|
|
230
|
+
extern bool ConditionalLockBufferForCleanup(Buffer buffer);
|
|
231
|
+
extern bool IsBufferCleanupOK(Buffer buffer);
|
|
232
|
+
extern bool HoldingBufferPinThatDelaysRecovery(void);
|
|
233
|
+
|
|
234
|
+
extern void AbortBufferIO(void);
|
|
235
|
+
|
|
236
|
+
extern void BufmgrCommit(void);
|
|
237
|
+
extern bool BgBufferSync(struct WritebackContext *wb_context);
|
|
238
|
+
|
|
239
|
+
extern void AtProcExit_LocalBuffers(void);
|
|
240
|
+
|
|
241
|
+
extern void TestForOldSnapshot_impl(Snapshot snapshot, Relation relation);
|
|
242
|
+
|
|
243
|
+
/* in freelist.c */
|
|
244
|
+
extern BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype);
|
|
245
|
+
extern void FreeAccessStrategy(BufferAccessStrategy strategy);
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
/* inline functions */
|
|
249
|
+
|
|
250
|
+
/*
|
|
251
|
+
* Although this header file is nominally backend-only, certain frontend
|
|
252
|
+
* programs like pg_waldump include it. For compilers that emit static
|
|
253
|
+
* inline functions even when they're unused, that leads to unsatisfied
|
|
254
|
+
* external references; hence hide these with #ifndef FRONTEND.
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
#ifndef FRONTEND
|
|
258
|
+
|
|
259
|
+
/*
|
|
260
|
+
* Check whether the given snapshot is too old to have safely read the given
|
|
261
|
+
* page from the given table. If so, throw a "snapshot too old" error.
|
|
262
|
+
*
|
|
263
|
+
* This test generally needs to be performed after every BufferGetPage() call
|
|
264
|
+
* that is executed as part of a scan. It is not needed for calls made for
|
|
265
|
+
* modifying the page (for example, to position to the right place to insert a
|
|
266
|
+
* new index tuple or for vacuuming). It may also be omitted where calls to
|
|
267
|
+
* lower-level functions will have already performed the test.
|
|
268
|
+
*
|
|
269
|
+
* Note that a NULL snapshot argument is allowed and causes a fast return
|
|
270
|
+
* without error; this is to support call sites which can be called from
|
|
271
|
+
* either scans or index modification areas.
|
|
272
|
+
*
|
|
273
|
+
* For best performance, keep the tests that are fastest and/or most likely to
|
|
274
|
+
* exclude a page from old snapshot testing near the front.
|
|
275
|
+
*/
|
|
276
|
+
static inline void
|
|
277
|
+
TestForOldSnapshot(Snapshot snapshot, Relation relation, Page page)
|
|
278
|
+
{
|
|
279
|
+
Assert(relation != NULL);
|
|
280
|
+
|
|
281
|
+
if (old_snapshot_threshold >= 0
|
|
282
|
+
&& (snapshot) != NULL
|
|
283
|
+
&& ((snapshot)->snapshot_type == SNAPSHOT_MVCC
|
|
284
|
+
|| (snapshot)->snapshot_type == SNAPSHOT_TOAST)
|
|
285
|
+
&& !XLogRecPtrIsInvalid((snapshot)->lsn)
|
|
286
|
+
&& PageGetLSN(page) > (snapshot)->lsn)
|
|
287
|
+
TestForOldSnapshot_impl(snapshot, relation);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
#endif /* FRONTEND */
|
|
291
|
+
|
|
292
|
+
#endif /* BUFMGR_H */
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
/*-------------------------------------------------------------------------
|
|
2
|
+
*
|
|
3
|
+
* bufpage.h
|
|
4
|
+
* Standard POSTGRES buffer page definitions.
|
|
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/storage/bufpage.h
|
|
11
|
+
*
|
|
12
|
+
*-------------------------------------------------------------------------
|
|
13
|
+
*/
|
|
14
|
+
#ifndef BUFPAGE_H
|
|
15
|
+
#define BUFPAGE_H
|
|
16
|
+
|
|
17
|
+
#include "access/xlogdefs.h"
|
|
18
|
+
#include "storage/block.h"
|
|
19
|
+
#include "storage/item.h"
|
|
20
|
+
#include "storage/off.h"
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* A postgres disk page is an abstraction layered on top of a postgres
|
|
24
|
+
* disk block (which is simply a unit of i/o, see block.h).
|
|
25
|
+
*
|
|
26
|
+
* specifically, while a disk block can be unformatted, a postgres
|
|
27
|
+
* disk page is always a slotted page of the form:
|
|
28
|
+
*
|
|
29
|
+
* +----------------+---------------------------------+
|
|
30
|
+
* | PageHeaderData | linp1 linp2 linp3 ... |
|
|
31
|
+
* +-----------+----+---------------------------------+
|
|
32
|
+
* | ... linpN | |
|
|
33
|
+
* +-----------+--------------------------------------+
|
|
34
|
+
* | ^ pd_lower |
|
|
35
|
+
* | |
|
|
36
|
+
* | v pd_upper |
|
|
37
|
+
* +-------------+------------------------------------+
|
|
38
|
+
* | | tupleN ... |
|
|
39
|
+
* +-------------+------------------+-----------------+
|
|
40
|
+
* | ... tuple3 tuple2 tuple1 | "special space" |
|
|
41
|
+
* +--------------------------------+-----------------+
|
|
42
|
+
* ^ pd_special
|
|
43
|
+
*
|
|
44
|
+
* a page is full when nothing can be added between pd_lower and
|
|
45
|
+
* pd_upper.
|
|
46
|
+
*
|
|
47
|
+
* all blocks written out by an access method must be disk pages.
|
|
48
|
+
*
|
|
49
|
+
* EXCEPTIONS:
|
|
50
|
+
*
|
|
51
|
+
* obviously, a page is not formatted before it is initialized by
|
|
52
|
+
* a call to PageInit.
|
|
53
|
+
*
|
|
54
|
+
* NOTES:
|
|
55
|
+
*
|
|
56
|
+
* linp1..N form an ItemId (line pointer) array. ItemPointers point
|
|
57
|
+
* to a physical block number and a logical offset (line pointer
|
|
58
|
+
* number) within that block/page. Note that OffsetNumbers
|
|
59
|
+
* conventionally start at 1, not 0.
|
|
60
|
+
*
|
|
61
|
+
* tuple1..N are added "backwards" on the page. Since an ItemPointer
|
|
62
|
+
* offset is used to access an ItemId entry rather than an actual
|
|
63
|
+
* byte-offset position, tuples can be physically shuffled on a page
|
|
64
|
+
* whenever the need arises. This indirection also keeps crash recovery
|
|
65
|
+
* relatively simple, because the low-level details of page space
|
|
66
|
+
* management can be controlled by standard buffer page code during
|
|
67
|
+
* logging, and during recovery.
|
|
68
|
+
*
|
|
69
|
+
* AM-generic per-page information is kept in PageHeaderData.
|
|
70
|
+
*
|
|
71
|
+
* AM-specific per-page data (if any) is kept in the area marked "special
|
|
72
|
+
* space"; each AM has an "opaque" structure defined somewhere that is
|
|
73
|
+
* stored as the page trailer. an access method should always
|
|
74
|
+
* initialize its pages with PageInit and then set its own opaque
|
|
75
|
+
* fields.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
typedef Pointer Page;
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
/*
|
|
82
|
+
* location (byte offset) within a page.
|
|
83
|
+
*
|
|
84
|
+
* note that this is actually limited to 2^15 because we have limited
|
|
85
|
+
* ItemIdData.lp_off and ItemIdData.lp_len to 15 bits (see itemid.h).
|
|
86
|
+
*/
|
|
87
|
+
typedef uint16 LocationIndex;
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* For historical reasons, the 64-bit LSN value is stored as two 32-bit
|
|
92
|
+
* values.
|
|
93
|
+
*/
|
|
94
|
+
typedef struct
|
|
95
|
+
{
|
|
96
|
+
uint32 xlogid; /* high bits */
|
|
97
|
+
uint32 xrecoff; /* low bits */
|
|
98
|
+
} PageXLogRecPtr;
|
|
99
|
+
|
|
100
|
+
#define PageXLogRecPtrGet(val) \
|
|
101
|
+
((uint64) (val).xlogid << 32 | (val).xrecoff)
|
|
102
|
+
#define PageXLogRecPtrSet(ptr, lsn) \
|
|
103
|
+
((ptr).xlogid = (uint32) ((lsn) >> 32), (ptr).xrecoff = (uint32) (lsn))
|
|
104
|
+
|
|
105
|
+
/*
|
|
106
|
+
* disk page organization
|
|
107
|
+
*
|
|
108
|
+
* space management information generic to any page
|
|
109
|
+
*
|
|
110
|
+
* pd_lsn - identifies xlog record for last change to this page.
|
|
111
|
+
* pd_checksum - page checksum, if set.
|
|
112
|
+
* pd_flags - flag bits.
|
|
113
|
+
* pd_lower - offset to start of free space.
|
|
114
|
+
* pd_upper - offset to end of free space.
|
|
115
|
+
* pd_special - offset to start of special space.
|
|
116
|
+
* pd_pagesize_version - size in bytes and page layout version number.
|
|
117
|
+
* pd_prune_xid - oldest XID among potentially prunable tuples on page.
|
|
118
|
+
*
|
|
119
|
+
* The LSN is used by the buffer manager to enforce the basic rule of WAL:
|
|
120
|
+
* "thou shalt write xlog before data". A dirty buffer cannot be dumped
|
|
121
|
+
* to disk until xlog has been flushed at least as far as the page's LSN.
|
|
122
|
+
*
|
|
123
|
+
* pd_checksum stores the page checksum, if it has been set for this page;
|
|
124
|
+
* zero is a valid value for a checksum. If a checksum is not in use then
|
|
125
|
+
* we leave the field unset. This will typically mean the field is zero
|
|
126
|
+
* though non-zero values may also be present if databases have been
|
|
127
|
+
* pg_upgraded from releases prior to 9.3, when the same byte offset was
|
|
128
|
+
* used to store the current timelineid when the page was last updated.
|
|
129
|
+
* Note that there is no indication on a page as to whether the checksum
|
|
130
|
+
* is valid or not, a deliberate design choice which avoids the problem
|
|
131
|
+
* of relying on the page contents to decide whether to verify it. Hence
|
|
132
|
+
* there are no flag bits relating to checksums.
|
|
133
|
+
*
|
|
134
|
+
* pd_prune_xid is a hint field that helps determine whether pruning will be
|
|
135
|
+
* useful. It is currently unused in index pages.
|
|
136
|
+
*
|
|
137
|
+
* The page version number and page size are packed together into a single
|
|
138
|
+
* uint16 field. This is for historical reasons: before PostgreSQL 7.3,
|
|
139
|
+
* there was no concept of a page version number, and doing it this way
|
|
140
|
+
* lets us pretend that pre-7.3 databases have page version number zero.
|
|
141
|
+
* We constrain page sizes to be multiples of 256, leaving the low eight
|
|
142
|
+
* bits available for a version number.
|
|
143
|
+
*
|
|
144
|
+
* Minimum possible page size is perhaps 64B to fit page header, opaque space
|
|
145
|
+
* and a minimal tuple; of course, in reality you want it much bigger, so
|
|
146
|
+
* the constraint on pagesize mod 256 is not an important restriction.
|
|
147
|
+
* On the high end, we can only support pages up to 32KB because lp_off/lp_len
|
|
148
|
+
* are 15 bits.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
typedef struct PageHeaderData
|
|
152
|
+
{
|
|
153
|
+
/* XXX LSN is member of *any* block, not only page-organized ones */
|
|
154
|
+
PageXLogRecPtr pd_lsn; /* LSN: next byte after last byte of xlog
|
|
155
|
+
* record for last change to this page */
|
|
156
|
+
uint16 pd_checksum; /* checksum */
|
|
157
|
+
uint16 pd_flags; /* flag bits, see below */
|
|
158
|
+
LocationIndex pd_lower; /* offset to start of free space */
|
|
159
|
+
LocationIndex pd_upper; /* offset to end of free space */
|
|
160
|
+
LocationIndex pd_special; /* offset to start of special space */
|
|
161
|
+
uint16 pd_pagesize_version;
|
|
162
|
+
TransactionId pd_prune_xid; /* oldest prunable XID, or zero if none */
|
|
163
|
+
ItemIdData pd_linp[FLEXIBLE_ARRAY_MEMBER]; /* line pointer array */
|
|
164
|
+
} PageHeaderData;
|
|
165
|
+
|
|
166
|
+
typedef PageHeaderData *PageHeader;
|
|
167
|
+
|
|
168
|
+
/*
|
|
169
|
+
* pd_flags contains the following flag bits. Undefined bits are initialized
|
|
170
|
+
* to zero and may be used in the future.
|
|
171
|
+
*
|
|
172
|
+
* PD_HAS_FREE_LINES is set if there are any LP_UNUSED line pointers before
|
|
173
|
+
* pd_lower. This should be considered a hint rather than the truth, since
|
|
174
|
+
* changes to it are not WAL-logged.
|
|
175
|
+
*
|
|
176
|
+
* PD_PAGE_FULL is set if an UPDATE doesn't find enough free space in the
|
|
177
|
+
* page for its new tuple version; this suggests that a prune is needed.
|
|
178
|
+
* Again, this is just a hint.
|
|
179
|
+
*/
|
|
180
|
+
#define PD_HAS_FREE_LINES 0x0001 /* are there any unused line pointers? */
|
|
181
|
+
#define PD_PAGE_FULL 0x0002 /* not enough free space for new tuple? */
|
|
182
|
+
#define PD_ALL_VISIBLE 0x0004 /* all tuples on page are visible to
|
|
183
|
+
* everyone */
|
|
184
|
+
|
|
185
|
+
#define PD_VALID_FLAG_BITS 0x0007 /* OR of all valid pd_flags bits */
|
|
186
|
+
|
|
187
|
+
/*
|
|
188
|
+
* Page layout version number 0 is for pre-7.3 Postgres releases.
|
|
189
|
+
* Releases 7.3 and 7.4 use 1, denoting a new HeapTupleHeader layout.
|
|
190
|
+
* Release 8.0 uses 2; it changed the HeapTupleHeader layout again.
|
|
191
|
+
* Release 8.1 uses 3; it redefined HeapTupleHeader infomask bits.
|
|
192
|
+
* Release 8.3 uses 4; it changed the HeapTupleHeader layout again, and
|
|
193
|
+
* added the pd_flags field (by stealing some bits from pd_tli),
|
|
194
|
+
* as well as adding the pd_prune_xid field (which enlarges the header).
|
|
195
|
+
*
|
|
196
|
+
* As of Release 9.3, the checksum version must also be considered when
|
|
197
|
+
* handling pages.
|
|
198
|
+
*/
|
|
199
|
+
#define PG_PAGE_LAYOUT_VERSION 4
|
|
200
|
+
#define PG_DATA_CHECKSUM_VERSION 1
|
|
201
|
+
|
|
202
|
+
/* ----------------------------------------------------------------
|
|
203
|
+
* page support macros
|
|
204
|
+
* ----------------------------------------------------------------
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
/*
|
|
208
|
+
* PageIsValid
|
|
209
|
+
* True iff page is valid.
|
|
210
|
+
*/
|
|
211
|
+
#define PageIsValid(page) PointerIsValid(page)
|
|
212
|
+
|
|
213
|
+
/*
|
|
214
|
+
* line pointer(s) do not count as part of header
|
|
215
|
+
*/
|
|
216
|
+
#define SizeOfPageHeaderData (offsetof(PageHeaderData, pd_linp))
|
|
217
|
+
|
|
218
|
+
/*
|
|
219
|
+
* PageIsEmpty
|
|
220
|
+
* returns true iff no itemid has been allocated on the page
|
|
221
|
+
*/
|
|
222
|
+
#define PageIsEmpty(page) \
|
|
223
|
+
(((PageHeader) (page))->pd_lower <= SizeOfPageHeaderData)
|
|
224
|
+
|
|
225
|
+
/*
|
|
226
|
+
* PageIsNew
|
|
227
|
+
* returns true iff page has not been initialized (by PageInit)
|
|
228
|
+
*/
|
|
229
|
+
#define PageIsNew(page) (((PageHeader) (page))->pd_upper == 0)
|
|
230
|
+
|
|
231
|
+
/*
|
|
232
|
+
* PageGetItemId
|
|
233
|
+
* Returns an item identifier of a page.
|
|
234
|
+
*/
|
|
235
|
+
#define PageGetItemId(page, offsetNumber) \
|
|
236
|
+
((ItemId) (&((PageHeader) (page))->pd_linp[(offsetNumber) - 1]))
|
|
237
|
+
|
|
238
|
+
/*
|
|
239
|
+
* PageGetContents
|
|
240
|
+
* To be used in cases where the page does not contain line pointers.
|
|
241
|
+
*
|
|
242
|
+
* Note: prior to 8.3 this was not guaranteed to yield a MAXALIGN'd result.
|
|
243
|
+
* Now it is. Beware of old code that might think the offset to the contents
|
|
244
|
+
* is just SizeOfPageHeaderData rather than MAXALIGN(SizeOfPageHeaderData).
|
|
245
|
+
*/
|
|
246
|
+
#define PageGetContents(page) \
|
|
247
|
+
((char *) (page) + MAXALIGN(SizeOfPageHeaderData))
|
|
248
|
+
|
|
249
|
+
/* ----------------
|
|
250
|
+
* macros to access page size info
|
|
251
|
+
* ----------------
|
|
252
|
+
*/
|
|
253
|
+
|
|
254
|
+
/*
|
|
255
|
+
* PageSizeIsValid
|
|
256
|
+
* True iff the page size is valid.
|
|
257
|
+
*/
|
|
258
|
+
#define PageSizeIsValid(pageSize) ((pageSize) == BLCKSZ)
|
|
259
|
+
|
|
260
|
+
/*
|
|
261
|
+
* PageGetPageSize
|
|
262
|
+
* Returns the page size of a page.
|
|
263
|
+
*
|
|
264
|
+
* this can only be called on a formatted page (unlike
|
|
265
|
+
* BufferGetPageSize, which can be called on an unformatted page).
|
|
266
|
+
* however, it can be called on a page that is not stored in a buffer.
|
|
267
|
+
*/
|
|
268
|
+
#define PageGetPageSize(page) \
|
|
269
|
+
((Size) (((PageHeader) (page))->pd_pagesize_version & (uint16) 0xFF00))
|
|
270
|
+
|
|
271
|
+
/*
|
|
272
|
+
* PageGetPageLayoutVersion
|
|
273
|
+
* Returns the page layout version of a page.
|
|
274
|
+
*/
|
|
275
|
+
#define PageGetPageLayoutVersion(page) \
|
|
276
|
+
(((PageHeader) (page))->pd_pagesize_version & 0x00FF)
|
|
277
|
+
|
|
278
|
+
/*
|
|
279
|
+
* PageSetPageSizeAndVersion
|
|
280
|
+
* Sets the page size and page layout version number of a page.
|
|
281
|
+
*
|
|
282
|
+
* We could support setting these two values separately, but there's
|
|
283
|
+
* no real need for it at the moment.
|
|
284
|
+
*/
|
|
285
|
+
#define PageSetPageSizeAndVersion(page, size, version) \
|
|
286
|
+
( \
|
|
287
|
+
AssertMacro(((size) & 0xFF00) == (size)), \
|
|
288
|
+
AssertMacro(((version) & 0x00FF) == (version)), \
|
|
289
|
+
((PageHeader) (page))->pd_pagesize_version = (size) | (version) \
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
/* ----------------
|
|
293
|
+
* page special data macros
|
|
294
|
+
* ----------------
|
|
295
|
+
*/
|
|
296
|
+
/*
|
|
297
|
+
* PageGetSpecialSize
|
|
298
|
+
* Returns size of special space on a page.
|
|
299
|
+
*/
|
|
300
|
+
#define PageGetSpecialSize(page) \
|
|
301
|
+
((uint16) (PageGetPageSize(page) - ((PageHeader)(page))->pd_special))
|
|
302
|
+
|
|
303
|
+
/*
|
|
304
|
+
* Using assertions, validate that the page special pointer is OK.
|
|
305
|
+
*
|
|
306
|
+
* This is intended to catch use of the pointer before page initialization.
|
|
307
|
+
* It is implemented as a function due to the limitations of the MSVC
|
|
308
|
+
* compiler, which choked on doing all these tests within another macro. We
|
|
309
|
+
* return true so that AssertMacro() can be used while still getting the
|
|
310
|
+
* specifics from the macro failure within this function.
|
|
311
|
+
*/
|
|
312
|
+
static inline bool
|
|
313
|
+
PageValidateSpecialPointer(Page page)
|
|
314
|
+
{
|
|
315
|
+
Assert(PageIsValid(page));
|
|
316
|
+
Assert(((PageHeader) (page))->pd_special <= BLCKSZ);
|
|
317
|
+
Assert(((PageHeader) (page))->pd_special >= SizeOfPageHeaderData);
|
|
318
|
+
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/*
|
|
323
|
+
* PageGetSpecialPointer
|
|
324
|
+
* Returns pointer to special space on a page.
|
|
325
|
+
*/
|
|
326
|
+
#define PageGetSpecialPointer(page) \
|
|
327
|
+
( \
|
|
328
|
+
AssertMacro(PageValidateSpecialPointer(page)), \
|
|
329
|
+
(char *) ((char *) (page) + ((PageHeader) (page))->pd_special) \
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
/*
|
|
333
|
+
* PageGetItem
|
|
334
|
+
* Retrieves an item on the given page.
|
|
335
|
+
*
|
|
336
|
+
* Note:
|
|
337
|
+
* This does not change the status of any of the resources passed.
|
|
338
|
+
* The semantics may change in the future.
|
|
339
|
+
*/
|
|
340
|
+
#define PageGetItem(page, itemId) \
|
|
341
|
+
( \
|
|
342
|
+
AssertMacro(PageIsValid(page)), \
|
|
343
|
+
AssertMacro(ItemIdHasStorage(itemId)), \
|
|
344
|
+
(Item)(((char *)(page)) + ItemIdGetOffset(itemId)) \
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
/*
|
|
348
|
+
* PageGetMaxOffsetNumber
|
|
349
|
+
* Returns the maximum offset number used by the given page.
|
|
350
|
+
* Since offset numbers are 1-based, this is also the number
|
|
351
|
+
* of items on the page.
|
|
352
|
+
*
|
|
353
|
+
* NOTE: if the page is not initialized (pd_lower == 0), we must
|
|
354
|
+
* return zero to ensure sane behavior. Accept double evaluation
|
|
355
|
+
* of the argument so that we can ensure this.
|
|
356
|
+
*/
|
|
357
|
+
#define PageGetMaxOffsetNumber(page) \
|
|
358
|
+
(((PageHeader) (page))->pd_lower <= SizeOfPageHeaderData ? 0 : \
|
|
359
|
+
((((PageHeader) (page))->pd_lower - SizeOfPageHeaderData) \
|
|
360
|
+
/ sizeof(ItemIdData)))
|
|
361
|
+
|
|
362
|
+
/*
|
|
363
|
+
* Additional macros for access to page headers. (Beware multiple evaluation
|
|
364
|
+
* of the arguments!)
|
|
365
|
+
*/
|
|
366
|
+
#define PageGetLSN(page) \
|
|
367
|
+
PageXLogRecPtrGet(((PageHeader) (page))->pd_lsn)
|
|
368
|
+
#define PageSetLSN(page, lsn) \
|
|
369
|
+
PageXLogRecPtrSet(((PageHeader) (page))->pd_lsn, lsn)
|
|
370
|
+
|
|
371
|
+
#define PageHasFreeLinePointers(page) \
|
|
372
|
+
(((PageHeader) (page))->pd_flags & PD_HAS_FREE_LINES)
|
|
373
|
+
#define PageSetHasFreeLinePointers(page) \
|
|
374
|
+
(((PageHeader) (page))->pd_flags |= PD_HAS_FREE_LINES)
|
|
375
|
+
#define PageClearHasFreeLinePointers(page) \
|
|
376
|
+
(((PageHeader) (page))->pd_flags &= ~PD_HAS_FREE_LINES)
|
|
377
|
+
|
|
378
|
+
#define PageIsFull(page) \
|
|
379
|
+
(((PageHeader) (page))->pd_flags & PD_PAGE_FULL)
|
|
380
|
+
#define PageSetFull(page) \
|
|
381
|
+
(((PageHeader) (page))->pd_flags |= PD_PAGE_FULL)
|
|
382
|
+
#define PageClearFull(page) \
|
|
383
|
+
(((PageHeader) (page))->pd_flags &= ~PD_PAGE_FULL)
|
|
384
|
+
|
|
385
|
+
#define PageIsAllVisible(page) \
|
|
386
|
+
(((PageHeader) (page))->pd_flags & PD_ALL_VISIBLE)
|
|
387
|
+
#define PageSetAllVisible(page) \
|
|
388
|
+
(((PageHeader) (page))->pd_flags |= PD_ALL_VISIBLE)
|
|
389
|
+
#define PageClearAllVisible(page) \
|
|
390
|
+
(((PageHeader) (page))->pd_flags &= ~PD_ALL_VISIBLE)
|
|
391
|
+
|
|
392
|
+
#define PageIsPrunable(page, oldestxmin) \
|
|
393
|
+
( \
|
|
394
|
+
AssertMacro(TransactionIdIsNormal(oldestxmin)), \
|
|
395
|
+
TransactionIdIsValid(((PageHeader) (page))->pd_prune_xid) && \
|
|
396
|
+
TransactionIdPrecedes(((PageHeader) (page))->pd_prune_xid, oldestxmin) \
|
|
397
|
+
)
|
|
398
|
+
#define PageSetPrunable(page, xid) \
|
|
399
|
+
do { \
|
|
400
|
+
Assert(TransactionIdIsNormal(xid)); \
|
|
401
|
+
if (!TransactionIdIsValid(((PageHeader) (page))->pd_prune_xid) || \
|
|
402
|
+
TransactionIdPrecedes(xid, ((PageHeader) (page))->pd_prune_xid)) \
|
|
403
|
+
((PageHeader) (page))->pd_prune_xid = (xid); \
|
|
404
|
+
} while (0)
|
|
405
|
+
#define PageClearPrunable(page) \
|
|
406
|
+
(((PageHeader) (page))->pd_prune_xid = InvalidTransactionId)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
/* ----------------------------------------------------------------
|
|
410
|
+
* extern declarations
|
|
411
|
+
* ----------------------------------------------------------------
|
|
412
|
+
*/
|
|
413
|
+
|
|
414
|
+
/* flags for PageAddItemExtended() */
|
|
415
|
+
#define PAI_OVERWRITE (1 << 0)
|
|
416
|
+
#define PAI_IS_HEAP (1 << 1)
|
|
417
|
+
|
|
418
|
+
/* flags for PageIsVerifiedExtended() */
|
|
419
|
+
#define PIV_LOG_WARNING (1 << 0)
|
|
420
|
+
#define PIV_REPORT_STAT (1 << 1)
|
|
421
|
+
|
|
422
|
+
#define PageAddItem(page, item, size, offsetNumber, overwrite, is_heap) \
|
|
423
|
+
PageAddItemExtended(page, item, size, offsetNumber, \
|
|
424
|
+
((overwrite) ? PAI_OVERWRITE : 0) | \
|
|
425
|
+
((is_heap) ? PAI_IS_HEAP : 0))
|
|
426
|
+
|
|
427
|
+
/*
|
|
428
|
+
* Check that BLCKSZ is a multiple of sizeof(size_t). In
|
|
429
|
+
* PageIsVerifiedExtended(), it is much faster to check if a page is
|
|
430
|
+
* full of zeroes using the native word size. Note that this assertion
|
|
431
|
+
* is kept within a header to make sure that StaticAssertDecl() works
|
|
432
|
+
* across various combinations of platforms and compilers.
|
|
433
|
+
*/
|
|
434
|
+
StaticAssertDecl(BLCKSZ == ((BLCKSZ / sizeof(size_t)) * sizeof(size_t)),
|
|
435
|
+
"BLCKSZ has to be a multiple of sizeof(size_t)");
|
|
436
|
+
|
|
437
|
+
extern void PageInit(Page page, Size pageSize, Size specialSize);
|
|
438
|
+
extern bool PageIsVerified(Page page, BlockNumber blkno);
|
|
439
|
+
extern bool PageIsVerifiedExtended(Page page, BlockNumber blkno, int flags);
|
|
440
|
+
extern OffsetNumber PageAddItemExtended(Page page, Item item, Size size,
|
|
441
|
+
OffsetNumber offsetNumber, int flags);
|
|
442
|
+
extern Page PageGetTempPage(Page page);
|
|
443
|
+
extern Page PageGetTempPageCopy(Page page);
|
|
444
|
+
extern Page PageGetTempPageCopySpecial(Page page);
|
|
445
|
+
extern void PageRestoreTempPage(Page tempPage, Page oldPage);
|
|
446
|
+
extern void PageRepairFragmentation(Page page);
|
|
447
|
+
extern Size PageGetFreeSpace(Page page);
|
|
448
|
+
extern Size PageGetFreeSpaceForMultipleTuples(Page page, int ntups);
|
|
449
|
+
extern Size PageGetExactFreeSpace(Page page);
|
|
450
|
+
extern Size PageGetHeapFreeSpace(Page page);
|
|
451
|
+
extern void PageIndexTupleDelete(Page page, OffsetNumber offset);
|
|
452
|
+
extern void PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems);
|
|
453
|
+
extern void PageIndexTupleDeleteNoCompact(Page page, OffsetNumber offset);
|
|
454
|
+
extern bool PageIndexTupleOverwrite(Page page, OffsetNumber offnum,
|
|
455
|
+
Item newtup, Size newsize);
|
|
456
|
+
extern char *PageSetChecksumCopy(Page page, BlockNumber blkno);
|
|
457
|
+
extern void PageSetChecksumInplace(Page page, BlockNumber blkno);
|
|
458
|
+
|
|
459
|
+
#endif /* BUFPAGE_H */
|