pg_query 2.2.0 → 6.1.0
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 +86 -0
- data/README.md +57 -31
- data/Rakefile +5 -6
- data/ext/pg_query/ext_symbols_freebsd.sym +1 -0
- data/ext/pg_query/ext_symbols_freebsd_with_ruby_abi_version.sym +2 -0
- data/ext/pg_query/ext_symbols_openbsd.sym +1 -0
- data/ext/pg_query/ext_symbols_openbsd_with_ruby_abi_version.sym +2 -0
- data/ext/pg_query/ext_symbols_with_ruby_abi_version.sym +2 -0
- data/ext/pg_query/extconf.rb +33 -9
- data/ext/pg_query/include/pg_query.h +30 -4
- data/ext/pg_query/include/pg_query_enum_defs.c +839 -290
- data/ext/pg_query/include/pg_query_fingerprint_conds.c +638 -481
- data/ext/pg_query/include/pg_query_fingerprint_defs.c +6786 -4193
- data/ext/pg_query/include/pg_query_outfuncs_conds.c +450 -330
- data/ext/pg_query/include/pg_query_outfuncs_defs.c +1489 -1044
- data/ext/pg_query/include/pg_query_readfuncs_conds.c +157 -118
- data/ext/pg_query/include/pg_query_readfuncs_defs.c +1933 -1410
- data/ext/pg_query/include/postgres/access/amapi.h +303 -0
- data/ext/pg_query/include/postgres/access/attmap.h +54 -0
- data/ext/pg_query/include/postgres/access/attnum.h +64 -0
- 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 +62 -0
- data/ext/pg_query/include/postgres/access/commit_ts.h +73 -0
- data/ext/pg_query/include/postgres/access/detoast.h +82 -0
- data/ext/pg_query/include/postgres/access/genam.h +246 -0
- data/ext/pg_query/include/postgres/access/gin.h +91 -0
- data/ext/pg_query/include/postgres/access/htup.h +89 -0
- data/ext/pg_query/include/postgres/access/htup_details.h +811 -0
- data/ext/pg_query/include/postgres/access/itup.h +170 -0
- data/ext/pg_query/include/postgres/access/parallel.h +81 -0
- data/ext/pg_query/include/postgres/access/printtup.h +35 -0
- data/ext/pg_query/include/postgres/access/relation.h +28 -0
- data/ext/pg_query/include/postgres/access/relscan.h +191 -0
- data/ext/pg_query/include/postgres/access/rmgr.h +62 -0
- data/ext/pg_query/include/postgres/access/rmgrlist.h +49 -0
- data/ext/pg_query/include/postgres/access/sdir.h +67 -0
- data/ext/pg_query/include/postgres/access/skey.h +151 -0
- data/ext/pg_query/include/postgres/access/slru.h +218 -0
- data/ext/pg_query/include/postgres/access/stratnum.h +85 -0
- data/ext/pg_query/include/postgres/access/sysattr.h +29 -0
- data/ext/pg_query/include/postgres/access/table.h +28 -0
- data/ext/pg_query/include/postgres/access/tableam.h +2110 -0
- data/ext/pg_query/include/postgres/access/tidstore.h +50 -0
- data/ext/pg_query/include/postgres/access/toast_compression.h +73 -0
- data/ext/pg_query/include/postgres/access/transam.h +418 -0
- data/ext/pg_query/include/postgres/access/tsmapi.h +82 -0
- data/ext/pg_query/include/postgres/access/tupconvert.h +54 -0
- data/ext/pg_query/include/postgres/access/tupdesc.h +154 -0
- data/ext/pg_query/include/postgres/access/tupmacs.h +207 -0
- data/ext/pg_query/include/postgres/access/twophase.h +65 -0
- data/ext/pg_query/include/postgres/access/xact.h +530 -0
- data/ext/pg_query/include/postgres/access/xlog.h +310 -0
- data/ext/pg_query/include/postgres/access/xlog_internal.h +405 -0
- data/ext/pg_query/include/postgres/access/xlogbackup.h +43 -0
- data/ext/pg_query/include/postgres/access/xlogdefs.h +82 -0
- data/ext/pg_query/include/postgres/access/xlogprefetcher.h +55 -0
- data/ext/pg_query/include/postgres/access/xlogreader.h +444 -0
- data/ext/pg_query/include/postgres/access/xlogrecord.h +248 -0
- data/ext/pg_query/include/postgres/access/xlogrecovery.h +158 -0
- data/ext/pg_query/include/postgres/archive/archive_module.h +67 -0
- data/ext/pg_query/include/postgres/c.h +1374 -0
- data/ext/pg_query/include/postgres/catalog/catalog.h +47 -0
- data/ext/pg_query/include/postgres/catalog/catversion.h +62 -0
- data/ext/pg_query/include/postgres/catalog/dependency.h +228 -0
- data/ext/pg_query/include/postgres/catalog/genbki.h +149 -0
- data/ext/pg_query/include/postgres/catalog/index.h +218 -0
- data/ext/pg_query/include/postgres/catalog/indexing.h +54 -0
- data/ext/pg_query/include/postgres/catalog/namespace.h +189 -0
- data/ext/pg_query/include/postgres/catalog/objectaccess.h +267 -0
- data/ext/pg_query/include/postgres/catalog/objectaddress.h +93 -0
- data/ext/pg_query/include/postgres/catalog/pg_aggregate.h +182 -0
- data/ext/pg_query/include/postgres/catalog/pg_aggregate_d.h +78 -0
- data/ext/pg_query/include/postgres/catalog/pg_am.h +66 -0
- data/ext/pg_query/include/postgres/catalog/pg_am_d.h +47 -0
- data/ext/pg_query/include/postgres/catalog/pg_attribute.h +240 -0
- data/ext/pg_query/include/postgres/catalog/pg_attribute_d.h +62 -0
- data/ext/pg_query/include/postgres/catalog/pg_authid.h +66 -0
- data/ext/pg_query/include/postgres/catalog/pg_authid_d.h +60 -0
- data/ext/pg_query/include/postgres/catalog/pg_class.h +235 -0
- data/ext/pg_query/include/postgres/catalog/pg_class_d.h +134 -0
- data/ext/pg_query/include/postgres/catalog/pg_collation.h +106 -0
- data/ext/pg_query/include/postgres/catalog/pg_collation_d.h +66 -0
- data/ext/pg_query/include/postgres/catalog/pg_constraint.h +278 -0
- data/ext/pg_query/include/postgres/catalog/pg_constraint_d.h +74 -0
- data/ext/pg_query/include/postgres/catalog/pg_control.h +260 -0
- data/ext/pg_query/include/postgres/catalog/pg_conversion.h +79 -0
- data/ext/pg_query/include/postgres/catalog/pg_conversion_d.h +38 -0
- data/ext/pg_query/include/postgres/catalog/pg_database.h +129 -0
- data/ext/pg_query/include/postgres/catalog/pg_database_d.h +53 -0
- data/ext/pg_query/include/postgres/catalog/pg_depend.h +77 -0
- data/ext/pg_query/include/postgres/catalog/pg_depend_d.h +36 -0
- data/ext/pg_query/include/postgres/catalog/pg_event_trigger.h +60 -0
- data/ext/pg_query/include/postgres/catalog/pg_event_trigger_d.h +36 -0
- data/ext/pg_query/include/postgres/catalog/pg_index.h +92 -0
- data/ext/pg_query/include/postgres/catalog/pg_index_d.h +59 -0
- data/ext/pg_query/include/postgres/catalog/pg_language.h +75 -0
- data/ext/pg_query/include/postgres/catalog/pg_language_d.h +41 -0
- data/ext/pg_query/include/postgres/catalog/pg_namespace.h +67 -0
- data/ext/pg_query/include/postgres/catalog/pg_namespace_d.h +36 -0
- data/ext/pg_query/include/postgres/catalog/pg_opclass.h +91 -0
- data/ext/pg_query/include/postgres/catalog/pg_opclass_d.h +51 -0
- data/ext/pg_query/include/postgres/catalog/pg_operator.h +124 -0
- data/ext/pg_query/include/postgres/catalog/pg_operator_d.h +142 -0
- data/ext/pg_query/include/postgres/catalog/pg_opfamily.h +67 -0
- data/ext/pg_query/include/postgres/catalog/pg_opfamily_d.h +51 -0
- data/ext/pg_query/include/postgres/catalog/pg_partitioned_table.h +76 -0
- data/ext/pg_query/include/postgres/catalog/pg_partitioned_table_d.h +36 -0
- data/ext/pg_query/include/postgres/catalog/pg_proc.h +223 -0
- data/ext/pg_query/include/postgres/catalog/pg_proc_d.h +101 -0
- data/ext/pg_query/include/postgres/catalog/pg_publication.h +161 -0
- data/ext/pg_query/include/postgres/catalog/pg_publication_d.h +38 -0
- data/ext/pg_query/include/postgres/catalog/pg_replication_origin.h +65 -0
- data/ext/pg_query/include/postgres/catalog/pg_replication_origin_d.h +33 -0
- data/ext/pg_query/include/postgres/catalog/pg_statistic.h +288 -0
- data/ext/pg_query/include/postgres/catalog/pg_statistic_d.h +199 -0
- data/ext/pg_query/include/postgres/catalog/pg_statistic_ext.h +91 -0
- data/ext/pg_query/include/postgres/catalog/pg_statistic_ext_d.h +45 -0
- data/ext/pg_query/include/postgres/catalog/pg_transform.h +51 -0
- data/ext/pg_query/include/postgres/catalog/pg_transform_d.h +34 -0
- data/ext/pg_query/include/postgres/catalog/pg_trigger.h +153 -0
- data/ext/pg_query/include/postgres/catalog/pg_trigger_d.h +109 -0
- data/ext/pg_query/include/postgres/catalog/pg_ts_config.h +56 -0
- data/ext/pg_query/include/postgres/catalog/pg_ts_config_d.h +34 -0
- data/ext/pg_query/include/postgres/catalog/pg_ts_dict.h +62 -0
- data/ext/pg_query/include/postgres/catalog/pg_ts_dict_d.h +35 -0
- data/ext/pg_query/include/postgres/catalog/pg_ts_parser.h +63 -0
- data/ext/pg_query/include/postgres/catalog/pg_ts_parser_d.h +37 -0
- data/ext/pg_query/include/postgres/catalog/pg_ts_template.h +54 -0
- data/ext/pg_query/include/postgres/catalog/pg_ts_template_d.h +34 -0
- data/ext/pg_query/include/postgres/catalog/pg_type.h +407 -0
- data/ext/pg_query/include/postgres/catalog/pg_type_d.h +324 -0
- data/ext/pg_query/include/postgres/catalog/storage.h +50 -0
- data/ext/pg_query/include/postgres/catalog/syscache_ids.h +104 -0
- data/ext/pg_query/include/postgres/commands/async.h +49 -0
- data/ext/pg_query/include/postgres/commands/dbcommands.h +37 -0
- data/ext/pg_query/include/postgres/commands/defrem.h +161 -0
- data/ext/pg_query/include/postgres/commands/event_trigger.h +97 -0
- data/ext/pg_query/include/postgres/commands/explain.h +145 -0
- data/ext/pg_query/include/postgres/commands/prepare.h +61 -0
- data/ext/pg_query/include/postgres/commands/tablespace.h +69 -0
- data/ext/pg_query/include/postgres/commands/trigger.h +288 -0
- data/ext/pg_query/include/postgres/commands/user.h +43 -0
- data/ext/pg_query/include/postgres/commands/vacuum.h +388 -0
- data/ext/pg_query/include/postgres/common/cryptohash.h +39 -0
- data/ext/pg_query/include/postgres/common/file_perm.h +56 -0
- data/ext/pg_query/include/postgres/common/file_utils.h +65 -0
- data/ext/pg_query/include/postgres/common/hashfn.h +119 -0
- data/ext/pg_query/include/postgres/common/hashfn_unstable.h +407 -0
- data/ext/pg_query/include/postgres/common/int.h +512 -0
- data/ext/pg_query/include/postgres/common/keywords.h +29 -0
- data/ext/pg_query/include/postgres/common/kwlookup.h +44 -0
- data/ext/pg_query/include/postgres/common/pg_prng.h +62 -0
- data/ext/pg_query/include/postgres/common/relpath.h +97 -0
- data/ext/pg_query/include/postgres/common/scram-common.h +70 -0
- data/ext/pg_query/include/postgres/common/sha2.h +32 -0
- data/ext/pg_query/include/postgres/common/string.h +44 -0
- data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +124 -0
- data/ext/pg_query/include/postgres/common/unicode_nonspacing_table.h +326 -0
- data/ext/pg_query/include/postgres/copyfuncs.funcs.c +5261 -0
- data/ext/pg_query/include/postgres/copyfuncs.switch.c +989 -0
- data/ext/pg_query/include/postgres/datatype/timestamp.h +269 -0
- data/ext/pg_query/include/postgres/equalfuncs.funcs.c +3310 -0
- data/ext/pg_query/include/postgres/equalfuncs.switch.c +836 -0
- data/ext/pg_query/include/postgres/executor/execdesc.h +70 -0
- data/ext/pg_query/include/postgres/executor/executor.h +681 -0
- data/ext/pg_query/include/postgres/executor/functions.h +56 -0
- data/ext/pg_query/include/postgres/executor/instrument.h +120 -0
- data/ext/pg_query/include/postgres/executor/spi.h +207 -0
- data/ext/pg_query/include/postgres/executor/tablefunc.h +67 -0
- data/ext/pg_query/include/postgres/executor/tuptable.h +523 -0
- data/ext/pg_query/include/postgres/fmgr.h +800 -0
- data/ext/pg_query/include/postgres/foreign/fdwapi.h +294 -0
- data/ext/pg_query/include/postgres/funcapi.h +360 -0
- data/ext/pg_query/include/postgres/gram.h +1168 -0
- data/ext/pg_query/include/postgres/gramparse.h +75 -0
- data/ext/pg_query/include/postgres/jit/jit.h +106 -0
- data/ext/pg_query/include/postgres/kwlist_d.h +1164 -0
- data/ext/pg_query/include/postgres/lib/dshash.h +130 -0
- data/ext/pg_query/include/postgres/lib/ilist.h +1159 -0
- data/ext/pg_query/include/postgres/lib/pairingheap.h +102 -0
- data/ext/pg_query/include/postgres/lib/simplehash.h +1206 -0
- data/ext/pg_query/include/postgres/lib/sort_template.h +445 -0
- data/ext/pg_query/include/postgres/lib/stringinfo.h +243 -0
- data/ext/pg_query/include/postgres/libpq/auth.h +37 -0
- data/ext/pg_query/include/postgres/libpq/crypt.h +47 -0
- data/ext/pg_query/include/postgres/libpq/hba.h +186 -0
- data/ext/pg_query/include/postgres/libpq/libpq-be.h +361 -0
- data/ext/pg_query/include/postgres/libpq/libpq.h +143 -0
- data/ext/pg_query/include/postgres/libpq/pqcomm.h +169 -0
- data/ext/pg_query/include/postgres/libpq/pqformat.h +209 -0
- data/ext/pg_query/include/postgres/libpq/pqsignal.h +54 -0
- data/ext/pg_query/include/postgres/libpq/protocol.h +89 -0
- data/ext/pg_query/include/postgres/libpq/sasl.h +136 -0
- data/ext/pg_query/include/postgres/libpq/scram.h +37 -0
- data/ext/pg_query/include/postgres/mb/pg_wchar.h +793 -0
- data/ext/pg_query/include/postgres/mb/stringinfo_mb.h +24 -0
- data/ext/pg_query/include/postgres/miscadmin.h +527 -0
- data/ext/pg_query/include/postgres/nodes/bitmapset.h +140 -0
- data/ext/pg_query/include/postgres/nodes/execnodes.h +2855 -0
- data/ext/pg_query/include/postgres/nodes/extensible.h +164 -0
- data/ext/pg_query/include/postgres/nodes/lockoptions.h +61 -0
- data/ext/pg_query/include/postgres/nodes/makefuncs.h +127 -0
- data/ext/pg_query/include/postgres/nodes/memnodes.h +152 -0
- data/ext/pg_query/include/postgres/nodes/miscnodes.h +56 -0
- data/ext/pg_query/include/postgres/nodes/nodeFuncs.h +222 -0
- data/ext/pg_query/include/postgres/nodes/nodes.h +435 -0
- data/ext/pg_query/include/postgres/nodes/nodetags.h +491 -0
- data/ext/pg_query/include/postgres/nodes/params.h +170 -0
- data/ext/pg_query/include/postgres/nodes/parsenodes.h +4233 -0
- data/ext/pg_query/include/postgres/nodes/pathnodes.h +3438 -0
- data/ext/pg_query/include/postgres/nodes/pg_list.h +686 -0
- data/ext/pg_query/include/postgres/nodes/plannodes.h +1593 -0
- data/ext/pg_query/include/postgres/nodes/primnodes.h +2339 -0
- data/ext/pg_query/include/postgres/nodes/print.h +34 -0
- data/ext/pg_query/include/postgres/nodes/queryjumble.h +86 -0
- data/ext/pg_query/include/postgres/nodes/replnodes.h +132 -0
- data/ext/pg_query/include/postgres/nodes/supportnodes.h +346 -0
- data/ext/pg_query/include/postgres/nodes/tidbitmap.h +75 -0
- data/ext/pg_query/include/postgres/nodes/value.h +90 -0
- data/ext/pg_query/include/postgres/optimizer/cost.h +216 -0
- data/ext/pg_query/include/postgres/optimizer/geqo.h +90 -0
- data/ext/pg_query/include/postgres/optimizer/geqo_gene.h +45 -0
- data/ext/pg_query/include/postgres/optimizer/optimizer.h +205 -0
- data/ext/pg_query/include/postgres/optimizer/paths.h +271 -0
- data/ext/pg_query/include/postgres/optimizer/planmain.h +123 -0
- data/ext/pg_query/include/postgres/parser/analyze.h +66 -0
- data/ext/pg_query/include/postgres/parser/kwlist.h +518 -0
- data/ext/pg_query/include/postgres/parser/parse_agg.h +65 -0
- data/ext/pg_query/include/postgres/parser/parse_coerce.h +105 -0
- data/ext/pg_query/include/postgres/parser/parse_expr.h +25 -0
- data/ext/pg_query/include/postgres/parser/parse_func.h +74 -0
- data/ext/pg_query/include/postgres/parser/parse_node.h +358 -0
- data/ext/pg_query/include/postgres/parser/parse_oper.h +68 -0
- data/ext/pg_query/include/postgres/parser/parse_relation.h +129 -0
- data/ext/pg_query/include/postgres/parser/parse_type.h +61 -0
- data/ext/pg_query/include/postgres/parser/parser.h +68 -0
- data/ext/pg_query/include/postgres/parser/parsetree.h +61 -0
- data/ext/pg_query/include/postgres/parser/scanner.h +152 -0
- data/ext/pg_query/include/postgres/parser/scansup.h +27 -0
- data/ext/pg_query/include/postgres/partitioning/partdefs.h +26 -0
- data/ext/pg_query/include/postgres/pg_config.h +985 -0
- data/ext/pg_query/include/postgres/pg_config_manual.h +385 -0
- data/ext/pg_query/include/postgres/pg_config_os.h +8 -0
- data/ext/pg_query/include/postgres/pg_getopt.h +56 -0
- data/ext/pg_query/include/postgres/pg_trace.h +17 -0
- data/ext/pg_query/include/postgres/pgstat.h +780 -0
- data/ext/pg_query/include/postgres/pgtime.h +94 -0
- data/ext/pg_query/include/postgres/pl_gram.h +385 -0
- data/ext/pg_query/include/postgres/pl_reserved_kwlist.h +52 -0
- data/ext/pg_query/include/postgres/pl_reserved_kwlist_d.h +114 -0
- data/ext/pg_query/include/postgres/pl_unreserved_kwlist.h +112 -0
- data/ext/pg_query/include/postgres/pl_unreserved_kwlist_d.h +246 -0
- data/ext/pg_query/include/postgres/plerrcodes.h +998 -0
- data/ext/pg_query/include/postgres/plpgsql.h +1342 -0
- data/ext/pg_query/include/postgres/port/atomics/arch-arm.h +32 -0
- data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +17 -0
- data/ext/pg_query/include/postgres/port/atomics/arch-ppc.h +256 -0
- data/ext/pg_query/include/postgres/port/atomics/arch-x86.h +254 -0
- data/ext/pg_query/include/postgres/port/atomics/fallback.h +170 -0
- data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +323 -0
- data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +119 -0
- data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +121 -0
- data/ext/pg_query/include/postgres/port/atomics/generic.h +437 -0
- data/ext/pg_query/include/postgres/port/atomics.h +606 -0
- data/ext/pg_query/include/postgres/port/pg_bitutils.h +421 -0
- data/ext/pg_query/include/postgres/port/pg_bswap.h +161 -0
- data/ext/pg_query/include/postgres/port/pg_crc32c.h +110 -0
- data/ext/pg_query/include/postgres/port/pg_iovec.h +117 -0
- data/ext/pg_query/include/postgres/port/simd.h +422 -0
- data/ext/pg_query/include/postgres/port/win32/arpa/inet.h +3 -0
- data/ext/pg_query/include/postgres/port/win32/dlfcn.h +1 -0
- data/ext/pg_query/include/postgres/port/win32/grp.h +1 -0
- data/ext/pg_query/include/postgres/port/win32/netdb.h +7 -0
- data/ext/pg_query/include/postgres/port/win32/netinet/in.h +3 -0
- data/ext/pg_query/include/postgres/port/win32/netinet/tcp.h +7 -0
- data/ext/pg_query/include/postgres/port/win32/pwd.h +3 -0
- data/ext/pg_query/include/postgres/port/win32/sys/resource.h +20 -0
- data/ext/pg_query/include/postgres/port/win32/sys/select.h +3 -0
- data/ext/pg_query/include/postgres/port/win32/sys/socket.h +34 -0
- data/ext/pg_query/include/postgres/port/win32/sys/un.h +17 -0
- data/ext/pg_query/include/postgres/port/win32/sys/wait.h +3 -0
- data/ext/pg_query/include/postgres/port/win32.h +59 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/dirent.h +34 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/sys/file.h +1 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/sys/param.h +1 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/sys/time.h +1 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/unistd.h +9 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/utime.h +3 -0
- data/ext/pg_query/include/postgres/port/win32_port.h +582 -0
- data/ext/pg_query/include/postgres/port.h +555 -0
- data/ext/pg_query/include/postgres/portability/instr_time.h +197 -0
- data/ext/pg_query/include/postgres/postgres.h +579 -0
- data/ext/pg_query/include/postgres/postgres_ext.h +73 -0
- data/ext/pg_query/include/postgres/postmaster/autovacuum.h +69 -0
- data/ext/pg_query/include/postgres/postmaster/bgworker.h +164 -0
- data/ext/pg_query/include/postgres/postmaster/bgworker_internals.h +60 -0
- data/ext/pg_query/include/postgres/postmaster/bgwriter.h +45 -0
- data/ext/pg_query/include/postgres/postmaster/interrupt.h +32 -0
- data/ext/pg_query/include/postgres/postmaster/pgarch.h +36 -0
- data/ext/pg_query/include/postgres/postmaster/postmaster.h +101 -0
- data/ext/pg_query/include/postgres/postmaster/startup.h +41 -0
- data/ext/pg_query/include/postgres/postmaster/syslogger.h +101 -0
- data/ext/pg_query/include/postgres/postmaster/walsummarizer.h +35 -0
- data/ext/pg_query/include/postgres/postmaster/walwriter.h +23 -0
- data/ext/pg_query/include/postgres/regex/regex.h +272 -0
- data/ext/pg_query/include/postgres/replication/logicallauncher.h +34 -0
- data/ext/pg_query/include/postgres/replication/logicalproto.h +274 -0
- data/ext/pg_query/include/postgres/replication/logicalworker.h +33 -0
- data/ext/pg_query/include/postgres/replication/origin.h +73 -0
- data/ext/pg_query/include/postgres/replication/reorderbuffer.h +734 -0
- data/ext/pg_query/include/postgres/replication/slot.h +289 -0
- data/ext/pg_query/include/postgres/replication/slotsync.h +38 -0
- data/ext/pg_query/include/postgres/replication/syncrep.h +109 -0
- data/ext/pg_query/include/postgres/replication/walreceiver.h +504 -0
- data/ext/pg_query/include/postgres/replication/walsender.h +76 -0
- data/ext/pg_query/include/postgres/rewrite/prs2lock.h +46 -0
- data/ext/pg_query/include/postgres/rewrite/rewriteHandler.h +41 -0
- data/ext/pg_query/include/postgres/rewrite/rewriteManip.h +96 -0
- data/ext/pg_query/include/postgres/rewrite/rewriteSupport.h +26 -0
- data/ext/pg_query/include/postgres/storage/block.h +108 -0
- data/ext/pg_query/include/postgres/storage/buf.h +46 -0
- data/ext/pg_query/include/postgres/storage/bufmgr.h +411 -0
- data/ext/pg_query/include/postgres/storage/bufpage.h +510 -0
- data/ext/pg_query/include/postgres/storage/condition_variable.h +73 -0
- data/ext/pg_query/include/postgres/storage/dsm.h +61 -0
- data/ext/pg_query/include/postgres/storage/dsm_impl.h +79 -0
- data/ext/pg_query/include/postgres/storage/fd.h +219 -0
- data/ext/pg_query/include/postgres/storage/fileset.h +40 -0
- data/ext/pg_query/include/postgres/storage/ipc.h +87 -0
- data/ext/pg_query/include/postgres/storage/item.h +19 -0
- data/ext/pg_query/include/postgres/storage/itemid.h +184 -0
- data/ext/pg_query/include/postgres/storage/itemptr.h +245 -0
- data/ext/pg_query/include/postgres/storage/large_object.h +100 -0
- data/ext/pg_query/include/postgres/storage/latch.h +196 -0
- data/ext/pg_query/include/postgres/storage/lmgr.h +126 -0
- data/ext/pg_query/include/postgres/storage/lock.h +624 -0
- data/ext/pg_query/include/postgres/storage/lockdefs.h +61 -0
- data/ext/pg_query/include/postgres/storage/lwlock.h +228 -0
- data/ext/pg_query/include/postgres/storage/lwlocknames.h +47 -0
- data/ext/pg_query/include/postgres/storage/off.h +57 -0
- data/ext/pg_query/include/postgres/storage/pg_sema.h +61 -0
- data/ext/pg_query/include/postgres/storage/pg_shmem.h +93 -0
- data/ext/pg_query/include/postgres/storage/pmsignal.h +105 -0
- data/ext/pg_query/include/postgres/storage/predicate.h +83 -0
- data/ext/pg_query/include/postgres/storage/proc.h +488 -0
- data/ext/pg_query/include/postgres/storage/procarray.h +103 -0
- data/ext/pg_query/include/postgres/storage/proclist_types.h +53 -0
- data/ext/pg_query/include/postgres/storage/procnumber.h +43 -0
- data/ext/pg_query/include/postgres/storage/procsignal.h +75 -0
- data/ext/pg_query/include/postgres/storage/read_stream.h +65 -0
- data/ext/pg_query/include/postgres/storage/relfilelocator.h +100 -0
- data/ext/pg_query/include/postgres/storage/s_lock.h +847 -0
- data/ext/pg_query/include/postgres/storage/sharedfileset.h +37 -0
- data/ext/pg_query/include/postgres/storage/shm_mq.h +86 -0
- data/ext/pg_query/include/postgres/storage/shm_toc.h +58 -0
- data/ext/pg_query/include/postgres/storage/shmem.h +59 -0
- data/ext/pg_query/include/postgres/storage/sinval.h +153 -0
- data/ext/pg_query/include/postgres/storage/smgr.h +130 -0
- data/ext/pg_query/include/postgres/storage/spin.h +77 -0
- data/ext/pg_query/include/postgres/storage/standby.h +109 -0
- data/ext/pg_query/include/postgres/storage/standbydefs.h +74 -0
- data/ext/pg_query/include/postgres/storage/sync.h +66 -0
- data/ext/pg_query/include/postgres/tcop/cmdtag.h +62 -0
- data/ext/pg_query/include/postgres/tcop/cmdtaglist.h +219 -0
- data/ext/pg_query/include/postgres/tcop/deparse_utility.h +108 -0
- data/ext/pg_query/include/postgres/tcop/dest.h +148 -0
- data/ext/pg_query/include/postgres/tcop/fastpath.h +20 -0
- data/ext/pg_query/include/postgres/tcop/pquery.h +51 -0
- data/ext/pg_query/include/postgres/tcop/tcopprot.h +98 -0
- data/ext/pg_query/include/postgres/tcop/utility.h +112 -0
- data/ext/pg_query/include/postgres/tsearch/ts_cache.h +96 -0
- data/ext/pg_query/include/postgres/utils/acl.h +290 -0
- data/ext/pg_query/include/postgres/utils/aclchk_internal.h +45 -0
- data/ext/pg_query/include/postgres/utils/array.h +481 -0
- data/ext/pg_query/include/postgres/utils/ascii.h +84 -0
- data/ext/pg_query/include/postgres/utils/backend_progress.h +46 -0
- data/ext/pg_query/include/postgres/utils/backend_status.h +340 -0
- data/ext/pg_query/include/postgres/utils/builtins.h +139 -0
- data/ext/pg_query/include/postgres/utils/bytea.h +28 -0
- data/ext/pg_query/include/postgres/utils/catcache.h +231 -0
- data/ext/pg_query/include/postgres/utils/date.h +118 -0
- data/ext/pg_query/include/postgres/utils/datetime.h +367 -0
- data/ext/pg_query/include/postgres/utils/datum.h +76 -0
- data/ext/pg_query/include/postgres/utils/dsa.h +166 -0
- data/ext/pg_query/include/postgres/utils/elog.h +540 -0
- data/ext/pg_query/include/postgres/utils/errcodes.h +352 -0
- data/ext/pg_query/include/postgres/utils/expandeddatum.h +170 -0
- data/ext/pg_query/include/postgres/utils/expandedrecord.h +241 -0
- data/ext/pg_query/include/postgres/utils/float.h +357 -0
- data/ext/pg_query/include/postgres/utils/fmgroids.h +3347 -0
- data/ext/pg_query/include/postgres/utils/fmgrprotos.h +2904 -0
- data/ext/pg_query/include/postgres/utils/fmgrtab.h +49 -0
- data/ext/pg_query/include/postgres/utils/guc.h +456 -0
- data/ext/pg_query/include/postgres/utils/guc_hooks.h +184 -0
- data/ext/pg_query/include/postgres/utils/guc_tables.h +323 -0
- data/ext/pg_query/include/postgres/utils/hsearch.h +153 -0
- data/ext/pg_query/include/postgres/utils/injection_point.h +44 -0
- data/ext/pg_query/include/postgres/utils/inval.h +68 -0
- data/ext/pg_query/include/postgres/utils/logtape.h +77 -0
- data/ext/pg_query/include/postgres/utils/lsyscache.h +215 -0
- data/ext/pg_query/include/postgres/utils/memdebug.h +82 -0
- data/ext/pg_query/include/postgres/utils/memutils.h +193 -0
- data/ext/pg_query/include/postgres/utils/memutils_internal.h +176 -0
- data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +253 -0
- data/ext/pg_query/include/postgres/utils/numeric.h +110 -0
- data/ext/pg_query/include/postgres/utils/palloc.h +151 -0
- data/ext/pg_query/include/postgres/utils/partcache.h +103 -0
- data/ext/pg_query/include/postgres/utils/pg_locale.h +136 -0
- data/ext/pg_query/include/postgres/utils/pgstat_internal.h +827 -0
- data/ext/pg_query/include/postgres/utils/plancache.h +238 -0
- data/ext/pg_query/include/postgres/utils/portal.h +252 -0
- data/ext/pg_query/include/postgres/utils/probes.h +114 -0
- data/ext/pg_query/include/postgres/utils/ps_status.h +47 -0
- data/ext/pg_query/include/postgres/utils/queryenvironment.h +74 -0
- data/ext/pg_query/include/postgres/utils/regproc.h +39 -0
- data/ext/pg_query/include/postgres/utils/rel.h +711 -0
- data/ext/pg_query/include/postgres/utils/relcache.h +155 -0
- data/ext/pg_query/include/postgres/utils/reltrigger.h +81 -0
- data/ext/pg_query/include/postgres/utils/resowner.h +167 -0
- data/ext/pg_query/include/postgres/utils/ruleutils.h +52 -0
- data/ext/pg_query/include/postgres/utils/sharedtuplestore.h +61 -0
- data/ext/pg_query/include/postgres/utils/snapmgr.h +130 -0
- data/ext/pg_query/include/postgres/utils/snapshot.h +219 -0
- data/ext/pg_query/include/postgres/utils/sortsupport.h +391 -0
- data/ext/pg_query/include/postgres/utils/syscache.h +136 -0
- data/ext/pg_query/include/postgres/utils/timeout.h +96 -0
- data/ext/pg_query/include/postgres/utils/timestamp.h +147 -0
- data/ext/pg_query/include/postgres/utils/tuplesort.h +472 -0
- data/ext/pg_query/include/postgres/utils/tuplestore.h +88 -0
- data/ext/pg_query/include/postgres/utils/typcache.h +210 -0
- data/ext/pg_query/include/postgres/utils/varlena.h +53 -0
- data/ext/pg_query/include/postgres/utils/wait_event.h +108 -0
- data/ext/pg_query/include/postgres/utils/wait_event_types.h +218 -0
- data/ext/pg_query/include/postgres/utils/xml.h +94 -0
- data/ext/pg_query/include/postgres/varatt.h +358 -0
- data/ext/pg_query/include/protobuf/pg_query.pb-c.h +8077 -6217
- data/ext/pg_query/include/protobuf/pg_query.pb.h +132024 -88124
- data/ext/pg_query/pg_query.c +10 -1
- data/ext/pg_query/pg_query.pb-c.c +24028 -17173
- data/ext/pg_query/pg_query_deparse.c +1 -9902
- data/ext/pg_query/pg_query_fingerprint.c +42 -18
- data/ext/pg_query/pg_query_fingerprint.h +1 -1
- data/ext/pg_query/pg_query_internal.h +1 -1
- data/ext/pg_query/pg_query_json_plpgsql.c +1 -25
- data/ext/pg_query/pg_query_normalize.c +44 -3
- data/ext/pg_query/pg_query_outfuncs_json.c +62 -16
- data/ext/pg_query/pg_query_outfuncs_protobuf.c +73 -12
- data/ext/pg_query/pg_query_parse.c +47 -5
- data/ext/pg_query/pg_query_parse_plpgsql.c +19 -18
- data/ext/pg_query/pg_query_readfuncs_protobuf.c +45 -10
- data/ext/pg_query/pg_query_ruby.c +5 -0
- data/ext/pg_query/pg_query_scan.c +4 -3
- data/ext/pg_query/pg_query_split.c +6 -5
- data/ext/pg_query/postgres_deparse.c +11496 -0
- data/ext/pg_query/postgres_deparse.h +9 -0
- data/ext/pg_query/src_backend_catalog_namespace.c +262 -71
- data/ext/pg_query/src_backend_catalog_pg_proc.c +3 -2
- data/ext/pg_query/src_backend_commands_define.c +12 -3
- data/ext/pg_query/src_backend_nodes_bitmapset.c +142 -156
- data/ext/pg_query/src_backend_nodes_copyfuncs.c +100 -5881
- data/ext/pg_query/src_backend_nodes_equalfuncs.c +102 -3831
- data/ext/pg_query/src_backend_nodes_extensible.c +6 -29
- data/ext/pg_query/src_backend_nodes_list.c +89 -18
- data/ext/pg_query/src_backend_nodes_makefuncs.c +138 -4
- data/ext/pg_query/src_backend_nodes_nodeFuncs.c +433 -132
- data/ext/pg_query/src_backend_nodes_value.c +28 -19
- data/ext/pg_query/src_backend_parser_gram.c +45255 -38885
- data/ext/pg_query/src_backend_parser_parser.c +53 -8
- data/ext/pg_query/src_backend_parser_scan.c +6999 -3438
- data/ext/pg_query/src_backend_parser_scansup.c +5 -28
- data/ext/pg_query/src_backend_storage_ipc_ipc.c +13 -4
- data/ext/pg_query/src_backend_tcop_postgres.c +156 -114
- data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +140 -0
- data/ext/pg_query/src_backend_utils_adt_datum.c +14 -2
- 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_numutils.c +488 -0
- data/ext/pg_query/src_backend_utils_adt_ruleutils.c +247 -34
- data/ext/pg_query/src_backend_utils_error_assert.c +17 -18
- data/ext/pg_query/src_backend_utils_error_elog.c +543 -343
- data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +47 -18
- data/ext/pg_query/src_backend_utils_init_globals.c +22 -7
- data/ext/pg_query/src_backend_utils_mb_mbutils.c +84 -148
- data/ext/pg_query/src_backend_utils_misc_guc_tables.c +502 -0
- data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +166 -0
- data/ext/pg_query/src_backend_utils_mmgr_aset.c +708 -499
- data/ext/pg_query/src_backend_utils_mmgr_bump.c +728 -0
- data/ext/pg_query/src_backend_utils_mmgr_generation.c +1115 -0
- data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +710 -218
- data/ext/pg_query/src_backend_utils_mmgr_slab.c +1079 -0
- data/ext/pg_query/src_common_encnames.c +46 -44
- 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 +602 -510
- 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 +21 -4
- data/ext/pg_query/src_common_wchar.c +754 -178
- data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +143 -24
- data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +3 -18
- data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +1295 -1255
- 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 +20 -2
- data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +60 -60
- data/ext/pg_query/src_port_pg_bitutils.c +283 -54
- data/ext/pg_query/src_port_pgstrcasecmp.c +57 -1
- data/ext/pg_query/src_port_qsort.c +12 -224
- data/ext/pg_query/src_port_snprintf.c +56 -39
- data/ext/pg_query/src_port_strerror.c +9 -21
- data/ext/pg_query/src_port_strlcpy.c +79 -0
- data/lib/pg_query/filter_columns.rb +1 -1
- data/lib/pg_query/fingerprint.rb +10 -9
- data/lib/pg_query/node.rb +18 -13
- data/lib/pg_query/param_refs.rb +3 -3
- data/lib/pg_query/parse.rb +25 -15
- data/lib/pg_query/parse_error.rb +1 -0
- data/lib/pg_query/pg_query_pb.rb +181 -3038
- data/lib/pg_query/scan.rb +1 -0
- data/lib/pg_query/treewalker.rb +55 -8
- data/lib/pg_query/truncate.rb +19 -21
- data/lib/pg_query/version.rb +1 -1
- metadata +447 -436
- data/ext/pg_query/guc-file.c +0 -0
- data/ext/pg_query/include/access/amapi.h +0 -246
- data/ext/pg_query/include/access/attmap.h +0 -52
- data/ext/pg_query/include/access/attnum.h +0 -64
- data/ext/pg_query/include/access/clog.h +0 -61
- data/ext/pg_query/include/access/commit_ts.h +0 -77
- data/ext/pg_query/include/access/detoast.h +0 -92
- data/ext/pg_query/include/access/genam.h +0 -228
- data/ext/pg_query/include/access/gin.h +0 -78
- data/ext/pg_query/include/access/htup.h +0 -89
- data/ext/pg_query/include/access/htup_details.h +0 -819
- data/ext/pg_query/include/access/itup.h +0 -161
- data/ext/pg_query/include/access/parallel.h +0 -82
- data/ext/pg_query/include/access/printtup.h +0 -35
- data/ext/pg_query/include/access/relation.h +0 -28
- data/ext/pg_query/include/access/relscan.h +0 -176
- data/ext/pg_query/include/access/rmgr.h +0 -35
- data/ext/pg_query/include/access/rmgrlist.h +0 -49
- data/ext/pg_query/include/access/sdir.h +0 -58
- data/ext/pg_query/include/access/skey.h +0 -151
- data/ext/pg_query/include/access/stratnum.h +0 -83
- data/ext/pg_query/include/access/sysattr.h +0 -29
- data/ext/pg_query/include/access/table.h +0 -27
- data/ext/pg_query/include/access/tableam.h +0 -1825
- data/ext/pg_query/include/access/transam.h +0 -265
- data/ext/pg_query/include/access/tupconvert.h +0 -51
- data/ext/pg_query/include/access/tupdesc.h +0 -154
- data/ext/pg_query/include/access/tupmacs.h +0 -247
- data/ext/pg_query/include/access/twophase.h +0 -63
- data/ext/pg_query/include/access/xact.h +0 -469
- data/ext/pg_query/include/access/xlog.h +0 -398
- data/ext/pg_query/include/access/xlog_internal.h +0 -339
- data/ext/pg_query/include/access/xlogdefs.h +0 -109
- data/ext/pg_query/include/access/xloginsert.h +0 -64
- data/ext/pg_query/include/access/xlogreader.h +0 -337
- data/ext/pg_query/include/access/xlogrecord.h +0 -227
- data/ext/pg_query/include/bootstrap/bootstrap.h +0 -62
- data/ext/pg_query/include/c.h +0 -1334
- data/ext/pg_query/include/catalog/catalog.h +0 -42
- data/ext/pg_query/include/catalog/catversion.h +0 -58
- data/ext/pg_query/include/catalog/dependency.h +0 -277
- data/ext/pg_query/include/catalog/genbki.h +0 -64
- data/ext/pg_query/include/catalog/index.h +0 -199
- data/ext/pg_query/include/catalog/indexing.h +0 -366
- data/ext/pg_query/include/catalog/namespace.h +0 -188
- data/ext/pg_query/include/catalog/objectaccess.h +0 -197
- data/ext/pg_query/include/catalog/objectaddress.h +0 -84
- data/ext/pg_query/include/catalog/pg_aggregate.h +0 -176
- data/ext/pg_query/include/catalog/pg_aggregate_d.h +0 -77
- data/ext/pg_query/include/catalog/pg_am.h +0 -60
- data/ext/pg_query/include/catalog/pg_am_d.h +0 -45
- data/ext/pg_query/include/catalog/pg_attribute.h +0 -204
- data/ext/pg_query/include/catalog/pg_attribute_d.h +0 -59
- data/ext/pg_query/include/catalog/pg_authid.h +0 -58
- data/ext/pg_query/include/catalog/pg_authid_d.h +0 -49
- data/ext/pg_query/include/catalog/pg_class.h +0 -200
- data/ext/pg_query/include/catalog/pg_class_d.h +0 -103
- data/ext/pg_query/include/catalog/pg_collation.h +0 -73
- data/ext/pg_query/include/catalog/pg_collation_d.h +0 -45
- data/ext/pg_query/include/catalog/pg_constraint.h +0 -247
- data/ext/pg_query/include/catalog/pg_constraint_d.h +0 -67
- data/ext/pg_query/include/catalog/pg_control.h +0 -252
- data/ext/pg_query/include/catalog/pg_conversion.h +0 -72
- data/ext/pg_query/include/catalog/pg_conversion_d.h +0 -35
- data/ext/pg_query/include/catalog/pg_depend.h +0 -73
- data/ext/pg_query/include/catalog/pg_depend_d.h +0 -34
- data/ext/pg_query/include/catalog/pg_event_trigger.h +0 -51
- data/ext/pg_query/include/catalog/pg_event_trigger_d.h +0 -34
- data/ext/pg_query/include/catalog/pg_index.h +0 -80
- data/ext/pg_query/include/catalog/pg_index_d.h +0 -56
- data/ext/pg_query/include/catalog/pg_language.h +0 -67
- data/ext/pg_query/include/catalog/pg_language_d.h +0 -39
- data/ext/pg_query/include/catalog/pg_namespace.h +0 -59
- data/ext/pg_query/include/catalog/pg_namespace_d.h +0 -34
- data/ext/pg_query/include/catalog/pg_opclass.h +0 -85
- data/ext/pg_query/include/catalog/pg_opclass_d.h +0 -49
- data/ext/pg_query/include/catalog/pg_operator.h +0 -104
- data/ext/pg_query/include/catalog/pg_operator_d.h +0 -106
- data/ext/pg_query/include/catalog/pg_opfamily.h +0 -60
- data/ext/pg_query/include/catalog/pg_opfamily_d.h +0 -47
- data/ext/pg_query/include/catalog/pg_partitioned_table.h +0 -63
- data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +0 -35
- data/ext/pg_query/include/catalog/pg_proc.h +0 -211
- data/ext/pg_query/include/catalog/pg_proc_d.h +0 -99
- data/ext/pg_query/include/catalog/pg_publication.h +0 -118
- data/ext/pg_query/include/catalog/pg_publication_d.h +0 -36
- data/ext/pg_query/include/catalog/pg_replication_origin.h +0 -57
- data/ext/pg_query/include/catalog/pg_replication_origin_d.h +0 -29
- data/ext/pg_query/include/catalog/pg_statistic.h +0 -275
- data/ext/pg_query/include/catalog/pg_statistic_d.h +0 -194
- data/ext/pg_query/include/catalog/pg_statistic_ext.h +0 -74
- data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +0 -40
- data/ext/pg_query/include/catalog/pg_transform.h +0 -45
- data/ext/pg_query/include/catalog/pg_transform_d.h +0 -32
- data/ext/pg_query/include/catalog/pg_trigger.h +0 -137
- data/ext/pg_query/include/catalog/pg_trigger_d.h +0 -106
- data/ext/pg_query/include/catalog/pg_ts_config.h +0 -50
- data/ext/pg_query/include/catalog/pg_ts_config_d.h +0 -32
- data/ext/pg_query/include/catalog/pg_ts_dict.h +0 -54
- data/ext/pg_query/include/catalog/pg_ts_dict_d.h +0 -33
- data/ext/pg_query/include/catalog/pg_ts_parser.h +0 -57
- data/ext/pg_query/include/catalog/pg_ts_parser_d.h +0 -35
- data/ext/pg_query/include/catalog/pg_ts_template.h +0 -48
- data/ext/pg_query/include/catalog/pg_ts_template_d.h +0 -32
- data/ext/pg_query/include/catalog/pg_type.h +0 -373
- data/ext/pg_query/include/catalog/pg_type_d.h +0 -285
- data/ext/pg_query/include/catalog/storage.h +0 -48
- data/ext/pg_query/include/commands/async.h +0 -54
- data/ext/pg_query/include/commands/dbcommands.h +0 -35
- data/ext/pg_query/include/commands/defrem.h +0 -173
- data/ext/pg_query/include/commands/event_trigger.h +0 -88
- data/ext/pg_query/include/commands/explain.h +0 -127
- data/ext/pg_query/include/commands/prepare.h +0 -61
- data/ext/pg_query/include/commands/tablespace.h +0 -69
- data/ext/pg_query/include/commands/trigger.h +0 -285
- data/ext/pg_query/include/commands/user.h +0 -37
- data/ext/pg_query/include/commands/vacuum.h +0 -293
- data/ext/pg_query/include/commands/variable.h +0 -38
- data/ext/pg_query/include/common/file_perm.h +0 -56
- data/ext/pg_query/include/common/hashfn.h +0 -104
- data/ext/pg_query/include/common/ip.h +0 -37
- data/ext/pg_query/include/common/keywords.h +0 -33
- data/ext/pg_query/include/common/kwlookup.h +0 -44
- data/ext/pg_query/include/common/relpath.h +0 -90
- data/ext/pg_query/include/common/string.h +0 -19
- data/ext/pg_query/include/common/unicode_combining_table.h +0 -196
- data/ext/pg_query/include/datatype/timestamp.h +0 -197
- data/ext/pg_query/include/executor/execdesc.h +0 -70
- data/ext/pg_query/include/executor/executor.h +0 -620
- data/ext/pg_query/include/executor/functions.h +0 -41
- data/ext/pg_query/include/executor/instrument.h +0 -101
- data/ext/pg_query/include/executor/spi.h +0 -175
- data/ext/pg_query/include/executor/tablefunc.h +0 -67
- data/ext/pg_query/include/executor/tuptable.h +0 -487
- data/ext/pg_query/include/fmgr.h +0 -775
- data/ext/pg_query/include/funcapi.h +0 -348
- data/ext/pg_query/include/getaddrinfo.h +0 -162
- data/ext/pg_query/include/jit/jit.h +0 -105
- data/ext/pg_query/include/kwlist_d.h +0 -1072
- data/ext/pg_query/include/lib/ilist.h +0 -727
- data/ext/pg_query/include/lib/pairingheap.h +0 -102
- data/ext/pg_query/include/lib/simplehash.h +0 -1059
- data/ext/pg_query/include/lib/stringinfo.h +0 -161
- data/ext/pg_query/include/libpq/auth.h +0 -29
- data/ext/pg_query/include/libpq/crypt.h +0 -46
- data/ext/pg_query/include/libpq/hba.h +0 -140
- data/ext/pg_query/include/libpq/libpq-be.h +0 -326
- data/ext/pg_query/include/libpq/libpq.h +0 -134
- data/ext/pg_query/include/libpq/pqcomm.h +0 -208
- data/ext/pg_query/include/libpq/pqformat.h +0 -210
- data/ext/pg_query/include/libpq/pqsignal.h +0 -42
- data/ext/pg_query/include/mb/pg_wchar.h +0 -673
- data/ext/pg_query/include/mb/stringinfo_mb.h +0 -24
- data/ext/pg_query/include/miscadmin.h +0 -489
- data/ext/pg_query/include/nodes/bitmapset.h +0 -122
- data/ext/pg_query/include/nodes/execnodes.h +0 -2523
- data/ext/pg_query/include/nodes/extensible.h +0 -160
- data/ext/pg_query/include/nodes/lockoptions.h +0 -61
- data/ext/pg_query/include/nodes/makefuncs.h +0 -108
- data/ext/pg_query/include/nodes/memnodes.h +0 -108
- data/ext/pg_query/include/nodes/nodeFuncs.h +0 -162
- data/ext/pg_query/include/nodes/nodes.h +0 -842
- data/ext/pg_query/include/nodes/params.h +0 -170
- data/ext/pg_query/include/nodes/parsenodes.h +0 -3580
- data/ext/pg_query/include/nodes/pathnodes.h +0 -2557
- data/ext/pg_query/include/nodes/pg_list.h +0 -606
- data/ext/pg_query/include/nodes/plannodes.h +0 -1266
- data/ext/pg_query/include/nodes/primnodes.h +0 -1541
- data/ext/pg_query/include/nodes/print.h +0 -34
- data/ext/pg_query/include/nodes/tidbitmap.h +0 -75
- data/ext/pg_query/include/nodes/value.h +0 -61
- data/ext/pg_query/include/optimizer/cost.h +0 -206
- data/ext/pg_query/include/optimizer/geqo.h +0 -88
- data/ext/pg_query/include/optimizer/geqo_gene.h +0 -45
- data/ext/pg_query/include/optimizer/optimizer.h +0 -194
- data/ext/pg_query/include/optimizer/paths.h +0 -257
- data/ext/pg_query/include/optimizer/planmain.h +0 -119
- data/ext/pg_query/include/parser/analyze.h +0 -49
- data/ext/pg_query/include/parser/gram.h +0 -1067
- data/ext/pg_query/include/parser/gramparse.h +0 -75
- data/ext/pg_query/include/parser/kwlist.h +0 -477
- data/ext/pg_query/include/parser/parse_agg.h +0 -68
- data/ext/pg_query/include/parser/parse_clause.h +0 -54
- data/ext/pg_query/include/parser/parse_coerce.h +0 -98
- data/ext/pg_query/include/parser/parse_collate.h +0 -27
- data/ext/pg_query/include/parser/parse_expr.h +0 -26
- data/ext/pg_query/include/parser/parse_func.h +0 -73
- data/ext/pg_query/include/parser/parse_node.h +0 -327
- data/ext/pg_query/include/parser/parse_oper.h +0 -67
- data/ext/pg_query/include/parser/parse_relation.h +0 -123
- data/ext/pg_query/include/parser/parse_target.h +0 -46
- data/ext/pg_query/include/parser/parse_type.h +0 -60
- data/ext/pg_query/include/parser/parser.h +0 -41
- data/ext/pg_query/include/parser/parsetree.h +0 -61
- data/ext/pg_query/include/parser/scanner.h +0 -152
- data/ext/pg_query/include/parser/scansup.h +0 -30
- data/ext/pg_query/include/partitioning/partdefs.h +0 -26
- data/ext/pg_query/include/pg_config.h +0 -995
- data/ext/pg_query/include/pg_config_manual.h +0 -357
- data/ext/pg_query/include/pg_config_os.h +0 -8
- data/ext/pg_query/include/pg_getopt.h +0 -56
- data/ext/pg_query/include/pg_trace.h +0 -17
- data/ext/pg_query/include/pgstat.h +0 -1488
- data/ext/pg_query/include/pgtime.h +0 -84
- data/ext/pg_query/include/pl_gram.h +0 -385
- data/ext/pg_query/include/pl_reserved_kwlist.h +0 -52
- data/ext/pg_query/include/pl_reserved_kwlist_d.h +0 -114
- data/ext/pg_query/include/pl_unreserved_kwlist.h +0 -112
- data/ext/pg_query/include/pl_unreserved_kwlist_d.h +0 -246
- data/ext/pg_query/include/plerrcodes.h +0 -990
- data/ext/pg_query/include/plpgsql.h +0 -1347
- data/ext/pg_query/include/port/atomics/arch-arm.h +0 -26
- data/ext/pg_query/include/port/atomics/arch-ppc.h +0 -254
- data/ext/pg_query/include/port/atomics/arch-x86.h +0 -252
- data/ext/pg_query/include/port/atomics/fallback.h +0 -170
- data/ext/pg_query/include/port/atomics/generic-gcc.h +0 -286
- data/ext/pg_query/include/port/atomics/generic.h +0 -401
- data/ext/pg_query/include/port/atomics.h +0 -524
- data/ext/pg_query/include/port/pg_bitutils.h +0 -272
- data/ext/pg_query/include/port/pg_bswap.h +0 -161
- data/ext/pg_query/include/port/pg_crc32c.h +0 -101
- data/ext/pg_query/include/port.h +0 -528
- data/ext/pg_query/include/portability/instr_time.h +0 -256
- data/ext/pg_query/include/postgres.h +0 -764
- data/ext/pg_query/include/postgres_ext.h +0 -74
- data/ext/pg_query/include/postmaster/autovacuum.h +0 -83
- data/ext/pg_query/include/postmaster/bgworker.h +0 -161
- data/ext/pg_query/include/postmaster/bgworker_internals.h +0 -64
- data/ext/pg_query/include/postmaster/bgwriter.h +0 -45
- data/ext/pg_query/include/postmaster/fork_process.h +0 -17
- data/ext/pg_query/include/postmaster/interrupt.h +0 -32
- data/ext/pg_query/include/postmaster/pgarch.h +0 -39
- data/ext/pg_query/include/postmaster/postmaster.h +0 -77
- data/ext/pg_query/include/postmaster/syslogger.h +0 -98
- data/ext/pg_query/include/postmaster/walwriter.h +0 -21
- data/ext/pg_query/include/regex/regex.h +0 -184
- data/ext/pg_query/include/replication/logicallauncher.h +0 -31
- data/ext/pg_query/include/replication/logicalproto.h +0 -110
- data/ext/pg_query/include/replication/logicalworker.h +0 -19
- data/ext/pg_query/include/replication/origin.h +0 -73
- data/ext/pg_query/include/replication/reorderbuffer.h +0 -468
- data/ext/pg_query/include/replication/slot.h +0 -219
- data/ext/pg_query/include/replication/syncrep.h +0 -115
- data/ext/pg_query/include/replication/walreceiver.h +0 -340
- data/ext/pg_query/include/replication/walsender.h +0 -74
- data/ext/pg_query/include/rewrite/prs2lock.h +0 -46
- data/ext/pg_query/include/rewrite/rewriteHandler.h +0 -40
- data/ext/pg_query/include/rewrite/rewriteManip.h +0 -87
- data/ext/pg_query/include/rewrite/rewriteSupport.h +0 -26
- data/ext/pg_query/include/storage/backendid.h +0 -37
- data/ext/pg_query/include/storage/block.h +0 -121
- data/ext/pg_query/include/storage/buf.h +0 -46
- data/ext/pg_query/include/storage/bufmgr.h +0 -292
- data/ext/pg_query/include/storage/bufpage.h +0 -459
- data/ext/pg_query/include/storage/condition_variable.h +0 -62
- data/ext/pg_query/include/storage/dsm.h +0 -61
- data/ext/pg_query/include/storage/dsm_impl.h +0 -75
- data/ext/pg_query/include/storage/fd.h +0 -168
- data/ext/pg_query/include/storage/ipc.h +0 -81
- data/ext/pg_query/include/storage/item.h +0 -19
- data/ext/pg_query/include/storage/itemid.h +0 -184
- data/ext/pg_query/include/storage/itemptr.h +0 -206
- data/ext/pg_query/include/storage/large_object.h +0 -100
- data/ext/pg_query/include/storage/latch.h +0 -190
- data/ext/pg_query/include/storage/lmgr.h +0 -114
- data/ext/pg_query/include/storage/lock.h +0 -613
- data/ext/pg_query/include/storage/lockdefs.h +0 -59
- data/ext/pg_query/include/storage/lwlock.h +0 -233
- data/ext/pg_query/include/storage/lwlocknames.h +0 -51
- data/ext/pg_query/include/storage/off.h +0 -57
- data/ext/pg_query/include/storage/pg_sema.h +0 -61
- data/ext/pg_query/include/storage/pg_shmem.h +0 -90
- data/ext/pg_query/include/storage/pmsignal.h +0 -94
- data/ext/pg_query/include/storage/predicate.h +0 -87
- data/ext/pg_query/include/storage/proc.h +0 -347
- data/ext/pg_query/include/storage/proclist_types.h +0 -51
- data/ext/pg_query/include/storage/procsignal.h +0 -75
- data/ext/pg_query/include/storage/relfilenode.h +0 -99
- data/ext/pg_query/include/storage/s_lock.h +0 -1071
- data/ext/pg_query/include/storage/sharedfileset.h +0 -45
- data/ext/pg_query/include/storage/shm_mq.h +0 -85
- data/ext/pg_query/include/storage/shm_toc.h +0 -58
- data/ext/pg_query/include/storage/shmem.h +0 -81
- data/ext/pg_query/include/storage/sinval.h +0 -153
- data/ext/pg_query/include/storage/sinvaladt.h +0 -43
- data/ext/pg_query/include/storage/smgr.h +0 -109
- data/ext/pg_query/include/storage/spin.h +0 -77
- data/ext/pg_query/include/storage/standby.h +0 -91
- data/ext/pg_query/include/storage/standbydefs.h +0 -74
- data/ext/pg_query/include/storage/sync.h +0 -62
- data/ext/pg_query/include/tcop/cmdtag.h +0 -58
- data/ext/pg_query/include/tcop/cmdtaglist.h +0 -217
- data/ext/pg_query/include/tcop/deparse_utility.h +0 -108
- data/ext/pg_query/include/tcop/dest.h +0 -149
- data/ext/pg_query/include/tcop/fastpath.h +0 -21
- data/ext/pg_query/include/tcop/pquery.h +0 -51
- data/ext/pg_query/include/tcop/tcopprot.h +0 -89
- data/ext/pg_query/include/tcop/utility.h +0 -108
- data/ext/pg_query/include/tsearch/ts_cache.h +0 -98
- data/ext/pg_query/include/utils/acl.h +0 -312
- data/ext/pg_query/include/utils/aclchk_internal.h +0 -45
- data/ext/pg_query/include/utils/array.h +0 -459
- data/ext/pg_query/include/utils/builtins.h +0 -128
- data/ext/pg_query/include/utils/bytea.h +0 -27
- data/ext/pg_query/include/utils/catcache.h +0 -231
- data/ext/pg_query/include/utils/date.h +0 -90
- data/ext/pg_query/include/utils/datetime.h +0 -343
- data/ext/pg_query/include/utils/datum.h +0 -68
- data/ext/pg_query/include/utils/dsa.h +0 -123
- data/ext/pg_query/include/utils/dynahash.h +0 -19
- data/ext/pg_query/include/utils/elog.h +0 -439
- data/ext/pg_query/include/utils/errcodes.h +0 -352
- data/ext/pg_query/include/utils/expandeddatum.h +0 -159
- data/ext/pg_query/include/utils/expandedrecord.h +0 -231
- data/ext/pg_query/include/utils/float.h +0 -356
- data/ext/pg_query/include/utils/fmgroids.h +0 -2657
- data/ext/pg_query/include/utils/fmgrprotos.h +0 -2646
- data/ext/pg_query/include/utils/fmgrtab.h +0 -48
- data/ext/pg_query/include/utils/guc.h +0 -443
- data/ext/pg_query/include/utils/guc_tables.h +0 -272
- data/ext/pg_query/include/utils/hsearch.h +0 -149
- data/ext/pg_query/include/utils/inval.h +0 -65
- data/ext/pg_query/include/utils/lsyscache.h +0 -198
- data/ext/pg_query/include/utils/memdebug.h +0 -82
- data/ext/pg_query/include/utils/memutils.h +0 -225
- data/ext/pg_query/include/utils/numeric.h +0 -76
- data/ext/pg_query/include/utils/palloc.h +0 -136
- data/ext/pg_query/include/utils/partcache.h +0 -102
- data/ext/pg_query/include/utils/pg_locale.h +0 -119
- data/ext/pg_query/include/utils/pg_lsn.h +0 -29
- data/ext/pg_query/include/utils/pidfile.h +0 -56
- data/ext/pg_query/include/utils/plancache.h +0 -235
- data/ext/pg_query/include/utils/portal.h +0 -254
- data/ext/pg_query/include/utils/probes.h +0 -114
- data/ext/pg_query/include/utils/ps_status.h +0 -25
- data/ext/pg_query/include/utils/queryenvironment.h +0 -74
- data/ext/pg_query/include/utils/regproc.h +0 -28
- data/ext/pg_query/include/utils/rel.h +0 -643
- data/ext/pg_query/include/utils/relcache.h +0 -150
- data/ext/pg_query/include/utils/reltrigger.h +0 -81
- data/ext/pg_query/include/utils/resowner.h +0 -86
- data/ext/pg_query/include/utils/rls.h +0 -50
- data/ext/pg_query/include/utils/ruleutils.h +0 -44
- data/ext/pg_query/include/utils/sharedtuplestore.h +0 -61
- data/ext/pg_query/include/utils/snapmgr.h +0 -159
- data/ext/pg_query/include/utils/snapshot.h +0 -206
- data/ext/pg_query/include/utils/sortsupport.h +0 -276
- data/ext/pg_query/include/utils/syscache.h +0 -219
- data/ext/pg_query/include/utils/timeout.h +0 -88
- data/ext/pg_query/include/utils/timestamp.h +0 -116
- data/ext/pg_query/include/utils/tuplesort.h +0 -277
- data/ext/pg_query/include/utils/tuplestore.h +0 -91
- data/ext/pg_query/include/utils/typcache.h +0 -202
- data/ext/pg_query/include/utils/tzparser.h +0 -39
- data/ext/pg_query/include/utils/varlena.h +0 -39
- data/ext/pg_query/include/utils/xml.h +0 -84
- data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -2
- data/ext/pg_query/src_backend_libpq_pqcomm.c +0 -659
- data/ext/pg_query/src_backend_parser_parse_expr.c +0 -313
- data/ext/pg_query/src_backend_postmaster_postmaster.c +0 -2230
- data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +0 -370
- data/ext/pg_query/src_backend_utils_hash_dynahash.c +0 -1086
- data/ext/pg_query/src_backend_utils_misc_guc.c +0 -1832
- data/ext/pg_query/src_common_string.c +0 -86
- data/ext/pg_query/src_port_erand48.c +0 -127
- data/ext/pg_query/src_port_pgsleep.c +0 -69
- data/ext/pg_query/src_port_random.c +0 -31
- data/ext/pg_query/src_port_strnlen.c +0 -39
- /data/ext/pg_query/{pg_query_ruby.sym → ext_symbols.sym} +0 -0
- /data/ext/pg_query/include/{pg_config_ext.h → postgres/pg_config_ext.h} +0 -0
@@ -1,1086 +0,0 @@
|
|
1
|
-
/*--------------------------------------------------------------------
|
2
|
-
* Symbols referenced in this file:
|
3
|
-
* - hash_search
|
4
|
-
* - hash_search_with_hash_value
|
5
|
-
* - has_seq_scans
|
6
|
-
* - num_seq_scans
|
7
|
-
* - seq_scan_tables
|
8
|
-
* - expand_table
|
9
|
-
* - dir_realloc
|
10
|
-
* - CurrentDynaHashCxt
|
11
|
-
* - seg_alloc
|
12
|
-
* - calc_bucket
|
13
|
-
* - hash_corrupted
|
14
|
-
* - DynaHashAlloc
|
15
|
-
* - get_hash_entry
|
16
|
-
* - element_alloc
|
17
|
-
*--------------------------------------------------------------------
|
18
|
-
*/
|
19
|
-
|
20
|
-
/*-------------------------------------------------------------------------
|
21
|
-
*
|
22
|
-
* dynahash.c
|
23
|
-
* dynamic hash tables
|
24
|
-
*
|
25
|
-
* dynahash.c supports both local-to-a-backend hash tables and hash tables in
|
26
|
-
* shared memory. For shared hash tables, it is the caller's responsibility
|
27
|
-
* to provide appropriate access interlocking. The simplest convention is
|
28
|
-
* that a single LWLock protects the whole hash table. Searches (HASH_FIND or
|
29
|
-
* hash_seq_search) need only shared lock, but any update requires exclusive
|
30
|
-
* lock. For heavily-used shared tables, the single-lock approach creates a
|
31
|
-
* concurrency bottleneck, so we also support "partitioned" locking wherein
|
32
|
-
* there are multiple LWLocks guarding distinct subsets of the table. To use
|
33
|
-
* a hash table in partitioned mode, the HASH_PARTITION flag must be given
|
34
|
-
* to hash_create. This prevents any attempt to split buckets on-the-fly.
|
35
|
-
* Therefore, each hash bucket chain operates independently, and no fields
|
36
|
-
* of the hash header change after init except nentries and freeList.
|
37
|
-
* (A partitioned table uses multiple copies of those fields, guarded by
|
38
|
-
* spinlocks, for additional concurrency.)
|
39
|
-
* This lets any subset of the hash buckets be treated as a separately
|
40
|
-
* lockable partition. We expect callers to use the low-order bits of a
|
41
|
-
* lookup key's hash value as a partition number --- this will work because
|
42
|
-
* of the way calc_bucket() maps hash values to bucket numbers.
|
43
|
-
*
|
44
|
-
* For hash tables in shared memory, the memory allocator function should
|
45
|
-
* match malloc's semantics of returning NULL on failure. For hash tables
|
46
|
-
* in local memory, we typically use palloc() which will throw error on
|
47
|
-
* failure. The code in this file has to cope with both cases.
|
48
|
-
*
|
49
|
-
* dynahash.c provides support for these types of lookup keys:
|
50
|
-
*
|
51
|
-
* 1. Null-terminated C strings (truncated if necessary to fit in keysize),
|
52
|
-
* compared as though by strcmp(). This is the default behavior.
|
53
|
-
*
|
54
|
-
* 2. Arbitrary binary data of size keysize, compared as though by memcmp().
|
55
|
-
* (Caller must ensure there are no undefined padding bits in the keys!)
|
56
|
-
* This is selected by specifying HASH_BLOBS flag to hash_create.
|
57
|
-
*
|
58
|
-
* 3. More complex key behavior can be selected by specifying user-supplied
|
59
|
-
* hashing, comparison, and/or key-copying functions. At least a hashing
|
60
|
-
* function must be supplied; comparison defaults to memcmp() and key copying
|
61
|
-
* to memcpy() when a user-defined hashing function is selected.
|
62
|
-
*
|
63
|
-
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
64
|
-
* Portions Copyright (c) 1994, Regents of the University of California
|
65
|
-
*
|
66
|
-
*
|
67
|
-
* IDENTIFICATION
|
68
|
-
* src/backend/utils/hash/dynahash.c
|
69
|
-
*
|
70
|
-
*-------------------------------------------------------------------------
|
71
|
-
*/
|
72
|
-
|
73
|
-
/*
|
74
|
-
* Original comments:
|
75
|
-
*
|
76
|
-
* Dynamic hashing, after CACM April 1988 pp 446-457, by Per-Ake Larson.
|
77
|
-
* Coded into C, with minor code improvements, and with hsearch(3) interface,
|
78
|
-
* by ejp@ausmelb.oz, Jul 26, 1988: 13:16;
|
79
|
-
* also, hcreate/hdestroy routines added to simulate hsearch(3).
|
80
|
-
*
|
81
|
-
* These routines simulate hsearch(3) and family, with the important
|
82
|
-
* difference that the hash table is dynamic - can grow indefinitely
|
83
|
-
* beyond its original size (as supplied to hcreate()).
|
84
|
-
*
|
85
|
-
* Performance appears to be comparable to that of hsearch(3).
|
86
|
-
* The 'source-code' options referred to in hsearch(3)'s 'man' page
|
87
|
-
* are not implemented; otherwise functionality is identical.
|
88
|
-
*
|
89
|
-
* Compilation controls:
|
90
|
-
* HASH_DEBUG controls some informative traces, mainly for debugging.
|
91
|
-
* HASH_STATISTICS causes HashAccesses and HashCollisions to be maintained;
|
92
|
-
* when combined with HASH_DEBUG, these are displayed by hdestroy().
|
93
|
-
*
|
94
|
-
* Problems & fixes to ejp@ausmelb.oz. WARNING: relies on pre-processor
|
95
|
-
* concatenation property, in probably unnecessary code 'optimization'.
|
96
|
-
*
|
97
|
-
* Modified margo@postgres.berkeley.edu February 1990
|
98
|
-
* added multiple table interface
|
99
|
-
* Modified by sullivan@postgres.berkeley.edu April 1990
|
100
|
-
* changed ctl structure for shared memory
|
101
|
-
*/
|
102
|
-
|
103
|
-
#include "postgres.h"
|
104
|
-
|
105
|
-
#include <limits.h>
|
106
|
-
|
107
|
-
#include "access/xact.h"
|
108
|
-
#include "common/hashfn.h"
|
109
|
-
#include "port/pg_bitutils.h"
|
110
|
-
#include "storage/shmem.h"
|
111
|
-
#include "storage/spin.h"
|
112
|
-
#include "utils/dynahash.h"
|
113
|
-
#include "utils/memutils.h"
|
114
|
-
|
115
|
-
|
116
|
-
/*
|
117
|
-
* Constants
|
118
|
-
*
|
119
|
-
* A hash table has a top-level "directory", each of whose entries points
|
120
|
-
* to a "segment" of ssize bucket headers. The maximum number of hash
|
121
|
-
* buckets is thus dsize * ssize (but dsize may be expansible). Of course,
|
122
|
-
* the number of records in the table can be larger, but we don't want a
|
123
|
-
* whole lot of records per bucket or performance goes down.
|
124
|
-
*
|
125
|
-
* In a hash table allocated in shared memory, the directory cannot be
|
126
|
-
* expanded because it must stay at a fixed address. The directory size
|
127
|
-
* should be selected using hash_select_dirsize (and you'd better have
|
128
|
-
* a good idea of the maximum number of entries!). For non-shared hash
|
129
|
-
* tables, the initial directory size can be left at the default.
|
130
|
-
*/
|
131
|
-
#define DEF_SEGSIZE 256
|
132
|
-
#define DEF_SEGSIZE_SHIFT 8 /* must be log2(DEF_SEGSIZE) */
|
133
|
-
#define DEF_DIRSIZE 256
|
134
|
-
#define DEF_FFACTOR 1 /* default fill factor */
|
135
|
-
|
136
|
-
/* Number of freelists to be used for a partitioned hash table. */
|
137
|
-
#define NUM_FREELISTS 32
|
138
|
-
|
139
|
-
/* A hash bucket is a linked list of HASHELEMENTs */
|
140
|
-
typedef HASHELEMENT *HASHBUCKET;
|
141
|
-
|
142
|
-
/* A hash segment is an array of bucket headers */
|
143
|
-
typedef HASHBUCKET *HASHSEGMENT;
|
144
|
-
|
145
|
-
/*
|
146
|
-
* Per-freelist data.
|
147
|
-
*
|
148
|
-
* In a partitioned hash table, each freelist is associated with a specific
|
149
|
-
* set of hashcodes, as determined by the FREELIST_IDX() macro below.
|
150
|
-
* nentries tracks the number of live hashtable entries having those hashcodes
|
151
|
-
* (NOT the number of entries in the freelist, as you might expect).
|
152
|
-
*
|
153
|
-
* The coverage of a freelist might be more or less than one partition, so it
|
154
|
-
* needs its own lock rather than relying on caller locking. Relying on that
|
155
|
-
* wouldn't work even if the coverage was the same, because of the occasional
|
156
|
-
* need to "borrow" entries from another freelist; see get_hash_entry().
|
157
|
-
*
|
158
|
-
* Using an array of FreeListData instead of separate arrays of mutexes,
|
159
|
-
* nentries and freeLists helps to reduce sharing of cache lines between
|
160
|
-
* different mutexes.
|
161
|
-
*/
|
162
|
-
typedef struct
|
163
|
-
{
|
164
|
-
slock_t mutex; /* spinlock for this freelist */
|
165
|
-
long nentries; /* number of entries in associated buckets */
|
166
|
-
HASHELEMENT *freeList; /* chain of free elements */
|
167
|
-
} FreeListData;
|
168
|
-
|
169
|
-
/*
|
170
|
-
* Header structure for a hash table --- contains all changeable info
|
171
|
-
*
|
172
|
-
* In a shared-memory hash table, the HASHHDR is in shared memory, while
|
173
|
-
* each backend has a local HTAB struct. For a non-shared table, there isn't
|
174
|
-
* any functional difference between HASHHDR and HTAB, but we separate them
|
175
|
-
* anyway to share code between shared and non-shared tables.
|
176
|
-
*/
|
177
|
-
struct HASHHDR
|
178
|
-
{
|
179
|
-
/*
|
180
|
-
* The freelist can become a point of contention in high-concurrency hash
|
181
|
-
* tables, so we use an array of freelists, each with its own mutex and
|
182
|
-
* nentries count, instead of just a single one. Although the freelists
|
183
|
-
* normally operate independently, we will scavenge entries from freelists
|
184
|
-
* other than a hashcode's default freelist when necessary.
|
185
|
-
*
|
186
|
-
* If the hash table is not partitioned, only freeList[0] is used and its
|
187
|
-
* spinlock is not used at all; callers' locking is assumed sufficient.
|
188
|
-
*/
|
189
|
-
FreeListData freeList[NUM_FREELISTS];
|
190
|
-
|
191
|
-
/* These fields can change, but not in a partitioned table */
|
192
|
-
/* Also, dsize can't change in a shared table, even if unpartitioned */
|
193
|
-
long dsize; /* directory size */
|
194
|
-
long nsegs; /* number of allocated segments (<= dsize) */
|
195
|
-
uint32 max_bucket; /* ID of maximum bucket in use */
|
196
|
-
uint32 high_mask; /* mask to modulo into entire table */
|
197
|
-
uint32 low_mask; /* mask to modulo into lower half of table */
|
198
|
-
|
199
|
-
/* These fields are fixed at hashtable creation */
|
200
|
-
Size keysize; /* hash key length in bytes */
|
201
|
-
Size entrysize; /* total user element size in bytes */
|
202
|
-
long num_partitions; /* # partitions (must be power of 2), or 0 */
|
203
|
-
long ffactor; /* target fill factor */
|
204
|
-
long max_dsize; /* 'dsize' limit if directory is fixed size */
|
205
|
-
long ssize; /* segment size --- must be power of 2 */
|
206
|
-
int sshift; /* segment shift = log2(ssize) */
|
207
|
-
int nelem_alloc; /* number of entries to allocate at once */
|
208
|
-
|
209
|
-
#ifdef HASH_STATISTICS
|
210
|
-
|
211
|
-
/*
|
212
|
-
* Count statistics here. NB: stats code doesn't bother with mutex, so
|
213
|
-
* counts could be corrupted a bit in a partitioned table.
|
214
|
-
*/
|
215
|
-
long accesses;
|
216
|
-
long collisions;
|
217
|
-
#endif
|
218
|
-
};
|
219
|
-
|
220
|
-
#define IS_PARTITIONED(hctl) ((hctl)->num_partitions != 0)
|
221
|
-
|
222
|
-
#define FREELIST_IDX(hctl, hashcode) \
|
223
|
-
(IS_PARTITIONED(hctl) ? (hashcode) % NUM_FREELISTS : 0)
|
224
|
-
|
225
|
-
/*
|
226
|
-
* Top control structure for a hashtable --- in a shared table, each backend
|
227
|
-
* has its own copy (OK since no fields change at runtime)
|
228
|
-
*/
|
229
|
-
struct HTAB
|
230
|
-
{
|
231
|
-
HASHHDR *hctl; /* => shared control information */
|
232
|
-
HASHSEGMENT *dir; /* directory of segment starts */
|
233
|
-
HashValueFunc hash; /* hash function */
|
234
|
-
HashCompareFunc match; /* key comparison function */
|
235
|
-
HashCopyFunc keycopy; /* key copying function */
|
236
|
-
HashAllocFunc alloc; /* memory allocator */
|
237
|
-
MemoryContext hcxt; /* memory context if default allocator used */
|
238
|
-
char *tabname; /* table name (for error messages) */
|
239
|
-
bool isshared; /* true if table is in shared memory */
|
240
|
-
bool isfixed; /* if true, don't enlarge */
|
241
|
-
|
242
|
-
/* freezing a shared table isn't allowed, so we can keep state here */
|
243
|
-
bool frozen; /* true = no more inserts allowed */
|
244
|
-
|
245
|
-
/* We keep local copies of these fixed values to reduce contention */
|
246
|
-
Size keysize; /* hash key length in bytes */
|
247
|
-
long ssize; /* segment size --- must be power of 2 */
|
248
|
-
int sshift; /* segment shift = log2(ssize) */
|
249
|
-
};
|
250
|
-
|
251
|
-
/*
|
252
|
-
* Key (also entry) part of a HASHELEMENT
|
253
|
-
*/
|
254
|
-
#define ELEMENTKEY(helem) (((char *)(helem)) + MAXALIGN(sizeof(HASHELEMENT)))
|
255
|
-
|
256
|
-
/*
|
257
|
-
* Obtain element pointer given pointer to key
|
258
|
-
*/
|
259
|
-
#define ELEMENT_FROM_KEY(key) \
|
260
|
-
((HASHELEMENT *) (((char *) (key)) - MAXALIGN(sizeof(HASHELEMENT))))
|
261
|
-
|
262
|
-
/*
|
263
|
-
* Fast MOD arithmetic, assuming that y is a power of 2 !
|
264
|
-
*/
|
265
|
-
#define MOD(x,y) ((x) & ((y)-1))
|
266
|
-
|
267
|
-
#ifdef HASH_STATISTICS
|
268
|
-
static long hash_accesses,
|
269
|
-
hash_collisions,
|
270
|
-
hash_expansions;
|
271
|
-
#endif
|
272
|
-
|
273
|
-
/*
|
274
|
-
* Private function prototypes
|
275
|
-
*/
|
276
|
-
static void *DynaHashAlloc(Size size);
|
277
|
-
static HASHSEGMENT seg_alloc(HTAB *hashp);
|
278
|
-
static bool element_alloc(HTAB *hashp, int nelem, int freelist_idx);
|
279
|
-
static bool dir_realloc(HTAB *hashp);
|
280
|
-
static bool expand_table(HTAB *hashp);
|
281
|
-
static HASHBUCKET get_hash_entry(HTAB *hashp, int freelist_idx);
|
282
|
-
static void hdefault(HTAB *hashp);
|
283
|
-
static int choose_nelem_alloc(Size entrysize);
|
284
|
-
static bool init_htab(HTAB *hashp, long nelem);
|
285
|
-
static void hash_corrupted(HTAB *hashp);
|
286
|
-
static long next_pow2_long(long num);
|
287
|
-
static int next_pow2_int(long num);
|
288
|
-
static void register_seq_scan(HTAB *hashp);
|
289
|
-
static void deregister_seq_scan(HTAB *hashp);
|
290
|
-
static bool has_seq_scans(HTAB *hashp);
|
291
|
-
|
292
|
-
|
293
|
-
/*
|
294
|
-
* memory allocation support
|
295
|
-
*/
|
296
|
-
static __thread MemoryContext CurrentDynaHashCxt = NULL;
|
297
|
-
|
298
|
-
|
299
|
-
static void *
|
300
|
-
DynaHashAlloc(Size size)
|
301
|
-
{
|
302
|
-
Assert(MemoryContextIsValid(CurrentDynaHashCxt));
|
303
|
-
return MemoryContextAlloc(CurrentDynaHashCxt, size);
|
304
|
-
}
|
305
|
-
|
306
|
-
|
307
|
-
/*
|
308
|
-
* HashCompareFunc for string keys
|
309
|
-
*
|
310
|
-
* Because we copy keys with strlcpy(), they will be truncated at keysize-1
|
311
|
-
* bytes, so we can only compare that many ... hence strncmp is almost but
|
312
|
-
* not quite the right thing.
|
313
|
-
*/
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
/************************** CREATE ROUTINES **********************/
|
318
|
-
|
319
|
-
/*
|
320
|
-
* hash_create -- create a new dynamic hash table
|
321
|
-
*
|
322
|
-
* tabname: a name for the table (for debugging purposes)
|
323
|
-
* nelem: maximum number of elements expected
|
324
|
-
* *info: additional table parameters, as indicated by flags
|
325
|
-
* flags: bitmask indicating which parameters to take from *info
|
326
|
-
*
|
327
|
-
* Note: for a shared-memory hashtable, nelem needs to be a pretty good
|
328
|
-
* estimate, since we can't expand the table on the fly. But an unshared
|
329
|
-
* hashtable can be expanded on-the-fly, so it's better for nelem to be
|
330
|
-
* on the small side and let the table grow if it's exceeded. An overly
|
331
|
-
* large nelem will penalize hash_seq_search speed without buying much.
|
332
|
-
*/
|
333
|
-
|
334
|
-
|
335
|
-
/*
|
336
|
-
* Set default HASHHDR parameters.
|
337
|
-
*/
|
338
|
-
#ifdef HASH_STATISTICS
|
339
|
-
#endif
|
340
|
-
|
341
|
-
/*
|
342
|
-
* Given the user-specified entry size, choose nelem_alloc, ie, how many
|
343
|
-
* elements to add to the hash table when we need more.
|
344
|
-
*/
|
345
|
-
|
346
|
-
|
347
|
-
/*
|
348
|
-
* Compute derived fields of hctl and build the initial directory/segment
|
349
|
-
* arrays
|
350
|
-
*/
|
351
|
-
#ifdef HASH_DEBUG
|
352
|
-
#endif
|
353
|
-
|
354
|
-
/*
|
355
|
-
* Estimate the space needed for a hashtable containing the given number
|
356
|
-
* of entries of given size.
|
357
|
-
* NOTE: this is used to estimate the footprint of hashtables in shared
|
358
|
-
* memory; therefore it does not count HTAB which is in local memory.
|
359
|
-
* NB: assumes that all hash structure parameters have default values!
|
360
|
-
*/
|
361
|
-
|
362
|
-
|
363
|
-
/*
|
364
|
-
* Select an appropriate directory size for a hashtable with the given
|
365
|
-
* maximum number of entries.
|
366
|
-
* This is only needed for hashtables in shared memory, whose directories
|
367
|
-
* cannot be expanded dynamically.
|
368
|
-
* NB: assumes that all hash structure parameters have default values!
|
369
|
-
*
|
370
|
-
* XXX this had better agree with the behavior of init_htab()...
|
371
|
-
*/
|
372
|
-
|
373
|
-
|
374
|
-
/*
|
375
|
-
* Compute the required initial memory allocation for a shared-memory
|
376
|
-
* hashtable with the given parameters. We need space for the HASHHDR
|
377
|
-
* and for the (non expansible) directory.
|
378
|
-
*/
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
/********************** DESTROY ROUTINES ************************/
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
#ifdef HASH_STATISTICS
|
387
|
-
#endif
|
388
|
-
|
389
|
-
/*******************************SEARCH ROUTINES *****************************/
|
390
|
-
|
391
|
-
|
392
|
-
/*
|
393
|
-
* get_hash_value -- exported routine to calculate a key's hash value
|
394
|
-
*
|
395
|
-
* We export this because for partitioned tables, callers need to compute
|
396
|
-
* the partition number (from the low-order bits of the hash value) before
|
397
|
-
* searching.
|
398
|
-
*/
|
399
|
-
|
400
|
-
|
401
|
-
/* Convert a hash value to a bucket number */
|
402
|
-
static inline uint32
|
403
|
-
calc_bucket(HASHHDR *hctl, uint32 hash_val)
|
404
|
-
{
|
405
|
-
uint32 bucket;
|
406
|
-
|
407
|
-
bucket = hash_val & hctl->high_mask;
|
408
|
-
if (bucket > hctl->max_bucket)
|
409
|
-
bucket = bucket & hctl->low_mask;
|
410
|
-
|
411
|
-
return bucket;
|
412
|
-
}
|
413
|
-
|
414
|
-
/*
|
415
|
-
* hash_search -- look up key in table and perform action
|
416
|
-
* hash_search_with_hash_value -- same, with key's hash value already computed
|
417
|
-
*
|
418
|
-
* action is one of:
|
419
|
-
* HASH_FIND: look up key in table
|
420
|
-
* HASH_ENTER: look up key in table, creating entry if not present
|
421
|
-
* HASH_ENTER_NULL: same, but return NULL if out of memory
|
422
|
-
* HASH_REMOVE: look up key in table, remove entry if present
|
423
|
-
*
|
424
|
-
* Return value is a pointer to the element found/entered/removed if any,
|
425
|
-
* or NULL if no match was found. (NB: in the case of the REMOVE action,
|
426
|
-
* the result is a dangling pointer that shouldn't be dereferenced!)
|
427
|
-
*
|
428
|
-
* HASH_ENTER will normally ereport a generic "out of memory" error if
|
429
|
-
* it is unable to create a new entry. The HASH_ENTER_NULL operation is
|
430
|
-
* the same except it will return NULL if out of memory. Note that
|
431
|
-
* HASH_ENTER_NULL cannot be used with the default palloc-based allocator,
|
432
|
-
* since palloc internally ereports on out-of-memory.
|
433
|
-
*
|
434
|
-
* If foundPtr isn't NULL, then *foundPtr is set true if we found an
|
435
|
-
* existing entry in the table, false otherwise. This is needed in the
|
436
|
-
* HASH_ENTER case, but is redundant with the return value otherwise.
|
437
|
-
*
|
438
|
-
* For hash_search_with_hash_value, the hashvalue parameter must have been
|
439
|
-
* calculated with get_hash_value().
|
440
|
-
*/
|
441
|
-
void *
|
442
|
-
hash_search(HTAB *hashp,
|
443
|
-
const void *keyPtr,
|
444
|
-
HASHACTION action,
|
445
|
-
bool *foundPtr)
|
446
|
-
{
|
447
|
-
return hash_search_with_hash_value(hashp,
|
448
|
-
keyPtr,
|
449
|
-
hashp->hash(keyPtr, hashp->keysize),
|
450
|
-
action,
|
451
|
-
foundPtr);
|
452
|
-
}
|
453
|
-
|
454
|
-
void *
|
455
|
-
hash_search_with_hash_value(HTAB *hashp,
|
456
|
-
const void *keyPtr,
|
457
|
-
uint32 hashvalue,
|
458
|
-
HASHACTION action,
|
459
|
-
bool *foundPtr)
|
460
|
-
{
|
461
|
-
HASHHDR *hctl = hashp->hctl;
|
462
|
-
int freelist_idx = FREELIST_IDX(hctl, hashvalue);
|
463
|
-
Size keysize;
|
464
|
-
uint32 bucket;
|
465
|
-
long segment_num;
|
466
|
-
long segment_ndx;
|
467
|
-
HASHSEGMENT segp;
|
468
|
-
HASHBUCKET currBucket;
|
469
|
-
HASHBUCKET *prevBucketPtr;
|
470
|
-
HashCompareFunc match;
|
471
|
-
|
472
|
-
#ifdef HASH_STATISTICS
|
473
|
-
hash_accesses++;
|
474
|
-
hctl->accesses++;
|
475
|
-
#endif
|
476
|
-
|
477
|
-
/*
|
478
|
-
* If inserting, check if it is time to split a bucket.
|
479
|
-
*
|
480
|
-
* NOTE: failure to expand table is not a fatal error, it just means we
|
481
|
-
* have to run at higher fill factor than we wanted. However, if we're
|
482
|
-
* using the palloc allocator then it will throw error anyway on
|
483
|
-
* out-of-memory, so we must do this before modifying the table.
|
484
|
-
*/
|
485
|
-
if (action == HASH_ENTER || action == HASH_ENTER_NULL)
|
486
|
-
{
|
487
|
-
/*
|
488
|
-
* Can't split if running in partitioned mode, nor if frozen, nor if
|
489
|
-
* table is the subject of any active hash_seq_search scans. Strange
|
490
|
-
* order of these tests is to try to check cheaper conditions first.
|
491
|
-
*/
|
492
|
-
if (!IS_PARTITIONED(hctl) && !hashp->frozen &&
|
493
|
-
hctl->freeList[0].nentries / (long) (hctl->max_bucket + 1) >= hctl->ffactor &&
|
494
|
-
!has_seq_scans(hashp))
|
495
|
-
(void) expand_table(hashp);
|
496
|
-
}
|
497
|
-
|
498
|
-
/*
|
499
|
-
* Do the initial lookup
|
500
|
-
*/
|
501
|
-
bucket = calc_bucket(hctl, hashvalue);
|
502
|
-
|
503
|
-
segment_num = bucket >> hashp->sshift;
|
504
|
-
segment_ndx = MOD(bucket, hashp->ssize);
|
505
|
-
|
506
|
-
segp = hashp->dir[segment_num];
|
507
|
-
|
508
|
-
if (segp == NULL)
|
509
|
-
hash_corrupted(hashp);
|
510
|
-
|
511
|
-
prevBucketPtr = &segp[segment_ndx];
|
512
|
-
currBucket = *prevBucketPtr;
|
513
|
-
|
514
|
-
/*
|
515
|
-
* Follow collision chain looking for matching key
|
516
|
-
*/
|
517
|
-
match = hashp->match; /* save one fetch in inner loop */
|
518
|
-
keysize = hashp->keysize; /* ditto */
|
519
|
-
|
520
|
-
while (currBucket != NULL)
|
521
|
-
{
|
522
|
-
if (currBucket->hashvalue == hashvalue &&
|
523
|
-
match(ELEMENTKEY(currBucket), keyPtr, keysize) == 0)
|
524
|
-
break;
|
525
|
-
prevBucketPtr = &(currBucket->link);
|
526
|
-
currBucket = *prevBucketPtr;
|
527
|
-
#ifdef HASH_STATISTICS
|
528
|
-
hash_collisions++;
|
529
|
-
hctl->collisions++;
|
530
|
-
#endif
|
531
|
-
}
|
532
|
-
|
533
|
-
if (foundPtr)
|
534
|
-
*foundPtr = (bool) (currBucket != NULL);
|
535
|
-
|
536
|
-
/*
|
537
|
-
* OK, now what?
|
538
|
-
*/
|
539
|
-
switch (action)
|
540
|
-
{
|
541
|
-
case HASH_FIND:
|
542
|
-
if (currBucket != NULL)
|
543
|
-
return (void *) ELEMENTKEY(currBucket);
|
544
|
-
return NULL;
|
545
|
-
|
546
|
-
case HASH_REMOVE:
|
547
|
-
if (currBucket != NULL)
|
548
|
-
{
|
549
|
-
/* if partitioned, must lock to touch nentries and freeList */
|
550
|
-
if (IS_PARTITIONED(hctl))
|
551
|
-
SpinLockAcquire(&(hctl->freeList[freelist_idx].mutex));
|
552
|
-
|
553
|
-
/* delete the record from the appropriate nentries counter. */
|
554
|
-
Assert(hctl->freeList[freelist_idx].nentries > 0);
|
555
|
-
hctl->freeList[freelist_idx].nentries--;
|
556
|
-
|
557
|
-
/* remove record from hash bucket's chain. */
|
558
|
-
*prevBucketPtr = currBucket->link;
|
559
|
-
|
560
|
-
/* add the record to the appropriate freelist. */
|
561
|
-
currBucket->link = hctl->freeList[freelist_idx].freeList;
|
562
|
-
hctl->freeList[freelist_idx].freeList = currBucket;
|
563
|
-
|
564
|
-
if (IS_PARTITIONED(hctl))
|
565
|
-
SpinLockRelease(&hctl->freeList[freelist_idx].mutex);
|
566
|
-
|
567
|
-
/*
|
568
|
-
* better hope the caller is synchronizing access to this
|
569
|
-
* element, because someone else is going to reuse it the next
|
570
|
-
* time something is added to the table
|
571
|
-
*/
|
572
|
-
return (void *) ELEMENTKEY(currBucket);
|
573
|
-
}
|
574
|
-
return NULL;
|
575
|
-
|
576
|
-
case HASH_ENTER_NULL:
|
577
|
-
/* ENTER_NULL does not work with palloc-based allocator */
|
578
|
-
Assert(hashp->alloc != DynaHashAlloc);
|
579
|
-
/* FALL THRU */
|
580
|
-
|
581
|
-
case HASH_ENTER:
|
582
|
-
/* Return existing element if found, else create one */
|
583
|
-
if (currBucket != NULL)
|
584
|
-
return (void *) ELEMENTKEY(currBucket);
|
585
|
-
|
586
|
-
/* disallow inserts if frozen */
|
587
|
-
if (hashp->frozen)
|
588
|
-
elog(ERROR, "cannot insert into frozen hashtable \"%s\"",
|
589
|
-
hashp->tabname);
|
590
|
-
|
591
|
-
currBucket = get_hash_entry(hashp, freelist_idx);
|
592
|
-
if (currBucket == NULL)
|
593
|
-
{
|
594
|
-
/* out of memory */
|
595
|
-
if (action == HASH_ENTER_NULL)
|
596
|
-
return NULL;
|
597
|
-
/* report a generic message */
|
598
|
-
if (hashp->isshared)
|
599
|
-
ereport(ERROR,
|
600
|
-
(errcode(ERRCODE_OUT_OF_MEMORY),
|
601
|
-
errmsg("out of shared memory")));
|
602
|
-
else
|
603
|
-
ereport(ERROR,
|
604
|
-
(errcode(ERRCODE_OUT_OF_MEMORY),
|
605
|
-
errmsg("out of memory")));
|
606
|
-
}
|
607
|
-
|
608
|
-
/* link into hashbucket chain */
|
609
|
-
*prevBucketPtr = currBucket;
|
610
|
-
currBucket->link = NULL;
|
611
|
-
|
612
|
-
/* copy key into record */
|
613
|
-
currBucket->hashvalue = hashvalue;
|
614
|
-
hashp->keycopy(ELEMENTKEY(currBucket), keyPtr, keysize);
|
615
|
-
|
616
|
-
/*
|
617
|
-
* Caller is expected to fill the data field on return. DO NOT
|
618
|
-
* insert any code that could possibly throw error here, as doing
|
619
|
-
* so would leave the table entry incomplete and hence corrupt the
|
620
|
-
* caller's data structure.
|
621
|
-
*/
|
622
|
-
|
623
|
-
return (void *) ELEMENTKEY(currBucket);
|
624
|
-
}
|
625
|
-
|
626
|
-
elog(ERROR, "unrecognized hash action code: %d", (int) action);
|
627
|
-
|
628
|
-
return NULL; /* keep compiler quiet */
|
629
|
-
}
|
630
|
-
|
631
|
-
/*
|
632
|
-
* hash_update_hash_key -- change the hash key of an existing table entry
|
633
|
-
*
|
634
|
-
* This is equivalent to removing the entry, making a new entry, and copying
|
635
|
-
* over its data, except that the entry never goes to the table's freelist.
|
636
|
-
* Therefore this cannot suffer an out-of-memory failure, even if there are
|
637
|
-
* other processes operating in other partitions of the hashtable.
|
638
|
-
*
|
639
|
-
* Returns true if successful, false if the requested new hash key is already
|
640
|
-
* present. Throws error if the specified entry pointer isn't actually a
|
641
|
-
* table member.
|
642
|
-
*
|
643
|
-
* NB: currently, there is no special case for old and new hash keys being
|
644
|
-
* identical, which means we'll report false for that situation. This is
|
645
|
-
* preferable for existing uses.
|
646
|
-
*
|
647
|
-
* NB: for a partitioned hashtable, caller must hold lock on both relevant
|
648
|
-
* partitions, if the new hash key would belong to a different partition.
|
649
|
-
*/
|
650
|
-
#ifdef HASH_STATISTICS
|
651
|
-
#endif
|
652
|
-
#ifdef HASH_STATISTICS
|
653
|
-
#endif
|
654
|
-
|
655
|
-
/*
|
656
|
-
* Allocate a new hashtable entry if possible; return NULL if out of memory.
|
657
|
-
* (Or, if the underlying space allocator throws error for out-of-memory,
|
658
|
-
* we won't return at all.)
|
659
|
-
*/
|
660
|
-
static HASHBUCKET
|
661
|
-
get_hash_entry(HTAB *hashp, int freelist_idx)
|
662
|
-
{
|
663
|
-
HASHHDR *hctl = hashp->hctl;
|
664
|
-
HASHBUCKET newElement;
|
665
|
-
|
666
|
-
for (;;)
|
667
|
-
{
|
668
|
-
/* if partitioned, must lock to touch nentries and freeList */
|
669
|
-
if (IS_PARTITIONED(hctl))
|
670
|
-
SpinLockAcquire(&hctl->freeList[freelist_idx].mutex);
|
671
|
-
|
672
|
-
/* try to get an entry from the freelist */
|
673
|
-
newElement = hctl->freeList[freelist_idx].freeList;
|
674
|
-
|
675
|
-
if (newElement != NULL)
|
676
|
-
break;
|
677
|
-
|
678
|
-
if (IS_PARTITIONED(hctl))
|
679
|
-
SpinLockRelease(&hctl->freeList[freelist_idx].mutex);
|
680
|
-
|
681
|
-
/*
|
682
|
-
* No free elements in this freelist. In a partitioned table, there
|
683
|
-
* might be entries in other freelists, but to reduce contention we
|
684
|
-
* prefer to first try to get another chunk of buckets from the main
|
685
|
-
* shmem allocator. If that fails, though, we *MUST* root through all
|
686
|
-
* the other freelists before giving up. There are multiple callers
|
687
|
-
* that assume that they can allocate every element in the initially
|
688
|
-
* requested table size, or that deleting an element guarantees they
|
689
|
-
* can insert a new element, even if shared memory is entirely full.
|
690
|
-
* Failing because the needed element is in a different freelist is
|
691
|
-
* not acceptable.
|
692
|
-
*/
|
693
|
-
if (!element_alloc(hashp, hctl->nelem_alloc, freelist_idx))
|
694
|
-
{
|
695
|
-
int borrow_from_idx;
|
696
|
-
|
697
|
-
if (!IS_PARTITIONED(hctl))
|
698
|
-
return NULL; /* out of memory */
|
699
|
-
|
700
|
-
/* try to borrow element from another freelist */
|
701
|
-
borrow_from_idx = freelist_idx;
|
702
|
-
for (;;)
|
703
|
-
{
|
704
|
-
borrow_from_idx = (borrow_from_idx + 1) % NUM_FREELISTS;
|
705
|
-
if (borrow_from_idx == freelist_idx)
|
706
|
-
break; /* examined all freelists, fail */
|
707
|
-
|
708
|
-
SpinLockAcquire(&(hctl->freeList[borrow_from_idx].mutex));
|
709
|
-
newElement = hctl->freeList[borrow_from_idx].freeList;
|
710
|
-
|
711
|
-
if (newElement != NULL)
|
712
|
-
{
|
713
|
-
hctl->freeList[borrow_from_idx].freeList = newElement->link;
|
714
|
-
SpinLockRelease(&(hctl->freeList[borrow_from_idx].mutex));
|
715
|
-
|
716
|
-
/* careful: count the new element in its proper freelist */
|
717
|
-
SpinLockAcquire(&hctl->freeList[freelist_idx].mutex);
|
718
|
-
hctl->freeList[freelist_idx].nentries++;
|
719
|
-
SpinLockRelease(&hctl->freeList[freelist_idx].mutex);
|
720
|
-
|
721
|
-
return newElement;
|
722
|
-
}
|
723
|
-
|
724
|
-
SpinLockRelease(&(hctl->freeList[borrow_from_idx].mutex));
|
725
|
-
}
|
726
|
-
|
727
|
-
/* no elements available to borrow either, so out of memory */
|
728
|
-
return NULL;
|
729
|
-
}
|
730
|
-
}
|
731
|
-
|
732
|
-
/* remove entry from freelist, bump nentries */
|
733
|
-
hctl->freeList[freelist_idx].freeList = newElement->link;
|
734
|
-
hctl->freeList[freelist_idx].nentries++;
|
735
|
-
|
736
|
-
if (IS_PARTITIONED(hctl))
|
737
|
-
SpinLockRelease(&hctl->freeList[freelist_idx].mutex);
|
738
|
-
|
739
|
-
return newElement;
|
740
|
-
}
|
741
|
-
|
742
|
-
/*
|
743
|
-
* hash_get_num_entries -- get the number of entries in a hashtable
|
744
|
-
*/
|
745
|
-
|
746
|
-
|
747
|
-
/*
|
748
|
-
* hash_seq_init/_search/_term
|
749
|
-
* Sequentially search through hash table and return
|
750
|
-
* all the elements one by one, return NULL when no more.
|
751
|
-
*
|
752
|
-
* hash_seq_term should be called if and only if the scan is abandoned before
|
753
|
-
* completion; if hash_seq_search returns NULL then it has already done the
|
754
|
-
* end-of-scan cleanup.
|
755
|
-
*
|
756
|
-
* NOTE: caller may delete the returned element before continuing the scan.
|
757
|
-
* However, deleting any other element while the scan is in progress is
|
758
|
-
* UNDEFINED (it might be the one that curIndex is pointing at!). Also,
|
759
|
-
* if elements are added to the table while the scan is in progress, it is
|
760
|
-
* unspecified whether they will be visited by the scan or not.
|
761
|
-
*
|
762
|
-
* NOTE: it is possible to use hash_seq_init/hash_seq_search without any
|
763
|
-
* worry about hash_seq_term cleanup, if the hashtable is first locked against
|
764
|
-
* further insertions by calling hash_freeze.
|
765
|
-
*
|
766
|
-
* NOTE: to use this with a partitioned hashtable, caller had better hold
|
767
|
-
* at least shared lock on all partitions of the table throughout the scan!
|
768
|
-
* We can cope with insertions or deletions by our own backend, but *not*
|
769
|
-
* with concurrent insertions or deletions by another.
|
770
|
-
*/
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
/*
|
778
|
-
* hash_freeze
|
779
|
-
* Freeze a hashtable against future insertions (deletions are
|
780
|
-
* still allowed)
|
781
|
-
*
|
782
|
-
* The reason for doing this is that by preventing any more bucket splits,
|
783
|
-
* we no longer need to worry about registering hash_seq_search scans,
|
784
|
-
* and thus caller need not be careful about ensuring hash_seq_term gets
|
785
|
-
* called at the right times.
|
786
|
-
*
|
787
|
-
* Multiple calls to hash_freeze() are allowed, but you can't freeze a table
|
788
|
-
* with active scans (since hash_seq_term would then do the wrong thing).
|
789
|
-
*/
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
/********************************* UTILITIES ************************/
|
794
|
-
|
795
|
-
/*
|
796
|
-
* Expand the table by adding one more hash bucket.
|
797
|
-
*/
|
798
|
-
static bool
|
799
|
-
expand_table(HTAB *hashp)
|
800
|
-
{
|
801
|
-
HASHHDR *hctl = hashp->hctl;
|
802
|
-
HASHSEGMENT old_seg,
|
803
|
-
new_seg;
|
804
|
-
long old_bucket,
|
805
|
-
new_bucket;
|
806
|
-
long new_segnum,
|
807
|
-
new_segndx;
|
808
|
-
long old_segnum,
|
809
|
-
old_segndx;
|
810
|
-
HASHBUCKET *oldlink,
|
811
|
-
*newlink;
|
812
|
-
HASHBUCKET currElement,
|
813
|
-
nextElement;
|
814
|
-
|
815
|
-
Assert(!IS_PARTITIONED(hctl));
|
816
|
-
|
817
|
-
#ifdef HASH_STATISTICS
|
818
|
-
hash_expansions++;
|
819
|
-
#endif
|
820
|
-
|
821
|
-
new_bucket = hctl->max_bucket + 1;
|
822
|
-
new_segnum = new_bucket >> hashp->sshift;
|
823
|
-
new_segndx = MOD(new_bucket, hashp->ssize);
|
824
|
-
|
825
|
-
if (new_segnum >= hctl->nsegs)
|
826
|
-
{
|
827
|
-
/* Allocate new segment if necessary -- could fail if dir full */
|
828
|
-
if (new_segnum >= hctl->dsize)
|
829
|
-
if (!dir_realloc(hashp))
|
830
|
-
return false;
|
831
|
-
if (!(hashp->dir[new_segnum] = seg_alloc(hashp)))
|
832
|
-
return false;
|
833
|
-
hctl->nsegs++;
|
834
|
-
}
|
835
|
-
|
836
|
-
/* OK, we created a new bucket */
|
837
|
-
hctl->max_bucket++;
|
838
|
-
|
839
|
-
/*
|
840
|
-
* *Before* changing masks, find old bucket corresponding to same hash
|
841
|
-
* values; values in that bucket may need to be relocated to new bucket.
|
842
|
-
* Note that new_bucket is certainly larger than low_mask at this point,
|
843
|
-
* so we can skip the first step of the regular hash mask calc.
|
844
|
-
*/
|
845
|
-
old_bucket = (new_bucket & hctl->low_mask);
|
846
|
-
|
847
|
-
/*
|
848
|
-
* If we crossed a power of 2, readjust masks.
|
849
|
-
*/
|
850
|
-
if ((uint32) new_bucket > hctl->high_mask)
|
851
|
-
{
|
852
|
-
hctl->low_mask = hctl->high_mask;
|
853
|
-
hctl->high_mask = (uint32) new_bucket | hctl->low_mask;
|
854
|
-
}
|
855
|
-
|
856
|
-
/*
|
857
|
-
* Relocate records to the new bucket. NOTE: because of the way the hash
|
858
|
-
* masking is done in calc_bucket, only one old bucket can need to be
|
859
|
-
* split at this point. With a different way of reducing the hash value,
|
860
|
-
* that might not be true!
|
861
|
-
*/
|
862
|
-
old_segnum = old_bucket >> hashp->sshift;
|
863
|
-
old_segndx = MOD(old_bucket, hashp->ssize);
|
864
|
-
|
865
|
-
old_seg = hashp->dir[old_segnum];
|
866
|
-
new_seg = hashp->dir[new_segnum];
|
867
|
-
|
868
|
-
oldlink = &old_seg[old_segndx];
|
869
|
-
newlink = &new_seg[new_segndx];
|
870
|
-
|
871
|
-
for (currElement = *oldlink;
|
872
|
-
currElement != NULL;
|
873
|
-
currElement = nextElement)
|
874
|
-
{
|
875
|
-
nextElement = currElement->link;
|
876
|
-
if ((long) calc_bucket(hctl, currElement->hashvalue) == old_bucket)
|
877
|
-
{
|
878
|
-
*oldlink = currElement;
|
879
|
-
oldlink = &currElement->link;
|
880
|
-
}
|
881
|
-
else
|
882
|
-
{
|
883
|
-
*newlink = currElement;
|
884
|
-
newlink = &currElement->link;
|
885
|
-
}
|
886
|
-
}
|
887
|
-
/* don't forget to terminate the rebuilt hash chains... */
|
888
|
-
*oldlink = NULL;
|
889
|
-
*newlink = NULL;
|
890
|
-
|
891
|
-
return true;
|
892
|
-
}
|
893
|
-
|
894
|
-
|
895
|
-
static bool
|
896
|
-
dir_realloc(HTAB *hashp)
|
897
|
-
{
|
898
|
-
HASHSEGMENT *p;
|
899
|
-
HASHSEGMENT *old_p;
|
900
|
-
long new_dsize;
|
901
|
-
long old_dirsize;
|
902
|
-
long new_dirsize;
|
903
|
-
|
904
|
-
if (hashp->hctl->max_dsize != NO_MAX_DSIZE)
|
905
|
-
return false;
|
906
|
-
|
907
|
-
/* Reallocate directory */
|
908
|
-
new_dsize = hashp->hctl->dsize << 1;
|
909
|
-
old_dirsize = hashp->hctl->dsize * sizeof(HASHSEGMENT);
|
910
|
-
new_dirsize = new_dsize * sizeof(HASHSEGMENT);
|
911
|
-
|
912
|
-
old_p = hashp->dir;
|
913
|
-
CurrentDynaHashCxt = hashp->hcxt;
|
914
|
-
p = (HASHSEGMENT *) hashp->alloc((Size) new_dirsize);
|
915
|
-
|
916
|
-
if (p != NULL)
|
917
|
-
{
|
918
|
-
memcpy(p, old_p, old_dirsize);
|
919
|
-
MemSet(((char *) p) + old_dirsize, 0, new_dirsize - old_dirsize);
|
920
|
-
hashp->dir = p;
|
921
|
-
hashp->hctl->dsize = new_dsize;
|
922
|
-
|
923
|
-
/* XXX assume the allocator is palloc, so we know how to free */
|
924
|
-
Assert(hashp->alloc == DynaHashAlloc);
|
925
|
-
pfree(old_p);
|
926
|
-
|
927
|
-
return true;
|
928
|
-
}
|
929
|
-
|
930
|
-
return false;
|
931
|
-
}
|
932
|
-
|
933
|
-
|
934
|
-
static HASHSEGMENT
|
935
|
-
seg_alloc(HTAB *hashp)
|
936
|
-
{
|
937
|
-
HASHSEGMENT segp;
|
938
|
-
|
939
|
-
CurrentDynaHashCxt = hashp->hcxt;
|
940
|
-
segp = (HASHSEGMENT) hashp->alloc(sizeof(HASHBUCKET) * hashp->ssize);
|
941
|
-
|
942
|
-
if (!segp)
|
943
|
-
return NULL;
|
944
|
-
|
945
|
-
MemSet(segp, 0, sizeof(HASHBUCKET) * hashp->ssize);
|
946
|
-
|
947
|
-
return segp;
|
948
|
-
}
|
949
|
-
|
950
|
-
/*
|
951
|
-
* allocate some new elements and link them into the indicated free list
|
952
|
-
*/
|
953
|
-
static bool
|
954
|
-
element_alloc(HTAB *hashp, int nelem, int freelist_idx)
|
955
|
-
{
|
956
|
-
HASHHDR *hctl = hashp->hctl;
|
957
|
-
Size elementSize;
|
958
|
-
HASHELEMENT *firstElement;
|
959
|
-
HASHELEMENT *tmpElement;
|
960
|
-
HASHELEMENT *prevElement;
|
961
|
-
int i;
|
962
|
-
|
963
|
-
if (hashp->isfixed)
|
964
|
-
return false;
|
965
|
-
|
966
|
-
/* Each element has a HASHELEMENT header plus user data. */
|
967
|
-
elementSize = MAXALIGN(sizeof(HASHELEMENT)) + MAXALIGN(hctl->entrysize);
|
968
|
-
|
969
|
-
CurrentDynaHashCxt = hashp->hcxt;
|
970
|
-
firstElement = (HASHELEMENT *) hashp->alloc(nelem * elementSize);
|
971
|
-
|
972
|
-
if (!firstElement)
|
973
|
-
return false;
|
974
|
-
|
975
|
-
/* prepare to link all the new entries into the freelist */
|
976
|
-
prevElement = NULL;
|
977
|
-
tmpElement = firstElement;
|
978
|
-
for (i = 0; i < nelem; i++)
|
979
|
-
{
|
980
|
-
tmpElement->link = prevElement;
|
981
|
-
prevElement = tmpElement;
|
982
|
-
tmpElement = (HASHELEMENT *) (((char *) tmpElement) + elementSize);
|
983
|
-
}
|
984
|
-
|
985
|
-
/* if partitioned, must lock to touch freeList */
|
986
|
-
if (IS_PARTITIONED(hctl))
|
987
|
-
SpinLockAcquire(&hctl->freeList[freelist_idx].mutex);
|
988
|
-
|
989
|
-
/* freelist could be nonempty if two backends did this concurrently */
|
990
|
-
firstElement->link = hctl->freeList[freelist_idx].freeList;
|
991
|
-
hctl->freeList[freelist_idx].freeList = prevElement;
|
992
|
-
|
993
|
-
if (IS_PARTITIONED(hctl))
|
994
|
-
SpinLockRelease(&hctl->freeList[freelist_idx].mutex);
|
995
|
-
|
996
|
-
return true;
|
997
|
-
}
|
998
|
-
|
999
|
-
/* complain when we have detected a corrupted hashtable */
|
1000
|
-
static void
|
1001
|
-
hash_corrupted(HTAB *hashp)
|
1002
|
-
{
|
1003
|
-
/*
|
1004
|
-
* If the corruption is in a shared hashtable, we'd better force a
|
1005
|
-
* systemwide restart. Otherwise, just shut down this one backend.
|
1006
|
-
*/
|
1007
|
-
if (hashp->isshared)
|
1008
|
-
elog(PANIC, "hash table \"%s\" corrupted", hashp->tabname);
|
1009
|
-
else
|
1010
|
-
elog(FATAL, "hash table \"%s\" corrupted", hashp->tabname);
|
1011
|
-
}
|
1012
|
-
|
1013
|
-
/* calculate ceil(log base 2) of num */
|
1014
|
-
#if SIZEOF_LONG < 8
|
1015
|
-
#else
|
1016
|
-
#endif
|
1017
|
-
|
1018
|
-
/* calculate first power of 2 >= num, bounded to what will fit in a long */
|
1019
|
-
|
1020
|
-
|
1021
|
-
/* calculate first power of 2 >= num, bounded to what will fit in an int */
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
/************************* SEQ SCAN TRACKING ************************/
|
1026
|
-
|
1027
|
-
/*
|
1028
|
-
* We track active hash_seq_search scans here. The need for this mechanism
|
1029
|
-
* comes from the fact that a scan will get confused if a bucket split occurs
|
1030
|
-
* while it's in progress: it might visit entries twice, or even miss some
|
1031
|
-
* entirely (if it's partway through the same bucket that splits). Hence
|
1032
|
-
* we want to inhibit bucket splits if there are any active scans on the
|
1033
|
-
* table being inserted into. This is a fairly rare case in current usage,
|
1034
|
-
* so just postponing the split until the next insertion seems sufficient.
|
1035
|
-
*
|
1036
|
-
* Given present usages of the function, only a few scans are likely to be
|
1037
|
-
* open concurrently; so a finite-size stack of open scans seems sufficient,
|
1038
|
-
* and we don't worry that linear search is too slow. Note that we do
|
1039
|
-
* allow multiple scans of the same hashtable to be open concurrently.
|
1040
|
-
*
|
1041
|
-
* This mechanism can support concurrent scan and insertion in a shared
|
1042
|
-
* hashtable if it's the same backend doing both. It would fail otherwise,
|
1043
|
-
* but locking reasons seem to preclude any such scenario anyway, so we don't
|
1044
|
-
* worry.
|
1045
|
-
*
|
1046
|
-
* This arrangement is reasonably robust if a transient hashtable is deleted
|
1047
|
-
* without notifying us. The absolute worst case is we might inhibit splits
|
1048
|
-
* in another table created later at exactly the same address. We will give
|
1049
|
-
* a warning at transaction end for reference leaks, so any bugs leading to
|
1050
|
-
* lack of notification should be easy to catch.
|
1051
|
-
*/
|
1052
|
-
|
1053
|
-
#define MAX_SEQ_SCANS 100
|
1054
|
-
|
1055
|
-
static __thread HTAB *seq_scan_tables[MAX_SEQ_SCANS];
|
1056
|
-
/* tables being scanned */
|
1057
|
-
/* subtransaction nest level */
|
1058
|
-
static __thread int num_seq_scans = 0;
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
/* Register a table as having an active hash_seq_search scan */
|
1063
|
-
|
1064
|
-
|
1065
|
-
/* Deregister an active scan */
|
1066
|
-
|
1067
|
-
|
1068
|
-
/* Check if a table has any active scan */
|
1069
|
-
static bool
|
1070
|
-
has_seq_scans(HTAB *hashp)
|
1071
|
-
{
|
1072
|
-
int i;
|
1073
|
-
|
1074
|
-
for (i = 0; i < num_seq_scans; i++)
|
1075
|
-
{
|
1076
|
-
if (seq_scan_tables[i] == hashp)
|
1077
|
-
return true;
|
1078
|
-
}
|
1079
|
-
return false;
|
1080
|
-
}
|
1081
|
-
|
1082
|
-
/* Clean up any open scans at end of transaction */
|
1083
|
-
|
1084
|
-
|
1085
|
-
/* Clean up any open scans at end of subtransaction */
|
1086
|
-
|