pg_query 2.1.0 → 4.2.1
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 +104 -0
- data/README.md +59 -31
- data/Rakefile +2 -2
- data/ext/pg_query/extconf.rb +8 -2
- data/ext/pg_query/include/access/amapi.h +45 -1
- data/ext/pg_query/include/access/attmap.h +1 -1
- data/ext/pg_query/include/access/attnum.h +2 -2
- data/ext/pg_query/include/access/clog.h +4 -2
- data/ext/pg_query/include/access/commit_ts.h +6 -9
- data/ext/pg_query/include/access/detoast.h +1 -11
- data/ext/pg_query/include/access/genam.h +15 -12
- data/ext/pg_query/include/access/gin.h +2 -2
- data/ext/pg_query/include/access/htup.h +1 -1
- data/ext/pg_query/include/access/htup_details.h +75 -87
- data/ext/pg_query/include/access/itup.h +7 -1
- data/ext/pg_query/include/access/parallel.h +2 -2
- data/ext/pg_query/include/access/printtup.h +1 -1
- data/ext/pg_query/include/access/relation.h +1 -1
- data/ext/pg_query/include/access/relscan.h +17 -2
- data/ext/pg_query/include/access/rmgr.h +30 -3
- data/ext/pg_query/include/access/rmgrlist.h +23 -23
- data/ext/pg_query/include/access/sdir.h +1 -1
- data/ext/pg_query/include/access/skey.h +1 -1
- data/ext/pg_query/include/access/stratnum.h +4 -2
- data/ext/pg_query/include/access/sysattr.h +1 -1
- data/ext/pg_query/include/access/table.h +2 -1
- data/ext/pg_query/include/access/tableam.h +272 -20
- data/ext/pg_query/include/access/toast_compression.h +73 -0
- data/ext/pg_query/include/access/transam.h +123 -13
- data/ext/pg_query/include/access/tupconvert.h +1 -1
- data/ext/pg_query/include/access/tupdesc.h +1 -1
- data/ext/pg_query/include/access/tupmacs.h +3 -3
- data/ext/pg_query/include/access/twophase.h +5 -1
- data/ext/pg_query/include/access/xact.h +79 -19
- data/ext/pg_query/include/access/xlog.h +60 -155
- data/ext/pg_query/include/access/xlog_internal.h +50 -14
- data/ext/pg_query/include/access/xlogdefs.h +8 -16
- data/ext/pg_query/include/access/xlogprefetcher.h +55 -0
- data/ext/pg_query/include/access/xlogreader.h +148 -32
- data/ext/pg_query/include/access/xlogrecord.h +18 -9
- data/ext/pg_query/include/access/xlogrecovery.h +157 -0
- data/ext/pg_query/include/c.h +101 -44
- data/ext/pg_query/include/catalog/catalog.h +3 -1
- data/ext/pg_query/include/catalog/catversion.h +2 -2
- data/ext/pg_query/include/catalog/dependency.h +10 -16
- data/ext/pg_query/include/catalog/genbki.h +83 -5
- data/ext/pg_query/include/catalog/index.h +18 -3
- data/ext/pg_query/include/catalog/indexing.h +12 -324
- data/ext/pg_query/include/catalog/namespace.h +4 -2
- data/ext/pg_query/include/catalog/objectaccess.h +70 -2
- data/ext/pg_query/include/catalog/objectaddress.h +11 -6
- data/ext/pg_query/include/catalog/pg_aggregate.h +14 -10
- data/ext/pg_query/include/catalog/pg_aggregate_d.h +2 -1
- data/ext/pg_query/include/catalog/pg_am.h +4 -1
- data/ext/pg_query/include/catalog/pg_am_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_attribute.h +27 -10
- data/ext/pg_query/include/catalog/pg_attribute_d.h +21 -18
- data/ext/pg_query/include/catalog/pg_authid.h +7 -2
- data/ext/pg_query/include/catalog/pg_authid_d.h +17 -9
- data/ext/pg_query/include/catalog/pg_class.h +45 -15
- data/ext/pg_query/include/catalog/pg_class_d.h +31 -2
- data/ext/pg_query/include/catalog/pg_collation.h +33 -8
- data/ext/pg_query/include/catalog/pg_collation_d.h +20 -3
- data/ext/pg_query/include/catalog/pg_constraint.h +38 -12
- data/ext/pg_query/include/catalog/pg_constraint_d.h +10 -4
- data/ext/pg_query/include/catalog/pg_control.h +5 -5
- data/ext/pg_query/include/catalog/pg_conversion.h +7 -4
- data/ext/pg_query/include/catalog/pg_conversion_d.h +4 -1
- data/ext/pg_query/include/catalog/pg_depend.h +11 -7
- data/ext/pg_query/include/catalog/pg_depend_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_event_trigger.h +9 -3
- data/ext/pg_query/include/catalog/pg_event_trigger_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_index.h +17 -7
- data/ext/pg_query/include/catalog/pg_index_d.h +20 -17
- data/ext/pg_query/include/catalog/pg_language.h +10 -5
- data/ext/pg_query/include/catalog/pg_language_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_namespace.h +7 -2
- data/ext/pg_query/include/catalog/pg_namespace_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_opclass.h +8 -5
- data/ext/pg_query/include/catalog/pg_opclass_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_operator.h +21 -16
- data/ext/pg_query/include/catalog/pg_operator_d.h +37 -1
- data/ext/pg_query/include/catalog/pg_opfamily.h +6 -3
- data/ext/pg_query/include/catalog/pg_opfamily_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_parameter_acl.h +60 -0
- data/ext/pg_query/include/catalog/pg_parameter_acl_d.h +34 -0
- data/ext/pg_query/include/catalog/pg_partitioned_table.h +20 -9
- data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +2 -1
- data/ext/pg_query/include/catalog/pg_proc.h +20 -11
- data/ext/pg_query/include/catalog/pg_proc_d.h +10 -8
- data/ext/pg_query/include/catalog/pg_publication.h +50 -4
- data/ext/pg_query/include/catalog/pg_publication_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_replication_origin.h +6 -1
- data/ext/pg_query/include/catalog/pg_replication_origin_d.h +5 -1
- data/ext/pg_query/include/catalog/pg_statistic.h +19 -12
- data/ext/pg_query/include/catalog/pg_statistic_d.h +2 -1
- data/ext/pg_query/include/catalog/pg_statistic_ext.h +19 -5
- data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +7 -2
- data/ext/pg_query/include/catalog/pg_transform.h +8 -5
- data/ext/pg_query/include/catalog/pg_transform_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_trigger.h +24 -8
- data/ext/pg_query/include/catalog/pg_trigger_d.h +4 -1
- data/ext/pg_query/include/catalog/pg_ts_config.h +6 -3
- data/ext/pg_query/include/catalog/pg_ts_config_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_ts_dict.h +8 -3
- data/ext/pg_query/include/catalog/pg_ts_dict_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_ts_parser.h +6 -3
- data/ext/pg_query/include/catalog/pg_ts_parser_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_ts_template.h +6 -3
- data/ext/pg_query/include/catalog/pg_ts_template_d.h +3 -1
- data/ext/pg_query/include/catalog/pg_type.h +56 -24
- data/ext/pg_query/include/catalog/pg_type_d.h +70 -31
- data/ext/pg_query/include/catalog/storage.h +5 -3
- data/ext/pg_query/include/commands/async.h +4 -5
- data/ext/pg_query/include/commands/dbcommands.h +2 -1
- data/ext/pg_query/include/commands/defrem.h +11 -24
- data/ext/pg_query/include/commands/event_trigger.h +2 -2
- data/ext/pg_query/include/commands/explain.h +1 -1
- data/ext/pg_query/include/commands/prepare.h +1 -1
- data/ext/pg_query/include/commands/tablespace.h +3 -1
- data/ext/pg_query/include/commands/trigger.h +27 -17
- data/ext/pg_query/include/commands/user.h +2 -2
- data/ext/pg_query/include/commands/vacuum.h +88 -41
- data/ext/pg_query/include/commands/variable.h +1 -1
- data/ext/pg_query/include/common/file_perm.h +4 -4
- data/ext/pg_query/include/common/hashfn.h +1 -1
- data/ext/pg_query/include/common/ip.h +1 -7
- data/ext/pg_query/include/common/keywords.h +2 -6
- data/ext/pg_query/include/common/kwlookup.h +1 -1
- data/ext/pg_query/include/common/pg_prng.h +60 -0
- data/ext/pg_query/include/common/relpath.h +2 -2
- data/ext/pg_query/include/common/string.h +24 -1
- data/ext/pg_query/include/common/unicode_combining_table.h +114 -2
- data/ext/pg_query/include/common/unicode_east_asian_fw_table.h +125 -0
- data/ext/pg_query/include/datatype/timestamp.h +40 -1
- data/ext/pg_query/include/executor/execdesc.h +1 -1
- data/ext/pg_query/include/executor/executor.h +65 -22
- data/ext/pg_query/include/executor/functions.h +17 -3
- data/ext/pg_query/include/executor/instrument.h +33 -16
- data/ext/pg_query/include/executor/spi.h +41 -3
- data/ext/pg_query/include/executor/tablefunc.h +1 -1
- data/ext/pg_query/include/executor/tuptable.h +1 -1
- data/ext/pg_query/include/fmgr.h +13 -7
- data/ext/pg_query/include/funcapi.h +16 -4
- data/ext/pg_query/include/getaddrinfo.h +1 -1
- data/ext/pg_query/include/jit/jit.h +11 -11
- data/ext/pg_query/include/kwlist_d.h +517 -494
- data/ext/pg_query/include/lib/dshash.h +112 -0
- data/ext/pg_query/include/lib/ilist.h +20 -1
- data/ext/pg_query/include/lib/pairingheap.h +1 -1
- data/ext/pg_query/include/lib/simplehash.h +150 -25
- data/ext/pg_query/include/lib/sort_template.h +432 -0
- data/ext/pg_query/include/lib/stringinfo.h +1 -1
- data/ext/pg_query/include/libpq/auth.h +6 -4
- data/ext/pg_query/include/libpq/crypt.h +5 -4
- data/ext/pg_query/include/libpq/hba.h +43 -4
- data/ext/pg_query/include/libpq/libpq-be.h +23 -6
- data/ext/pg_query/include/libpq/libpq.h +31 -20
- data/ext/pg_query/include/libpq/pqcomm.h +17 -31
- data/ext/pg_query/include/libpq/pqformat.h +1 -1
- data/ext/pg_query/include/libpq/pqsignal.h +4 -4
- data/ext/pg_query/include/mb/pg_wchar.h +106 -23
- data/ext/pg_query/include/mb/stringinfo_mb.h +1 -1
- data/ext/pg_query/include/miscadmin.h +71 -52
- data/ext/pg_query/include/nodes/bitmapset.h +1 -1
- data/ext/pg_query/include/nodes/execnodes.h +272 -80
- data/ext/pg_query/include/nodes/extensible.h +4 -2
- data/ext/pg_query/include/nodes/lockoptions.h +1 -1
- data/ext/pg_query/include/nodes/makefuncs.h +7 -6
- data/ext/pg_query/include/nodes/memnodes.h +5 -3
- data/ext/pg_query/include/nodes/nodeFuncs.h +1 -1
- data/ext/pg_query/include/nodes/nodes.h +30 -11
- data/ext/pg_query/include/nodes/params.h +1 -1
- data/ext/pg_query/include/nodes/parsenodes.h +327 -94
- data/ext/pg_query/include/nodes/pathnodes.h +245 -67
- data/ext/pg_query/include/nodes/pg_list.h +75 -68
- data/ext/pg_query/include/nodes/plannodes.h +128 -30
- data/ext/pg_query/include/nodes/primnodes.h +99 -47
- data/ext/pg_query/include/nodes/print.h +1 -1
- data/ext/pg_query/include/nodes/tidbitmap.h +1 -1
- data/ext/pg_query/include/nodes/value.h +58 -39
- data/ext/pg_query/include/optimizer/cost.h +9 -2
- data/ext/pg_query/include/optimizer/geqo.h +9 -7
- data/ext/pg_query/include/optimizer/geqo_gene.h +1 -1
- data/ext/pg_query/include/optimizer/optimizer.h +25 -22
- data/ext/pg_query/include/optimizer/paths.h +6 -6
- data/ext/pg_query/include/optimizer/planmain.h +15 -14
- data/ext/pg_query/include/parser/analyze.h +19 -5
- data/ext/pg_query/include/parser/gram.h +947 -913
- data/ext/pg_query/include/parser/gramparse.h +1 -1
- data/ext/pg_query/include/parser/kwlist.h +463 -453
- data/ext/pg_query/include/parser/parse_agg.h +2 -7
- data/ext/pg_query/include/parser/parse_coerce.h +4 -1
- data/ext/pg_query/include/parser/parse_expr.h +2 -3
- data/ext/pg_query/include/parser/parse_func.h +2 -1
- data/ext/pg_query/include/parser/parse_node.h +21 -9
- data/ext/pg_query/include/parser/parse_oper.h +1 -3
- data/ext/pg_query/include/parser/parse_relation.h +5 -4
- data/ext/pg_query/include/parser/parse_type.h +1 -1
- data/ext/pg_query/include/parser/parser.h +31 -4
- data/ext/pg_query/include/parser/parsetree.h +1 -1
- data/ext/pg_query/include/parser/scanner.h +1 -1
- data/ext/pg_query/include/parser/scansup.h +2 -5
- data/ext/pg_query/include/partitioning/partdefs.h +1 -1
- data/ext/pg_query/include/pg_config.h +94 -46
- data/ext/pg_query/include/pg_config_manual.h +74 -21
- data/ext/pg_query/include/pg_getopt.h +6 -6
- data/ext/pg_query/include/pg_query.h +5 -4
- data/ext/pg_query/include/pg_query_enum_defs.c +358 -241
- data/ext/pg_query/include/pg_query_fingerprint_conds.c +44 -7
- data/ext/pg_query/include/pg_query_fingerprint_defs.c +1220 -422
- data/ext/pg_query/include/pg_query_outfuncs_conds.c +43 -13
- data/ext/pg_query/include/pg_query_outfuncs_defs.c +152 -26
- data/ext/pg_query/include/pg_query_readfuncs_conds.c +11 -2
- data/ext/pg_query/include/pg_query_readfuncs_defs.c +174 -30
- data/ext/pg_query/include/pg_trace.h +1 -1
- data/ext/pg_query/include/pgstat.h +449 -1237
- data/ext/pg_query/include/pgtime.h +14 -4
- data/ext/pg_query/include/pl_gram.h +126 -128
- data/ext/pg_query/include/pl_reserved_kwlist.h +1 -1
- data/ext/pg_query/include/pl_reserved_kwlist_d.h +10 -10
- data/ext/pg_query/include/pl_unreserved_kwlist.h +2 -3
- data/ext/pg_query/include/pl_unreserved_kwlist_d.h +54 -56
- data/ext/pg_query/include/plerrcodes.h +9 -1
- data/ext/pg_query/include/plpgsql.h +52 -54
- data/ext/pg_query/include/port/atomics/arch-arm.h +7 -1
- data/ext/pg_query/include/port/atomics/arch-ppc.h +1 -1
- data/ext/pg_query/include/port/atomics/arch-x86.h +1 -1
- data/ext/pg_query/include/port/atomics/fallback.h +1 -1
- data/ext/pg_query/include/port/atomics/generic-gcc.h +3 -3
- data/ext/pg_query/include/port/atomics/generic.h +1 -1
- data/ext/pg_query/include/port/atomics.h +1 -1
- data/ext/pg_query/include/port/pg_bitutils.h +88 -12
- data/ext/pg_query/include/port/pg_bswap.h +1 -1
- data/ext/pg_query/include/port/pg_crc32c.h +1 -1
- data/ext/pg_query/include/port.h +72 -43
- data/ext/pg_query/include/portability/instr_time.h +1 -1
- data/ext/pg_query/include/postgres.h +60 -16
- data/ext/pg_query/include/postmaster/autovacuum.h +17 -17
- data/ext/pg_query/include/postmaster/auxprocess.h +20 -0
- data/ext/pg_query/include/postmaster/bgworker.h +2 -1
- data/ext/pg_query/include/postmaster/bgworker_internals.h +2 -2
- data/ext/pg_query/include/postmaster/bgwriter.h +5 -5
- data/ext/pg_query/include/postmaster/fork_process.h +1 -1
- data/ext/pg_query/include/postmaster/interrupt.h +1 -1
- data/ext/pg_query/include/postmaster/pgarch.h +42 -8
- data/ext/pg_query/include/postmaster/postmaster.h +18 -17
- data/ext/pg_query/include/postmaster/startup.h +39 -0
- data/ext/pg_query/include/postmaster/syslogger.h +15 -10
- data/ext/pg_query/include/postmaster/walwriter.h +3 -3
- data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1422 -916
- data/ext/pg_query/include/protobuf/pg_query.pb.h +43678 -32769
- data/ext/pg_query/include/regex/regex.h +18 -16
- data/ext/pg_query/include/replication/logicallauncher.h +3 -5
- data/ext/pg_query/include/replication/logicalproto.h +161 -17
- data/ext/pg_query/include/replication/logicalworker.h +1 -1
- data/ext/pg_query/include/replication/origin.h +7 -7
- data/ext/pg_query/include/replication/reorderbuffer.h +262 -44
- data/ext/pg_query/include/replication/slot.h +23 -12
- data/ext/pg_query/include/replication/syncrep.h +5 -5
- data/ext/pg_query/include/replication/walreceiver.h +145 -13
- data/ext/pg_query/include/replication/walsender.h +8 -8
- data/ext/pg_query/include/rewrite/prs2lock.h +1 -1
- data/ext/pg_query/include/rewrite/rewriteHandler.h +1 -3
- data/ext/pg_query/include/rewrite/rewriteManip.h +1 -1
- data/ext/pg_query/include/rewrite/rewriteSupport.h +1 -1
- data/ext/pg_query/include/storage/backendid.h +3 -3
- data/ext/pg_query/include/storage/block.h +4 -10
- data/ext/pg_query/include/storage/buf.h +1 -1
- data/ext/pg_query/include/storage/bufmgr.h +19 -14
- data/ext/pg_query/include/storage/bufpage.h +6 -8
- data/ext/pg_query/include/storage/condition_variable.h +13 -2
- data/ext/pg_query/include/storage/dsm.h +4 -1
- data/ext/pg_query/include/storage/dsm_impl.h +3 -2
- data/ext/pg_query/include/storage/fd.h +33 -3
- data/ext/pg_query/include/storage/fileset.h +40 -0
- data/ext/pg_query/include/storage/ipc.h +4 -1
- data/ext/pg_query/include/storage/item.h +1 -1
- data/ext/pg_query/include/storage/itemid.h +1 -1
- data/ext/pg_query/include/storage/itemptr.h +3 -1
- data/ext/pg_query/include/storage/large_object.h +2 -2
- data/ext/pg_query/include/storage/latch.h +9 -13
- data/ext/pg_query/include/storage/lmgr.h +2 -1
- data/ext/pg_query/include/storage/lock.h +17 -13
- data/ext/pg_query/include/storage/lockdefs.h +2 -2
- data/ext/pg_query/include/storage/lwlock.h +6 -32
- data/ext/pg_query/include/storage/lwlocknames.h +0 -1
- data/ext/pg_query/include/storage/off.h +1 -1
- data/ext/pg_query/include/storage/pg_sema.h +1 -1
- data/ext/pg_query/include/storage/pg_shmem.h +9 -7
- data/ext/pg_query/include/storage/pmsignal.h +15 -4
- data/ext/pg_query/include/storage/predicate.h +4 -4
- data/ext/pg_query/include/storage/proc.h +183 -55
- data/ext/pg_query/include/storage/procarray.h +98 -0
- data/ext/pg_query/include/storage/proclist_types.h +1 -1
- data/ext/pg_query/include/storage/procsignal.h +3 -7
- data/ext/pg_query/include/storage/relfilenode.h +1 -1
- data/ext/pg_query/include/storage/s_lock.h +67 -4
- data/ext/pg_query/include/storage/sharedfileset.h +3 -11
- data/ext/pg_query/include/storage/shm_mq.h +5 -4
- data/ext/pg_query/include/storage/shm_toc.h +1 -1
- data/ext/pg_query/include/storage/shmem.h +1 -1
- data/ext/pg_query/include/storage/sinval.h +3 -3
- data/ext/pg_query/include/storage/sinvaladt.h +1 -1
- data/ext/pg_query/include/storage/smgr.h +10 -8
- data/ext/pg_query/include/storage/spin.h +2 -2
- data/ext/pg_query/include/storage/standby.h +13 -6
- data/ext/pg_query/include/storage/standbydefs.h +2 -2
- data/ext/pg_query/include/storage/sync.h +7 -3
- data/ext/pg_query/include/tcop/cmdtag.h +1 -1
- data/ext/pg_query/include/tcop/cmdtaglist.h +3 -2
- data/ext/pg_query/include/tcop/deparse_utility.h +1 -1
- data/ext/pg_query/include/tcop/dest.h +1 -1
- data/ext/pg_query/include/tcop/fastpath.h +1 -2
- data/ext/pg_query/include/tcop/pquery.h +7 -1
- data/ext/pg_query/include/tcop/tcopprot.h +19 -11
- data/ext/pg_query/include/tcop/utility.h +7 -3
- data/ext/pg_query/include/tsearch/ts_cache.h +2 -2
- data/ext/pg_query/include/utils/acl.h +24 -3
- data/ext/pg_query/include/utils/aclchk_internal.h +1 -1
- data/ext/pg_query/include/utils/array.h +7 -2
- data/ext/pg_query/include/utils/backend_progress.h +44 -0
- data/ext/pg_query/include/utils/backend_status.h +321 -0
- data/ext/pg_query/include/utils/builtins.h +11 -11
- data/ext/pg_query/include/utils/bytea.h +3 -2
- data/ext/pg_query/include/utils/catcache.h +1 -1
- data/ext/pg_query/include/utils/date.h +1 -1
- data/ext/pg_query/include/utils/datetime.h +8 -7
- data/ext/pg_query/include/utils/datum.h +9 -1
- data/ext/pg_query/include/utils/dsa.h +1 -1
- data/ext/pg_query/include/utils/dynahash.h +4 -3
- data/ext/pg_query/include/utils/elog.h +52 -21
- data/ext/pg_query/include/utils/errcodes.h +2 -0
- data/ext/pg_query/include/utils/expandeddatum.h +1 -1
- data/ext/pg_query/include/utils/expandedrecord.h +1 -1
- data/ext/pg_query/include/utils/float.h +7 -7
- data/ext/pg_query/include/utils/fmgroids.h +1300 -696
- data/ext/pg_query/include/utils/fmgrprotos.h +199 -16
- data/ext/pg_query/include/utils/fmgrtab.h +6 -5
- data/ext/pg_query/include/utils/guc.h +69 -43
- data/ext/pg_query/include/utils/guc_tables.h +23 -19
- data/ext/pg_query/include/utils/hsearch.h +15 -11
- data/ext/pg_query/include/utils/inval.h +5 -1
- data/ext/pg_query/include/utils/lsyscache.h +11 -1
- data/ext/pg_query/include/utils/memdebug.h +1 -1
- data/ext/pg_query/include/utils/memutils.h +8 -3
- data/ext/pg_query/include/utils/numeric.h +19 -5
- data/ext/pg_query/include/utils/palloc.h +25 -3
- data/ext/pg_query/include/utils/partcache.h +1 -1
- data/ext/pg_query/include/utils/pg_locale.h +17 -9
- data/ext/pg_query/include/utils/pg_lsn.h +1 -1
- data/ext/pg_query/include/utils/pgstat_internal.h +784 -0
- data/ext/pg_query/include/utils/pidfile.h +1 -1
- data/ext/pg_query/include/utils/plancache.h +6 -5
- data/ext/pg_query/include/utils/portal.h +12 -1
- data/ext/pg_query/include/utils/ps_status.h +1 -1
- data/ext/pg_query/include/utils/queryenvironment.h +1 -1
- data/ext/pg_query/include/utils/queryjumble.h +88 -0
- data/ext/pg_query/include/utils/regproc.h +14 -3
- data/ext/pg_query/include/utils/rel.h +71 -20
- data/ext/pg_query/include/utils/relcache.h +9 -7
- data/ext/pg_query/include/utils/reltrigger.h +1 -1
- data/ext/pg_query/include/utils/resowner.h +1 -1
- data/ext/pg_query/include/utils/rls.h +2 -2
- data/ext/pg_query/include/utils/ruleutils.h +4 -1
- data/ext/pg_query/include/utils/sharedtuplestore.h +1 -1
- data/ext/pg_query/include/utils/snapmgr.h +35 -14
- data/ext/pg_query/include/utils/snapshot.h +14 -1
- data/ext/pg_query/include/utils/sortsupport.h +117 -2
- data/ext/pg_query/include/utils/syscache.h +6 -1
- data/ext/pg_query/include/utils/timeout.h +11 -4
- data/ext/pg_query/include/utils/timestamp.h +6 -5
- data/ext/pg_query/include/utils/tuplesort.h +25 -11
- data/ext/pg_query/include/utils/tuplestore.h +2 -2
- data/ext/pg_query/include/utils/typcache.h +24 -17
- data/ext/pg_query/include/utils/tzparser.h +1 -1
- data/ext/pg_query/include/utils/varlena.h +5 -3
- data/ext/pg_query/include/utils/wait_event.h +289 -0
- data/ext/pg_query/include/utils/xml.h +4 -4
- data/ext/pg_query/pg_query.pb-c.c +4318 -2307
- data/ext/pg_query/pg_query_deparse.c +1114 -381
- data/ext/pg_query/pg_query_fingerprint.c +46 -10
- data/ext/pg_query/pg_query_fingerprint.h +3 -1
- data/ext/pg_query/pg_query_json_plpgsql.c +55 -12
- data/ext/pg_query/pg_query_normalize.c +163 -20
- data/ext/pg_query/pg_query_outfuncs.h +1 -0
- data/ext/pg_query/pg_query_outfuncs_json.c +65 -16
- data/ext/pg_query/pg_query_outfuncs_protobuf.c +70 -10
- data/ext/pg_query/pg_query_parse.c +1 -1
- data/ext/pg_query/pg_query_parse_plpgsql.c +79 -16
- data/ext/pg_query/pg_query_readfuncs_protobuf.c +42 -8
- data/ext/pg_query/pg_query_ruby.c +1 -1
- data/ext/pg_query/pg_query_scan.c +2 -1
- data/ext/pg_query/pg_query_split.c +3 -2
- data/ext/pg_query/src_backend_catalog_namespace.c +21 -9
- data/ext/pg_query/src_backend_catalog_pg_proc.c +4 -1
- data/ext/pg_query/src_backend_commands_define.c +11 -1
- data/ext/pg_query/src_backend_nodes_bitmapset.c +3 -1
- data/ext/pg_query/src_backend_nodes_copyfuncs.c +424 -109
- data/ext/pg_query/src_backend_nodes_equalfuncs.c +291 -46
- data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
- data/ext/pg_query/src_backend_nodes_list.c +86 -11
- data/ext/pg_query/src_backend_nodes_makefuncs.c +5 -4
- data/ext/pg_query/src_backend_nodes_nodeFuncs.c +55 -12
- data/ext/pg_query/src_backend_nodes_value.c +28 -19
- data/ext/pg_query/src_backend_parser_gram.c +33890 -31262
- data/ext/pg_query/src_backend_parser_parser.c +26 -7
- data/ext/pg_query/src_backend_parser_scan.c +644 -441
- data/ext/pg_query/src_backend_parser_scansup.c +4 -28
- data/ext/pg_query/src_backend_postmaster_postmaster.c +77 -106
- data/ext/pg_query/src_backend_storage_ipc_ipc.c +13 -4
- data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +5 -4
- data/ext/pg_query/src_backend_tcop_postgres.c +73 -24
- data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +140 -0
- data/ext/pg_query/src_backend_utils_adt_datum.c +13 -1
- data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
- data/ext/pg_query/src_backend_utils_adt_format_type.c +6 -2
- data/ext/pg_query/src_backend_utils_adt_ruleutils.c +109 -15
- data/ext/pg_query/src_backend_utils_error_assert.c +16 -14
- data/ext/pg_query/src_backend_utils_error_elog.c +172 -99
- data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +12 -17
- data/ext/pg_query/src_backend_utils_hash_dynahash.c +40 -10
- data/ext/pg_query/src_backend_utils_init_globals.c +5 -5
- data/ext/pg_query/src_backend_utils_mb_mbutils.c +55 -66
- data/ext/pg_query/src_backend_utils_misc_guc.c +207 -45
- data/ext/pg_query/src_backend_utils_mmgr_aset.c +7 -5
- data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +123 -35
- data/ext/pg_query/src_common_encnames.c +1 -1
- data/ext/pg_query/src_common_hashfn.c +3 -3
- data/ext/pg_query/src_common_keywords.c +15 -2
- data/ext/pg_query/src_common_kwlist_d.h +517 -494
- data/ext/pg_query/src_common_kwlookup.c +1 -1
- data/ext/pg_query/src_common_pg_prng.c +152 -0
- data/ext/pg_query/src_common_psprintf.c +1 -1
- data/ext/pg_query/src_common_string.c +7 -1
- data/ext/pg_query/src_common_stringinfo.c +1 -1
- data/ext/pg_query/src_common_wchar.c +712 -109
- data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +49 -22
- data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -18
- data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +1235 -1261
- data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
- data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +10 -10
- data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +2 -2
- data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +54 -56
- data/ext/pg_query/src_port_pg_bitutils.c +41 -52
- data/ext/pg_query/src_port_pgsleep.c +1 -1
- data/ext/pg_query/src_port_pgstrcasecmp.c +1 -1
- data/ext/pg_query/src_port_qsort.c +12 -224
- data/ext/pg_query/src_port_snprintf.c +46 -20
- data/ext/pg_query/src_port_strerror.c +9 -19
- data/ext/pg_query/src_port_strnlen.c +1 -1
- data/lib/pg_query/deparse.rb +7 -1
- data/lib/pg_query/filter_columns.rb +6 -4
- data/lib/pg_query/fingerprint.rb +18 -3
- data/lib/pg_query/node.rb +2 -2
- data/lib/pg_query/param_refs.rb +1 -1
- data/lib/pg_query/parse.rb +87 -51
- data/lib/pg_query/pg_query_pb.rb +1109 -942
- data/lib/pg_query/treewalker.rb +6 -0
- data/lib/pg_query/truncate.rb +54 -8
- data/lib/pg_query/version.rb +1 -1
- metadata +29 -18
- data/ext/pg_query/include/access/xloginsert.h +0 -64
- data/ext/pg_query/include/bootstrap/bootstrap.h +0 -62
- data/ext/pg_query/include/parser/parse_clause.h +0 -54
- data/ext/pg_query/include/parser/parse_collate.h +0 -27
- data/ext/pg_query/include/parser/parse_target.h +0 -46
- data/ext/pg_query/src_backend_libpq_pqcomm.c +0 -651
- data/ext/pg_query/src_backend_parser_parse_expr.c +0 -313
- data/ext/pg_query/src_port_erand48.c +0 -127
- data/ext/pg_query/src_port_random.c +0 -31
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* plpgsql.h - Definitions for the PL/pgSQL
|
|
4
4
|
* procedural language
|
|
5
5
|
*
|
|
6
|
-
* Portions Copyright (c) 1996-
|
|
6
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
7
7
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
8
8
|
*
|
|
9
9
|
*
|
|
@@ -64,7 +64,6 @@ typedef enum PLpgSQL_datum_type
|
|
|
64
64
|
PLPGSQL_DTYPE_ROW,
|
|
65
65
|
PLPGSQL_DTYPE_REC,
|
|
66
66
|
PLPGSQL_DTYPE_RECFIELD,
|
|
67
|
-
PLPGSQL_DTYPE_ARRAYELEM,
|
|
68
67
|
PLPGSQL_DTYPE_PROMISE
|
|
69
68
|
} PLpgSQL_datum_type;
|
|
70
69
|
|
|
@@ -128,8 +127,7 @@ typedef enum PLpgSQL_stmt_type
|
|
|
128
127
|
PLPGSQL_STMT_PERFORM,
|
|
129
128
|
PLPGSQL_STMT_CALL,
|
|
130
129
|
PLPGSQL_STMT_COMMIT,
|
|
131
|
-
PLPGSQL_STMT_ROLLBACK
|
|
132
|
-
PLPGSQL_STMT_SET
|
|
130
|
+
PLPGSQL_STMT_ROLLBACK
|
|
133
131
|
} PLpgSQL_stmt_type;
|
|
134
132
|
|
|
135
133
|
/*
|
|
@@ -218,10 +216,10 @@ typedef struct PLpgSQL_type
|
|
|
218
216
|
*/
|
|
219
217
|
typedef struct PLpgSQL_expr
|
|
220
218
|
{
|
|
221
|
-
char *query;
|
|
222
|
-
|
|
219
|
+
char *query; /* query string, verbatim from function body */
|
|
220
|
+
RawParseMode parseMode; /* raw_parser() mode to use */
|
|
221
|
+
SPIPlanPtr plan; /* plan, or NULL if not made yet */
|
|
223
222
|
Bitmapset *paramnos; /* all dnos referenced by this query */
|
|
224
|
-
int rwparam; /* dno of read/write param, or -1 if none */
|
|
225
223
|
|
|
226
224
|
/* function containing this expr (not set until we first parse query) */
|
|
227
225
|
struct PLpgSQL_function *func;
|
|
@@ -235,6 +233,17 @@ typedef struct PLpgSQL_expr
|
|
|
235
233
|
int32 expr_simple_typmod; /* result typmod, if simple */
|
|
236
234
|
bool expr_simple_mutable; /* true if simple expr is mutable */
|
|
237
235
|
|
|
236
|
+
/*
|
|
237
|
+
* These fields are used to optimize assignments to expanded-datum
|
|
238
|
+
* variables. If this expression is the source of an assignment to a
|
|
239
|
+
* simple variable, target_param holds that variable's dno; else it's -1.
|
|
240
|
+
* If we match a Param within expr_simple_expr to such a variable, that
|
|
241
|
+
* Param's address is stored in expr_rw_param; then expression code
|
|
242
|
+
* generation will allow the value for that Param to be passed read/write.
|
|
243
|
+
*/
|
|
244
|
+
int target_param; /* dno of assign target, or -1 if none */
|
|
245
|
+
Param *expr_rw_param; /* read/write Param within expr, if any */
|
|
246
|
+
|
|
238
247
|
/*
|
|
239
248
|
* If the expression was ever determined to be simple, we remember its
|
|
240
249
|
* CachedPlanSource and CachedPlan here. If expr_simple_plan_lxid matches
|
|
@@ -260,7 +269,7 @@ typedef struct PLpgSQL_expr
|
|
|
260
269
|
* Generic datum array item
|
|
261
270
|
*
|
|
262
271
|
* PLpgSQL_datum is the common supertype for PLpgSQL_var, PLpgSQL_row,
|
|
263
|
-
* PLpgSQL_rec,
|
|
272
|
+
* PLpgSQL_rec, and PLpgSQL_recfield.
|
|
264
273
|
*/
|
|
265
274
|
typedef struct PLpgSQL_datum
|
|
266
275
|
{
|
|
@@ -421,30 +430,6 @@ typedef struct PLpgSQL_recfield
|
|
|
421
430
|
/* if rectupledescid == INVALID_TUPLEDESC_IDENTIFIER, finfo isn't valid */
|
|
422
431
|
} PLpgSQL_recfield;
|
|
423
432
|
|
|
424
|
-
/*
|
|
425
|
-
* Element of array variable
|
|
426
|
-
*/
|
|
427
|
-
typedef struct PLpgSQL_arrayelem
|
|
428
|
-
{
|
|
429
|
-
PLpgSQL_datum_type dtype;
|
|
430
|
-
int dno;
|
|
431
|
-
/* end of PLpgSQL_datum fields */
|
|
432
|
-
|
|
433
|
-
PLpgSQL_expr *subscript;
|
|
434
|
-
int arrayparentno; /* dno of parent array variable */
|
|
435
|
-
|
|
436
|
-
/* Remaining fields are cached info about the array variable's type */
|
|
437
|
-
Oid parenttypoid; /* type of array variable; 0 if not yet set */
|
|
438
|
-
int32 parenttypmod; /* typmod of array variable */
|
|
439
|
-
Oid arraytypoid; /* OID of actual array type */
|
|
440
|
-
int32 arraytypmod; /* typmod of array (and its elements too) */
|
|
441
|
-
int16 arraytyplen; /* typlen of array type */
|
|
442
|
-
Oid elemtypoid; /* OID of array element type */
|
|
443
|
-
int16 elemtyplen; /* typlen of element type */
|
|
444
|
-
bool elemtypbyval; /* element type is pass-by-value? */
|
|
445
|
-
char elemtypalign; /* typalign of element type */
|
|
446
|
-
} PLpgSQL_arrayelem;
|
|
447
|
-
|
|
448
433
|
/*
|
|
449
434
|
* Item in the compilers namespace tree
|
|
450
435
|
*/
|
|
@@ -580,17 +565,6 @@ typedef struct PLpgSQL_stmt_rollback
|
|
|
580
565
|
bool chain;
|
|
581
566
|
} PLpgSQL_stmt_rollback;
|
|
582
567
|
|
|
583
|
-
/*
|
|
584
|
-
* SET statement
|
|
585
|
-
*/
|
|
586
|
-
typedef struct PLpgSQL_stmt_set
|
|
587
|
-
{
|
|
588
|
-
PLpgSQL_stmt_type cmd_type;
|
|
589
|
-
int lineno;
|
|
590
|
-
unsigned int stmtid;
|
|
591
|
-
PLpgSQL_expr *expr;
|
|
592
|
-
} PLpgSQL_stmt_set;
|
|
593
|
-
|
|
594
568
|
/*
|
|
595
569
|
* GET DIAGNOSTICS item
|
|
596
570
|
*/
|
|
@@ -919,8 +893,8 @@ typedef struct PLpgSQL_stmt_execsql
|
|
|
919
893
|
int lineno;
|
|
920
894
|
unsigned int stmtid;
|
|
921
895
|
PLpgSQL_expr *sqlstmt;
|
|
922
|
-
bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE?
|
|
923
|
-
|
|
896
|
+
bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE/MERGE? */
|
|
897
|
+
bool mod_stmt_set; /* is mod_stmt valid yet? */
|
|
924
898
|
bool into; /* INTO supplied? */
|
|
925
899
|
bool strict; /* INTO STRICT flag */
|
|
926
900
|
PLpgSQL_variable *target; /* INTO target (record or row) */
|
|
@@ -1023,9 +997,6 @@ typedef struct PLpgSQL_function
|
|
|
1023
997
|
int extra_warnings;
|
|
1024
998
|
int extra_errors;
|
|
1025
999
|
|
|
1026
|
-
/* count of statements inside function */
|
|
1027
|
-
unsigned int nstatements;
|
|
1028
|
-
|
|
1029
1000
|
/* the datums representing the function's local variables */
|
|
1030
1001
|
int ndatums;
|
|
1031
1002
|
PLpgSQL_datum **datums;
|
|
@@ -1034,6 +1005,10 @@ typedef struct PLpgSQL_function
|
|
|
1034
1005
|
/* function body parsetree */
|
|
1035
1006
|
PLpgSQL_stmt_block *action;
|
|
1036
1007
|
|
|
1008
|
+
/* data derived while parsing body */
|
|
1009
|
+
unsigned int nstatements; /* counter for assigning stmtids */
|
|
1010
|
+
bool requires_procedure_resowner; /* contains CALL or DO? */
|
|
1011
|
+
|
|
1037
1012
|
/* these fields change when the function is used */
|
|
1038
1013
|
struct PLpgSQL_execstate *cur_estate;
|
|
1039
1014
|
unsigned long use_count;
|
|
@@ -1095,6 +1070,9 @@ typedef struct PLpgSQL_execstate
|
|
|
1095
1070
|
EState *simple_eval_estate;
|
|
1096
1071
|
ResourceOwner simple_eval_resowner;
|
|
1097
1072
|
|
|
1073
|
+
/* if running nonatomic procedure or DO block, resowner to use for CALL */
|
|
1074
|
+
ResourceOwner procedure_resowner;
|
|
1075
|
+
|
|
1098
1076
|
/* lookup table to use for executing type casts */
|
|
1099
1077
|
HTAB *cast_hash;
|
|
1100
1078
|
MemoryContext cast_hash_context;
|
|
@@ -1110,6 +1088,7 @@ typedef struct PLpgSQL_execstate
|
|
|
1110
1088
|
|
|
1111
1089
|
/* status information for error context reporting */
|
|
1112
1090
|
PLpgSQL_stmt *err_stmt; /* current stmt */
|
|
1091
|
+
PLpgSQL_variable *err_var; /* current variable, if in a DECLARE section */
|
|
1113
1092
|
const char *err_text; /* additional state info */
|
|
1114
1093
|
|
|
1115
1094
|
void *plugin_info; /* reserved for use by optional plugin */
|
|
@@ -1121,8 +1100,6 @@ typedef struct PLpgSQL_execstate
|
|
|
1121
1100
|
* variable "PLpgSQL_plugin" and set it to point to a PLpgSQL_plugin struct.
|
|
1122
1101
|
* Typically the struct could just be static data in the plugin library.
|
|
1123
1102
|
* We expect that a plugin would do this at library load time (_PG_init()).
|
|
1124
|
-
* It must also be careful to set the rendezvous variable back to NULL
|
|
1125
|
-
* if it is unloaded (_PG_fini()).
|
|
1126
1103
|
*
|
|
1127
1104
|
* This structure is basically a collection of function pointers --- at
|
|
1128
1105
|
* various interesting points in pl_exec.c, we call these functions
|
|
@@ -1141,9 +1118,17 @@ typedef struct PLpgSQL_execstate
|
|
|
1141
1118
|
* statement.
|
|
1142
1119
|
*
|
|
1143
1120
|
* Also, immediately before any call to func_setup, PL/pgSQL fills in the
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1121
|
+
* remaining fields with pointers to some of its own functions, allowing the
|
|
1122
|
+
* plugin to invoke those functions conveniently. The exposed functions are:
|
|
1123
|
+
* plpgsql_exec_error_callback
|
|
1124
|
+
* exec_assign_expr
|
|
1125
|
+
* exec_assign_value
|
|
1126
|
+
* exec_eval_datum
|
|
1127
|
+
* exec_cast_value
|
|
1128
|
+
* (plpgsql_exec_error_callback is not actually meant to be called by the
|
|
1129
|
+
* plugin, but rather to allow it to identify PL/pgSQL error context stack
|
|
1130
|
+
* frames. The others are useful for debugger-like plugins to examine and
|
|
1131
|
+
* set variables.)
|
|
1147
1132
|
*/
|
|
1148
1133
|
typedef struct PLpgSQL_plugin
|
|
1149
1134
|
{
|
|
@@ -1156,8 +1141,20 @@ typedef struct PLpgSQL_plugin
|
|
|
1156
1141
|
|
|
1157
1142
|
/* Function pointers set by PL/pgSQL itself */
|
|
1158
1143
|
void (*error_callback) (void *arg);
|
|
1159
|
-
void (*assign_expr) (PLpgSQL_execstate *estate,
|
|
1144
|
+
void (*assign_expr) (PLpgSQL_execstate *estate,
|
|
1145
|
+
PLpgSQL_datum *target,
|
|
1160
1146
|
PLpgSQL_expr *expr);
|
|
1147
|
+
void (*assign_value) (PLpgSQL_execstate *estate,
|
|
1148
|
+
PLpgSQL_datum *target,
|
|
1149
|
+
Datum value, bool isNull,
|
|
1150
|
+
Oid valtype, int32 valtypmod);
|
|
1151
|
+
void (*eval_datum) (PLpgSQL_execstate *estate, PLpgSQL_datum *datum,
|
|
1152
|
+
Oid *typeId, int32 *typetypmod,
|
|
1153
|
+
Datum *value, bool *isnull);
|
|
1154
|
+
Datum (*cast_value) (PLpgSQL_execstate *estate,
|
|
1155
|
+
Datum value, bool *isnull,
|
|
1156
|
+
Oid valtype, int32 valtypmod,
|
|
1157
|
+
Oid reqtype, int32 reqtypmod);
|
|
1161
1158
|
} PLpgSQL_plugin;
|
|
1162
1159
|
|
|
1163
1160
|
/*
|
|
@@ -1281,6 +1278,7 @@ extern Datum plpgsql_exec_function(PLpgSQL_function *func,
|
|
|
1281
1278
|
FunctionCallInfo fcinfo,
|
|
1282
1279
|
EState *simple_eval_estate,
|
|
1283
1280
|
ResourceOwner simple_eval_resowner,
|
|
1281
|
+
ResourceOwner procedure_resowner,
|
|
1284
1282
|
bool atomic);
|
|
1285
1283
|
extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func,
|
|
1286
1284
|
TriggerData *trigdata);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* arch-arm.h
|
|
4
4
|
* Atomic operations considerations specific to ARM
|
|
5
5
|
*
|
|
6
|
-
* Portions Copyright (c) 2013-
|
|
6
|
+
* Portions Copyright (c) 2013-2022, PostgreSQL Global Development Group
|
|
7
7
|
*
|
|
8
8
|
* NOTES:
|
|
9
9
|
*
|
|
@@ -23,4 +23,10 @@
|
|
|
23
23
|
*/
|
|
24
24
|
#if !defined(__aarch64__) && !defined(__aarch64)
|
|
25
25
|
#define PG_DISABLE_64_BIT_ATOMICS
|
|
26
|
+
#else
|
|
27
|
+
/*
|
|
28
|
+
* Architecture Reference Manual for ARMv8 states aligned read/write to/from
|
|
29
|
+
* general purpose register is atomic.
|
|
30
|
+
*/
|
|
31
|
+
#define PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY
|
|
26
32
|
#endif /* __aarch64__ || __aarch64 */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* arch-ppc.h
|
|
4
4
|
* Atomic operations considerations specific to PowerPC
|
|
5
5
|
*
|
|
6
|
-
* Portions Copyright (c) 1996-
|
|
6
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
7
7
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
8
8
|
*
|
|
9
9
|
* NOTES:
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* support for xadd and cmpxchg. Given that the 386 isn't supported anywhere
|
|
8
8
|
* anymore that's not much of a restriction luckily.
|
|
9
9
|
*
|
|
10
|
-
* Portions Copyright (c) 1996-
|
|
10
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
11
11
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
12
12
|
*
|
|
13
13
|
* NOTES:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Fallback for platforms without spinlock and/or atomics support. Slower
|
|
5
5
|
* than native atomics support, but not unusably slow.
|
|
6
6
|
*
|
|
7
|
-
* Portions Copyright (c) 1996-
|
|
7
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
8
8
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
9
9
|
*
|
|
10
10
|
* src/include/port/atomics/fallback.h
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* generic-gcc.h
|
|
4
4
|
* Atomic operations, implemented using gcc (or compatible) intrinsics.
|
|
5
5
|
*
|
|
6
|
-
* Portions Copyright (c) 1996-
|
|
6
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
7
7
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
8
8
|
*
|
|
9
9
|
* NOTES:
|
|
10
10
|
*
|
|
11
11
|
* Documentation:
|
|
12
12
|
* * Legacy __sync Built-in Functions for Atomic Memory Access
|
|
13
|
-
*
|
|
13
|
+
* https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/_005f_005fsync-Builtins.html
|
|
14
14
|
* * Built-in functions for memory model aware atomic operations
|
|
15
|
-
*
|
|
15
|
+
* https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/_005f_005fatomic-Builtins.html
|
|
16
16
|
*
|
|
17
17
|
* src/include/port/atomics/generic-gcc.h
|
|
18
18
|
*
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Implement higher level operations based on some lower level atomic
|
|
5
5
|
* operations.
|
|
6
6
|
*
|
|
7
|
-
* Portions Copyright (c) 1996-
|
|
7
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
8
8
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
9
9
|
*
|
|
10
10
|
* src/include/port/atomics/generic.h
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* For an introduction to using memory barriers within the PostgreSQL backend,
|
|
29
29
|
* see src/backend/storage/lmgr/README.barrier
|
|
30
30
|
*
|
|
31
|
-
* Portions Copyright (c) 1996-
|
|
31
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
32
32
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
33
33
|
*
|
|
34
34
|
* src/include/port/atomics.h
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Miscellaneous functions for bit-wise operations.
|
|
5
5
|
*
|
|
6
6
|
*
|
|
7
|
-
* Copyright (c) 2019-
|
|
7
|
+
* Copyright (c) 2019-2022, PostgreSQL Global Development Group
|
|
8
8
|
*
|
|
9
9
|
* src/include/port/pg_bitutils.h
|
|
10
10
|
*
|
|
@@ -13,15 +13,9 @@
|
|
|
13
13
|
#ifndef PG_BITUTILS_H
|
|
14
14
|
#define PG_BITUTILS_H
|
|
15
15
|
|
|
16
|
-
#ifndef FRONTEND
|
|
17
16
|
extern PGDLLIMPORT const uint8 pg_leftmost_one_pos[256];
|
|
18
17
|
extern PGDLLIMPORT const uint8 pg_rightmost_one_pos[256];
|
|
19
18
|
extern PGDLLIMPORT const uint8 pg_number_of_ones[256];
|
|
20
|
-
#else
|
|
21
|
-
extern const uint8 pg_leftmost_one_pos[256];
|
|
22
|
-
extern const uint8 pg_rightmost_one_pos[256];
|
|
23
|
-
extern const uint8 pg_number_of_ones[256];
|
|
24
|
-
#endif
|
|
25
19
|
|
|
26
20
|
/*
|
|
27
21
|
* pg_leftmost_one_pos32
|
|
@@ -137,7 +131,7 @@ pg_rightmost_one_pos64(uint64 word)
|
|
|
137
131
|
|
|
138
132
|
/*
|
|
139
133
|
* pg_nextpower2_32
|
|
140
|
-
* Returns the next
|
|
134
|
+
* Returns the next higher power of 2 above 'num', or 'num' if it's
|
|
141
135
|
* already a power of 2.
|
|
142
136
|
*
|
|
143
137
|
* 'num' mustn't be 0 or be above PG_UINT32_MAX / 2 + 1.
|
|
@@ -160,7 +154,7 @@ pg_nextpower2_32(uint32 num)
|
|
|
160
154
|
|
|
161
155
|
/*
|
|
162
156
|
* pg_nextpower2_64
|
|
163
|
-
* Returns the next
|
|
157
|
+
* Returns the next higher power of 2 above 'num', or 'num' if it's
|
|
164
158
|
* already a power of 2.
|
|
165
159
|
*
|
|
166
160
|
* 'num' mustn't be 0 or be above PG_UINT64_MAX / 2 + 1.
|
|
@@ -181,6 +175,52 @@ pg_nextpower2_64(uint64 num)
|
|
|
181
175
|
return ((uint64) 1) << (pg_leftmost_one_pos64(num) + 1);
|
|
182
176
|
}
|
|
183
177
|
|
|
178
|
+
/*
|
|
179
|
+
* pg_nextpower2_size_t
|
|
180
|
+
* Returns the next higher power of 2 above 'num', for a size_t input.
|
|
181
|
+
*/
|
|
182
|
+
#if SIZEOF_SIZE_T == 4
|
|
183
|
+
#define pg_nextpower2_size_t(num) pg_nextpower2_32(num)
|
|
184
|
+
#else
|
|
185
|
+
#define pg_nextpower2_size_t(num) pg_nextpower2_64(num)
|
|
186
|
+
#endif
|
|
187
|
+
|
|
188
|
+
/*
|
|
189
|
+
* pg_prevpower2_32
|
|
190
|
+
* Returns the next lower power of 2 below 'num', or 'num' if it's
|
|
191
|
+
* already a power of 2.
|
|
192
|
+
*
|
|
193
|
+
* 'num' mustn't be 0.
|
|
194
|
+
*/
|
|
195
|
+
static inline uint32
|
|
196
|
+
pg_prevpower2_32(uint32 num)
|
|
197
|
+
{
|
|
198
|
+
return ((uint32) 1) << pg_leftmost_one_pos32(num);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/*
|
|
202
|
+
* pg_prevpower2_64
|
|
203
|
+
* Returns the next lower power of 2 below 'num', or 'num' if it's
|
|
204
|
+
* already a power of 2.
|
|
205
|
+
*
|
|
206
|
+
* 'num' mustn't be 0.
|
|
207
|
+
*/
|
|
208
|
+
static inline uint64
|
|
209
|
+
pg_prevpower2_64(uint64 num)
|
|
210
|
+
{
|
|
211
|
+
return ((uint64) 1) << pg_leftmost_one_pos64(num);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/*
|
|
215
|
+
* pg_prevpower2_size_t
|
|
216
|
+
* Returns the next lower power of 2 below 'num', for a size_t input.
|
|
217
|
+
*/
|
|
218
|
+
#if SIZEOF_SIZE_T == 4
|
|
219
|
+
#define pg_prevpower2_size_t(num) pg_prevpower2_32(num)
|
|
220
|
+
#else
|
|
221
|
+
#define pg_prevpower2_size_t(num) pg_prevpower2_64(num)
|
|
222
|
+
#endif
|
|
223
|
+
|
|
184
224
|
/*
|
|
185
225
|
* pg_ceil_log2_32
|
|
186
226
|
* Returns equivalent of ceil(log2(num))
|
|
@@ -207,20 +247,56 @@ pg_ceil_log2_64(uint64 num)
|
|
|
207
247
|
return pg_leftmost_one_pos64(num - 1) + 1;
|
|
208
248
|
}
|
|
209
249
|
|
|
210
|
-
/*
|
|
250
|
+
/*
|
|
251
|
+
* With MSVC on x86_64 builds, try using native popcnt instructions via the
|
|
252
|
+
* __popcnt and __popcnt64 intrinsics. These don't work the same as GCC's
|
|
253
|
+
* __builtin_popcount* intrinsic functions as they always emit popcnt
|
|
254
|
+
* instructions.
|
|
255
|
+
*/
|
|
256
|
+
#if defined(_MSC_VER) && defined(_M_AMD64)
|
|
257
|
+
#define HAVE_X86_64_POPCNTQ
|
|
258
|
+
#endif
|
|
259
|
+
|
|
260
|
+
/*
|
|
261
|
+
* On x86_64, we can use the hardware popcount instruction, but only if
|
|
262
|
+
* we can verify that the CPU supports it via the cpuid instruction.
|
|
263
|
+
*
|
|
264
|
+
* Otherwise, we fall back to a hand-rolled implementation.
|
|
265
|
+
*/
|
|
266
|
+
#ifdef HAVE_X86_64_POPCNTQ
|
|
267
|
+
#if defined(HAVE__GET_CPUID) || defined(HAVE__CPUID)
|
|
268
|
+
#define TRY_POPCNT_FAST 1
|
|
269
|
+
#endif
|
|
270
|
+
#endif
|
|
271
|
+
|
|
272
|
+
#ifdef TRY_POPCNT_FAST
|
|
273
|
+
/* Attempt to use the POPCNT instruction, but perform a runtime check first */
|
|
211
274
|
extern int (*pg_popcount32) (uint32 word);
|
|
212
275
|
extern int (*pg_popcount64) (uint64 word);
|
|
213
276
|
|
|
277
|
+
#else
|
|
278
|
+
/* Use a portable implementation -- no need for a function pointer. */
|
|
279
|
+
extern int pg_popcount32(uint32 word);
|
|
280
|
+
extern int pg_popcount64(uint64 word);
|
|
281
|
+
|
|
282
|
+
#endif /* TRY_POPCNT_FAST */
|
|
283
|
+
|
|
214
284
|
/* Count the number of one-bits in a byte array */
|
|
215
285
|
extern uint64 pg_popcount(const char *buf, int bytes);
|
|
216
286
|
|
|
217
287
|
/*
|
|
218
|
-
* Rotate the bits of "word" to the right by n bits.
|
|
288
|
+
* Rotate the bits of "word" to the right/left by n bits.
|
|
219
289
|
*/
|
|
220
290
|
static inline uint32
|
|
221
291
|
pg_rotate_right32(uint32 word, int n)
|
|
222
292
|
{
|
|
223
|
-
return (word >> n) | (word << (
|
|
293
|
+
return (word >> n) | (word << (32 - n));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
static inline uint32
|
|
297
|
+
pg_rotate_left32(uint32 word, int n)
|
|
298
|
+
{
|
|
299
|
+
return (word << n) | (word >> (32 - n));
|
|
224
300
|
}
|
|
225
301
|
|
|
226
302
|
#endif /* PG_BITUTILS_H */
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* return the same. Use caution when using these wrapper macros with signed
|
|
12
12
|
* integers.
|
|
13
13
|
*
|
|
14
|
-
* Copyright (c) 2015-
|
|
14
|
+
* Copyright (c) 2015-2022, PostgreSQL Global Development Group
|
|
15
15
|
*
|
|
16
16
|
* src/include/port/pg_bswap.h
|
|
17
17
|
*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* EQ_CRC32C(c1, c2)
|
|
24
24
|
* Check for equality of two CRCs.
|
|
25
25
|
*
|
|
26
|
-
* Portions Copyright (c) 1996-
|
|
26
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
27
27
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
28
28
|
*
|
|
29
29
|
* src/include/port/pg_crc32c.h
|