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
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
/*-------------------------------------------------------------------------
|
|
11
11
|
*
|
|
12
12
|
* scansup.c
|
|
13
|
-
* support routines
|
|
14
|
-
* backend as well as the bootstrap backend
|
|
13
|
+
* scanner support routines used by the core lexer
|
|
15
14
|
*
|
|
16
|
-
* Portions Copyright (c) 1996-
|
|
15
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
17
16
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
18
17
|
*
|
|
19
18
|
*
|
|
@@ -29,19 +28,6 @@
|
|
|
29
28
|
#include "mb/pg_wchar.h"
|
|
30
29
|
#include "parser/scansup.h"
|
|
31
30
|
|
|
32
|
-
/* ----------------
|
|
33
|
-
* scanstr
|
|
34
|
-
*
|
|
35
|
-
* if the string passed in has escaped codes, map the escape codes to actual
|
|
36
|
-
* chars
|
|
37
|
-
*
|
|
38
|
-
* the string returned is palloc'd and should eventually be pfree'd by the
|
|
39
|
-
* caller!
|
|
40
|
-
* ----------------
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
31
|
|
|
46
32
|
/*
|
|
47
33
|
* downcase_truncate_identifier() --- do appropriate downcasing and
|
|
@@ -119,20 +105,10 @@ truncate_identifier(char *ident, int len, bool warn)
|
|
|
119
105
|
{
|
|
120
106
|
len = pg_mbcliplen(ident, len, NAMEDATALEN - 1);
|
|
121
107
|
if (warn)
|
|
122
|
-
{
|
|
123
|
-
/*
|
|
124
|
-
* We avoid using %.*s here because it can misbehave if the data
|
|
125
|
-
* is not valid in what libc thinks is the prevailing encoding.
|
|
126
|
-
*/
|
|
127
|
-
char buf[NAMEDATALEN];
|
|
128
|
-
|
|
129
|
-
memcpy(buf, ident, len);
|
|
130
|
-
buf[len] = '\0';
|
|
131
108
|
ereport(NOTICE,
|
|
132
109
|
(errcode(ERRCODE_NAME_TOO_LONG),
|
|
133
|
-
errmsg("identifier \"%s\" will be truncated to \"
|
|
134
|
-
ident,
|
|
135
|
-
}
|
|
110
|
+
errmsg("identifier \"%s\" will be truncated to \"%.*s\"",
|
|
111
|
+
ident, len, ident)));
|
|
136
112
|
ident[len] = '\0';
|
|
137
113
|
}
|
|
138
114
|
}
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* clients.
|
|
39
39
|
*
|
|
40
40
|
*
|
|
41
|
-
* Portions Copyright (c) 1996-
|
|
41
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
42
42
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
43
43
|
*
|
|
44
44
|
*
|
|
@@ -101,21 +101,22 @@
|
|
|
101
101
|
|
|
102
102
|
#include "access/transam.h"
|
|
103
103
|
#include "access/xlog.h"
|
|
104
|
-
#include "
|
|
104
|
+
#include "access/xlogrecovery.h"
|
|
105
105
|
#include "catalog/pg_control.h"
|
|
106
106
|
#include "common/file_perm.h"
|
|
107
107
|
#include "common/ip.h"
|
|
108
|
+
#include "common/pg_prng.h"
|
|
108
109
|
#include "common/string.h"
|
|
109
110
|
#include "lib/ilist.h"
|
|
110
111
|
#include "libpq/auth.h"
|
|
111
112
|
#include "libpq/libpq.h"
|
|
112
113
|
#include "libpq/pqformat.h"
|
|
113
114
|
#include "libpq/pqsignal.h"
|
|
114
|
-
#include "miscadmin.h"
|
|
115
115
|
#include "pg_getopt.h"
|
|
116
116
|
#include "pgstat.h"
|
|
117
117
|
#include "port/pg_bswap.h"
|
|
118
118
|
#include "postmaster/autovacuum.h"
|
|
119
|
+
#include "postmaster/auxprocess.h"
|
|
119
120
|
#include "postmaster/bgworker_internals.h"
|
|
120
121
|
#include "postmaster/fork_process.h"
|
|
121
122
|
#include "postmaster/interrupt.h"
|
|
@@ -135,6 +136,7 @@
|
|
|
135
136
|
#include "utils/memutils.h"
|
|
136
137
|
#include "utils/pidfile.h"
|
|
137
138
|
#include "utils/ps_status.h"
|
|
139
|
+
#include "utils/queryjumble.h"
|
|
138
140
|
#include "utils/timeout.h"
|
|
139
141
|
#include "utils/timestamp.h"
|
|
140
142
|
#include "utils/varlena.h"
|
|
@@ -161,28 +163,32 @@
|
|
|
161
163
|
* authorization phase). This is used mainly to keep track of how many
|
|
162
164
|
* children we have and send them appropriate signals when necessary.
|
|
163
165
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
+
* As shown in the above set of backend types, this list includes not only
|
|
167
|
+
* "normal" client sessions, but also autovacuum workers, walsenders, and
|
|
168
|
+
* background workers. (Note that at the time of launch, walsenders are
|
|
169
|
+
* labeled BACKEND_TYPE_NORMAL; we relabel them to BACKEND_TYPE_WALSND
|
|
170
|
+
* upon noticing they've changed their PMChildFlags entry. Hence that check
|
|
171
|
+
* must be done before any operation that needs to distinguish walsenders
|
|
172
|
+
* from normal backends.)
|
|
173
|
+
*
|
|
166
174
|
* Also, "dead_end" children are in it: these are children launched just for
|
|
167
175
|
* the purpose of sending a friendly rejection message to a would-be client.
|
|
168
176
|
* We must track them because they are attached to shared memory, but we know
|
|
169
177
|
* they will never become live backends. dead_end children are not assigned a
|
|
170
|
-
* PMChildSlot.
|
|
178
|
+
* PMChildSlot. dead_end children have bkend_type NORMAL.
|
|
171
179
|
*
|
|
172
|
-
*
|
|
180
|
+
* "Special" children such as the startup, bgwriter and autovacuum launcher
|
|
181
|
+
* tasks are not in this list. They are tracked via StartupPID and other
|
|
182
|
+
* pid_t variables below. (Thus, there can't be more than one of any given
|
|
183
|
+
* "special" child process type. We use BackendList entries for any child
|
|
184
|
+
* process there can be more than one of.)
|
|
173
185
|
*/
|
|
174
186
|
typedef struct bkend
|
|
175
187
|
{
|
|
176
188
|
pid_t pid; /* process id of backend */
|
|
177
189
|
int32 cancel_key; /* cancel key for cancels for this backend */
|
|
178
190
|
int child_slot; /* PMChildSlot for this backend, if any */
|
|
179
|
-
|
|
180
|
-
/*
|
|
181
|
-
* Flavor of backend or auxiliary process. Note that BACKEND_TYPE_WALSND
|
|
182
|
-
* backends initially announce themselves as BACKEND_TYPE_NORMAL, so if
|
|
183
|
-
* bkend_type is normal, you should check for a recent transition.
|
|
184
|
-
*/
|
|
185
|
-
int bkend_type;
|
|
191
|
+
int bkend_type; /* child process flavor, see above */
|
|
186
192
|
bool dead_end; /* is it going to send an error and quit? */
|
|
187
193
|
bool bgworker_notify; /* gets bgworker start/stop notifications */
|
|
188
194
|
dlist_node elem; /* list link in BackendList */
|
|
@@ -222,11 +228,6 @@ static Backend *ShmemBackendArray;
|
|
|
222
228
|
#define MAXLISTEN 64
|
|
223
229
|
|
|
224
230
|
|
|
225
|
-
/*
|
|
226
|
-
* Set by the -o option
|
|
227
|
-
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
231
|
/*
|
|
231
232
|
* These globals control the behavior of the postmaster in case some
|
|
232
233
|
* backend dumps core. Normally, it kills all peers of the dead backend
|
|
@@ -251,8 +252,8 @@ static Backend *ShmemBackendArray;
|
|
|
251
252
|
|
|
252
253
|
|
|
253
254
|
|
|
254
|
-
/* PIDs of special child processes; 0 when not running */
|
|
255
255
|
|
|
256
|
+
/* PIDs of special child processes; 0 when not running */
|
|
256
257
|
|
|
257
258
|
|
|
258
259
|
|
|
@@ -349,13 +350,6 @@ typedef enum
|
|
|
349
350
|
* connsAllowed is a sub-state indicator showing the active restriction.
|
|
350
351
|
* It is of no interest unless pmState is PM_RUN or PM_HOT_STANDBY.
|
|
351
352
|
*/
|
|
352
|
-
typedef enum
|
|
353
|
-
{
|
|
354
|
-
ALLOW_ALL_CONNS, /* normal not-shutting-down state */
|
|
355
|
-
ALLOW_SUPERUSER_CONNS, /* only superusers can connect */
|
|
356
|
-
ALLOW_NO_CONNS /* no new connections allowed, period */
|
|
357
|
-
} ConnsAllowedState;
|
|
358
|
-
|
|
359
353
|
|
|
360
354
|
|
|
361
355
|
/* Start time of SIGKILL timeout during immediate shutdown or child crash */
|
|
@@ -452,9 +446,10 @@ static void InitPostmasterDeathWatchHandle(void);
|
|
|
452
446
|
* even during recovery.
|
|
453
447
|
*/
|
|
454
448
|
#define PgArchStartupAllowed() \
|
|
455
|
-
((XLogArchivingActive() && pmState == PM_RUN) ||
|
|
456
|
-
|
|
457
|
-
|
|
449
|
+
(((XLogArchivingActive() && pmState == PM_RUN) || \
|
|
450
|
+
(XLogArchivingAlways() && \
|
|
451
|
+
(pmState == PM_RECOVERY || pmState == PM_HOT_STANDBY))) && \
|
|
452
|
+
PgArchCanRestart())
|
|
458
453
|
|
|
459
454
|
#ifdef EXEC_BACKEND
|
|
460
455
|
|
|
@@ -521,13 +516,13 @@ typedef struct
|
|
|
521
516
|
PGPROC *AuxiliaryProcs;
|
|
522
517
|
PGPROC *PreparedXactProcs;
|
|
523
518
|
PMSignalData *PMSignalState;
|
|
524
|
-
InheritableSocket pgStatSock;
|
|
525
519
|
pid_t PostmasterPid;
|
|
526
520
|
TimestampTz PgStartTime;
|
|
527
521
|
TimestampTz PgReloadTime;
|
|
528
522
|
pg_time_t first_syslogger_file_time;
|
|
529
523
|
bool redirection_done;
|
|
530
524
|
bool IsBinaryUpgrade;
|
|
525
|
+
bool query_id_enabled;
|
|
531
526
|
int max_safe_fds;
|
|
532
527
|
int MaxBackends;
|
|
533
528
|
#ifdef WIN32
|
|
@@ -540,7 +535,6 @@ typedef struct
|
|
|
540
535
|
#endif
|
|
541
536
|
char my_exec_path[MAXPGPATH];
|
|
542
537
|
char pkglib_path[MAXPGPATH];
|
|
543
|
-
char ExtraOptions[MAXPGPATH];
|
|
544
538
|
} BackendParameters;
|
|
545
539
|
|
|
546
540
|
static void read_backend_variables(char *id, Port *port);
|
|
@@ -558,6 +552,7 @@ static void ShmemBackendArrayRemove(Backend *bn);
|
|
|
558
552
|
#endif /* EXEC_BACKEND */
|
|
559
553
|
|
|
560
554
|
#define StartupDataBase() StartChildProcess(StartupProcess)
|
|
555
|
+
#define StartArchiver() StartChildProcess(ArchiverProcess)
|
|
561
556
|
#define StartBackgroundWriter() StartChildProcess(BgWriterProcess)
|
|
562
557
|
#define StartCheckpointer() StartChildProcess(CheckpointerProcess)
|
|
563
558
|
#define StartWalWriter() StartChildProcess(WalWriterProcess)
|
|
@@ -582,6 +577,10 @@ HANDLE PostmasterHandle;
|
|
|
582
577
|
/*
|
|
583
578
|
* Postmaster main entry point
|
|
584
579
|
*/
|
|
580
|
+
#ifdef WIN32
|
|
581
|
+
#endif
|
|
582
|
+
#ifdef SIGURG
|
|
583
|
+
#endif
|
|
585
584
|
#ifdef SIGTTIN
|
|
586
585
|
#endif
|
|
587
586
|
#ifdef SIGTTOU
|
|
@@ -764,7 +763,8 @@ HANDLE PostmasterHandle;
|
|
|
764
763
|
*
|
|
765
764
|
* Called early in the postmaster and every backend.
|
|
766
765
|
*/
|
|
767
|
-
|
|
766
|
+
#ifndef WIN32
|
|
767
|
+
#endif
|
|
768
768
|
|
|
769
769
|
|
|
770
770
|
/*
|
|
@@ -838,7 +838,7 @@ HANDLE PostmasterHandle;
|
|
|
838
838
|
|
|
839
839
|
/*
|
|
840
840
|
* HandleChildCrash -- cleanup after failed backend, bgwriter, checkpointer,
|
|
841
|
-
* walwriter, autovacuum, or background worker.
|
|
841
|
+
* walwriter, autovacuum, archiver or background worker.
|
|
842
842
|
*
|
|
843
843
|
* The objectives here are to clean up our local state about the child
|
|
844
844
|
* process, and to signal all other remaining children to quickdie.
|
|
@@ -926,6 +926,8 @@ HANDLE PostmasterHandle;
|
|
|
926
926
|
* returns: nothing. Will not return at all if there's any failure.
|
|
927
927
|
*
|
|
928
928
|
* Note: this code does not depend on having any access to shared memory.
|
|
929
|
+
* Indeed, our approach to SIGTERM/timeout handling *requires* that
|
|
930
|
+
* shared memory not have been touched yet; see comments within.
|
|
929
931
|
* In the EXEC_BACKEND case, we are physically attached to shared memory
|
|
930
932
|
* but have not yet set up most of our local pointers to shmem structures.
|
|
931
933
|
*/
|
|
@@ -936,8 +938,7 @@ HANDLE PostmasterHandle;
|
|
|
936
938
|
* BackendRun -- set up the backend's argument list and invoke PostgresMain()
|
|
937
939
|
*
|
|
938
940
|
* returns:
|
|
939
|
-
*
|
|
940
|
-
* If PostgresMain() fails, return status.
|
|
941
|
+
* Doesn't return at all.
|
|
941
942
|
*/
|
|
942
943
|
|
|
943
944
|
|
|
@@ -1127,16 +1128,18 @@ retry:
|
|
|
1127
1128
|
NULL);
|
|
1128
1129
|
if (paramHandle == INVALID_HANDLE_VALUE)
|
|
1129
1130
|
{
|
|
1130
|
-
|
|
1131
|
-
|
|
1131
|
+
ereport(LOG,
|
|
1132
|
+
(errmsg("could not create backend parameter file mapping: error code %lu",
|
|
1133
|
+
GetLastError())));
|
|
1132
1134
|
return -1;
|
|
1133
1135
|
}
|
|
1134
1136
|
|
|
1135
1137
|
param = MapViewOfFile(paramHandle, FILE_MAP_WRITE, 0, 0, sizeof(BackendParameters));
|
|
1136
1138
|
if (!param)
|
|
1137
1139
|
{
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
+
ereport(LOG,
|
|
1141
|
+
(errmsg("could not map backend parameter memory: error code %lu",
|
|
1142
|
+
GetLastError())));
|
|
1140
1143
|
CloseHandle(paramHandle);
|
|
1141
1144
|
return -1;
|
|
1142
1145
|
}
|
|
@@ -1161,7 +1164,8 @@ retry:
|
|
|
1161
1164
|
}
|
|
1162
1165
|
if (cmdLine[sizeof(cmdLine) - 2] != '\0')
|
|
1163
1166
|
{
|
|
1164
|
-
|
|
1167
|
+
ereport(LOG,
|
|
1168
|
+
(errmsg("subprocess command line too long")));
|
|
1165
1169
|
UnmapViewOfFile(param);
|
|
1166
1170
|
CloseHandle(paramHandle);
|
|
1167
1171
|
return -1;
|
|
@@ -1178,8 +1182,9 @@ retry:
|
|
|
1178
1182
|
if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED,
|
|
1179
1183
|
NULL, NULL, &si, &pi))
|
|
1180
1184
|
{
|
|
1181
|
-
|
|
1182
|
-
|
|
1185
|
+
ereport(LOG,
|
|
1186
|
+
(errmsg("CreateProcess() call failed: %m (error code %lu)",
|
|
1187
|
+
GetLastError())));
|
|
1183
1188
|
UnmapViewOfFile(param);
|
|
1184
1189
|
CloseHandle(paramHandle);
|
|
1185
1190
|
return -1;
|
|
@@ -1204,11 +1209,13 @@ retry:
|
|
|
1204
1209
|
|
|
1205
1210
|
/* Drop the parameter shared memory that is now inherited to the backend */
|
|
1206
1211
|
if (!UnmapViewOfFile(param))
|
|
1207
|
-
|
|
1208
|
-
|
|
1212
|
+
ereport(LOG,
|
|
1213
|
+
(errmsg("could not unmap view of backend parameter file: error code %lu",
|
|
1214
|
+
GetLastError())));
|
|
1209
1215
|
if (!CloseHandle(paramHandle))
|
|
1210
|
-
|
|
1211
|
-
|
|
1216
|
+
ereport(LOG,
|
|
1217
|
+
(errmsg("could not close handle to backend parameter file: error code %lu",
|
|
1218
|
+
GetLastError())));
|
|
1212
1219
|
|
|
1213
1220
|
/*
|
|
1214
1221
|
* Reserve the memory region used by our main shared memory segment before
|
|
@@ -1314,9 +1321,6 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1314
1321
|
IsPostmasterEnvironment = true;
|
|
1315
1322
|
whereToSendOutput = DestNone;
|
|
1316
1323
|
|
|
1317
|
-
/* Setup as postmaster child */
|
|
1318
|
-
InitPostmasterChild();
|
|
1319
|
-
|
|
1320
1324
|
/* Setup essential subsystems (to ensure elog() behaves sanely) */
|
|
1321
1325
|
InitializeGUCOptions();
|
|
1322
1326
|
|
|
@@ -1331,6 +1335,9 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1331
1335
|
/* Close the postmaster's sockets (as soon as we know them) */
|
|
1332
1336
|
ClosePostmasterPorts(strcmp(argv[1], "--forklog") == 0);
|
|
1333
1337
|
|
|
1338
|
+
/* Setup as postmaster child */
|
|
1339
|
+
InitPostmasterChild();
|
|
1340
|
+
|
|
1334
1341
|
/*
|
|
1335
1342
|
* If appropriate, physically re-attach to shared memory segment. We want
|
|
1336
1343
|
* to do this before going any further to ensure that we can attach at the
|
|
@@ -1340,7 +1347,7 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1340
1347
|
* If testing EXEC_BACKEND on Linux, you should run this as root before
|
|
1341
1348
|
* starting the postmaster:
|
|
1342
1349
|
*
|
|
1343
|
-
*
|
|
1350
|
+
* sysctl -w kernel.randomize_va_space=0
|
|
1344
1351
|
*
|
|
1345
1352
|
* This prevents using randomized stack and code addresses that cause the
|
|
1346
1353
|
* child process's memory map to be different from the parent's, making it
|
|
@@ -1350,7 +1357,7 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1350
1357
|
if (strcmp(argv[1], "--forkbackend") == 0 ||
|
|
1351
1358
|
strcmp(argv[1], "--forkavlauncher") == 0 ||
|
|
1352
1359
|
strcmp(argv[1], "--forkavworker") == 0 ||
|
|
1353
|
-
strcmp(argv[1], "--
|
|
1360
|
+
strcmp(argv[1], "--forkaux") == 0 ||
|
|
1354
1361
|
strncmp(argv[1], "--forkbgworker=", 15) == 0)
|
|
1355
1362
|
PGSharedMemoryReAttach();
|
|
1356
1363
|
else
|
|
@@ -1362,19 +1369,6 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1362
1369
|
if (strcmp(argv[1], "--forkavworker") == 0)
|
|
1363
1370
|
AutovacuumWorkerIAm();
|
|
1364
1371
|
|
|
1365
|
-
/*
|
|
1366
|
-
* Start our win32 signal implementation. This has to be done after we
|
|
1367
|
-
* read the backend variables, because we need to pick up the signal pipe
|
|
1368
|
-
* from the parent process.
|
|
1369
|
-
*/
|
|
1370
|
-
#ifdef WIN32
|
|
1371
|
-
pgwin32_signal_initialize();
|
|
1372
|
-
#endif
|
|
1373
|
-
|
|
1374
|
-
/* In EXEC_BACKEND case we will not have inherited these settings */
|
|
1375
|
-
pqinitmask();
|
|
1376
|
-
PG_SETMASK(&BlockSig);
|
|
1377
|
-
|
|
1378
1372
|
/* Read in remaining GUC variables */
|
|
1379
1373
|
read_nondefault_variables();
|
|
1380
1374
|
|
|
@@ -1451,8 +1445,12 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1451
1445
|
/* And run the backend */
|
|
1452
1446
|
BackendRun(&port); /* does not return */
|
|
1453
1447
|
}
|
|
1454
|
-
if (strcmp(argv[1], "--
|
|
1448
|
+
if (strcmp(argv[1], "--forkaux") == 0)
|
|
1455
1449
|
{
|
|
1450
|
+
AuxProcType auxtype;
|
|
1451
|
+
|
|
1452
|
+
Assert(argc == 4);
|
|
1453
|
+
|
|
1456
1454
|
/* Restore basic shared memory pointers */
|
|
1457
1455
|
InitShmemAccess(UsedShmemSegAddr);
|
|
1458
1456
|
|
|
@@ -1462,7 +1460,8 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1462
1460
|
/* Attach process to shared data structures */
|
|
1463
1461
|
CreateSharedMemoryAndSemaphores();
|
|
1464
1462
|
|
|
1465
|
-
|
|
1463
|
+
auxtype = atoi(argv[3]);
|
|
1464
|
+
AuxiliaryProcessMain(auxtype); /* does not return */
|
|
1466
1465
|
}
|
|
1467
1466
|
if (strcmp(argv[1], "--forkavlauncher") == 0)
|
|
1468
1467
|
{
|
|
@@ -1512,18 +1511,6 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1512
1511
|
|
|
1513
1512
|
StartBackgroundWorker();
|
|
1514
1513
|
}
|
|
1515
|
-
if (strcmp(argv[1], "--forkarch") == 0)
|
|
1516
|
-
{
|
|
1517
|
-
/* Do not want to attach to shared memory */
|
|
1518
|
-
|
|
1519
|
-
PgArchiverMain(argc, argv); /* does not return */
|
|
1520
|
-
}
|
|
1521
|
-
if (strcmp(argv[1], "--forkcol") == 0)
|
|
1522
|
-
{
|
|
1523
|
-
/* Do not want to attach to shared memory */
|
|
1524
|
-
|
|
1525
|
-
PgstatCollectorMain(argc, argv); /* does not return */
|
|
1526
|
-
}
|
|
1527
1514
|
if (strcmp(argv[1], "--forklog") == 0)
|
|
1528
1515
|
{
|
|
1529
1516
|
/* Do not want to attach to shared memory */
|
|
@@ -1558,18 +1545,16 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1558
1545
|
|
|
1559
1546
|
/*
|
|
1560
1547
|
* SIGTERM while processing startup packet.
|
|
1561
|
-
* Clean up and exit(1).
|
|
1562
1548
|
*
|
|
1563
|
-
* Running proc_exit() from a signal handler
|
|
1564
|
-
*
|
|
1565
|
-
*
|
|
1566
|
-
* would cause a database crash cycle (forcing WAL replay at restart)
|
|
1567
|
-
* if any sessions are in authentication. So we live with it for now.
|
|
1549
|
+
* Running proc_exit() from a signal handler would be quite unsafe.
|
|
1550
|
+
* However, since we have not yet touched shared memory, we can just
|
|
1551
|
+
* pull the plug and exit without running any atexit handlers.
|
|
1568
1552
|
*
|
|
1569
|
-
* One might be tempted to try to send a message
|
|
1570
|
-
* disconnecting. However, that would
|
|
1571
|
-
* it seems undesirable to provide clues about the database's state
|
|
1572
|
-
* a client that has not yet completed authentication
|
|
1553
|
+
* One might be tempted to try to send a message, or log one, indicating
|
|
1554
|
+
* why we are disconnecting. However, that would be quite unsafe in itself.
|
|
1555
|
+
* Also, it seems undesirable to provide clues about the database's state
|
|
1556
|
+
* to a client that has not yet completed authentication, or even sent us
|
|
1557
|
+
* a startup packet.
|
|
1573
1558
|
*/
|
|
1574
1559
|
|
|
1575
1560
|
|
|
@@ -1586,11 +1571,7 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1586
1571
|
|
|
1587
1572
|
/*
|
|
1588
1573
|
* Timeout while processing startup packet.
|
|
1589
|
-
* As for process_startup_packet_die(), we
|
|
1590
|
-
*
|
|
1591
|
-
* This is theoretically just as hazardous as in process_startup_packet_die(),
|
|
1592
|
-
* although in practice we're almost certainly waiting for client input,
|
|
1593
|
-
* which greatly reduces the risk.
|
|
1574
|
+
* As for process_startup_packet_die(), we exit via _exit(1).
|
|
1594
1575
|
*/
|
|
1595
1576
|
|
|
1596
1577
|
|
|
@@ -1617,8 +1598,6 @@ SubPostmasterMain(int argc, char *argv[])
|
|
|
1617
1598
|
* to start subprocess.
|
|
1618
1599
|
*/
|
|
1619
1600
|
#ifdef EXEC_BACKEND
|
|
1620
|
-
#endif
|
|
1621
|
-
#ifdef EXEC_BACKEND
|
|
1622
1601
|
#else /* !EXEC_BACKEND */
|
|
1623
1602
|
#endif /* EXEC_BACKEND */
|
|
1624
1603
|
|
|
@@ -1769,7 +1748,6 @@ extern slock_t *ShmemLock;
|
|
|
1769
1748
|
extern slock_t *ProcStructLock;
|
|
1770
1749
|
extern PGPROC *AuxiliaryProcs;
|
|
1771
1750
|
extern PMSignalData *PMSignalState;
|
|
1772
|
-
extern pgsocket pgStatSock;
|
|
1773
1751
|
extern pg_time_t first_syslogger_file_time;
|
|
1774
1752
|
|
|
1775
1753
|
#ifndef WIN32
|
|
@@ -1825,8 +1803,6 @@ save_backend_variables(BackendParameters *param, Port *port,
|
|
|
1825
1803
|
param->AuxiliaryProcs = AuxiliaryProcs;
|
|
1826
1804
|
param->PreparedXactProcs = PreparedXactProcs;
|
|
1827
1805
|
param->PMSignalState = PMSignalState;
|
|
1828
|
-
if (!write_inheritable_socket(¶m->pgStatSock, pgStatSock, childPid))
|
|
1829
|
-
return false;
|
|
1830
1806
|
|
|
1831
1807
|
param->PostmasterPid = PostmasterPid;
|
|
1832
1808
|
param->PgStartTime = PgStartTime;
|
|
@@ -1835,6 +1811,7 @@ save_backend_variables(BackendParameters *param, Port *port,
|
|
|
1835
1811
|
|
|
1836
1812
|
param->redirection_done = redirection_done;
|
|
1837
1813
|
param->IsBinaryUpgrade = IsBinaryUpgrade;
|
|
1814
|
+
param->query_id_enabled = query_id_enabled;
|
|
1838
1815
|
param->max_safe_fds = max_safe_fds;
|
|
1839
1816
|
|
|
1840
1817
|
param->MaxBackends = MaxBackends;
|
|
@@ -1856,8 +1833,6 @@ save_backend_variables(BackendParameters *param, Port *port,
|
|
|
1856
1833
|
|
|
1857
1834
|
strlcpy(param->pkglib_path, pkglib_path, MAXPGPATH);
|
|
1858
1835
|
|
|
1859
|
-
strlcpy(param->ExtraOptions, ExtraOptions, MAXPGPATH);
|
|
1860
|
-
|
|
1861
1836
|
return true;
|
|
1862
1837
|
}
|
|
1863
1838
|
|
|
@@ -2061,7 +2036,6 @@ restore_backend_variables(BackendParameters *param, Port *port)
|
|
|
2061
2036
|
AuxiliaryProcs = param->AuxiliaryProcs;
|
|
2062
2037
|
PreparedXactProcs = param->PreparedXactProcs;
|
|
2063
2038
|
PMSignalState = param->PMSignalState;
|
|
2064
|
-
read_inheritable_socket(&pgStatSock, ¶m->pgStatSock);
|
|
2065
2039
|
|
|
2066
2040
|
PostmasterPid = param->PostmasterPid;
|
|
2067
2041
|
PgStartTime = param->PgStartTime;
|
|
@@ -2070,6 +2044,7 @@ restore_backend_variables(BackendParameters *param, Port *port)
|
|
|
2070
2044
|
|
|
2071
2045
|
redirection_done = param->redirection_done;
|
|
2072
2046
|
IsBinaryUpgrade = param->IsBinaryUpgrade;
|
|
2047
|
+
query_id_enabled = param->query_id_enabled;
|
|
2073
2048
|
max_safe_fds = param->max_safe_fds;
|
|
2074
2049
|
|
|
2075
2050
|
MaxBackends = param->MaxBackends;
|
|
@@ -2088,8 +2063,6 @@ restore_backend_variables(BackendParameters *param, Port *port)
|
|
|
2088
2063
|
|
|
2089
2064
|
strlcpy(pkglib_path, param->pkglib_path, MAXPGPATH);
|
|
2090
2065
|
|
|
2091
|
-
strlcpy(ExtraOptions, param->ExtraOptions, MAXPGPATH);
|
|
2092
|
-
|
|
2093
2066
|
/*
|
|
2094
2067
|
* We need to restore fd.c's counts of externally-opened FDs; to avoid
|
|
2095
2068
|
* confusion, be sure to do this after restoring max_safe_fds. (Note:
|
|
@@ -2101,8 +2074,6 @@ restore_backend_variables(BackendParameters *param, Port *port)
|
|
|
2101
2074
|
if (postmaster_alive_fds[1] >= 0)
|
|
2102
2075
|
ReserveExternalFD();
|
|
2103
2076
|
#endif
|
|
2104
|
-
if (pgStatSock != PGINVALID_SOCKET)
|
|
2105
|
-
ReserveExternalFD();
|
|
2106
2077
|
}
|
|
2107
2078
|
|
|
2108
2079
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* exit-time cleanup for either a postmaster or a backend.
|
|
16
16
|
*
|
|
17
17
|
*
|
|
18
|
-
* Portions Copyright (c) 1996-
|
|
18
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
19
19
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
20
20
|
*
|
|
21
21
|
*
|
|
@@ -173,9 +173,9 @@ void proc_exit(int code) { printf("Terminating process due to FATAL error\n"); e
|
|
|
173
173
|
* cancel_before_shmem_exit
|
|
174
174
|
*
|
|
175
175
|
* this function removes a previously-registered before_shmem_exit
|
|
176
|
-
* callback.
|
|
177
|
-
*
|
|
178
|
-
*
|
|
176
|
+
* callback. We only look at the latest entry for removal, as we
|
|
177
|
+
* expect callers to add and remove temporary before_shmem_exit
|
|
178
|
+
* callbacks in strict LIFO order.
|
|
179
179
|
* ----------------------------------------------------------------
|
|
180
180
|
*/
|
|
181
181
|
|
|
@@ -190,3 +190,12 @@ void proc_exit(int code) { printf("Terminating process due to FATAL error\n"); e
|
|
|
190
190
|
* ----------------------------------------------------------------
|
|
191
191
|
*/
|
|
192
192
|
|
|
193
|
+
|
|
194
|
+
/* ----------------------------------------------------------------
|
|
195
|
+
* check_on_shmem_exit_lists_are_empty
|
|
196
|
+
*
|
|
197
|
+
* Debugging check that no shmem cleanup handlers have been registered
|
|
198
|
+
* prematurely in the current process.
|
|
199
|
+
* ----------------------------------------------------------------
|
|
200
|
+
*/
|
|
201
|
+
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* the probability of unintended failure) than to fix the total time
|
|
47
47
|
* spent.
|
|
48
48
|
*
|
|
49
|
-
* Portions Copyright (c) 1996-
|
|
49
|
+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
|
50
50
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
51
51
|
*
|
|
52
52
|
*
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
#include <time.h>
|
|
61
61
|
#include <unistd.h>
|
|
62
62
|
|
|
63
|
+
#include "common/pg_prng.h"
|
|
63
64
|
#include "port/atomics.h"
|
|
64
65
|
#include "storage/s_lock.h"
|
|
65
66
|
|
|
@@ -155,7 +156,7 @@ perform_spin_delay(SpinDelayStatus *status)
|
|
|
155
156
|
|
|
156
157
|
/* increase delay by a random fraction between 1X and 2X */
|
|
157
158
|
status->cur_delay += (int) (status->cur_delay *
|
|
158
|
-
(
|
|
159
|
+
pg_prng_double(&pg_global_prng_state) + 0.5);
|
|
159
160
|
/* wrap back to minimum delay when max is exceeded */
|
|
160
161
|
if (status->cur_delay > MAX_DELAY_USEC)
|
|
161
162
|
status->cur_delay = MIN_DELAY_USEC;
|
|
@@ -296,7 +297,7 @@ volatile struct test_lock_struct test_lock;
|
|
|
296
297
|
int
|
|
297
298
|
main()
|
|
298
299
|
{
|
|
299
|
-
|
|
300
|
+
pg_prng_seed(&pg_global_prng_state, (uint64) time(NULL));
|
|
300
301
|
|
|
301
302
|
test_lock.pad1 = test_lock.pad2 = 0x44;
|
|
302
303
|
|
|
@@ -361,7 +362,7 @@ main()
|
|
|
361
362
|
printf(" if S_LOCK() and TAS() are working.\n");
|
|
362
363
|
fflush(stdout);
|
|
363
364
|
|
|
364
|
-
s_lock(&test_lock.lock, __FILE__, __LINE__);
|
|
365
|
+
s_lock(&test_lock.lock, __FILE__, __LINE__, PG_FUNCNAME_MACRO);
|
|
365
366
|
|
|
366
367
|
printf("S_LOCK_TEST: failed, lock not locked\n");
|
|
367
368
|
return 1;
|