pg_query 5.1.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/ext/pg_query/include/pg_query.h +4 -3
- data/ext/pg_query/include/pg_query_enum_defs.c +424 -154
- data/ext/pg_query/include/pg_query_fingerprint_conds.c +68 -4
- data/ext/pg_query/include/pg_query_fingerprint_defs.c +2952 -1845
- data/ext/pg_query/include/pg_query_outfuncs_conds.c +51 -3
- data/ext/pg_query/include/pg_query_outfuncs_defs.c +210 -23
- data/ext/pg_query/include/pg_query_readfuncs_conds.c +17 -1
- data/ext/pg_query/include/pg_query_readfuncs_defs.c +271 -52
- data/ext/pg_query/include/postgres/access/amapi.h +10 -3
- data/ext/pg_query/include/postgres/access/attmap.h +1 -1
- data/ext/pg_query/include/postgres/access/attnum.h +1 -1
- data/ext/pg_query/include/postgres/access/brin_internal.h +116 -0
- data/ext/pg_query/include/postgres/access/brin_tuple.h +112 -0
- data/ext/pg_query/include/postgres/access/clog.h +2 -3
- data/ext/pg_query/include/postgres/access/commit_ts.h +2 -3
- data/ext/pg_query/include/postgres/access/detoast.h +1 -1
- data/ext/pg_query/include/postgres/access/genam.h +8 -4
- data/ext/pg_query/include/postgres/access/gin.h +1 -1
- data/ext/pg_query/include/postgres/access/htup.h +1 -1
- data/ext/pg_query/include/postgres/access/htup_details.h +11 -11
- data/ext/pg_query/include/postgres/access/itup.h +3 -3
- data/ext/pg_query/include/postgres/access/parallel.h +1 -2
- data/ext/pg_query/include/postgres/access/printtup.h +1 -1
- data/ext/pg_query/include/postgres/access/relation.h +1 -1
- data/ext/pg_query/include/postgres/access/relscan.h +1 -1
- data/ext/pg_query/include/postgres/access/rmgrlist.h +1 -1
- data/ext/pg_query/include/postgres/access/sdir.h +1 -1
- data/ext/pg_query/include/postgres/access/skey.h +1 -1
- data/ext/pg_query/include/postgres/access/slru.h +221 -0
- data/ext/pg_query/include/postgres/access/stratnum.h +1 -1
- data/ext/pg_query/include/postgres/access/sysattr.h +1 -1
- data/ext/pg_query/include/postgres/access/table.h +1 -1
- data/ext/pg_query/include/postgres/access/tableam.h +33 -24
- data/ext/pg_query/include/postgres/access/tidstore.h +50 -0
- data/ext/pg_query/include/postgres/access/toast_compression.h +2 -2
- data/ext/pg_query/include/postgres/access/transam.h +7 -7
- data/ext/pg_query/include/postgres/access/tsmapi.h +1 -1
- data/ext/pg_query/include/postgres/access/tupconvert.h +1 -1
- data/ext/pg_query/include/postgres/access/tupdesc.h +5 -5
- data/ext/pg_query/include/postgres/access/tupmacs.h +1 -1
- data/ext/pg_query/include/postgres/access/twophase.h +2 -2
- data/ext/pg_query/include/postgres/access/xact.h +5 -5
- data/ext/pg_query/include/postgres/access/xlog.h +20 -12
- data/ext/pg_query/include/postgres/access/xlog_internal.h +4 -3
- data/ext/pg_query/include/postgres/access/xlogbackup.h +3 -1
- data/ext/pg_query/include/postgres/access/xlogdefs.h +5 -5
- data/ext/pg_query/include/postgres/access/xlogprefetcher.h +2 -2
- data/ext/pg_query/include/postgres/access/xlogreader.h +2 -2
- data/ext/pg_query/include/postgres/access/xlogrecord.h +3 -3
- data/ext/pg_query/include/postgres/access/xlogrecovery.h +4 -4
- data/ext/pg_query/include/postgres/archive/archive_module.h +9 -1
- data/ext/pg_query/include/postgres/c.h +31 -36
- data/ext/pg_query/include/postgres/catalog/catalog.h +3 -1
- data/ext/pg_query/include/postgres/catalog/catversion.h +2 -2
- data/ext/pg_query/include/postgres/catalog/dependency.h +17 -59
- data/ext/pg_query/include/postgres/catalog/genbki.h +12 -6
- data/ext/pg_query/include/postgres/catalog/index.h +22 -18
- data/ext/pg_query/include/postgres/catalog/indexing.h +1 -1
- data/ext/pg_query/include/postgres/catalog/namespace.h +18 -19
- data/ext/pg_query/include/postgres/catalog/objectaccess.h +2 -2
- data/ext/pg_query/include/postgres/catalog/objectaddress.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_aggregate.h +4 -2
- data/ext/pg_query/include/postgres/catalog/pg_aggregate_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_am.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_am_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_attribute.h +31 -14
- data/ext/pg_query/include/postgres/catalog/pg_attribute_d.h +3 -3
- data/ext/pg_query/include/postgres/catalog/pg_authid.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_authid_d.h +2 -1
- data/ext/pg_query/include/postgres/catalog/pg_class.h +10 -5
- data/ext/pg_query/include/postgres/catalog/pg_class_d.h +4 -2
- data/ext/pg_query/include/postgres/catalog/pg_collation.h +11 -5
- data/ext/pg_query/include/postgres/catalog/pg_collation_d.h +5 -2
- data/ext/pg_query/include/postgres/catalog/pg_constraint.h +15 -10
- data/ext/pg_query/include/postgres/catalog/pg_constraint_d.h +2 -1
- data/ext/pg_query/include/postgres/catalog/pg_control.h +5 -3
- data/ext/pg_query/include/postgres/catalog/pg_conversion.h +8 -4
- data/ext/pg_query/include/postgres/catalog/pg_conversion_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_database.h +9 -4
- data/ext/pg_query/include/postgres/catalog/pg_database_d.h +13 -12
- data/ext/pg_query/include/postgres/catalog/pg_depend.h +3 -3
- data/ext/pg_query/include/postgres/catalog/pg_depend_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_event_trigger.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_event_trigger_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_index.h +5 -3
- data/ext/pg_query/include/postgres/catalog/pg_index_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_language.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_language_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_namespace.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_namespace_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_opclass.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_opclass_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_operator.h +20 -3
- data/ext/pg_query/include/postgres/catalog/pg_operator_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_opfamily.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_opfamily_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_partitioned_table.h +4 -2
- data/ext/pg_query/include/postgres/catalog/pg_partitioned_table_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_proc.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_proc_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_publication.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_publication_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_replication_origin.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_replication_origin_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_statistic.h +10 -4
- data/ext/pg_query/include/postgres/catalog/pg_statistic_d.h +7 -3
- data/ext/pg_query/include/postgres/catalog/pg_statistic_ext.h +10 -7
- data/ext/pg_query/include/postgres/catalog/pg_statistic_ext_d.h +3 -3
- data/ext/pg_query/include/postgres/catalog/pg_transform.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_transform_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_trigger.h +4 -4
- data/ext/pg_query/include/postgres/catalog/pg_trigger_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_ts_config.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_ts_config_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_ts_dict.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_ts_dict_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_ts_parser.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_ts_parser_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_ts_template.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_ts_template_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_type.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_type_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/storage.h +1 -1
- data/ext/pg_query/include/postgres/catalog/syscache_ids.h +104 -0
- data/ext/pg_query/include/postgres/commands/async.h +2 -6
- data/ext/pg_query/include/postgres/commands/dbcommands.h +1 -1
- data/ext/pg_query/include/postgres/commands/defrem.h +6 -6
- data/ext/pg_query/include/postgres/commands/event_trigger.h +5 -2
- data/ext/pg_query/include/postgres/commands/explain.h +19 -3
- data/ext/pg_query/include/postgres/commands/prepare.h +1 -1
- data/ext/pg_query/include/postgres/commands/tablespace.h +1 -1
- data/ext/pg_query/include/postgres/commands/trigger.h +1 -1
- data/ext/pg_query/include/postgres/commands/vacuum.h +28 -26
- data/ext/pg_query/include/postgres/common/cryptohash.h +2 -2
- data/ext/pg_query/include/postgres/common/file_perm.h +1 -1
- data/ext/pg_query/include/postgres/common/file_utils.h +65 -0
- data/ext/pg_query/include/postgres/common/hashfn.h +16 -1
- data/ext/pg_query/include/postgres/common/hashfn_unstable.h +453 -0
- data/ext/pg_query/include/postgres/common/int.h +79 -4
- data/ext/pg_query/include/postgres/common/keywords.h +1 -1
- data/ext/pg_query/include/postgres/common/kwlookup.h +1 -1
- data/ext/pg_query/include/postgres/common/pg_prng.h +2 -1
- data/ext/pg_query/include/postgres/common/relpath.h +4 -4
- data/ext/pg_query/include/postgres/common/scram-common.h +1 -1
- data/ext/pg_query/include/postgres/common/sha2.h +1 -1
- data/ext/pg_query/include/postgres/common/string.h +1 -1
- data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +2 -3
- data/ext/pg_query/include/postgres/copyfuncs.funcs.c +278 -30
- data/ext/pg_query/include/postgres/copyfuncs.switch.c +55 -4
- data/ext/pg_query/include/postgres/datatype/timestamp.h +28 -2
- data/ext/pg_query/include/postgres/equalfuncs.funcs.c +239 -26
- data/ext/pg_query/include/postgres/equalfuncs.switch.c +55 -4
- data/ext/pg_query/include/postgres/executor/execdesc.h +1 -1
- data/ext/pg_query/include/postgres/executor/executor.h +6 -5
- data/ext/pg_query/include/postgres/executor/functions.h +2 -1
- data/ext/pg_query/include/postgres/executor/instrument.h +5 -3
- data/ext/pg_query/include/postgres/executor/spi.h +2 -8
- data/ext/pg_query/include/postgres/executor/tablefunc.h +1 -1
- data/ext/pg_query/include/postgres/executor/tuptable.h +31 -2
- data/ext/pg_query/include/postgres/fmgr.h +2 -2
- data/ext/pg_query/include/postgres/foreign/fdwapi.h +1 -1
- data/ext/pg_query/include/postgres/funcapi.h +2 -2
- data/ext/pg_query/include/postgres/gram.h +871 -830
- data/ext/pg_query/include/postgres/gramparse.h +1 -1
- data/ext/pg_query/include/postgres/jit/jit.h +4 -3
- data/ext/pg_query/include/postgres/kwlist_d.h +511 -466
- data/ext/pg_query/include/postgres/lib/dshash.h +25 -10
- data/ext/pg_query/include/postgres/lib/ilist.h +1 -1
- data/ext/pg_query/include/postgres/lib/pairingheap.h +1 -1
- data/ext/pg_query/include/postgres/lib/simplehash.h +40 -18
- data/ext/pg_query/include/postgres/lib/sort_template.h +14 -1
- data/ext/pg_query/include/postgres/lib/stringinfo.h +93 -11
- data/ext/pg_query/include/postgres/libpq/auth.h +1 -1
- data/ext/pg_query/include/postgres/libpq/crypt.h +2 -2
- data/ext/pg_query/include/postgres/libpq/hba.h +4 -4
- data/ext/pg_query/include/postgres/libpq/libpq-be.h +29 -25
- data/ext/pg_query/include/postgres/libpq/libpq.h +6 -7
- data/ext/pg_query/include/postgres/libpq/pqcomm.h +26 -20
- data/ext/pg_query/include/postgres/libpq/pqformat.h +2 -3
- data/ext/pg_query/include/postgres/libpq/pqsignal.h +1 -1
- data/ext/pg_query/include/postgres/libpq/protocol.h +89 -0
- data/ext/pg_query/include/postgres/libpq/sasl.h +1 -1
- data/ext/pg_query/include/postgres/libpq/scram.h +1 -1
- data/ext/pg_query/include/postgres/mb/pg_wchar.h +102 -82
- data/ext/pg_query/include/postgres/mb/stringinfo_mb.h +1 -1
- data/ext/pg_query/include/postgres/miscadmin.h +64 -52
- data/ext/pg_query/include/postgres/nodes/bitmapset.h +17 -3
- data/ext/pg_query/include/postgres/nodes/execnodes.h +109 -25
- data/ext/pg_query/include/postgres/nodes/extensible.h +1 -1
- data/ext/pg_query/include/postgres/nodes/lockoptions.h +4 -4
- data/ext/pg_query/include/postgres/nodes/makefuncs.h +8 -2
- data/ext/pg_query/include/postgres/nodes/memnodes.h +43 -4
- data/ext/pg_query/include/postgres/nodes/miscnodes.h +1 -1
- data/ext/pg_query/include/postgres/nodes/nodeFuncs.h +1 -1
- data/ext/pg_query/include/postgres/nodes/nodes.h +30 -41
- data/ext/pg_query/include/postgres/nodes/nodetags.h +464 -444
- data/ext/pg_query/include/postgres/nodes/params.h +1 -1
- data/ext/pg_query/include/postgres/nodes/parsenodes.h +358 -175
- data/ext/pg_query/include/postgres/nodes/pathnodes.h +60 -9
- data/ext/pg_query/include/postgres/nodes/pg_list.h +62 -11
- data/ext/pg_query/include/postgres/nodes/plannodes.h +11 -10
- data/ext/pg_query/include/postgres/nodes/primnodes.h +344 -50
- data/ext/pg_query/include/postgres/nodes/print.h +1 -1
- data/ext/pg_query/include/postgres/nodes/queryjumble.h +2 -2
- data/ext/pg_query/include/postgres/nodes/replnodes.h +23 -2
- data/ext/pg_query/include/postgres/nodes/supportnodes.h +1 -1
- data/ext/pg_query/include/postgres/nodes/tidbitmap.h +1 -1
- data/ext/pg_query/include/postgres/nodes/value.h +1 -1
- data/ext/pg_query/include/postgres/optimizer/cost.h +5 -4
- data/ext/pg_query/include/postgres/optimizer/geqo.h +1 -1
- data/ext/pg_query/include/postgres/optimizer/geqo_gene.h +1 -1
- data/ext/pg_query/include/postgres/optimizer/optimizer.h +5 -2
- data/ext/pg_query/include/postgres/optimizer/paths.h +13 -8
- data/ext/pg_query/include/postgres/optimizer/planmain.h +7 -1
- data/ext/pg_query/include/postgres/parser/analyze.h +3 -1
- data/ext/pg_query/include/postgres/parser/kwlist.h +22 -2
- data/ext/pg_query/include/postgres/parser/parse_agg.h +1 -1
- data/ext/pg_query/include/postgres/parser/parse_coerce.h +2 -2
- data/ext/pg_query/include/postgres/parser/parse_expr.h +1 -1
- data/ext/pg_query/include/postgres/parser/parse_func.h +2 -2
- data/ext/pg_query/include/postgres/parser/parse_node.h +3 -2
- data/ext/pg_query/include/postgres/parser/parse_oper.h +4 -1
- data/ext/pg_query/include/postgres/parser/parse_relation.h +1 -1
- data/ext/pg_query/include/postgres/parser/parse_type.h +2 -2
- data/ext/pg_query/include/postgres/parser/parser.h +3 -3
- data/ext/pg_query/include/postgres/parser/parsetree.h +1 -1
- data/ext/pg_query/include/postgres/parser/scanner.h +1 -1
- data/ext/pg_query/include/postgres/parser/scansup.h +1 -1
- data/ext/pg_query/include/postgres/partitioning/partdefs.h +1 -1
- data/ext/pg_query/include/postgres/pg_config.h +34 -34
- data/ext/pg_query/include/postgres/pg_config_manual.h +21 -8
- data/ext/pg_query/include/postgres/pg_getopt.h +1 -1
- data/ext/pg_query/include/postgres/pg_trace.h +1 -1
- data/ext/pg_query/include/postgres/pgstat.h +13 -11
- data/ext/pg_query/include/postgres/pgtime.h +1 -1
- data/ext/pg_query/include/postgres/pl_reserved_kwlist.h +1 -1
- data/ext/pg_query/include/postgres/pl_reserved_kwlist_d.h +1 -1
- data/ext/pg_query/include/postgres/pl_unreserved_kwlist.h +1 -1
- data/ext/pg_query/include/postgres/pl_unreserved_kwlist_d.h +1 -1
- data/ext/pg_query/include/postgres/plerrcodes.h +4 -4
- data/ext/pg_query/include/postgres/plpgsql.h +15 -13
- data/ext/pg_query/include/postgres/port/atomics/arch-arm.h +1 -1
- data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +1 -1
- data/ext/pg_query/include/postgres/port/atomics/arch-ppc.h +3 -1
- data/ext/pg_query/include/postgres/port/atomics/arch-x86.h +3 -1
- data/ext/pg_query/include/postgres/port/atomics/fallback.h +1 -1
- data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +38 -1
- data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +19 -1
- data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +16 -1
- data/ext/pg_query/include/postgres/port/atomics/generic.h +38 -2
- data/ext/pg_query/include/postgres/port/atomics.h +93 -6
- data/ext/pg_query/include/postgres/port/pg_bitutils.h +91 -9
- data/ext/pg_query/include/postgres/port/pg_bswap.h +1 -1
- data/ext/pg_query/include/postgres/port/pg_crc32c.h +10 -1
- data/ext/pg_query/include/postgres/port/pg_iovec.h +117 -0
- data/ext/pg_query/include/postgres/port/simd.h +48 -1
- data/ext/pg_query/include/postgres/port/win32/sys/socket.h +8 -0
- data/ext/pg_query/include/postgres/port/win32_port.h +1 -11
- data/ext/pg_query/include/postgres/port.h +7 -3
- data/ext/pg_query/include/postgres/portability/instr_time.h +1 -1
- data/ext/pg_query/include/postgres/postgres.h +1 -1
- data/ext/pg_query/include/postgres/postmaster/autovacuum.h +5 -16
- data/ext/pg_query/include/postgres/postmaster/bgworker.h +8 -6
- data/ext/pg_query/include/postgres/postmaster/bgworker_internals.h +3 -7
- data/ext/pg_query/include/postgres/postmaster/bgwriter.h +3 -3
- data/ext/pg_query/include/postgres/postmaster/interrupt.h +1 -1
- data/ext/pg_query/include/postgres/postmaster/pgarch.h +2 -2
- data/ext/pg_query/include/postgres/postmaster/postmaster.h +25 -5
- data/ext/pg_query/include/postgres/postmaster/startup.h +2 -2
- data/ext/pg_query/include/postgres/postmaster/syslogger.h +2 -4
- data/ext/pg_query/include/postgres/postmaster/walsummarizer.h +35 -0
- data/ext/pg_query/include/postgres/postmaster/walwriter.h +2 -2
- data/ext/pg_query/include/postgres/regex/regex.h +92 -9
- data/ext/pg_query/include/postgres/replication/logicallauncher.h +1 -1
- data/ext/pg_query/include/postgres/replication/logicalproto.h +2 -2
- data/ext/pg_query/include/postgres/replication/logicalworker.h +2 -1
- data/ext/pg_query/include/postgres/replication/origin.h +1 -1
- data/ext/pg_query/include/postgres/replication/reorderbuffer.h +18 -28
- data/ext/pg_query/include/postgres/replication/slot.h +41 -5
- data/ext/pg_query/include/postgres/replication/slotsync.h +38 -0
- data/ext/pg_query/include/postgres/replication/syncrep.h +1 -1
- data/ext/pg_query/include/postgres/replication/walreceiver.h +37 -11
- data/ext/pg_query/include/postgres/replication/walsender.h +5 -3
- data/ext/pg_query/include/postgres/rewrite/prs2lock.h +1 -1
- data/ext/pg_query/include/postgres/rewrite/rewriteHandler.h +7 -1
- data/ext/pg_query/include/postgres/rewrite/rewriteManip.h +2 -2
- data/ext/pg_query/include/postgres/rewrite/rewriteSupport.h +1 -1
- data/ext/pg_query/include/postgres/storage/block.h +1 -1
- data/ext/pg_query/include/postgres/storage/buf.h +1 -1
- data/ext/pg_query/include/postgres/storage/bufmgr.h +59 -41
- data/ext/pg_query/include/postgres/storage/bufpage.h +1 -1
- data/ext/pg_query/include/postgres/storage/condition_variable.h +1 -1
- data/ext/pg_query/include/postgres/storage/dsm.h +1 -1
- data/ext/pg_query/include/postgres/storage/dsm_impl.h +2 -2
- data/ext/pg_query/include/postgres/storage/fd.h +30 -13
- data/ext/pg_query/include/postgres/storage/fileset.h +1 -1
- data/ext/pg_query/include/postgres/storage/ipc.h +4 -1
- data/ext/pg_query/include/postgres/storage/item.h +1 -1
- data/ext/pg_query/include/postgres/storage/itemid.h +1 -1
- data/ext/pg_query/include/postgres/storage/itemptr.h +1 -1
- data/ext/pg_query/include/postgres/storage/large_object.h +1 -1
- data/ext/pg_query/include/postgres/storage/latch.h +4 -2
- data/ext/pg_query/include/postgres/storage/lmgr.h +8 -2
- data/ext/pg_query/include/postgres/storage/lock.h +19 -19
- data/ext/pg_query/include/postgres/storage/lockdefs.h +1 -1
- data/ext/pg_query/include/postgres/storage/lwlock.h +17 -9
- data/ext/pg_query/include/postgres/storage/lwlocknames.h +7 -10
- data/ext/pg_query/include/postgres/storage/off.h +1 -1
- data/ext/pg_query/include/postgres/storage/pg_sema.h +1 -1
- data/ext/pg_query/include/postgres/storage/pg_shmem.h +5 -4
- data/ext/pg_query/include/postgres/storage/pmsignal.h +2 -2
- data/ext/pg_query/include/postgres/storage/predicate.h +1 -5
- data/ext/pg_query/include/postgres/storage/proc.h +48 -23
- data/ext/pg_query/include/postgres/storage/procarray.h +5 -1
- data/ext/pg_query/include/postgres/storage/proclist_types.h +11 -9
- data/ext/pg_query/include/postgres/storage/procnumber.h +43 -0
- data/ext/pg_query/include/postgres/storage/procsignal.h +8 -6
- data/ext/pg_query/include/postgres/storage/read_stream.h +65 -0
- data/ext/pg_query/include/postgres/storage/relfilelocator.h +16 -15
- data/ext/pg_query/include/postgres/storage/s_lock.h +7 -27
- data/ext/pg_query/include/postgres/storage/sharedfileset.h +1 -1
- data/ext/pg_query/include/postgres/storage/shm_mq.h +2 -2
- data/ext/pg_query/include/postgres/storage/shm_toc.h +1 -1
- data/ext/pg_query/include/postgres/storage/shmem.h +1 -1
- data/ext/pg_query/include/postgres/storage/sinval.h +3 -3
- data/ext/pg_query/include/postgres/storage/smgr.h +41 -27
- data/ext/pg_query/include/postgres/storage/spin.h +1 -1
- data/ext/pg_query/include/postgres/storage/standby.h +13 -3
- data/ext/pg_query/include/postgres/storage/standbydefs.h +2 -2
- data/ext/pg_query/include/postgres/storage/sync.h +4 -4
- data/ext/pg_query/include/postgres/tcop/cmdtag.h +1 -2
- data/ext/pg_query/include/postgres/tcop/cmdtaglist.h +3 -2
- data/ext/pg_query/include/postgres/tcop/deparse_utility.h +2 -2
- data/ext/pg_query/include/postgres/tcop/dest.h +3 -2
- data/ext/pg_query/include/postgres/tcop/fastpath.h +1 -1
- data/ext/pg_query/include/postgres/tcop/pquery.h +1 -1
- data/ext/pg_query/include/postgres/tcop/tcopprot.h +9 -5
- data/ext/pg_query/include/postgres/tcop/utility.h +2 -2
- data/ext/pg_query/include/postgres/tsearch/ts_cache.h +1 -1
- data/ext/pg_query/include/postgres/utils/acl.h +19 -7
- data/ext/pg_query/include/postgres/utils/aclchk_internal.h +1 -1
- data/ext/pg_query/include/postgres/utils/array.h +1 -2
- data/ext/pg_query/include/postgres/utils/ascii.h +84 -0
- data/ext/pg_query/include/postgres/utils/backend_progress.h +3 -2
- data/ext/pg_query/include/postgres/utils/backend_status.h +8 -10
- data/ext/pg_query/include/postgres/utils/builtins.h +4 -1
- data/ext/pg_query/include/postgres/utils/bytea.h +2 -2
- data/ext/pg_query/include/postgres/utils/catcache.h +5 -6
- data/ext/pg_query/include/postgres/utils/date.h +1 -1
- data/ext/pg_query/include/postgres/utils/datetime.h +4 -1
- data/ext/pg_query/include/postgres/utils/datum.h +1 -1
- data/ext/pg_query/include/postgres/utils/dsa.h +44 -5
- data/ext/pg_query/include/postgres/utils/elog.h +3 -8
- data/ext/pg_query/include/postgres/utils/errcodes.h +1 -3
- data/ext/pg_query/include/postgres/utils/expandeddatum.h +1 -1
- data/ext/pg_query/include/postgres/utils/expandedrecord.h +1 -1
- data/ext/pg_query/include/postgres/utils/float.h +1 -1
- data/ext/pg_query/include/postgres/utils/fmgroids.h +49 -16
- data/ext/pg_query/include/postgres/utils/fmgrprotos.h +47 -14
- data/ext/pg_query/include/postgres/utils/fmgrtab.h +1 -1
- data/ext/pg_query/include/postgres/utils/guc.h +20 -6
- data/ext/pg_query/include/postgres/utils/guc_hooks.h +23 -2
- data/ext/pg_query/include/postgres/utils/guc_tables.h +6 -5
- data/ext/pg_query/include/postgres/utils/hsearch.h +2 -2
- data/ext/pg_query/include/postgres/utils/injection_point.h +44 -0
- data/ext/pg_query/include/postgres/utils/inval.h +1 -1
- data/ext/pg_query/include/postgres/utils/logtape.h +5 -5
- data/ext/pg_query/include/postgres/utils/lsyscache.h +6 -3
- data/ext/pg_query/include/postgres/utils/memdebug.h +1 -1
- data/ext/pg_query/include/postgres/utils/memutils.h +12 -5
- data/ext/pg_query/include/postgres/utils/memutils_internal.h +53 -13
- data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +25 -9
- data/ext/pg_query/include/postgres/utils/numeric.h +6 -1
- data/ext/pg_query/include/postgres/utils/palloc.h +1 -15
- data/ext/pg_query/include/postgres/utils/partcache.h +1 -1
- data/ext/pg_query/include/postgres/utils/pg_locale.h +8 -7
- data/ext/pg_query/include/postgres/utils/pgstat_internal.h +11 -17
- data/ext/pg_query/include/postgres/utils/plancache.h +5 -3
- data/ext/pg_query/include/postgres/utils/portal.h +9 -9
- data/ext/pg_query/include/postgres/utils/queryenvironment.h +2 -2
- data/ext/pg_query/include/postgres/utils/regproc.h +1 -1
- data/ext/pg_query/include/postgres/utils/rel.h +14 -15
- data/ext/pg_query/include/postgres/utils/relcache.h +2 -5
- data/ext/pg_query/include/postgres/utils/reltrigger.h +1 -1
- data/ext/pg_query/include/postgres/utils/resowner.h +90 -9
- data/ext/pg_query/include/postgres/utils/ruleutils.h +1 -1
- data/ext/pg_query/include/postgres/utils/sharedtuplestore.h +1 -1
- data/ext/pg_query/include/postgres/utils/snapmgr.h +1 -52
- data/ext/pg_query/include/postgres/utils/snapshot.h +2 -2
- data/ext/pg_query/include/postgres/utils/sortsupport.h +1 -1
- data/ext/pg_query/include/postgres/utils/syscache.h +2 -98
- data/ext/pg_query/include/postgres/utils/timeout.h +3 -2
- data/ext/pg_query/include/postgres/utils/timestamp.h +1 -1
- data/ext/pg_query/include/postgres/utils/tuplesort.h +36 -9
- data/ext/pg_query/include/postgres/utils/tuplestore.h +2 -5
- data/ext/pg_query/include/postgres/utils/typcache.h +2 -1
- data/ext/pg_query/include/postgres/utils/varlena.h +1 -1
- data/ext/pg_query/include/postgres/utils/wait_event.h +28 -214
- data/ext/pg_query/include/postgres/utils/wait_event_types.h +218 -0
- data/ext/pg_query/include/postgres/utils/xml.h +4 -4
- data/ext/pg_query/include/postgres/varatt.h +1 -1
- data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1546 -792
- data/ext/pg_query/include/protobuf/pg_query.pb.h +58365 -46595
- data/ext/pg_query/pg_query.pb-c.c +6598 -3739
- data/ext/pg_query/pg_query_normalize.c +42 -1
- data/ext/pg_query/pg_query_outfuncs_json.c +3 -1
- data/ext/pg_query/pg_query_parse_plpgsql.c +12 -13
- data/ext/pg_query/pg_query_readfuncs_protobuf.c +2 -2
- data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -1
- data/ext/pg_query/pg_query_scan.c +1 -1
- data/ext/pg_query/postgres_deparse.c +409 -21
- data/ext/pg_query/src_backend_catalog_namespace.c +241 -66
- data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -3
- data/ext/pg_query/src_backend_commands_define.c +2 -3
- data/ext/pg_query/src_backend_nodes_bitmapset.c +137 -94
- data/ext/pg_query/src_backend_nodes_copyfuncs.c +1 -1
- data/ext/pg_query/src_backend_nodes_equalfuncs.c +1 -1
- data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
- data/ext/pg_query/src_backend_nodes_list.c +3 -7
- data/ext/pg_query/src_backend_nodes_makefuncs.c +59 -20
- data/ext/pg_query/src_backend_nodes_nodeFuncs.c +109 -2
- data/ext/pg_query/src_backend_nodes_value.c +1 -1
- data/ext/pg_query/src_backend_parser_gram.c +34490 -32135
- data/ext/pg_query/src_backend_parser_parser.c +8 -8
- data/ext/pg_query/src_backend_parser_scan.c +5637 -3028
- data/ext/pg_query/src_backend_parser_scansup.c +2 -1
- data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
- data/ext/pg_query/src_backend_tcop_postgres.c +34 -10
- data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +2 -2
- data/ext/pg_query/src_backend_utils_adt_datum.c +8 -6
- data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
- data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
- data/ext/pg_query/src_backend_utils_adt_numutils.c +4 -5
- data/ext/pg_query/src_backend_utils_adt_ruleutils.c +101 -28
- data/ext/pg_query/src_backend_utils_error_assert.c +1 -1
- data/ext/pg_query/src_backend_utils_error_elog.c +47 -42
- data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +4 -2
- data/ext/pg_query/src_backend_utils_init_globals.c +15 -3
- data/ext/pg_query/src_backend_utils_mb_mbutils.c +11 -18
- data/ext/pg_query/src_backend_utils_misc_guc_tables.c +16 -6
- data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +8 -5
- data/ext/pg_query/src_backend_utils_mmgr_aset.c +308 -238
- data/ext/pg_query/src_backend_utils_mmgr_bump.c +728 -0
- data/ext/pg_query/src_backend_utils_mmgr_generation.c +273 -197
- data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +270 -215
- data/ext/pg_query/src_backend_utils_mmgr_slab.c +154 -96
- data/ext/pg_query/src_common_encnames.c +43 -44
- data/ext/pg_query/src_common_hashfn.c +1 -1
- data/ext/pg_query/src_common_keywords.c +1 -1
- data/ext/pg_query/src_common_kwlist_d.h +511 -466
- data/ext/pg_query/src_common_kwlookup.c +1 -1
- data/ext/pg_query/src_common_psprintf.c +3 -3
- data/ext/pg_query/src_common_stringinfo.c +18 -1
- data/ext/pg_query/src_common_wchar.c +45 -108
- data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +99 -5
- data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -1
- data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +242 -143
- 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 +1 -1
- data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +19 -1
- data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +1 -1
- data/ext/pg_query/src_port_pg_bitutils.c +173 -28
- data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
- data/ext/pg_query/src_port_snprintf.c +1 -1
- data/ext/pg_query/src_port_strerror.c +1 -3
- data/ext/pg_query/src_port_strlcpy.c +1 -1
- data/lib/pg_query/param_refs.rb +1 -1
- data/lib/pg_query/pg_query_pb.rb +26 -3
- data/lib/pg_query/treewalker.rb +38 -11
- data/lib/pg_query/truncate.rb +1 -1
- data/lib/pg_query/version.rb +1 -1
- metadata +25 -11
- data/ext/pg_query/include/postgres/storage/backendid.h +0 -37
- data/ext/pg_query/include/postgres/storage/sinvaladt.h +0 -45
- data/ext/pg_query/src_backend_nodes_nodes.c +0 -38
@@ -3,7 +3,7 @@
|
|
3
3
|
* dshash.h
|
4
4
|
* Concurrent hash tables backed by dynamic shared memory areas.
|
5
5
|
*
|
6
|
-
* Portions Copyright (c) 1996-
|
6
|
+
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
7
7
|
* Portions Copyright (c) 1994, Regents of the University of California
|
8
8
|
*
|
9
9
|
* IDENTIFICATION
|
@@ -37,17 +37,19 @@ typedef int (*dshash_compare_function) (const void *a, const void *b,
|
|
37
37
|
typedef dshash_hash (*dshash_hash_function) (const void *v, size_t size,
|
38
38
|
void *arg);
|
39
39
|
|
40
|
+
/* A function type for copying keys. */
|
41
|
+
typedef void (*dshash_copy_function) (void *dest, const void *src, size_t size,
|
42
|
+
void *arg);
|
43
|
+
|
40
44
|
/*
|
41
45
|
* The set of parameters needed to create or attach to a hash table. The
|
42
|
-
*
|
43
|
-
*
|
46
|
+
* tranche_id member does not need to be initialized when attaching to an
|
47
|
+
* existing hash table.
|
44
48
|
*
|
45
|
-
* Compare and
|
46
|
-
* can't safely share function pointers between backends in general.
|
47
|
-
*
|
48
|
-
*
|
49
|
-
* user data pointer supplied to the create and attach functions will be
|
50
|
-
* passed to the hash and compare functions.
|
49
|
+
* Compare, hash, and copy functions must be supplied even when attaching,
|
50
|
+
* because we can't safely share function pointers between backends in general.
|
51
|
+
* The user data pointer supplied to the create and attach functions will be
|
52
|
+
* passed to these functions.
|
51
53
|
*/
|
52
54
|
typedef struct dshash_parameters
|
53
55
|
{
|
@@ -55,6 +57,7 @@ typedef struct dshash_parameters
|
|
55
57
|
size_t entry_size; /* Total size of entry */
|
56
58
|
dshash_compare_function compare_function; /* Compare function */
|
57
59
|
dshash_hash_function hash_function; /* Hash function */
|
60
|
+
dshash_copy_function copy_function; /* Copy function */
|
58
61
|
int tranche_id; /* The tranche ID to use for locks */
|
59
62
|
} dshash_parameters;
|
60
63
|
|
@@ -105,9 +108,21 @@ extern void *dshash_seq_next(dshash_seq_status *status);
|
|
105
108
|
extern void dshash_seq_term(dshash_seq_status *status);
|
106
109
|
extern void dshash_delete_current(dshash_seq_status *status);
|
107
110
|
|
108
|
-
/*
|
111
|
+
/*
|
112
|
+
* Convenience hash, compare, and copy functions wrapping memcmp, tag_hash, and
|
113
|
+
* memcpy.
|
114
|
+
*/
|
109
115
|
extern int dshash_memcmp(const void *a, const void *b, size_t size, void *arg);
|
110
116
|
extern dshash_hash dshash_memhash(const void *v, size_t size, void *arg);
|
117
|
+
extern void dshash_memcpy(void *dest, const void *src, size_t size, void *arg);
|
118
|
+
|
119
|
+
/*
|
120
|
+
* Convenience hash, compare, and copy functions wrapping strcmp, string_hash,
|
121
|
+
* and strcpy.
|
122
|
+
*/
|
123
|
+
extern int dshash_strcmp(const void *a, const void *b, size_t size, void *arg);
|
124
|
+
extern dshash_hash dshash_strhash(const void *v, size_t size, void *arg);
|
125
|
+
extern void dshash_strcpy(void *dest, const void *src, size_t size, void *arg);
|
111
126
|
|
112
127
|
/* Debugging support. */
|
113
128
|
extern void dshash_dump(dshash_table *hash_table);
|
@@ -112,7 +112,7 @@
|
|
112
112
|
* }
|
113
113
|
*
|
114
114
|
*
|
115
|
-
* Portions Copyright (c) 1996-
|
115
|
+
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
116
116
|
* Portions Copyright (c) 1994, Regents of the University of California
|
117
117
|
*
|
118
118
|
* IDENTIFICATION
|
@@ -87,7 +87,7 @@
|
|
87
87
|
* looking or is done - buckets following a deleted element are shifted
|
88
88
|
* backwards, unless they're empty or already at their optimal position.
|
89
89
|
*
|
90
|
-
* Portions Copyright (c) 1996-
|
90
|
+
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
91
91
|
* Portions Copyright (c) 1994, Regents of the University of California
|
92
92
|
*
|
93
93
|
* src/include/lib/simplehash.h
|
@@ -128,7 +128,8 @@
|
|
128
128
|
#define SH_STAT SH_MAKE_NAME(stat)
|
129
129
|
|
130
130
|
/* internal helper functions (no externally visible prototypes) */
|
131
|
-
#define
|
131
|
+
#define SH_COMPUTE_SIZE SH_MAKE_NAME(compute_size)
|
132
|
+
#define SH_UPDATE_PARAMETERS SH_MAKE_NAME(update_parameters)
|
132
133
|
#define SH_NEXT SH_MAKE_NAME(next)
|
133
134
|
#define SH_PREV SH_MAKE_NAME(prev)
|
134
135
|
#define SH_DISTANCE_FROM_OPTIMAL SH_MAKE_NAME(distance)
|
@@ -303,11 +304,11 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
|
|
303
304
|
#endif
|
304
305
|
|
305
306
|
/*
|
306
|
-
* Compute
|
307
|
-
*
|
307
|
+
* Compute allocation size for hashtable. Result can be passed to
|
308
|
+
* SH_UPDATE_PARAMETERS.
|
308
309
|
*/
|
309
|
-
static inline
|
310
|
-
|
310
|
+
static inline uint64
|
311
|
+
SH_COMPUTE_SIZE(uint64 newsize)
|
311
312
|
{
|
312
313
|
uint64 size;
|
313
314
|
|
@@ -325,6 +326,18 @@ SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint64 newsize)
|
|
325
326
|
if (unlikely((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2))
|
326
327
|
sh_error("hash table too large");
|
327
328
|
|
329
|
+
return size;
|
330
|
+
}
|
331
|
+
|
332
|
+
/*
|
333
|
+
* Update sizing parameters for hashtable. Called when creating and growing
|
334
|
+
* the hashtable.
|
335
|
+
*/
|
336
|
+
static inline void
|
337
|
+
SH_UPDATE_PARAMETERS(SH_TYPE * tb, uint64 newsize)
|
338
|
+
{
|
339
|
+
uint64 size = SH_COMPUTE_SIZE(newsize);
|
340
|
+
|
328
341
|
/* now set size */
|
329
342
|
tb->size = size;
|
330
343
|
tb->sizemask = (uint32) (size - 1);
|
@@ -446,10 +459,11 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
|
|
446
459
|
/* increase nelements by fillfactor, want to store nelements elements */
|
447
460
|
size = Min((double) SH_MAX_SIZE, ((double) nelements) / SH_FILLFACTOR);
|
448
461
|
|
449
|
-
|
462
|
+
size = SH_COMPUTE_SIZE(size);
|
450
463
|
|
451
|
-
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) *
|
464
|
+
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * size);
|
452
465
|
|
466
|
+
SH_UPDATE_PARAMETERS(tb, size);
|
453
467
|
return tb;
|
454
468
|
}
|
455
469
|
|
@@ -490,10 +504,15 @@ SH_GROW(SH_TYPE * tb, uint64 newsize)
|
|
490
504
|
Assert(oldsize != SH_MAX_SIZE);
|
491
505
|
Assert(oldsize < newsize);
|
492
506
|
|
493
|
-
|
494
|
-
SH_COMPUTE_PARAMETERS(tb, newsize);
|
507
|
+
newsize = SH_COMPUTE_SIZE(newsize);
|
495
508
|
|
496
|
-
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) *
|
509
|
+
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * newsize);
|
510
|
+
|
511
|
+
/*
|
512
|
+
* Update parameters for new table after allocation succeeds to avoid
|
513
|
+
* inconsistent state on OOM.
|
514
|
+
*/
|
515
|
+
SH_UPDATE_PARAMETERS(tb, newsize);
|
497
516
|
|
498
517
|
newdata = tb->data;
|
499
518
|
|
@@ -751,9 +770,8 @@ restart:
|
|
751
770
|
}
|
752
771
|
|
753
772
|
/*
|
754
|
-
* Insert the key
|
755
|
-
*
|
756
|
-
* case.
|
773
|
+
* Insert the key into the hash-table, set *found to true if the key already
|
774
|
+
* exists, false otherwise. Returns the hash-table entry in either case.
|
757
775
|
*/
|
758
776
|
SH_SCOPE SH_ELEMENT_TYPE *
|
759
777
|
SH_INSERT(SH_TYPE * tb, SH_KEY_TYPE key, bool *found)
|
@@ -764,9 +782,9 @@ SH_INSERT(SH_TYPE * tb, SH_KEY_TYPE key, bool *found)
|
|
764
782
|
}
|
765
783
|
|
766
784
|
/*
|
767
|
-
* Insert the key
|
768
|
-
*
|
769
|
-
*
|
785
|
+
* Insert the key into the hash-table using an already-calculated hash. Set
|
786
|
+
* *found to true if the key already exists, false otherwise. Returns the
|
787
|
+
* hash-table entry in either case.
|
770
788
|
*/
|
771
789
|
SH_SCOPE SH_ELEMENT_TYPE *
|
772
790
|
SH_INSERT_HASH(SH_TYPE * tb, SH_KEY_TYPE key, uint32 hash, bool *found)
|
@@ -1101,6 +1119,9 @@ SH_STAT(SH_TYPE * tb)
|
|
1101
1119
|
max_collisions = curcoll;
|
1102
1120
|
}
|
1103
1121
|
|
1122
|
+
/* large enough to be worth freeing, even if just used for debugging */
|
1123
|
+
pfree(collisions);
|
1124
|
+
|
1104
1125
|
if (tb->members > 0)
|
1105
1126
|
{
|
1106
1127
|
fillfactor = tb->members / ((double) tb->size);
|
@@ -1173,7 +1194,8 @@ SH_STAT(SH_TYPE * tb)
|
|
1173
1194
|
#undef SH_STAT
|
1174
1195
|
|
1175
1196
|
/* internal function names */
|
1176
|
-
#undef
|
1197
|
+
#undef SH_COMPUTE_SIZE
|
1198
|
+
#undef SH_UPDATE_PARAMETERS
|
1177
1199
|
#undef SH_COMPARE_KEYS
|
1178
1200
|
#undef SH_INITIAL_BUCKET
|
1179
1201
|
#undef SH_NEXT
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* A template for a sort algorithm that supports varying degrees of
|
6
6
|
* specialization.
|
7
7
|
*
|
8
|
-
* Copyright (c) 2021-
|
8
|
+
* Copyright (c) 2021-2024, PostgreSQL Global Development Group
|
9
9
|
* Portions Copyright (c) 1992-1994, Regents of the University of California
|
10
10
|
*
|
11
11
|
* Usage notes:
|
@@ -34,6 +34,16 @@
|
|
34
34
|
* - ST_COMPARE(a, b, arg) - variant that takes an extra argument
|
35
35
|
* - ST_COMPARE_RUNTIME_POINTER - sort function takes a function pointer
|
36
36
|
*
|
37
|
+
* NB: If the comparator function is inlined, some compilers may produce
|
38
|
+
* worse code with the optimized comparison routines in common/int.h than
|
39
|
+
* with code with the following form:
|
40
|
+
*
|
41
|
+
* if (a < b)
|
42
|
+
* return -1;
|
43
|
+
* if (a > b)
|
44
|
+
* return 1;
|
45
|
+
* return 0;
|
46
|
+
*
|
37
47
|
* To say that the comparator and therefore also sort function should
|
38
48
|
* receive an extra pass-through argument, specify the type of the
|
39
49
|
* argument.
|
@@ -243,6 +253,9 @@ ST_SCOPE void ST_SORT(ST_ELEMENT_TYPE * first, size_t n
|
|
243
253
|
* Find the median of three values. Currently, performance seems to be best
|
244
254
|
* if the comparator is inlined here, but the med3 function is not inlined
|
245
255
|
* in the qsort function.
|
256
|
+
*
|
257
|
+
* Refer to the comment at the top of this file for known caveats to consider
|
258
|
+
* when writing inlined comparator functions.
|
246
259
|
*/
|
247
260
|
static pg_noinline ST_ELEMENT_TYPE *
|
248
261
|
ST_MED3(ST_ELEMENT_TYPE * a,
|
@@ -8,7 +8,7 @@
|
|
8
8
|
* (null-terminated text) or arbitrary binary data. All storage is allocated
|
9
9
|
* with palloc() (falling back to malloc in frontend code).
|
10
10
|
*
|
11
|
-
* Portions Copyright (c) 1996-
|
11
|
+
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
12
12
|
* Portions Copyright (c) 1994, Regents of the University of California
|
13
13
|
*
|
14
14
|
* src/include/lib/stringinfo.h
|
@@ -20,17 +20,27 @@
|
|
20
20
|
|
21
21
|
/*-------------------------
|
22
22
|
* StringInfoData holds information about an extensible string.
|
23
|
-
* data is the current buffer for the string
|
24
|
-
* len is the current string length.
|
25
|
-
*
|
26
|
-
*
|
23
|
+
* data is the current buffer for the string.
|
24
|
+
* len is the current string length. Except in the case of read-only
|
25
|
+
* strings described below, there is guaranteed to be a
|
26
|
+
* terminating '\0' at data[len].
|
27
27
|
* maxlen is the allocated size in bytes of 'data', i.e. the maximum
|
28
28
|
* string size (including the terminating '\0' char) that we can
|
29
29
|
* currently store in 'data' without having to reallocate
|
30
|
-
* more space. We must always have maxlen > len
|
31
|
-
*
|
32
|
-
*
|
33
|
-
*
|
30
|
+
* more space. We must always have maxlen > len, except
|
31
|
+
* in the read-only case described below.
|
32
|
+
* cursor is initialized to zero by makeStringInfo, initStringInfo,
|
33
|
+
* initReadOnlyStringInfo and initStringInfoFromString but is not
|
34
|
+
* otherwise touched by the stringinfo.c routines. Some routines
|
35
|
+
* use it to scan through a StringInfo.
|
36
|
+
*
|
37
|
+
* As a special case, a StringInfoData can be initialized with a read-only
|
38
|
+
* string buffer. In this case "data" does not necessarily point at a
|
39
|
+
* palloc'd chunk, and management of the buffer storage is the caller's
|
40
|
+
* responsibility. maxlen is set to zero to indicate that this is the case.
|
41
|
+
* Read-only StringInfoDatas cannot be appended to or reset.
|
42
|
+
* Also, it is caller's option whether a read-only string buffer has a
|
43
|
+
* terminating '\0' or not. This depends on the intended usage.
|
34
44
|
*-------------------------
|
35
45
|
*/
|
36
46
|
typedef struct StringInfoData
|
@@ -45,7 +55,7 @@ typedef StringInfoData *StringInfo;
|
|
45
55
|
|
46
56
|
|
47
57
|
/*------------------------
|
48
|
-
* There are
|
58
|
+
* There are four ways to create a StringInfo object initially:
|
49
59
|
*
|
50
60
|
* StringInfo stringptr = makeStringInfo();
|
51
61
|
* Both the StringInfoData and the data buffer are palloc'd.
|
@@ -56,8 +66,32 @@ typedef StringInfoData *StringInfo;
|
|
56
66
|
* This is the easiest approach for a StringInfo object that will
|
57
67
|
* only live as long as the current routine.
|
58
68
|
*
|
69
|
+
* StringInfoData string;
|
70
|
+
* initReadOnlyStringInfo(&string, existingbuf, len);
|
71
|
+
* The StringInfoData's data field is set to point directly to the
|
72
|
+
* existing buffer and the StringInfoData's len is set to the given len.
|
73
|
+
* The given buffer can point to memory that's not managed by palloc or
|
74
|
+
* is pointing partway through a palloc'd chunk. The maxlen field is set
|
75
|
+
* to 0. A read-only StringInfo cannot be appended to using any of the
|
76
|
+
* appendStringInfo functions or reset with resetStringInfo(). The given
|
77
|
+
* buffer can optionally omit the trailing NUL.
|
78
|
+
*
|
79
|
+
* StringInfoData string;
|
80
|
+
* initStringInfoFromString(&string, palloced_buf, len);
|
81
|
+
* The StringInfoData's data field is set to point directly to the given
|
82
|
+
* buffer and the StringInfoData's len is set to the given len. This
|
83
|
+
* method of initialization is useful when the buffer already exists.
|
84
|
+
* StringInfos initialized this way can be appended to using the
|
85
|
+
* appendStringInfo functions and reset with resetStringInfo(). The
|
86
|
+
* given buffer must be NUL-terminated. The palloc'd buffer is assumed
|
87
|
+
* to be len + 1 in size.
|
88
|
+
*
|
59
89
|
* To destroy a StringInfo, pfree() the data buffer, and then pfree() the
|
60
|
-
* StringInfoData if it was palloc'd.
|
90
|
+
* StringInfoData if it was palloc'd. For StringInfos created with
|
91
|
+
* makeStringInfo(), destroyStringInfo() is provided for this purpose.
|
92
|
+
* However, if the StringInfo was initialized using initReadOnlyStringInfo()
|
93
|
+
* then the caller will need to consider if it is safe to pfree the data
|
94
|
+
* buffer.
|
61
95
|
*
|
62
96
|
* NOTE: some routines build up a string using StringInfo, and then
|
63
97
|
* release the StringInfoData but return the data string itself to their
|
@@ -79,6 +113,48 @@ extern StringInfo makeStringInfo(void);
|
|
79
113
|
*/
|
80
114
|
extern void initStringInfo(StringInfo str);
|
81
115
|
|
116
|
+
/*------------------------
|
117
|
+
* initReadOnlyStringInfo
|
118
|
+
* Initialize a StringInfoData struct from an existing string without copying
|
119
|
+
* the string. The caller is responsible for ensuring the given string
|
120
|
+
* remains valid as long as the StringInfoData does. Calls to this are used
|
121
|
+
* in performance critical locations where allocating a new buffer and copying
|
122
|
+
* would be too costly. Read-only StringInfoData's may not be appended to
|
123
|
+
* using any of the appendStringInfo functions or reset with
|
124
|
+
* resetStringInfo().
|
125
|
+
*
|
126
|
+
* 'data' does not need to point directly to a palloc'd chunk of memory and may
|
127
|
+
* omit the NUL termination character at data[len].
|
128
|
+
*/
|
129
|
+
static inline void
|
130
|
+
initReadOnlyStringInfo(StringInfo str, char *data, int len)
|
131
|
+
{
|
132
|
+
str->data = data;
|
133
|
+
str->len = len;
|
134
|
+
str->maxlen = 0; /* read-only */
|
135
|
+
str->cursor = 0;
|
136
|
+
}
|
137
|
+
|
138
|
+
/*------------------------
|
139
|
+
* initStringInfoFromString
|
140
|
+
* Initialize a StringInfoData struct from an existing string without copying
|
141
|
+
* the string. 'data' must be a valid palloc'd chunk of memory that can have
|
142
|
+
* repalloc() called should more space be required during a call to any of the
|
143
|
+
* appendStringInfo functions.
|
144
|
+
*
|
145
|
+
* 'data' must be NUL terminated at 'len' bytes.
|
146
|
+
*/
|
147
|
+
static inline void
|
148
|
+
initStringInfoFromString(StringInfo str, char *data, int len)
|
149
|
+
{
|
150
|
+
Assert(data[len] == '\0');
|
151
|
+
|
152
|
+
str->data = data;
|
153
|
+
str->len = len;
|
154
|
+
str->maxlen = len + 1;
|
155
|
+
str->cursor = 0;
|
156
|
+
}
|
157
|
+
|
82
158
|
/*------------------------
|
83
159
|
* resetStringInfo
|
84
160
|
* Clears the current content of the StringInfo, if any. The
|
@@ -158,4 +234,10 @@ extern void appendBinaryStringInfoNT(StringInfo str,
|
|
158
234
|
*/
|
159
235
|
extern void enlargeStringInfo(StringInfo str, int needed);
|
160
236
|
|
237
|
+
/*------------------------
|
238
|
+
* destroyStringInfo
|
239
|
+
* Frees a StringInfo and its buffer (opposite of makeStringInfo()).
|
240
|
+
*/
|
241
|
+
extern void destroyStringInfo(StringInfo str);
|
242
|
+
|
161
243
|
#endif /* STRINGINFO_H */
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* Definitions for network authentication routines
|
5
5
|
*
|
6
6
|
*
|
7
|
-
* Portions Copyright (c) 1996-
|
7
|
+
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
8
8
|
* Portions Copyright (c) 1994, Regents of the University of California
|
9
9
|
*
|
10
10
|
* src/include/libpq/auth.h
|
@@ -3,7 +3,7 @@
|
|
3
3
|
* crypt.h
|
4
4
|
* Interface to libpq/crypt.c
|
5
5
|
*
|
6
|
-
* Portions Copyright (c) 1996-
|
6
|
+
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
7
7
|
* Portions Copyright (c) 1994, Regents of the University of California
|
8
8
|
*
|
9
9
|
* src/include/libpq/crypt.h
|
@@ -28,7 +28,7 @@ typedef enum PasswordType
|
|
28
28
|
{
|
29
29
|
PASSWORD_TYPE_PLAINTEXT = 0,
|
30
30
|
PASSWORD_TYPE_MD5,
|
31
|
-
PASSWORD_TYPE_SCRAM_SHA_256
|
31
|
+
PASSWORD_TYPE_SCRAM_SHA_256,
|
32
32
|
} PasswordType;
|
33
33
|
|
34
34
|
extern PasswordType get_password_type(const char *shadow_pass);
|
@@ -38,7 +38,7 @@ typedef enum UserAuth
|
|
38
38
|
uaLDAP,
|
39
39
|
uaCert,
|
40
40
|
uaRADIUS,
|
41
|
-
uaPeer
|
41
|
+
uaPeer,
|
42
42
|
#define USER_AUTH_LAST uaPeer /* Must be last value of this enum */
|
43
43
|
} UserAuth;
|
44
44
|
|
@@ -51,7 +51,7 @@ typedef enum IPCompareMethod
|
|
51
51
|
ipCmpMask,
|
52
52
|
ipCmpSameHost,
|
53
53
|
ipCmpSameNet,
|
54
|
-
ipCmpAll
|
54
|
+
ipCmpAll,
|
55
55
|
} IPCompareMethod;
|
56
56
|
|
57
57
|
typedef enum ConnType
|
@@ -68,13 +68,13 @@ typedef enum ClientCertMode
|
|
68
68
|
{
|
69
69
|
clientCertOff,
|
70
70
|
clientCertCA,
|
71
|
-
clientCertFull
|
71
|
+
clientCertFull,
|
72
72
|
} ClientCertMode;
|
73
73
|
|
74
74
|
typedef enum ClientCertName
|
75
75
|
{
|
76
76
|
clientCertCN,
|
77
|
-
clientCertDN
|
77
|
+
clientCertDN,
|
78
78
|
} ClientCertName;
|
79
79
|
|
80
80
|
/*
|
@@ -8,7 +8,7 @@
|
|
8
8
|
* Structs that need to be client-visible are in pqcomm.h.
|
9
9
|
*
|
10
10
|
*
|
11
|
-
* Portions Copyright (c) 1996-
|
11
|
+
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
12
12
|
* Portions Copyright (c) 1994, Regents of the University of California
|
13
13
|
*
|
14
14
|
* src/include/libpq/libpq-be.h
|
@@ -58,17 +58,6 @@ typedef struct
|
|
58
58
|
#include "libpq/pqcomm.h"
|
59
59
|
|
60
60
|
|
61
|
-
typedef enum CAC_state
|
62
|
-
{
|
63
|
-
CAC_OK,
|
64
|
-
CAC_STARTUP,
|
65
|
-
CAC_SHUTDOWN,
|
66
|
-
CAC_RECOVERY,
|
67
|
-
CAC_NOTCONSISTENT,
|
68
|
-
CAC_TOOMANY
|
69
|
-
} CAC_state;
|
70
|
-
|
71
|
-
|
72
61
|
/*
|
73
62
|
* GSSAPI specific state information
|
74
63
|
*/
|
@@ -121,12 +110,9 @@ typedef struct ClientConnectionInfo
|
|
121
110
|
} ClientConnectionInfo;
|
122
111
|
|
123
112
|
/*
|
124
|
-
*
|
125
|
-
*
|
126
|
-
*
|
127
|
-
* still available when a backend is running (see MyProcPort). The data
|
128
|
-
* it points to must also be malloc'd, or else palloc'd in TopMemoryContext,
|
129
|
-
* so that it survives into PostgresMain execution!
|
113
|
+
* The Port structure holds state information about a client connection in a
|
114
|
+
* backend process. It is available in the global variable MyProcPort. The
|
115
|
+
* struct and all the data it points are kept in TopMemoryContext.
|
130
116
|
*
|
131
117
|
* remote_hostname is set if we did a successful reverse lookup of the
|
132
118
|
* client's IP address during connection setup.
|
@@ -156,7 +142,6 @@ typedef struct Port
|
|
156
142
|
int remote_hostname_resolv; /* see above */
|
157
143
|
int remote_hostname_errcode; /* see above */
|
158
144
|
char *remote_port; /* text rep of remote port */
|
159
|
-
CAC_state canAcceptConnections; /* postmaster connection status */
|
160
145
|
|
161
146
|
/*
|
162
147
|
* Information that needs to be saved from the startup packet and passed
|
@@ -218,6 +203,7 @@ typedef struct Port
|
|
218
203
|
char *peer_cn;
|
219
204
|
char *peer_dn;
|
220
205
|
bool peer_cert_valid;
|
206
|
+
bool alpn_used;
|
221
207
|
|
222
208
|
/*
|
223
209
|
* OpenSSL structures. (Keep these last so that the locations of other
|
@@ -227,8 +213,32 @@ typedef struct Port
|
|
227
213
|
SSL *ssl;
|
228
214
|
X509 *peer;
|
229
215
|
#endif
|
216
|
+
|
217
|
+
/*
|
218
|
+
* This is a bit of a hack. raw_buf is data that was previously read and
|
219
|
+
* buffered in a higher layer but then "unread" and needs to be read again
|
220
|
+
* while establishing an SSL connection via the SSL library layer.
|
221
|
+
*
|
222
|
+
* There's no API to "unread", the upper layer just places the data in the
|
223
|
+
* Port structure in raw_buf and sets raw_buf_remaining to the amount of
|
224
|
+
* bytes unread and raw_buf_consumed to 0.
|
225
|
+
*/
|
226
|
+
char *raw_buf;
|
227
|
+
ssize_t raw_buf_consumed,
|
228
|
+
raw_buf_remaining;
|
230
229
|
} Port;
|
231
230
|
|
231
|
+
/*
|
232
|
+
* ClientSocket holds a socket for an accepted connection, along with the
|
233
|
+
* information about the remote endpoint. This is passed from postmaster to
|
234
|
+
* the backend process.
|
235
|
+
*/
|
236
|
+
typedef struct ClientSocket
|
237
|
+
{
|
238
|
+
pgsocket sock; /* File descriptor */
|
239
|
+
SockAddr raddr; /* remote addr (client) */
|
240
|
+
} ClientSocket;
|
241
|
+
|
232
242
|
#ifdef USE_SSL
|
233
243
|
/*
|
234
244
|
* Hardcoded DH parameters, used in ephemeral DH keying. (See also
|
@@ -305,14 +315,8 @@ extern void be_tls_get_peer_serial(Port *port, char *ptr, size_t len);
|
|
305
315
|
*
|
306
316
|
* The result is a palloc'd hash of the server certificate with its
|
307
317
|
* size, and NULL if there is no certificate available.
|
308
|
-
*
|
309
|
-
* This is not supported with old versions of OpenSSL that don't have
|
310
|
-
* the X509_get_signature_nid() function.
|
311
318
|
*/
|
312
|
-
#if defined(USE_OPENSSL) && (defined(HAVE_X509_GET_SIGNATURE_NID) || defined(HAVE_X509_GET_SIGNATURE_INFO))
|
313
|
-
#define HAVE_BE_TLS_GET_CERTIFICATE_HASH
|
314
319
|
extern char *be_tls_get_certificate_hash(Port *port, size_t *len);
|
315
|
-
#endif
|
316
320
|
|
317
321
|
/* init hook for SSL, the default sets the password callback if appropriate */
|
318
322
|
#ifdef USE_OPENSSL
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* POSTGRES LIBPQ buffer structure definitions.
|
5
5
|
*
|
6
6
|
*
|
7
|
-
* Portions Copyright (c) 1996-
|
7
|
+
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
8
8
|
* Portions Copyright (c) 1994, Regents of the University of California
|
9
9
|
*
|
10
10
|
* src/include/libpq/libpq.h
|
@@ -64,14 +64,13 @@ extern PGDLLIMPORT WaitEventSet *FeBeWaitSet;
|
|
64
64
|
#define FeBeWaitSetLatchPos 1
|
65
65
|
#define FeBeWaitSetNEvents 3
|
66
66
|
|
67
|
-
extern int
|
67
|
+
extern int ListenServerPort(int family, const char *hostName,
|
68
68
|
unsigned short portNumber, const char *unixSocketDir,
|
69
|
-
pgsocket
|
70
|
-
extern int
|
71
|
-
extern void StreamClose(pgsocket sock);
|
69
|
+
pgsocket ListenSockets[], int *NumListenSockets, int MaxListen);
|
70
|
+
extern int AcceptConnection(pgsocket server_fd, ClientSocket *client_sock);
|
72
71
|
extern void TouchSocketFiles(void);
|
73
72
|
extern void RemoveSocketFiles(void);
|
74
|
-
extern
|
73
|
+
extern Port *pq_init(ClientSocket *client_sock);
|
75
74
|
extern int pq_getbytes(char *s, size_t len);
|
76
75
|
extern void pq_startmsgread(void);
|
77
76
|
extern void pq_endmsgread(void);
|
@@ -80,7 +79,7 @@ extern int pq_getmessage(StringInfo s, int maxlen);
|
|
80
79
|
extern int pq_getbyte(void);
|
81
80
|
extern int pq_peekbyte(void);
|
82
81
|
extern int pq_getbyte_if_available(unsigned char *c);
|
83
|
-
extern
|
82
|
+
extern ssize_t pq_buffer_remaining_data(void);
|
84
83
|
extern int pq_putmessage_v2(char msgtype, const char *s, size_t len);
|
85
84
|
extern bool pq_check_connection(void);
|
86
85
|
|