From 34b3ea84136c4c963c7f00b524b3c3e63cac6feb Mon Sep 17 00:00:00 2001 From: Lukas Fittl Date: Mon, 1 Jan 2024 01:12:49 -0800 Subject: [PATCH] Windows test build --- .github/workflows/ci.yml | 21 +- Makefile | 5 +- parser/guc-file.c | 0 parser/include/common/ip.h | 33 - parser/include/pg_config_os.h | 8 - parser/include/pg_query_fingerprint_defs.c | 2 +- parser/include/pg_query_outfuncs_defs.c | 2 +- parser/include/pg_query_readfuncs_defs.c | 2 +- parser/include/{ => postgres}/access/amapi.h | 0 parser/include/{ => postgres}/access/attmap.h | 0 parser/include/{ => postgres}/access/attnum.h | 0 parser/include/{ => postgres}/access/clog.h | 0 .../include/{ => postgres}/access/commit_ts.h | 0 .../include/{ => postgres}/access/detoast.h | 0 parser/include/{ => postgres}/access/genam.h | 0 parser/include/{ => postgres}/access/gin.h | 0 parser/include/{ => postgres}/access/htup.h | 0 .../{ => postgres}/access/htup_details.h | 0 parser/include/{ => postgres}/access/itup.h | 0 .../include/{ => postgres}/access/parallel.h | 0 .../include/{ => postgres}/access/printtup.h | 0 .../include/{ => postgres}/access/relation.h | 0 .../include/{ => postgres}/access/relscan.h | 0 parser/include/{ => postgres}/access/rmgr.h | 0 .../include/{ => postgres}/access/rmgrlist.h | 0 parser/include/{ => postgres}/access/sdir.h | 0 parser/include/{ => postgres}/access/skey.h | 0 .../include/{ => postgres}/access/stratnum.h | 0 .../include/{ => postgres}/access/sysattr.h | 0 parser/include/{ => postgres}/access/table.h | 0 .../include/{ => postgres}/access/tableam.h | 0 .../{ => postgres}/access/toast_compression.h | 0 .../include/{ => postgres}/access/transam.h | 0 parser/include/{ => postgres}/access/tsmapi.h | 0 .../{ => postgres}/access/tupconvert.h | 0 .../include/{ => postgres}/access/tupdesc.h | 0 .../include/{ => postgres}/access/tupmacs.h | 0 .../include/{ => postgres}/access/twophase.h | 0 parser/include/{ => postgres}/access/xact.h | 0 parser/include/{ => postgres}/access/xlog.h | 0 .../{ => postgres}/access/xlog_internal.h | 0 .../{ => postgres}/access/xlogbackup.h | 0 .../include/{ => postgres}/access/xlogdefs.h | 0 .../{ => postgres}/access/xlogprefetcher.h | 0 .../{ => postgres}/access/xlogreader.h | 0 .../{ => postgres}/access/xlogrecord.h | 0 .../{ => postgres}/access/xlogrecovery.h | 0 .../{ => postgres}/archive/archive_module.h | 0 parser/include/{ => postgres}/c.h | 0 .../include/{ => postgres}/catalog/catalog.h | 0 .../{ => postgres}/catalog/catversion.h | 0 .../{ => postgres}/catalog/dependency.h | 0 .../include/{ => postgres}/catalog/genbki.h | 0 parser/include/{ => postgres}/catalog/index.h | 0 .../include/{ => postgres}/catalog/indexing.h | 0 .../{ => postgres}/catalog/namespace.h | 0 .../{ => postgres}/catalog/objectaccess.h | 0 .../{ => postgres}/catalog/objectaddress.h | 0 .../{ => postgres}/catalog/pg_aggregate.h | 0 .../{ => postgres}/catalog/pg_aggregate_d.h | 0 parser/include/{ => postgres}/catalog/pg_am.h | 0 .../include/{ => postgres}/catalog/pg_am_d.h | 0 .../{ => postgres}/catalog/pg_attribute.h | 0 .../{ => postgres}/catalog/pg_attribute_d.h | 0 .../{ => postgres}/catalog/pg_authid.h | 0 .../{ => postgres}/catalog/pg_authid_d.h | 0 .../include/{ => postgres}/catalog/pg_class.h | 0 .../{ => postgres}/catalog/pg_class_d.h | 0 .../{ => postgres}/catalog/pg_collation.h | 0 .../{ => postgres}/catalog/pg_collation_d.h | 0 .../{ => postgres}/catalog/pg_constraint.h | 0 .../{ => postgres}/catalog/pg_constraint_d.h | 0 .../{ => postgres}/catalog/pg_control.h | 0 .../{ => postgres}/catalog/pg_conversion.h | 0 .../{ => postgres}/catalog/pg_conversion_d.h | 0 .../{ => postgres}/catalog/pg_database.h | 0 .../{ => postgres}/catalog/pg_database_d.h | 0 .../{ => postgres}/catalog/pg_depend.h | 0 .../{ => postgres}/catalog/pg_depend_d.h | 0 .../{ => postgres}/catalog/pg_event_trigger.h | 0 .../catalog/pg_event_trigger_d.h | 0 .../include/{ => postgres}/catalog/pg_index.h | 0 .../{ => postgres}/catalog/pg_index_d.h | 0 .../{ => postgres}/catalog/pg_language.h | 0 .../{ => postgres}/catalog/pg_language_d.h | 0 .../{ => postgres}/catalog/pg_namespace.h | 0 .../{ => postgres}/catalog/pg_namespace_d.h | 0 .../{ => postgres}/catalog/pg_opclass.h | 0 .../{ => postgres}/catalog/pg_opclass_d.h | 0 .../{ => postgres}/catalog/pg_operator.h | 0 .../{ => postgres}/catalog/pg_operator_d.h | 0 .../{ => postgres}/catalog/pg_opfamily.h | 0 .../{ => postgres}/catalog/pg_opfamily_d.h | 0 .../catalog/pg_partitioned_table.h | 0 .../catalog/pg_partitioned_table_d.h | 0 .../include/{ => postgres}/catalog/pg_proc.h | 0 .../{ => postgres}/catalog/pg_proc_d.h | 0 .../{ => postgres}/catalog/pg_publication.h | 0 .../{ => postgres}/catalog/pg_publication_d.h | 0 .../catalog/pg_replication_origin.h | 0 .../catalog/pg_replication_origin_d.h | 0 .../{ => postgres}/catalog/pg_statistic.h | 0 .../{ => postgres}/catalog/pg_statistic_d.h | 0 .../{ => postgres}/catalog/pg_statistic_ext.h | 0 .../catalog/pg_statistic_ext_d.h | 0 .../{ => postgres}/catalog/pg_transform.h | 0 .../{ => postgres}/catalog/pg_transform_d.h | 0 .../{ => postgres}/catalog/pg_trigger.h | 0 .../{ => postgres}/catalog/pg_trigger_d.h | 0 .../{ => postgres}/catalog/pg_ts_config.h | 0 .../{ => postgres}/catalog/pg_ts_config_d.h | 0 .../{ => postgres}/catalog/pg_ts_dict.h | 0 .../{ => postgres}/catalog/pg_ts_dict_d.h | 0 .../{ => postgres}/catalog/pg_ts_parser.h | 0 .../{ => postgres}/catalog/pg_ts_parser_d.h | 0 .../{ => postgres}/catalog/pg_ts_template.h | 0 .../{ => postgres}/catalog/pg_ts_template_d.h | 0 .../include/{ => postgres}/catalog/pg_type.h | 0 .../{ => postgres}/catalog/pg_type_d.h | 0 .../include/{ => postgres}/catalog/storage.h | 0 .../include/{ => postgres}/commands/async.h | 0 .../{ => postgres}/commands/dbcommands.h | 0 .../include/{ => postgres}/commands/defrem.h | 0 .../{ => postgres}/commands/event_trigger.h | 0 .../include/{ => postgres}/commands/explain.h | 0 .../include/{ => postgres}/commands/prepare.h | 0 .../{ => postgres}/commands/tablespace.h | 0 .../include/{ => postgres}/commands/trigger.h | 0 parser/include/{ => postgres}/commands/user.h | 0 .../include/{ => postgres}/commands/vacuum.h | 0 .../{ => postgres}/common/cryptohash.h | 0 .../include/{ => postgres}/common/file_perm.h | 0 parser/include/{ => postgres}/common/hashfn.h | 0 parser/include/{ => postgres}/common/int.h | 0 .../include/{ => postgres}/common/keywords.h | 0 .../include/{ => postgres}/common/kwlookup.h | 0 .../include/{ => postgres}/common/pg_prng.h | 0 .../include/{ => postgres}/common/relpath.h | 0 .../{ => postgres}/common/scram-common.h | 0 parser/include/{ => postgres}/common/sha2.h | 0 parser/include/{ => postgres}/common/string.h | 0 .../common/unicode_east_asian_fw_table.h | 0 .../common/unicode_nonspacing_table.h | 0 .../include/{ => postgres}/copyfuncs.funcs.c | 0 .../include/{ => postgres}/copyfuncs.switch.c | 0 .../{ => postgres}/datatype/timestamp.h | 0 .../include/{ => postgres}/equalfuncs.funcs.c | 0 .../{ => postgres}/equalfuncs.switch.c | 0 .../{ => postgres}/executor/execdesc.h | 0 .../{ => postgres}/executor/executor.h | 0 .../{ => postgres}/executor/functions.h | 0 .../{ => postgres}/executor/instrument.h | 0 parser/include/{ => postgres}/executor/spi.h | 0 .../{ => postgres}/executor/tablefunc.h | 0 .../{ => postgres}/executor/tuptable.h | 0 parser/include/{ => postgres}/fmgr.h | 0 .../include/{ => postgres}/foreign/fdwapi.h | 0 parser/include/{ => postgres}/funcapi.h | 0 parser/include/{ => postgres}/gram.h | 0 parser/include/{ => postgres}/gramparse.h | 0 parser/include/{ => postgres}/jit/jit.h | 0 parser/include/{ => postgres}/kwlist_d.h | 0 parser/include/{ => postgres}/lib/dshash.h | 0 parser/include/{ => postgres}/lib/ilist.h | 0 .../include/{ => postgres}/lib/pairingheap.h | 0 .../include/{ => postgres}/lib/simplehash.h | 0 .../{ => postgres}/lib/sort_template.h | 0 .../include/{ => postgres}/lib/stringinfo.h | 0 parser/include/{ => postgres}/libpq/auth.h | 0 parser/include/{ => postgres}/libpq/crypt.h | 0 parser/include/{ => postgres}/libpq/hba.h | 0 .../include/{ => postgres}/libpq/libpq-be.h | 0 parser/include/{ => postgres}/libpq/libpq.h | 0 parser/include/{ => postgres}/libpq/pqcomm.h | 0 .../include/{ => postgres}/libpq/pqformat.h | 0 .../include/{ => postgres}/libpq/pqsignal.h | 0 parser/include/{ => postgres}/libpq/sasl.h | 0 parser/include/{ => postgres}/libpq/scram.h | 0 parser/include/{ => postgres}/mb/pg_wchar.h | 0 .../include/{ => postgres}/mb/stringinfo_mb.h | 0 parser/include/{ => postgres}/miscadmin.h | 2 +- .../include/{ => postgres}/nodes/bitmapset.h | 0 .../include/{ => postgres}/nodes/execnodes.h | 0 .../include/{ => postgres}/nodes/extensible.h | 0 .../{ => postgres}/nodes/lockoptions.h | 0 .../include/{ => postgres}/nodes/makefuncs.h | 0 .../include/{ => postgres}/nodes/memnodes.h | 0 .../include/{ => postgres}/nodes/miscnodes.h | 0 .../include/{ => postgres}/nodes/nodeFuncs.h | 0 parser/include/{ => postgres}/nodes/nodes.h | 2 +- .../include/{ => postgres}/nodes/nodetags.h | 0 parser/include/{ => postgres}/nodes/params.h | 0 .../include/{ => postgres}/nodes/parsenodes.h | 0 .../include/{ => postgres}/nodes/pathnodes.h | 0 parser/include/{ => postgres}/nodes/pg_list.h | 0 .../include/{ => postgres}/nodes/plannodes.h | 0 .../include/{ => postgres}/nodes/primnodes.h | 0 parser/include/{ => postgres}/nodes/print.h | 0 .../{ => postgres}/nodes/queryjumble.h | 0 .../include/{ => postgres}/nodes/replnodes.h | 0 .../{ => postgres}/nodes/supportnodes.h | 0 .../include/{ => postgres}/nodes/tidbitmap.h | 0 parser/include/{ => postgres}/nodes/value.h | 0 .../include/{ => postgres}/optimizer/cost.h | 0 .../include/{ => postgres}/optimizer/geqo.h | 0 .../{ => postgres}/optimizer/geqo_gene.h | 0 .../{ => postgres}/optimizer/optimizer.h | 0 .../include/{ => postgres}/optimizer/paths.h | 0 .../{ => postgres}/optimizer/planmain.h | 0 .../include/{ => postgres}/parser/analyze.h | 0 parser/include/{ => postgres}/parser/kwlist.h | 0 .../include/{ => postgres}/parser/parse_agg.h | 0 .../{ => postgres}/parser/parse_coerce.h | 0 .../{ => postgres}/parser/parse_expr.h | 0 .../{ => postgres}/parser/parse_func.h | 0 .../{ => postgres}/parser/parse_node.h | 0 .../{ => postgres}/parser/parse_oper.h | 0 .../{ => postgres}/parser/parse_relation.h | 0 .../{ => postgres}/parser/parse_type.h | 0 parser/include/{ => postgres}/parser/parser.h | 6 +- .../include/{ => postgres}/parser/parsetree.h | 0 .../include/{ => postgres}/parser/scanner.h | 0 .../include/{ => postgres}/parser/scansup.h | 0 .../{ => postgres}/partitioning/partdefs.h | 0 parser/include/{ => postgres}/pg_config.h | 138 +- parser/include/{ => postgres}/pg_config_ext.h | 0 .../include/{ => postgres}/pg_config_manual.h | 0 parser/include/postgres/pg_config_os.h | 8 + parser/include/{ => postgres}/pg_getopt.h | 0 parser/include/{ => postgres}/pg_trace.h | 0 parser/include/{ => postgres}/pgstat.h | 2 +- parser/include/{ => postgres}/pgtime.h | 0 parser/include/{ => postgres}/pl_gram.h | 4 +- .../{ => postgres}/pl_reserved_kwlist.h | 0 .../{ => postgres}/pl_reserved_kwlist_d.h | 0 .../{ => postgres}/pl_unreserved_kwlist.h | 0 .../{ => postgres}/pl_unreserved_kwlist_d.h | 0 parser/include/{ => postgres}/plerrcodes.h | 0 parser/include/{ => postgres}/plpgsql.h | 22 +- parser/include/{ => postgres}/port.h | 0 parser/include/{ => postgres}/port/atomics.h | 0 .../{ => postgres}/port/atomics/arch-arm.h | 0 .../include/postgres/port/atomics/arch-hppa.h | 17 + .../{ => postgres}/port/atomics/arch-ppc.h | 0 .../{ => postgres}/port/atomics/arch-x86.h | 0 .../{ => postgres}/port/atomics/fallback.h | 0 .../{ => postgres}/port/atomics/generic-gcc.h | 0 .../postgres/port/atomics/generic-msvc.h | 101 + .../postgres/port/atomics/generic-sunpro.h | 106 + .../{ => postgres}/port/atomics/generic.h | 0 .../include/{ => postgres}/port/pg_bitutils.h | 0 parser/include/{ => postgres}/port/pg_bswap.h | 0 .../include/{ => postgres}/port/pg_crc32c.h | 0 parser/include/{ => postgres}/port/simd.h | 0 parser/include/postgres/port/win32.h | 59 + .../include/postgres/port/win32/arpa/inet.h | 3 + parser/include/postgres/port/win32/dlfcn.h | 1 + parser/include/postgres/port/win32/grp.h | 1 + parser/include/postgres/port/win32/netdb.h | 7 + .../include/postgres/port/win32/netinet/in.h | 3 + .../include/postgres/port/win32/netinet/tcp.h | 7 + parser/include/postgres/port/win32/pwd.h | 3 + .../postgres/port/win32/sys/resource.h | 20 + .../include/postgres/port/win32/sys/select.h | 3 + .../include/postgres/port/win32/sys/socket.h | 26 + parser/include/postgres/port/win32/sys/un.h | 17 + parser/include/postgres/port/win32/sys/wait.h | 3 + .../include/postgres/port/win32_msvc/dirent.h | 34 + .../postgres/port/win32_msvc/sys/file.h | 1 + .../postgres/port/win32_msvc/sys/param.h | 1 + .../postgres/port/win32_msvc/sys/time.h | 1 + .../include/postgres/port/win32_msvc/unistd.h | 9 + .../include/postgres/port/win32_msvc/utime.h | 3 + parser/include/postgres/port/win32_port.h | 594 ++ .../{ => postgres}/portability/instr_time.h | 0 parser/include/{ => postgres}/postgres.h | 0 parser/include/{ => postgres}/postgres_ext.h | 0 .../{ => postgres}/postmaster/autovacuum.h | 0 .../{ => postgres}/postmaster/bgworker.h | 0 .../postmaster/bgworker_internals.h | 0 .../{ => postgres}/postmaster/bgwriter.h | 0 .../{ => postgres}/postmaster/interrupt.h | 0 .../{ => postgres}/postmaster/pgarch.h | 0 .../{ => postgres}/postmaster/postmaster.h | 2 +- .../{ => postgres}/postmaster/startup.h | 0 .../{ => postgres}/postmaster/syslogger.h | 0 .../{ => postgres}/postmaster/walwriter.h | 0 parser/include/{ => postgres}/regex/regex.h | 0 .../replication/logicallauncher.h | 0 .../{ => postgres}/replication/logicalproto.h | 0 .../replication/logicalworker.h | 0 .../{ => postgres}/replication/origin.h | 0 .../replication/reorderbuffer.h | 0 .../include/{ => postgres}/replication/slot.h | 0 .../{ => postgres}/replication/syncrep.h | 0 .../{ => postgres}/replication/walreceiver.h | 0 .../{ => postgres}/replication/walsender.h | 0 .../include/{ => postgres}/rewrite/prs2lock.h | 0 .../{ => postgres}/rewrite/rewriteHandler.h | 0 .../{ => postgres}/rewrite/rewriteManip.h | 0 .../{ => postgres}/rewrite/rewriteSupport.h | 0 .../{ => postgres}/storage/backendid.h | 0 parser/include/{ => postgres}/storage/block.h | 0 parser/include/{ => postgres}/storage/buf.h | 0 .../include/{ => postgres}/storage/bufmgr.h | 0 .../include/{ => postgres}/storage/bufpage.h | 0 .../storage/condition_variable.h | 0 parser/include/{ => postgres}/storage/dsm.h | 0 .../include/{ => postgres}/storage/dsm_impl.h | 0 parser/include/{ => postgres}/storage/fd.h | 0 .../include/{ => postgres}/storage/fileset.h | 0 parser/include/{ => postgres}/storage/ipc.h | 2 +- parser/include/{ => postgres}/storage/item.h | 0 .../include/{ => postgres}/storage/itemid.h | 0 .../include/{ => postgres}/storage/itemptr.h | 0 .../{ => postgres}/storage/large_object.h | 0 parser/include/{ => postgres}/storage/latch.h | 0 parser/include/{ => postgres}/storage/lmgr.h | 0 parser/include/{ => postgres}/storage/lock.h | 0 .../include/{ => postgres}/storage/lockdefs.h | 0 .../include/{ => postgres}/storage/lwlock.h | 0 .../{ => postgres}/storage/lwlocknames.h | 0 parser/include/{ => postgres}/storage/off.h | 0 .../include/{ => postgres}/storage/pg_sema.h | 0 .../include/{ => postgres}/storage/pg_shmem.h | 0 .../include/{ => postgres}/storage/pmsignal.h | 0 .../{ => postgres}/storage/predicate.h | 0 parser/include/{ => postgres}/storage/proc.h | 0 .../{ => postgres}/storage/procarray.h | 0 .../{ => postgres}/storage/proclist_types.h | 0 .../{ => postgres}/storage/procsignal.h | 0 .../{ => postgres}/storage/relfilelocator.h | 0 .../include/{ => postgres}/storage/s_lock.h | 0 .../{ => postgres}/storage/sharedfileset.h | 0 .../include/{ => postgres}/storage/shm_mq.h | 0 .../include/{ => postgres}/storage/shm_toc.h | 0 parser/include/{ => postgres}/storage/shmem.h | 0 .../include/{ => postgres}/storage/sinval.h | 0 .../{ => postgres}/storage/sinvaladt.h | 0 parser/include/{ => postgres}/storage/smgr.h | 0 parser/include/{ => postgres}/storage/spin.h | 0 .../include/{ => postgres}/storage/standby.h | 0 .../{ => postgres}/storage/standbydefs.h | 0 parser/include/{ => postgres}/storage/sync.h | 0 parser/include/{ => postgres}/tcop/cmdtag.h | 0 .../include/{ => postgres}/tcop/cmdtaglist.h | 0 .../{ => postgres}/tcop/deparse_utility.h | 0 parser/include/{ => postgres}/tcop/dest.h | 0 parser/include/{ => postgres}/tcop/fastpath.h | 0 parser/include/{ => postgres}/tcop/pquery.h | 0 parser/include/{ => postgres}/tcop/tcopprot.h | 4 +- parser/include/{ => postgres}/tcop/utility.h | 0 .../include/{ => postgres}/tsearch/ts_cache.h | 0 parser/include/{ => postgres}/utils/acl.h | 0 .../{ => postgres}/utils/aclchk_internal.h | 0 parser/include/{ => postgres}/utils/array.h | 0 .../{ => postgres}/utils/backend_progress.h | 0 .../{ => postgres}/utils/backend_status.h | 0 .../include/{ => postgres}/utils/builtins.h | 2 +- parser/include/{ => postgres}/utils/bytea.h | 0 .../include/{ => postgres}/utils/catcache.h | 0 parser/include/{ => postgres}/utils/date.h | 0 .../include/{ => postgres}/utils/datetime.h | 0 parser/include/{ => postgres}/utils/datum.h | 0 parser/include/{ => postgres}/utils/dsa.h | 0 parser/include/{ => postgres}/utils/elog.h | 6 +- .../include/{ => postgres}/utils/errcodes.h | 0 .../{ => postgres}/utils/expandeddatum.h | 0 .../{ => postgres}/utils/expandedrecord.h | 0 parser/include/{ => postgres}/utils/float.h | 0 .../include/{ => postgres}/utils/fmgroids.h | 0 .../include/{ => postgres}/utils/fmgrprotos.h | 0 parser/include/{ => postgres}/utils/fmgrtab.h | 0 parser/include/{ => postgres}/utils/guc.h | 8 +- .../include/{ => postgres}/utils/guc_hooks.h | 0 .../include/{ => postgres}/utils/guc_tables.h | 0 parser/include/{ => postgres}/utils/hsearch.h | 0 parser/include/{ => postgres}/utils/inval.h | 0 parser/include/{ => postgres}/utils/logtape.h | 0 .../include/{ => postgres}/utils/lsyscache.h | 0 .../include/{ => postgres}/utils/memdebug.h | 0 .../include/{ => postgres}/utils/memutils.h | 4 +- .../{ => postgres}/utils/memutils_internal.h | 0 .../utils/memutils_memorychunk.h | 0 parser/include/{ => postgres}/utils/numeric.h | 0 parser/include/{ => postgres}/utils/palloc.h | 2 +- .../include/{ => postgres}/utils/partcache.h | 0 .../include/{ => postgres}/utils/pg_locale.h | 0 .../{ => postgres}/utils/pgstat_internal.h | 0 .../include/{ => postgres}/utils/plancache.h | 0 parser/include/{ => postgres}/utils/portal.h | 0 parser/include/{ => postgres}/utils/probes.h | 0 .../include/{ => postgres}/utils/ps_status.h | 0 .../{ => postgres}/utils/queryenvironment.h | 0 parser/include/{ => postgres}/utils/regproc.h | 0 parser/include/{ => postgres}/utils/rel.h | 0 .../include/{ => postgres}/utils/relcache.h | 0 .../include/{ => postgres}/utils/reltrigger.h | 0 .../include/{ => postgres}/utils/resowner.h | 0 .../include/{ => postgres}/utils/ruleutils.h | 0 .../{ => postgres}/utils/sharedtuplestore.h | 0 parser/include/{ => postgres}/utils/snapmgr.h | 0 .../include/{ => postgres}/utils/snapshot.h | 0 .../{ => postgres}/utils/sortsupport.h | 0 .../include/{ => postgres}/utils/syscache.h | 0 parser/include/{ => postgres}/utils/timeout.h | 0 .../include/{ => postgres}/utils/timestamp.h | 0 .../include/{ => postgres}/utils/tuplesort.h | 0 .../include/{ => postgres}/utils/tuplestore.h | 0 .../include/{ => postgres}/utils/typcache.h | 0 parser/include/{ => postgres}/utils/varlena.h | 0 .../include/{ => postgres}/utils/wait_event.h | 0 parser/include/{ => postgres}/utils/xml.h | 0 parser/include/{ => postgres}/varatt.h | 0 parser/include/postmaster/auxprocess.h | 20 - parser/include/postmaster/fork_process.h | 17 - .../src_backend_nodes_copyfuncs.funcs.c | 5321 ----------------- .../src_backend_nodes_equalfuncs.funcs.c | 3354 ----------- parser/include/utils/pidfile.h | 56 - parser/parser.go | 3 +- parser/pg_query.c | 9 + parser/pg_query_fingerprint.c | 9 +- parser/pg_query_outfuncs_json.c | 6 + parser/pg_query_outfuncs_protobuf.c | 1 + parser/pg_query_parse.c | 2 +- parser/pg_query_parse_plpgsql.c | 9 +- parser/pg_query_readfuncs_protobuf.c | 1 + parser/pg_query_split.c | 2 +- parser/src_backend_nodes_nodes.c | 38 + parser/src_backend_postmaster_postmaster.c | 2220 ------- parser/src_backend_utils_error_elog.c | 169 +- parser/src_backend_utils_init_globals.c | 2 +- parser/src_backend_utils_mb_mbutils.c | 71 +- parser/src_backend_utils_misc_guc_tables.c | 2 - parser/src_port_pg_bitutils.c | 82 +- parser/src_port_snprintf.c | 6 +- parser/src_port_strlcpy.c | 79 + parser/src_port_strnlen.c | 39 - pg_query.go | 4 +- pg_query.pb.go | 6 +- 440 files changed, 1474 insertions(+), 11361 deletions(-) delete mode 100644 parser/guc-file.c delete mode 100644 parser/include/common/ip.h delete mode 100644 parser/include/pg_config_os.h rename parser/include/{ => postgres}/access/amapi.h (100%) rename parser/include/{ => postgres}/access/attmap.h (100%) rename parser/include/{ => postgres}/access/attnum.h (100%) rename parser/include/{ => postgres}/access/clog.h (100%) rename parser/include/{ => postgres}/access/commit_ts.h (100%) rename parser/include/{ => postgres}/access/detoast.h (100%) rename parser/include/{ => postgres}/access/genam.h (100%) rename parser/include/{ => postgres}/access/gin.h (100%) rename parser/include/{ => postgres}/access/htup.h (100%) rename parser/include/{ => postgres}/access/htup_details.h (100%) rename parser/include/{ => postgres}/access/itup.h (100%) rename parser/include/{ => postgres}/access/parallel.h (100%) rename parser/include/{ => postgres}/access/printtup.h (100%) rename parser/include/{ => postgres}/access/relation.h (100%) rename parser/include/{ => postgres}/access/relscan.h (100%) rename parser/include/{ => postgres}/access/rmgr.h (100%) rename parser/include/{ => postgres}/access/rmgrlist.h (100%) rename parser/include/{ => postgres}/access/sdir.h (100%) rename parser/include/{ => postgres}/access/skey.h (100%) rename parser/include/{ => postgres}/access/stratnum.h (100%) rename parser/include/{ => postgres}/access/sysattr.h (100%) rename parser/include/{ => postgres}/access/table.h (100%) rename parser/include/{ => postgres}/access/tableam.h (100%) rename parser/include/{ => postgres}/access/toast_compression.h (100%) rename parser/include/{ => postgres}/access/transam.h (100%) rename parser/include/{ => postgres}/access/tsmapi.h (100%) rename parser/include/{ => postgres}/access/tupconvert.h (100%) rename parser/include/{ => postgres}/access/tupdesc.h (100%) rename parser/include/{ => postgres}/access/tupmacs.h (100%) rename parser/include/{ => postgres}/access/twophase.h (100%) rename parser/include/{ => postgres}/access/xact.h (100%) rename parser/include/{ => postgres}/access/xlog.h (100%) rename parser/include/{ => postgres}/access/xlog_internal.h (100%) rename parser/include/{ => postgres}/access/xlogbackup.h (100%) rename parser/include/{ => postgres}/access/xlogdefs.h (100%) rename parser/include/{ => postgres}/access/xlogprefetcher.h (100%) rename parser/include/{ => postgres}/access/xlogreader.h (100%) rename parser/include/{ => postgres}/access/xlogrecord.h (100%) rename parser/include/{ => postgres}/access/xlogrecovery.h (100%) rename parser/include/{ => postgres}/archive/archive_module.h (100%) rename parser/include/{ => postgres}/c.h (100%) rename parser/include/{ => postgres}/catalog/catalog.h (100%) rename parser/include/{ => postgres}/catalog/catversion.h (100%) rename parser/include/{ => postgres}/catalog/dependency.h (100%) rename parser/include/{ => postgres}/catalog/genbki.h (100%) rename parser/include/{ => postgres}/catalog/index.h (100%) rename parser/include/{ => postgres}/catalog/indexing.h (100%) rename parser/include/{ => postgres}/catalog/namespace.h (100%) rename parser/include/{ => postgres}/catalog/objectaccess.h (100%) rename parser/include/{ => postgres}/catalog/objectaddress.h (100%) rename parser/include/{ => postgres}/catalog/pg_aggregate.h (100%) rename parser/include/{ => postgres}/catalog/pg_aggregate_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_am.h (100%) rename parser/include/{ => postgres}/catalog/pg_am_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_attribute.h (100%) rename parser/include/{ => postgres}/catalog/pg_attribute_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_authid.h (100%) rename parser/include/{ => postgres}/catalog/pg_authid_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_class.h (100%) rename parser/include/{ => postgres}/catalog/pg_class_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_collation.h (100%) rename parser/include/{ => postgres}/catalog/pg_collation_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_constraint.h (100%) rename parser/include/{ => postgres}/catalog/pg_constraint_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_control.h (100%) rename parser/include/{ => postgres}/catalog/pg_conversion.h (100%) rename parser/include/{ => postgres}/catalog/pg_conversion_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_database.h (100%) rename parser/include/{ => postgres}/catalog/pg_database_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_depend.h (100%) rename parser/include/{ => postgres}/catalog/pg_depend_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_event_trigger.h (100%) rename parser/include/{ => postgres}/catalog/pg_event_trigger_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_index.h (100%) rename parser/include/{ => postgres}/catalog/pg_index_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_language.h (100%) rename parser/include/{ => postgres}/catalog/pg_language_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_namespace.h (100%) rename parser/include/{ => postgres}/catalog/pg_namespace_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_opclass.h (100%) rename parser/include/{ => postgres}/catalog/pg_opclass_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_operator.h (100%) rename parser/include/{ => postgres}/catalog/pg_operator_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_opfamily.h (100%) rename parser/include/{ => postgres}/catalog/pg_opfamily_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_partitioned_table.h (100%) rename parser/include/{ => postgres}/catalog/pg_partitioned_table_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_proc.h (100%) rename parser/include/{ => postgres}/catalog/pg_proc_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_publication.h (100%) rename parser/include/{ => postgres}/catalog/pg_publication_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_replication_origin.h (100%) rename parser/include/{ => postgres}/catalog/pg_replication_origin_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_statistic.h (100%) rename parser/include/{ => postgres}/catalog/pg_statistic_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_statistic_ext.h (100%) rename parser/include/{ => postgres}/catalog/pg_statistic_ext_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_transform.h (100%) rename parser/include/{ => postgres}/catalog/pg_transform_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_trigger.h (100%) rename parser/include/{ => postgres}/catalog/pg_trigger_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_ts_config.h (100%) rename parser/include/{ => postgres}/catalog/pg_ts_config_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_ts_dict.h (100%) rename parser/include/{ => postgres}/catalog/pg_ts_dict_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_ts_parser.h (100%) rename parser/include/{ => postgres}/catalog/pg_ts_parser_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_ts_template.h (100%) rename parser/include/{ => postgres}/catalog/pg_ts_template_d.h (100%) rename parser/include/{ => postgres}/catalog/pg_type.h (100%) rename parser/include/{ => postgres}/catalog/pg_type_d.h (100%) rename parser/include/{ => postgres}/catalog/storage.h (100%) rename parser/include/{ => postgres}/commands/async.h (100%) rename parser/include/{ => postgres}/commands/dbcommands.h (100%) rename parser/include/{ => postgres}/commands/defrem.h (100%) rename parser/include/{ => postgres}/commands/event_trigger.h (100%) rename parser/include/{ => postgres}/commands/explain.h (100%) rename parser/include/{ => postgres}/commands/prepare.h (100%) rename parser/include/{ => postgres}/commands/tablespace.h (100%) rename parser/include/{ => postgres}/commands/trigger.h (100%) rename parser/include/{ => postgres}/commands/user.h (100%) rename parser/include/{ => postgres}/commands/vacuum.h (100%) rename parser/include/{ => postgres}/common/cryptohash.h (100%) rename parser/include/{ => postgres}/common/file_perm.h (100%) rename parser/include/{ => postgres}/common/hashfn.h (100%) rename parser/include/{ => postgres}/common/int.h (100%) rename parser/include/{ => postgres}/common/keywords.h (100%) rename parser/include/{ => postgres}/common/kwlookup.h (100%) rename parser/include/{ => postgres}/common/pg_prng.h (100%) rename parser/include/{ => postgres}/common/relpath.h (100%) rename parser/include/{ => postgres}/common/scram-common.h (100%) rename parser/include/{ => postgres}/common/sha2.h (100%) rename parser/include/{ => postgres}/common/string.h (100%) rename parser/include/{ => postgres}/common/unicode_east_asian_fw_table.h (100%) rename parser/include/{ => postgres}/common/unicode_nonspacing_table.h (100%) rename parser/include/{ => postgres}/copyfuncs.funcs.c (100%) rename parser/include/{ => postgres}/copyfuncs.switch.c (100%) rename parser/include/{ => postgres}/datatype/timestamp.h (100%) rename parser/include/{ => postgres}/equalfuncs.funcs.c (100%) rename parser/include/{ => postgres}/equalfuncs.switch.c (100%) rename parser/include/{ => postgres}/executor/execdesc.h (100%) rename parser/include/{ => postgres}/executor/executor.h (100%) rename parser/include/{ => postgres}/executor/functions.h (100%) rename parser/include/{ => postgres}/executor/instrument.h (100%) rename parser/include/{ => postgres}/executor/spi.h (100%) rename parser/include/{ => postgres}/executor/tablefunc.h (100%) rename parser/include/{ => postgres}/executor/tuptable.h (100%) rename parser/include/{ => postgres}/fmgr.h (100%) rename parser/include/{ => postgres}/foreign/fdwapi.h (100%) rename parser/include/{ => postgres}/funcapi.h (100%) rename parser/include/{ => postgres}/gram.h (100%) rename parser/include/{ => postgres}/gramparse.h (100%) rename parser/include/{ => postgres}/jit/jit.h (100%) rename parser/include/{ => postgres}/kwlist_d.h (100%) rename parser/include/{ => postgres}/lib/dshash.h (100%) rename parser/include/{ => postgres}/lib/ilist.h (100%) rename parser/include/{ => postgres}/lib/pairingheap.h (100%) rename parser/include/{ => postgres}/lib/simplehash.h (100%) rename parser/include/{ => postgres}/lib/sort_template.h (100%) rename parser/include/{ => postgres}/lib/stringinfo.h (100%) rename parser/include/{ => postgres}/libpq/auth.h (100%) rename parser/include/{ => postgres}/libpq/crypt.h (100%) rename parser/include/{ => postgres}/libpq/hba.h (100%) rename parser/include/{ => postgres}/libpq/libpq-be.h (100%) rename parser/include/{ => postgres}/libpq/libpq.h (100%) rename parser/include/{ => postgres}/libpq/pqcomm.h (100%) rename parser/include/{ => postgres}/libpq/pqformat.h (100%) rename parser/include/{ => postgres}/libpq/pqsignal.h (100%) rename parser/include/{ => postgres}/libpq/sasl.h (100%) rename parser/include/{ => postgres}/libpq/scram.h (100%) rename parser/include/{ => postgres}/mb/pg_wchar.h (100%) rename parser/include/{ => postgres}/mb/stringinfo_mb.h (100%) rename parser/include/{ => postgres}/miscadmin.h (99%) rename parser/include/{ => postgres}/nodes/bitmapset.h (100%) rename parser/include/{ => postgres}/nodes/execnodes.h (100%) rename parser/include/{ => postgres}/nodes/extensible.h (100%) rename parser/include/{ => postgres}/nodes/lockoptions.h (100%) rename parser/include/{ => postgres}/nodes/makefuncs.h (100%) rename parser/include/{ => postgres}/nodes/memnodes.h (100%) rename parser/include/{ => postgres}/nodes/miscnodes.h (100%) rename parser/include/{ => postgres}/nodes/nodeFuncs.h (100%) rename parser/include/{ => postgres}/nodes/nodes.h (99%) rename parser/include/{ => postgres}/nodes/nodetags.h (100%) rename parser/include/{ => postgres}/nodes/params.h (100%) rename parser/include/{ => postgres}/nodes/parsenodes.h (100%) rename parser/include/{ => postgres}/nodes/pathnodes.h (100%) rename parser/include/{ => postgres}/nodes/pg_list.h (100%) rename parser/include/{ => postgres}/nodes/plannodes.h (100%) rename parser/include/{ => postgres}/nodes/primnodes.h (100%) rename parser/include/{ => postgres}/nodes/print.h (100%) rename parser/include/{ => postgres}/nodes/queryjumble.h (100%) rename parser/include/{ => postgres}/nodes/replnodes.h (100%) rename parser/include/{ => postgres}/nodes/supportnodes.h (100%) rename parser/include/{ => postgres}/nodes/tidbitmap.h (100%) rename parser/include/{ => postgres}/nodes/value.h (100%) rename parser/include/{ => postgres}/optimizer/cost.h (100%) rename parser/include/{ => postgres}/optimizer/geqo.h (100%) rename parser/include/{ => postgres}/optimizer/geqo_gene.h (100%) rename parser/include/{ => postgres}/optimizer/optimizer.h (100%) rename parser/include/{ => postgres}/optimizer/paths.h (100%) rename parser/include/{ => postgres}/optimizer/planmain.h (100%) rename parser/include/{ => postgres}/parser/analyze.h (100%) rename parser/include/{ => postgres}/parser/kwlist.h (100%) rename parser/include/{ => postgres}/parser/parse_agg.h (100%) rename parser/include/{ => postgres}/parser/parse_coerce.h (100%) rename parser/include/{ => postgres}/parser/parse_expr.h (100%) rename parser/include/{ => postgres}/parser/parse_func.h (100%) rename parser/include/{ => postgres}/parser/parse_node.h (100%) rename parser/include/{ => postgres}/parser/parse_oper.h (100%) rename parser/include/{ => postgres}/parser/parse_relation.h (100%) rename parser/include/{ => postgres}/parser/parse_type.h (100%) rename parser/include/{ => postgres}/parser/parser.h (91%) rename parser/include/{ => postgres}/parser/parsetree.h (100%) rename parser/include/{ => postgres}/parser/scanner.h (100%) rename parser/include/{ => postgres}/parser/scansup.h (100%) rename parser/include/{ => postgres}/partitioning/partdefs.h (100%) rename parser/include/{ => postgres}/pg_config.h (87%) rename parser/include/{ => postgres}/pg_config_ext.h (100%) rename parser/include/{ => postgres}/pg_config_manual.h (100%) create mode 100644 parser/include/postgres/pg_config_os.h rename parser/include/{ => postgres}/pg_getopt.h (100%) rename parser/include/{ => postgres}/pg_trace.h (100%) rename parser/include/{ => postgres}/pgstat.h (99%) rename parser/include/{ => postgres}/pgtime.h (100%) rename parser/include/{ => postgres}/pl_gram.h (99%) rename parser/include/{ => postgres}/pl_reserved_kwlist.h (100%) rename parser/include/{ => postgres}/pl_reserved_kwlist_d.h (100%) rename parser/include/{ => postgres}/pl_unreserved_kwlist.h (100%) rename parser/include/{ => postgres}/pl_unreserved_kwlist_d.h (100%) rename parser/include/{ => postgres}/plerrcodes.h (100%) rename parser/include/{ => postgres}/plpgsql.h (98%) rename parser/include/{ => postgres}/port.h (100%) rename parser/include/{ => postgres}/port/atomics.h (100%) rename parser/include/{ => postgres}/port/atomics/arch-arm.h (100%) create mode 100644 parser/include/postgres/port/atomics/arch-hppa.h rename parser/include/{ => postgres}/port/atomics/arch-ppc.h (100%) rename parser/include/{ => postgres}/port/atomics/arch-x86.h (100%) rename parser/include/{ => postgres}/port/atomics/fallback.h (100%) rename parser/include/{ => postgres}/port/atomics/generic-gcc.h (100%) create mode 100644 parser/include/postgres/port/atomics/generic-msvc.h create mode 100644 parser/include/postgres/port/atomics/generic-sunpro.h rename parser/include/{ => postgres}/port/atomics/generic.h (100%) rename parser/include/{ => postgres}/port/pg_bitutils.h (100%) rename parser/include/{ => postgres}/port/pg_bswap.h (100%) rename parser/include/{ => postgres}/port/pg_crc32c.h (100%) rename parser/include/{ => postgres}/port/simd.h (100%) create mode 100644 parser/include/postgres/port/win32.h create mode 100644 parser/include/postgres/port/win32/arpa/inet.h create mode 100644 parser/include/postgres/port/win32/dlfcn.h create mode 100644 parser/include/postgres/port/win32/grp.h create mode 100644 parser/include/postgres/port/win32/netdb.h create mode 100644 parser/include/postgres/port/win32/netinet/in.h create mode 100644 parser/include/postgres/port/win32/netinet/tcp.h create mode 100644 parser/include/postgres/port/win32/pwd.h create mode 100644 parser/include/postgres/port/win32/sys/resource.h create mode 100644 parser/include/postgres/port/win32/sys/select.h create mode 100644 parser/include/postgres/port/win32/sys/socket.h create mode 100644 parser/include/postgres/port/win32/sys/un.h create mode 100644 parser/include/postgres/port/win32/sys/wait.h create mode 100644 parser/include/postgres/port/win32_msvc/dirent.h create mode 100644 parser/include/postgres/port/win32_msvc/sys/file.h create mode 100644 parser/include/postgres/port/win32_msvc/sys/param.h create mode 100644 parser/include/postgres/port/win32_msvc/sys/time.h create mode 100644 parser/include/postgres/port/win32_msvc/unistd.h create mode 100644 parser/include/postgres/port/win32_msvc/utime.h create mode 100644 parser/include/postgres/port/win32_port.h rename parser/include/{ => postgres}/portability/instr_time.h (100%) rename parser/include/{ => postgres}/postgres.h (100%) rename parser/include/{ => postgres}/postgres_ext.h (100%) rename parser/include/{ => postgres}/postmaster/autovacuum.h (100%) rename parser/include/{ => postgres}/postmaster/bgworker.h (100%) rename parser/include/{ => postgres}/postmaster/bgworker_internals.h (100%) rename parser/include/{ => postgres}/postmaster/bgwriter.h (100%) rename parser/include/{ => postgres}/postmaster/interrupt.h (100%) rename parser/include/{ => postgres}/postmaster/pgarch.h (100%) rename parser/include/{ => postgres}/postmaster/postmaster.h (98%) rename parser/include/{ => postgres}/postmaster/startup.h (100%) rename parser/include/{ => postgres}/postmaster/syslogger.h (100%) rename parser/include/{ => postgres}/postmaster/walwriter.h (100%) rename parser/include/{ => postgres}/regex/regex.h (100%) rename parser/include/{ => postgres}/replication/logicallauncher.h (100%) rename parser/include/{ => postgres}/replication/logicalproto.h (100%) rename parser/include/{ => postgres}/replication/logicalworker.h (100%) rename parser/include/{ => postgres}/replication/origin.h (100%) rename parser/include/{ => postgres}/replication/reorderbuffer.h (100%) rename parser/include/{ => postgres}/replication/slot.h (100%) rename parser/include/{ => postgres}/replication/syncrep.h (100%) rename parser/include/{ => postgres}/replication/walreceiver.h (100%) rename parser/include/{ => postgres}/replication/walsender.h (100%) rename parser/include/{ => postgres}/rewrite/prs2lock.h (100%) rename parser/include/{ => postgres}/rewrite/rewriteHandler.h (100%) rename parser/include/{ => postgres}/rewrite/rewriteManip.h (100%) rename parser/include/{ => postgres}/rewrite/rewriteSupport.h (100%) rename parser/include/{ => postgres}/storage/backendid.h (100%) rename parser/include/{ => postgres}/storage/block.h (100%) rename parser/include/{ => postgres}/storage/buf.h (100%) rename parser/include/{ => postgres}/storage/bufmgr.h (100%) rename parser/include/{ => postgres}/storage/bufpage.h (100%) rename parser/include/{ => postgres}/storage/condition_variable.h (100%) rename parser/include/{ => postgres}/storage/dsm.h (100%) rename parser/include/{ => postgres}/storage/dsm_impl.h (100%) rename parser/include/{ => postgres}/storage/fd.h (100%) rename parser/include/{ => postgres}/storage/fileset.h (100%) rename parser/include/{ => postgres}/storage/ipc.h (98%) rename parser/include/{ => postgres}/storage/item.h (100%) rename parser/include/{ => postgres}/storage/itemid.h (100%) rename parser/include/{ => postgres}/storage/itemptr.h (100%) rename parser/include/{ => postgres}/storage/large_object.h (100%) rename parser/include/{ => postgres}/storage/latch.h (100%) rename parser/include/{ => postgres}/storage/lmgr.h (100%) rename parser/include/{ => postgres}/storage/lock.h (100%) rename parser/include/{ => postgres}/storage/lockdefs.h (100%) rename parser/include/{ => postgres}/storage/lwlock.h (100%) rename parser/include/{ => postgres}/storage/lwlocknames.h (100%) rename parser/include/{ => postgres}/storage/off.h (100%) rename parser/include/{ => postgres}/storage/pg_sema.h (100%) rename parser/include/{ => postgres}/storage/pg_shmem.h (100%) rename parser/include/{ => postgres}/storage/pmsignal.h (100%) rename parser/include/{ => postgres}/storage/predicate.h (100%) rename parser/include/{ => postgres}/storage/proc.h (100%) rename parser/include/{ => postgres}/storage/procarray.h (100%) rename parser/include/{ => postgres}/storage/proclist_types.h (100%) rename parser/include/{ => postgres}/storage/procsignal.h (100%) rename parser/include/{ => postgres}/storage/relfilelocator.h (100%) rename parser/include/{ => postgres}/storage/s_lock.h (100%) rename parser/include/{ => postgres}/storage/sharedfileset.h (100%) rename parser/include/{ => postgres}/storage/shm_mq.h (100%) rename parser/include/{ => postgres}/storage/shm_toc.h (100%) rename parser/include/{ => postgres}/storage/shmem.h (100%) rename parser/include/{ => postgres}/storage/sinval.h (100%) rename parser/include/{ => postgres}/storage/sinvaladt.h (100%) rename parser/include/{ => postgres}/storage/smgr.h (100%) rename parser/include/{ => postgres}/storage/spin.h (100%) rename parser/include/{ => postgres}/storage/standby.h (100%) rename parser/include/{ => postgres}/storage/standbydefs.h (100%) rename parser/include/{ => postgres}/storage/sync.h (100%) rename parser/include/{ => postgres}/tcop/cmdtag.h (100%) rename parser/include/{ => postgres}/tcop/cmdtaglist.h (100%) rename parser/include/{ => postgres}/tcop/deparse_utility.h (100%) rename parser/include/{ => postgres}/tcop/dest.h (100%) rename parser/include/{ => postgres}/tcop/fastpath.h (100%) rename parser/include/{ => postgres}/tcop/pquery.h (100%) rename parser/include/{ => postgres}/tcop/tcopprot.h (96%) rename parser/include/{ => postgres}/tcop/utility.h (100%) rename parser/include/{ => postgres}/tsearch/ts_cache.h (100%) rename parser/include/{ => postgres}/utils/acl.h (100%) rename parser/include/{ => postgres}/utils/aclchk_internal.h (100%) rename parser/include/{ => postgres}/utils/array.h (100%) rename parser/include/{ => postgres}/utils/backend_progress.h (100%) rename parser/include/{ => postgres}/utils/backend_status.h (100%) rename parser/include/{ => postgres}/utils/builtins.h (98%) rename parser/include/{ => postgres}/utils/bytea.h (100%) rename parser/include/{ => postgres}/utils/catcache.h (100%) rename parser/include/{ => postgres}/utils/date.h (100%) rename parser/include/{ => postgres}/utils/datetime.h (100%) rename parser/include/{ => postgres}/utils/datum.h (100%) rename parser/include/{ => postgres}/utils/dsa.h (100%) rename parser/include/{ => postgres}/utils/elog.h (99%) rename parser/include/{ => postgres}/utils/errcodes.h (100%) rename parser/include/{ => postgres}/utils/expandeddatum.h (100%) rename parser/include/{ => postgres}/utils/expandedrecord.h (100%) rename parser/include/{ => postgres}/utils/float.h (100%) rename parser/include/{ => postgres}/utils/fmgroids.h (100%) rename parser/include/{ => postgres}/utils/fmgrprotos.h (100%) rename parser/include/{ => postgres}/utils/fmgrtab.h (100%) rename parser/include/{ => postgres}/utils/guc.h (98%) rename parser/include/{ => postgres}/utils/guc_hooks.h (100%) rename parser/include/{ => postgres}/utils/guc_tables.h (100%) rename parser/include/{ => postgres}/utils/hsearch.h (100%) rename parser/include/{ => postgres}/utils/inval.h (100%) rename parser/include/{ => postgres}/utils/logtape.h (100%) rename parser/include/{ => postgres}/utils/lsyscache.h (100%) rename parser/include/{ => postgres}/utils/memdebug.h (100%) rename parser/include/{ => postgres}/utils/memutils.h (98%) rename parser/include/{ => postgres}/utils/memutils_internal.h (100%) rename parser/include/{ => postgres}/utils/memutils_memorychunk.h (100%) rename parser/include/{ => postgres}/utils/numeric.h (100%) rename parser/include/{ => postgres}/utils/palloc.h (98%) rename parser/include/{ => postgres}/utils/partcache.h (100%) rename parser/include/{ => postgres}/utils/pg_locale.h (100%) rename parser/include/{ => postgres}/utils/pgstat_internal.h (100%) rename parser/include/{ => postgres}/utils/plancache.h (100%) rename parser/include/{ => postgres}/utils/portal.h (100%) rename parser/include/{ => postgres}/utils/probes.h (100%) rename parser/include/{ => postgres}/utils/ps_status.h (100%) rename parser/include/{ => postgres}/utils/queryenvironment.h (100%) rename parser/include/{ => postgres}/utils/regproc.h (100%) rename parser/include/{ => postgres}/utils/rel.h (100%) rename parser/include/{ => postgres}/utils/relcache.h (100%) rename parser/include/{ => postgres}/utils/reltrigger.h (100%) rename parser/include/{ => postgres}/utils/resowner.h (100%) rename parser/include/{ => postgres}/utils/ruleutils.h (100%) rename parser/include/{ => postgres}/utils/sharedtuplestore.h (100%) rename parser/include/{ => postgres}/utils/snapmgr.h (100%) rename parser/include/{ => postgres}/utils/snapshot.h (100%) rename parser/include/{ => postgres}/utils/sortsupport.h (100%) rename parser/include/{ => postgres}/utils/syscache.h (100%) rename parser/include/{ => postgres}/utils/timeout.h (100%) rename parser/include/{ => postgres}/utils/timestamp.h (100%) rename parser/include/{ => postgres}/utils/tuplesort.h (100%) rename parser/include/{ => postgres}/utils/tuplestore.h (100%) rename parser/include/{ => postgres}/utils/typcache.h (100%) rename parser/include/{ => postgres}/utils/varlena.h (100%) rename parser/include/{ => postgres}/utils/wait_event.h (100%) rename parser/include/{ => postgres}/utils/xml.h (100%) rename parser/include/{ => postgres}/varatt.h (100%) delete mode 100644 parser/include/postmaster/auxprocess.h delete mode 100644 parser/include/postmaster/fork_process.h delete mode 100644 parser/include/src_backend_nodes_copyfuncs.funcs.c delete mode 100644 parser/include/src_backend_nodes_equalfuncs.funcs.c delete mode 100644 parser/include/utils/pidfile.h create mode 100644 parser/src_backend_nodes_nodes.c delete mode 100644 parser/src_backend_postmaster_postmaster.c create mode 100644 parser/src_port_strlcpy.c delete mode 100644 parser/src_port_strnlen.c diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f26c5ee7..2057ae0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,20 +1,21 @@ name: CI - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - +on: [push, pull_request] jobs: build: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + go: ['1.20', '1.21'] + os: ['ubuntu-latest', 'windows-latest'] + include: + go: 1.16 # Oldest Go version still tested (Windows requires 1.20+ due to https://github.com/golang/go/issues/57455) + os: ubuntu-latest + runs-on: ${{ matrix.os }} steps: - name: Set up Go 1.x uses: actions/setup-go@v4 with: - go-version: 1.16 - id: go + go-version: ${{ matrix.go }} - name: Check out code uses: actions/checkout@v3 - name: Runs tests diff --git a/Makefile b/Makefile index 4cec87cb..e3669639 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ benchmark: # --- Below only needed for releasing new versions -LIB_PG_QUERY_TAG = 16-5.0.0 +LIB_PG_QUERY_TAG = win root_dir := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) LIB_TMPDIR = $(root_dir)/tmp @@ -36,12 +36,11 @@ update_source: $(LIBDIR) rm -fr parser/include # Reduce everything down to one directory cp -a $(LIBDIR)/src/* parser/ + mv parser/postgres/include parser/include/postgres rm parser/pg_query_outfuncs_protobuf_cpp.cc mv parser/postgres/* parser/ rmdir parser/postgres cp -a $(LIBDIR)/pg_query.h parser/include - # Make sure every .c in the top-level directory is its own translation unit - mv parser/*{_conds,_defs,_helper,.funcs}.c parser/include # Protobuf definitions mkdir -p $(PWD)/bin GOBIN=$(PWD)/bin go install google.golang.org/protobuf/cmd/protoc-gen-go diff --git a/parser/guc-file.c b/parser/guc-file.c deleted file mode 100644 index e69de29b..00000000 diff --git a/parser/include/common/ip.h b/parser/include/common/ip.h deleted file mode 100644 index 9f2ed5fe..00000000 --- a/parser/include/common/ip.h +++ /dev/null @@ -1,33 +0,0 @@ -/*------------------------------------------------------------------------- - * - * ip.h - * Definitions for IPv6-aware network access. - * - * These definitions are used by both frontend and backend code. - * - * Copyright (c) 2003-2023, PostgreSQL Global Development Group - * - * src/include/common/ip.h - * - *------------------------------------------------------------------------- - */ -#ifndef IP_H -#define IP_H - -#include -#include - -#include "libpq/pqcomm.h" /* pgrminclude ignore */ - - -extern int pg_getaddrinfo_all(const char *hostname, const char *servname, - const struct addrinfo *hintp, - struct addrinfo **result); -extern void pg_freeaddrinfo_all(int hint_ai_family, struct addrinfo *ai); - -extern int pg_getnameinfo_all(const struct sockaddr_storage *addr, int salen, - char *node, int nodelen, - char *service, int servicelen, - int flags); - -#endif /* IP_H */ diff --git a/parser/include/pg_config_os.h b/parser/include/pg_config_os.h deleted file mode 100644 index 15fb69d6..00000000 --- a/parser/include/pg_config_os.h +++ /dev/null @@ -1,8 +0,0 @@ -/* src/include/port/darwin.h */ - -#define __darwin__ 1 - -#if HAVE_DECL_F_FULLFSYNC /* not present before macOS 10.3 */ -#define HAVE_FSYNC_WRITETHROUGH - -#endif diff --git a/parser/include/pg_query_fingerprint_defs.c b/parser/include/pg_query_fingerprint_defs.c index 0837af60..77b0155e 100644 --- a/parser/include/pg_query_fingerprint_defs.c +++ b/parser/include/pg_query_fingerprint_defs.c @@ -5894,7 +5894,7 @@ _fingerprintRTEPermissionInfo(FingerprintContext *ctx, const RTEPermissionInfo * if (node->requiredPerms != 0) { char buffer[50]; - sprintf(buffer, "%ld", node->requiredPerms); + sprintf(buffer, UINT64_FORMAT, node->requiredPerms); _fingerprintString(ctx, "requiredPerms"); _fingerprintString(ctx, buffer); } diff --git a/parser/include/pg_query_outfuncs_defs.c b/parser/include/pg_query_outfuncs_defs.c index 6e88bc20..57522fe6 100644 --- a/parser/include/pg_query_outfuncs_defs.c +++ b/parser/include/pg_query_outfuncs_defs.c @@ -1240,7 +1240,7 @@ _outRTEPermissionInfo(OUT_TYPE(RTEPermissionInfo, RTEPermissionInfo) out, const { WRITE_UINT_FIELD(relid, relid, relid); WRITE_BOOL_FIELD(inh, inh, inh); - WRITE_LONG_FIELD(required_perms, requiredPerms, requiredPerms); + WRITE_UINT64_FIELD(required_perms, requiredPerms, requiredPerms); WRITE_UINT_FIELD(check_as_user, checkAsUser, checkAsUser); WRITE_BITMAPSET_FIELD(selected_cols, selectedCols, selectedCols); WRITE_BITMAPSET_FIELD(inserted_cols, insertedCols, insertedCols); diff --git a/parser/include/pg_query_readfuncs_defs.c b/parser/include/pg_query_readfuncs_defs.c index 3b163760..60aa21dc 100644 --- a/parser/include/pg_query_readfuncs_defs.c +++ b/parser/include/pg_query_readfuncs_defs.c @@ -1419,7 +1419,7 @@ _readRTEPermissionInfo(OUT_TYPE(RTEPermissionInfo, RTEPermissionInfo) msg) RTEPermissionInfo *node = makeNode(RTEPermissionInfo); READ_UINT_FIELD(relid, relid, relid); READ_BOOL_FIELD(inh, inh, inh); - READ_LONG_FIELD(required_perms, requiredPerms, requiredPerms); + READ_UINT64_FIELD(required_perms, requiredPerms, requiredPerms); READ_UINT_FIELD(check_as_user, checkAsUser, checkAsUser); READ_BITMAPSET_FIELD(selected_cols, selectedCols, selectedCols); READ_BITMAPSET_FIELD(inserted_cols, insertedCols, insertedCols); diff --git a/parser/include/access/amapi.h b/parser/include/postgres/access/amapi.h similarity index 100% rename from parser/include/access/amapi.h rename to parser/include/postgres/access/amapi.h diff --git a/parser/include/access/attmap.h b/parser/include/postgres/access/attmap.h similarity index 100% rename from parser/include/access/attmap.h rename to parser/include/postgres/access/attmap.h diff --git a/parser/include/access/attnum.h b/parser/include/postgres/access/attnum.h similarity index 100% rename from parser/include/access/attnum.h rename to parser/include/postgres/access/attnum.h diff --git a/parser/include/access/clog.h b/parser/include/postgres/access/clog.h similarity index 100% rename from parser/include/access/clog.h rename to parser/include/postgres/access/clog.h diff --git a/parser/include/access/commit_ts.h b/parser/include/postgres/access/commit_ts.h similarity index 100% rename from parser/include/access/commit_ts.h rename to parser/include/postgres/access/commit_ts.h diff --git a/parser/include/access/detoast.h b/parser/include/postgres/access/detoast.h similarity index 100% rename from parser/include/access/detoast.h rename to parser/include/postgres/access/detoast.h diff --git a/parser/include/access/genam.h b/parser/include/postgres/access/genam.h similarity index 100% rename from parser/include/access/genam.h rename to parser/include/postgres/access/genam.h diff --git a/parser/include/access/gin.h b/parser/include/postgres/access/gin.h similarity index 100% rename from parser/include/access/gin.h rename to parser/include/postgres/access/gin.h diff --git a/parser/include/access/htup.h b/parser/include/postgres/access/htup.h similarity index 100% rename from parser/include/access/htup.h rename to parser/include/postgres/access/htup.h diff --git a/parser/include/access/htup_details.h b/parser/include/postgres/access/htup_details.h similarity index 100% rename from parser/include/access/htup_details.h rename to parser/include/postgres/access/htup_details.h diff --git a/parser/include/access/itup.h b/parser/include/postgres/access/itup.h similarity index 100% rename from parser/include/access/itup.h rename to parser/include/postgres/access/itup.h diff --git a/parser/include/access/parallel.h b/parser/include/postgres/access/parallel.h similarity index 100% rename from parser/include/access/parallel.h rename to parser/include/postgres/access/parallel.h diff --git a/parser/include/access/printtup.h b/parser/include/postgres/access/printtup.h similarity index 100% rename from parser/include/access/printtup.h rename to parser/include/postgres/access/printtup.h diff --git a/parser/include/access/relation.h b/parser/include/postgres/access/relation.h similarity index 100% rename from parser/include/access/relation.h rename to parser/include/postgres/access/relation.h diff --git a/parser/include/access/relscan.h b/parser/include/postgres/access/relscan.h similarity index 100% rename from parser/include/access/relscan.h rename to parser/include/postgres/access/relscan.h diff --git a/parser/include/access/rmgr.h b/parser/include/postgres/access/rmgr.h similarity index 100% rename from parser/include/access/rmgr.h rename to parser/include/postgres/access/rmgr.h diff --git a/parser/include/access/rmgrlist.h b/parser/include/postgres/access/rmgrlist.h similarity index 100% rename from parser/include/access/rmgrlist.h rename to parser/include/postgres/access/rmgrlist.h diff --git a/parser/include/access/sdir.h b/parser/include/postgres/access/sdir.h similarity index 100% rename from parser/include/access/sdir.h rename to parser/include/postgres/access/sdir.h diff --git a/parser/include/access/skey.h b/parser/include/postgres/access/skey.h similarity index 100% rename from parser/include/access/skey.h rename to parser/include/postgres/access/skey.h diff --git a/parser/include/access/stratnum.h b/parser/include/postgres/access/stratnum.h similarity index 100% rename from parser/include/access/stratnum.h rename to parser/include/postgres/access/stratnum.h diff --git a/parser/include/access/sysattr.h b/parser/include/postgres/access/sysattr.h similarity index 100% rename from parser/include/access/sysattr.h rename to parser/include/postgres/access/sysattr.h diff --git a/parser/include/access/table.h b/parser/include/postgres/access/table.h similarity index 100% rename from parser/include/access/table.h rename to parser/include/postgres/access/table.h diff --git a/parser/include/access/tableam.h b/parser/include/postgres/access/tableam.h similarity index 100% rename from parser/include/access/tableam.h rename to parser/include/postgres/access/tableam.h diff --git a/parser/include/access/toast_compression.h b/parser/include/postgres/access/toast_compression.h similarity index 100% rename from parser/include/access/toast_compression.h rename to parser/include/postgres/access/toast_compression.h diff --git a/parser/include/access/transam.h b/parser/include/postgres/access/transam.h similarity index 100% rename from parser/include/access/transam.h rename to parser/include/postgres/access/transam.h diff --git a/parser/include/access/tsmapi.h b/parser/include/postgres/access/tsmapi.h similarity index 100% rename from parser/include/access/tsmapi.h rename to parser/include/postgres/access/tsmapi.h diff --git a/parser/include/access/tupconvert.h b/parser/include/postgres/access/tupconvert.h similarity index 100% rename from parser/include/access/tupconvert.h rename to parser/include/postgres/access/tupconvert.h diff --git a/parser/include/access/tupdesc.h b/parser/include/postgres/access/tupdesc.h similarity index 100% rename from parser/include/access/tupdesc.h rename to parser/include/postgres/access/tupdesc.h diff --git a/parser/include/access/tupmacs.h b/parser/include/postgres/access/tupmacs.h similarity index 100% rename from parser/include/access/tupmacs.h rename to parser/include/postgres/access/tupmacs.h diff --git a/parser/include/access/twophase.h b/parser/include/postgres/access/twophase.h similarity index 100% rename from parser/include/access/twophase.h rename to parser/include/postgres/access/twophase.h diff --git a/parser/include/access/xact.h b/parser/include/postgres/access/xact.h similarity index 100% rename from parser/include/access/xact.h rename to parser/include/postgres/access/xact.h diff --git a/parser/include/access/xlog.h b/parser/include/postgres/access/xlog.h similarity index 100% rename from parser/include/access/xlog.h rename to parser/include/postgres/access/xlog.h diff --git a/parser/include/access/xlog_internal.h b/parser/include/postgres/access/xlog_internal.h similarity index 100% rename from parser/include/access/xlog_internal.h rename to parser/include/postgres/access/xlog_internal.h diff --git a/parser/include/access/xlogbackup.h b/parser/include/postgres/access/xlogbackup.h similarity index 100% rename from parser/include/access/xlogbackup.h rename to parser/include/postgres/access/xlogbackup.h diff --git a/parser/include/access/xlogdefs.h b/parser/include/postgres/access/xlogdefs.h similarity index 100% rename from parser/include/access/xlogdefs.h rename to parser/include/postgres/access/xlogdefs.h diff --git a/parser/include/access/xlogprefetcher.h b/parser/include/postgres/access/xlogprefetcher.h similarity index 100% rename from parser/include/access/xlogprefetcher.h rename to parser/include/postgres/access/xlogprefetcher.h diff --git a/parser/include/access/xlogreader.h b/parser/include/postgres/access/xlogreader.h similarity index 100% rename from parser/include/access/xlogreader.h rename to parser/include/postgres/access/xlogreader.h diff --git a/parser/include/access/xlogrecord.h b/parser/include/postgres/access/xlogrecord.h similarity index 100% rename from parser/include/access/xlogrecord.h rename to parser/include/postgres/access/xlogrecord.h diff --git a/parser/include/access/xlogrecovery.h b/parser/include/postgres/access/xlogrecovery.h similarity index 100% rename from parser/include/access/xlogrecovery.h rename to parser/include/postgres/access/xlogrecovery.h diff --git a/parser/include/archive/archive_module.h b/parser/include/postgres/archive/archive_module.h similarity index 100% rename from parser/include/archive/archive_module.h rename to parser/include/postgres/archive/archive_module.h diff --git a/parser/include/c.h b/parser/include/postgres/c.h similarity index 100% rename from parser/include/c.h rename to parser/include/postgres/c.h diff --git a/parser/include/catalog/catalog.h b/parser/include/postgres/catalog/catalog.h similarity index 100% rename from parser/include/catalog/catalog.h rename to parser/include/postgres/catalog/catalog.h diff --git a/parser/include/catalog/catversion.h b/parser/include/postgres/catalog/catversion.h similarity index 100% rename from parser/include/catalog/catversion.h rename to parser/include/postgres/catalog/catversion.h diff --git a/parser/include/catalog/dependency.h b/parser/include/postgres/catalog/dependency.h similarity index 100% rename from parser/include/catalog/dependency.h rename to parser/include/postgres/catalog/dependency.h diff --git a/parser/include/catalog/genbki.h b/parser/include/postgres/catalog/genbki.h similarity index 100% rename from parser/include/catalog/genbki.h rename to parser/include/postgres/catalog/genbki.h diff --git a/parser/include/catalog/index.h b/parser/include/postgres/catalog/index.h similarity index 100% rename from parser/include/catalog/index.h rename to parser/include/postgres/catalog/index.h diff --git a/parser/include/catalog/indexing.h b/parser/include/postgres/catalog/indexing.h similarity index 100% rename from parser/include/catalog/indexing.h rename to parser/include/postgres/catalog/indexing.h diff --git a/parser/include/catalog/namespace.h b/parser/include/postgres/catalog/namespace.h similarity index 100% rename from parser/include/catalog/namespace.h rename to parser/include/postgres/catalog/namespace.h diff --git a/parser/include/catalog/objectaccess.h b/parser/include/postgres/catalog/objectaccess.h similarity index 100% rename from parser/include/catalog/objectaccess.h rename to parser/include/postgres/catalog/objectaccess.h diff --git a/parser/include/catalog/objectaddress.h b/parser/include/postgres/catalog/objectaddress.h similarity index 100% rename from parser/include/catalog/objectaddress.h rename to parser/include/postgres/catalog/objectaddress.h diff --git a/parser/include/catalog/pg_aggregate.h b/parser/include/postgres/catalog/pg_aggregate.h similarity index 100% rename from parser/include/catalog/pg_aggregate.h rename to parser/include/postgres/catalog/pg_aggregate.h diff --git a/parser/include/catalog/pg_aggregate_d.h b/parser/include/postgres/catalog/pg_aggregate_d.h similarity index 100% rename from parser/include/catalog/pg_aggregate_d.h rename to parser/include/postgres/catalog/pg_aggregate_d.h diff --git a/parser/include/catalog/pg_am.h b/parser/include/postgres/catalog/pg_am.h similarity index 100% rename from parser/include/catalog/pg_am.h rename to parser/include/postgres/catalog/pg_am.h diff --git a/parser/include/catalog/pg_am_d.h b/parser/include/postgres/catalog/pg_am_d.h similarity index 100% rename from parser/include/catalog/pg_am_d.h rename to parser/include/postgres/catalog/pg_am_d.h diff --git a/parser/include/catalog/pg_attribute.h b/parser/include/postgres/catalog/pg_attribute.h similarity index 100% rename from parser/include/catalog/pg_attribute.h rename to parser/include/postgres/catalog/pg_attribute.h diff --git a/parser/include/catalog/pg_attribute_d.h b/parser/include/postgres/catalog/pg_attribute_d.h similarity index 100% rename from parser/include/catalog/pg_attribute_d.h rename to parser/include/postgres/catalog/pg_attribute_d.h diff --git a/parser/include/catalog/pg_authid.h b/parser/include/postgres/catalog/pg_authid.h similarity index 100% rename from parser/include/catalog/pg_authid.h rename to parser/include/postgres/catalog/pg_authid.h diff --git a/parser/include/catalog/pg_authid_d.h b/parser/include/postgres/catalog/pg_authid_d.h similarity index 100% rename from parser/include/catalog/pg_authid_d.h rename to parser/include/postgres/catalog/pg_authid_d.h diff --git a/parser/include/catalog/pg_class.h b/parser/include/postgres/catalog/pg_class.h similarity index 100% rename from parser/include/catalog/pg_class.h rename to parser/include/postgres/catalog/pg_class.h diff --git a/parser/include/catalog/pg_class_d.h b/parser/include/postgres/catalog/pg_class_d.h similarity index 100% rename from parser/include/catalog/pg_class_d.h rename to parser/include/postgres/catalog/pg_class_d.h diff --git a/parser/include/catalog/pg_collation.h b/parser/include/postgres/catalog/pg_collation.h similarity index 100% rename from parser/include/catalog/pg_collation.h rename to parser/include/postgres/catalog/pg_collation.h diff --git a/parser/include/catalog/pg_collation_d.h b/parser/include/postgres/catalog/pg_collation_d.h similarity index 100% rename from parser/include/catalog/pg_collation_d.h rename to parser/include/postgres/catalog/pg_collation_d.h diff --git a/parser/include/catalog/pg_constraint.h b/parser/include/postgres/catalog/pg_constraint.h similarity index 100% rename from parser/include/catalog/pg_constraint.h rename to parser/include/postgres/catalog/pg_constraint.h diff --git a/parser/include/catalog/pg_constraint_d.h b/parser/include/postgres/catalog/pg_constraint_d.h similarity index 100% rename from parser/include/catalog/pg_constraint_d.h rename to parser/include/postgres/catalog/pg_constraint_d.h diff --git a/parser/include/catalog/pg_control.h b/parser/include/postgres/catalog/pg_control.h similarity index 100% rename from parser/include/catalog/pg_control.h rename to parser/include/postgres/catalog/pg_control.h diff --git a/parser/include/catalog/pg_conversion.h b/parser/include/postgres/catalog/pg_conversion.h similarity index 100% rename from parser/include/catalog/pg_conversion.h rename to parser/include/postgres/catalog/pg_conversion.h diff --git a/parser/include/catalog/pg_conversion_d.h b/parser/include/postgres/catalog/pg_conversion_d.h similarity index 100% rename from parser/include/catalog/pg_conversion_d.h rename to parser/include/postgres/catalog/pg_conversion_d.h diff --git a/parser/include/catalog/pg_database.h b/parser/include/postgres/catalog/pg_database.h similarity index 100% rename from parser/include/catalog/pg_database.h rename to parser/include/postgres/catalog/pg_database.h diff --git a/parser/include/catalog/pg_database_d.h b/parser/include/postgres/catalog/pg_database_d.h similarity index 100% rename from parser/include/catalog/pg_database_d.h rename to parser/include/postgres/catalog/pg_database_d.h diff --git a/parser/include/catalog/pg_depend.h b/parser/include/postgres/catalog/pg_depend.h similarity index 100% rename from parser/include/catalog/pg_depend.h rename to parser/include/postgres/catalog/pg_depend.h diff --git a/parser/include/catalog/pg_depend_d.h b/parser/include/postgres/catalog/pg_depend_d.h similarity index 100% rename from parser/include/catalog/pg_depend_d.h rename to parser/include/postgres/catalog/pg_depend_d.h diff --git a/parser/include/catalog/pg_event_trigger.h b/parser/include/postgres/catalog/pg_event_trigger.h similarity index 100% rename from parser/include/catalog/pg_event_trigger.h rename to parser/include/postgres/catalog/pg_event_trigger.h diff --git a/parser/include/catalog/pg_event_trigger_d.h b/parser/include/postgres/catalog/pg_event_trigger_d.h similarity index 100% rename from parser/include/catalog/pg_event_trigger_d.h rename to parser/include/postgres/catalog/pg_event_trigger_d.h diff --git a/parser/include/catalog/pg_index.h b/parser/include/postgres/catalog/pg_index.h similarity index 100% rename from parser/include/catalog/pg_index.h rename to parser/include/postgres/catalog/pg_index.h diff --git a/parser/include/catalog/pg_index_d.h b/parser/include/postgres/catalog/pg_index_d.h similarity index 100% rename from parser/include/catalog/pg_index_d.h rename to parser/include/postgres/catalog/pg_index_d.h diff --git a/parser/include/catalog/pg_language.h b/parser/include/postgres/catalog/pg_language.h similarity index 100% rename from parser/include/catalog/pg_language.h rename to parser/include/postgres/catalog/pg_language.h diff --git a/parser/include/catalog/pg_language_d.h b/parser/include/postgres/catalog/pg_language_d.h similarity index 100% rename from parser/include/catalog/pg_language_d.h rename to parser/include/postgres/catalog/pg_language_d.h diff --git a/parser/include/catalog/pg_namespace.h b/parser/include/postgres/catalog/pg_namespace.h similarity index 100% rename from parser/include/catalog/pg_namespace.h rename to parser/include/postgres/catalog/pg_namespace.h diff --git a/parser/include/catalog/pg_namespace_d.h b/parser/include/postgres/catalog/pg_namespace_d.h similarity index 100% rename from parser/include/catalog/pg_namespace_d.h rename to parser/include/postgres/catalog/pg_namespace_d.h diff --git a/parser/include/catalog/pg_opclass.h b/parser/include/postgres/catalog/pg_opclass.h similarity index 100% rename from parser/include/catalog/pg_opclass.h rename to parser/include/postgres/catalog/pg_opclass.h diff --git a/parser/include/catalog/pg_opclass_d.h b/parser/include/postgres/catalog/pg_opclass_d.h similarity index 100% rename from parser/include/catalog/pg_opclass_d.h rename to parser/include/postgres/catalog/pg_opclass_d.h diff --git a/parser/include/catalog/pg_operator.h b/parser/include/postgres/catalog/pg_operator.h similarity index 100% rename from parser/include/catalog/pg_operator.h rename to parser/include/postgres/catalog/pg_operator.h diff --git a/parser/include/catalog/pg_operator_d.h b/parser/include/postgres/catalog/pg_operator_d.h similarity index 100% rename from parser/include/catalog/pg_operator_d.h rename to parser/include/postgres/catalog/pg_operator_d.h diff --git a/parser/include/catalog/pg_opfamily.h b/parser/include/postgres/catalog/pg_opfamily.h similarity index 100% rename from parser/include/catalog/pg_opfamily.h rename to parser/include/postgres/catalog/pg_opfamily.h diff --git a/parser/include/catalog/pg_opfamily_d.h b/parser/include/postgres/catalog/pg_opfamily_d.h similarity index 100% rename from parser/include/catalog/pg_opfamily_d.h rename to parser/include/postgres/catalog/pg_opfamily_d.h diff --git a/parser/include/catalog/pg_partitioned_table.h b/parser/include/postgres/catalog/pg_partitioned_table.h similarity index 100% rename from parser/include/catalog/pg_partitioned_table.h rename to parser/include/postgres/catalog/pg_partitioned_table.h diff --git a/parser/include/catalog/pg_partitioned_table_d.h b/parser/include/postgres/catalog/pg_partitioned_table_d.h similarity index 100% rename from parser/include/catalog/pg_partitioned_table_d.h rename to parser/include/postgres/catalog/pg_partitioned_table_d.h diff --git a/parser/include/catalog/pg_proc.h b/parser/include/postgres/catalog/pg_proc.h similarity index 100% rename from parser/include/catalog/pg_proc.h rename to parser/include/postgres/catalog/pg_proc.h diff --git a/parser/include/catalog/pg_proc_d.h b/parser/include/postgres/catalog/pg_proc_d.h similarity index 100% rename from parser/include/catalog/pg_proc_d.h rename to parser/include/postgres/catalog/pg_proc_d.h diff --git a/parser/include/catalog/pg_publication.h b/parser/include/postgres/catalog/pg_publication.h similarity index 100% rename from parser/include/catalog/pg_publication.h rename to parser/include/postgres/catalog/pg_publication.h diff --git a/parser/include/catalog/pg_publication_d.h b/parser/include/postgres/catalog/pg_publication_d.h similarity index 100% rename from parser/include/catalog/pg_publication_d.h rename to parser/include/postgres/catalog/pg_publication_d.h diff --git a/parser/include/catalog/pg_replication_origin.h b/parser/include/postgres/catalog/pg_replication_origin.h similarity index 100% rename from parser/include/catalog/pg_replication_origin.h rename to parser/include/postgres/catalog/pg_replication_origin.h diff --git a/parser/include/catalog/pg_replication_origin_d.h b/parser/include/postgres/catalog/pg_replication_origin_d.h similarity index 100% rename from parser/include/catalog/pg_replication_origin_d.h rename to parser/include/postgres/catalog/pg_replication_origin_d.h diff --git a/parser/include/catalog/pg_statistic.h b/parser/include/postgres/catalog/pg_statistic.h similarity index 100% rename from parser/include/catalog/pg_statistic.h rename to parser/include/postgres/catalog/pg_statistic.h diff --git a/parser/include/catalog/pg_statistic_d.h b/parser/include/postgres/catalog/pg_statistic_d.h similarity index 100% rename from parser/include/catalog/pg_statistic_d.h rename to parser/include/postgres/catalog/pg_statistic_d.h diff --git a/parser/include/catalog/pg_statistic_ext.h b/parser/include/postgres/catalog/pg_statistic_ext.h similarity index 100% rename from parser/include/catalog/pg_statistic_ext.h rename to parser/include/postgres/catalog/pg_statistic_ext.h diff --git a/parser/include/catalog/pg_statistic_ext_d.h b/parser/include/postgres/catalog/pg_statistic_ext_d.h similarity index 100% rename from parser/include/catalog/pg_statistic_ext_d.h rename to parser/include/postgres/catalog/pg_statistic_ext_d.h diff --git a/parser/include/catalog/pg_transform.h b/parser/include/postgres/catalog/pg_transform.h similarity index 100% rename from parser/include/catalog/pg_transform.h rename to parser/include/postgres/catalog/pg_transform.h diff --git a/parser/include/catalog/pg_transform_d.h b/parser/include/postgres/catalog/pg_transform_d.h similarity index 100% rename from parser/include/catalog/pg_transform_d.h rename to parser/include/postgres/catalog/pg_transform_d.h diff --git a/parser/include/catalog/pg_trigger.h b/parser/include/postgres/catalog/pg_trigger.h similarity index 100% rename from parser/include/catalog/pg_trigger.h rename to parser/include/postgres/catalog/pg_trigger.h diff --git a/parser/include/catalog/pg_trigger_d.h b/parser/include/postgres/catalog/pg_trigger_d.h similarity index 100% rename from parser/include/catalog/pg_trigger_d.h rename to parser/include/postgres/catalog/pg_trigger_d.h diff --git a/parser/include/catalog/pg_ts_config.h b/parser/include/postgres/catalog/pg_ts_config.h similarity index 100% rename from parser/include/catalog/pg_ts_config.h rename to parser/include/postgres/catalog/pg_ts_config.h diff --git a/parser/include/catalog/pg_ts_config_d.h b/parser/include/postgres/catalog/pg_ts_config_d.h similarity index 100% rename from parser/include/catalog/pg_ts_config_d.h rename to parser/include/postgres/catalog/pg_ts_config_d.h diff --git a/parser/include/catalog/pg_ts_dict.h b/parser/include/postgres/catalog/pg_ts_dict.h similarity index 100% rename from parser/include/catalog/pg_ts_dict.h rename to parser/include/postgres/catalog/pg_ts_dict.h diff --git a/parser/include/catalog/pg_ts_dict_d.h b/parser/include/postgres/catalog/pg_ts_dict_d.h similarity index 100% rename from parser/include/catalog/pg_ts_dict_d.h rename to parser/include/postgres/catalog/pg_ts_dict_d.h diff --git a/parser/include/catalog/pg_ts_parser.h b/parser/include/postgres/catalog/pg_ts_parser.h similarity index 100% rename from parser/include/catalog/pg_ts_parser.h rename to parser/include/postgres/catalog/pg_ts_parser.h diff --git a/parser/include/catalog/pg_ts_parser_d.h b/parser/include/postgres/catalog/pg_ts_parser_d.h similarity index 100% rename from parser/include/catalog/pg_ts_parser_d.h rename to parser/include/postgres/catalog/pg_ts_parser_d.h diff --git a/parser/include/catalog/pg_ts_template.h b/parser/include/postgres/catalog/pg_ts_template.h similarity index 100% rename from parser/include/catalog/pg_ts_template.h rename to parser/include/postgres/catalog/pg_ts_template.h diff --git a/parser/include/catalog/pg_ts_template_d.h b/parser/include/postgres/catalog/pg_ts_template_d.h similarity index 100% rename from parser/include/catalog/pg_ts_template_d.h rename to parser/include/postgres/catalog/pg_ts_template_d.h diff --git a/parser/include/catalog/pg_type.h b/parser/include/postgres/catalog/pg_type.h similarity index 100% rename from parser/include/catalog/pg_type.h rename to parser/include/postgres/catalog/pg_type.h diff --git a/parser/include/catalog/pg_type_d.h b/parser/include/postgres/catalog/pg_type_d.h similarity index 100% rename from parser/include/catalog/pg_type_d.h rename to parser/include/postgres/catalog/pg_type_d.h diff --git a/parser/include/catalog/storage.h b/parser/include/postgres/catalog/storage.h similarity index 100% rename from parser/include/catalog/storage.h rename to parser/include/postgres/catalog/storage.h diff --git a/parser/include/commands/async.h b/parser/include/postgres/commands/async.h similarity index 100% rename from parser/include/commands/async.h rename to parser/include/postgres/commands/async.h diff --git a/parser/include/commands/dbcommands.h b/parser/include/postgres/commands/dbcommands.h similarity index 100% rename from parser/include/commands/dbcommands.h rename to parser/include/postgres/commands/dbcommands.h diff --git a/parser/include/commands/defrem.h b/parser/include/postgres/commands/defrem.h similarity index 100% rename from parser/include/commands/defrem.h rename to parser/include/postgres/commands/defrem.h diff --git a/parser/include/commands/event_trigger.h b/parser/include/postgres/commands/event_trigger.h similarity index 100% rename from parser/include/commands/event_trigger.h rename to parser/include/postgres/commands/event_trigger.h diff --git a/parser/include/commands/explain.h b/parser/include/postgres/commands/explain.h similarity index 100% rename from parser/include/commands/explain.h rename to parser/include/postgres/commands/explain.h diff --git a/parser/include/commands/prepare.h b/parser/include/postgres/commands/prepare.h similarity index 100% rename from parser/include/commands/prepare.h rename to parser/include/postgres/commands/prepare.h diff --git a/parser/include/commands/tablespace.h b/parser/include/postgres/commands/tablespace.h similarity index 100% rename from parser/include/commands/tablespace.h rename to parser/include/postgres/commands/tablespace.h diff --git a/parser/include/commands/trigger.h b/parser/include/postgres/commands/trigger.h similarity index 100% rename from parser/include/commands/trigger.h rename to parser/include/postgres/commands/trigger.h diff --git a/parser/include/commands/user.h b/parser/include/postgres/commands/user.h similarity index 100% rename from parser/include/commands/user.h rename to parser/include/postgres/commands/user.h diff --git a/parser/include/commands/vacuum.h b/parser/include/postgres/commands/vacuum.h similarity index 100% rename from parser/include/commands/vacuum.h rename to parser/include/postgres/commands/vacuum.h diff --git a/parser/include/common/cryptohash.h b/parser/include/postgres/common/cryptohash.h similarity index 100% rename from parser/include/common/cryptohash.h rename to parser/include/postgres/common/cryptohash.h diff --git a/parser/include/common/file_perm.h b/parser/include/postgres/common/file_perm.h similarity index 100% rename from parser/include/common/file_perm.h rename to parser/include/postgres/common/file_perm.h diff --git a/parser/include/common/hashfn.h b/parser/include/postgres/common/hashfn.h similarity index 100% rename from parser/include/common/hashfn.h rename to parser/include/postgres/common/hashfn.h diff --git a/parser/include/common/int.h b/parser/include/postgres/common/int.h similarity index 100% rename from parser/include/common/int.h rename to parser/include/postgres/common/int.h diff --git a/parser/include/common/keywords.h b/parser/include/postgres/common/keywords.h similarity index 100% rename from parser/include/common/keywords.h rename to parser/include/postgres/common/keywords.h diff --git a/parser/include/common/kwlookup.h b/parser/include/postgres/common/kwlookup.h similarity index 100% rename from parser/include/common/kwlookup.h rename to parser/include/postgres/common/kwlookup.h diff --git a/parser/include/common/pg_prng.h b/parser/include/postgres/common/pg_prng.h similarity index 100% rename from parser/include/common/pg_prng.h rename to parser/include/postgres/common/pg_prng.h diff --git a/parser/include/common/relpath.h b/parser/include/postgres/common/relpath.h similarity index 100% rename from parser/include/common/relpath.h rename to parser/include/postgres/common/relpath.h diff --git a/parser/include/common/scram-common.h b/parser/include/postgres/common/scram-common.h similarity index 100% rename from parser/include/common/scram-common.h rename to parser/include/postgres/common/scram-common.h diff --git a/parser/include/common/sha2.h b/parser/include/postgres/common/sha2.h similarity index 100% rename from parser/include/common/sha2.h rename to parser/include/postgres/common/sha2.h diff --git a/parser/include/common/string.h b/parser/include/postgres/common/string.h similarity index 100% rename from parser/include/common/string.h rename to parser/include/postgres/common/string.h diff --git a/parser/include/common/unicode_east_asian_fw_table.h b/parser/include/postgres/common/unicode_east_asian_fw_table.h similarity index 100% rename from parser/include/common/unicode_east_asian_fw_table.h rename to parser/include/postgres/common/unicode_east_asian_fw_table.h diff --git a/parser/include/common/unicode_nonspacing_table.h b/parser/include/postgres/common/unicode_nonspacing_table.h similarity index 100% rename from parser/include/common/unicode_nonspacing_table.h rename to parser/include/postgres/common/unicode_nonspacing_table.h diff --git a/parser/include/copyfuncs.funcs.c b/parser/include/postgres/copyfuncs.funcs.c similarity index 100% rename from parser/include/copyfuncs.funcs.c rename to parser/include/postgres/copyfuncs.funcs.c diff --git a/parser/include/copyfuncs.switch.c b/parser/include/postgres/copyfuncs.switch.c similarity index 100% rename from parser/include/copyfuncs.switch.c rename to parser/include/postgres/copyfuncs.switch.c diff --git a/parser/include/datatype/timestamp.h b/parser/include/postgres/datatype/timestamp.h similarity index 100% rename from parser/include/datatype/timestamp.h rename to parser/include/postgres/datatype/timestamp.h diff --git a/parser/include/equalfuncs.funcs.c b/parser/include/postgres/equalfuncs.funcs.c similarity index 100% rename from parser/include/equalfuncs.funcs.c rename to parser/include/postgres/equalfuncs.funcs.c diff --git a/parser/include/equalfuncs.switch.c b/parser/include/postgres/equalfuncs.switch.c similarity index 100% rename from parser/include/equalfuncs.switch.c rename to parser/include/postgres/equalfuncs.switch.c diff --git a/parser/include/executor/execdesc.h b/parser/include/postgres/executor/execdesc.h similarity index 100% rename from parser/include/executor/execdesc.h rename to parser/include/postgres/executor/execdesc.h diff --git a/parser/include/executor/executor.h b/parser/include/postgres/executor/executor.h similarity index 100% rename from parser/include/executor/executor.h rename to parser/include/postgres/executor/executor.h diff --git a/parser/include/executor/functions.h b/parser/include/postgres/executor/functions.h similarity index 100% rename from parser/include/executor/functions.h rename to parser/include/postgres/executor/functions.h diff --git a/parser/include/executor/instrument.h b/parser/include/postgres/executor/instrument.h similarity index 100% rename from parser/include/executor/instrument.h rename to parser/include/postgres/executor/instrument.h diff --git a/parser/include/executor/spi.h b/parser/include/postgres/executor/spi.h similarity index 100% rename from parser/include/executor/spi.h rename to parser/include/postgres/executor/spi.h diff --git a/parser/include/executor/tablefunc.h b/parser/include/postgres/executor/tablefunc.h similarity index 100% rename from parser/include/executor/tablefunc.h rename to parser/include/postgres/executor/tablefunc.h diff --git a/parser/include/executor/tuptable.h b/parser/include/postgres/executor/tuptable.h similarity index 100% rename from parser/include/executor/tuptable.h rename to parser/include/postgres/executor/tuptable.h diff --git a/parser/include/fmgr.h b/parser/include/postgres/fmgr.h similarity index 100% rename from parser/include/fmgr.h rename to parser/include/postgres/fmgr.h diff --git a/parser/include/foreign/fdwapi.h b/parser/include/postgres/foreign/fdwapi.h similarity index 100% rename from parser/include/foreign/fdwapi.h rename to parser/include/postgres/foreign/fdwapi.h diff --git a/parser/include/funcapi.h b/parser/include/postgres/funcapi.h similarity index 100% rename from parser/include/funcapi.h rename to parser/include/postgres/funcapi.h diff --git a/parser/include/gram.h b/parser/include/postgres/gram.h similarity index 100% rename from parser/include/gram.h rename to parser/include/postgres/gram.h diff --git a/parser/include/gramparse.h b/parser/include/postgres/gramparse.h similarity index 100% rename from parser/include/gramparse.h rename to parser/include/postgres/gramparse.h diff --git a/parser/include/jit/jit.h b/parser/include/postgres/jit/jit.h similarity index 100% rename from parser/include/jit/jit.h rename to parser/include/postgres/jit/jit.h diff --git a/parser/include/kwlist_d.h b/parser/include/postgres/kwlist_d.h similarity index 100% rename from parser/include/kwlist_d.h rename to parser/include/postgres/kwlist_d.h diff --git a/parser/include/lib/dshash.h b/parser/include/postgres/lib/dshash.h similarity index 100% rename from parser/include/lib/dshash.h rename to parser/include/postgres/lib/dshash.h diff --git a/parser/include/lib/ilist.h b/parser/include/postgres/lib/ilist.h similarity index 100% rename from parser/include/lib/ilist.h rename to parser/include/postgres/lib/ilist.h diff --git a/parser/include/lib/pairingheap.h b/parser/include/postgres/lib/pairingheap.h similarity index 100% rename from parser/include/lib/pairingheap.h rename to parser/include/postgres/lib/pairingheap.h diff --git a/parser/include/lib/simplehash.h b/parser/include/postgres/lib/simplehash.h similarity index 100% rename from parser/include/lib/simplehash.h rename to parser/include/postgres/lib/simplehash.h diff --git a/parser/include/lib/sort_template.h b/parser/include/postgres/lib/sort_template.h similarity index 100% rename from parser/include/lib/sort_template.h rename to parser/include/postgres/lib/sort_template.h diff --git a/parser/include/lib/stringinfo.h b/parser/include/postgres/lib/stringinfo.h similarity index 100% rename from parser/include/lib/stringinfo.h rename to parser/include/postgres/lib/stringinfo.h diff --git a/parser/include/libpq/auth.h b/parser/include/postgres/libpq/auth.h similarity index 100% rename from parser/include/libpq/auth.h rename to parser/include/postgres/libpq/auth.h diff --git a/parser/include/libpq/crypt.h b/parser/include/postgres/libpq/crypt.h similarity index 100% rename from parser/include/libpq/crypt.h rename to parser/include/postgres/libpq/crypt.h diff --git a/parser/include/libpq/hba.h b/parser/include/postgres/libpq/hba.h similarity index 100% rename from parser/include/libpq/hba.h rename to parser/include/postgres/libpq/hba.h diff --git a/parser/include/libpq/libpq-be.h b/parser/include/postgres/libpq/libpq-be.h similarity index 100% rename from parser/include/libpq/libpq-be.h rename to parser/include/postgres/libpq/libpq-be.h diff --git a/parser/include/libpq/libpq.h b/parser/include/postgres/libpq/libpq.h similarity index 100% rename from parser/include/libpq/libpq.h rename to parser/include/postgres/libpq/libpq.h diff --git a/parser/include/libpq/pqcomm.h b/parser/include/postgres/libpq/pqcomm.h similarity index 100% rename from parser/include/libpq/pqcomm.h rename to parser/include/postgres/libpq/pqcomm.h diff --git a/parser/include/libpq/pqformat.h b/parser/include/postgres/libpq/pqformat.h similarity index 100% rename from parser/include/libpq/pqformat.h rename to parser/include/postgres/libpq/pqformat.h diff --git a/parser/include/libpq/pqsignal.h b/parser/include/postgres/libpq/pqsignal.h similarity index 100% rename from parser/include/libpq/pqsignal.h rename to parser/include/postgres/libpq/pqsignal.h diff --git a/parser/include/libpq/sasl.h b/parser/include/postgres/libpq/sasl.h similarity index 100% rename from parser/include/libpq/sasl.h rename to parser/include/postgres/libpq/sasl.h diff --git a/parser/include/libpq/scram.h b/parser/include/postgres/libpq/scram.h similarity index 100% rename from parser/include/libpq/scram.h rename to parser/include/postgres/libpq/scram.h diff --git a/parser/include/mb/pg_wchar.h b/parser/include/postgres/mb/pg_wchar.h similarity index 100% rename from parser/include/mb/pg_wchar.h rename to parser/include/postgres/mb/pg_wchar.h diff --git a/parser/include/mb/stringinfo_mb.h b/parser/include/postgres/mb/stringinfo_mb.h similarity index 100% rename from parser/include/mb/stringinfo_mb.h rename to parser/include/postgres/mb/stringinfo_mb.h diff --git a/parser/include/miscadmin.h b/parser/include/postgres/miscadmin.h similarity index 99% rename from parser/include/miscadmin.h rename to parser/include/postgres/miscadmin.h index 6e5284d5..8fcdba35 100644 --- a/parser/include/miscadmin.h +++ b/parser/include/postgres/miscadmin.h @@ -167,7 +167,7 @@ extern PGDLLIMPORT bool IsUnderPostmaster; extern PGDLLIMPORT bool IsBackgroundWorker; extern PGDLLIMPORT bool IsBinaryUpgrade; -extern PGDLLIMPORT __thread bool ExitOnAnyError; +extern PGDLLIMPORT __thread bool ExitOnAnyError; extern PGDLLIMPORT char *DataDir; extern PGDLLIMPORT int data_directory_mode; diff --git a/parser/include/nodes/bitmapset.h b/parser/include/postgres/nodes/bitmapset.h similarity index 100% rename from parser/include/nodes/bitmapset.h rename to parser/include/postgres/nodes/bitmapset.h diff --git a/parser/include/nodes/execnodes.h b/parser/include/postgres/nodes/execnodes.h similarity index 100% rename from parser/include/nodes/execnodes.h rename to parser/include/postgres/nodes/execnodes.h diff --git a/parser/include/nodes/extensible.h b/parser/include/postgres/nodes/extensible.h similarity index 100% rename from parser/include/nodes/extensible.h rename to parser/include/postgres/nodes/extensible.h diff --git a/parser/include/nodes/lockoptions.h b/parser/include/postgres/nodes/lockoptions.h similarity index 100% rename from parser/include/nodes/lockoptions.h rename to parser/include/postgres/nodes/lockoptions.h diff --git a/parser/include/nodes/makefuncs.h b/parser/include/postgres/nodes/makefuncs.h similarity index 100% rename from parser/include/nodes/makefuncs.h rename to parser/include/postgres/nodes/makefuncs.h diff --git a/parser/include/nodes/memnodes.h b/parser/include/postgres/nodes/memnodes.h similarity index 100% rename from parser/include/nodes/memnodes.h rename to parser/include/postgres/nodes/memnodes.h diff --git a/parser/include/nodes/miscnodes.h b/parser/include/postgres/nodes/miscnodes.h similarity index 100% rename from parser/include/nodes/miscnodes.h rename to parser/include/postgres/nodes/miscnodes.h diff --git a/parser/include/nodes/nodeFuncs.h b/parser/include/postgres/nodes/nodeFuncs.h similarity index 100% rename from parser/include/nodes/nodeFuncs.h rename to parser/include/postgres/nodes/nodeFuncs.h diff --git a/parser/include/nodes/nodes.h b/parser/include/postgres/nodes/nodes.h similarity index 99% rename from parser/include/nodes/nodes.h rename to parser/include/postgres/nodes/nodes.h index 13ea9cae..cfc3816f 100644 --- a/parser/include/nodes/nodes.h +++ b/parser/include/postgres/nodes/nodes.h @@ -161,7 +161,7 @@ typedef struct Node * Fortunately, this macro isn't recursive so we just define * a global variable for this purpose. */ -extern PGDLLIMPORT Node *newNodeMacroHolder; +extern PGDLLIMPORT __thread Node *newNodeMacroHolder; #define newNode(size, tag) \ ( \ diff --git a/parser/include/nodes/nodetags.h b/parser/include/postgres/nodes/nodetags.h similarity index 100% rename from parser/include/nodes/nodetags.h rename to parser/include/postgres/nodes/nodetags.h diff --git a/parser/include/nodes/params.h b/parser/include/postgres/nodes/params.h similarity index 100% rename from parser/include/nodes/params.h rename to parser/include/postgres/nodes/params.h diff --git a/parser/include/nodes/parsenodes.h b/parser/include/postgres/nodes/parsenodes.h similarity index 100% rename from parser/include/nodes/parsenodes.h rename to parser/include/postgres/nodes/parsenodes.h diff --git a/parser/include/nodes/pathnodes.h b/parser/include/postgres/nodes/pathnodes.h similarity index 100% rename from parser/include/nodes/pathnodes.h rename to parser/include/postgres/nodes/pathnodes.h diff --git a/parser/include/nodes/pg_list.h b/parser/include/postgres/nodes/pg_list.h similarity index 100% rename from parser/include/nodes/pg_list.h rename to parser/include/postgres/nodes/pg_list.h diff --git a/parser/include/nodes/plannodes.h b/parser/include/postgres/nodes/plannodes.h similarity index 100% rename from parser/include/nodes/plannodes.h rename to parser/include/postgres/nodes/plannodes.h diff --git a/parser/include/nodes/primnodes.h b/parser/include/postgres/nodes/primnodes.h similarity index 100% rename from parser/include/nodes/primnodes.h rename to parser/include/postgres/nodes/primnodes.h diff --git a/parser/include/nodes/print.h b/parser/include/postgres/nodes/print.h similarity index 100% rename from parser/include/nodes/print.h rename to parser/include/postgres/nodes/print.h diff --git a/parser/include/nodes/queryjumble.h b/parser/include/postgres/nodes/queryjumble.h similarity index 100% rename from parser/include/nodes/queryjumble.h rename to parser/include/postgres/nodes/queryjumble.h diff --git a/parser/include/nodes/replnodes.h b/parser/include/postgres/nodes/replnodes.h similarity index 100% rename from parser/include/nodes/replnodes.h rename to parser/include/postgres/nodes/replnodes.h diff --git a/parser/include/nodes/supportnodes.h b/parser/include/postgres/nodes/supportnodes.h similarity index 100% rename from parser/include/nodes/supportnodes.h rename to parser/include/postgres/nodes/supportnodes.h diff --git a/parser/include/nodes/tidbitmap.h b/parser/include/postgres/nodes/tidbitmap.h similarity index 100% rename from parser/include/nodes/tidbitmap.h rename to parser/include/postgres/nodes/tidbitmap.h diff --git a/parser/include/nodes/value.h b/parser/include/postgres/nodes/value.h similarity index 100% rename from parser/include/nodes/value.h rename to parser/include/postgres/nodes/value.h diff --git a/parser/include/optimizer/cost.h b/parser/include/postgres/optimizer/cost.h similarity index 100% rename from parser/include/optimizer/cost.h rename to parser/include/postgres/optimizer/cost.h diff --git a/parser/include/optimizer/geqo.h b/parser/include/postgres/optimizer/geqo.h similarity index 100% rename from parser/include/optimizer/geqo.h rename to parser/include/postgres/optimizer/geqo.h diff --git a/parser/include/optimizer/geqo_gene.h b/parser/include/postgres/optimizer/geqo_gene.h similarity index 100% rename from parser/include/optimizer/geqo_gene.h rename to parser/include/postgres/optimizer/geqo_gene.h diff --git a/parser/include/optimizer/optimizer.h b/parser/include/postgres/optimizer/optimizer.h similarity index 100% rename from parser/include/optimizer/optimizer.h rename to parser/include/postgres/optimizer/optimizer.h diff --git a/parser/include/optimizer/paths.h b/parser/include/postgres/optimizer/paths.h similarity index 100% rename from parser/include/optimizer/paths.h rename to parser/include/postgres/optimizer/paths.h diff --git a/parser/include/optimizer/planmain.h b/parser/include/postgres/optimizer/planmain.h similarity index 100% rename from parser/include/optimizer/planmain.h rename to parser/include/postgres/optimizer/planmain.h diff --git a/parser/include/parser/analyze.h b/parser/include/postgres/parser/analyze.h similarity index 100% rename from parser/include/parser/analyze.h rename to parser/include/postgres/parser/analyze.h diff --git a/parser/include/parser/kwlist.h b/parser/include/postgres/parser/kwlist.h similarity index 100% rename from parser/include/parser/kwlist.h rename to parser/include/postgres/parser/kwlist.h diff --git a/parser/include/parser/parse_agg.h b/parser/include/postgres/parser/parse_agg.h similarity index 100% rename from parser/include/parser/parse_agg.h rename to parser/include/postgres/parser/parse_agg.h diff --git a/parser/include/parser/parse_coerce.h b/parser/include/postgres/parser/parse_coerce.h similarity index 100% rename from parser/include/parser/parse_coerce.h rename to parser/include/postgres/parser/parse_coerce.h diff --git a/parser/include/parser/parse_expr.h b/parser/include/postgres/parser/parse_expr.h similarity index 100% rename from parser/include/parser/parse_expr.h rename to parser/include/postgres/parser/parse_expr.h diff --git a/parser/include/parser/parse_func.h b/parser/include/postgres/parser/parse_func.h similarity index 100% rename from parser/include/parser/parse_func.h rename to parser/include/postgres/parser/parse_func.h diff --git a/parser/include/parser/parse_node.h b/parser/include/postgres/parser/parse_node.h similarity index 100% rename from parser/include/parser/parse_node.h rename to parser/include/postgres/parser/parse_node.h diff --git a/parser/include/parser/parse_oper.h b/parser/include/postgres/parser/parse_oper.h similarity index 100% rename from parser/include/parser/parse_oper.h rename to parser/include/postgres/parser/parse_oper.h diff --git a/parser/include/parser/parse_relation.h b/parser/include/postgres/parser/parse_relation.h similarity index 100% rename from parser/include/parser/parse_relation.h rename to parser/include/postgres/parser/parse_relation.h diff --git a/parser/include/parser/parse_type.h b/parser/include/postgres/parser/parse_type.h similarity index 100% rename from parser/include/parser/parse_type.h rename to parser/include/postgres/parser/parse_type.h diff --git a/parser/include/parser/parser.h b/parser/include/postgres/parser/parser.h similarity index 91% rename from parser/include/parser/parser.h rename to parser/include/postgres/parser/parser.h index cd7588c7..42832bfb 100644 --- a/parser/include/parser/parser.h +++ b/parser/include/postgres/parser/parser.h @@ -53,9 +53,9 @@ typedef enum } BackslashQuoteType; /* GUC variables in scan.l (every one of these is a bad idea :-() */ -extern PGDLLIMPORT __thread int backslash_quote; -extern PGDLLIMPORT __thread bool escape_string_warning; -extern PGDLLIMPORT __thread bool standard_conforming_strings; +extern PGDLLIMPORT __thread int backslash_quote; +extern PGDLLIMPORT __thread bool escape_string_warning; +extern PGDLLIMPORT __thread bool standard_conforming_strings; /* Primary entry point for the raw parsing functions */ diff --git a/parser/include/parser/parsetree.h b/parser/include/postgres/parser/parsetree.h similarity index 100% rename from parser/include/parser/parsetree.h rename to parser/include/postgres/parser/parsetree.h diff --git a/parser/include/parser/scanner.h b/parser/include/postgres/parser/scanner.h similarity index 100% rename from parser/include/parser/scanner.h rename to parser/include/postgres/parser/scanner.h diff --git a/parser/include/parser/scansup.h b/parser/include/postgres/parser/scansup.h similarity index 100% rename from parser/include/parser/scansup.h rename to parser/include/postgres/parser/scansup.h diff --git a/parser/include/partitioning/partdefs.h b/parser/include/postgres/partitioning/partdefs.h similarity index 100% rename from parser/include/partitioning/partdefs.h rename to parser/include/postgres/partitioning/partdefs.h diff --git a/parser/include/pg_config.h b/parser/include/postgres/pg_config.h similarity index 87% rename from parser/include/pg_config.h rename to parser/include/postgres/pg_config.h index d1dd7b72..bba2f42b 100644 --- a/parser/include/pg_config.h +++ b/parser/include/postgres/pg_config.h @@ -650,7 +650,7 @@ #define PG_VERSION_NUM 160001 /* A string containing the version number, platform, and C compiler */ -#define PG_VERSION_STR "PostgreSQL 16.1 on aarch64-apple-darwin21.6.0, compiled by Apple clang version 14.0.0 (clang-1400.0.29.102), 64-bit" +#define PG_VERSION_STR "PostgreSQL 16.1 (libpg_query)" /* Define to 1 to allow profiling output to be saved separately for each process. */ @@ -826,18 +826,152 @@ /* Define to how the compiler spells `typeof'. */ /* #undef typeof */ +/* This causes compatibility problems on some Linux distros, with "xlocale.h" not being available */ #undef HAVE_LOCALE_T #undef LOCALE_T_IN_XLOCALE #undef WCSTOMBS_L_IN_XLOCALE -#undef PG_INT128_TYPE + +/* Support gcc earlier than 4.6.0 and MSVC */ #undef HAVE__STATIC_ASSERT + +/* Avoid dependency on execinfo (requires extra library on musl-libc based systems, not supported on Windows) */ #undef HAVE_EXECINFO_H #undef HAVE_BACKTRACE_SYMBOLS + +/* Avoid dependency on hardware popcount instructions (POPQNTQ) on x86 */ #undef HAVE_X86_64_POPCNTQ + +/* Avoid dependency on cpuid.h (only supported on x86 systems) */ #undef HAVE__GET_CPUID + +/* Avoid CRC extension usage to ensure we are not architecture-dependent */ #undef USE_ARMV8_CRC32C #undef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK + +/* Ensure we do not fail on systems that have strchrnul support (FreeBSD, NetBSD and newer glibc) */ #include #if defined(__FreeBSD__) || defined(__NetBSD__) || (defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 38) || __GLIBC__ > 2)) #define HAVE_STRCHRNUL #endif + +/* 32-bit */ +#if defined(_WIN32) || __SIZEOF_POINTER__ == 4 +#undef ALIGNOF_DOUBLE +#define ALIGNOF_DOUBLE 4 +#undef ALIGNOF_LONG +#define ALIGNOF_LONG 4 +#define ALIGNOF_LONG_LONG_INT 4 +#undef ALIGNOF_PG_INT128_TYPE +#undef HAVE_LONG_INT_64 +#define HAVE_LONG_LONG_INT_64 1 +#undef INT64_MODIFIER +#define INT64_MODIFIER "ll" +#undef PG_INT128_TYPE +#undef PG_INT64_TYPE +#define PG_INT64_TYPE long long int +#undef SIZEOF_LONG +#define SIZEOF_LONG 4 +#undef SIZEOF_OFF_T +#define SIZEOF_OFF_T 4 +#undef SIZEOF_SIZE_T +#define SIZEOF_SIZE_T 4 +#undef SIZEOF_VOID_P +#define SIZEOF_VOID_P 4 +#endif + +/* Windows */ +#if defined(_WIN32) || defined(_WIN64) +#undef HAVE_COPYFILE +#undef HAVE_COPYFILE_H +#undef HAVE_DECL_F_FULLFSYNC +#define HAVE_DECL_F_FULLFSYNC 0 +#undef HAVE_DECL_PREADV +#define HAVE_DECL_PREADV 0 +#undef HAVE_DECL_PWRITEV +#define HAVE_DECL_PWRITEV 0 +#undef HAVE_DECL_STRLCAT +#define HAVE_DECL_STRLCAT 0 +#undef HAVE_DECL_STRLCPY +#define HAVE_DECL_STRLCPY 0 +#undef HAVE_GETIFADDRS +#undef HAVE_GETPEEREID +#undef HAVE_IFADDRS_H +#undef HAVE_INET_ATON +#undef HAVE_INT_OPTRESET +#undef HAVE_KQUEUE +#undef HAVE_LANGINFO_H +#undef HAVE_MEMSET_S +#undef HAVE_MKDTEMP +#undef HAVE_PTHREAD +#undef HAVE_PTHREAD_BARRIER_WAIT +#undef HAVE_PTHREAD_IS_THREADED_NP +#undef HAVE_PTHREAD_PRIO_INHERIT +#undef HAVE_STRERROR_R +#undef HAVE_STRLCAT +#undef HAVE_STRLCPY +#undef HAVE_STRSIGNAL +#undef HAVE_STRUCT_SOCKADDR_SA_LEN +#undef HAVE_STRUCT_TM_TM_ZONE +#undef HAVE_SYSLOG +#undef HAVE_SYS_EVENT_H +#undef HAVE_SYS_UCRED_H +#undef HAVE_TERMIOS_H +#undef HAVE_UNION_SEMUN +#undef HAVE_USELOCALE +#define HAVE__CONFIGTHREADLOCALE 1 +#undef STRERROR_R_INT +#undef USE_SYSV_SEMAPHORES +#undef USE_SYSV_SHARED_MEMORY +#define USE_WIN32_SEMAPHORES 1 +#define USE_WIN32_SHARED_MEMORY 1 +#undef PG_PRINTF_ATTRIBUTE +#if defined(__clang__) +#define PG_PRINTF_ATTRIBUTE printf +#elif defined(__MINGW32__) || defined(__MINGW64__) || defined(__MSYS__) || defined(__CYGWIN__) +#define PG_PRINTF_ATTRIBUTE gnu_printf +#endif +#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__MSYS__) || defined(__CYGWIN__) +#undef HAVE_MBSTOWCS_L +#undef HAVE_WCSTOMBS_L +#define HAVE_CRTDEFS_H 1 +#define HAVE_PTHREAD_BARRIER_WAIT 1 +#endif +#endif + +/* Microsoft Visual Studio Compiler */ +#ifdef _MSC_VER +#undef HAVE_COMPUTED_GOTO +#undef HAVE_GCC__ATOMIC_INT32_CAS +#undef HAVE_GCC__ATOMIC_INT64_CAS +#undef HAVE_GCC__SYNC_CHAR_TAS +#undef HAVE_GCC__SYNC_INT32_CAS +#undef HAVE_GCC__SYNC_INT32_TAS +#undef HAVE_GCC__SYNC_INT64_CAS +#undef HAVE_GETOPT +#undef HAVE_GETOPT_H +#undef HAVE_GETOPT_LONG +#undef HAVE_INTTYPES_H +#undef HAVE_INT_OPTERR +#undef HAVE_LIBM +#undef HAVE_STRINGS_H +#undef HAVE_STRUCT_OPTION +#undef HAVE_TYPEOF +#undef HAVE_VISIBILITY_ATTRIBUTE +#undef HAVE__BOOL +#undef HAVE__BUILTIN_BSWAP16 +#undef HAVE__BUILTIN_BSWAP32 +#undef HAVE__BUILTIN_BSWAP64 +#undef HAVE__BUILTIN_CLZ +#undef HAVE__BUILTIN_CONSTANT_P +#undef HAVE__BUILTIN_CTZ +#undef HAVE__BUILTIN_FRAME_ADDRESS +#undef HAVE__BUILTIN_OP_OVERFLOW +#undef HAVE__BUILTIN_POPCOUNT +#undef HAVE__BUILTIN_TYPES_COMPATIBLE_P +#undef HAVE__BUILTIN_UNREACHABLE +#ifndef __cplusplus +#define inline __inline +#endif +#undef restrict +#define __thread __declspec( thread ) +#endif diff --git a/parser/include/pg_config_ext.h b/parser/include/postgres/pg_config_ext.h similarity index 100% rename from parser/include/pg_config_ext.h rename to parser/include/postgres/pg_config_ext.h diff --git a/parser/include/pg_config_manual.h b/parser/include/postgres/pg_config_manual.h similarity index 100% rename from parser/include/pg_config_manual.h rename to parser/include/postgres/pg_config_manual.h diff --git a/parser/include/postgres/pg_config_os.h b/parser/include/postgres/pg_config_os.h new file mode 100644 index 00000000..4dc81de2 --- /dev/null +++ b/parser/include/postgres/pg_config_os.h @@ -0,0 +1,8 @@ +#if defined(_WIN32) || defined(_WIN64) +#include "port/win32.h" +#undef PGDLLIMPORT +#undef PGDLLEXPORT +#ifdef __clang__ +#undef __MINGW64__ +#endif /* __clang__ */ +#endif diff --git a/parser/include/pg_getopt.h b/parser/include/postgres/pg_getopt.h similarity index 100% rename from parser/include/pg_getopt.h rename to parser/include/postgres/pg_getopt.h diff --git a/parser/include/pg_trace.h b/parser/include/postgres/pg_trace.h similarity index 100% rename from parser/include/pg_trace.h rename to parser/include/postgres/pg_trace.h diff --git a/parser/include/pgstat.h b/parser/include/postgres/pgstat.h similarity index 99% rename from parser/include/pgstat.h rename to parser/include/postgres/pgstat.h index c99dd1cd..5a4dd0a1 100644 --- a/parser/include/pgstat.h +++ b/parser/include/postgres/pgstat.h @@ -764,7 +764,7 @@ extern PGDLLIMPORT PgStat_Counter pgStatActiveTime; extern PGDLLIMPORT PgStat_Counter pgStatTransactionIdleTime; /* updated by the traffic cop and in errfinish() */ -extern PGDLLIMPORT __thread SessionEndType pgStatSessionEndCause; +extern PGDLLIMPORT __thread SessionEndType pgStatSessionEndCause; /* diff --git a/parser/include/pgtime.h b/parser/include/postgres/pgtime.h similarity index 100% rename from parser/include/pgtime.h rename to parser/include/postgres/pgtime.h diff --git a/parser/include/pl_gram.h b/parser/include/postgres/pl_gram.h similarity index 99% rename from parser/include/pl_gram.h rename to parser/include/postgres/pl_gram.h index 4448e806..3045b730 100644 --- a/parser/include/pl_gram.h +++ b/parser/include/postgres/pl_gram.h @@ -367,7 +367,7 @@ typedef union YYSTYPE # define YYSTYPE_IS_TRIVIAL 1 #endif -extern __thread YYSTYPE plpgsql_yylval; +extern __thread YYSTYPE plpgsql_yylval; #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE @@ -382,4 +382,4 @@ typedef struct YYLTYPE # define YYLTYPE_IS_TRIVIAL 1 #endif -extern __thread YYLTYPE plpgsql_yylloc; +extern __thread YYLTYPE plpgsql_yylloc; diff --git a/parser/include/pl_reserved_kwlist.h b/parser/include/postgres/pl_reserved_kwlist.h similarity index 100% rename from parser/include/pl_reserved_kwlist.h rename to parser/include/postgres/pl_reserved_kwlist.h diff --git a/parser/include/pl_reserved_kwlist_d.h b/parser/include/postgres/pl_reserved_kwlist_d.h similarity index 100% rename from parser/include/pl_reserved_kwlist_d.h rename to parser/include/postgres/pl_reserved_kwlist_d.h diff --git a/parser/include/pl_unreserved_kwlist.h b/parser/include/postgres/pl_unreserved_kwlist.h similarity index 100% rename from parser/include/pl_unreserved_kwlist.h rename to parser/include/postgres/pl_unreserved_kwlist.h diff --git a/parser/include/pl_unreserved_kwlist_d.h b/parser/include/postgres/pl_unreserved_kwlist_d.h similarity index 100% rename from parser/include/pl_unreserved_kwlist_d.h rename to parser/include/postgres/pl_unreserved_kwlist_d.h diff --git a/parser/include/plerrcodes.h b/parser/include/postgres/plerrcodes.h similarity index 100% rename from parser/include/plerrcodes.h rename to parser/include/postgres/plerrcodes.h diff --git a/parser/include/plpgsql.h b/parser/include/postgres/plpgsql.h similarity index 98% rename from parser/include/plpgsql.h rename to parser/include/postgres/plpgsql.h index 6723e3d4..d172fe51 100644 --- a/parser/include/plpgsql.h +++ b/parser/include/postgres/plpgsql.h @@ -1191,11 +1191,11 @@ typedef enum IDENTIFIER_LOOKUP_EXPR /* In SQL expression --- special case */ } IdentifierLookup; -extern __thread IdentifierLookup plpgsql_IdentifierLookup; +extern __thread IdentifierLookup plpgsql_IdentifierLookup; -extern __thread int plpgsql_variable_conflict; +extern __thread int plpgsql_variable_conflict; -extern __thread bool plpgsql_print_strict_params; +extern __thread bool plpgsql_print_strict_params; extern bool plpgsql_check_asserts; @@ -1209,18 +1209,18 @@ extern bool plpgsql_check_asserts; extern int plpgsql_extra_warnings; extern int plpgsql_extra_errors; -extern __thread bool plpgsql_check_syntax; -extern __thread bool plpgsql_DumpExecTree; +extern __thread bool plpgsql_check_syntax; +extern __thread bool plpgsql_DumpExecTree; -extern __thread PLpgSQL_stmt_block *plpgsql_parse_result; +extern __thread PLpgSQL_stmt_block *plpgsql_parse_result; -extern __thread int plpgsql_nDatums; -extern __thread PLpgSQL_datum **plpgsql_Datums; +extern __thread int plpgsql_nDatums; +extern __thread PLpgSQL_datum **plpgsql_Datums; -extern __thread char *plpgsql_error_funcname; +extern __thread char *plpgsql_error_funcname; -extern __thread PLpgSQL_function *plpgsql_curr_compile; -extern __thread MemoryContext plpgsql_compile_tmp_cxt; +extern __thread PLpgSQL_function *plpgsql_curr_compile; +extern __thread MemoryContext plpgsql_compile_tmp_cxt; extern PLpgSQL_plugin **plpgsql_plugin_ptr; diff --git a/parser/include/port.h b/parser/include/postgres/port.h similarity index 100% rename from parser/include/port.h rename to parser/include/postgres/port.h diff --git a/parser/include/port/atomics.h b/parser/include/postgres/port/atomics.h similarity index 100% rename from parser/include/port/atomics.h rename to parser/include/postgres/port/atomics.h diff --git a/parser/include/port/atomics/arch-arm.h b/parser/include/postgres/port/atomics/arch-arm.h similarity index 100% rename from parser/include/port/atomics/arch-arm.h rename to parser/include/postgres/port/atomics/arch-arm.h diff --git a/parser/include/postgres/port/atomics/arch-hppa.h b/parser/include/postgres/port/atomics/arch-hppa.h new file mode 100644 index 00000000..4c89fbff --- /dev/null +++ b/parser/include/postgres/port/atomics/arch-hppa.h @@ -0,0 +1,17 @@ +/*------------------------------------------------------------------------- + * + * arch-hppa.h + * Atomic operations considerations specific to HPPA + * + * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * NOTES: + * + * src/include/port/atomics/arch-hppa.h + * + *------------------------------------------------------------------------- + */ + +/* HPPA doesn't do either read or write reordering */ +#define pg_memory_barrier_impl() pg_compiler_barrier_impl() diff --git a/parser/include/port/atomics/arch-ppc.h b/parser/include/postgres/port/atomics/arch-ppc.h similarity index 100% rename from parser/include/port/atomics/arch-ppc.h rename to parser/include/postgres/port/atomics/arch-ppc.h diff --git a/parser/include/port/atomics/arch-x86.h b/parser/include/postgres/port/atomics/arch-x86.h similarity index 100% rename from parser/include/port/atomics/arch-x86.h rename to parser/include/postgres/port/atomics/arch-x86.h diff --git a/parser/include/port/atomics/fallback.h b/parser/include/postgres/port/atomics/fallback.h similarity index 100% rename from parser/include/port/atomics/fallback.h rename to parser/include/postgres/port/atomics/fallback.h diff --git a/parser/include/port/atomics/generic-gcc.h b/parser/include/postgres/port/atomics/generic-gcc.h similarity index 100% rename from parser/include/port/atomics/generic-gcc.h rename to parser/include/postgres/port/atomics/generic-gcc.h diff --git a/parser/include/postgres/port/atomics/generic-msvc.h b/parser/include/postgres/port/atomics/generic-msvc.h new file mode 100644 index 00000000..8835f4ce --- /dev/null +++ b/parser/include/postgres/port/atomics/generic-msvc.h @@ -0,0 +1,101 @@ +/*------------------------------------------------------------------------- + * + * generic-msvc.h + * Atomic operations support when using MSVC + * + * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * NOTES: + * + * Documentation: + * * Interlocked Variable Access + * http://msdn.microsoft.com/en-us/library/ms684122%28VS.85%29.aspx + * + * src/include/port/atomics/generic-msvc.h + * + *------------------------------------------------------------------------- + */ +#include + +/* intentionally no include guards, should only be included by atomics.h */ +#ifndef INSIDE_ATOMICS_H +#error "should be included via atomics.h" +#endif + +#pragma intrinsic(_ReadWriteBarrier) +#define pg_compiler_barrier_impl() _ReadWriteBarrier() + +#ifndef pg_memory_barrier_impl +#define pg_memory_barrier_impl() MemoryBarrier() +#endif + +#if defined(HAVE_ATOMICS) + +#define PG_HAVE_ATOMIC_U32_SUPPORT +typedef struct pg_atomic_uint32 +{ + volatile uint32 value; +} pg_atomic_uint32; + +#define PG_HAVE_ATOMIC_U64_SUPPORT +typedef struct pg_attribute_aligned(8) pg_atomic_uint64 +{ + volatile uint64 value; +} pg_atomic_uint64; + + +#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32 +static inline bool +pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, + uint32 *expected, uint32 newval) +{ + bool ret; + uint32 current; + current = InterlockedCompareExchange(&ptr->value, newval, *expected); + ret = current == *expected; + *expected = current; + return ret; +} + +#define PG_HAVE_ATOMIC_FETCH_ADD_U32 +static inline uint32 +pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_) +{ + return InterlockedExchangeAdd(&ptr->value, add_); +} + +/* + * The non-intrinsics versions are only available in vista upwards, so use the + * intrinsic version. Only supported on >486, but we require XP as a minimum + * baseline, which doesn't support the 486, so we don't need to add checks for + * that case. + */ +#pragma intrinsic(_InterlockedCompareExchange64) + +#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64 +static inline bool +pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, + uint64 *expected, uint64 newval) +{ + bool ret; + uint64 current; + current = _InterlockedCompareExchange64(&ptr->value, newval, *expected); + ret = current == *expected; + *expected = current; + return ret; +} + +/* Only implemented on 64bit builds */ +#ifdef _WIN64 +#pragma intrinsic(_InterlockedExchangeAdd64) + +#define PG_HAVE_ATOMIC_FETCH_ADD_U64 +static inline uint64 +pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_) +{ + return _InterlockedExchangeAdd64(&ptr->value, add_); +} +#endif /* _WIN64 */ + +#endif /* HAVE_ATOMICS */ diff --git a/parser/include/postgres/port/atomics/generic-sunpro.h b/parser/include/postgres/port/atomics/generic-sunpro.h new file mode 100644 index 00000000..30f7d8b5 --- /dev/null +++ b/parser/include/postgres/port/atomics/generic-sunpro.h @@ -0,0 +1,106 @@ +/*------------------------------------------------------------------------- + * + * generic-sunpro.h + * Atomic operations for solaris' CC + * + * Portions Copyright (c) 2013-2023, PostgreSQL Global Development Group + * + * NOTES: + * + * Documentation: + * * manpage for atomic_cas(3C) + * http://www.unix.com/man-page/opensolaris/3c/atomic_cas/ + * http://docs.oracle.com/cd/E23824_01/html/821-1465/atomic-cas-3c.html + * + * src/include/port/atomics/generic-sunpro.h + * + * ------------------------------------------------------------------------- + */ + +#if defined(HAVE_ATOMICS) + +#ifdef HAVE_MBARRIER_H +#include + +#define pg_compiler_barrier_impl() __compiler_barrier() + +#ifndef pg_memory_barrier_impl +/* + * Despite the name this is actually a full barrier. Expanding to mfence/ + * membar #StoreStore | #LoadStore | #StoreLoad | #LoadLoad on x86/sparc + * respectively. + */ +# define pg_memory_barrier_impl() __machine_rw_barrier() +#endif +#ifndef pg_read_barrier_impl +# define pg_read_barrier_impl() __machine_r_barrier() +#endif +#ifndef pg_write_barrier_impl +# define pg_write_barrier_impl() __machine_w_barrier() +#endif + +#endif /* HAVE_MBARRIER_H */ + +/* Older versions of the compiler don't have atomic.h... */ +#ifdef HAVE_ATOMIC_H + +#include + +#define PG_HAVE_ATOMIC_U32_SUPPORT +typedef struct pg_atomic_uint32 +{ + volatile uint32 value; +} pg_atomic_uint32; + +#define PG_HAVE_ATOMIC_U64_SUPPORT +typedef struct pg_atomic_uint64 +{ + /* + * Syntax to enforce variable alignment should be supported by versions + * supporting atomic.h, but it's hard to find accurate documentation. If + * it proves to be a problem, we'll have to add more version checks for 64 + * bit support. + */ + volatile uint64 value pg_attribute_aligned(8); +} pg_atomic_uint64; + +#endif /* HAVE_ATOMIC_H */ + +#endif /* defined(HAVE_ATOMICS) */ + + +#if defined(HAVE_ATOMICS) + +#ifdef HAVE_ATOMIC_H + +#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32 +static inline bool +pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, + uint32 *expected, uint32 newval) +{ + bool ret; + uint32 current; + + current = atomic_cas_32(&ptr->value, *expected, newval); + ret = current == *expected; + *expected = current; + return ret; +} + +#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64 +static inline bool +pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, + uint64 *expected, uint64 newval) +{ + bool ret; + uint64 current; + + current = atomic_cas_64(&ptr->value, *expected, newval); + ret = current == *expected; + *expected = current; + return ret; +} + +#endif /* HAVE_ATOMIC_H */ + +#endif /* defined(HAVE_ATOMICS) */ diff --git a/parser/include/port/atomics/generic.h b/parser/include/postgres/port/atomics/generic.h similarity index 100% rename from parser/include/port/atomics/generic.h rename to parser/include/postgres/port/atomics/generic.h diff --git a/parser/include/port/pg_bitutils.h b/parser/include/postgres/port/pg_bitutils.h similarity index 100% rename from parser/include/port/pg_bitutils.h rename to parser/include/postgres/port/pg_bitutils.h diff --git a/parser/include/port/pg_bswap.h b/parser/include/postgres/port/pg_bswap.h similarity index 100% rename from parser/include/port/pg_bswap.h rename to parser/include/postgres/port/pg_bswap.h diff --git a/parser/include/port/pg_crc32c.h b/parser/include/postgres/port/pg_crc32c.h similarity index 100% rename from parser/include/port/pg_crc32c.h rename to parser/include/postgres/port/pg_crc32c.h diff --git a/parser/include/port/simd.h b/parser/include/postgres/port/simd.h similarity index 100% rename from parser/include/port/simd.h rename to parser/include/postgres/port/simd.h diff --git a/parser/include/postgres/port/win32.h b/parser/include/postgres/port/win32.h new file mode 100644 index 00000000..d6c13d0b --- /dev/null +++ b/parser/include/postgres/port/win32.h @@ -0,0 +1,59 @@ +/* src/include/port/win32.h */ + +/* + * We always rely on the WIN32 macro being set by our build system, + * but _WIN32 is the compiler pre-defined macro. So make sure we define + * WIN32 whenever _WIN32 is set, to facilitate standalone building. + */ +#if defined(_WIN32) && !defined(WIN32) +#define WIN32 +#endif + +/* + * Make sure _WIN32_WINNT has the minimum required value. + * Leave a higher value in place. The minimum requirement is Windows 10. + */ +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif + +#define _WIN32_WINNT 0x0A00 + +/* + * We need to prevent from defining a symbol conflicting with + * our errcode() function. Since it's likely to get included by standard + * system headers, pre-emptively include it now. + */ +#if defined(_MSC_VER) || defined(HAVE_CRTDEFS_H) +#define errcode __msvc_errcode +#include +#undef errcode +#endif + +/* + * defines for dynamic linking on Win32 platform + */ + +/* + * Variables declared in the core backend and referenced by loadable + * modules need to be marked "dllimport" in the core build, but + * "dllexport" when the declaration is read in a loadable module. + * No special markings should be used when compiling frontend code. + */ +#ifndef FRONTEND +#ifdef BUILDING_DLL +#define PGDLLIMPORT __declspec (dllexport) +#else +#define PGDLLIMPORT __declspec (dllimport) +#endif +#endif + +/* + * Functions exported by a loadable module must be marked "dllexport". + * + * While mingw would otherwise fall back to + * __attribute__((visibility("default"))), that appears to only work as long + * as no symbols are declared with __declspec(dllexport). But we can end up + * with some, e.g. plpython's Py_Init. + */ +#define PGDLLEXPORT __declspec (dllexport) diff --git a/parser/include/postgres/port/win32/arpa/inet.h b/parser/include/postgres/port/win32/arpa/inet.h new file mode 100644 index 00000000..ad180317 --- /dev/null +++ b/parser/include/postgres/port/win32/arpa/inet.h @@ -0,0 +1,3 @@ +/* src/include/port/win32/arpa/inet.h */ + +#include diff --git a/parser/include/postgres/port/win32/dlfcn.h b/parser/include/postgres/port/win32/dlfcn.h new file mode 100644 index 00000000..b6e43c09 --- /dev/null +++ b/parser/include/postgres/port/win32/dlfcn.h @@ -0,0 +1 @@ +/* src/include/port/win32/dlfcn.h */ diff --git a/parser/include/postgres/port/win32/grp.h b/parser/include/postgres/port/win32/grp.h new file mode 100644 index 00000000..8b4f2131 --- /dev/null +++ b/parser/include/postgres/port/win32/grp.h @@ -0,0 +1 @@ +/* src/include/port/win32/grp.h */ diff --git a/parser/include/postgres/port/win32/netdb.h b/parser/include/postgres/port/win32/netdb.h new file mode 100644 index 00000000..9ed13e45 --- /dev/null +++ b/parser/include/postgres/port/win32/netdb.h @@ -0,0 +1,7 @@ +/* src/include/port/win32/netdb.h */ +#ifndef WIN32_NETDB_H +#define WIN32_NETDB_H + +#include + +#endif diff --git a/parser/include/postgres/port/win32/netinet/in.h b/parser/include/postgres/port/win32/netinet/in.h new file mode 100644 index 00000000..a4e22f89 --- /dev/null +++ b/parser/include/postgres/port/win32/netinet/in.h @@ -0,0 +1,3 @@ +/* src/include/port/win32/netinet/in.h */ + +#include diff --git a/parser/include/postgres/port/win32/netinet/tcp.h b/parser/include/postgres/port/win32/netinet/tcp.h new file mode 100644 index 00000000..1d377b6a --- /dev/null +++ b/parser/include/postgres/port/win32/netinet/tcp.h @@ -0,0 +1,7 @@ +/* src/include/port/win32/netinet/tcp.h */ +#ifndef WIN32_NETINET_TCP_H +#define WIN32_NETINET_TCP_H + +#include + +#endif diff --git a/parser/include/postgres/port/win32/pwd.h b/parser/include/postgres/port/win32/pwd.h new file mode 100644 index 00000000..b8c7178f --- /dev/null +++ b/parser/include/postgres/port/win32/pwd.h @@ -0,0 +1,3 @@ +/* + * src/include/port/win32/pwd.h + */ diff --git a/parser/include/postgres/port/win32/sys/resource.h b/parser/include/postgres/port/win32/sys/resource.h new file mode 100644 index 00000000..a14feeb5 --- /dev/null +++ b/parser/include/postgres/port/win32/sys/resource.h @@ -0,0 +1,20 @@ +/* + * Replacement for for Windows. + */ +#ifndef WIN32_SYS_RESOURCE_H +#define WIN32_SYS_RESOURCE_H + +#include /* for struct timeval */ + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN (-1) + +struct rusage +{ + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ +}; + +extern int getrusage(int who, struct rusage *rusage); + +#endif /* WIN32_SYS_RESOURCE_H */ diff --git a/parser/include/postgres/port/win32/sys/select.h b/parser/include/postgres/port/win32/sys/select.h new file mode 100644 index 00000000..f8a877ac --- /dev/null +++ b/parser/include/postgres/port/win32/sys/select.h @@ -0,0 +1,3 @@ +/* + * src/include/port/win32/sys/select.h + */ diff --git a/parser/include/postgres/port/win32/sys/socket.h b/parser/include/postgres/port/win32/sys/socket.h new file mode 100644 index 00000000..0c32c0f7 --- /dev/null +++ b/parser/include/postgres/port/win32/sys/socket.h @@ -0,0 +1,26 @@ +/* + * src/include/port/win32/sys/socket.h + */ +#ifndef WIN32_SYS_SOCKET_H +#define WIN32_SYS_SOCKET_H + +/* + * Unfortunately, of VC++ also defines ERROR. + * To avoid the conflict, we include here and undefine ERROR + * immediately. + * + * Note: Don't include directly. It causes compile errors. + */ +#include +#include +#include + +#undef ERROR +#undef small + +/* Restore old ERROR value */ +#ifdef PGERROR +#define ERROR PGERROR +#endif + +#endif /* WIN32_SYS_SOCKET_H */ diff --git a/parser/include/postgres/port/win32/sys/un.h b/parser/include/postgres/port/win32/sys/un.h new file mode 100644 index 00000000..4fc13a23 --- /dev/null +++ b/parser/include/postgres/port/win32/sys/un.h @@ -0,0 +1,17 @@ +/* + * src/include/port/win32/sys/un.h + */ +#ifndef WIN32_SYS_UN_H +#define WIN32_SYS_UN_H + +/* + * Windows defines this structure in , but not all tool chains have + * the header yet, so we define it here for now. + */ +struct sockaddr_un +{ + unsigned short sun_family; + char sun_path[108]; +}; + +#endif diff --git a/parser/include/postgres/port/win32/sys/wait.h b/parser/include/postgres/port/win32/sys/wait.h new file mode 100644 index 00000000..eaeb5661 --- /dev/null +++ b/parser/include/postgres/port/win32/sys/wait.h @@ -0,0 +1,3 @@ +/* + * src/include/port/win32/sys/wait.h + */ diff --git a/parser/include/postgres/port/win32_msvc/dirent.h b/parser/include/postgres/port/win32_msvc/dirent.h new file mode 100644 index 00000000..62799db0 --- /dev/null +++ b/parser/include/postgres/port/win32_msvc/dirent.h @@ -0,0 +1,34 @@ +/* + * Headers for port/dirent.c, win32 native implementation of dirent functions + * + * src/include/port/win32_msvc/dirent.h + */ + +#ifndef _WIN32VC_DIRENT_H +#define _WIN32VC_DIRENT_H +struct dirent +{ + long d_ino; + unsigned short d_reclen; + unsigned char d_type; + unsigned short d_namlen; + char d_name[MAX_PATH]; +}; + +typedef struct DIR DIR; + +DIR *opendir(const char *); +struct dirent *readdir(DIR *); +int closedir(DIR *); + +/* File types for 'd_type'. */ +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 +#endif diff --git a/parser/include/postgres/port/win32_msvc/sys/file.h b/parser/include/postgres/port/win32_msvc/sys/file.h new file mode 100644 index 00000000..76be3e77 --- /dev/null +++ b/parser/include/postgres/port/win32_msvc/sys/file.h @@ -0,0 +1 @@ +/* src/include/port/win32_msvc/sys/file.h */ diff --git a/parser/include/postgres/port/win32_msvc/sys/param.h b/parser/include/postgres/port/win32_msvc/sys/param.h new file mode 100644 index 00000000..160df3b2 --- /dev/null +++ b/parser/include/postgres/port/win32_msvc/sys/param.h @@ -0,0 +1 @@ +/* src/include/port/win32_msvc/sys/param.h */ diff --git a/parser/include/postgres/port/win32_msvc/sys/time.h b/parser/include/postgres/port/win32_msvc/sys/time.h new file mode 100644 index 00000000..9d943ecc --- /dev/null +++ b/parser/include/postgres/port/win32_msvc/sys/time.h @@ -0,0 +1 @@ +/* src/include/port/win32_msvc/sys/time.h */ diff --git a/parser/include/postgres/port/win32_msvc/unistd.h b/parser/include/postgres/port/win32_msvc/unistd.h new file mode 100644 index 00000000..b7795ba0 --- /dev/null +++ b/parser/include/postgres/port/win32_msvc/unistd.h @@ -0,0 +1,9 @@ +/* src/include/port/win32_msvc/unistd.h */ + +/* + * MSVC does not define these, nor does _fileno(stdin) etc reliably work + * (returns -1 if stdin/out/err are closed). + */ +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 diff --git a/parser/include/postgres/port/win32_msvc/utime.h b/parser/include/postgres/port/win32_msvc/utime.h new file mode 100644 index 00000000..c78e79c3 --- /dev/null +++ b/parser/include/postgres/port/win32_msvc/utime.h @@ -0,0 +1,3 @@ +/* src/include/port/win32_msvc/utime.h */ + +#include /* for non-unicode version */ diff --git a/parser/include/postgres/port/win32_port.h b/parser/include/postgres/port/win32_port.h new file mode 100644 index 00000000..4dc26094 --- /dev/null +++ b/parser/include/postgres/port/win32_port.h @@ -0,0 +1,594 @@ +/*------------------------------------------------------------------------- + * + * win32_port.h + * Windows-specific compatibility stuff. + * + * Note this is read in MinGW as well as native Windows builds, + * but not in Cygwin builds. + * + * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/port/win32_port.h + * + *------------------------------------------------------------------------- + */ +#ifndef PG_WIN32_PORT_H +#define PG_WIN32_PORT_H + +/* + * Always build with SSPI support. Keep it as a #define in case + * we want a switch to disable it sometime in the future. + */ +#define ENABLE_SSPI 1 + +/* undefine and redefine after #include */ +#undef mkdir + +#undef ERROR + +/* + * VS2013 and later issue warnings about using the old Winsock API, + * which we don't really want to hear about. + */ +#ifdef _MSC_VER +#define _WINSOCK_DEPRECATED_NO_WARNINGS +#endif + +/* + * The MinGW64 headers choke if this is already defined - they + * define it themselves. + */ +#if !defined(__MINGW64_VERSION_MAJOR) || defined(_MSC_VER) +#define _WINSOCKAPI_ +#endif + +/* + * windows.h includes a lot of other headers, slowing down compilation + * significantly. WIN32_LEAN_AND_MEAN reduces that a bit. It'd be better to + * remove the include of windows.h (as well as indirect inclusions of it) from + * such a central place, but until then... + * + * To be able to include ntstatus.h tell windows.h to not declare NTSTATUS by + * temporarily defining UMDF_USING_NTSTATUS, otherwise we'll get warning about + * macro redefinitions, as windows.h also defines NTSTATUS (yuck). That in + * turn requires including ntstatus.h, winternl.h to get common symbols. + */ +#define WIN32_LEAN_AND_MEAN +#define UMDF_USING_NTSTATUS + +#include +#include +#include +#include +#include + +#undef small +#include +#include +#include +#undef near + +/* needed before sys/stat hacking below: */ +#define fstat microsoft_native_fstat +#define stat microsoft_native_stat +#include +#undef fstat +#undef stat + +/* Must be here to avoid conflicting with prototype in windows.h */ +#define mkdir(a,b) mkdir(a) + +#define ftruncate(a,b) chsize(a,b) + +/* Windows doesn't have fsync() as such, use _commit() */ +#define fsync(fd) _commit(fd) + +/* + * For historical reasons, we allow setting wal_sync_method to + * fsync_writethrough on Windows, even though it's really identical to fsync + * (both code paths wind up at _commit()). + */ +#define HAVE_FSYNC_WRITETHROUGH +#define FSYNC_WRITETHROUGH_IS_FSYNC + +#define USES_WINSOCK + +/* + * IPC defines + */ +#undef HAVE_UNION_SEMUN +#define HAVE_UNION_SEMUN 1 + +#define IPC_RMID 256 +#define IPC_CREAT 512 +#define IPC_EXCL 1024 +#define IPC_PRIVATE 234564 +#define IPC_NOWAIT 2048 +#define IPC_STAT 4096 + +#define EACCESS 2048 +#ifndef EIDRM +#define EIDRM 4096 +#endif + +#define SETALL 8192 +#define GETNCNT 16384 +#define GETVAL 65536 +#define SETVAL 131072 +#define GETPID 262144 + + +/* + * Signal stuff + * + * For WIN32, there is no wait() call so there are no wait() macros + * to interpret the return value of system(). Instead, system() + * return values < 0x100 are used for exit() termination, and higher + * values are used to indicate non-exit() termination, which is + * similar to a unix-style signal exit (think SIGSEGV == + * STATUS_ACCESS_VIOLATION). Return values are broken up into groups: + * + * https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values + * + * NT_SUCCESS 0 - 0x3FFFFFFF + * NT_INFORMATION 0x40000000 - 0x7FFFFFFF + * NT_WARNING 0x80000000 - 0xBFFFFFFF + * NT_ERROR 0xC0000000 - 0xFFFFFFFF + * + * Effectively, we don't care on the severity of the return value from + * system(), we just need to know if it was because of exit() or generated + * by the system, and it seems values >= 0x100 are system-generated. + * See this URL for a list of WIN32 STATUS_* values: + * + * Wine (URL used in our error messages) - + * http://source.winehq.org/source/include/ntstatus.h + * Descriptions - + * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55 + * + * The comprehensive exception list is included in ntstatus.h from the + * Windows Driver Kit (WDK). A subset of the list is also included in + * winnt.h from the Windows SDK. Defining WIN32_NO_STATUS before including + * windows.h helps to avoid any conflicts. + * + * Some day we might want to print descriptions for the most common + * exceptions, rather than printing an include file name. We could use + * RtlNtStatusToDosError() and pass to FormatMessage(), which can print + * the text of error values, but MinGW does not support + * RtlNtStatusToDosError(). + */ +#define WIFEXITED(w) (((w) & 0XFFFFFF00) == 0) +#define WIFSIGNALED(w) (!WIFEXITED(w)) +#define WEXITSTATUS(w) (w) +#define WTERMSIG(w) (w) + +#define sigmask(sig) ( 1 << ((sig)-1) ) + +/* Signal function return values */ +#undef SIG_DFL +#undef SIG_ERR +#undef SIG_IGN +#define SIG_DFL ((pqsigfunc)0) +#define SIG_ERR ((pqsigfunc)-1) +#define SIG_IGN ((pqsigfunc)1) + +/* Some extra signals */ +#define SIGHUP 1 +#define SIGQUIT 3 +#define SIGTRAP 5 +#define SIGABRT 22 /* Set to match W32 value -- not UNIX value */ +#define SIGKILL 9 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGSTOP 17 +#define SIGTSTP 18 +#define SIGCONT 19 +#define SIGCHLD 20 +#define SIGWINCH 28 +#define SIGUSR1 30 +#define SIGUSR2 31 + +/* MinGW has gettimeofday(), but MSVC doesn't */ +#ifdef _MSC_VER +/* Last parameter not used */ +extern int gettimeofday(struct timeval *tp, void *tzp); +#endif + +/* for setitimer in backend/port/win32/timer.c */ +#define ITIMER_REAL 0 +struct itimerval +{ + struct timeval it_interval; + struct timeval it_value; +}; + +int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue); + +/* Convenience wrapper for GetFileType() */ +extern DWORD pgwin32_get_file_type(HANDLE hFile); + +/* + * WIN32 does not provide 64-bit off_t, but does provide the functions operating + * with 64-bit offsets. Also, fseek() might not give an error for unseekable + * streams, so harden that function with our version. + */ +#define pgoff_t __int64 + +#ifdef _MSC_VER +extern int _pgfseeko64(FILE *stream, pgoff_t offset, int origin); +extern pgoff_t _pgftello64(FILE *stream); +#define fseeko(stream, offset, origin) _pgfseeko64(stream, offset, origin) +#define ftello(stream) _pgftello64(stream) +#else +#ifndef fseeko +#define fseeko(stream, offset, origin) fseeko64(stream, offset, origin) +#endif +#ifndef ftello +#define ftello(stream) ftello64(stream) +#endif +#endif + +/* + * Win32 also doesn't have symlinks, but we can emulate them with + * junction points on newer Win32 versions. + * + * Cygwin has its own symlinks which work on Win95/98/ME where + * junction points don't, so use those instead. We have no way of + * knowing what type of system Cygwin binaries will be run on. + * Note: Some CYGWIN includes might #define WIN32. + */ +extern int pgsymlink(const char *oldpath, const char *newpath); +extern int pgreadlink(const char *path, char *buf, size_t size); + +#define symlink(oldpath, newpath) pgsymlink(oldpath, newpath) +#define readlink(path, buf, size) pgreadlink(path, buf, size) + +/* + * Supplement to . + * + * Perl already has typedefs for uid_t and gid_t. + */ +#ifndef PLPERL_HAVE_UID_GID +typedef int uid_t; +typedef int gid_t; +#endif +typedef long key_t; + +#ifdef _MSC_VER +typedef int pid_t; +#endif + +/* + * Supplement to . + * + * We must pull in sys/stat.h before this part, else our overrides lose. + * + * stat() is not guaranteed to set the st_size field on win32, so we + * redefine it to our own implementation. See src/port/win32stat.c. + * + * The struct stat is 32 bit in MSVC, so we redefine it as a copy of + * struct __stat64. This also fixes the struct size for MINGW builds. + */ +struct stat /* This should match struct __stat64 */ +{ + _dev_t st_dev; + _ino_t st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + _dev_t st_rdev; + __int64 st_size; + __time64_t st_atime; + __time64_t st_mtime; + __time64_t st_ctime; +}; + +extern int _pgfstat64(int fileno, struct stat *buf); +extern int _pgstat64(const char *name, struct stat *buf); +extern int _pglstat64(const char *name, struct stat *buf); + +#define fstat(fileno, sb) _pgfstat64(fileno, sb) +#define stat(path, sb) _pgstat64(path, sb) +#define lstat(path, sb) _pglstat64(path, sb) + +/* These macros are not provided by older MinGW, nor by MSVC */ +#ifndef S_IRUSR +#define S_IRUSR _S_IREAD +#endif +#ifndef S_IWUSR +#define S_IWUSR _S_IWRITE +#endif +#ifndef S_IXUSR +#define S_IXUSR _S_IEXEC +#endif +#ifndef S_IRWXU +#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +#endif +#ifndef S_IRGRP +#define S_IRGRP 0 +#endif +#ifndef S_IWGRP +#define S_IWGRP 0 +#endif +#ifndef S_IXGRP +#define S_IXGRP 0 +#endif +#ifndef S_IRWXG +#define S_IRWXG 0 +#endif +#ifndef S_IROTH +#define S_IROTH 0 +#endif +#ifndef S_IWOTH +#define S_IWOTH 0 +#endif +#ifndef S_IXOTH +#define S_IXOTH 0 +#endif +#ifndef S_IRWXO +#define S_IRWXO 0 +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif +#ifndef S_ISREG +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif + +/* + * In order for lstat() to be able to report junction points as symlinks, we + * need to hijack a bit in st_mode, since neither MSVC nor MinGW provides + * S_ISLNK and there aren't any spare bits. We'll steal the one for character + * devices, because we don't otherwise make use of those. + */ +#ifdef S_ISLNK +#error "S_ISLNK is already defined" +#endif +#ifdef S_IFLNK +#error "S_IFLNK is already defined" +#endif +#define S_IFLNK S_IFCHR +#define S_ISLNK(m) (((m) & S_IFLNK) == S_IFLNK) + +/* + * Supplement to . + * This is the same value as _O_NOINHERIT in the MS header file. This is + * to ensure that we don't collide with a future definition. It means + * we cannot use _O_NOINHERIT ourselves. + */ +#define O_DSYNC 0x0080 + +/* + * Our open() replacement does not create inheritable handles, so it is safe to + * ignore O_CLOEXEC. (If we were using Windows' own open(), it might be + * necessary to convert this to _O_NOINHERIT.) + */ +#define O_CLOEXEC 0 + +/* + * Supplement to . + * + * We redefine network-related Berkeley error symbols as the corresponding WSA + * constants. This allows strerror.c to recognize them as being in the Winsock + * error code range and pass them off to win32_socket_strerror(), since + * Windows' version of plain strerror() won't cope. Note that this will break + * if these names are used for anything else besides Windows Sockets errors. + * See TranslateSocketError() when changing this list. + */ +#undef EAGAIN +#define EAGAIN WSAEWOULDBLOCK +#undef EINTR +#define EINTR WSAEINTR +#undef EMSGSIZE +#define EMSGSIZE WSAEMSGSIZE +#undef EAFNOSUPPORT +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#undef EWOULDBLOCK +#define EWOULDBLOCK WSAEWOULDBLOCK +#undef ECONNABORTED +#define ECONNABORTED WSAECONNABORTED +#undef ECONNRESET +#define ECONNRESET WSAECONNRESET +#undef EINPROGRESS +#define EINPROGRESS WSAEINPROGRESS +#undef EISCONN +#define EISCONN WSAEISCONN +#undef ENOBUFS +#define ENOBUFS WSAENOBUFS +#undef EPROTONOSUPPORT +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#undef ECONNREFUSED +#define ECONNREFUSED WSAECONNREFUSED +#undef ENOTSOCK +#define ENOTSOCK WSAENOTSOCK +#undef EOPNOTSUPP +#define EOPNOTSUPP WSAEOPNOTSUPP +#undef EADDRINUSE +#define EADDRINUSE WSAEADDRINUSE +#undef EADDRNOTAVAIL +#define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#undef EHOSTDOWN +#define EHOSTDOWN WSAEHOSTDOWN +#undef EHOSTUNREACH +#define EHOSTUNREACH WSAEHOSTUNREACH +#undef ENETDOWN +#define ENETDOWN WSAENETDOWN +#undef ENETRESET +#define ENETRESET WSAENETRESET +#undef ENETUNREACH +#define ENETUNREACH WSAENETUNREACH +#undef ENOTCONN +#define ENOTCONN WSAENOTCONN +#undef ETIMEDOUT +#define ETIMEDOUT WSAETIMEDOUT + +/* + * Locale stuff. + * + * Extended locale functions with gratuitous underscore prefixes. + * (These APIs are nevertheless fully documented by Microsoft.) + */ +#define locale_t _locale_t +#define tolower_l _tolower_l +#define toupper_l _toupper_l +#define towlower_l _towlower_l +#define towupper_l _towupper_l +#define isdigit_l _isdigit_l +#define iswdigit_l _iswdigit_l +#define isalpha_l _isalpha_l +#define iswalpha_l _iswalpha_l +#define isalnum_l _isalnum_l +#define iswalnum_l _iswalnum_l +#define isupper_l _isupper_l +#define iswupper_l _iswupper_l +#define islower_l _islower_l +#define iswlower_l _iswlower_l +#define isgraph_l _isgraph_l +#define iswgraph_l _iswgraph_l +#define isprint_l _isprint_l +#define iswprint_l _iswprint_l +#define ispunct_l _ispunct_l +#define iswpunct_l _iswpunct_l +#define isspace_l _isspace_l +#define iswspace_l _iswspace_l +#define strcoll_l _strcoll_l +#define strxfrm_l _strxfrm_l +#define wcscoll_l _wcscoll_l +#define wcstombs_l _wcstombs_l +#define mbstowcs_l _mbstowcs_l + +/* + * Versions of libintl >= 0.18? try to replace setlocale() with a macro + * to their own versions. Remove the macro, if it exists, because it + * ends up calling the wrong version when the backend and libintl use + * different versions of msvcrt. + */ +#if defined(setlocale) +#undef setlocale +#endif + +/* + * Define our own wrapper macro around setlocale() to work around bugs in + * Windows' native setlocale() function. + */ +extern char *pgwin32_setlocale(int category, const char *locale); + +#define setlocale(a,b) pgwin32_setlocale(a,b) + + +/* In backend/port/win32/signal.c */ +extern PGDLLIMPORT __thread volatile int pg_signal_queue; +extern PGDLLIMPORT __thread int pg_signal_mask; +extern PGDLLIMPORT HANDLE pgwin32_signal_event; +extern PGDLLIMPORT HANDLE pgwin32_initial_signal_pipe; + +#define UNBLOCKED_SIGNAL_QUEUE() (pg_signal_queue & ~pg_signal_mask) +#define PG_SIGNAL_COUNT 32 + +extern void pgwin32_signal_initialize(void); +extern HANDLE pgwin32_create_signal_listener(pid_t pid); +extern void pgwin32_dispatch_queued_signals(void); +extern void pg_queue_signal(int signum); + +/* In src/port/kill.c */ +#define kill(pid,sig) pgkill(pid,sig) +extern int pgkill(int pid, int sig); + +/* In backend/port/win32/socket.c */ +#ifndef FRONTEND +#define socket(af, type, protocol) pgwin32_socket(af, type, protocol) +#define bind(s, addr, addrlen) pgwin32_bind(s, addr, addrlen) +#define listen(s, backlog) pgwin32_listen(s, backlog) +#define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen) +#define connect(s, name, namelen) pgwin32_connect(s, name, namelen) +#define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout) +#define recv(s, buf, len, flags) pgwin32_recv(s, buf, len, flags) +#define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags) + +extern SOCKET pgwin32_socket(int af, int type, int protocol); +extern int pgwin32_bind(SOCKET s, struct sockaddr *addr, int addrlen); +extern int pgwin32_listen(SOCKET s, int backlog); +extern SOCKET pgwin32_accept(SOCKET s, struct sockaddr *addr, int *addrlen); +extern int pgwin32_connect(SOCKET s, const struct sockaddr *name, int namelen); +extern int pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout); +extern int pgwin32_recv(SOCKET s, char *buf, int len, int flags); +extern int pgwin32_send(SOCKET s, const void *buf, int len, int flags); +extern int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout); + +extern PGDLLIMPORT int pgwin32_noblock; + +#endif /* FRONTEND */ + +/* in backend/port/win32_shmem.c */ +extern int pgwin32_ReserveSharedMemoryRegion(HANDLE); + +/* in backend/port/win32/crashdump.c */ +extern void pgwin32_install_crashdump_handler(void); + +/* in port/win32dlopen.c */ +extern void *dlopen(const char *file, int mode); +extern void *dlsym(void *handle, const char *symbol); +extern int dlclose(void *handle); +extern char *dlerror(void); + +#define RTLD_NOW 1 +#define RTLD_GLOBAL 0 + +/* in port/win32error.c */ +extern void _dosmaperr(unsigned long); + +/* in port/win32env.c */ +extern int pgwin32_putenv(const char *); +extern int pgwin32_setenv(const char *name, const char *value, int overwrite); +extern int pgwin32_unsetenv(const char *name); + +#define putenv(x) pgwin32_putenv(x) +#define setenv(x,y,z) pgwin32_setenv(x,y,z) +#define unsetenv(x) pgwin32_unsetenv(x) + +/* in port/win32security.c */ +extern int pgwin32_is_service(void); +extern int pgwin32_is_admin(void); + +/* Windows security token manipulation (in src/common/exec.c) */ +extern BOOL AddUserToTokenDacl(HANDLE hToken); + +/* Things that exist in MinGW headers, but need to be added to MSVC */ +#ifdef _MSC_VER + +#ifndef _WIN64 +typedef long ssize_t; +#else +typedef __int64 ssize_t; +#endif + +typedef unsigned short mode_t; + +#define F_OK 0 +#define W_OK 2 +#define R_OK 4 + +#endif /* _MSC_VER */ + +#if defined(__MINGW32__) || defined(__MINGW64__) +/* + * Mingw claims to have a strtof, and my reading of its source code suggests + * that it ought to work (and not need this hack), but the regression test + * results disagree with me; whether this is a version issue or not is not + * clear. However, using our wrapper (and the misrounded-input variant file, + * already required for supporting ancient systems) can't make things any + * worse, except for a tiny performance loss when reading zeros. + * + * See also cygwin.h for another instance of this. + */ +#define HAVE_BUGGY_STRTOF 1 +#endif + +/* in port/win32pread.c */ +extern ssize_t pg_pread(int fd, void *buf, size_t nbyte, off_t offset); + +/* in port/win32pwrite.c */ +extern ssize_t pg_pwrite(int fd, const void *buf, size_t nbyte, off_t offset); + +#endif /* PG_WIN32_PORT_H */ diff --git a/parser/include/portability/instr_time.h b/parser/include/postgres/portability/instr_time.h similarity index 100% rename from parser/include/portability/instr_time.h rename to parser/include/postgres/portability/instr_time.h diff --git a/parser/include/postgres.h b/parser/include/postgres/postgres.h similarity index 100% rename from parser/include/postgres.h rename to parser/include/postgres/postgres.h diff --git a/parser/include/postgres_ext.h b/parser/include/postgres/postgres_ext.h similarity index 100% rename from parser/include/postgres_ext.h rename to parser/include/postgres/postgres_ext.h diff --git a/parser/include/postmaster/autovacuum.h b/parser/include/postgres/postmaster/autovacuum.h similarity index 100% rename from parser/include/postmaster/autovacuum.h rename to parser/include/postgres/postmaster/autovacuum.h diff --git a/parser/include/postmaster/bgworker.h b/parser/include/postgres/postmaster/bgworker.h similarity index 100% rename from parser/include/postmaster/bgworker.h rename to parser/include/postgres/postmaster/bgworker.h diff --git a/parser/include/postmaster/bgworker_internals.h b/parser/include/postgres/postmaster/bgworker_internals.h similarity index 100% rename from parser/include/postmaster/bgworker_internals.h rename to parser/include/postgres/postmaster/bgworker_internals.h diff --git a/parser/include/postmaster/bgwriter.h b/parser/include/postgres/postmaster/bgwriter.h similarity index 100% rename from parser/include/postmaster/bgwriter.h rename to parser/include/postgres/postmaster/bgwriter.h diff --git a/parser/include/postmaster/interrupt.h b/parser/include/postgres/postmaster/interrupt.h similarity index 100% rename from parser/include/postmaster/interrupt.h rename to parser/include/postgres/postmaster/interrupt.h diff --git a/parser/include/postmaster/pgarch.h b/parser/include/postgres/postmaster/pgarch.h similarity index 100% rename from parser/include/postmaster/pgarch.h rename to parser/include/postgres/postmaster/pgarch.h diff --git a/parser/include/postmaster/postmaster.h b/parser/include/postgres/postmaster/postmaster.h similarity index 98% rename from parser/include/postmaster/postmaster.h rename to parser/include/postgres/postmaster/postmaster.h index cdee1968..3b3889c5 100644 --- a/parser/include/postmaster/postmaster.h +++ b/parser/include/postgres/postmaster/postmaster.h @@ -22,7 +22,7 @@ extern PGDLLIMPORT int Unix_socket_permissions; extern PGDLLIMPORT char *Unix_socket_group; extern PGDLLIMPORT char *Unix_socket_directories; extern PGDLLIMPORT char *ListenAddresses; -extern PGDLLIMPORT __thread bool ClientAuthInProgress; +extern PGDLLIMPORT bool ClientAuthInProgress; extern PGDLLIMPORT int PreAuthDelay; extern PGDLLIMPORT int AuthenticationTimeout; extern PGDLLIMPORT bool Log_connections; diff --git a/parser/include/postmaster/startup.h b/parser/include/postgres/postmaster/startup.h similarity index 100% rename from parser/include/postmaster/startup.h rename to parser/include/postgres/postmaster/startup.h diff --git a/parser/include/postmaster/syslogger.h b/parser/include/postgres/postmaster/syslogger.h similarity index 100% rename from parser/include/postmaster/syslogger.h rename to parser/include/postgres/postmaster/syslogger.h diff --git a/parser/include/postmaster/walwriter.h b/parser/include/postgres/postmaster/walwriter.h similarity index 100% rename from parser/include/postmaster/walwriter.h rename to parser/include/postgres/postmaster/walwriter.h diff --git a/parser/include/regex/regex.h b/parser/include/postgres/regex/regex.h similarity index 100% rename from parser/include/regex/regex.h rename to parser/include/postgres/regex/regex.h diff --git a/parser/include/replication/logicallauncher.h b/parser/include/postgres/replication/logicallauncher.h similarity index 100% rename from parser/include/replication/logicallauncher.h rename to parser/include/postgres/replication/logicallauncher.h diff --git a/parser/include/replication/logicalproto.h b/parser/include/postgres/replication/logicalproto.h similarity index 100% rename from parser/include/replication/logicalproto.h rename to parser/include/postgres/replication/logicalproto.h diff --git a/parser/include/replication/logicalworker.h b/parser/include/postgres/replication/logicalworker.h similarity index 100% rename from parser/include/replication/logicalworker.h rename to parser/include/postgres/replication/logicalworker.h diff --git a/parser/include/replication/origin.h b/parser/include/postgres/replication/origin.h similarity index 100% rename from parser/include/replication/origin.h rename to parser/include/postgres/replication/origin.h diff --git a/parser/include/replication/reorderbuffer.h b/parser/include/postgres/replication/reorderbuffer.h similarity index 100% rename from parser/include/replication/reorderbuffer.h rename to parser/include/postgres/replication/reorderbuffer.h diff --git a/parser/include/replication/slot.h b/parser/include/postgres/replication/slot.h similarity index 100% rename from parser/include/replication/slot.h rename to parser/include/postgres/replication/slot.h diff --git a/parser/include/replication/syncrep.h b/parser/include/postgres/replication/syncrep.h similarity index 100% rename from parser/include/replication/syncrep.h rename to parser/include/postgres/replication/syncrep.h diff --git a/parser/include/replication/walreceiver.h b/parser/include/postgres/replication/walreceiver.h similarity index 100% rename from parser/include/replication/walreceiver.h rename to parser/include/postgres/replication/walreceiver.h diff --git a/parser/include/replication/walsender.h b/parser/include/postgres/replication/walsender.h similarity index 100% rename from parser/include/replication/walsender.h rename to parser/include/postgres/replication/walsender.h diff --git a/parser/include/rewrite/prs2lock.h b/parser/include/postgres/rewrite/prs2lock.h similarity index 100% rename from parser/include/rewrite/prs2lock.h rename to parser/include/postgres/rewrite/prs2lock.h diff --git a/parser/include/rewrite/rewriteHandler.h b/parser/include/postgres/rewrite/rewriteHandler.h similarity index 100% rename from parser/include/rewrite/rewriteHandler.h rename to parser/include/postgres/rewrite/rewriteHandler.h diff --git a/parser/include/rewrite/rewriteManip.h b/parser/include/postgres/rewrite/rewriteManip.h similarity index 100% rename from parser/include/rewrite/rewriteManip.h rename to parser/include/postgres/rewrite/rewriteManip.h diff --git a/parser/include/rewrite/rewriteSupport.h b/parser/include/postgres/rewrite/rewriteSupport.h similarity index 100% rename from parser/include/rewrite/rewriteSupport.h rename to parser/include/postgres/rewrite/rewriteSupport.h diff --git a/parser/include/storage/backendid.h b/parser/include/postgres/storage/backendid.h similarity index 100% rename from parser/include/storage/backendid.h rename to parser/include/postgres/storage/backendid.h diff --git a/parser/include/storage/block.h b/parser/include/postgres/storage/block.h similarity index 100% rename from parser/include/storage/block.h rename to parser/include/postgres/storage/block.h diff --git a/parser/include/storage/buf.h b/parser/include/postgres/storage/buf.h similarity index 100% rename from parser/include/storage/buf.h rename to parser/include/postgres/storage/buf.h diff --git a/parser/include/storage/bufmgr.h b/parser/include/postgres/storage/bufmgr.h similarity index 100% rename from parser/include/storage/bufmgr.h rename to parser/include/postgres/storage/bufmgr.h diff --git a/parser/include/storage/bufpage.h b/parser/include/postgres/storage/bufpage.h similarity index 100% rename from parser/include/storage/bufpage.h rename to parser/include/postgres/storage/bufpage.h diff --git a/parser/include/storage/condition_variable.h b/parser/include/postgres/storage/condition_variable.h similarity index 100% rename from parser/include/storage/condition_variable.h rename to parser/include/postgres/storage/condition_variable.h diff --git a/parser/include/storage/dsm.h b/parser/include/postgres/storage/dsm.h similarity index 100% rename from parser/include/storage/dsm.h rename to parser/include/postgres/storage/dsm.h diff --git a/parser/include/storage/dsm_impl.h b/parser/include/postgres/storage/dsm_impl.h similarity index 100% rename from parser/include/storage/dsm_impl.h rename to parser/include/postgres/storage/dsm_impl.h diff --git a/parser/include/storage/fd.h b/parser/include/postgres/storage/fd.h similarity index 100% rename from parser/include/storage/fd.h rename to parser/include/postgres/storage/fd.h diff --git a/parser/include/storage/fileset.h b/parser/include/postgres/storage/fileset.h similarity index 100% rename from parser/include/storage/fileset.h rename to parser/include/postgres/storage/fileset.h diff --git a/parser/include/storage/ipc.h b/parser/include/postgres/storage/ipc.h similarity index 98% rename from parser/include/storage/ipc.h rename to parser/include/postgres/storage/ipc.h index 53714afd..91bbc58e 100644 --- a/parser/include/storage/ipc.h +++ b/parser/include/postgres/storage/ipc.h @@ -62,7 +62,7 @@ typedef void (*shmem_startup_hook_type) (void); /* ipc.c */ -extern PGDLLIMPORT __thread bool proc_exit_inprogress; +extern PGDLLIMPORT __thread bool proc_exit_inprogress; extern PGDLLIMPORT bool shmem_exit_inprogress; extern void proc_exit(int code) pg_attribute_noreturn(); diff --git a/parser/include/storage/item.h b/parser/include/postgres/storage/item.h similarity index 100% rename from parser/include/storage/item.h rename to parser/include/postgres/storage/item.h diff --git a/parser/include/storage/itemid.h b/parser/include/postgres/storage/itemid.h similarity index 100% rename from parser/include/storage/itemid.h rename to parser/include/postgres/storage/itemid.h diff --git a/parser/include/storage/itemptr.h b/parser/include/postgres/storage/itemptr.h similarity index 100% rename from parser/include/storage/itemptr.h rename to parser/include/postgres/storage/itemptr.h diff --git a/parser/include/storage/large_object.h b/parser/include/postgres/storage/large_object.h similarity index 100% rename from parser/include/storage/large_object.h rename to parser/include/postgres/storage/large_object.h diff --git a/parser/include/storage/latch.h b/parser/include/postgres/storage/latch.h similarity index 100% rename from parser/include/storage/latch.h rename to parser/include/postgres/storage/latch.h diff --git a/parser/include/storage/lmgr.h b/parser/include/postgres/storage/lmgr.h similarity index 100% rename from parser/include/storage/lmgr.h rename to parser/include/postgres/storage/lmgr.h diff --git a/parser/include/storage/lock.h b/parser/include/postgres/storage/lock.h similarity index 100% rename from parser/include/storage/lock.h rename to parser/include/postgres/storage/lock.h diff --git a/parser/include/storage/lockdefs.h b/parser/include/postgres/storage/lockdefs.h similarity index 100% rename from parser/include/storage/lockdefs.h rename to parser/include/postgres/storage/lockdefs.h diff --git a/parser/include/storage/lwlock.h b/parser/include/postgres/storage/lwlock.h similarity index 100% rename from parser/include/storage/lwlock.h rename to parser/include/postgres/storage/lwlock.h diff --git a/parser/include/storage/lwlocknames.h b/parser/include/postgres/storage/lwlocknames.h similarity index 100% rename from parser/include/storage/lwlocknames.h rename to parser/include/postgres/storage/lwlocknames.h diff --git a/parser/include/storage/off.h b/parser/include/postgres/storage/off.h similarity index 100% rename from parser/include/storage/off.h rename to parser/include/postgres/storage/off.h diff --git a/parser/include/storage/pg_sema.h b/parser/include/postgres/storage/pg_sema.h similarity index 100% rename from parser/include/storage/pg_sema.h rename to parser/include/postgres/storage/pg_sema.h diff --git a/parser/include/storage/pg_shmem.h b/parser/include/postgres/storage/pg_shmem.h similarity index 100% rename from parser/include/storage/pg_shmem.h rename to parser/include/postgres/storage/pg_shmem.h diff --git a/parser/include/storage/pmsignal.h b/parser/include/postgres/storage/pmsignal.h similarity index 100% rename from parser/include/storage/pmsignal.h rename to parser/include/postgres/storage/pmsignal.h diff --git a/parser/include/storage/predicate.h b/parser/include/postgres/storage/predicate.h similarity index 100% rename from parser/include/storage/predicate.h rename to parser/include/postgres/storage/predicate.h diff --git a/parser/include/storage/proc.h b/parser/include/postgres/storage/proc.h similarity index 100% rename from parser/include/storage/proc.h rename to parser/include/postgres/storage/proc.h diff --git a/parser/include/storage/procarray.h b/parser/include/postgres/storage/procarray.h similarity index 100% rename from parser/include/storage/procarray.h rename to parser/include/postgres/storage/procarray.h diff --git a/parser/include/storage/proclist_types.h b/parser/include/postgres/storage/proclist_types.h similarity index 100% rename from parser/include/storage/proclist_types.h rename to parser/include/postgres/storage/proclist_types.h diff --git a/parser/include/storage/procsignal.h b/parser/include/postgres/storage/procsignal.h similarity index 100% rename from parser/include/storage/procsignal.h rename to parser/include/postgres/storage/procsignal.h diff --git a/parser/include/storage/relfilelocator.h b/parser/include/postgres/storage/relfilelocator.h similarity index 100% rename from parser/include/storage/relfilelocator.h rename to parser/include/postgres/storage/relfilelocator.h diff --git a/parser/include/storage/s_lock.h b/parser/include/postgres/storage/s_lock.h similarity index 100% rename from parser/include/storage/s_lock.h rename to parser/include/postgres/storage/s_lock.h diff --git a/parser/include/storage/sharedfileset.h b/parser/include/postgres/storage/sharedfileset.h similarity index 100% rename from parser/include/storage/sharedfileset.h rename to parser/include/postgres/storage/sharedfileset.h diff --git a/parser/include/storage/shm_mq.h b/parser/include/postgres/storage/shm_mq.h similarity index 100% rename from parser/include/storage/shm_mq.h rename to parser/include/postgres/storage/shm_mq.h diff --git a/parser/include/storage/shm_toc.h b/parser/include/postgres/storage/shm_toc.h similarity index 100% rename from parser/include/storage/shm_toc.h rename to parser/include/postgres/storage/shm_toc.h diff --git a/parser/include/storage/shmem.h b/parser/include/postgres/storage/shmem.h similarity index 100% rename from parser/include/storage/shmem.h rename to parser/include/postgres/storage/shmem.h diff --git a/parser/include/storage/sinval.h b/parser/include/postgres/storage/sinval.h similarity index 100% rename from parser/include/storage/sinval.h rename to parser/include/postgres/storage/sinval.h diff --git a/parser/include/storage/sinvaladt.h b/parser/include/postgres/storage/sinvaladt.h similarity index 100% rename from parser/include/storage/sinvaladt.h rename to parser/include/postgres/storage/sinvaladt.h diff --git a/parser/include/storage/smgr.h b/parser/include/postgres/storage/smgr.h similarity index 100% rename from parser/include/storage/smgr.h rename to parser/include/postgres/storage/smgr.h diff --git a/parser/include/storage/spin.h b/parser/include/postgres/storage/spin.h similarity index 100% rename from parser/include/storage/spin.h rename to parser/include/postgres/storage/spin.h diff --git a/parser/include/storage/standby.h b/parser/include/postgres/storage/standby.h similarity index 100% rename from parser/include/storage/standby.h rename to parser/include/postgres/storage/standby.h diff --git a/parser/include/storage/standbydefs.h b/parser/include/postgres/storage/standbydefs.h similarity index 100% rename from parser/include/storage/standbydefs.h rename to parser/include/postgres/storage/standbydefs.h diff --git a/parser/include/storage/sync.h b/parser/include/postgres/storage/sync.h similarity index 100% rename from parser/include/storage/sync.h rename to parser/include/postgres/storage/sync.h diff --git a/parser/include/tcop/cmdtag.h b/parser/include/postgres/tcop/cmdtag.h similarity index 100% rename from parser/include/tcop/cmdtag.h rename to parser/include/postgres/tcop/cmdtag.h diff --git a/parser/include/tcop/cmdtaglist.h b/parser/include/postgres/tcop/cmdtaglist.h similarity index 100% rename from parser/include/tcop/cmdtaglist.h rename to parser/include/postgres/tcop/cmdtaglist.h diff --git a/parser/include/tcop/deparse_utility.h b/parser/include/postgres/tcop/deparse_utility.h similarity index 100% rename from parser/include/tcop/deparse_utility.h rename to parser/include/postgres/tcop/deparse_utility.h diff --git a/parser/include/tcop/dest.h b/parser/include/postgres/tcop/dest.h similarity index 100% rename from parser/include/tcop/dest.h rename to parser/include/postgres/tcop/dest.h diff --git a/parser/include/tcop/fastpath.h b/parser/include/postgres/tcop/fastpath.h similarity index 100% rename from parser/include/tcop/fastpath.h rename to parser/include/postgres/tcop/fastpath.h diff --git a/parser/include/tcop/pquery.h b/parser/include/postgres/tcop/pquery.h similarity index 100% rename from parser/include/tcop/pquery.h rename to parser/include/postgres/tcop/pquery.h diff --git a/parser/include/tcop/tcopprot.h b/parser/include/postgres/tcop/tcopprot.h similarity index 96% rename from parser/include/tcop/tcopprot.h rename to parser/include/postgres/tcop/tcopprot.h index 7c4670eb..3976568b 100644 --- a/parser/include/tcop/tcopprot.h +++ b/parser/include/postgres/tcop/tcopprot.h @@ -25,9 +25,9 @@ /* Required daylight between max_stack_depth and the kernel limit, in bytes */ #define STACK_DEPTH_SLOP (512 * 1024L) -extern PGDLLIMPORT __thread CommandDest whereToSendOutput; +extern PGDLLIMPORT __thread CommandDest whereToSendOutput; extern PGDLLIMPORT __thread const char *debug_query_string; -extern PGDLLIMPORT __thread int max_stack_depth; +extern PGDLLIMPORT __thread int max_stack_depth; extern PGDLLIMPORT int PostAuthDelay; extern PGDLLIMPORT int client_connection_check_interval; diff --git a/parser/include/tcop/utility.h b/parser/include/postgres/tcop/utility.h similarity index 100% rename from parser/include/tcop/utility.h rename to parser/include/postgres/tcop/utility.h diff --git a/parser/include/tsearch/ts_cache.h b/parser/include/postgres/tsearch/ts_cache.h similarity index 100% rename from parser/include/tsearch/ts_cache.h rename to parser/include/postgres/tsearch/ts_cache.h diff --git a/parser/include/utils/acl.h b/parser/include/postgres/utils/acl.h similarity index 100% rename from parser/include/utils/acl.h rename to parser/include/postgres/utils/acl.h diff --git a/parser/include/utils/aclchk_internal.h b/parser/include/postgres/utils/aclchk_internal.h similarity index 100% rename from parser/include/utils/aclchk_internal.h rename to parser/include/postgres/utils/aclchk_internal.h diff --git a/parser/include/utils/array.h b/parser/include/postgres/utils/array.h similarity index 100% rename from parser/include/utils/array.h rename to parser/include/postgres/utils/array.h diff --git a/parser/include/utils/backend_progress.h b/parser/include/postgres/utils/backend_progress.h similarity index 100% rename from parser/include/utils/backend_progress.h rename to parser/include/postgres/utils/backend_progress.h diff --git a/parser/include/utils/backend_status.h b/parser/include/postgres/utils/backend_status.h similarity index 100% rename from parser/include/utils/backend_status.h rename to parser/include/postgres/utils/backend_status.h diff --git a/parser/include/utils/builtins.h b/parser/include/postgres/utils/builtins.h similarity index 98% rename from parser/include/utils/builtins.h rename to parser/include/postgres/utils/builtins.h index 1c665691..864e902f 100644 --- a/parser/include/utils/builtins.h +++ b/parser/include/postgres/utils/builtins.h @@ -73,7 +73,7 @@ extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive, Oid collation, bool *exact); /* ruleutils.c */ -extern PGDLLIMPORT __thread bool quote_all_identifiers; +extern PGDLLIMPORT __thread bool quote_all_identifiers; extern const char *quote_identifier(const char *ident); extern char *quote_qualified_identifier(const char *qualifier, const char *ident); diff --git a/parser/include/utils/bytea.h b/parser/include/postgres/utils/bytea.h similarity index 100% rename from parser/include/utils/bytea.h rename to parser/include/postgres/utils/bytea.h diff --git a/parser/include/utils/catcache.h b/parser/include/postgres/utils/catcache.h similarity index 100% rename from parser/include/utils/catcache.h rename to parser/include/postgres/utils/catcache.h diff --git a/parser/include/utils/date.h b/parser/include/postgres/utils/date.h similarity index 100% rename from parser/include/utils/date.h rename to parser/include/postgres/utils/date.h diff --git a/parser/include/utils/datetime.h b/parser/include/postgres/utils/datetime.h similarity index 100% rename from parser/include/utils/datetime.h rename to parser/include/postgres/utils/datetime.h diff --git a/parser/include/utils/datum.h b/parser/include/postgres/utils/datum.h similarity index 100% rename from parser/include/utils/datum.h rename to parser/include/postgres/utils/datum.h diff --git a/parser/include/utils/dsa.h b/parser/include/postgres/utils/dsa.h similarity index 100% rename from parser/include/utils/dsa.h rename to parser/include/postgres/utils/dsa.h diff --git a/parser/include/utils/elog.h b/parser/include/postgres/utils/elog.h similarity index 99% rename from parser/include/utils/elog.h rename to parser/include/postgres/utils/elog.h index 6acc2c25..7655196c 100644 --- a/parser/include/utils/elog.h +++ b/parser/include/postgres/utils/elog.h @@ -311,7 +311,7 @@ typedef struct ErrorContextCallback void *arg; } ErrorContextCallback; -extern PGDLLIMPORT __thread ErrorContextCallback *error_context_stack; +extern PGDLLIMPORT __thread ErrorContextCallback *error_context_stack; /*---------- @@ -426,7 +426,7 @@ extern PGDLLIMPORT __thread ErrorContextCallback *error_context_stack; (pg_re_throw(), pg_unreachable()) #endif -extern PGDLLIMPORT __thread sigjmp_buf *PG_exception_stack; +extern PGDLLIMPORT __thread sigjmp_buf *PG_exception_stack; /* Stuff that error handlers might want to use */ @@ -483,7 +483,7 @@ extern char *GetErrorContextStack(void); /* Hook for intercepting messages before they are sent to the server log */ typedef void (*emit_log_hook_type) (ErrorData *edata); -extern PGDLLIMPORT __thread emit_log_hook_type emit_log_hook; +extern PGDLLIMPORT __thread emit_log_hook_type emit_log_hook; /* GUC-configurable parameters */ diff --git a/parser/include/utils/errcodes.h b/parser/include/postgres/utils/errcodes.h similarity index 100% rename from parser/include/utils/errcodes.h rename to parser/include/postgres/utils/errcodes.h diff --git a/parser/include/utils/expandeddatum.h b/parser/include/postgres/utils/expandeddatum.h similarity index 100% rename from parser/include/utils/expandeddatum.h rename to parser/include/postgres/utils/expandeddatum.h diff --git a/parser/include/utils/expandedrecord.h b/parser/include/postgres/utils/expandedrecord.h similarity index 100% rename from parser/include/utils/expandedrecord.h rename to parser/include/postgres/utils/expandedrecord.h diff --git a/parser/include/utils/float.h b/parser/include/postgres/utils/float.h similarity index 100% rename from parser/include/utils/float.h rename to parser/include/postgres/utils/float.h diff --git a/parser/include/utils/fmgroids.h b/parser/include/postgres/utils/fmgroids.h similarity index 100% rename from parser/include/utils/fmgroids.h rename to parser/include/postgres/utils/fmgroids.h diff --git a/parser/include/utils/fmgrprotos.h b/parser/include/postgres/utils/fmgrprotos.h similarity index 100% rename from parser/include/utils/fmgrprotos.h rename to parser/include/postgres/utils/fmgrprotos.h diff --git a/parser/include/utils/fmgrtab.h b/parser/include/postgres/utils/fmgrtab.h similarity index 100% rename from parser/include/utils/fmgrtab.h rename to parser/include/postgres/utils/fmgrtab.h diff --git a/parser/include/utils/guc.h b/parser/include/postgres/utils/guc.h similarity index 98% rename from parser/include/utils/guc.h rename to parser/include/postgres/utils/guc.h index 2355fc2d..9410f3d1 100644 --- a/parser/include/utils/guc.h +++ b/parser/include/postgres/utils/guc.h @@ -249,21 +249,21 @@ extern PGDLLIMPORT bool log_executor_stats; extern PGDLLIMPORT bool log_statement_stats; extern PGDLLIMPORT bool log_btree_build_stats; -extern PGDLLIMPORT __thread bool check_function_bodies; +extern PGDLLIMPORT __thread bool check_function_bodies; extern PGDLLIMPORT bool session_auth_is_superuser; extern PGDLLIMPORT bool log_duration; extern PGDLLIMPORT int log_parameter_max_length; extern PGDLLIMPORT int log_parameter_max_length_on_error; extern PGDLLIMPORT int log_min_error_statement; -extern PGDLLIMPORT __thread int log_min_messages; -extern PGDLLIMPORT __thread int client_min_messages; +extern PGDLLIMPORT __thread int log_min_messages; +extern PGDLLIMPORT int client_min_messages; extern PGDLLIMPORT int log_min_duration_sample; extern PGDLLIMPORT int log_min_duration_statement; extern PGDLLIMPORT int log_temp_files; extern PGDLLIMPORT double log_statement_sample_rate; extern PGDLLIMPORT double log_xact_sample_rate; -extern PGDLLIMPORT __thread char *backtrace_functions; +extern PGDLLIMPORT __thread char *backtrace_functions; extern PGDLLIMPORT int temp_file_limit; diff --git a/parser/include/utils/guc_hooks.h b/parser/include/postgres/utils/guc_hooks.h similarity index 100% rename from parser/include/utils/guc_hooks.h rename to parser/include/postgres/utils/guc_hooks.h diff --git a/parser/include/utils/guc_tables.h b/parser/include/postgres/utils/guc_tables.h similarity index 100% rename from parser/include/utils/guc_tables.h rename to parser/include/postgres/utils/guc_tables.h diff --git a/parser/include/utils/hsearch.h b/parser/include/postgres/utils/hsearch.h similarity index 100% rename from parser/include/utils/hsearch.h rename to parser/include/postgres/utils/hsearch.h diff --git a/parser/include/utils/inval.h b/parser/include/postgres/utils/inval.h similarity index 100% rename from parser/include/utils/inval.h rename to parser/include/postgres/utils/inval.h diff --git a/parser/include/utils/logtape.h b/parser/include/postgres/utils/logtape.h similarity index 100% rename from parser/include/utils/logtape.h rename to parser/include/postgres/utils/logtape.h diff --git a/parser/include/utils/lsyscache.h b/parser/include/postgres/utils/lsyscache.h similarity index 100% rename from parser/include/utils/lsyscache.h rename to parser/include/postgres/utils/lsyscache.h diff --git a/parser/include/utils/memdebug.h b/parser/include/postgres/utils/memdebug.h similarity index 100% rename from parser/include/utils/memdebug.h rename to parser/include/postgres/utils/memdebug.h diff --git a/parser/include/utils/memutils.h b/parser/include/postgres/utils/memutils.h similarity index 98% rename from parser/include/utils/memutils.h rename to parser/include/postgres/utils/memutils.h index 01275a1e..2fcf6cce 100644 --- a/parser/include/utils/memutils.h +++ b/parser/include/postgres/utils/memutils.h @@ -55,8 +55,8 @@ * Only TopMemoryContext and ErrorContext are initialized by * MemoryContextInit() itself. */ -extern PGDLLIMPORT __thread MemoryContext TopMemoryContext; -extern PGDLLIMPORT __thread MemoryContext ErrorContext; +extern PGDLLIMPORT __thread MemoryContext TopMemoryContext; +extern PGDLLIMPORT __thread MemoryContext ErrorContext; extern PGDLLIMPORT MemoryContext PostmasterContext; extern PGDLLIMPORT MemoryContext CacheMemoryContext; extern PGDLLIMPORT MemoryContext MessageContext; diff --git a/parser/include/utils/memutils_internal.h b/parser/include/postgres/utils/memutils_internal.h similarity index 100% rename from parser/include/utils/memutils_internal.h rename to parser/include/postgres/utils/memutils_internal.h diff --git a/parser/include/utils/memutils_memorychunk.h b/parser/include/postgres/utils/memutils_memorychunk.h similarity index 100% rename from parser/include/utils/memutils_memorychunk.h rename to parser/include/postgres/utils/memutils_memorychunk.h diff --git a/parser/include/utils/numeric.h b/parser/include/postgres/utils/numeric.h similarity index 100% rename from parser/include/utils/numeric.h rename to parser/include/postgres/utils/numeric.h diff --git a/parser/include/utils/palloc.h b/parser/include/postgres/utils/palloc.h similarity index 98% rename from parser/include/utils/palloc.h rename to parser/include/postgres/utils/palloc.h index 90a7684d..dd3748bd 100644 --- a/parser/include/utils/palloc.h +++ b/parser/include/postgres/utils/palloc.h @@ -56,7 +56,7 @@ typedef struct MemoryContextCallback * Avoid accessing it directly! Instead, use MemoryContextSwitchTo() * to change the setting. */ -extern PGDLLIMPORT __thread MemoryContext CurrentMemoryContext; +extern PGDLLIMPORT __thread MemoryContext CurrentMemoryContext; /* * Flags for MemoryContextAllocExtended. diff --git a/parser/include/utils/partcache.h b/parser/include/postgres/utils/partcache.h similarity index 100% rename from parser/include/utils/partcache.h rename to parser/include/postgres/utils/partcache.h diff --git a/parser/include/utils/pg_locale.h b/parser/include/postgres/utils/pg_locale.h similarity index 100% rename from parser/include/utils/pg_locale.h rename to parser/include/postgres/utils/pg_locale.h diff --git a/parser/include/utils/pgstat_internal.h b/parser/include/postgres/utils/pgstat_internal.h similarity index 100% rename from parser/include/utils/pgstat_internal.h rename to parser/include/postgres/utils/pgstat_internal.h diff --git a/parser/include/utils/plancache.h b/parser/include/postgres/utils/plancache.h similarity index 100% rename from parser/include/utils/plancache.h rename to parser/include/postgres/utils/plancache.h diff --git a/parser/include/utils/portal.h b/parser/include/postgres/utils/portal.h similarity index 100% rename from parser/include/utils/portal.h rename to parser/include/postgres/utils/portal.h diff --git a/parser/include/utils/probes.h b/parser/include/postgres/utils/probes.h similarity index 100% rename from parser/include/utils/probes.h rename to parser/include/postgres/utils/probes.h diff --git a/parser/include/utils/ps_status.h b/parser/include/postgres/utils/ps_status.h similarity index 100% rename from parser/include/utils/ps_status.h rename to parser/include/postgres/utils/ps_status.h diff --git a/parser/include/utils/queryenvironment.h b/parser/include/postgres/utils/queryenvironment.h similarity index 100% rename from parser/include/utils/queryenvironment.h rename to parser/include/postgres/utils/queryenvironment.h diff --git a/parser/include/utils/regproc.h b/parser/include/postgres/utils/regproc.h similarity index 100% rename from parser/include/utils/regproc.h rename to parser/include/postgres/utils/regproc.h diff --git a/parser/include/utils/rel.h b/parser/include/postgres/utils/rel.h similarity index 100% rename from parser/include/utils/rel.h rename to parser/include/postgres/utils/rel.h diff --git a/parser/include/utils/relcache.h b/parser/include/postgres/utils/relcache.h similarity index 100% rename from parser/include/utils/relcache.h rename to parser/include/postgres/utils/relcache.h diff --git a/parser/include/utils/reltrigger.h b/parser/include/postgres/utils/reltrigger.h similarity index 100% rename from parser/include/utils/reltrigger.h rename to parser/include/postgres/utils/reltrigger.h diff --git a/parser/include/utils/resowner.h b/parser/include/postgres/utils/resowner.h similarity index 100% rename from parser/include/utils/resowner.h rename to parser/include/postgres/utils/resowner.h diff --git a/parser/include/utils/ruleutils.h b/parser/include/postgres/utils/ruleutils.h similarity index 100% rename from parser/include/utils/ruleutils.h rename to parser/include/postgres/utils/ruleutils.h diff --git a/parser/include/utils/sharedtuplestore.h b/parser/include/postgres/utils/sharedtuplestore.h similarity index 100% rename from parser/include/utils/sharedtuplestore.h rename to parser/include/postgres/utils/sharedtuplestore.h diff --git a/parser/include/utils/snapmgr.h b/parser/include/postgres/utils/snapmgr.h similarity index 100% rename from parser/include/utils/snapmgr.h rename to parser/include/postgres/utils/snapmgr.h diff --git a/parser/include/utils/snapshot.h b/parser/include/postgres/utils/snapshot.h similarity index 100% rename from parser/include/utils/snapshot.h rename to parser/include/postgres/utils/snapshot.h diff --git a/parser/include/utils/sortsupport.h b/parser/include/postgres/utils/sortsupport.h similarity index 100% rename from parser/include/utils/sortsupport.h rename to parser/include/postgres/utils/sortsupport.h diff --git a/parser/include/utils/syscache.h b/parser/include/postgres/utils/syscache.h similarity index 100% rename from parser/include/utils/syscache.h rename to parser/include/postgres/utils/syscache.h diff --git a/parser/include/utils/timeout.h b/parser/include/postgres/utils/timeout.h similarity index 100% rename from parser/include/utils/timeout.h rename to parser/include/postgres/utils/timeout.h diff --git a/parser/include/utils/timestamp.h b/parser/include/postgres/utils/timestamp.h similarity index 100% rename from parser/include/utils/timestamp.h rename to parser/include/postgres/utils/timestamp.h diff --git a/parser/include/utils/tuplesort.h b/parser/include/postgres/utils/tuplesort.h similarity index 100% rename from parser/include/utils/tuplesort.h rename to parser/include/postgres/utils/tuplesort.h diff --git a/parser/include/utils/tuplestore.h b/parser/include/postgres/utils/tuplestore.h similarity index 100% rename from parser/include/utils/tuplestore.h rename to parser/include/postgres/utils/tuplestore.h diff --git a/parser/include/utils/typcache.h b/parser/include/postgres/utils/typcache.h similarity index 100% rename from parser/include/utils/typcache.h rename to parser/include/postgres/utils/typcache.h diff --git a/parser/include/utils/varlena.h b/parser/include/postgres/utils/varlena.h similarity index 100% rename from parser/include/utils/varlena.h rename to parser/include/postgres/utils/varlena.h diff --git a/parser/include/utils/wait_event.h b/parser/include/postgres/utils/wait_event.h similarity index 100% rename from parser/include/utils/wait_event.h rename to parser/include/postgres/utils/wait_event.h diff --git a/parser/include/utils/xml.h b/parser/include/postgres/utils/xml.h similarity index 100% rename from parser/include/utils/xml.h rename to parser/include/postgres/utils/xml.h diff --git a/parser/include/varatt.h b/parser/include/postgres/varatt.h similarity index 100% rename from parser/include/varatt.h rename to parser/include/postgres/varatt.h diff --git a/parser/include/postmaster/auxprocess.h b/parser/include/postmaster/auxprocess.h deleted file mode 100644 index 5c2d6527..00000000 --- a/parser/include/postmaster/auxprocess.h +++ /dev/null @@ -1,20 +0,0 @@ -/*------------------------------------------------------------------------- - * auxprocess.h - * include file for functions related to auxiliary processes. - * - * - * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * IDENTIFICATION - * src/include/postmaster/auxprocess.h - *------------------------------------------------------------------------- - */ -#ifndef AUXPROCESS_H -#define AUXPROCESS_H - -#include "miscadmin.h" - -extern void AuxiliaryProcessMain(AuxProcType auxtype) pg_attribute_noreturn(); - -#endif /* AUXPROCESS_H */ diff --git a/parser/include/postmaster/fork_process.h b/parser/include/postmaster/fork_process.h deleted file mode 100644 index 12decc81..00000000 --- a/parser/include/postmaster/fork_process.h +++ /dev/null @@ -1,17 +0,0 @@ -/*------------------------------------------------------------------------- - * - * fork_process.h - * Exports from postmaster/fork_process.c. - * - * Copyright (c) 1996-2023, PostgreSQL Global Development Group - * - * src/include/postmaster/fork_process.h - * - *------------------------------------------------------------------------- - */ -#ifndef FORK_PROCESS_H -#define FORK_PROCESS_H - -extern pid_t fork_process(void); - -#endif /* FORK_PROCESS_H */ diff --git a/parser/include/src_backend_nodes_copyfuncs.funcs.c b/parser/include/src_backend_nodes_copyfuncs.funcs.c deleted file mode 100644 index 2a5b27e6..00000000 --- a/parser/include/src_backend_nodes_copyfuncs.funcs.c +++ /dev/null @@ -1,5321 +0,0 @@ -/*-------------------------------------------------------------------- - * Symbols referenced in this file: - * - _copyAlias - * - _copyRangeVar - * - _copyTableFunc - * - _copyIntoClause - * - _copyVar - * - _copyParam - * - _copyAggref - * - _copyGroupingFunc - * - _copyWindowFunc - * - _copySubscriptingRef - * - _copyFuncExpr - * - _copyNamedArgExpr - * - _copyOpExpr - * - _copyDistinctExpr - * - _copyNullIfExpr - * - _copyScalarArrayOpExpr - * - _copyBoolExpr - * - _copySubLink - * - _copySubPlan - * - _copyAlternativeSubPlan - * - _copyFieldSelect - * - _copyFieldStore - * - _copyRelabelType - * - _copyCoerceViaIO - * - _copyArrayCoerceExpr - * - _copyConvertRowtypeExpr - * - _copyCollateExpr - * - _copyCaseExpr - * - _copyCaseWhen - * - _copyCaseTestExpr - * - _copyArrayExpr - * - _copyRowExpr - * - _copyRowCompareExpr - * - _copyCoalesceExpr - * - _copyMinMaxExpr - * - _copySQLValueFunction - * - _copyXmlExpr - * - _copyJsonFormat - * - _copyJsonReturning - * - _copyJsonValueExpr - * - _copyJsonConstructorExpr - * - _copyJsonIsPredicate - * - _copyNullTest - * - _copyBooleanTest - * - _copyCoerceToDomain - * - _copyCoerceToDomainValue - * - _copySetToDefault - * - _copyCurrentOfExpr - * - _copyNextValueExpr - * - _copyInferenceElem - * - _copyTargetEntry - * - _copyRangeTblRef - * - _copyJoinExpr - * - _copyFromExpr - * - _copyOnConflictExpr - * - _copyQuery - * - _copyTypeName - * - _copyColumnRef - * - _copyParamRef - * - _copyA_Expr - * - _copyTypeCast - * - _copyCollateClause - * - _copyRoleSpec - * - _copyFuncCall - * - _copyA_Star - * - _copyA_Indices - * - _copyA_Indirection - * - _copyA_ArrayExpr - * - _copyResTarget - * - _copyMultiAssignRef - * - _copySortBy - * - _copyWindowDef - * - _copyRangeSubselect - * - _copyRangeFunction - * - _copyRangeTableFunc - * - _copyRangeTableFuncCol - * - _copyRangeTableSample - * - _copyColumnDef - * - _copyTableLikeClause - * - _copyIndexElem - * - _copyDefElem - * - _copyLockingClause - * - _copyXmlSerialize - * - _copyPartitionElem - * - _copyPartitionSpec - * - _copyPartitionBoundSpec - * - _copyPartitionRangeDatum - * - _copyPartitionCmd - * - _copyRangeTblEntry - * - _copyRTEPermissionInfo - * - _copyRangeTblFunction - * - _copyTableSampleClause - * - _copyWithCheckOption - * - _copySortGroupClause - * - _copyGroupingSet - * - _copyWindowClause - * - _copyRowMarkClause - * - _copyWithClause - * - _copyInferClause - * - _copyOnConflictClause - * - _copyCTESearchClause - * - _copyCTECycleClause - * - _copyCommonTableExpr - * - _copyMergeWhenClause - * - _copyMergeAction - * - _copyTriggerTransition - * - _copyJsonOutput - * - _copyJsonKeyValue - * - _copyJsonObjectConstructor - * - _copyJsonArrayConstructor - * - _copyJsonArrayQueryConstructor - * - _copyJsonAggConstructor - * - _copyJsonObjectAgg - * - _copyJsonArrayAgg - * - _copyRawStmt - * - _copyInsertStmt - * - _copyDeleteStmt - * - _copyUpdateStmt - * - _copyMergeStmt - * - _copySelectStmt - * - _copySetOperationStmt - * - _copyReturnStmt - * - _copyPLAssignStmt - * - _copyCreateSchemaStmt - * - _copyAlterTableStmt - * - _copyReplicaIdentityStmt - * - _copyAlterTableCmd - * - _copyAlterCollationStmt - * - _copyAlterDomainStmt - * - _copyGrantStmt - * - _copyObjectWithArgs - * - _copyAccessPriv - * - _copyGrantRoleStmt - * - _copyAlterDefaultPrivilegesStmt - * - _copyCopyStmt - * - _copyVariableSetStmt - * - _copyVariableShowStmt - * - _copyCreateStmt - * - _copyConstraint - * - _copyCreateTableSpaceStmt - * - _copyDropTableSpaceStmt - * - _copyAlterTableSpaceOptionsStmt - * - _copyAlterTableMoveAllStmt - * - _copyCreateExtensionStmt - * - _copyAlterExtensionStmt - * - _copyAlterExtensionContentsStmt - * - _copyCreateFdwStmt - * - _copyAlterFdwStmt - * - _copyCreateForeignServerStmt - * - _copyAlterForeignServerStmt - * - _copyCreateForeignTableStmt - * - _copyCreateUserMappingStmt - * - _copyAlterUserMappingStmt - * - _copyDropUserMappingStmt - * - _copyImportForeignSchemaStmt - * - _copyCreatePolicyStmt - * - _copyAlterPolicyStmt - * - _copyCreateAmStmt - * - _copyCreateTrigStmt - * - _copyCreateEventTrigStmt - * - _copyAlterEventTrigStmt - * - _copyCreatePLangStmt - * - _copyCreateRoleStmt - * - _copyAlterRoleStmt - * - _copyAlterRoleSetStmt - * - _copyDropRoleStmt - * - _copyCreateSeqStmt - * - _copyAlterSeqStmt - * - _copyDefineStmt - * - _copyCreateDomainStmt - * - _copyCreateOpClassStmt - * - _copyCreateOpClassItem - * - _copyCreateOpFamilyStmt - * - _copyAlterOpFamilyStmt - * - _copyDropStmt - * - _copyTruncateStmt - * - _copyCommentStmt - * - _copySecLabelStmt - * - _copyDeclareCursorStmt - * - _copyClosePortalStmt - * - _copyFetchStmt - * - _copyIndexStmt - * - _copyCreateStatsStmt - * - _copyStatsElem - * - _copyAlterStatsStmt - * - _copyCreateFunctionStmt - * - _copyFunctionParameter - * - _copyAlterFunctionStmt - * - _copyDoStmt - * - _copyCallStmt - * - _copyRenameStmt - * - _copyAlterObjectDependsStmt - * - _copyAlterObjectSchemaStmt - * - _copyAlterOwnerStmt - * - _copyAlterOperatorStmt - * - _copyAlterTypeStmt - * - _copyRuleStmt - * - _copyNotifyStmt - * - _copyListenStmt - * - _copyUnlistenStmt - * - _copyTransactionStmt - * - _copyCompositeTypeStmt - * - _copyCreateEnumStmt - * - _copyCreateRangeStmt - * - _copyAlterEnumStmt - * - _copyViewStmt - * - _copyLoadStmt - * - _copyCreatedbStmt - * - _copyAlterDatabaseStmt - * - _copyAlterDatabaseRefreshCollStmt - * - _copyAlterDatabaseSetStmt - * - _copyDropdbStmt - * - _copyAlterSystemStmt - * - _copyClusterStmt - * - _copyVacuumStmt - * - _copyVacuumRelation - * - _copyExplainStmt - * - _copyCreateTableAsStmt - * - _copyRefreshMatViewStmt - * - _copyCheckPointStmt - * - _copyDiscardStmt - * - _copyLockStmt - * - _copyConstraintsSetStmt - * - _copyReindexStmt - * - _copyCreateConversionStmt - * - _copyCreateCastStmt - * - _copyCreateTransformStmt - * - _copyPrepareStmt - * - _copyExecuteStmt - * - _copyDeallocateStmt - * - _copyDropOwnedStmt - * - _copyReassignOwnedStmt - * - _copyAlterTSDictionaryStmt - * - _copyAlterTSConfigurationStmt - * - _copyPublicationTable - * - _copyPublicationObjSpec - * - _copyCreatePublicationStmt - * - _copyAlterPublicationStmt - * - _copyCreateSubscriptionStmt - * - _copyAlterSubscriptionStmt - * - _copyDropSubscriptionStmt - * - _copyPathKey - * - _copyRestrictInfo - * - _copyPlaceHolderVar - * - _copySpecialJoinInfo - * - _copyAppendRelInfo - * - _copyPlaceHolderInfo - * - _copyPlannedStmt - * - _copyResult - * - _copyProjectSet - * - _copyModifyTable - * - _copyAppend - * - _copyMergeAppend - * - _copyRecursiveUnion - * - _copyBitmapAnd - * - _copyBitmapOr - * - _copySeqScan - * - _copySampleScan - * - _copyIndexScan - * - _copyIndexOnlyScan - * - _copyBitmapIndexScan - * - _copyBitmapHeapScan - * - _copyTidScan - * - _copyTidRangeScan - * - _copySubqueryScan - * - _copyFunctionScan - * - _copyValuesScan - * - _copyTableFuncScan - * - _copyCteScan - * - _copyNamedTuplestoreScan - * - _copyWorkTableScan - * - _copyForeignScan - * - _copyCustomScan - * - _copyNestLoop - * - _copyNestLoopParam - * - _copyMergeJoin - * - _copyHashJoin - * - _copyMaterial - * - _copyMemoize - * - _copySort - * - _copyIncrementalSort - * - _copyGroup - * - _copyAgg - * - _copyWindowAgg - * - _copyUnique - * - _copyGather - * - _copyGatherMerge - * - _copyHash - * - _copySetOp - * - _copyLockRows - * - _copyLimit - * - _copyPlanRowMark - * - _copyPartitionPruneInfo - * - _copyPartitionedRelPruneInfo - * - _copyPartitionPruneStepOp - * - _copyPartitionPruneStepCombine - * - _copyPlanInvalItem - * - _copyInteger - * - _copyFloat - * - _copyBoolean - * - _copyString - * - _copyBitString - * - _copyForeignKeyCacheInfo - *-------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------- - * - * copyfuncs.funcs.c - * Generated node infrastructure code - * - * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * NOTES - * ****************************** - * *** DO NOT EDIT THIS FILE! *** - * ****************************** - * - * It has been GENERATED by src/backend/nodes/gen_node_support.pl - * - *------------------------------------------------------------------------- - */ -#include "access/amapi.h" -#include "access/sdir.h" -#include "access/tableam.h" -#include "access/tsmapi.h" -#include "commands/event_trigger.h" -#include "commands/trigger.h" -#include "executor/tuptable.h" -#include "foreign/fdwapi.h" -#include "nodes/bitmapset.h" -#include "nodes/execnodes.h" -#include "nodes/extensible.h" -#include "nodes/lockoptions.h" -#include "nodes/miscnodes.h" -#include "nodes/nodes.h" -#include "nodes/parsenodes.h" -#include "nodes/pathnodes.h" -#include "nodes/plannodes.h" -#include "nodes/primnodes.h" -#include "nodes/replnodes.h" -#include "nodes/supportnodes.h" -#include "nodes/value.h" -#include "utils/rel.h" - -static Alias * -_copyAlias(const Alias *from) -{ - Alias *newnode = makeNode(Alias); - - COPY_STRING_FIELD(aliasname); - COPY_NODE_FIELD(colnames); - - return newnode; -} - -static RangeVar * -_copyRangeVar(const RangeVar *from) -{ - RangeVar *newnode = makeNode(RangeVar); - - COPY_STRING_FIELD(catalogname); - COPY_STRING_FIELD(schemaname); - COPY_STRING_FIELD(relname); - COPY_SCALAR_FIELD(inh); - COPY_SCALAR_FIELD(relpersistence); - COPY_NODE_FIELD(alias); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static TableFunc * -_copyTableFunc(const TableFunc *from) -{ - TableFunc *newnode = makeNode(TableFunc); - - COPY_NODE_FIELD(ns_uris); - COPY_NODE_FIELD(ns_names); - COPY_NODE_FIELD(docexpr); - COPY_NODE_FIELD(rowexpr); - COPY_NODE_FIELD(colnames); - COPY_NODE_FIELD(coltypes); - COPY_NODE_FIELD(coltypmods); - COPY_NODE_FIELD(colcollations); - COPY_NODE_FIELD(colexprs); - COPY_NODE_FIELD(coldefexprs); - COPY_BITMAPSET_FIELD(notnulls); - COPY_SCALAR_FIELD(ordinalitycol); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static IntoClause * -_copyIntoClause(const IntoClause *from) -{ - IntoClause *newnode = makeNode(IntoClause); - - COPY_NODE_FIELD(rel); - COPY_NODE_FIELD(colNames); - COPY_STRING_FIELD(accessMethod); - COPY_NODE_FIELD(options); - COPY_SCALAR_FIELD(onCommit); - COPY_STRING_FIELD(tableSpaceName); - COPY_NODE_FIELD(viewQuery); - COPY_SCALAR_FIELD(skipData); - - return newnode; -} - -static Var * -_copyVar(const Var *from) -{ - Var *newnode = makeNode(Var); - - COPY_SCALAR_FIELD(varno); - COPY_SCALAR_FIELD(varattno); - COPY_SCALAR_FIELD(vartype); - COPY_SCALAR_FIELD(vartypmod); - COPY_SCALAR_FIELD(varcollid); - COPY_BITMAPSET_FIELD(varnullingrels); - COPY_SCALAR_FIELD(varlevelsup); - COPY_SCALAR_FIELD(varnosyn); - COPY_SCALAR_FIELD(varattnosyn); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static Param * -_copyParam(const Param *from) -{ - Param *newnode = makeNode(Param); - - COPY_SCALAR_FIELD(paramkind); - COPY_SCALAR_FIELD(paramid); - COPY_SCALAR_FIELD(paramtype); - COPY_SCALAR_FIELD(paramtypmod); - COPY_SCALAR_FIELD(paramcollid); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static Aggref * -_copyAggref(const Aggref *from) -{ - Aggref *newnode = makeNode(Aggref); - - COPY_SCALAR_FIELD(aggfnoid); - COPY_SCALAR_FIELD(aggtype); - COPY_SCALAR_FIELD(aggcollid); - COPY_SCALAR_FIELD(inputcollid); - COPY_SCALAR_FIELD(aggtranstype); - COPY_NODE_FIELD(aggargtypes); - COPY_NODE_FIELD(aggdirectargs); - COPY_NODE_FIELD(args); - COPY_NODE_FIELD(aggorder); - COPY_NODE_FIELD(aggdistinct); - COPY_NODE_FIELD(aggfilter); - COPY_SCALAR_FIELD(aggstar); - COPY_SCALAR_FIELD(aggvariadic); - COPY_SCALAR_FIELD(aggkind); - COPY_SCALAR_FIELD(aggpresorted); - COPY_SCALAR_FIELD(agglevelsup); - COPY_SCALAR_FIELD(aggsplit); - COPY_SCALAR_FIELD(aggno); - COPY_SCALAR_FIELD(aggtransno); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static GroupingFunc * -_copyGroupingFunc(const GroupingFunc *from) -{ - GroupingFunc *newnode = makeNode(GroupingFunc); - - COPY_NODE_FIELD(args); - COPY_NODE_FIELD(refs); - COPY_NODE_FIELD(cols); - COPY_SCALAR_FIELD(agglevelsup); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static WindowFunc * -_copyWindowFunc(const WindowFunc *from) -{ - WindowFunc *newnode = makeNode(WindowFunc); - - COPY_SCALAR_FIELD(winfnoid); - COPY_SCALAR_FIELD(wintype); - COPY_SCALAR_FIELD(wincollid); - COPY_SCALAR_FIELD(inputcollid); - COPY_NODE_FIELD(args); - COPY_NODE_FIELD(aggfilter); - COPY_SCALAR_FIELD(winref); - COPY_SCALAR_FIELD(winstar); - COPY_SCALAR_FIELD(winagg); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static SubscriptingRef * -_copySubscriptingRef(const SubscriptingRef *from) -{ - SubscriptingRef *newnode = makeNode(SubscriptingRef); - - COPY_SCALAR_FIELD(refcontainertype); - COPY_SCALAR_FIELD(refelemtype); - COPY_SCALAR_FIELD(refrestype); - COPY_SCALAR_FIELD(reftypmod); - COPY_SCALAR_FIELD(refcollid); - COPY_NODE_FIELD(refupperindexpr); - COPY_NODE_FIELD(reflowerindexpr); - COPY_NODE_FIELD(refexpr); - COPY_NODE_FIELD(refassgnexpr); - - return newnode; -} - -static FuncExpr * -_copyFuncExpr(const FuncExpr *from) -{ - FuncExpr *newnode = makeNode(FuncExpr); - - COPY_SCALAR_FIELD(funcid); - COPY_SCALAR_FIELD(funcresulttype); - COPY_SCALAR_FIELD(funcretset); - COPY_SCALAR_FIELD(funcvariadic); - COPY_SCALAR_FIELD(funcformat); - COPY_SCALAR_FIELD(funccollid); - COPY_SCALAR_FIELD(inputcollid); - COPY_NODE_FIELD(args); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static NamedArgExpr * -_copyNamedArgExpr(const NamedArgExpr *from) -{ - NamedArgExpr *newnode = makeNode(NamedArgExpr); - - COPY_NODE_FIELD(arg); - COPY_STRING_FIELD(name); - COPY_SCALAR_FIELD(argnumber); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static OpExpr * -_copyOpExpr(const OpExpr *from) -{ - OpExpr *newnode = makeNode(OpExpr); - - COPY_SCALAR_FIELD(opno); - COPY_SCALAR_FIELD(opfuncid); - COPY_SCALAR_FIELD(opresulttype); - COPY_SCALAR_FIELD(opretset); - COPY_SCALAR_FIELD(opcollid); - COPY_SCALAR_FIELD(inputcollid); - COPY_NODE_FIELD(args); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static DistinctExpr * -_copyDistinctExpr(const DistinctExpr *from) -{ - DistinctExpr *newnode = makeNode(DistinctExpr); - - COPY_SCALAR_FIELD(opno); - COPY_SCALAR_FIELD(opfuncid); - COPY_SCALAR_FIELD(opresulttype); - COPY_SCALAR_FIELD(opretset); - COPY_SCALAR_FIELD(opcollid); - COPY_SCALAR_FIELD(inputcollid); - COPY_NODE_FIELD(args); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static NullIfExpr * -_copyNullIfExpr(const NullIfExpr *from) -{ - NullIfExpr *newnode = makeNode(NullIfExpr); - - COPY_SCALAR_FIELD(opno); - COPY_SCALAR_FIELD(opfuncid); - COPY_SCALAR_FIELD(opresulttype); - COPY_SCALAR_FIELD(opretset); - COPY_SCALAR_FIELD(opcollid); - COPY_SCALAR_FIELD(inputcollid); - COPY_NODE_FIELD(args); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static ScalarArrayOpExpr * -_copyScalarArrayOpExpr(const ScalarArrayOpExpr *from) -{ - ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr); - - COPY_SCALAR_FIELD(opno); - COPY_SCALAR_FIELD(opfuncid); - COPY_SCALAR_FIELD(hashfuncid); - COPY_SCALAR_FIELD(negfuncid); - COPY_SCALAR_FIELD(useOr); - COPY_SCALAR_FIELD(inputcollid); - COPY_NODE_FIELD(args); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static BoolExpr * -_copyBoolExpr(const BoolExpr *from) -{ - BoolExpr *newnode = makeNode(BoolExpr); - - COPY_SCALAR_FIELD(boolop); - COPY_NODE_FIELD(args); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static SubLink * -_copySubLink(const SubLink *from) -{ - SubLink *newnode = makeNode(SubLink); - - COPY_SCALAR_FIELD(subLinkType); - COPY_SCALAR_FIELD(subLinkId); - COPY_NODE_FIELD(testexpr); - COPY_NODE_FIELD(operName); - COPY_NODE_FIELD(subselect); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static SubPlan * -_copySubPlan(const SubPlan *from) -{ - SubPlan *newnode = makeNode(SubPlan); - - COPY_SCALAR_FIELD(subLinkType); - COPY_NODE_FIELD(testexpr); - COPY_NODE_FIELD(paramIds); - COPY_SCALAR_FIELD(plan_id); - COPY_STRING_FIELD(plan_name); - COPY_SCALAR_FIELD(firstColType); - COPY_SCALAR_FIELD(firstColTypmod); - COPY_SCALAR_FIELD(firstColCollation); - COPY_SCALAR_FIELD(useHashTable); - COPY_SCALAR_FIELD(unknownEqFalse); - COPY_SCALAR_FIELD(parallel_safe); - COPY_NODE_FIELD(setParam); - COPY_NODE_FIELD(parParam); - COPY_NODE_FIELD(args); - COPY_SCALAR_FIELD(startup_cost); - COPY_SCALAR_FIELD(per_call_cost); - - return newnode; -} - -static AlternativeSubPlan * -_copyAlternativeSubPlan(const AlternativeSubPlan *from) -{ - AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan); - - COPY_NODE_FIELD(subplans); - - return newnode; -} - -static FieldSelect * -_copyFieldSelect(const FieldSelect *from) -{ - FieldSelect *newnode = makeNode(FieldSelect); - - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(fieldnum); - COPY_SCALAR_FIELD(resulttype); - COPY_SCALAR_FIELD(resulttypmod); - COPY_SCALAR_FIELD(resultcollid); - - return newnode; -} - -static FieldStore * -_copyFieldStore(const FieldStore *from) -{ - FieldStore *newnode = makeNode(FieldStore); - - COPY_NODE_FIELD(arg); - COPY_NODE_FIELD(newvals); - COPY_NODE_FIELD(fieldnums); - COPY_SCALAR_FIELD(resulttype); - - return newnode; -} - -static RelabelType * -_copyRelabelType(const RelabelType *from) -{ - RelabelType *newnode = makeNode(RelabelType); - - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(resulttype); - COPY_SCALAR_FIELD(resulttypmod); - COPY_SCALAR_FIELD(resultcollid); - COPY_SCALAR_FIELD(relabelformat); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CoerceViaIO * -_copyCoerceViaIO(const CoerceViaIO *from) -{ - CoerceViaIO *newnode = makeNode(CoerceViaIO); - - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(resulttype); - COPY_SCALAR_FIELD(resultcollid); - COPY_SCALAR_FIELD(coerceformat); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static ArrayCoerceExpr * -_copyArrayCoerceExpr(const ArrayCoerceExpr *from) -{ - ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr); - - COPY_NODE_FIELD(arg); - COPY_NODE_FIELD(elemexpr); - COPY_SCALAR_FIELD(resulttype); - COPY_SCALAR_FIELD(resulttypmod); - COPY_SCALAR_FIELD(resultcollid); - COPY_SCALAR_FIELD(coerceformat); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static ConvertRowtypeExpr * -_copyConvertRowtypeExpr(const ConvertRowtypeExpr *from) -{ - ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr); - - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(resulttype); - COPY_SCALAR_FIELD(convertformat); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CollateExpr * -_copyCollateExpr(const CollateExpr *from) -{ - CollateExpr *newnode = makeNode(CollateExpr); - - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(collOid); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CaseExpr * -_copyCaseExpr(const CaseExpr *from) -{ - CaseExpr *newnode = makeNode(CaseExpr); - - COPY_SCALAR_FIELD(casetype); - COPY_SCALAR_FIELD(casecollid); - COPY_NODE_FIELD(arg); - COPY_NODE_FIELD(args); - COPY_NODE_FIELD(defresult); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CaseWhen * -_copyCaseWhen(const CaseWhen *from) -{ - CaseWhen *newnode = makeNode(CaseWhen); - - COPY_NODE_FIELD(expr); - COPY_NODE_FIELD(result); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CaseTestExpr * -_copyCaseTestExpr(const CaseTestExpr *from) -{ - CaseTestExpr *newnode = makeNode(CaseTestExpr); - - COPY_SCALAR_FIELD(typeId); - COPY_SCALAR_FIELD(typeMod); - COPY_SCALAR_FIELD(collation); - - return newnode; -} - -static ArrayExpr * -_copyArrayExpr(const ArrayExpr *from) -{ - ArrayExpr *newnode = makeNode(ArrayExpr); - - COPY_SCALAR_FIELD(array_typeid); - COPY_SCALAR_FIELD(array_collid); - COPY_SCALAR_FIELD(element_typeid); - COPY_NODE_FIELD(elements); - COPY_SCALAR_FIELD(multidims); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static RowExpr * -_copyRowExpr(const RowExpr *from) -{ - RowExpr *newnode = makeNode(RowExpr); - - COPY_NODE_FIELD(args); - COPY_SCALAR_FIELD(row_typeid); - COPY_SCALAR_FIELD(row_format); - COPY_NODE_FIELD(colnames); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static RowCompareExpr * -_copyRowCompareExpr(const RowCompareExpr *from) -{ - RowCompareExpr *newnode = makeNode(RowCompareExpr); - - COPY_SCALAR_FIELD(rctype); - COPY_NODE_FIELD(opnos); - COPY_NODE_FIELD(opfamilies); - COPY_NODE_FIELD(inputcollids); - COPY_NODE_FIELD(largs); - COPY_NODE_FIELD(rargs); - - return newnode; -} - -static CoalesceExpr * -_copyCoalesceExpr(const CoalesceExpr *from) -{ - CoalesceExpr *newnode = makeNode(CoalesceExpr); - - COPY_SCALAR_FIELD(coalescetype); - COPY_SCALAR_FIELD(coalescecollid); - COPY_NODE_FIELD(args); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static MinMaxExpr * -_copyMinMaxExpr(const MinMaxExpr *from) -{ - MinMaxExpr *newnode = makeNode(MinMaxExpr); - - COPY_SCALAR_FIELD(minmaxtype); - COPY_SCALAR_FIELD(minmaxcollid); - COPY_SCALAR_FIELD(inputcollid); - COPY_SCALAR_FIELD(op); - COPY_NODE_FIELD(args); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static SQLValueFunction * -_copySQLValueFunction(const SQLValueFunction *from) -{ - SQLValueFunction *newnode = makeNode(SQLValueFunction); - - COPY_SCALAR_FIELD(op); - COPY_SCALAR_FIELD(type); - COPY_SCALAR_FIELD(typmod); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static XmlExpr * -_copyXmlExpr(const XmlExpr *from) -{ - XmlExpr *newnode = makeNode(XmlExpr); - - COPY_SCALAR_FIELD(op); - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(named_args); - COPY_NODE_FIELD(arg_names); - COPY_NODE_FIELD(args); - COPY_SCALAR_FIELD(xmloption); - COPY_SCALAR_FIELD(indent); - COPY_SCALAR_FIELD(type); - COPY_SCALAR_FIELD(typmod); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static JsonFormat * -_copyJsonFormat(const JsonFormat *from) -{ - JsonFormat *newnode = makeNode(JsonFormat); - - COPY_SCALAR_FIELD(format_type); - COPY_SCALAR_FIELD(encoding); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static JsonReturning * -_copyJsonReturning(const JsonReturning *from) -{ - JsonReturning *newnode = makeNode(JsonReturning); - - COPY_NODE_FIELD(format); - COPY_SCALAR_FIELD(typid); - COPY_SCALAR_FIELD(typmod); - - return newnode; -} - -static JsonValueExpr * -_copyJsonValueExpr(const JsonValueExpr *from) -{ - JsonValueExpr *newnode = makeNode(JsonValueExpr); - - COPY_NODE_FIELD(raw_expr); - COPY_NODE_FIELD(formatted_expr); - COPY_NODE_FIELD(format); - - return newnode; -} - -static JsonConstructorExpr * -_copyJsonConstructorExpr(const JsonConstructorExpr *from) -{ - JsonConstructorExpr *newnode = makeNode(JsonConstructorExpr); - - COPY_SCALAR_FIELD(type); - COPY_NODE_FIELD(args); - COPY_NODE_FIELD(func); - COPY_NODE_FIELD(coercion); - COPY_NODE_FIELD(returning); - COPY_SCALAR_FIELD(absent_on_null); - COPY_SCALAR_FIELD(unique); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static JsonIsPredicate * -_copyJsonIsPredicate(const JsonIsPredicate *from) -{ - JsonIsPredicate *newnode = makeNode(JsonIsPredicate); - - COPY_NODE_FIELD(expr); - COPY_NODE_FIELD(format); - COPY_SCALAR_FIELD(item_type); - COPY_SCALAR_FIELD(unique_keys); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static NullTest * -_copyNullTest(const NullTest *from) -{ - NullTest *newnode = makeNode(NullTest); - - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(nulltesttype); - COPY_SCALAR_FIELD(argisrow); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static BooleanTest * -_copyBooleanTest(const BooleanTest *from) -{ - BooleanTest *newnode = makeNode(BooleanTest); - - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(booltesttype); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CoerceToDomain * -_copyCoerceToDomain(const CoerceToDomain *from) -{ - CoerceToDomain *newnode = makeNode(CoerceToDomain); - - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(resulttype); - COPY_SCALAR_FIELD(resulttypmod); - COPY_SCALAR_FIELD(resultcollid); - COPY_SCALAR_FIELD(coercionformat); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CoerceToDomainValue * -_copyCoerceToDomainValue(const CoerceToDomainValue *from) -{ - CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue); - - COPY_SCALAR_FIELD(typeId); - COPY_SCALAR_FIELD(typeMod); - COPY_SCALAR_FIELD(collation); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static SetToDefault * -_copySetToDefault(const SetToDefault *from) -{ - SetToDefault *newnode = makeNode(SetToDefault); - - COPY_SCALAR_FIELD(typeId); - COPY_SCALAR_FIELD(typeMod); - COPY_SCALAR_FIELD(collation); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CurrentOfExpr * -_copyCurrentOfExpr(const CurrentOfExpr *from) -{ - CurrentOfExpr *newnode = makeNode(CurrentOfExpr); - - COPY_SCALAR_FIELD(cvarno); - COPY_STRING_FIELD(cursor_name); - COPY_SCALAR_FIELD(cursor_param); - - return newnode; -} - -static NextValueExpr * -_copyNextValueExpr(const NextValueExpr *from) -{ - NextValueExpr *newnode = makeNode(NextValueExpr); - - COPY_SCALAR_FIELD(seqid); - COPY_SCALAR_FIELD(typeId); - - return newnode; -} - -static InferenceElem * -_copyInferenceElem(const InferenceElem *from) -{ - InferenceElem *newnode = makeNode(InferenceElem); - - COPY_NODE_FIELD(expr); - COPY_SCALAR_FIELD(infercollid); - COPY_SCALAR_FIELD(inferopclass); - - return newnode; -} - -static TargetEntry * -_copyTargetEntry(const TargetEntry *from) -{ - TargetEntry *newnode = makeNode(TargetEntry); - - COPY_NODE_FIELD(expr); - COPY_SCALAR_FIELD(resno); - COPY_STRING_FIELD(resname); - COPY_SCALAR_FIELD(ressortgroupref); - COPY_SCALAR_FIELD(resorigtbl); - COPY_SCALAR_FIELD(resorigcol); - COPY_SCALAR_FIELD(resjunk); - - return newnode; -} - -static RangeTblRef * -_copyRangeTblRef(const RangeTblRef *from) -{ - RangeTblRef *newnode = makeNode(RangeTblRef); - - COPY_SCALAR_FIELD(rtindex); - - return newnode; -} - -static JoinExpr * -_copyJoinExpr(const JoinExpr *from) -{ - JoinExpr *newnode = makeNode(JoinExpr); - - COPY_SCALAR_FIELD(jointype); - COPY_SCALAR_FIELD(isNatural); - COPY_NODE_FIELD(larg); - COPY_NODE_FIELD(rarg); - COPY_NODE_FIELD(usingClause); - COPY_NODE_FIELD(join_using_alias); - COPY_NODE_FIELD(quals); - COPY_NODE_FIELD(alias); - COPY_SCALAR_FIELD(rtindex); - - return newnode; -} - -static FromExpr * -_copyFromExpr(const FromExpr *from) -{ - FromExpr *newnode = makeNode(FromExpr); - - COPY_NODE_FIELD(fromlist); - COPY_NODE_FIELD(quals); - - return newnode; -} - -static OnConflictExpr * -_copyOnConflictExpr(const OnConflictExpr *from) -{ - OnConflictExpr *newnode = makeNode(OnConflictExpr); - - COPY_SCALAR_FIELD(action); - COPY_NODE_FIELD(arbiterElems); - COPY_NODE_FIELD(arbiterWhere); - COPY_SCALAR_FIELD(constraint); - COPY_NODE_FIELD(onConflictSet); - COPY_NODE_FIELD(onConflictWhere); - COPY_SCALAR_FIELD(exclRelIndex); - COPY_NODE_FIELD(exclRelTlist); - - return newnode; -} - -static Query * -_copyQuery(const Query *from) -{ - Query *newnode = makeNode(Query); - - COPY_SCALAR_FIELD(commandType); - COPY_SCALAR_FIELD(querySource); - COPY_SCALAR_FIELD(queryId); - COPY_SCALAR_FIELD(canSetTag); - COPY_NODE_FIELD(utilityStmt); - COPY_SCALAR_FIELD(resultRelation); - COPY_SCALAR_FIELD(hasAggs); - COPY_SCALAR_FIELD(hasWindowFuncs); - COPY_SCALAR_FIELD(hasTargetSRFs); - COPY_SCALAR_FIELD(hasSubLinks); - COPY_SCALAR_FIELD(hasDistinctOn); - COPY_SCALAR_FIELD(hasRecursive); - COPY_SCALAR_FIELD(hasModifyingCTE); - COPY_SCALAR_FIELD(hasForUpdate); - COPY_SCALAR_FIELD(hasRowSecurity); - COPY_SCALAR_FIELD(isReturn); - COPY_NODE_FIELD(cteList); - COPY_NODE_FIELD(rtable); - COPY_NODE_FIELD(rteperminfos); - COPY_NODE_FIELD(jointree); - COPY_NODE_FIELD(mergeActionList); - COPY_SCALAR_FIELD(mergeUseOuterJoin); - COPY_NODE_FIELD(targetList); - COPY_SCALAR_FIELD(override); - COPY_NODE_FIELD(onConflict); - COPY_NODE_FIELD(returningList); - COPY_NODE_FIELD(groupClause); - COPY_SCALAR_FIELD(groupDistinct); - COPY_NODE_FIELD(groupingSets); - COPY_NODE_FIELD(havingQual); - COPY_NODE_FIELD(windowClause); - COPY_NODE_FIELD(distinctClause); - COPY_NODE_FIELD(sortClause); - COPY_NODE_FIELD(limitOffset); - COPY_NODE_FIELD(limitCount); - COPY_SCALAR_FIELD(limitOption); - COPY_NODE_FIELD(rowMarks); - COPY_NODE_FIELD(setOperations); - COPY_NODE_FIELD(constraintDeps); - COPY_NODE_FIELD(withCheckOptions); - COPY_LOCATION_FIELD(stmt_location); - COPY_SCALAR_FIELD(stmt_len); - - return newnode; -} - -static TypeName * -_copyTypeName(const TypeName *from) -{ - TypeName *newnode = makeNode(TypeName); - - COPY_NODE_FIELD(names); - COPY_SCALAR_FIELD(typeOid); - COPY_SCALAR_FIELD(setof); - COPY_SCALAR_FIELD(pct_type); - COPY_NODE_FIELD(typmods); - COPY_SCALAR_FIELD(typemod); - COPY_NODE_FIELD(arrayBounds); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static ColumnRef * -_copyColumnRef(const ColumnRef *from) -{ - ColumnRef *newnode = makeNode(ColumnRef); - - COPY_NODE_FIELD(fields); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static ParamRef * -_copyParamRef(const ParamRef *from) -{ - ParamRef *newnode = makeNode(ParamRef); - - COPY_SCALAR_FIELD(number); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static A_Expr * -_copyA_Expr(const A_Expr *from) -{ - A_Expr *newnode = makeNode(A_Expr); - - COPY_SCALAR_FIELD(kind); - COPY_NODE_FIELD(name); - COPY_NODE_FIELD(lexpr); - COPY_NODE_FIELD(rexpr); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static TypeCast * -_copyTypeCast(const TypeCast *from) -{ - TypeCast *newnode = makeNode(TypeCast); - - COPY_NODE_FIELD(arg); - COPY_NODE_FIELD(typeName); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CollateClause * -_copyCollateClause(const CollateClause *from) -{ - CollateClause *newnode = makeNode(CollateClause); - - COPY_NODE_FIELD(arg); - COPY_NODE_FIELD(collname); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static RoleSpec * -_copyRoleSpec(const RoleSpec *from) -{ - RoleSpec *newnode = makeNode(RoleSpec); - - COPY_SCALAR_FIELD(roletype); - COPY_STRING_FIELD(rolename); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static FuncCall * -_copyFuncCall(const FuncCall *from) -{ - FuncCall *newnode = makeNode(FuncCall); - - COPY_NODE_FIELD(funcname); - COPY_NODE_FIELD(args); - COPY_NODE_FIELD(agg_order); - COPY_NODE_FIELD(agg_filter); - COPY_NODE_FIELD(over); - COPY_SCALAR_FIELD(agg_within_group); - COPY_SCALAR_FIELD(agg_star); - COPY_SCALAR_FIELD(agg_distinct); - COPY_SCALAR_FIELD(func_variadic); - COPY_SCALAR_FIELD(funcformat); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static A_Star * -_copyA_Star(const A_Star *from) -{ - A_Star *newnode = makeNode(A_Star); - - - return newnode; -} - -static A_Indices * -_copyA_Indices(const A_Indices *from) -{ - A_Indices *newnode = makeNode(A_Indices); - - COPY_SCALAR_FIELD(is_slice); - COPY_NODE_FIELD(lidx); - COPY_NODE_FIELD(uidx); - - return newnode; -} - -static A_Indirection * -_copyA_Indirection(const A_Indirection *from) -{ - A_Indirection *newnode = makeNode(A_Indirection); - - COPY_NODE_FIELD(arg); - COPY_NODE_FIELD(indirection); - - return newnode; -} - -static A_ArrayExpr * -_copyA_ArrayExpr(const A_ArrayExpr *from) -{ - A_ArrayExpr *newnode = makeNode(A_ArrayExpr); - - COPY_NODE_FIELD(elements); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static ResTarget * -_copyResTarget(const ResTarget *from) -{ - ResTarget *newnode = makeNode(ResTarget); - - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(indirection); - COPY_NODE_FIELD(val); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static MultiAssignRef * -_copyMultiAssignRef(const MultiAssignRef *from) -{ - MultiAssignRef *newnode = makeNode(MultiAssignRef); - - COPY_NODE_FIELD(source); - COPY_SCALAR_FIELD(colno); - COPY_SCALAR_FIELD(ncolumns); - - return newnode; -} - -static SortBy * -_copySortBy(const SortBy *from) -{ - SortBy *newnode = makeNode(SortBy); - - COPY_NODE_FIELD(node); - COPY_SCALAR_FIELD(sortby_dir); - COPY_SCALAR_FIELD(sortby_nulls); - COPY_NODE_FIELD(useOp); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static WindowDef * -_copyWindowDef(const WindowDef *from) -{ - WindowDef *newnode = makeNode(WindowDef); - - COPY_STRING_FIELD(name); - COPY_STRING_FIELD(refname); - COPY_NODE_FIELD(partitionClause); - COPY_NODE_FIELD(orderClause); - COPY_SCALAR_FIELD(frameOptions); - COPY_NODE_FIELD(startOffset); - COPY_NODE_FIELD(endOffset); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static RangeSubselect * -_copyRangeSubselect(const RangeSubselect *from) -{ - RangeSubselect *newnode = makeNode(RangeSubselect); - - COPY_SCALAR_FIELD(lateral); - COPY_NODE_FIELD(subquery); - COPY_NODE_FIELD(alias); - - return newnode; -} - -static RangeFunction * -_copyRangeFunction(const RangeFunction *from) -{ - RangeFunction *newnode = makeNode(RangeFunction); - - COPY_SCALAR_FIELD(lateral); - COPY_SCALAR_FIELD(ordinality); - COPY_SCALAR_FIELD(is_rowsfrom); - COPY_NODE_FIELD(functions); - COPY_NODE_FIELD(alias); - COPY_NODE_FIELD(coldeflist); - - return newnode; -} - -static RangeTableFunc * -_copyRangeTableFunc(const RangeTableFunc *from) -{ - RangeTableFunc *newnode = makeNode(RangeTableFunc); - - COPY_SCALAR_FIELD(lateral); - COPY_NODE_FIELD(docexpr); - COPY_NODE_FIELD(rowexpr); - COPY_NODE_FIELD(namespaces); - COPY_NODE_FIELD(columns); - COPY_NODE_FIELD(alias); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static RangeTableFuncCol * -_copyRangeTableFuncCol(const RangeTableFuncCol *from) -{ - RangeTableFuncCol *newnode = makeNode(RangeTableFuncCol); - - COPY_STRING_FIELD(colname); - COPY_NODE_FIELD(typeName); - COPY_SCALAR_FIELD(for_ordinality); - COPY_SCALAR_FIELD(is_not_null); - COPY_NODE_FIELD(colexpr); - COPY_NODE_FIELD(coldefexpr); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static RangeTableSample * -_copyRangeTableSample(const RangeTableSample *from) -{ - RangeTableSample *newnode = makeNode(RangeTableSample); - - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(method); - COPY_NODE_FIELD(args); - COPY_NODE_FIELD(repeatable); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static ColumnDef * -_copyColumnDef(const ColumnDef *from) -{ - ColumnDef *newnode = makeNode(ColumnDef); - - COPY_STRING_FIELD(colname); - COPY_NODE_FIELD(typeName); - COPY_STRING_FIELD(compression); - COPY_SCALAR_FIELD(inhcount); - COPY_SCALAR_FIELD(is_local); - COPY_SCALAR_FIELD(is_not_null); - COPY_SCALAR_FIELD(is_from_type); - COPY_SCALAR_FIELD(storage); - COPY_STRING_FIELD(storage_name); - COPY_NODE_FIELD(raw_default); - COPY_NODE_FIELD(cooked_default); - COPY_SCALAR_FIELD(identity); - COPY_NODE_FIELD(identitySequence); - COPY_SCALAR_FIELD(generated); - COPY_NODE_FIELD(collClause); - COPY_SCALAR_FIELD(collOid); - COPY_NODE_FIELD(constraints); - COPY_NODE_FIELD(fdwoptions); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static TableLikeClause * -_copyTableLikeClause(const TableLikeClause *from) -{ - TableLikeClause *newnode = makeNode(TableLikeClause); - - COPY_NODE_FIELD(relation); - COPY_SCALAR_FIELD(options); - COPY_SCALAR_FIELD(relationOid); - - return newnode; -} - -static IndexElem * -_copyIndexElem(const IndexElem *from) -{ - IndexElem *newnode = makeNode(IndexElem); - - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(expr); - COPY_STRING_FIELD(indexcolname); - COPY_NODE_FIELD(collation); - COPY_NODE_FIELD(opclass); - COPY_NODE_FIELD(opclassopts); - COPY_SCALAR_FIELD(ordering); - COPY_SCALAR_FIELD(nulls_ordering); - - return newnode; -} - -static DefElem * -_copyDefElem(const DefElem *from) -{ - DefElem *newnode = makeNode(DefElem); - - COPY_STRING_FIELD(defnamespace); - COPY_STRING_FIELD(defname); - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(defaction); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static LockingClause * -_copyLockingClause(const LockingClause *from) -{ - LockingClause *newnode = makeNode(LockingClause); - - COPY_NODE_FIELD(lockedRels); - COPY_SCALAR_FIELD(strength); - COPY_SCALAR_FIELD(waitPolicy); - - return newnode; -} - -static XmlSerialize * -_copyXmlSerialize(const XmlSerialize *from) -{ - XmlSerialize *newnode = makeNode(XmlSerialize); - - COPY_SCALAR_FIELD(xmloption); - COPY_NODE_FIELD(expr); - COPY_NODE_FIELD(typeName); - COPY_SCALAR_FIELD(indent); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static PartitionElem * -_copyPartitionElem(const PartitionElem *from) -{ - PartitionElem *newnode = makeNode(PartitionElem); - - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(expr); - COPY_NODE_FIELD(collation); - COPY_NODE_FIELD(opclass); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static PartitionSpec * -_copyPartitionSpec(const PartitionSpec *from) -{ - PartitionSpec *newnode = makeNode(PartitionSpec); - - COPY_SCALAR_FIELD(strategy); - COPY_NODE_FIELD(partParams); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static PartitionBoundSpec * -_copyPartitionBoundSpec(const PartitionBoundSpec *from) -{ - PartitionBoundSpec *newnode = makeNode(PartitionBoundSpec); - - COPY_SCALAR_FIELD(strategy); - COPY_SCALAR_FIELD(is_default); - COPY_SCALAR_FIELD(modulus); - COPY_SCALAR_FIELD(remainder); - COPY_NODE_FIELD(listdatums); - COPY_NODE_FIELD(lowerdatums); - COPY_NODE_FIELD(upperdatums); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static PartitionRangeDatum * -_copyPartitionRangeDatum(const PartitionRangeDatum *from) -{ - PartitionRangeDatum *newnode = makeNode(PartitionRangeDatum); - - COPY_SCALAR_FIELD(kind); - COPY_NODE_FIELD(value); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static PartitionCmd * -_copyPartitionCmd(const PartitionCmd *from) -{ - PartitionCmd *newnode = makeNode(PartitionCmd); - - COPY_NODE_FIELD(name); - COPY_NODE_FIELD(bound); - COPY_SCALAR_FIELD(concurrent); - - return newnode; -} - -static RangeTblEntry * -_copyRangeTblEntry(const RangeTblEntry *from) -{ - RangeTblEntry *newnode = makeNode(RangeTblEntry); - - COPY_SCALAR_FIELD(rtekind); - COPY_SCALAR_FIELD(relid); - COPY_SCALAR_FIELD(relkind); - COPY_SCALAR_FIELD(rellockmode); - COPY_NODE_FIELD(tablesample); - COPY_SCALAR_FIELD(perminfoindex); - COPY_NODE_FIELD(subquery); - COPY_SCALAR_FIELD(security_barrier); - COPY_SCALAR_FIELD(jointype); - COPY_SCALAR_FIELD(joinmergedcols); - COPY_NODE_FIELD(joinaliasvars); - COPY_NODE_FIELD(joinleftcols); - COPY_NODE_FIELD(joinrightcols); - COPY_NODE_FIELD(join_using_alias); - COPY_NODE_FIELD(functions); - COPY_SCALAR_FIELD(funcordinality); - COPY_NODE_FIELD(tablefunc); - COPY_NODE_FIELD(values_lists); - COPY_STRING_FIELD(ctename); - COPY_SCALAR_FIELD(ctelevelsup); - COPY_SCALAR_FIELD(self_reference); - COPY_NODE_FIELD(coltypes); - COPY_NODE_FIELD(coltypmods); - COPY_NODE_FIELD(colcollations); - COPY_STRING_FIELD(enrname); - COPY_SCALAR_FIELD(enrtuples); - COPY_NODE_FIELD(alias); - COPY_NODE_FIELD(eref); - COPY_SCALAR_FIELD(lateral); - COPY_SCALAR_FIELD(inh); - COPY_SCALAR_FIELD(inFromCl); - COPY_NODE_FIELD(securityQuals); - - return newnode; -} - -static RTEPermissionInfo * -_copyRTEPermissionInfo(const RTEPermissionInfo *from) -{ - RTEPermissionInfo *newnode = makeNode(RTEPermissionInfo); - - COPY_SCALAR_FIELD(relid); - COPY_SCALAR_FIELD(inh); - COPY_SCALAR_FIELD(requiredPerms); - COPY_SCALAR_FIELD(checkAsUser); - COPY_BITMAPSET_FIELD(selectedCols); - COPY_BITMAPSET_FIELD(insertedCols); - COPY_BITMAPSET_FIELD(updatedCols); - - return newnode; -} - -static RangeTblFunction * -_copyRangeTblFunction(const RangeTblFunction *from) -{ - RangeTblFunction *newnode = makeNode(RangeTblFunction); - - COPY_NODE_FIELD(funcexpr); - COPY_SCALAR_FIELD(funccolcount); - COPY_NODE_FIELD(funccolnames); - COPY_NODE_FIELD(funccoltypes); - COPY_NODE_FIELD(funccoltypmods); - COPY_NODE_FIELD(funccolcollations); - COPY_BITMAPSET_FIELD(funcparams); - - return newnode; -} - -static TableSampleClause * -_copyTableSampleClause(const TableSampleClause *from) -{ - TableSampleClause *newnode = makeNode(TableSampleClause); - - COPY_SCALAR_FIELD(tsmhandler); - COPY_NODE_FIELD(args); - COPY_NODE_FIELD(repeatable); - - return newnode; -} - -static WithCheckOption * -_copyWithCheckOption(const WithCheckOption *from) -{ - WithCheckOption *newnode = makeNode(WithCheckOption); - - COPY_SCALAR_FIELD(kind); - COPY_STRING_FIELD(relname); - COPY_STRING_FIELD(polname); - COPY_NODE_FIELD(qual); - COPY_SCALAR_FIELD(cascaded); - - return newnode; -} - -static SortGroupClause * -_copySortGroupClause(const SortGroupClause *from) -{ - SortGroupClause *newnode = makeNode(SortGroupClause); - - COPY_SCALAR_FIELD(tleSortGroupRef); - COPY_SCALAR_FIELD(eqop); - COPY_SCALAR_FIELD(sortop); - COPY_SCALAR_FIELD(nulls_first); - COPY_SCALAR_FIELD(hashable); - - return newnode; -} - -static GroupingSet * -_copyGroupingSet(const GroupingSet *from) -{ - GroupingSet *newnode = makeNode(GroupingSet); - - COPY_SCALAR_FIELD(kind); - COPY_NODE_FIELD(content); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static WindowClause * -_copyWindowClause(const WindowClause *from) -{ - WindowClause *newnode = makeNode(WindowClause); - - COPY_STRING_FIELD(name); - COPY_STRING_FIELD(refname); - COPY_NODE_FIELD(partitionClause); - COPY_NODE_FIELD(orderClause); - COPY_SCALAR_FIELD(frameOptions); - COPY_NODE_FIELD(startOffset); - COPY_NODE_FIELD(endOffset); - COPY_NODE_FIELD(runCondition); - COPY_SCALAR_FIELD(startInRangeFunc); - COPY_SCALAR_FIELD(endInRangeFunc); - COPY_SCALAR_FIELD(inRangeColl); - COPY_SCALAR_FIELD(inRangeAsc); - COPY_SCALAR_FIELD(inRangeNullsFirst); - COPY_SCALAR_FIELD(winref); - COPY_SCALAR_FIELD(copiedOrder); - - return newnode; -} - -static RowMarkClause * -_copyRowMarkClause(const RowMarkClause *from) -{ - RowMarkClause *newnode = makeNode(RowMarkClause); - - COPY_SCALAR_FIELD(rti); - COPY_SCALAR_FIELD(strength); - COPY_SCALAR_FIELD(waitPolicy); - COPY_SCALAR_FIELD(pushedDown); - - return newnode; -} - -static WithClause * -_copyWithClause(const WithClause *from) -{ - WithClause *newnode = makeNode(WithClause); - - COPY_NODE_FIELD(ctes); - COPY_SCALAR_FIELD(recursive); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static InferClause * -_copyInferClause(const InferClause *from) -{ - InferClause *newnode = makeNode(InferClause); - - COPY_NODE_FIELD(indexElems); - COPY_NODE_FIELD(whereClause); - COPY_STRING_FIELD(conname); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static OnConflictClause * -_copyOnConflictClause(const OnConflictClause *from) -{ - OnConflictClause *newnode = makeNode(OnConflictClause); - - COPY_SCALAR_FIELD(action); - COPY_NODE_FIELD(infer); - COPY_NODE_FIELD(targetList); - COPY_NODE_FIELD(whereClause); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CTESearchClause * -_copyCTESearchClause(const CTESearchClause *from) -{ - CTESearchClause *newnode = makeNode(CTESearchClause); - - COPY_NODE_FIELD(search_col_list); - COPY_SCALAR_FIELD(search_breadth_first); - COPY_STRING_FIELD(search_seq_column); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CTECycleClause * -_copyCTECycleClause(const CTECycleClause *from) -{ - CTECycleClause *newnode = makeNode(CTECycleClause); - - COPY_NODE_FIELD(cycle_col_list); - COPY_STRING_FIELD(cycle_mark_column); - COPY_NODE_FIELD(cycle_mark_value); - COPY_NODE_FIELD(cycle_mark_default); - COPY_STRING_FIELD(cycle_path_column); - COPY_LOCATION_FIELD(location); - COPY_SCALAR_FIELD(cycle_mark_type); - COPY_SCALAR_FIELD(cycle_mark_typmod); - COPY_SCALAR_FIELD(cycle_mark_collation); - COPY_SCALAR_FIELD(cycle_mark_neop); - - return newnode; -} - -static CommonTableExpr * -_copyCommonTableExpr(const CommonTableExpr *from) -{ - CommonTableExpr *newnode = makeNode(CommonTableExpr); - - COPY_STRING_FIELD(ctename); - COPY_NODE_FIELD(aliascolnames); - COPY_SCALAR_FIELD(ctematerialized); - COPY_NODE_FIELD(ctequery); - COPY_NODE_FIELD(search_clause); - COPY_NODE_FIELD(cycle_clause); - COPY_LOCATION_FIELD(location); - COPY_SCALAR_FIELD(cterecursive); - COPY_SCALAR_FIELD(cterefcount); - COPY_NODE_FIELD(ctecolnames); - COPY_NODE_FIELD(ctecoltypes); - COPY_NODE_FIELD(ctecoltypmods); - COPY_NODE_FIELD(ctecolcollations); - - return newnode; -} - -static MergeWhenClause * -_copyMergeWhenClause(const MergeWhenClause *from) -{ - MergeWhenClause *newnode = makeNode(MergeWhenClause); - - COPY_SCALAR_FIELD(matched); - COPY_SCALAR_FIELD(commandType); - COPY_SCALAR_FIELD(override); - COPY_NODE_FIELD(condition); - COPY_NODE_FIELD(targetList); - COPY_NODE_FIELD(values); - - return newnode; -} - -static MergeAction * -_copyMergeAction(const MergeAction *from) -{ - MergeAction *newnode = makeNode(MergeAction); - - COPY_SCALAR_FIELD(matched); - COPY_SCALAR_FIELD(commandType); - COPY_SCALAR_FIELD(override); - COPY_NODE_FIELD(qual); - COPY_NODE_FIELD(targetList); - COPY_NODE_FIELD(updateColnos); - - return newnode; -} - -static TriggerTransition * -_copyTriggerTransition(const TriggerTransition *from) -{ - TriggerTransition *newnode = makeNode(TriggerTransition); - - COPY_STRING_FIELD(name); - COPY_SCALAR_FIELD(isNew); - COPY_SCALAR_FIELD(isTable); - - return newnode; -} - -static JsonOutput * -_copyJsonOutput(const JsonOutput *from) -{ - JsonOutput *newnode = makeNode(JsonOutput); - - COPY_NODE_FIELD(typeName); - COPY_NODE_FIELD(returning); - - return newnode; -} - -static JsonKeyValue * -_copyJsonKeyValue(const JsonKeyValue *from) -{ - JsonKeyValue *newnode = makeNode(JsonKeyValue); - - COPY_NODE_FIELD(key); - COPY_NODE_FIELD(value); - - return newnode; -} - -static JsonObjectConstructor * -_copyJsonObjectConstructor(const JsonObjectConstructor *from) -{ - JsonObjectConstructor *newnode = makeNode(JsonObjectConstructor); - - COPY_NODE_FIELD(exprs); - COPY_NODE_FIELD(output); - COPY_SCALAR_FIELD(absent_on_null); - COPY_SCALAR_FIELD(unique); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static JsonArrayConstructor * -_copyJsonArrayConstructor(const JsonArrayConstructor *from) -{ - JsonArrayConstructor *newnode = makeNode(JsonArrayConstructor); - - COPY_NODE_FIELD(exprs); - COPY_NODE_FIELD(output); - COPY_SCALAR_FIELD(absent_on_null); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static JsonArrayQueryConstructor * -_copyJsonArrayQueryConstructor(const JsonArrayQueryConstructor *from) -{ - JsonArrayQueryConstructor *newnode = makeNode(JsonArrayQueryConstructor); - - COPY_NODE_FIELD(query); - COPY_NODE_FIELD(output); - COPY_NODE_FIELD(format); - COPY_SCALAR_FIELD(absent_on_null); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static JsonAggConstructor * -_copyJsonAggConstructor(const JsonAggConstructor *from) -{ - JsonAggConstructor *newnode = makeNode(JsonAggConstructor); - - COPY_NODE_FIELD(output); - COPY_NODE_FIELD(agg_filter); - COPY_NODE_FIELD(agg_order); - COPY_NODE_FIELD(over); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static JsonObjectAgg * -_copyJsonObjectAgg(const JsonObjectAgg *from) -{ - JsonObjectAgg *newnode = makeNode(JsonObjectAgg); - - COPY_NODE_FIELD(constructor); - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(absent_on_null); - COPY_SCALAR_FIELD(unique); - - return newnode; -} - -static JsonArrayAgg * -_copyJsonArrayAgg(const JsonArrayAgg *from) -{ - JsonArrayAgg *newnode = makeNode(JsonArrayAgg); - - COPY_NODE_FIELD(constructor); - COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(absent_on_null); - - return newnode; -} - -static RawStmt * -_copyRawStmt(const RawStmt *from) -{ - RawStmt *newnode = makeNode(RawStmt); - - COPY_NODE_FIELD(stmt); - COPY_LOCATION_FIELD(stmt_location); - COPY_SCALAR_FIELD(stmt_len); - - return newnode; -} - -static InsertStmt * -_copyInsertStmt(const InsertStmt *from) -{ - InsertStmt *newnode = makeNode(InsertStmt); - - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(cols); - COPY_NODE_FIELD(selectStmt); - COPY_NODE_FIELD(onConflictClause); - COPY_NODE_FIELD(returningList); - COPY_NODE_FIELD(withClause); - COPY_SCALAR_FIELD(override); - - return newnode; -} - -static DeleteStmt * -_copyDeleteStmt(const DeleteStmt *from) -{ - DeleteStmt *newnode = makeNode(DeleteStmt); - - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(usingClause); - COPY_NODE_FIELD(whereClause); - COPY_NODE_FIELD(returningList); - COPY_NODE_FIELD(withClause); - - return newnode; -} - -static UpdateStmt * -_copyUpdateStmt(const UpdateStmt *from) -{ - UpdateStmt *newnode = makeNode(UpdateStmt); - - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(targetList); - COPY_NODE_FIELD(whereClause); - COPY_NODE_FIELD(fromClause); - COPY_NODE_FIELD(returningList); - COPY_NODE_FIELD(withClause); - - return newnode; -} - -static MergeStmt * -_copyMergeStmt(const MergeStmt *from) -{ - MergeStmt *newnode = makeNode(MergeStmt); - - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(sourceRelation); - COPY_NODE_FIELD(joinCondition); - COPY_NODE_FIELD(mergeWhenClauses); - COPY_NODE_FIELD(withClause); - - return newnode; -} - -static SelectStmt * -_copySelectStmt(const SelectStmt *from) -{ - SelectStmt *newnode = makeNode(SelectStmt); - - COPY_NODE_FIELD(distinctClause); - COPY_NODE_FIELD(intoClause); - COPY_NODE_FIELD(targetList); - COPY_NODE_FIELD(fromClause); - COPY_NODE_FIELD(whereClause); - COPY_NODE_FIELD(groupClause); - COPY_SCALAR_FIELD(groupDistinct); - COPY_NODE_FIELD(havingClause); - COPY_NODE_FIELD(windowClause); - COPY_NODE_FIELD(valuesLists); - COPY_NODE_FIELD(sortClause); - COPY_NODE_FIELD(limitOffset); - COPY_NODE_FIELD(limitCount); - COPY_SCALAR_FIELD(limitOption); - COPY_NODE_FIELD(lockingClause); - COPY_NODE_FIELD(withClause); - COPY_SCALAR_FIELD(op); - COPY_SCALAR_FIELD(all); - COPY_NODE_FIELD(larg); - COPY_NODE_FIELD(rarg); - - return newnode; -} - -static SetOperationStmt * -_copySetOperationStmt(const SetOperationStmt *from) -{ - SetOperationStmt *newnode = makeNode(SetOperationStmt); - - COPY_SCALAR_FIELD(op); - COPY_SCALAR_FIELD(all); - COPY_NODE_FIELD(larg); - COPY_NODE_FIELD(rarg); - COPY_NODE_FIELD(colTypes); - COPY_NODE_FIELD(colTypmods); - COPY_NODE_FIELD(colCollations); - COPY_NODE_FIELD(groupClauses); - - return newnode; -} - -static ReturnStmt * -_copyReturnStmt(const ReturnStmt *from) -{ - ReturnStmt *newnode = makeNode(ReturnStmt); - - COPY_NODE_FIELD(returnval); - - return newnode; -} - -static PLAssignStmt * -_copyPLAssignStmt(const PLAssignStmt *from) -{ - PLAssignStmt *newnode = makeNode(PLAssignStmt); - - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(indirection); - COPY_SCALAR_FIELD(nnames); - COPY_NODE_FIELD(val); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CreateSchemaStmt * -_copyCreateSchemaStmt(const CreateSchemaStmt *from) -{ - CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt); - - COPY_STRING_FIELD(schemaname); - COPY_NODE_FIELD(authrole); - COPY_NODE_FIELD(schemaElts); - COPY_SCALAR_FIELD(if_not_exists); - - return newnode; -} - -static AlterTableStmt * -_copyAlterTableStmt(const AlterTableStmt *from) -{ - AlterTableStmt *newnode = makeNode(AlterTableStmt); - - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(cmds); - COPY_SCALAR_FIELD(objtype); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static ReplicaIdentityStmt * -_copyReplicaIdentityStmt(const ReplicaIdentityStmt *from) -{ - ReplicaIdentityStmt *newnode = makeNode(ReplicaIdentityStmt); - - COPY_SCALAR_FIELD(identity_type); - COPY_STRING_FIELD(name); - - return newnode; -} - -static AlterTableCmd * -_copyAlterTableCmd(const AlterTableCmd *from) -{ - AlterTableCmd *newnode = makeNode(AlterTableCmd); - - COPY_SCALAR_FIELD(subtype); - COPY_STRING_FIELD(name); - COPY_SCALAR_FIELD(num); - COPY_NODE_FIELD(newowner); - COPY_NODE_FIELD(def); - COPY_SCALAR_FIELD(behavior); - COPY_SCALAR_FIELD(missing_ok); - COPY_SCALAR_FIELD(recurse); - - return newnode; -} - -static AlterCollationStmt * -_copyAlterCollationStmt(const AlterCollationStmt *from) -{ - AlterCollationStmt *newnode = makeNode(AlterCollationStmt); - - COPY_NODE_FIELD(collname); - - return newnode; -} - -static AlterDomainStmt * -_copyAlterDomainStmt(const AlterDomainStmt *from) -{ - AlterDomainStmt *newnode = makeNode(AlterDomainStmt); - - COPY_SCALAR_FIELD(subtype); - COPY_NODE_FIELD(typeName); - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(def); - COPY_SCALAR_FIELD(behavior); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static GrantStmt * -_copyGrantStmt(const GrantStmt *from) -{ - GrantStmt *newnode = makeNode(GrantStmt); - - COPY_SCALAR_FIELD(is_grant); - COPY_SCALAR_FIELD(targtype); - COPY_SCALAR_FIELD(objtype); - COPY_NODE_FIELD(objects); - COPY_NODE_FIELD(privileges); - COPY_NODE_FIELD(grantees); - COPY_SCALAR_FIELD(grant_option); - COPY_NODE_FIELD(grantor); - COPY_SCALAR_FIELD(behavior); - - return newnode; -} - -static ObjectWithArgs * -_copyObjectWithArgs(const ObjectWithArgs *from) -{ - ObjectWithArgs *newnode = makeNode(ObjectWithArgs); - - COPY_NODE_FIELD(objname); - COPY_NODE_FIELD(objargs); - COPY_NODE_FIELD(objfuncargs); - COPY_SCALAR_FIELD(args_unspecified); - - return newnode; -} - -static AccessPriv * -_copyAccessPriv(const AccessPriv *from) -{ - AccessPriv *newnode = makeNode(AccessPriv); - - COPY_STRING_FIELD(priv_name); - COPY_NODE_FIELD(cols); - - return newnode; -} - -static GrantRoleStmt * -_copyGrantRoleStmt(const GrantRoleStmt *from) -{ - GrantRoleStmt *newnode = makeNode(GrantRoleStmt); - - COPY_NODE_FIELD(granted_roles); - COPY_NODE_FIELD(grantee_roles); - COPY_SCALAR_FIELD(is_grant); - COPY_NODE_FIELD(opt); - COPY_NODE_FIELD(grantor); - COPY_SCALAR_FIELD(behavior); - - return newnode; -} - -static AlterDefaultPrivilegesStmt * -_copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from) -{ - AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt); - - COPY_NODE_FIELD(options); - COPY_NODE_FIELD(action); - - return newnode; -} - -static CopyStmt * -_copyCopyStmt(const CopyStmt *from) -{ - CopyStmt *newnode = makeNode(CopyStmt); - - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(query); - COPY_NODE_FIELD(attlist); - COPY_SCALAR_FIELD(is_from); - COPY_SCALAR_FIELD(is_program); - COPY_STRING_FIELD(filename); - COPY_NODE_FIELD(options); - COPY_NODE_FIELD(whereClause); - - return newnode; -} - -static VariableSetStmt * -_copyVariableSetStmt(const VariableSetStmt *from) -{ - VariableSetStmt *newnode = makeNode(VariableSetStmt); - - COPY_SCALAR_FIELD(kind); - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(args); - COPY_SCALAR_FIELD(is_local); - - return newnode; -} - -static VariableShowStmt * -_copyVariableShowStmt(const VariableShowStmt *from) -{ - VariableShowStmt *newnode = makeNode(VariableShowStmt); - - COPY_STRING_FIELD(name); - - return newnode; -} - -static CreateStmt * -_copyCreateStmt(const CreateStmt *from) -{ - CreateStmt *newnode = makeNode(CreateStmt); - - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(tableElts); - COPY_NODE_FIELD(inhRelations); - COPY_NODE_FIELD(partbound); - COPY_NODE_FIELD(partspec); - COPY_NODE_FIELD(ofTypename); - COPY_NODE_FIELD(constraints); - COPY_NODE_FIELD(options); - COPY_SCALAR_FIELD(oncommit); - COPY_STRING_FIELD(tablespacename); - COPY_STRING_FIELD(accessMethod); - COPY_SCALAR_FIELD(if_not_exists); - - return newnode; -} - -static Constraint * -_copyConstraint(const Constraint *from) -{ - Constraint *newnode = makeNode(Constraint); - - COPY_SCALAR_FIELD(contype); - COPY_STRING_FIELD(conname); - COPY_SCALAR_FIELD(deferrable); - COPY_SCALAR_FIELD(initdeferred); - COPY_LOCATION_FIELD(location); - COPY_SCALAR_FIELD(is_no_inherit); - COPY_NODE_FIELD(raw_expr); - COPY_STRING_FIELD(cooked_expr); - COPY_SCALAR_FIELD(generated_when); - COPY_SCALAR_FIELD(nulls_not_distinct); - COPY_NODE_FIELD(keys); - COPY_NODE_FIELD(including); - COPY_NODE_FIELD(exclusions); - COPY_NODE_FIELD(options); - COPY_STRING_FIELD(indexname); - COPY_STRING_FIELD(indexspace); - COPY_SCALAR_FIELD(reset_default_tblspc); - COPY_STRING_FIELD(access_method); - COPY_NODE_FIELD(where_clause); - COPY_NODE_FIELD(pktable); - COPY_NODE_FIELD(fk_attrs); - COPY_NODE_FIELD(pk_attrs); - COPY_SCALAR_FIELD(fk_matchtype); - COPY_SCALAR_FIELD(fk_upd_action); - COPY_SCALAR_FIELD(fk_del_action); - COPY_NODE_FIELD(fk_del_set_cols); - COPY_NODE_FIELD(old_conpfeqop); - COPY_SCALAR_FIELD(old_pktable_oid); - COPY_SCALAR_FIELD(skip_validation); - COPY_SCALAR_FIELD(initially_valid); - - return newnode; -} - -static CreateTableSpaceStmt * -_copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from) -{ - CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt); - - COPY_STRING_FIELD(tablespacename); - COPY_NODE_FIELD(owner); - COPY_STRING_FIELD(location); - COPY_NODE_FIELD(options); - - return newnode; -} - -static DropTableSpaceStmt * -_copyDropTableSpaceStmt(const DropTableSpaceStmt *from) -{ - DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt); - - COPY_STRING_FIELD(tablespacename); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static AlterTableSpaceOptionsStmt * -_copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from) -{ - AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt); - - COPY_STRING_FIELD(tablespacename); - COPY_NODE_FIELD(options); - COPY_SCALAR_FIELD(isReset); - - return newnode; -} - -static AlterTableMoveAllStmt * -_copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from) -{ - AlterTableMoveAllStmt *newnode = makeNode(AlterTableMoveAllStmt); - - COPY_STRING_FIELD(orig_tablespacename); - COPY_SCALAR_FIELD(objtype); - COPY_NODE_FIELD(roles); - COPY_STRING_FIELD(new_tablespacename); - COPY_SCALAR_FIELD(nowait); - - return newnode; -} - -static CreateExtensionStmt * -_copyCreateExtensionStmt(const CreateExtensionStmt *from) -{ - CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt); - - COPY_STRING_FIELD(extname); - COPY_SCALAR_FIELD(if_not_exists); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterExtensionStmt * -_copyAlterExtensionStmt(const AlterExtensionStmt *from) -{ - AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt); - - COPY_STRING_FIELD(extname); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterExtensionContentsStmt * -_copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from) -{ - AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt); - - COPY_STRING_FIELD(extname); - COPY_SCALAR_FIELD(action); - COPY_SCALAR_FIELD(objtype); - COPY_NODE_FIELD(object); - - return newnode; -} - -static CreateFdwStmt * -_copyCreateFdwStmt(const CreateFdwStmt *from) -{ - CreateFdwStmt *newnode = makeNode(CreateFdwStmt); - - COPY_STRING_FIELD(fdwname); - COPY_NODE_FIELD(func_options); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterFdwStmt * -_copyAlterFdwStmt(const AlterFdwStmt *from) -{ - AlterFdwStmt *newnode = makeNode(AlterFdwStmt); - - COPY_STRING_FIELD(fdwname); - COPY_NODE_FIELD(func_options); - COPY_NODE_FIELD(options); - - return newnode; -} - -static CreateForeignServerStmt * -_copyCreateForeignServerStmt(const CreateForeignServerStmt *from) -{ - CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt); - - COPY_STRING_FIELD(servername); - COPY_STRING_FIELD(servertype); - COPY_STRING_FIELD(version); - COPY_STRING_FIELD(fdwname); - COPY_SCALAR_FIELD(if_not_exists); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterForeignServerStmt * -_copyAlterForeignServerStmt(const AlterForeignServerStmt *from) -{ - AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt); - - COPY_STRING_FIELD(servername); - COPY_STRING_FIELD(version); - COPY_NODE_FIELD(options); - COPY_SCALAR_FIELD(has_version); - - return newnode; -} - -static CreateForeignTableStmt * -_copyCreateForeignTableStmt(const CreateForeignTableStmt *from) -{ - CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt); - - COPY_NODE_FIELD(base.relation); - COPY_NODE_FIELD(base.tableElts); - COPY_NODE_FIELD(base.inhRelations); - COPY_NODE_FIELD(base.partbound); - COPY_NODE_FIELD(base.partspec); - COPY_NODE_FIELD(base.ofTypename); - COPY_NODE_FIELD(base.constraints); - COPY_NODE_FIELD(base.options); - COPY_SCALAR_FIELD(base.oncommit); - COPY_STRING_FIELD(base.tablespacename); - COPY_STRING_FIELD(base.accessMethod); - COPY_SCALAR_FIELD(base.if_not_exists); - COPY_STRING_FIELD(servername); - COPY_NODE_FIELD(options); - - return newnode; -} - -static CreateUserMappingStmt * -_copyCreateUserMappingStmt(const CreateUserMappingStmt *from) -{ - CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt); - - COPY_NODE_FIELD(user); - COPY_STRING_FIELD(servername); - COPY_SCALAR_FIELD(if_not_exists); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterUserMappingStmt * -_copyAlterUserMappingStmt(const AlterUserMappingStmt *from) -{ - AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt); - - COPY_NODE_FIELD(user); - COPY_STRING_FIELD(servername); - COPY_NODE_FIELD(options); - - return newnode; -} - -static DropUserMappingStmt * -_copyDropUserMappingStmt(const DropUserMappingStmt *from) -{ - DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt); - - COPY_NODE_FIELD(user); - COPY_STRING_FIELD(servername); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static ImportForeignSchemaStmt * -_copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *from) -{ - ImportForeignSchemaStmt *newnode = makeNode(ImportForeignSchemaStmt); - - COPY_STRING_FIELD(server_name); - COPY_STRING_FIELD(remote_schema); - COPY_STRING_FIELD(local_schema); - COPY_SCALAR_FIELD(list_type); - COPY_NODE_FIELD(table_list); - COPY_NODE_FIELD(options); - - return newnode; -} - -static CreatePolicyStmt * -_copyCreatePolicyStmt(const CreatePolicyStmt *from) -{ - CreatePolicyStmt *newnode = makeNode(CreatePolicyStmt); - - COPY_STRING_FIELD(policy_name); - COPY_NODE_FIELD(table); - COPY_STRING_FIELD(cmd_name); - COPY_SCALAR_FIELD(permissive); - COPY_NODE_FIELD(roles); - COPY_NODE_FIELD(qual); - COPY_NODE_FIELD(with_check); - - return newnode; -} - -static AlterPolicyStmt * -_copyAlterPolicyStmt(const AlterPolicyStmt *from) -{ - AlterPolicyStmt *newnode = makeNode(AlterPolicyStmt); - - COPY_STRING_FIELD(policy_name); - COPY_NODE_FIELD(table); - COPY_NODE_FIELD(roles); - COPY_NODE_FIELD(qual); - COPY_NODE_FIELD(with_check); - - return newnode; -} - -static CreateAmStmt * -_copyCreateAmStmt(const CreateAmStmt *from) -{ - CreateAmStmt *newnode = makeNode(CreateAmStmt); - - COPY_STRING_FIELD(amname); - COPY_NODE_FIELD(handler_name); - COPY_SCALAR_FIELD(amtype); - - return newnode; -} - -static CreateTrigStmt * -_copyCreateTrigStmt(const CreateTrigStmt *from) -{ - CreateTrigStmt *newnode = makeNode(CreateTrigStmt); - - COPY_SCALAR_FIELD(replace); - COPY_SCALAR_FIELD(isconstraint); - COPY_STRING_FIELD(trigname); - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(funcname); - COPY_NODE_FIELD(args); - COPY_SCALAR_FIELD(row); - COPY_SCALAR_FIELD(timing); - COPY_SCALAR_FIELD(events); - COPY_NODE_FIELD(columns); - COPY_NODE_FIELD(whenClause); - COPY_NODE_FIELD(transitionRels); - COPY_SCALAR_FIELD(deferrable); - COPY_SCALAR_FIELD(initdeferred); - COPY_NODE_FIELD(constrrel); - - return newnode; -} - -static CreateEventTrigStmt * -_copyCreateEventTrigStmt(const CreateEventTrigStmt *from) -{ - CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt); - - COPY_STRING_FIELD(trigname); - COPY_STRING_FIELD(eventname); - COPY_NODE_FIELD(whenclause); - COPY_NODE_FIELD(funcname); - - return newnode; -} - -static AlterEventTrigStmt * -_copyAlterEventTrigStmt(const AlterEventTrigStmt *from) -{ - AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt); - - COPY_STRING_FIELD(trigname); - COPY_SCALAR_FIELD(tgenabled); - - return newnode; -} - -static CreatePLangStmt * -_copyCreatePLangStmt(const CreatePLangStmt *from) -{ - CreatePLangStmt *newnode = makeNode(CreatePLangStmt); - - COPY_SCALAR_FIELD(replace); - COPY_STRING_FIELD(plname); - COPY_NODE_FIELD(plhandler); - COPY_NODE_FIELD(plinline); - COPY_NODE_FIELD(plvalidator); - COPY_SCALAR_FIELD(pltrusted); - - return newnode; -} - -static CreateRoleStmt * -_copyCreateRoleStmt(const CreateRoleStmt *from) -{ - CreateRoleStmt *newnode = makeNode(CreateRoleStmt); - - COPY_SCALAR_FIELD(stmt_type); - COPY_STRING_FIELD(role); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterRoleStmt * -_copyAlterRoleStmt(const AlterRoleStmt *from) -{ - AlterRoleStmt *newnode = makeNode(AlterRoleStmt); - - COPY_NODE_FIELD(role); - COPY_NODE_FIELD(options); - COPY_SCALAR_FIELD(action); - - return newnode; -} - -static AlterRoleSetStmt * -_copyAlterRoleSetStmt(const AlterRoleSetStmt *from) -{ - AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt); - - COPY_NODE_FIELD(role); - COPY_STRING_FIELD(database); - COPY_NODE_FIELD(setstmt); - - return newnode; -} - -static DropRoleStmt * -_copyDropRoleStmt(const DropRoleStmt *from) -{ - DropRoleStmt *newnode = makeNode(DropRoleStmt); - - COPY_NODE_FIELD(roles); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static CreateSeqStmt * -_copyCreateSeqStmt(const CreateSeqStmt *from) -{ - CreateSeqStmt *newnode = makeNode(CreateSeqStmt); - - COPY_NODE_FIELD(sequence); - COPY_NODE_FIELD(options); - COPY_SCALAR_FIELD(ownerId); - COPY_SCALAR_FIELD(for_identity); - COPY_SCALAR_FIELD(if_not_exists); - - return newnode; -} - -static AlterSeqStmt * -_copyAlterSeqStmt(const AlterSeqStmt *from) -{ - AlterSeqStmt *newnode = makeNode(AlterSeqStmt); - - COPY_NODE_FIELD(sequence); - COPY_NODE_FIELD(options); - COPY_SCALAR_FIELD(for_identity); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static DefineStmt * -_copyDefineStmt(const DefineStmt *from) -{ - DefineStmt *newnode = makeNode(DefineStmt); - - COPY_SCALAR_FIELD(kind); - COPY_SCALAR_FIELD(oldstyle); - COPY_NODE_FIELD(defnames); - COPY_NODE_FIELD(args); - COPY_NODE_FIELD(definition); - COPY_SCALAR_FIELD(if_not_exists); - COPY_SCALAR_FIELD(replace); - - return newnode; -} - -static CreateDomainStmt * -_copyCreateDomainStmt(const CreateDomainStmt *from) -{ - CreateDomainStmt *newnode = makeNode(CreateDomainStmt); - - COPY_NODE_FIELD(domainname); - COPY_NODE_FIELD(typeName); - COPY_NODE_FIELD(collClause); - COPY_NODE_FIELD(constraints); - - return newnode; -} - -static CreateOpClassStmt * -_copyCreateOpClassStmt(const CreateOpClassStmt *from) -{ - CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt); - - COPY_NODE_FIELD(opclassname); - COPY_NODE_FIELD(opfamilyname); - COPY_STRING_FIELD(amname); - COPY_NODE_FIELD(datatype); - COPY_NODE_FIELD(items); - COPY_SCALAR_FIELD(isDefault); - - return newnode; -} - -static CreateOpClassItem * -_copyCreateOpClassItem(const CreateOpClassItem *from) -{ - CreateOpClassItem *newnode = makeNode(CreateOpClassItem); - - COPY_SCALAR_FIELD(itemtype); - COPY_NODE_FIELD(name); - COPY_SCALAR_FIELD(number); - COPY_NODE_FIELD(order_family); - COPY_NODE_FIELD(class_args); - COPY_NODE_FIELD(storedtype); - - return newnode; -} - -static CreateOpFamilyStmt * -_copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from) -{ - CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt); - - COPY_NODE_FIELD(opfamilyname); - COPY_STRING_FIELD(amname); - - return newnode; -} - -static AlterOpFamilyStmt * -_copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from) -{ - AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt); - - COPY_NODE_FIELD(opfamilyname); - COPY_STRING_FIELD(amname); - COPY_SCALAR_FIELD(isDrop); - COPY_NODE_FIELD(items); - - return newnode; -} - -static DropStmt * -_copyDropStmt(const DropStmt *from) -{ - DropStmt *newnode = makeNode(DropStmt); - - COPY_NODE_FIELD(objects); - COPY_SCALAR_FIELD(removeType); - COPY_SCALAR_FIELD(behavior); - COPY_SCALAR_FIELD(missing_ok); - COPY_SCALAR_FIELD(concurrent); - - return newnode; -} - -static TruncateStmt * -_copyTruncateStmt(const TruncateStmt *from) -{ - TruncateStmt *newnode = makeNode(TruncateStmt); - - COPY_NODE_FIELD(relations); - COPY_SCALAR_FIELD(restart_seqs); - COPY_SCALAR_FIELD(behavior); - - return newnode; -} - -static CommentStmt * -_copyCommentStmt(const CommentStmt *from) -{ - CommentStmt *newnode = makeNode(CommentStmt); - - COPY_SCALAR_FIELD(objtype); - COPY_NODE_FIELD(object); - COPY_STRING_FIELD(comment); - - return newnode; -} - -static SecLabelStmt * -_copySecLabelStmt(const SecLabelStmt *from) -{ - SecLabelStmt *newnode = makeNode(SecLabelStmt); - - COPY_SCALAR_FIELD(objtype); - COPY_NODE_FIELD(object); - COPY_STRING_FIELD(provider); - COPY_STRING_FIELD(label); - - return newnode; -} - -static DeclareCursorStmt * -_copyDeclareCursorStmt(const DeclareCursorStmt *from) -{ - DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt); - - COPY_STRING_FIELD(portalname); - COPY_SCALAR_FIELD(options); - COPY_NODE_FIELD(query); - - return newnode; -} - -static ClosePortalStmt * -_copyClosePortalStmt(const ClosePortalStmt *from) -{ - ClosePortalStmt *newnode = makeNode(ClosePortalStmt); - - COPY_STRING_FIELD(portalname); - - return newnode; -} - -static FetchStmt * -_copyFetchStmt(const FetchStmt *from) -{ - FetchStmt *newnode = makeNode(FetchStmt); - - COPY_SCALAR_FIELD(direction); - COPY_SCALAR_FIELD(howMany); - COPY_STRING_FIELD(portalname); - COPY_SCALAR_FIELD(ismove); - - return newnode; -} - -static IndexStmt * -_copyIndexStmt(const IndexStmt *from) -{ - IndexStmt *newnode = makeNode(IndexStmt); - - COPY_STRING_FIELD(idxname); - COPY_NODE_FIELD(relation); - COPY_STRING_FIELD(accessMethod); - COPY_STRING_FIELD(tableSpace); - COPY_NODE_FIELD(indexParams); - COPY_NODE_FIELD(indexIncludingParams); - COPY_NODE_FIELD(options); - COPY_NODE_FIELD(whereClause); - COPY_NODE_FIELD(excludeOpNames); - COPY_STRING_FIELD(idxcomment); - COPY_SCALAR_FIELD(indexOid); - COPY_SCALAR_FIELD(oldNumber); - COPY_SCALAR_FIELD(oldCreateSubid); - COPY_SCALAR_FIELD(oldFirstRelfilelocatorSubid); - COPY_SCALAR_FIELD(unique); - COPY_SCALAR_FIELD(nulls_not_distinct); - COPY_SCALAR_FIELD(primary); - COPY_SCALAR_FIELD(isconstraint); - COPY_SCALAR_FIELD(deferrable); - COPY_SCALAR_FIELD(initdeferred); - COPY_SCALAR_FIELD(transformed); - COPY_SCALAR_FIELD(concurrent); - COPY_SCALAR_FIELD(if_not_exists); - COPY_SCALAR_FIELD(reset_default_tblspc); - - return newnode; -} - -static CreateStatsStmt * -_copyCreateStatsStmt(const CreateStatsStmt *from) -{ - CreateStatsStmt *newnode = makeNode(CreateStatsStmt); - - COPY_NODE_FIELD(defnames); - COPY_NODE_FIELD(stat_types); - COPY_NODE_FIELD(exprs); - COPY_NODE_FIELD(relations); - COPY_STRING_FIELD(stxcomment); - COPY_SCALAR_FIELD(transformed); - COPY_SCALAR_FIELD(if_not_exists); - - return newnode; -} - -static StatsElem * -_copyStatsElem(const StatsElem *from) -{ - StatsElem *newnode = makeNode(StatsElem); - - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(expr); - - return newnode; -} - -static AlterStatsStmt * -_copyAlterStatsStmt(const AlterStatsStmt *from) -{ - AlterStatsStmt *newnode = makeNode(AlterStatsStmt); - - COPY_NODE_FIELD(defnames); - COPY_SCALAR_FIELD(stxstattarget); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static CreateFunctionStmt * -_copyCreateFunctionStmt(const CreateFunctionStmt *from) -{ - CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt); - - COPY_SCALAR_FIELD(is_procedure); - COPY_SCALAR_FIELD(replace); - COPY_NODE_FIELD(funcname); - COPY_NODE_FIELD(parameters); - COPY_NODE_FIELD(returnType); - COPY_NODE_FIELD(options); - COPY_NODE_FIELD(sql_body); - - return newnode; -} - -static FunctionParameter * -_copyFunctionParameter(const FunctionParameter *from) -{ - FunctionParameter *newnode = makeNode(FunctionParameter); - - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(argType); - COPY_SCALAR_FIELD(mode); - COPY_NODE_FIELD(defexpr); - - return newnode; -} - -static AlterFunctionStmt * -_copyAlterFunctionStmt(const AlterFunctionStmt *from) -{ - AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt); - - COPY_SCALAR_FIELD(objtype); - COPY_NODE_FIELD(func); - COPY_NODE_FIELD(actions); - - return newnode; -} - -static DoStmt * -_copyDoStmt(const DoStmt *from) -{ - DoStmt *newnode = makeNode(DoStmt); - - COPY_NODE_FIELD(args); - - return newnode; -} - -static CallStmt * -_copyCallStmt(const CallStmt *from) -{ - CallStmt *newnode = makeNode(CallStmt); - - COPY_NODE_FIELD(funccall); - COPY_NODE_FIELD(funcexpr); - COPY_NODE_FIELD(outargs); - - return newnode; -} - -static RenameStmt * -_copyRenameStmt(const RenameStmt *from) -{ - RenameStmt *newnode = makeNode(RenameStmt); - - COPY_SCALAR_FIELD(renameType); - COPY_SCALAR_FIELD(relationType); - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(object); - COPY_STRING_FIELD(subname); - COPY_STRING_FIELD(newname); - COPY_SCALAR_FIELD(behavior); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static AlterObjectDependsStmt * -_copyAlterObjectDependsStmt(const AlterObjectDependsStmt *from) -{ - AlterObjectDependsStmt *newnode = makeNode(AlterObjectDependsStmt); - - COPY_SCALAR_FIELD(objectType); - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(object); - COPY_NODE_FIELD(extname); - COPY_SCALAR_FIELD(remove); - - return newnode; -} - -static AlterObjectSchemaStmt * -_copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from) -{ - AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt); - - COPY_SCALAR_FIELD(objectType); - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(object); - COPY_STRING_FIELD(newschema); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static AlterOwnerStmt * -_copyAlterOwnerStmt(const AlterOwnerStmt *from) -{ - AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt); - - COPY_SCALAR_FIELD(objectType); - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(object); - COPY_NODE_FIELD(newowner); - - return newnode; -} - -static AlterOperatorStmt * -_copyAlterOperatorStmt(const AlterOperatorStmt *from) -{ - AlterOperatorStmt *newnode = makeNode(AlterOperatorStmt); - - COPY_NODE_FIELD(opername); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterTypeStmt * -_copyAlterTypeStmt(const AlterTypeStmt *from) -{ - AlterTypeStmt *newnode = makeNode(AlterTypeStmt); - - COPY_NODE_FIELD(typeName); - COPY_NODE_FIELD(options); - - return newnode; -} - -static RuleStmt * -_copyRuleStmt(const RuleStmt *from) -{ - RuleStmt *newnode = makeNode(RuleStmt); - - COPY_NODE_FIELD(relation); - COPY_STRING_FIELD(rulename); - COPY_NODE_FIELD(whereClause); - COPY_SCALAR_FIELD(event); - COPY_SCALAR_FIELD(instead); - COPY_NODE_FIELD(actions); - COPY_SCALAR_FIELD(replace); - - return newnode; -} - -static NotifyStmt * -_copyNotifyStmt(const NotifyStmt *from) -{ - NotifyStmt *newnode = makeNode(NotifyStmt); - - COPY_STRING_FIELD(conditionname); - COPY_STRING_FIELD(payload); - - return newnode; -} - -static ListenStmt * -_copyListenStmt(const ListenStmt *from) -{ - ListenStmt *newnode = makeNode(ListenStmt); - - COPY_STRING_FIELD(conditionname); - - return newnode; -} - -static UnlistenStmt * -_copyUnlistenStmt(const UnlistenStmt *from) -{ - UnlistenStmt *newnode = makeNode(UnlistenStmt); - - COPY_STRING_FIELD(conditionname); - - return newnode; -} - -static TransactionStmt * -_copyTransactionStmt(const TransactionStmt *from) -{ - TransactionStmt *newnode = makeNode(TransactionStmt); - - COPY_SCALAR_FIELD(kind); - COPY_NODE_FIELD(options); - COPY_STRING_FIELD(savepoint_name); - COPY_STRING_FIELD(gid); - COPY_SCALAR_FIELD(chain); - - return newnode; -} - -static CompositeTypeStmt * -_copyCompositeTypeStmt(const CompositeTypeStmt *from) -{ - CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt); - - COPY_NODE_FIELD(typevar); - COPY_NODE_FIELD(coldeflist); - - return newnode; -} - -static CreateEnumStmt * -_copyCreateEnumStmt(const CreateEnumStmt *from) -{ - CreateEnumStmt *newnode = makeNode(CreateEnumStmt); - - COPY_NODE_FIELD(typeName); - COPY_NODE_FIELD(vals); - - return newnode; -} - -static CreateRangeStmt * -_copyCreateRangeStmt(const CreateRangeStmt *from) -{ - CreateRangeStmt *newnode = makeNode(CreateRangeStmt); - - COPY_NODE_FIELD(typeName); - COPY_NODE_FIELD(params); - - return newnode; -} - -static AlterEnumStmt * -_copyAlterEnumStmt(const AlterEnumStmt *from) -{ - AlterEnumStmt *newnode = makeNode(AlterEnumStmt); - - COPY_NODE_FIELD(typeName); - COPY_STRING_FIELD(oldVal); - COPY_STRING_FIELD(newVal); - COPY_STRING_FIELD(newValNeighbor); - COPY_SCALAR_FIELD(newValIsAfter); - COPY_SCALAR_FIELD(skipIfNewValExists); - - return newnode; -} - -static ViewStmt * -_copyViewStmt(const ViewStmt *from) -{ - ViewStmt *newnode = makeNode(ViewStmt); - - COPY_NODE_FIELD(view); - COPY_NODE_FIELD(aliases); - COPY_NODE_FIELD(query); - COPY_SCALAR_FIELD(replace); - COPY_NODE_FIELD(options); - COPY_SCALAR_FIELD(withCheckOption); - - return newnode; -} - -static LoadStmt * -_copyLoadStmt(const LoadStmt *from) -{ - LoadStmt *newnode = makeNode(LoadStmt); - - COPY_STRING_FIELD(filename); - - return newnode; -} - -static CreatedbStmt * -_copyCreatedbStmt(const CreatedbStmt *from) -{ - CreatedbStmt *newnode = makeNode(CreatedbStmt); - - COPY_STRING_FIELD(dbname); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterDatabaseStmt * -_copyAlterDatabaseStmt(const AlterDatabaseStmt *from) -{ - AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt); - - COPY_STRING_FIELD(dbname); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterDatabaseRefreshCollStmt * -_copyAlterDatabaseRefreshCollStmt(const AlterDatabaseRefreshCollStmt *from) -{ - AlterDatabaseRefreshCollStmt *newnode = makeNode(AlterDatabaseRefreshCollStmt); - - COPY_STRING_FIELD(dbname); - - return newnode; -} - -static AlterDatabaseSetStmt * -_copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from) -{ - AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt); - - COPY_STRING_FIELD(dbname); - COPY_NODE_FIELD(setstmt); - - return newnode; -} - -static DropdbStmt * -_copyDropdbStmt(const DropdbStmt *from) -{ - DropdbStmt *newnode = makeNode(DropdbStmt); - - COPY_STRING_FIELD(dbname); - COPY_SCALAR_FIELD(missing_ok); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterSystemStmt * -_copyAlterSystemStmt(const AlterSystemStmt *from) -{ - AlterSystemStmt *newnode = makeNode(AlterSystemStmt); - - COPY_NODE_FIELD(setstmt); - - return newnode; -} - -static ClusterStmt * -_copyClusterStmt(const ClusterStmt *from) -{ - ClusterStmt *newnode = makeNode(ClusterStmt); - - COPY_NODE_FIELD(relation); - COPY_STRING_FIELD(indexname); - COPY_NODE_FIELD(params); - - return newnode; -} - -static VacuumStmt * -_copyVacuumStmt(const VacuumStmt *from) -{ - VacuumStmt *newnode = makeNode(VacuumStmt); - - COPY_NODE_FIELD(options); - COPY_NODE_FIELD(rels); - COPY_SCALAR_FIELD(is_vacuumcmd); - - return newnode; -} - -static VacuumRelation * -_copyVacuumRelation(const VacuumRelation *from) -{ - VacuumRelation *newnode = makeNode(VacuumRelation); - - COPY_NODE_FIELD(relation); - COPY_SCALAR_FIELD(oid); - COPY_NODE_FIELD(va_cols); - - return newnode; -} - -static ExplainStmt * -_copyExplainStmt(const ExplainStmt *from) -{ - ExplainStmt *newnode = makeNode(ExplainStmt); - - COPY_NODE_FIELD(query); - COPY_NODE_FIELD(options); - - return newnode; -} - -static CreateTableAsStmt * -_copyCreateTableAsStmt(const CreateTableAsStmt *from) -{ - CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt); - - COPY_NODE_FIELD(query); - COPY_NODE_FIELD(into); - COPY_SCALAR_FIELD(objtype); - COPY_SCALAR_FIELD(is_select_into); - COPY_SCALAR_FIELD(if_not_exists); - - return newnode; -} - -static RefreshMatViewStmt * -_copyRefreshMatViewStmt(const RefreshMatViewStmt *from) -{ - RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt); - - COPY_SCALAR_FIELD(concurrent); - COPY_SCALAR_FIELD(skipData); - COPY_NODE_FIELD(relation); - - return newnode; -} - -static CheckPointStmt * -_copyCheckPointStmt(const CheckPointStmt *from) -{ - CheckPointStmt *newnode = makeNode(CheckPointStmt); - - - return newnode; -} - -static DiscardStmt * -_copyDiscardStmt(const DiscardStmt *from) -{ - DiscardStmt *newnode = makeNode(DiscardStmt); - - COPY_SCALAR_FIELD(target); - - return newnode; -} - -static LockStmt * -_copyLockStmt(const LockStmt *from) -{ - LockStmt *newnode = makeNode(LockStmt); - - COPY_NODE_FIELD(relations); - COPY_SCALAR_FIELD(mode); - COPY_SCALAR_FIELD(nowait); - - return newnode; -} - -static ConstraintsSetStmt * -_copyConstraintsSetStmt(const ConstraintsSetStmt *from) -{ - ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt); - - COPY_NODE_FIELD(constraints); - COPY_SCALAR_FIELD(deferred); - - return newnode; -} - -static ReindexStmt * -_copyReindexStmt(const ReindexStmt *from) -{ - ReindexStmt *newnode = makeNode(ReindexStmt); - - COPY_SCALAR_FIELD(kind); - COPY_NODE_FIELD(relation); - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(params); - - return newnode; -} - -static CreateConversionStmt * -_copyCreateConversionStmt(const CreateConversionStmt *from) -{ - CreateConversionStmt *newnode = makeNode(CreateConversionStmt); - - COPY_NODE_FIELD(conversion_name); - COPY_STRING_FIELD(for_encoding_name); - COPY_STRING_FIELD(to_encoding_name); - COPY_NODE_FIELD(func_name); - COPY_SCALAR_FIELD(def); - - return newnode; -} - -static CreateCastStmt * -_copyCreateCastStmt(const CreateCastStmt *from) -{ - CreateCastStmt *newnode = makeNode(CreateCastStmt); - - COPY_NODE_FIELD(sourcetype); - COPY_NODE_FIELD(targettype); - COPY_NODE_FIELD(func); - COPY_SCALAR_FIELD(context); - COPY_SCALAR_FIELD(inout); - - return newnode; -} - -static CreateTransformStmt * -_copyCreateTransformStmt(const CreateTransformStmt *from) -{ - CreateTransformStmt *newnode = makeNode(CreateTransformStmt); - - COPY_SCALAR_FIELD(replace); - COPY_NODE_FIELD(type_name); - COPY_STRING_FIELD(lang); - COPY_NODE_FIELD(fromsql); - COPY_NODE_FIELD(tosql); - - return newnode; -} - -static PrepareStmt * -_copyPrepareStmt(const PrepareStmt *from) -{ - PrepareStmt *newnode = makeNode(PrepareStmt); - - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(argtypes); - COPY_NODE_FIELD(query); - - return newnode; -} - -static ExecuteStmt * -_copyExecuteStmt(const ExecuteStmt *from) -{ - ExecuteStmt *newnode = makeNode(ExecuteStmt); - - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(params); - - return newnode; -} - -static DeallocateStmt * -_copyDeallocateStmt(const DeallocateStmt *from) -{ - DeallocateStmt *newnode = makeNode(DeallocateStmt); - - COPY_STRING_FIELD(name); - - return newnode; -} - -static DropOwnedStmt * -_copyDropOwnedStmt(const DropOwnedStmt *from) -{ - DropOwnedStmt *newnode = makeNode(DropOwnedStmt); - - COPY_NODE_FIELD(roles); - COPY_SCALAR_FIELD(behavior); - - return newnode; -} - -static ReassignOwnedStmt * -_copyReassignOwnedStmt(const ReassignOwnedStmt *from) -{ - ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt); - - COPY_NODE_FIELD(roles); - COPY_NODE_FIELD(newrole); - - return newnode; -} - -static AlterTSDictionaryStmt * -_copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from) -{ - AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt); - - COPY_NODE_FIELD(dictname); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterTSConfigurationStmt * -_copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from) -{ - AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt); - - COPY_SCALAR_FIELD(kind); - COPY_NODE_FIELD(cfgname); - COPY_NODE_FIELD(tokentype); - COPY_NODE_FIELD(dicts); - COPY_SCALAR_FIELD(override); - COPY_SCALAR_FIELD(replace); - COPY_SCALAR_FIELD(missing_ok); - - return newnode; -} - -static PublicationTable * -_copyPublicationTable(const PublicationTable *from) -{ - PublicationTable *newnode = makeNode(PublicationTable); - - COPY_NODE_FIELD(relation); - COPY_NODE_FIELD(whereClause); - COPY_NODE_FIELD(columns); - - return newnode; -} - -static PublicationObjSpec * -_copyPublicationObjSpec(const PublicationObjSpec *from) -{ - PublicationObjSpec *newnode = makeNode(PublicationObjSpec); - - COPY_SCALAR_FIELD(pubobjtype); - COPY_STRING_FIELD(name); - COPY_NODE_FIELD(pubtable); - COPY_LOCATION_FIELD(location); - - return newnode; -} - -static CreatePublicationStmt * -_copyCreatePublicationStmt(const CreatePublicationStmt *from) -{ - CreatePublicationStmt *newnode = makeNode(CreatePublicationStmt); - - COPY_STRING_FIELD(pubname); - COPY_NODE_FIELD(options); - COPY_NODE_FIELD(pubobjects); - COPY_SCALAR_FIELD(for_all_tables); - - return newnode; -} - -static AlterPublicationStmt * -_copyAlterPublicationStmt(const AlterPublicationStmt *from) -{ - AlterPublicationStmt *newnode = makeNode(AlterPublicationStmt); - - COPY_STRING_FIELD(pubname); - COPY_NODE_FIELD(options); - COPY_NODE_FIELD(pubobjects); - COPY_SCALAR_FIELD(for_all_tables); - COPY_SCALAR_FIELD(action); - - return newnode; -} - -static CreateSubscriptionStmt * -_copyCreateSubscriptionStmt(const CreateSubscriptionStmt *from) -{ - CreateSubscriptionStmt *newnode = makeNode(CreateSubscriptionStmt); - - COPY_STRING_FIELD(subname); - COPY_STRING_FIELD(conninfo); - COPY_NODE_FIELD(publication); - COPY_NODE_FIELD(options); - - return newnode; -} - -static AlterSubscriptionStmt * -_copyAlterSubscriptionStmt(const AlterSubscriptionStmt *from) -{ - AlterSubscriptionStmt *newnode = makeNode(AlterSubscriptionStmt); - - COPY_SCALAR_FIELD(kind); - COPY_STRING_FIELD(subname); - COPY_STRING_FIELD(conninfo); - COPY_NODE_FIELD(publication); - COPY_NODE_FIELD(options); - - return newnode; -} - -static DropSubscriptionStmt * -_copyDropSubscriptionStmt(const DropSubscriptionStmt *from) -{ - DropSubscriptionStmt *newnode = makeNode(DropSubscriptionStmt); - - COPY_STRING_FIELD(subname); - COPY_SCALAR_FIELD(missing_ok); - COPY_SCALAR_FIELD(behavior); - - return newnode; -} - -static PathKey * -_copyPathKey(const PathKey *from) -{ - PathKey *newnode = makeNode(PathKey); - - COPY_SCALAR_FIELD(pk_eclass); - COPY_SCALAR_FIELD(pk_opfamily); - COPY_SCALAR_FIELD(pk_strategy); - COPY_SCALAR_FIELD(pk_nulls_first); - - return newnode; -} - -static RestrictInfo * -_copyRestrictInfo(const RestrictInfo *from) -{ - RestrictInfo *newnode = makeNode(RestrictInfo); - - COPY_NODE_FIELD(clause); - COPY_SCALAR_FIELD(is_pushed_down); - COPY_SCALAR_FIELD(can_join); - COPY_SCALAR_FIELD(pseudoconstant); - COPY_SCALAR_FIELD(has_clone); - COPY_SCALAR_FIELD(is_clone); - COPY_SCALAR_FIELD(leakproof); - COPY_SCALAR_FIELD(has_volatile); - COPY_SCALAR_FIELD(security_level); - COPY_SCALAR_FIELD(num_base_rels); - COPY_BITMAPSET_FIELD(clause_relids); - COPY_BITMAPSET_FIELD(required_relids); - COPY_BITMAPSET_FIELD(incompatible_relids); - COPY_BITMAPSET_FIELD(outer_relids); - COPY_BITMAPSET_FIELD(left_relids); - COPY_BITMAPSET_FIELD(right_relids); - COPY_NODE_FIELD(orclause); - COPY_SCALAR_FIELD(rinfo_serial); - COPY_SCALAR_FIELD(parent_ec); - COPY_SCALAR_FIELD(eval_cost); - COPY_SCALAR_FIELD(norm_selec); - COPY_SCALAR_FIELD(outer_selec); - COPY_NODE_FIELD(mergeopfamilies); - COPY_SCALAR_FIELD(left_ec); - COPY_SCALAR_FIELD(right_ec); - COPY_SCALAR_FIELD(left_em); - COPY_SCALAR_FIELD(right_em); - newnode->scansel_cache = NIL; - COPY_SCALAR_FIELD(outer_is_left); - COPY_SCALAR_FIELD(hashjoinoperator); - COPY_SCALAR_FIELD(left_bucketsize); - COPY_SCALAR_FIELD(right_bucketsize); - COPY_SCALAR_FIELD(left_mcvfreq); - COPY_SCALAR_FIELD(right_mcvfreq); - COPY_SCALAR_FIELD(left_hasheqoperator); - COPY_SCALAR_FIELD(right_hasheqoperator); - - return newnode; -} - -static PlaceHolderVar * -_copyPlaceHolderVar(const PlaceHolderVar *from) -{ - PlaceHolderVar *newnode = makeNode(PlaceHolderVar); - - COPY_NODE_FIELD(phexpr); - COPY_BITMAPSET_FIELD(phrels); - COPY_BITMAPSET_FIELD(phnullingrels); - COPY_SCALAR_FIELD(phid); - COPY_SCALAR_FIELD(phlevelsup); - - return newnode; -} - -static SpecialJoinInfo * -_copySpecialJoinInfo(const SpecialJoinInfo *from) -{ - SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo); - - COPY_BITMAPSET_FIELD(min_lefthand); - COPY_BITMAPSET_FIELD(min_righthand); - COPY_BITMAPSET_FIELD(syn_lefthand); - COPY_BITMAPSET_FIELD(syn_righthand); - COPY_SCALAR_FIELD(jointype); - COPY_SCALAR_FIELD(ojrelid); - COPY_BITMAPSET_FIELD(commute_above_l); - COPY_BITMAPSET_FIELD(commute_above_r); - COPY_BITMAPSET_FIELD(commute_below_l); - COPY_BITMAPSET_FIELD(commute_below_r); - COPY_SCALAR_FIELD(lhs_strict); - COPY_SCALAR_FIELD(semi_can_btree); - COPY_SCALAR_FIELD(semi_can_hash); - COPY_NODE_FIELD(semi_operators); - COPY_NODE_FIELD(semi_rhs_exprs); - - return newnode; -} - -static AppendRelInfo * -_copyAppendRelInfo(const AppendRelInfo *from) -{ - AppendRelInfo *newnode = makeNode(AppendRelInfo); - - COPY_SCALAR_FIELD(parent_relid); - COPY_SCALAR_FIELD(child_relid); - COPY_SCALAR_FIELD(parent_reltype); - COPY_SCALAR_FIELD(child_reltype); - COPY_NODE_FIELD(translated_vars); - COPY_SCALAR_FIELD(num_child_cols); - COPY_POINTER_FIELD(parent_colnos, from->num_child_cols * sizeof(AttrNumber)); - COPY_SCALAR_FIELD(parent_reloid); - - return newnode; -} - -static PlaceHolderInfo * -_copyPlaceHolderInfo(const PlaceHolderInfo *from) -{ - PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo); - - COPY_SCALAR_FIELD(phid); - COPY_NODE_FIELD(ph_var); - COPY_BITMAPSET_FIELD(ph_eval_at); - COPY_BITMAPSET_FIELD(ph_lateral); - COPY_BITMAPSET_FIELD(ph_needed); - COPY_SCALAR_FIELD(ph_width); - - return newnode; -} - -static PlannedStmt * -_copyPlannedStmt(const PlannedStmt *from) -{ - PlannedStmt *newnode = makeNode(PlannedStmt); - - COPY_SCALAR_FIELD(commandType); - COPY_SCALAR_FIELD(queryId); - COPY_SCALAR_FIELD(hasReturning); - COPY_SCALAR_FIELD(hasModifyingCTE); - COPY_SCALAR_FIELD(canSetTag); - COPY_SCALAR_FIELD(transientPlan); - COPY_SCALAR_FIELD(dependsOnRole); - COPY_SCALAR_FIELD(parallelModeNeeded); - COPY_SCALAR_FIELD(jitFlags); - COPY_NODE_FIELD(planTree); - COPY_NODE_FIELD(rtable); - COPY_NODE_FIELD(permInfos); - COPY_NODE_FIELD(resultRelations); - COPY_NODE_FIELD(appendRelations); - COPY_NODE_FIELD(subplans); - COPY_BITMAPSET_FIELD(rewindPlanIDs); - COPY_NODE_FIELD(rowMarks); - COPY_NODE_FIELD(relationOids); - COPY_NODE_FIELD(invalItems); - COPY_NODE_FIELD(paramExecTypes); - COPY_NODE_FIELD(utilityStmt); - COPY_LOCATION_FIELD(stmt_location); - COPY_SCALAR_FIELD(stmt_len); - - return newnode; -} - -static Result * -_copyResult(const Result *from) -{ - Result *newnode = makeNode(Result); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_NODE_FIELD(resconstantqual); - - return newnode; -} - -static ProjectSet * -_copyProjectSet(const ProjectSet *from) -{ - ProjectSet *newnode = makeNode(ProjectSet); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - - return newnode; -} - -static ModifyTable * -_copyModifyTable(const ModifyTable *from) -{ - ModifyTable *newnode = makeNode(ModifyTable); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(operation); - COPY_SCALAR_FIELD(canSetTag); - COPY_SCALAR_FIELD(nominalRelation); - COPY_SCALAR_FIELD(rootRelation); - COPY_SCALAR_FIELD(partColsUpdated); - COPY_NODE_FIELD(resultRelations); - COPY_NODE_FIELD(updateColnosLists); - COPY_NODE_FIELD(withCheckOptionLists); - COPY_NODE_FIELD(returningLists); - COPY_NODE_FIELD(fdwPrivLists); - COPY_BITMAPSET_FIELD(fdwDirectModifyPlans); - COPY_NODE_FIELD(rowMarks); - COPY_SCALAR_FIELD(epqParam); - COPY_SCALAR_FIELD(onConflictAction); - COPY_NODE_FIELD(arbiterIndexes); - COPY_NODE_FIELD(onConflictSet); - COPY_NODE_FIELD(onConflictCols); - COPY_NODE_FIELD(onConflictWhere); - COPY_SCALAR_FIELD(exclRelRTI); - COPY_NODE_FIELD(exclRelTlist); - COPY_NODE_FIELD(mergeActionLists); - - return newnode; -} - -static Append * -_copyAppend(const Append *from) -{ - Append *newnode = makeNode(Append); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_BITMAPSET_FIELD(apprelids); - COPY_NODE_FIELD(appendplans); - COPY_SCALAR_FIELD(nasyncplans); - COPY_SCALAR_FIELD(first_partial_plan); - COPY_NODE_FIELD(part_prune_info); - - return newnode; -} - -static MergeAppend * -_copyMergeAppend(const MergeAppend *from) -{ - MergeAppend *newnode = makeNode(MergeAppend); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_BITMAPSET_FIELD(apprelids); - COPY_NODE_FIELD(mergeplans); - COPY_SCALAR_FIELD(numCols); - COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool)); - COPY_NODE_FIELD(part_prune_info); - - return newnode; -} - -static RecursiveUnion * -_copyRecursiveUnion(const RecursiveUnion *from) -{ - RecursiveUnion *newnode = makeNode(RecursiveUnion); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(wtParam); - COPY_SCALAR_FIELD(numCols); - COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(dupCollations, from->numCols * sizeof(Oid)); - COPY_SCALAR_FIELD(numGroups); - - return newnode; -} - -static BitmapAnd * -_copyBitmapAnd(const BitmapAnd *from) -{ - BitmapAnd *newnode = makeNode(BitmapAnd); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_NODE_FIELD(bitmapplans); - - return newnode; -} - -static BitmapOr * -_copyBitmapOr(const BitmapOr *from) -{ - BitmapOr *newnode = makeNode(BitmapOr); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(isshared); - COPY_NODE_FIELD(bitmapplans); - - return newnode; -} - -static SeqScan * -_copySeqScan(const SeqScan *from) -{ - SeqScan *newnode = makeNode(SeqScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - - return newnode; -} - -static SampleScan * -_copySampleScan(const SampleScan *from) -{ - SampleScan *newnode = makeNode(SampleScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_NODE_FIELD(tablesample); - - return newnode; -} - -static IndexScan * -_copyIndexScan(const IndexScan *from) -{ - IndexScan *newnode = makeNode(IndexScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_SCALAR_FIELD(indexid); - COPY_NODE_FIELD(indexqual); - COPY_NODE_FIELD(indexqualorig); - COPY_NODE_FIELD(indexorderby); - COPY_NODE_FIELD(indexorderbyorig); - COPY_NODE_FIELD(indexorderbyops); - COPY_SCALAR_FIELD(indexorderdir); - - return newnode; -} - -static IndexOnlyScan * -_copyIndexOnlyScan(const IndexOnlyScan *from) -{ - IndexOnlyScan *newnode = makeNode(IndexOnlyScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_SCALAR_FIELD(indexid); - COPY_NODE_FIELD(indexqual); - COPY_NODE_FIELD(recheckqual); - COPY_NODE_FIELD(indexorderby); - COPY_NODE_FIELD(indextlist); - COPY_SCALAR_FIELD(indexorderdir); - - return newnode; -} - -static BitmapIndexScan * -_copyBitmapIndexScan(const BitmapIndexScan *from) -{ - BitmapIndexScan *newnode = makeNode(BitmapIndexScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_SCALAR_FIELD(indexid); - COPY_SCALAR_FIELD(isshared); - COPY_NODE_FIELD(indexqual); - COPY_NODE_FIELD(indexqualorig); - - return newnode; -} - -static BitmapHeapScan * -_copyBitmapHeapScan(const BitmapHeapScan *from) -{ - BitmapHeapScan *newnode = makeNode(BitmapHeapScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_NODE_FIELD(bitmapqualorig); - - return newnode; -} - -static TidScan * -_copyTidScan(const TidScan *from) -{ - TidScan *newnode = makeNode(TidScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_NODE_FIELD(tidquals); - - return newnode; -} - -static TidRangeScan * -_copyTidRangeScan(const TidRangeScan *from) -{ - TidRangeScan *newnode = makeNode(TidRangeScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_NODE_FIELD(tidrangequals); - - return newnode; -} - -static SubqueryScan * -_copySubqueryScan(const SubqueryScan *from) -{ - SubqueryScan *newnode = makeNode(SubqueryScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_NODE_FIELD(subplan); - COPY_SCALAR_FIELD(scanstatus); - - return newnode; -} - -static FunctionScan * -_copyFunctionScan(const FunctionScan *from) -{ - FunctionScan *newnode = makeNode(FunctionScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_NODE_FIELD(functions); - COPY_SCALAR_FIELD(funcordinality); - - return newnode; -} - -static ValuesScan * -_copyValuesScan(const ValuesScan *from) -{ - ValuesScan *newnode = makeNode(ValuesScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_NODE_FIELD(values_lists); - - return newnode; -} - -static TableFuncScan * -_copyTableFuncScan(const TableFuncScan *from) -{ - TableFuncScan *newnode = makeNode(TableFuncScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_NODE_FIELD(tablefunc); - - return newnode; -} - -static CteScan * -_copyCteScan(const CteScan *from) -{ - CteScan *newnode = makeNode(CteScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_SCALAR_FIELD(ctePlanId); - COPY_SCALAR_FIELD(cteParam); - - return newnode; -} - -static NamedTuplestoreScan * -_copyNamedTuplestoreScan(const NamedTuplestoreScan *from) -{ - NamedTuplestoreScan *newnode = makeNode(NamedTuplestoreScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_STRING_FIELD(enrname); - - return newnode; -} - -static WorkTableScan * -_copyWorkTableScan(const WorkTableScan *from) -{ - WorkTableScan *newnode = makeNode(WorkTableScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_SCALAR_FIELD(wtParam); - - return newnode; -} - -static ForeignScan * -_copyForeignScan(const ForeignScan *from) -{ - ForeignScan *newnode = makeNode(ForeignScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_SCALAR_FIELD(operation); - COPY_SCALAR_FIELD(resultRelation); - COPY_SCALAR_FIELD(checkAsUser); - COPY_SCALAR_FIELD(fs_server); - COPY_NODE_FIELD(fdw_exprs); - COPY_NODE_FIELD(fdw_private); - COPY_NODE_FIELD(fdw_scan_tlist); - COPY_NODE_FIELD(fdw_recheck_quals); - COPY_BITMAPSET_FIELD(fs_relids); - COPY_BITMAPSET_FIELD(fs_base_relids); - COPY_SCALAR_FIELD(fsSystemCol); - - return newnode; -} - -static CustomScan * -_copyCustomScan(const CustomScan *from) -{ - CustomScan *newnode = makeNode(CustomScan); - - COPY_SCALAR_FIELD(scan.plan.startup_cost); - COPY_SCALAR_FIELD(scan.plan.total_cost); - COPY_SCALAR_FIELD(scan.plan.plan_rows); - COPY_SCALAR_FIELD(scan.plan.plan_width); - COPY_SCALAR_FIELD(scan.plan.parallel_aware); - COPY_SCALAR_FIELD(scan.plan.parallel_safe); - COPY_SCALAR_FIELD(scan.plan.async_capable); - COPY_SCALAR_FIELD(scan.plan.plan_node_id); - COPY_NODE_FIELD(scan.plan.targetlist); - COPY_NODE_FIELD(scan.plan.qual); - COPY_NODE_FIELD(scan.plan.lefttree); - COPY_NODE_FIELD(scan.plan.righttree); - COPY_NODE_FIELD(scan.plan.initPlan); - COPY_BITMAPSET_FIELD(scan.plan.extParam); - COPY_BITMAPSET_FIELD(scan.plan.allParam); - COPY_SCALAR_FIELD(scan.scanrelid); - COPY_SCALAR_FIELD(flags); - COPY_NODE_FIELD(custom_plans); - COPY_NODE_FIELD(custom_exprs); - COPY_NODE_FIELD(custom_private); - COPY_NODE_FIELD(custom_scan_tlist); - COPY_BITMAPSET_FIELD(custom_relids); - COPY_SCALAR_FIELD(methods); - - return newnode; -} - -static NestLoop * -_copyNestLoop(const NestLoop *from) -{ - NestLoop *newnode = makeNode(NestLoop); - - COPY_SCALAR_FIELD(join.plan.startup_cost); - COPY_SCALAR_FIELD(join.plan.total_cost); - COPY_SCALAR_FIELD(join.plan.plan_rows); - COPY_SCALAR_FIELD(join.plan.plan_width); - COPY_SCALAR_FIELD(join.plan.parallel_aware); - COPY_SCALAR_FIELD(join.plan.parallel_safe); - COPY_SCALAR_FIELD(join.plan.async_capable); - COPY_SCALAR_FIELD(join.plan.plan_node_id); - COPY_NODE_FIELD(join.plan.targetlist); - COPY_NODE_FIELD(join.plan.qual); - COPY_NODE_FIELD(join.plan.lefttree); - COPY_NODE_FIELD(join.plan.righttree); - COPY_NODE_FIELD(join.plan.initPlan); - COPY_BITMAPSET_FIELD(join.plan.extParam); - COPY_BITMAPSET_FIELD(join.plan.allParam); - COPY_SCALAR_FIELD(join.jointype); - COPY_SCALAR_FIELD(join.inner_unique); - COPY_NODE_FIELD(join.joinqual); - COPY_NODE_FIELD(nestParams); - - return newnode; -} - -static NestLoopParam * -_copyNestLoopParam(const NestLoopParam *from) -{ - NestLoopParam *newnode = makeNode(NestLoopParam); - - COPY_SCALAR_FIELD(paramno); - COPY_NODE_FIELD(paramval); - - return newnode; -} - -static MergeJoin * -_copyMergeJoin(const MergeJoin *from) -{ - MergeJoin *newnode = makeNode(MergeJoin); - - COPY_SCALAR_FIELD(join.plan.startup_cost); - COPY_SCALAR_FIELD(join.plan.total_cost); - COPY_SCALAR_FIELD(join.plan.plan_rows); - COPY_SCALAR_FIELD(join.plan.plan_width); - COPY_SCALAR_FIELD(join.plan.parallel_aware); - COPY_SCALAR_FIELD(join.plan.parallel_safe); - COPY_SCALAR_FIELD(join.plan.async_capable); - COPY_SCALAR_FIELD(join.plan.plan_node_id); - COPY_NODE_FIELD(join.plan.targetlist); - COPY_NODE_FIELD(join.plan.qual); - COPY_NODE_FIELD(join.plan.lefttree); - COPY_NODE_FIELD(join.plan.righttree); - COPY_NODE_FIELD(join.plan.initPlan); - COPY_BITMAPSET_FIELD(join.plan.extParam); - COPY_BITMAPSET_FIELD(join.plan.allParam); - COPY_SCALAR_FIELD(join.jointype); - COPY_SCALAR_FIELD(join.inner_unique); - COPY_NODE_FIELD(join.joinqual); - COPY_SCALAR_FIELD(skip_mark_restore); - COPY_NODE_FIELD(mergeclauses); - COPY_POINTER_FIELD(mergeFamilies, list_length(from->mergeclauses) * sizeof(Oid)); - COPY_POINTER_FIELD(mergeCollations, list_length(from->mergeclauses) * sizeof(Oid)); - COPY_POINTER_FIELD(mergeStrategies, list_length(from->mergeclauses) * sizeof(int)); - COPY_POINTER_FIELD(mergeNullsFirst, list_length(from->mergeclauses) * sizeof(bool)); - - return newnode; -} - -static HashJoin * -_copyHashJoin(const HashJoin *from) -{ - HashJoin *newnode = makeNode(HashJoin); - - COPY_SCALAR_FIELD(join.plan.startup_cost); - COPY_SCALAR_FIELD(join.plan.total_cost); - COPY_SCALAR_FIELD(join.plan.plan_rows); - COPY_SCALAR_FIELD(join.plan.plan_width); - COPY_SCALAR_FIELD(join.plan.parallel_aware); - COPY_SCALAR_FIELD(join.plan.parallel_safe); - COPY_SCALAR_FIELD(join.plan.async_capable); - COPY_SCALAR_FIELD(join.plan.plan_node_id); - COPY_NODE_FIELD(join.plan.targetlist); - COPY_NODE_FIELD(join.plan.qual); - COPY_NODE_FIELD(join.plan.lefttree); - COPY_NODE_FIELD(join.plan.righttree); - COPY_NODE_FIELD(join.plan.initPlan); - COPY_BITMAPSET_FIELD(join.plan.extParam); - COPY_BITMAPSET_FIELD(join.plan.allParam); - COPY_SCALAR_FIELD(join.jointype); - COPY_SCALAR_FIELD(join.inner_unique); - COPY_NODE_FIELD(join.joinqual); - COPY_NODE_FIELD(hashclauses); - COPY_NODE_FIELD(hashoperators); - COPY_NODE_FIELD(hashcollations); - COPY_NODE_FIELD(hashkeys); - - return newnode; -} - -static Material * -_copyMaterial(const Material *from) -{ - Material *newnode = makeNode(Material); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - - return newnode; -} - -static Memoize * -_copyMemoize(const Memoize *from) -{ - Memoize *newnode = makeNode(Memoize); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(numKeys); - COPY_POINTER_FIELD(hashOperators, from->numKeys * sizeof(Oid)); - COPY_POINTER_FIELD(collations, from->numKeys * sizeof(Oid)); - COPY_NODE_FIELD(param_exprs); - COPY_SCALAR_FIELD(singlerow); - COPY_SCALAR_FIELD(binary_mode); - COPY_SCALAR_FIELD(est_entries); - COPY_BITMAPSET_FIELD(keyparamids); - - return newnode; -} - -static Sort * -_copySort(const Sort *from) -{ - Sort *newnode = makeNode(Sort); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(numCols); - COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool)); - - return newnode; -} - -static IncrementalSort * -_copyIncrementalSort(const IncrementalSort *from) -{ - IncrementalSort *newnode = makeNode(IncrementalSort); - - COPY_SCALAR_FIELD(sort.plan.startup_cost); - COPY_SCALAR_FIELD(sort.plan.total_cost); - COPY_SCALAR_FIELD(sort.plan.plan_rows); - COPY_SCALAR_FIELD(sort.plan.plan_width); - COPY_SCALAR_FIELD(sort.plan.parallel_aware); - COPY_SCALAR_FIELD(sort.plan.parallel_safe); - COPY_SCALAR_FIELD(sort.plan.async_capable); - COPY_SCALAR_FIELD(sort.plan.plan_node_id); - COPY_NODE_FIELD(sort.plan.targetlist); - COPY_NODE_FIELD(sort.plan.qual); - COPY_NODE_FIELD(sort.plan.lefttree); - COPY_NODE_FIELD(sort.plan.righttree); - COPY_NODE_FIELD(sort.plan.initPlan); - COPY_BITMAPSET_FIELD(sort.plan.extParam); - COPY_BITMAPSET_FIELD(sort.plan.allParam); - COPY_SCALAR_FIELD(sort.numCols); - COPY_POINTER_FIELD(sort.sortColIdx, from->sort.numCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(sort.sortOperators, from->sort.numCols * sizeof(Oid)); - COPY_POINTER_FIELD(sort.collations, from->sort.numCols * sizeof(Oid)); - COPY_POINTER_FIELD(sort.nullsFirst, from->sort.numCols * sizeof(bool)); - COPY_SCALAR_FIELD(nPresortedCols); - - return newnode; -} - -static Group * -_copyGroup(const Group *from) -{ - Group *newnode = makeNode(Group); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(numCols); - COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(grpCollations, from->numCols * sizeof(Oid)); - - return newnode; -} - -static Agg * -_copyAgg(const Agg *from) -{ - Agg *newnode = makeNode(Agg); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(aggstrategy); - COPY_SCALAR_FIELD(aggsplit); - COPY_SCALAR_FIELD(numCols); - COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(grpCollations, from->numCols * sizeof(Oid)); - COPY_SCALAR_FIELD(numGroups); - COPY_SCALAR_FIELD(transitionSpace); - COPY_BITMAPSET_FIELD(aggParams); - COPY_NODE_FIELD(groupingSets); - COPY_NODE_FIELD(chain); - - return newnode; -} - -static WindowAgg * -_copyWindowAgg(const WindowAgg *from) -{ - WindowAgg *newnode = makeNode(WindowAgg); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(winref); - COPY_SCALAR_FIELD(partNumCols); - COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid)); - COPY_POINTER_FIELD(partCollations, from->partNumCols * sizeof(Oid)); - COPY_SCALAR_FIELD(ordNumCols); - COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid)); - COPY_POINTER_FIELD(ordCollations, from->ordNumCols * sizeof(Oid)); - COPY_SCALAR_FIELD(frameOptions); - COPY_NODE_FIELD(startOffset); - COPY_NODE_FIELD(endOffset); - COPY_NODE_FIELD(runCondition); - COPY_NODE_FIELD(runConditionOrig); - COPY_SCALAR_FIELD(startInRangeFunc); - COPY_SCALAR_FIELD(endInRangeFunc); - COPY_SCALAR_FIELD(inRangeColl); - COPY_SCALAR_FIELD(inRangeAsc); - COPY_SCALAR_FIELD(inRangeNullsFirst); - COPY_SCALAR_FIELD(topWindow); - - return newnode; -} - -static Unique * -_copyUnique(const Unique *from) -{ - Unique *newnode = makeNode(Unique); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(numCols); - COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(uniqCollations, from->numCols * sizeof(Oid)); - - return newnode; -} - -static Gather * -_copyGather(const Gather *from) -{ - Gather *newnode = makeNode(Gather); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(num_workers); - COPY_SCALAR_FIELD(rescan_param); - COPY_SCALAR_FIELD(single_copy); - COPY_SCALAR_FIELD(invisible); - COPY_BITMAPSET_FIELD(initParam); - - return newnode; -} - -static GatherMerge * -_copyGatherMerge(const GatherMerge *from) -{ - GatherMerge *newnode = makeNode(GatherMerge); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(num_workers); - COPY_SCALAR_FIELD(rescan_param); - COPY_SCALAR_FIELD(numCols); - COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool)); - COPY_BITMAPSET_FIELD(initParam); - - return newnode; -} - -static Hash * -_copyHash(const Hash *from) -{ - Hash *newnode = makeNode(Hash); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_NODE_FIELD(hashkeys); - COPY_SCALAR_FIELD(skewTable); - COPY_SCALAR_FIELD(skewColumn); - COPY_SCALAR_FIELD(skewInherit); - COPY_SCALAR_FIELD(rows_total); - - return newnode; -} - -static SetOp * -_copySetOp(const SetOp *from) -{ - SetOp *newnode = makeNode(SetOp); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_SCALAR_FIELD(cmd); - COPY_SCALAR_FIELD(strategy); - COPY_SCALAR_FIELD(numCols); - COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid)); - COPY_POINTER_FIELD(dupCollations, from->numCols * sizeof(Oid)); - COPY_SCALAR_FIELD(flagColIdx); - COPY_SCALAR_FIELD(firstFlag); - COPY_SCALAR_FIELD(numGroups); - - return newnode; -} - -static LockRows * -_copyLockRows(const LockRows *from) -{ - LockRows *newnode = makeNode(LockRows); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_NODE_FIELD(rowMarks); - COPY_SCALAR_FIELD(epqParam); - - return newnode; -} - -static Limit * -_copyLimit(const Limit *from) -{ - Limit *newnode = makeNode(Limit); - - COPY_SCALAR_FIELD(plan.startup_cost); - COPY_SCALAR_FIELD(plan.total_cost); - COPY_SCALAR_FIELD(plan.plan_rows); - COPY_SCALAR_FIELD(plan.plan_width); - COPY_SCALAR_FIELD(plan.parallel_aware); - COPY_SCALAR_FIELD(plan.parallel_safe); - COPY_SCALAR_FIELD(plan.async_capable); - COPY_SCALAR_FIELD(plan.plan_node_id); - COPY_NODE_FIELD(plan.targetlist); - COPY_NODE_FIELD(plan.qual); - COPY_NODE_FIELD(plan.lefttree); - COPY_NODE_FIELD(plan.righttree); - COPY_NODE_FIELD(plan.initPlan); - COPY_BITMAPSET_FIELD(plan.extParam); - COPY_BITMAPSET_FIELD(plan.allParam); - COPY_NODE_FIELD(limitOffset); - COPY_NODE_FIELD(limitCount); - COPY_SCALAR_FIELD(limitOption); - COPY_SCALAR_FIELD(uniqNumCols); - COPY_POINTER_FIELD(uniqColIdx, from->uniqNumCols * sizeof(AttrNumber)); - COPY_POINTER_FIELD(uniqOperators, from->uniqNumCols * sizeof(Oid)); - COPY_POINTER_FIELD(uniqCollations, from->uniqNumCols * sizeof(Oid)); - - return newnode; -} - -static PlanRowMark * -_copyPlanRowMark(const PlanRowMark *from) -{ - PlanRowMark *newnode = makeNode(PlanRowMark); - - COPY_SCALAR_FIELD(rti); - COPY_SCALAR_FIELD(prti); - COPY_SCALAR_FIELD(rowmarkId); - COPY_SCALAR_FIELD(markType); - COPY_SCALAR_FIELD(allMarkTypes); - COPY_SCALAR_FIELD(strength); - COPY_SCALAR_FIELD(waitPolicy); - COPY_SCALAR_FIELD(isParent); - - return newnode; -} - -static PartitionPruneInfo * -_copyPartitionPruneInfo(const PartitionPruneInfo *from) -{ - PartitionPruneInfo *newnode = makeNode(PartitionPruneInfo); - - COPY_NODE_FIELD(prune_infos); - COPY_BITMAPSET_FIELD(other_subplans); - - return newnode; -} - -static PartitionedRelPruneInfo * -_copyPartitionedRelPruneInfo(const PartitionedRelPruneInfo *from) -{ - PartitionedRelPruneInfo *newnode = makeNode(PartitionedRelPruneInfo); - - COPY_SCALAR_FIELD(rtindex); - COPY_BITMAPSET_FIELD(present_parts); - COPY_SCALAR_FIELD(nparts); - COPY_POINTER_FIELD(subplan_map, from->nparts * sizeof(int)); - COPY_POINTER_FIELD(subpart_map, from->nparts * sizeof(int)); - COPY_POINTER_FIELD(relid_map, from->nparts * sizeof(Oid)); - COPY_NODE_FIELD(initial_pruning_steps); - COPY_NODE_FIELD(exec_pruning_steps); - COPY_BITMAPSET_FIELD(execparamids); - - return newnode; -} - -static PartitionPruneStepOp * -_copyPartitionPruneStepOp(const PartitionPruneStepOp *from) -{ - PartitionPruneStepOp *newnode = makeNode(PartitionPruneStepOp); - - COPY_SCALAR_FIELD(step.step_id); - COPY_SCALAR_FIELD(opstrategy); - COPY_NODE_FIELD(exprs); - COPY_NODE_FIELD(cmpfns); - COPY_BITMAPSET_FIELD(nullkeys); - - return newnode; -} - -static PartitionPruneStepCombine * -_copyPartitionPruneStepCombine(const PartitionPruneStepCombine *from) -{ - PartitionPruneStepCombine *newnode = makeNode(PartitionPruneStepCombine); - - COPY_SCALAR_FIELD(step.step_id); - COPY_SCALAR_FIELD(combineOp); - COPY_NODE_FIELD(source_stepids); - - return newnode; -} - -static PlanInvalItem * -_copyPlanInvalItem(const PlanInvalItem *from) -{ - PlanInvalItem *newnode = makeNode(PlanInvalItem); - - COPY_SCALAR_FIELD(cacheId); - COPY_SCALAR_FIELD(hashValue); - - return newnode; -} - -static Integer * -_copyInteger(const Integer *from) -{ - Integer *newnode = makeNode(Integer); - - COPY_SCALAR_FIELD(ival); - - return newnode; -} - -static Float * -_copyFloat(const Float *from) -{ - Float *newnode = makeNode(Float); - - COPY_STRING_FIELD(fval); - - return newnode; -} - -static Boolean * -_copyBoolean(const Boolean *from) -{ - Boolean *newnode = makeNode(Boolean); - - COPY_SCALAR_FIELD(boolval); - - return newnode; -} - -static String * -_copyString(const String *from) -{ - String *newnode = makeNode(String); - - COPY_STRING_FIELD(sval); - - return newnode; -} - -static BitString * -_copyBitString(const BitString *from) -{ - BitString *newnode = makeNode(BitString); - - COPY_STRING_FIELD(bsval); - - return newnode; -} - -static ForeignKeyCacheInfo * -_copyForeignKeyCacheInfo(const ForeignKeyCacheInfo *from) -{ - ForeignKeyCacheInfo *newnode = makeNode(ForeignKeyCacheInfo); - - COPY_SCALAR_FIELD(conoid); - COPY_SCALAR_FIELD(conrelid); - COPY_SCALAR_FIELD(confrelid); - COPY_SCALAR_FIELD(nkeys); - COPY_ARRAY_FIELD(conkey); - COPY_ARRAY_FIELD(confkey); - COPY_ARRAY_FIELD(conpfeqop); - - return newnode; -} diff --git a/parser/include/src_backend_nodes_equalfuncs.funcs.c b/parser/include/src_backend_nodes_equalfuncs.funcs.c deleted file mode 100644 index f0fdb85f..00000000 --- a/parser/include/src_backend_nodes_equalfuncs.funcs.c +++ /dev/null @@ -1,3354 +0,0 @@ -/*-------------------------------------------------------------------- - * Symbols referenced in this file: - * - _equalAlias - * - _equalRangeVar - * - _equalTableFunc - * - _equalIntoClause - * - _equalVar - * - _equalParam - * - _equalAggref - * - _equalGroupingFunc - * - _equalWindowFunc - * - _equalSubscriptingRef - * - _equalFuncExpr - * - _equalNamedArgExpr - * - _equalOpExpr - * - _equalDistinctExpr - * - _equalNullIfExpr - * - _equalScalarArrayOpExpr - * - _equalBoolExpr - * - _equalSubLink - * - _equalSubPlan - * - _equalAlternativeSubPlan - * - _equalFieldSelect - * - _equalFieldStore - * - _equalRelabelType - * - _equalCoerceViaIO - * - _equalArrayCoerceExpr - * - _equalConvertRowtypeExpr - * - _equalCollateExpr - * - _equalCaseExpr - * - _equalCaseWhen - * - _equalCaseTestExpr - * - _equalArrayExpr - * - _equalRowExpr - * - _equalRowCompareExpr - * - _equalCoalesceExpr - * - _equalMinMaxExpr - * - _equalSQLValueFunction - * - _equalXmlExpr - * - _equalJsonFormat - * - _equalJsonReturning - * - _equalJsonValueExpr - * - _equalJsonConstructorExpr - * - _equalJsonIsPredicate - * - _equalNullTest - * - _equalBooleanTest - * - _equalCoerceToDomain - * - _equalCoerceToDomainValue - * - _equalSetToDefault - * - _equalCurrentOfExpr - * - _equalNextValueExpr - * - _equalInferenceElem - * - _equalTargetEntry - * - _equalRangeTblRef - * - _equalJoinExpr - * - _equalFromExpr - * - _equalOnConflictExpr - * - _equalQuery - * - _equalTypeName - * - _equalColumnRef - * - _equalParamRef - * - _equalA_Expr - * - _equalTypeCast - * - _equalCollateClause - * - _equalRoleSpec - * - _equalFuncCall - * - _equalA_Star - * - _equalA_Indices - * - _equalA_Indirection - * - _equalA_ArrayExpr - * - _equalResTarget - * - _equalMultiAssignRef - * - _equalSortBy - * - _equalWindowDef - * - _equalRangeSubselect - * - _equalRangeFunction - * - _equalRangeTableFunc - * - _equalRangeTableFuncCol - * - _equalRangeTableSample - * - _equalColumnDef - * - _equalTableLikeClause - * - _equalIndexElem - * - _equalDefElem - * - _equalLockingClause - * - _equalXmlSerialize - * - _equalPartitionElem - * - _equalPartitionSpec - * - _equalPartitionBoundSpec - * - _equalPartitionRangeDatum - * - _equalPartitionCmd - * - _equalRangeTblEntry - * - _equalRTEPermissionInfo - * - _equalRangeTblFunction - * - _equalTableSampleClause - * - _equalWithCheckOption - * - _equalSortGroupClause - * - _equalGroupingSet - * - _equalWindowClause - * - _equalRowMarkClause - * - _equalWithClause - * - _equalInferClause - * - _equalOnConflictClause - * - _equalCTESearchClause - * - _equalCTECycleClause - * - _equalCommonTableExpr - * - _equalMergeWhenClause - * - _equalMergeAction - * - _equalTriggerTransition - * - _equalJsonOutput - * - _equalJsonKeyValue - * - _equalJsonObjectConstructor - * - _equalJsonArrayConstructor - * - _equalJsonArrayQueryConstructor - * - _equalJsonAggConstructor - * - _equalJsonObjectAgg - * - _equalJsonArrayAgg - * - _equalRawStmt - * - _equalInsertStmt - * - _equalDeleteStmt - * - _equalUpdateStmt - * - _equalMergeStmt - * - _equalSelectStmt - * - _equalSetOperationStmt - * - _equalReturnStmt - * - _equalPLAssignStmt - * - _equalCreateSchemaStmt - * - _equalAlterTableStmt - * - _equalReplicaIdentityStmt - * - _equalAlterTableCmd - * - _equalAlterCollationStmt - * - _equalAlterDomainStmt - * - _equalGrantStmt - * - _equalObjectWithArgs - * - _equalAccessPriv - * - _equalGrantRoleStmt - * - _equalAlterDefaultPrivilegesStmt - * - _equalCopyStmt - * - _equalVariableSetStmt - * - _equalVariableShowStmt - * - _equalCreateStmt - * - _equalConstraint - * - _equalCreateTableSpaceStmt - * - _equalDropTableSpaceStmt - * - _equalAlterTableSpaceOptionsStmt - * - _equalAlterTableMoveAllStmt - * - _equalCreateExtensionStmt - * - _equalAlterExtensionStmt - * - _equalAlterExtensionContentsStmt - * - _equalCreateFdwStmt - * - _equalAlterFdwStmt - * - _equalCreateForeignServerStmt - * - _equalAlterForeignServerStmt - * - _equalCreateForeignTableStmt - * - _equalCreateUserMappingStmt - * - _equalAlterUserMappingStmt - * - _equalDropUserMappingStmt - * - _equalImportForeignSchemaStmt - * - _equalCreatePolicyStmt - * - _equalAlterPolicyStmt - * - _equalCreateAmStmt - * - _equalCreateTrigStmt - * - _equalCreateEventTrigStmt - * - _equalAlterEventTrigStmt - * - _equalCreatePLangStmt - * - _equalCreateRoleStmt - * - _equalAlterRoleStmt - * - _equalAlterRoleSetStmt - * - _equalDropRoleStmt - * - _equalCreateSeqStmt - * - _equalAlterSeqStmt - * - _equalDefineStmt - * - _equalCreateDomainStmt - * - _equalCreateOpClassStmt - * - _equalCreateOpClassItem - * - _equalCreateOpFamilyStmt - * - _equalAlterOpFamilyStmt - * - _equalDropStmt - * - _equalTruncateStmt - * - _equalCommentStmt - * - _equalSecLabelStmt - * - _equalDeclareCursorStmt - * - _equalClosePortalStmt - * - _equalFetchStmt - * - _equalIndexStmt - * - _equalCreateStatsStmt - * - _equalStatsElem - * - _equalAlterStatsStmt - * - _equalCreateFunctionStmt - * - _equalFunctionParameter - * - _equalAlterFunctionStmt - * - _equalDoStmt - * - _equalCallStmt - * - _equalRenameStmt - * - _equalAlterObjectDependsStmt - * - _equalAlterObjectSchemaStmt - * - _equalAlterOwnerStmt - * - _equalAlterOperatorStmt - * - _equalAlterTypeStmt - * - _equalRuleStmt - * - _equalNotifyStmt - * - _equalListenStmt - * - _equalUnlistenStmt - * - _equalTransactionStmt - * - _equalCompositeTypeStmt - * - _equalCreateEnumStmt - * - _equalCreateRangeStmt - * - _equalAlterEnumStmt - * - _equalViewStmt - * - _equalLoadStmt - * - _equalCreatedbStmt - * - _equalAlterDatabaseStmt - * - _equalAlterDatabaseRefreshCollStmt - * - _equalAlterDatabaseSetStmt - * - _equalDropdbStmt - * - _equalAlterSystemStmt - * - _equalClusterStmt - * - _equalVacuumStmt - * - _equalVacuumRelation - * - _equalExplainStmt - * - _equalCreateTableAsStmt - * - _equalRefreshMatViewStmt - * - _equalCheckPointStmt - * - _equalDiscardStmt - * - _equalLockStmt - * - _equalConstraintsSetStmt - * - _equalReindexStmt - * - _equalCreateConversionStmt - * - _equalCreateCastStmt - * - _equalCreateTransformStmt - * - _equalPrepareStmt - * - _equalExecuteStmt - * - _equalDeallocateStmt - * - _equalDropOwnedStmt - * - _equalReassignOwnedStmt - * - _equalAlterTSDictionaryStmt - * - _equalAlterTSConfigurationStmt - * - _equalPublicationTable - * - _equalPublicationObjSpec - * - _equalCreatePublicationStmt - * - _equalAlterPublicationStmt - * - _equalCreateSubscriptionStmt - * - _equalAlterSubscriptionStmt - * - _equalDropSubscriptionStmt - * - _equalPathKey - * - _equalRestrictInfo - * - _equalPlaceHolderVar - * - _equalSpecialJoinInfo - * - _equalAppendRelInfo - * - _equalPlaceHolderInfo - * - _equalInteger - * - _equalFloat - * - _equalBoolean - * - _equalString - * - _equalBitString - *-------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------- - * - * equalfuncs.funcs.c - * Generated node infrastructure code - * - * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * NOTES - * ****************************** - * *** DO NOT EDIT THIS FILE! *** - * ****************************** - * - * It has been GENERATED by src/backend/nodes/gen_node_support.pl - * - *------------------------------------------------------------------------- - */ -#include "access/amapi.h" -#include "access/sdir.h" -#include "access/tableam.h" -#include "access/tsmapi.h" -#include "commands/event_trigger.h" -#include "commands/trigger.h" -#include "executor/tuptable.h" -#include "foreign/fdwapi.h" -#include "nodes/bitmapset.h" -#include "nodes/execnodes.h" -#include "nodes/extensible.h" -#include "nodes/lockoptions.h" -#include "nodes/miscnodes.h" -#include "nodes/nodes.h" -#include "nodes/parsenodes.h" -#include "nodes/pathnodes.h" -#include "nodes/plannodes.h" -#include "nodes/primnodes.h" -#include "nodes/replnodes.h" -#include "nodes/supportnodes.h" -#include "nodes/value.h" -#include "utils/rel.h" - -static bool -_equalAlias(const Alias *a, const Alias *b) -{ - COMPARE_STRING_FIELD(aliasname); - COMPARE_NODE_FIELD(colnames); - - return true; -} - -static bool -_equalRangeVar(const RangeVar *a, const RangeVar *b) -{ - COMPARE_STRING_FIELD(catalogname); - COMPARE_STRING_FIELD(schemaname); - COMPARE_STRING_FIELD(relname); - COMPARE_SCALAR_FIELD(inh); - COMPARE_SCALAR_FIELD(relpersistence); - COMPARE_NODE_FIELD(alias); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalTableFunc(const TableFunc *a, const TableFunc *b) -{ - COMPARE_NODE_FIELD(ns_uris); - COMPARE_NODE_FIELD(ns_names); - COMPARE_NODE_FIELD(docexpr); - COMPARE_NODE_FIELD(rowexpr); - COMPARE_NODE_FIELD(colnames); - COMPARE_NODE_FIELD(coltypes); - COMPARE_NODE_FIELD(coltypmods); - COMPARE_NODE_FIELD(colcollations); - COMPARE_NODE_FIELD(colexprs); - COMPARE_NODE_FIELD(coldefexprs); - COMPARE_BITMAPSET_FIELD(notnulls); - COMPARE_SCALAR_FIELD(ordinalitycol); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalIntoClause(const IntoClause *a, const IntoClause *b) -{ - COMPARE_NODE_FIELD(rel); - COMPARE_NODE_FIELD(colNames); - COMPARE_STRING_FIELD(accessMethod); - COMPARE_NODE_FIELD(options); - COMPARE_SCALAR_FIELD(onCommit); - COMPARE_STRING_FIELD(tableSpaceName); - COMPARE_NODE_FIELD(viewQuery); - COMPARE_SCALAR_FIELD(skipData); - - return true; -} - -static bool -_equalVar(const Var *a, const Var *b) -{ - COMPARE_SCALAR_FIELD(varno); - COMPARE_SCALAR_FIELD(varattno); - COMPARE_SCALAR_FIELD(vartype); - COMPARE_SCALAR_FIELD(vartypmod); - COMPARE_SCALAR_FIELD(varcollid); - COMPARE_BITMAPSET_FIELD(varnullingrels); - COMPARE_SCALAR_FIELD(varlevelsup); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalParam(const Param *a, const Param *b) -{ - COMPARE_SCALAR_FIELD(paramkind); - COMPARE_SCALAR_FIELD(paramid); - COMPARE_SCALAR_FIELD(paramtype); - COMPARE_SCALAR_FIELD(paramtypmod); - COMPARE_SCALAR_FIELD(paramcollid); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalAggref(const Aggref *a, const Aggref *b) -{ - COMPARE_SCALAR_FIELD(aggfnoid); - COMPARE_SCALAR_FIELD(aggtype); - COMPARE_SCALAR_FIELD(aggcollid); - COMPARE_SCALAR_FIELD(inputcollid); - COMPARE_NODE_FIELD(aggargtypes); - COMPARE_NODE_FIELD(aggdirectargs); - COMPARE_NODE_FIELD(args); - COMPARE_NODE_FIELD(aggorder); - COMPARE_NODE_FIELD(aggdistinct); - COMPARE_NODE_FIELD(aggfilter); - COMPARE_SCALAR_FIELD(aggstar); - COMPARE_SCALAR_FIELD(aggvariadic); - COMPARE_SCALAR_FIELD(aggkind); - COMPARE_SCALAR_FIELD(agglevelsup); - COMPARE_SCALAR_FIELD(aggsplit); - COMPARE_SCALAR_FIELD(aggno); - COMPARE_SCALAR_FIELD(aggtransno); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalGroupingFunc(const GroupingFunc *a, const GroupingFunc *b) -{ - COMPARE_NODE_FIELD(args); - COMPARE_SCALAR_FIELD(agglevelsup); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalWindowFunc(const WindowFunc *a, const WindowFunc *b) -{ - COMPARE_SCALAR_FIELD(winfnoid); - COMPARE_SCALAR_FIELD(wintype); - COMPARE_SCALAR_FIELD(wincollid); - COMPARE_SCALAR_FIELD(inputcollid); - COMPARE_NODE_FIELD(args); - COMPARE_NODE_FIELD(aggfilter); - COMPARE_SCALAR_FIELD(winref); - COMPARE_SCALAR_FIELD(winstar); - COMPARE_SCALAR_FIELD(winagg); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalSubscriptingRef(const SubscriptingRef *a, const SubscriptingRef *b) -{ - COMPARE_SCALAR_FIELD(refcontainertype); - COMPARE_SCALAR_FIELD(refelemtype); - COMPARE_SCALAR_FIELD(refrestype); - COMPARE_SCALAR_FIELD(reftypmod); - COMPARE_SCALAR_FIELD(refcollid); - COMPARE_NODE_FIELD(refupperindexpr); - COMPARE_NODE_FIELD(reflowerindexpr); - COMPARE_NODE_FIELD(refexpr); - COMPARE_NODE_FIELD(refassgnexpr); - - return true; -} - -static bool -_equalFuncExpr(const FuncExpr *a, const FuncExpr *b) -{ - COMPARE_SCALAR_FIELD(funcid); - COMPARE_SCALAR_FIELD(funcresulttype); - COMPARE_SCALAR_FIELD(funcretset); - COMPARE_SCALAR_FIELD(funcvariadic); - COMPARE_SCALAR_FIELD(funccollid); - COMPARE_SCALAR_FIELD(inputcollid); - COMPARE_NODE_FIELD(args); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalNamedArgExpr(const NamedArgExpr *a, const NamedArgExpr *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_STRING_FIELD(name); - COMPARE_SCALAR_FIELD(argnumber); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalOpExpr(const OpExpr *a, const OpExpr *b) -{ - COMPARE_SCALAR_FIELD(opno); - if (a->opfuncid != b->opfuncid && a->opfuncid != 0 && b->opfuncid != 0) - return false; - COMPARE_SCALAR_FIELD(opresulttype); - COMPARE_SCALAR_FIELD(opretset); - COMPARE_SCALAR_FIELD(opcollid); - COMPARE_SCALAR_FIELD(inputcollid); - COMPARE_NODE_FIELD(args); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalDistinctExpr(const DistinctExpr *a, const DistinctExpr *b) -{ - COMPARE_SCALAR_FIELD(opno); - if (a->opfuncid != b->opfuncid && a->opfuncid != 0 && b->opfuncid != 0) - return false; - COMPARE_SCALAR_FIELD(opresulttype); - COMPARE_SCALAR_FIELD(opretset); - COMPARE_SCALAR_FIELD(opcollid); - COMPARE_SCALAR_FIELD(inputcollid); - COMPARE_NODE_FIELD(args); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalNullIfExpr(const NullIfExpr *a, const NullIfExpr *b) -{ - COMPARE_SCALAR_FIELD(opno); - if (a->opfuncid != b->opfuncid && a->opfuncid != 0 && b->opfuncid != 0) - return false; - COMPARE_SCALAR_FIELD(opresulttype); - COMPARE_SCALAR_FIELD(opretset); - COMPARE_SCALAR_FIELD(opcollid); - COMPARE_SCALAR_FIELD(inputcollid); - COMPARE_NODE_FIELD(args); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalScalarArrayOpExpr(const ScalarArrayOpExpr *a, const ScalarArrayOpExpr *b) -{ - COMPARE_SCALAR_FIELD(opno); - if (a->opfuncid != b->opfuncid && a->opfuncid != 0 && b->opfuncid != 0) - return false; - if (a->hashfuncid != b->hashfuncid && a->hashfuncid != 0 && b->hashfuncid != 0) - return false; - if (a->negfuncid != b->negfuncid && a->negfuncid != 0 && b->negfuncid != 0) - return false; - COMPARE_SCALAR_FIELD(useOr); - COMPARE_SCALAR_FIELD(inputcollid); - COMPARE_NODE_FIELD(args); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalBoolExpr(const BoolExpr *a, const BoolExpr *b) -{ - COMPARE_SCALAR_FIELD(boolop); - COMPARE_NODE_FIELD(args); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalSubLink(const SubLink *a, const SubLink *b) -{ - COMPARE_SCALAR_FIELD(subLinkType); - COMPARE_SCALAR_FIELD(subLinkId); - COMPARE_NODE_FIELD(testexpr); - COMPARE_NODE_FIELD(operName); - COMPARE_NODE_FIELD(subselect); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalSubPlan(const SubPlan *a, const SubPlan *b) -{ - COMPARE_SCALAR_FIELD(subLinkType); - COMPARE_NODE_FIELD(testexpr); - COMPARE_NODE_FIELD(paramIds); - COMPARE_SCALAR_FIELD(plan_id); - COMPARE_STRING_FIELD(plan_name); - COMPARE_SCALAR_FIELD(firstColType); - COMPARE_SCALAR_FIELD(firstColTypmod); - COMPARE_SCALAR_FIELD(firstColCollation); - COMPARE_SCALAR_FIELD(useHashTable); - COMPARE_SCALAR_FIELD(unknownEqFalse); - COMPARE_SCALAR_FIELD(parallel_safe); - COMPARE_NODE_FIELD(setParam); - COMPARE_NODE_FIELD(parParam); - COMPARE_NODE_FIELD(args); - COMPARE_SCALAR_FIELD(startup_cost); - COMPARE_SCALAR_FIELD(per_call_cost); - - return true; -} - -static bool -_equalAlternativeSubPlan(const AlternativeSubPlan *a, const AlternativeSubPlan *b) -{ - COMPARE_NODE_FIELD(subplans); - - return true; -} - -static bool -_equalFieldSelect(const FieldSelect *a, const FieldSelect *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(fieldnum); - COMPARE_SCALAR_FIELD(resulttype); - COMPARE_SCALAR_FIELD(resulttypmod); - COMPARE_SCALAR_FIELD(resultcollid); - - return true; -} - -static bool -_equalFieldStore(const FieldStore *a, const FieldStore *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_NODE_FIELD(newvals); - COMPARE_NODE_FIELD(fieldnums); - COMPARE_SCALAR_FIELD(resulttype); - - return true; -} - -static bool -_equalRelabelType(const RelabelType *a, const RelabelType *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(resulttype); - COMPARE_SCALAR_FIELD(resulttypmod); - COMPARE_SCALAR_FIELD(resultcollid); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCoerceViaIO(const CoerceViaIO *a, const CoerceViaIO *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(resulttype); - COMPARE_SCALAR_FIELD(resultcollid); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalArrayCoerceExpr(const ArrayCoerceExpr *a, const ArrayCoerceExpr *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_NODE_FIELD(elemexpr); - COMPARE_SCALAR_FIELD(resulttype); - COMPARE_SCALAR_FIELD(resulttypmod); - COMPARE_SCALAR_FIELD(resultcollid); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalConvertRowtypeExpr(const ConvertRowtypeExpr *a, const ConvertRowtypeExpr *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(resulttype); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCollateExpr(const CollateExpr *a, const CollateExpr *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(collOid); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCaseExpr(const CaseExpr *a, const CaseExpr *b) -{ - COMPARE_SCALAR_FIELD(casetype); - COMPARE_SCALAR_FIELD(casecollid); - COMPARE_NODE_FIELD(arg); - COMPARE_NODE_FIELD(args); - COMPARE_NODE_FIELD(defresult); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCaseWhen(const CaseWhen *a, const CaseWhen *b) -{ - COMPARE_NODE_FIELD(expr); - COMPARE_NODE_FIELD(result); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCaseTestExpr(const CaseTestExpr *a, const CaseTestExpr *b) -{ - COMPARE_SCALAR_FIELD(typeId); - COMPARE_SCALAR_FIELD(typeMod); - COMPARE_SCALAR_FIELD(collation); - - return true; -} - -static bool -_equalArrayExpr(const ArrayExpr *a, const ArrayExpr *b) -{ - COMPARE_SCALAR_FIELD(array_typeid); - COMPARE_SCALAR_FIELD(array_collid); - COMPARE_SCALAR_FIELD(element_typeid); - COMPARE_NODE_FIELD(elements); - COMPARE_SCALAR_FIELD(multidims); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalRowExpr(const RowExpr *a, const RowExpr *b) -{ - COMPARE_NODE_FIELD(args); - COMPARE_SCALAR_FIELD(row_typeid); - COMPARE_NODE_FIELD(colnames); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalRowCompareExpr(const RowCompareExpr *a, const RowCompareExpr *b) -{ - COMPARE_SCALAR_FIELD(rctype); - COMPARE_NODE_FIELD(opnos); - COMPARE_NODE_FIELD(opfamilies); - COMPARE_NODE_FIELD(inputcollids); - COMPARE_NODE_FIELD(largs); - COMPARE_NODE_FIELD(rargs); - - return true; -} - -static bool -_equalCoalesceExpr(const CoalesceExpr *a, const CoalesceExpr *b) -{ - COMPARE_SCALAR_FIELD(coalescetype); - COMPARE_SCALAR_FIELD(coalescecollid); - COMPARE_NODE_FIELD(args); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalMinMaxExpr(const MinMaxExpr *a, const MinMaxExpr *b) -{ - COMPARE_SCALAR_FIELD(minmaxtype); - COMPARE_SCALAR_FIELD(minmaxcollid); - COMPARE_SCALAR_FIELD(inputcollid); - COMPARE_SCALAR_FIELD(op); - COMPARE_NODE_FIELD(args); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalSQLValueFunction(const SQLValueFunction *a, const SQLValueFunction *b) -{ - COMPARE_SCALAR_FIELD(op); - COMPARE_SCALAR_FIELD(type); - COMPARE_SCALAR_FIELD(typmod); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalXmlExpr(const XmlExpr *a, const XmlExpr *b) -{ - COMPARE_SCALAR_FIELD(op); - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(named_args); - COMPARE_NODE_FIELD(arg_names); - COMPARE_NODE_FIELD(args); - COMPARE_SCALAR_FIELD(xmloption); - COMPARE_SCALAR_FIELD(indent); - COMPARE_SCALAR_FIELD(type); - COMPARE_SCALAR_FIELD(typmod); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalJsonFormat(const JsonFormat *a, const JsonFormat *b) -{ - COMPARE_SCALAR_FIELD(format_type); - COMPARE_SCALAR_FIELD(encoding); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalJsonReturning(const JsonReturning *a, const JsonReturning *b) -{ - COMPARE_NODE_FIELD(format); - COMPARE_SCALAR_FIELD(typid); - COMPARE_SCALAR_FIELD(typmod); - - return true; -} - -static bool -_equalJsonValueExpr(const JsonValueExpr *a, const JsonValueExpr *b) -{ - COMPARE_NODE_FIELD(raw_expr); - COMPARE_NODE_FIELD(formatted_expr); - COMPARE_NODE_FIELD(format); - - return true; -} - -static bool -_equalJsonConstructorExpr(const JsonConstructorExpr *a, const JsonConstructorExpr *b) -{ - COMPARE_SCALAR_FIELD(type); - COMPARE_NODE_FIELD(args); - COMPARE_NODE_FIELD(func); - COMPARE_NODE_FIELD(coercion); - COMPARE_NODE_FIELD(returning); - COMPARE_SCALAR_FIELD(absent_on_null); - COMPARE_SCALAR_FIELD(unique); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalJsonIsPredicate(const JsonIsPredicate *a, const JsonIsPredicate *b) -{ - COMPARE_NODE_FIELD(expr); - COMPARE_NODE_FIELD(format); - COMPARE_SCALAR_FIELD(item_type); - COMPARE_SCALAR_FIELD(unique_keys); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalNullTest(const NullTest *a, const NullTest *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(nulltesttype); - COMPARE_SCALAR_FIELD(argisrow); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalBooleanTest(const BooleanTest *a, const BooleanTest *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(booltesttype); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCoerceToDomain(const CoerceToDomain *a, const CoerceToDomain *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(resulttype); - COMPARE_SCALAR_FIELD(resulttypmod); - COMPARE_SCALAR_FIELD(resultcollid); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCoerceToDomainValue(const CoerceToDomainValue *a, const CoerceToDomainValue *b) -{ - COMPARE_SCALAR_FIELD(typeId); - COMPARE_SCALAR_FIELD(typeMod); - COMPARE_SCALAR_FIELD(collation); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalSetToDefault(const SetToDefault *a, const SetToDefault *b) -{ - COMPARE_SCALAR_FIELD(typeId); - COMPARE_SCALAR_FIELD(typeMod); - COMPARE_SCALAR_FIELD(collation); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCurrentOfExpr(const CurrentOfExpr *a, const CurrentOfExpr *b) -{ - COMPARE_SCALAR_FIELD(cvarno); - COMPARE_STRING_FIELD(cursor_name); - COMPARE_SCALAR_FIELD(cursor_param); - - return true; -} - -static bool -_equalNextValueExpr(const NextValueExpr *a, const NextValueExpr *b) -{ - COMPARE_SCALAR_FIELD(seqid); - COMPARE_SCALAR_FIELD(typeId); - - return true; -} - -static bool -_equalInferenceElem(const InferenceElem *a, const InferenceElem *b) -{ - COMPARE_NODE_FIELD(expr); - COMPARE_SCALAR_FIELD(infercollid); - COMPARE_SCALAR_FIELD(inferopclass); - - return true; -} - -static bool -_equalTargetEntry(const TargetEntry *a, const TargetEntry *b) -{ - COMPARE_NODE_FIELD(expr); - COMPARE_SCALAR_FIELD(resno); - COMPARE_STRING_FIELD(resname); - COMPARE_SCALAR_FIELD(ressortgroupref); - COMPARE_SCALAR_FIELD(resorigtbl); - COMPARE_SCALAR_FIELD(resorigcol); - COMPARE_SCALAR_FIELD(resjunk); - - return true; -} - -static bool -_equalRangeTblRef(const RangeTblRef *a, const RangeTblRef *b) -{ - COMPARE_SCALAR_FIELD(rtindex); - - return true; -} - -static bool -_equalJoinExpr(const JoinExpr *a, const JoinExpr *b) -{ - COMPARE_SCALAR_FIELD(jointype); - COMPARE_SCALAR_FIELD(isNatural); - COMPARE_NODE_FIELD(larg); - COMPARE_NODE_FIELD(rarg); - COMPARE_NODE_FIELD(usingClause); - COMPARE_NODE_FIELD(join_using_alias); - COMPARE_NODE_FIELD(quals); - COMPARE_NODE_FIELD(alias); - COMPARE_SCALAR_FIELD(rtindex); - - return true; -} - -static bool -_equalFromExpr(const FromExpr *a, const FromExpr *b) -{ - COMPARE_NODE_FIELD(fromlist); - COMPARE_NODE_FIELD(quals); - - return true; -} - -static bool -_equalOnConflictExpr(const OnConflictExpr *a, const OnConflictExpr *b) -{ - COMPARE_SCALAR_FIELD(action); - COMPARE_NODE_FIELD(arbiterElems); - COMPARE_NODE_FIELD(arbiterWhere); - COMPARE_SCALAR_FIELD(constraint); - COMPARE_NODE_FIELD(onConflictSet); - COMPARE_NODE_FIELD(onConflictWhere); - COMPARE_SCALAR_FIELD(exclRelIndex); - COMPARE_NODE_FIELD(exclRelTlist); - - return true; -} - -static bool -_equalQuery(const Query *a, const Query *b) -{ - COMPARE_SCALAR_FIELD(commandType); - COMPARE_SCALAR_FIELD(querySource); - COMPARE_SCALAR_FIELD(canSetTag); - COMPARE_NODE_FIELD(utilityStmt); - COMPARE_SCALAR_FIELD(resultRelation); - COMPARE_SCALAR_FIELD(hasAggs); - COMPARE_SCALAR_FIELD(hasWindowFuncs); - COMPARE_SCALAR_FIELD(hasTargetSRFs); - COMPARE_SCALAR_FIELD(hasSubLinks); - COMPARE_SCALAR_FIELD(hasDistinctOn); - COMPARE_SCALAR_FIELD(hasRecursive); - COMPARE_SCALAR_FIELD(hasModifyingCTE); - COMPARE_SCALAR_FIELD(hasForUpdate); - COMPARE_SCALAR_FIELD(hasRowSecurity); - COMPARE_SCALAR_FIELD(isReturn); - COMPARE_NODE_FIELD(cteList); - COMPARE_NODE_FIELD(rtable); - COMPARE_NODE_FIELD(rteperminfos); - COMPARE_NODE_FIELD(jointree); - COMPARE_NODE_FIELD(mergeActionList); - COMPARE_SCALAR_FIELD(mergeUseOuterJoin); - COMPARE_NODE_FIELD(targetList); - COMPARE_SCALAR_FIELD(override); - COMPARE_NODE_FIELD(onConflict); - COMPARE_NODE_FIELD(returningList); - COMPARE_NODE_FIELD(groupClause); - COMPARE_SCALAR_FIELD(groupDistinct); - COMPARE_NODE_FIELD(groupingSets); - COMPARE_NODE_FIELD(havingQual); - COMPARE_NODE_FIELD(windowClause); - COMPARE_NODE_FIELD(distinctClause); - COMPARE_NODE_FIELD(sortClause); - COMPARE_NODE_FIELD(limitOffset); - COMPARE_NODE_FIELD(limitCount); - COMPARE_SCALAR_FIELD(limitOption); - COMPARE_NODE_FIELD(rowMarks); - COMPARE_NODE_FIELD(setOperations); - COMPARE_NODE_FIELD(constraintDeps); - COMPARE_NODE_FIELD(withCheckOptions); - COMPARE_LOCATION_FIELD(stmt_location); - COMPARE_SCALAR_FIELD(stmt_len); - - return true; -} - -static bool -_equalTypeName(const TypeName *a, const TypeName *b) -{ - COMPARE_NODE_FIELD(names); - COMPARE_SCALAR_FIELD(typeOid); - COMPARE_SCALAR_FIELD(setof); - COMPARE_SCALAR_FIELD(pct_type); - COMPARE_NODE_FIELD(typmods); - COMPARE_SCALAR_FIELD(typemod); - COMPARE_NODE_FIELD(arrayBounds); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalColumnRef(const ColumnRef *a, const ColumnRef *b) -{ - COMPARE_NODE_FIELD(fields); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalParamRef(const ParamRef *a, const ParamRef *b) -{ - COMPARE_SCALAR_FIELD(number); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalA_Expr(const A_Expr *a, const A_Expr *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_NODE_FIELD(name); - COMPARE_NODE_FIELD(lexpr); - COMPARE_NODE_FIELD(rexpr); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalTypeCast(const TypeCast *a, const TypeCast *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_NODE_FIELD(typeName); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCollateClause(const CollateClause *a, const CollateClause *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_NODE_FIELD(collname); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalRoleSpec(const RoleSpec *a, const RoleSpec *b) -{ - COMPARE_SCALAR_FIELD(roletype); - COMPARE_STRING_FIELD(rolename); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalFuncCall(const FuncCall *a, const FuncCall *b) -{ - COMPARE_NODE_FIELD(funcname); - COMPARE_NODE_FIELD(args); - COMPARE_NODE_FIELD(agg_order); - COMPARE_NODE_FIELD(agg_filter); - COMPARE_NODE_FIELD(over); - COMPARE_SCALAR_FIELD(agg_within_group); - COMPARE_SCALAR_FIELD(agg_star); - COMPARE_SCALAR_FIELD(agg_distinct); - COMPARE_SCALAR_FIELD(func_variadic); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalA_Star(const A_Star *a, const A_Star *b) -{ - - return true; -} - -static bool -_equalA_Indices(const A_Indices *a, const A_Indices *b) -{ - COMPARE_SCALAR_FIELD(is_slice); - COMPARE_NODE_FIELD(lidx); - COMPARE_NODE_FIELD(uidx); - - return true; -} - -static bool -_equalA_Indirection(const A_Indirection *a, const A_Indirection *b) -{ - COMPARE_NODE_FIELD(arg); - COMPARE_NODE_FIELD(indirection); - - return true; -} - -static bool -_equalA_ArrayExpr(const A_ArrayExpr *a, const A_ArrayExpr *b) -{ - COMPARE_NODE_FIELD(elements); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalResTarget(const ResTarget *a, const ResTarget *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(indirection); - COMPARE_NODE_FIELD(val); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalMultiAssignRef(const MultiAssignRef *a, const MultiAssignRef *b) -{ - COMPARE_NODE_FIELD(source); - COMPARE_SCALAR_FIELD(colno); - COMPARE_SCALAR_FIELD(ncolumns); - - return true; -} - -static bool -_equalSortBy(const SortBy *a, const SortBy *b) -{ - COMPARE_NODE_FIELD(node); - COMPARE_SCALAR_FIELD(sortby_dir); - COMPARE_SCALAR_FIELD(sortby_nulls); - COMPARE_NODE_FIELD(useOp); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalWindowDef(const WindowDef *a, const WindowDef *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_STRING_FIELD(refname); - COMPARE_NODE_FIELD(partitionClause); - COMPARE_NODE_FIELD(orderClause); - COMPARE_SCALAR_FIELD(frameOptions); - COMPARE_NODE_FIELD(startOffset); - COMPARE_NODE_FIELD(endOffset); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalRangeSubselect(const RangeSubselect *a, const RangeSubselect *b) -{ - COMPARE_SCALAR_FIELD(lateral); - COMPARE_NODE_FIELD(subquery); - COMPARE_NODE_FIELD(alias); - - return true; -} - -static bool -_equalRangeFunction(const RangeFunction *a, const RangeFunction *b) -{ - COMPARE_SCALAR_FIELD(lateral); - COMPARE_SCALAR_FIELD(ordinality); - COMPARE_SCALAR_FIELD(is_rowsfrom); - COMPARE_NODE_FIELD(functions); - COMPARE_NODE_FIELD(alias); - COMPARE_NODE_FIELD(coldeflist); - - return true; -} - -static bool -_equalRangeTableFunc(const RangeTableFunc *a, const RangeTableFunc *b) -{ - COMPARE_SCALAR_FIELD(lateral); - COMPARE_NODE_FIELD(docexpr); - COMPARE_NODE_FIELD(rowexpr); - COMPARE_NODE_FIELD(namespaces); - COMPARE_NODE_FIELD(columns); - COMPARE_NODE_FIELD(alias); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalRangeTableFuncCol(const RangeTableFuncCol *a, const RangeTableFuncCol *b) -{ - COMPARE_STRING_FIELD(colname); - COMPARE_NODE_FIELD(typeName); - COMPARE_SCALAR_FIELD(for_ordinality); - COMPARE_SCALAR_FIELD(is_not_null); - COMPARE_NODE_FIELD(colexpr); - COMPARE_NODE_FIELD(coldefexpr); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalRangeTableSample(const RangeTableSample *a, const RangeTableSample *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(method); - COMPARE_NODE_FIELD(args); - COMPARE_NODE_FIELD(repeatable); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalColumnDef(const ColumnDef *a, const ColumnDef *b) -{ - COMPARE_STRING_FIELD(colname); - COMPARE_NODE_FIELD(typeName); - COMPARE_STRING_FIELD(compression); - COMPARE_SCALAR_FIELD(inhcount); - COMPARE_SCALAR_FIELD(is_local); - COMPARE_SCALAR_FIELD(is_not_null); - COMPARE_SCALAR_FIELD(is_from_type); - COMPARE_SCALAR_FIELD(storage); - COMPARE_STRING_FIELD(storage_name); - COMPARE_NODE_FIELD(raw_default); - COMPARE_NODE_FIELD(cooked_default); - COMPARE_SCALAR_FIELD(identity); - COMPARE_NODE_FIELD(identitySequence); - COMPARE_SCALAR_FIELD(generated); - COMPARE_NODE_FIELD(collClause); - COMPARE_SCALAR_FIELD(collOid); - COMPARE_NODE_FIELD(constraints); - COMPARE_NODE_FIELD(fdwoptions); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalTableLikeClause(const TableLikeClause *a, const TableLikeClause *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_SCALAR_FIELD(options); - COMPARE_SCALAR_FIELD(relationOid); - - return true; -} - -static bool -_equalIndexElem(const IndexElem *a, const IndexElem *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(expr); - COMPARE_STRING_FIELD(indexcolname); - COMPARE_NODE_FIELD(collation); - COMPARE_NODE_FIELD(opclass); - COMPARE_NODE_FIELD(opclassopts); - COMPARE_SCALAR_FIELD(ordering); - COMPARE_SCALAR_FIELD(nulls_ordering); - - return true; -} - -static bool -_equalDefElem(const DefElem *a, const DefElem *b) -{ - COMPARE_STRING_FIELD(defnamespace); - COMPARE_STRING_FIELD(defname); - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(defaction); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalLockingClause(const LockingClause *a, const LockingClause *b) -{ - COMPARE_NODE_FIELD(lockedRels); - COMPARE_SCALAR_FIELD(strength); - COMPARE_SCALAR_FIELD(waitPolicy); - - return true; -} - -static bool -_equalXmlSerialize(const XmlSerialize *a, const XmlSerialize *b) -{ - COMPARE_SCALAR_FIELD(xmloption); - COMPARE_NODE_FIELD(expr); - COMPARE_NODE_FIELD(typeName); - COMPARE_SCALAR_FIELD(indent); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalPartitionElem(const PartitionElem *a, const PartitionElem *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(expr); - COMPARE_NODE_FIELD(collation); - COMPARE_NODE_FIELD(opclass); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalPartitionSpec(const PartitionSpec *a, const PartitionSpec *b) -{ - COMPARE_SCALAR_FIELD(strategy); - COMPARE_NODE_FIELD(partParams); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalPartitionBoundSpec(const PartitionBoundSpec *a, const PartitionBoundSpec *b) -{ - COMPARE_SCALAR_FIELD(strategy); - COMPARE_SCALAR_FIELD(is_default); - COMPARE_SCALAR_FIELD(modulus); - COMPARE_SCALAR_FIELD(remainder); - COMPARE_NODE_FIELD(listdatums); - COMPARE_NODE_FIELD(lowerdatums); - COMPARE_NODE_FIELD(upperdatums); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalPartitionRangeDatum(const PartitionRangeDatum *a, const PartitionRangeDatum *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_NODE_FIELD(value); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalPartitionCmd(const PartitionCmd *a, const PartitionCmd *b) -{ - COMPARE_NODE_FIELD(name); - COMPARE_NODE_FIELD(bound); - COMPARE_SCALAR_FIELD(concurrent); - - return true; -} - -static bool -_equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b) -{ - COMPARE_SCALAR_FIELD(rtekind); - COMPARE_SCALAR_FIELD(relid); - COMPARE_SCALAR_FIELD(relkind); - COMPARE_SCALAR_FIELD(rellockmode); - COMPARE_NODE_FIELD(tablesample); - COMPARE_SCALAR_FIELD(perminfoindex); - COMPARE_NODE_FIELD(subquery); - COMPARE_SCALAR_FIELD(security_barrier); - COMPARE_SCALAR_FIELD(jointype); - COMPARE_SCALAR_FIELD(joinmergedcols); - COMPARE_NODE_FIELD(joinaliasvars); - COMPARE_NODE_FIELD(joinleftcols); - COMPARE_NODE_FIELD(joinrightcols); - COMPARE_NODE_FIELD(join_using_alias); - COMPARE_NODE_FIELD(functions); - COMPARE_SCALAR_FIELD(funcordinality); - COMPARE_NODE_FIELD(tablefunc); - COMPARE_NODE_FIELD(values_lists); - COMPARE_STRING_FIELD(ctename); - COMPARE_SCALAR_FIELD(ctelevelsup); - COMPARE_SCALAR_FIELD(self_reference); - COMPARE_NODE_FIELD(coltypes); - COMPARE_NODE_FIELD(coltypmods); - COMPARE_NODE_FIELD(colcollations); - COMPARE_STRING_FIELD(enrname); - COMPARE_SCALAR_FIELD(enrtuples); - COMPARE_NODE_FIELD(alias); - COMPARE_NODE_FIELD(eref); - COMPARE_SCALAR_FIELD(lateral); - COMPARE_SCALAR_FIELD(inh); - COMPARE_SCALAR_FIELD(inFromCl); - COMPARE_NODE_FIELD(securityQuals); - - return true; -} - -static bool -_equalRTEPermissionInfo(const RTEPermissionInfo *a, const RTEPermissionInfo *b) -{ - COMPARE_SCALAR_FIELD(relid); - COMPARE_SCALAR_FIELD(inh); - COMPARE_SCALAR_FIELD(requiredPerms); - COMPARE_SCALAR_FIELD(checkAsUser); - COMPARE_BITMAPSET_FIELD(selectedCols); - COMPARE_BITMAPSET_FIELD(insertedCols); - COMPARE_BITMAPSET_FIELD(updatedCols); - - return true; -} - -static bool -_equalRangeTblFunction(const RangeTblFunction *a, const RangeTblFunction *b) -{ - COMPARE_NODE_FIELD(funcexpr); - COMPARE_SCALAR_FIELD(funccolcount); - COMPARE_NODE_FIELD(funccolnames); - COMPARE_NODE_FIELD(funccoltypes); - COMPARE_NODE_FIELD(funccoltypmods); - COMPARE_NODE_FIELD(funccolcollations); - COMPARE_BITMAPSET_FIELD(funcparams); - - return true; -} - -static bool -_equalTableSampleClause(const TableSampleClause *a, const TableSampleClause *b) -{ - COMPARE_SCALAR_FIELD(tsmhandler); - COMPARE_NODE_FIELD(args); - COMPARE_NODE_FIELD(repeatable); - - return true; -} - -static bool -_equalWithCheckOption(const WithCheckOption *a, const WithCheckOption *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_STRING_FIELD(relname); - COMPARE_STRING_FIELD(polname); - COMPARE_NODE_FIELD(qual); - COMPARE_SCALAR_FIELD(cascaded); - - return true; -} - -static bool -_equalSortGroupClause(const SortGroupClause *a, const SortGroupClause *b) -{ - COMPARE_SCALAR_FIELD(tleSortGroupRef); - COMPARE_SCALAR_FIELD(eqop); - COMPARE_SCALAR_FIELD(sortop); - COMPARE_SCALAR_FIELD(nulls_first); - COMPARE_SCALAR_FIELD(hashable); - - return true; -} - -static bool -_equalGroupingSet(const GroupingSet *a, const GroupingSet *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_NODE_FIELD(content); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalWindowClause(const WindowClause *a, const WindowClause *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_STRING_FIELD(refname); - COMPARE_NODE_FIELD(partitionClause); - COMPARE_NODE_FIELD(orderClause); - COMPARE_SCALAR_FIELD(frameOptions); - COMPARE_NODE_FIELD(startOffset); - COMPARE_NODE_FIELD(endOffset); - COMPARE_NODE_FIELD(runCondition); - COMPARE_SCALAR_FIELD(startInRangeFunc); - COMPARE_SCALAR_FIELD(endInRangeFunc); - COMPARE_SCALAR_FIELD(inRangeColl); - COMPARE_SCALAR_FIELD(inRangeAsc); - COMPARE_SCALAR_FIELD(inRangeNullsFirst); - COMPARE_SCALAR_FIELD(winref); - COMPARE_SCALAR_FIELD(copiedOrder); - - return true; -} - -static bool -_equalRowMarkClause(const RowMarkClause *a, const RowMarkClause *b) -{ - COMPARE_SCALAR_FIELD(rti); - COMPARE_SCALAR_FIELD(strength); - COMPARE_SCALAR_FIELD(waitPolicy); - COMPARE_SCALAR_FIELD(pushedDown); - - return true; -} - -static bool -_equalWithClause(const WithClause *a, const WithClause *b) -{ - COMPARE_NODE_FIELD(ctes); - COMPARE_SCALAR_FIELD(recursive); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalInferClause(const InferClause *a, const InferClause *b) -{ - COMPARE_NODE_FIELD(indexElems); - COMPARE_NODE_FIELD(whereClause); - COMPARE_STRING_FIELD(conname); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalOnConflictClause(const OnConflictClause *a, const OnConflictClause *b) -{ - COMPARE_SCALAR_FIELD(action); - COMPARE_NODE_FIELD(infer); - COMPARE_NODE_FIELD(targetList); - COMPARE_NODE_FIELD(whereClause); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCTESearchClause(const CTESearchClause *a, const CTESearchClause *b) -{ - COMPARE_NODE_FIELD(search_col_list); - COMPARE_SCALAR_FIELD(search_breadth_first); - COMPARE_STRING_FIELD(search_seq_column); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCTECycleClause(const CTECycleClause *a, const CTECycleClause *b) -{ - COMPARE_NODE_FIELD(cycle_col_list); - COMPARE_STRING_FIELD(cycle_mark_column); - COMPARE_NODE_FIELD(cycle_mark_value); - COMPARE_NODE_FIELD(cycle_mark_default); - COMPARE_STRING_FIELD(cycle_path_column); - COMPARE_LOCATION_FIELD(location); - COMPARE_SCALAR_FIELD(cycle_mark_type); - COMPARE_SCALAR_FIELD(cycle_mark_typmod); - COMPARE_SCALAR_FIELD(cycle_mark_collation); - COMPARE_SCALAR_FIELD(cycle_mark_neop); - - return true; -} - -static bool -_equalCommonTableExpr(const CommonTableExpr *a, const CommonTableExpr *b) -{ - COMPARE_STRING_FIELD(ctename); - COMPARE_NODE_FIELD(aliascolnames); - COMPARE_SCALAR_FIELD(ctematerialized); - COMPARE_NODE_FIELD(ctequery); - COMPARE_NODE_FIELD(search_clause); - COMPARE_NODE_FIELD(cycle_clause); - COMPARE_LOCATION_FIELD(location); - COMPARE_SCALAR_FIELD(cterecursive); - COMPARE_SCALAR_FIELD(cterefcount); - COMPARE_NODE_FIELD(ctecolnames); - COMPARE_NODE_FIELD(ctecoltypes); - COMPARE_NODE_FIELD(ctecoltypmods); - COMPARE_NODE_FIELD(ctecolcollations); - - return true; -} - -static bool -_equalMergeWhenClause(const MergeWhenClause *a, const MergeWhenClause *b) -{ - COMPARE_SCALAR_FIELD(matched); - COMPARE_SCALAR_FIELD(commandType); - COMPARE_SCALAR_FIELD(override); - COMPARE_NODE_FIELD(condition); - COMPARE_NODE_FIELD(targetList); - COMPARE_NODE_FIELD(values); - - return true; -} - -static bool -_equalMergeAction(const MergeAction *a, const MergeAction *b) -{ - COMPARE_SCALAR_FIELD(matched); - COMPARE_SCALAR_FIELD(commandType); - COMPARE_SCALAR_FIELD(override); - COMPARE_NODE_FIELD(qual); - COMPARE_NODE_FIELD(targetList); - COMPARE_NODE_FIELD(updateColnos); - - return true; -} - -static bool -_equalTriggerTransition(const TriggerTransition *a, const TriggerTransition *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_SCALAR_FIELD(isNew); - COMPARE_SCALAR_FIELD(isTable); - - return true; -} - -static bool -_equalJsonOutput(const JsonOutput *a, const JsonOutput *b) -{ - COMPARE_NODE_FIELD(typeName); - COMPARE_NODE_FIELD(returning); - - return true; -} - -static bool -_equalJsonKeyValue(const JsonKeyValue *a, const JsonKeyValue *b) -{ - COMPARE_NODE_FIELD(key); - COMPARE_NODE_FIELD(value); - - return true; -} - -static bool -_equalJsonObjectConstructor(const JsonObjectConstructor *a, const JsonObjectConstructor *b) -{ - COMPARE_NODE_FIELD(exprs); - COMPARE_NODE_FIELD(output); - COMPARE_SCALAR_FIELD(absent_on_null); - COMPARE_SCALAR_FIELD(unique); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalJsonArrayConstructor(const JsonArrayConstructor *a, const JsonArrayConstructor *b) -{ - COMPARE_NODE_FIELD(exprs); - COMPARE_NODE_FIELD(output); - COMPARE_SCALAR_FIELD(absent_on_null); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalJsonArrayQueryConstructor(const JsonArrayQueryConstructor *a, const JsonArrayQueryConstructor *b) -{ - COMPARE_NODE_FIELD(query); - COMPARE_NODE_FIELD(output); - COMPARE_NODE_FIELD(format); - COMPARE_SCALAR_FIELD(absent_on_null); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalJsonAggConstructor(const JsonAggConstructor *a, const JsonAggConstructor *b) -{ - COMPARE_NODE_FIELD(output); - COMPARE_NODE_FIELD(agg_filter); - COMPARE_NODE_FIELD(agg_order); - COMPARE_NODE_FIELD(over); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalJsonObjectAgg(const JsonObjectAgg *a, const JsonObjectAgg *b) -{ - COMPARE_NODE_FIELD(constructor); - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(absent_on_null); - COMPARE_SCALAR_FIELD(unique); - - return true; -} - -static bool -_equalJsonArrayAgg(const JsonArrayAgg *a, const JsonArrayAgg *b) -{ - COMPARE_NODE_FIELD(constructor); - COMPARE_NODE_FIELD(arg); - COMPARE_SCALAR_FIELD(absent_on_null); - - return true; -} - -static bool -_equalRawStmt(const RawStmt *a, const RawStmt *b) -{ - COMPARE_NODE_FIELD(stmt); - COMPARE_LOCATION_FIELD(stmt_location); - COMPARE_SCALAR_FIELD(stmt_len); - - return true; -} - -static bool -_equalInsertStmt(const InsertStmt *a, const InsertStmt *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(cols); - COMPARE_NODE_FIELD(selectStmt); - COMPARE_NODE_FIELD(onConflictClause); - COMPARE_NODE_FIELD(returningList); - COMPARE_NODE_FIELD(withClause); - COMPARE_SCALAR_FIELD(override); - - return true; -} - -static bool -_equalDeleteStmt(const DeleteStmt *a, const DeleteStmt *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(usingClause); - COMPARE_NODE_FIELD(whereClause); - COMPARE_NODE_FIELD(returningList); - COMPARE_NODE_FIELD(withClause); - - return true; -} - -static bool -_equalUpdateStmt(const UpdateStmt *a, const UpdateStmt *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(targetList); - COMPARE_NODE_FIELD(whereClause); - COMPARE_NODE_FIELD(fromClause); - COMPARE_NODE_FIELD(returningList); - COMPARE_NODE_FIELD(withClause); - - return true; -} - -static bool -_equalMergeStmt(const MergeStmt *a, const MergeStmt *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(sourceRelation); - COMPARE_NODE_FIELD(joinCondition); - COMPARE_NODE_FIELD(mergeWhenClauses); - COMPARE_NODE_FIELD(withClause); - - return true; -} - -static bool -_equalSelectStmt(const SelectStmt *a, const SelectStmt *b) -{ - COMPARE_NODE_FIELD(distinctClause); - COMPARE_NODE_FIELD(intoClause); - COMPARE_NODE_FIELD(targetList); - COMPARE_NODE_FIELD(fromClause); - COMPARE_NODE_FIELD(whereClause); - COMPARE_NODE_FIELD(groupClause); - COMPARE_SCALAR_FIELD(groupDistinct); - COMPARE_NODE_FIELD(havingClause); - COMPARE_NODE_FIELD(windowClause); - COMPARE_NODE_FIELD(valuesLists); - COMPARE_NODE_FIELD(sortClause); - COMPARE_NODE_FIELD(limitOffset); - COMPARE_NODE_FIELD(limitCount); - COMPARE_SCALAR_FIELD(limitOption); - COMPARE_NODE_FIELD(lockingClause); - COMPARE_NODE_FIELD(withClause); - COMPARE_SCALAR_FIELD(op); - COMPARE_SCALAR_FIELD(all); - COMPARE_NODE_FIELD(larg); - COMPARE_NODE_FIELD(rarg); - - return true; -} - -static bool -_equalSetOperationStmt(const SetOperationStmt *a, const SetOperationStmt *b) -{ - COMPARE_SCALAR_FIELD(op); - COMPARE_SCALAR_FIELD(all); - COMPARE_NODE_FIELD(larg); - COMPARE_NODE_FIELD(rarg); - COMPARE_NODE_FIELD(colTypes); - COMPARE_NODE_FIELD(colTypmods); - COMPARE_NODE_FIELD(colCollations); - COMPARE_NODE_FIELD(groupClauses); - - return true; -} - -static bool -_equalReturnStmt(const ReturnStmt *a, const ReturnStmt *b) -{ - COMPARE_NODE_FIELD(returnval); - - return true; -} - -static bool -_equalPLAssignStmt(const PLAssignStmt *a, const PLAssignStmt *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(indirection); - COMPARE_SCALAR_FIELD(nnames); - COMPARE_NODE_FIELD(val); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCreateSchemaStmt(const CreateSchemaStmt *a, const CreateSchemaStmt *b) -{ - COMPARE_STRING_FIELD(schemaname); - COMPARE_NODE_FIELD(authrole); - COMPARE_NODE_FIELD(schemaElts); - COMPARE_SCALAR_FIELD(if_not_exists); - - return true; -} - -static bool -_equalAlterTableStmt(const AlterTableStmt *a, const AlterTableStmt *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(cmds); - COMPARE_SCALAR_FIELD(objtype); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalReplicaIdentityStmt(const ReplicaIdentityStmt *a, const ReplicaIdentityStmt *b) -{ - COMPARE_SCALAR_FIELD(identity_type); - COMPARE_STRING_FIELD(name); - - return true; -} - -static bool -_equalAlterTableCmd(const AlterTableCmd *a, const AlterTableCmd *b) -{ - COMPARE_SCALAR_FIELD(subtype); - COMPARE_STRING_FIELD(name); - COMPARE_SCALAR_FIELD(num); - COMPARE_NODE_FIELD(newowner); - COMPARE_NODE_FIELD(def); - COMPARE_SCALAR_FIELD(behavior); - COMPARE_SCALAR_FIELD(missing_ok); - COMPARE_SCALAR_FIELD(recurse); - - return true; -} - -static bool -_equalAlterCollationStmt(const AlterCollationStmt *a, const AlterCollationStmt *b) -{ - COMPARE_NODE_FIELD(collname); - - return true; -} - -static bool -_equalAlterDomainStmt(const AlterDomainStmt *a, const AlterDomainStmt *b) -{ - COMPARE_SCALAR_FIELD(subtype); - COMPARE_NODE_FIELD(typeName); - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(def); - COMPARE_SCALAR_FIELD(behavior); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalGrantStmt(const GrantStmt *a, const GrantStmt *b) -{ - COMPARE_SCALAR_FIELD(is_grant); - COMPARE_SCALAR_FIELD(targtype); - COMPARE_SCALAR_FIELD(objtype); - COMPARE_NODE_FIELD(objects); - COMPARE_NODE_FIELD(privileges); - COMPARE_NODE_FIELD(grantees); - COMPARE_SCALAR_FIELD(grant_option); - COMPARE_NODE_FIELD(grantor); - COMPARE_SCALAR_FIELD(behavior); - - return true; -} - -static bool -_equalObjectWithArgs(const ObjectWithArgs *a, const ObjectWithArgs *b) -{ - COMPARE_NODE_FIELD(objname); - COMPARE_NODE_FIELD(objargs); - COMPARE_NODE_FIELD(objfuncargs); - COMPARE_SCALAR_FIELD(args_unspecified); - - return true; -} - -static bool -_equalAccessPriv(const AccessPriv *a, const AccessPriv *b) -{ - COMPARE_STRING_FIELD(priv_name); - COMPARE_NODE_FIELD(cols); - - return true; -} - -static bool -_equalGrantRoleStmt(const GrantRoleStmt *a, const GrantRoleStmt *b) -{ - COMPARE_NODE_FIELD(granted_roles); - COMPARE_NODE_FIELD(grantee_roles); - COMPARE_SCALAR_FIELD(is_grant); - COMPARE_NODE_FIELD(opt); - COMPARE_NODE_FIELD(grantor); - COMPARE_SCALAR_FIELD(behavior); - - return true; -} - -static bool -_equalAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *a, const AlterDefaultPrivilegesStmt *b) -{ - COMPARE_NODE_FIELD(options); - COMPARE_NODE_FIELD(action); - - return true; -} - -static bool -_equalCopyStmt(const CopyStmt *a, const CopyStmt *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(query); - COMPARE_NODE_FIELD(attlist); - COMPARE_SCALAR_FIELD(is_from); - COMPARE_SCALAR_FIELD(is_program); - COMPARE_STRING_FIELD(filename); - COMPARE_NODE_FIELD(options); - COMPARE_NODE_FIELD(whereClause); - - return true; -} - -static bool -_equalVariableSetStmt(const VariableSetStmt *a, const VariableSetStmt *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(args); - COMPARE_SCALAR_FIELD(is_local); - - return true; -} - -static bool -_equalVariableShowStmt(const VariableShowStmt *a, const VariableShowStmt *b) -{ - COMPARE_STRING_FIELD(name); - - return true; -} - -static bool -_equalCreateStmt(const CreateStmt *a, const CreateStmt *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(tableElts); - COMPARE_NODE_FIELD(inhRelations); - COMPARE_NODE_FIELD(partbound); - COMPARE_NODE_FIELD(partspec); - COMPARE_NODE_FIELD(ofTypename); - COMPARE_NODE_FIELD(constraints); - COMPARE_NODE_FIELD(options); - COMPARE_SCALAR_FIELD(oncommit); - COMPARE_STRING_FIELD(tablespacename); - COMPARE_STRING_FIELD(accessMethod); - COMPARE_SCALAR_FIELD(if_not_exists); - - return true; -} - -static bool -_equalConstraint(const Constraint *a, const Constraint *b) -{ - COMPARE_SCALAR_FIELD(contype); - COMPARE_STRING_FIELD(conname); - COMPARE_SCALAR_FIELD(deferrable); - COMPARE_SCALAR_FIELD(initdeferred); - COMPARE_LOCATION_FIELD(location); - COMPARE_SCALAR_FIELD(is_no_inherit); - COMPARE_NODE_FIELD(raw_expr); - COMPARE_STRING_FIELD(cooked_expr); - COMPARE_SCALAR_FIELD(generated_when); - COMPARE_SCALAR_FIELD(nulls_not_distinct); - COMPARE_NODE_FIELD(keys); - COMPARE_NODE_FIELD(including); - COMPARE_NODE_FIELD(exclusions); - COMPARE_NODE_FIELD(options); - COMPARE_STRING_FIELD(indexname); - COMPARE_STRING_FIELD(indexspace); - COMPARE_SCALAR_FIELD(reset_default_tblspc); - COMPARE_STRING_FIELD(access_method); - COMPARE_NODE_FIELD(where_clause); - COMPARE_NODE_FIELD(pktable); - COMPARE_NODE_FIELD(fk_attrs); - COMPARE_NODE_FIELD(pk_attrs); - COMPARE_SCALAR_FIELD(fk_matchtype); - COMPARE_SCALAR_FIELD(fk_upd_action); - COMPARE_SCALAR_FIELD(fk_del_action); - COMPARE_NODE_FIELD(fk_del_set_cols); - COMPARE_NODE_FIELD(old_conpfeqop); - COMPARE_SCALAR_FIELD(old_pktable_oid); - COMPARE_SCALAR_FIELD(skip_validation); - COMPARE_SCALAR_FIELD(initially_valid); - - return true; -} - -static bool -_equalCreateTableSpaceStmt(const CreateTableSpaceStmt *a, const CreateTableSpaceStmt *b) -{ - COMPARE_STRING_FIELD(tablespacename); - COMPARE_NODE_FIELD(owner); - COMPARE_STRING_FIELD(location); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalDropTableSpaceStmt(const DropTableSpaceStmt *a, const DropTableSpaceStmt *b) -{ - COMPARE_STRING_FIELD(tablespacename); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *a, const AlterTableSpaceOptionsStmt *b) -{ - COMPARE_STRING_FIELD(tablespacename); - COMPARE_NODE_FIELD(options); - COMPARE_SCALAR_FIELD(isReset); - - return true; -} - -static bool -_equalAlterTableMoveAllStmt(const AlterTableMoveAllStmt *a, const AlterTableMoveAllStmt *b) -{ - COMPARE_STRING_FIELD(orig_tablespacename); - COMPARE_SCALAR_FIELD(objtype); - COMPARE_NODE_FIELD(roles); - COMPARE_STRING_FIELD(new_tablespacename); - COMPARE_SCALAR_FIELD(nowait); - - return true; -} - -static bool -_equalCreateExtensionStmt(const CreateExtensionStmt *a, const CreateExtensionStmt *b) -{ - COMPARE_STRING_FIELD(extname); - COMPARE_SCALAR_FIELD(if_not_exists); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterExtensionStmt(const AlterExtensionStmt *a, const AlterExtensionStmt *b) -{ - COMPARE_STRING_FIELD(extname); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const AlterExtensionContentsStmt *b) -{ - COMPARE_STRING_FIELD(extname); - COMPARE_SCALAR_FIELD(action); - COMPARE_SCALAR_FIELD(objtype); - COMPARE_NODE_FIELD(object); - - return true; -} - -static bool -_equalCreateFdwStmt(const CreateFdwStmt *a, const CreateFdwStmt *b) -{ - COMPARE_STRING_FIELD(fdwname); - COMPARE_NODE_FIELD(func_options); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterFdwStmt(const AlterFdwStmt *a, const AlterFdwStmt *b) -{ - COMPARE_STRING_FIELD(fdwname); - COMPARE_NODE_FIELD(func_options); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalCreateForeignServerStmt(const CreateForeignServerStmt *a, const CreateForeignServerStmt *b) -{ - COMPARE_STRING_FIELD(servername); - COMPARE_STRING_FIELD(servertype); - COMPARE_STRING_FIELD(version); - COMPARE_STRING_FIELD(fdwname); - COMPARE_SCALAR_FIELD(if_not_exists); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterForeignServerStmt(const AlterForeignServerStmt *a, const AlterForeignServerStmt *b) -{ - COMPARE_STRING_FIELD(servername); - COMPARE_STRING_FIELD(version); - COMPARE_NODE_FIELD(options); - COMPARE_SCALAR_FIELD(has_version); - - return true; -} - -static bool -_equalCreateForeignTableStmt(const CreateForeignTableStmt *a, const CreateForeignTableStmt *b) -{ - COMPARE_NODE_FIELD(base.relation); - COMPARE_NODE_FIELD(base.tableElts); - COMPARE_NODE_FIELD(base.inhRelations); - COMPARE_NODE_FIELD(base.partbound); - COMPARE_NODE_FIELD(base.partspec); - COMPARE_NODE_FIELD(base.ofTypename); - COMPARE_NODE_FIELD(base.constraints); - COMPARE_NODE_FIELD(base.options); - COMPARE_SCALAR_FIELD(base.oncommit); - COMPARE_STRING_FIELD(base.tablespacename); - COMPARE_STRING_FIELD(base.accessMethod); - COMPARE_SCALAR_FIELD(base.if_not_exists); - COMPARE_STRING_FIELD(servername); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalCreateUserMappingStmt(const CreateUserMappingStmt *a, const CreateUserMappingStmt *b) -{ - COMPARE_NODE_FIELD(user); - COMPARE_STRING_FIELD(servername); - COMPARE_SCALAR_FIELD(if_not_exists); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterUserMappingStmt(const AlterUserMappingStmt *a, const AlterUserMappingStmt *b) -{ - COMPARE_NODE_FIELD(user); - COMPARE_STRING_FIELD(servername); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalDropUserMappingStmt(const DropUserMappingStmt *a, const DropUserMappingStmt *b) -{ - COMPARE_NODE_FIELD(user); - COMPARE_STRING_FIELD(servername); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalImportForeignSchemaStmt(const ImportForeignSchemaStmt *a, const ImportForeignSchemaStmt *b) -{ - COMPARE_STRING_FIELD(server_name); - COMPARE_STRING_FIELD(remote_schema); - COMPARE_STRING_FIELD(local_schema); - COMPARE_SCALAR_FIELD(list_type); - COMPARE_NODE_FIELD(table_list); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalCreatePolicyStmt(const CreatePolicyStmt *a, const CreatePolicyStmt *b) -{ - COMPARE_STRING_FIELD(policy_name); - COMPARE_NODE_FIELD(table); - COMPARE_STRING_FIELD(cmd_name); - COMPARE_SCALAR_FIELD(permissive); - COMPARE_NODE_FIELD(roles); - COMPARE_NODE_FIELD(qual); - COMPARE_NODE_FIELD(with_check); - - return true; -} - -static bool -_equalAlterPolicyStmt(const AlterPolicyStmt *a, const AlterPolicyStmt *b) -{ - COMPARE_STRING_FIELD(policy_name); - COMPARE_NODE_FIELD(table); - COMPARE_NODE_FIELD(roles); - COMPARE_NODE_FIELD(qual); - COMPARE_NODE_FIELD(with_check); - - return true; -} - -static bool -_equalCreateAmStmt(const CreateAmStmt *a, const CreateAmStmt *b) -{ - COMPARE_STRING_FIELD(amname); - COMPARE_NODE_FIELD(handler_name); - COMPARE_SCALAR_FIELD(amtype); - - return true; -} - -static bool -_equalCreateTrigStmt(const CreateTrigStmt *a, const CreateTrigStmt *b) -{ - COMPARE_SCALAR_FIELD(replace); - COMPARE_SCALAR_FIELD(isconstraint); - COMPARE_STRING_FIELD(trigname); - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(funcname); - COMPARE_NODE_FIELD(args); - COMPARE_SCALAR_FIELD(row); - COMPARE_SCALAR_FIELD(timing); - COMPARE_SCALAR_FIELD(events); - COMPARE_NODE_FIELD(columns); - COMPARE_NODE_FIELD(whenClause); - COMPARE_NODE_FIELD(transitionRels); - COMPARE_SCALAR_FIELD(deferrable); - COMPARE_SCALAR_FIELD(initdeferred); - COMPARE_NODE_FIELD(constrrel); - - return true; -} - -static bool -_equalCreateEventTrigStmt(const CreateEventTrigStmt *a, const CreateEventTrigStmt *b) -{ - COMPARE_STRING_FIELD(trigname); - COMPARE_STRING_FIELD(eventname); - COMPARE_NODE_FIELD(whenclause); - COMPARE_NODE_FIELD(funcname); - - return true; -} - -static bool -_equalAlterEventTrigStmt(const AlterEventTrigStmt *a, const AlterEventTrigStmt *b) -{ - COMPARE_STRING_FIELD(trigname); - COMPARE_SCALAR_FIELD(tgenabled); - - return true; -} - -static bool -_equalCreatePLangStmt(const CreatePLangStmt *a, const CreatePLangStmt *b) -{ - COMPARE_SCALAR_FIELD(replace); - COMPARE_STRING_FIELD(plname); - COMPARE_NODE_FIELD(plhandler); - COMPARE_NODE_FIELD(plinline); - COMPARE_NODE_FIELD(plvalidator); - COMPARE_SCALAR_FIELD(pltrusted); - - return true; -} - -static bool -_equalCreateRoleStmt(const CreateRoleStmt *a, const CreateRoleStmt *b) -{ - COMPARE_SCALAR_FIELD(stmt_type); - COMPARE_STRING_FIELD(role); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterRoleStmt(const AlterRoleStmt *a, const AlterRoleStmt *b) -{ - COMPARE_NODE_FIELD(role); - COMPARE_NODE_FIELD(options); - COMPARE_SCALAR_FIELD(action); - - return true; -} - -static bool -_equalAlterRoleSetStmt(const AlterRoleSetStmt *a, const AlterRoleSetStmt *b) -{ - COMPARE_NODE_FIELD(role); - COMPARE_STRING_FIELD(database); - COMPARE_NODE_FIELD(setstmt); - - return true; -} - -static bool -_equalDropRoleStmt(const DropRoleStmt *a, const DropRoleStmt *b) -{ - COMPARE_NODE_FIELD(roles); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalCreateSeqStmt(const CreateSeqStmt *a, const CreateSeqStmt *b) -{ - COMPARE_NODE_FIELD(sequence); - COMPARE_NODE_FIELD(options); - COMPARE_SCALAR_FIELD(ownerId); - COMPARE_SCALAR_FIELD(for_identity); - COMPARE_SCALAR_FIELD(if_not_exists); - - return true; -} - -static bool -_equalAlterSeqStmt(const AlterSeqStmt *a, const AlterSeqStmt *b) -{ - COMPARE_NODE_FIELD(sequence); - COMPARE_NODE_FIELD(options); - COMPARE_SCALAR_FIELD(for_identity); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalDefineStmt(const DefineStmt *a, const DefineStmt *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_SCALAR_FIELD(oldstyle); - COMPARE_NODE_FIELD(defnames); - COMPARE_NODE_FIELD(args); - COMPARE_NODE_FIELD(definition); - COMPARE_SCALAR_FIELD(if_not_exists); - COMPARE_SCALAR_FIELD(replace); - - return true; -} - -static bool -_equalCreateDomainStmt(const CreateDomainStmt *a, const CreateDomainStmt *b) -{ - COMPARE_NODE_FIELD(domainname); - COMPARE_NODE_FIELD(typeName); - COMPARE_NODE_FIELD(collClause); - COMPARE_NODE_FIELD(constraints); - - return true; -} - -static bool -_equalCreateOpClassStmt(const CreateOpClassStmt *a, const CreateOpClassStmt *b) -{ - COMPARE_NODE_FIELD(opclassname); - COMPARE_NODE_FIELD(opfamilyname); - COMPARE_STRING_FIELD(amname); - COMPARE_NODE_FIELD(datatype); - COMPARE_NODE_FIELD(items); - COMPARE_SCALAR_FIELD(isDefault); - - return true; -} - -static bool -_equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b) -{ - COMPARE_SCALAR_FIELD(itemtype); - COMPARE_NODE_FIELD(name); - COMPARE_SCALAR_FIELD(number); - COMPARE_NODE_FIELD(order_family); - COMPARE_NODE_FIELD(class_args); - COMPARE_NODE_FIELD(storedtype); - - return true; -} - -static bool -_equalCreateOpFamilyStmt(const CreateOpFamilyStmt *a, const CreateOpFamilyStmt *b) -{ - COMPARE_NODE_FIELD(opfamilyname); - COMPARE_STRING_FIELD(amname); - - return true; -} - -static bool -_equalAlterOpFamilyStmt(const AlterOpFamilyStmt *a, const AlterOpFamilyStmt *b) -{ - COMPARE_NODE_FIELD(opfamilyname); - COMPARE_STRING_FIELD(amname); - COMPARE_SCALAR_FIELD(isDrop); - COMPARE_NODE_FIELD(items); - - return true; -} - -static bool -_equalDropStmt(const DropStmt *a, const DropStmt *b) -{ - COMPARE_NODE_FIELD(objects); - COMPARE_SCALAR_FIELD(removeType); - COMPARE_SCALAR_FIELD(behavior); - COMPARE_SCALAR_FIELD(missing_ok); - COMPARE_SCALAR_FIELD(concurrent); - - return true; -} - -static bool -_equalTruncateStmt(const TruncateStmt *a, const TruncateStmt *b) -{ - COMPARE_NODE_FIELD(relations); - COMPARE_SCALAR_FIELD(restart_seqs); - COMPARE_SCALAR_FIELD(behavior); - - return true; -} - -static bool -_equalCommentStmt(const CommentStmt *a, const CommentStmt *b) -{ - COMPARE_SCALAR_FIELD(objtype); - COMPARE_NODE_FIELD(object); - COMPARE_STRING_FIELD(comment); - - return true; -} - -static bool -_equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b) -{ - COMPARE_SCALAR_FIELD(objtype); - COMPARE_NODE_FIELD(object); - COMPARE_STRING_FIELD(provider); - COMPARE_STRING_FIELD(label); - - return true; -} - -static bool -_equalDeclareCursorStmt(const DeclareCursorStmt *a, const DeclareCursorStmt *b) -{ - COMPARE_STRING_FIELD(portalname); - COMPARE_SCALAR_FIELD(options); - COMPARE_NODE_FIELD(query); - - return true; -} - -static bool -_equalClosePortalStmt(const ClosePortalStmt *a, const ClosePortalStmt *b) -{ - COMPARE_STRING_FIELD(portalname); - - return true; -} - -static bool -_equalFetchStmt(const FetchStmt *a, const FetchStmt *b) -{ - COMPARE_SCALAR_FIELD(direction); - COMPARE_SCALAR_FIELD(howMany); - COMPARE_STRING_FIELD(portalname); - COMPARE_SCALAR_FIELD(ismove); - - return true; -} - -static bool -_equalIndexStmt(const IndexStmt *a, const IndexStmt *b) -{ - COMPARE_STRING_FIELD(idxname); - COMPARE_NODE_FIELD(relation); - COMPARE_STRING_FIELD(accessMethod); - COMPARE_STRING_FIELD(tableSpace); - COMPARE_NODE_FIELD(indexParams); - COMPARE_NODE_FIELD(indexIncludingParams); - COMPARE_NODE_FIELD(options); - COMPARE_NODE_FIELD(whereClause); - COMPARE_NODE_FIELD(excludeOpNames); - COMPARE_STRING_FIELD(idxcomment); - COMPARE_SCALAR_FIELD(indexOid); - COMPARE_SCALAR_FIELD(oldNumber); - COMPARE_SCALAR_FIELD(oldCreateSubid); - COMPARE_SCALAR_FIELD(oldFirstRelfilelocatorSubid); - COMPARE_SCALAR_FIELD(unique); - COMPARE_SCALAR_FIELD(nulls_not_distinct); - COMPARE_SCALAR_FIELD(primary); - COMPARE_SCALAR_FIELD(isconstraint); - COMPARE_SCALAR_FIELD(deferrable); - COMPARE_SCALAR_FIELD(initdeferred); - COMPARE_SCALAR_FIELD(transformed); - COMPARE_SCALAR_FIELD(concurrent); - COMPARE_SCALAR_FIELD(if_not_exists); - COMPARE_SCALAR_FIELD(reset_default_tblspc); - - return true; -} - -static bool -_equalCreateStatsStmt(const CreateStatsStmt *a, const CreateStatsStmt *b) -{ - COMPARE_NODE_FIELD(defnames); - COMPARE_NODE_FIELD(stat_types); - COMPARE_NODE_FIELD(exprs); - COMPARE_NODE_FIELD(relations); - COMPARE_STRING_FIELD(stxcomment); - COMPARE_SCALAR_FIELD(transformed); - COMPARE_SCALAR_FIELD(if_not_exists); - - return true; -} - -static bool -_equalStatsElem(const StatsElem *a, const StatsElem *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(expr); - - return true; -} - -static bool -_equalAlterStatsStmt(const AlterStatsStmt *a, const AlterStatsStmt *b) -{ - COMPARE_NODE_FIELD(defnames); - COMPARE_SCALAR_FIELD(stxstattarget); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalCreateFunctionStmt(const CreateFunctionStmt *a, const CreateFunctionStmt *b) -{ - COMPARE_SCALAR_FIELD(is_procedure); - COMPARE_SCALAR_FIELD(replace); - COMPARE_NODE_FIELD(funcname); - COMPARE_NODE_FIELD(parameters); - COMPARE_NODE_FIELD(returnType); - COMPARE_NODE_FIELD(options); - COMPARE_NODE_FIELD(sql_body); - - return true; -} - -static bool -_equalFunctionParameter(const FunctionParameter *a, const FunctionParameter *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(argType); - COMPARE_SCALAR_FIELD(mode); - COMPARE_NODE_FIELD(defexpr); - - return true; -} - -static bool -_equalAlterFunctionStmt(const AlterFunctionStmt *a, const AlterFunctionStmt *b) -{ - COMPARE_SCALAR_FIELD(objtype); - COMPARE_NODE_FIELD(func); - COMPARE_NODE_FIELD(actions); - - return true; -} - -static bool -_equalDoStmt(const DoStmt *a, const DoStmt *b) -{ - COMPARE_NODE_FIELD(args); - - return true; -} - -static bool -_equalCallStmt(const CallStmt *a, const CallStmt *b) -{ - COMPARE_NODE_FIELD(funccall); - COMPARE_NODE_FIELD(funcexpr); - COMPARE_NODE_FIELD(outargs); - - return true; -} - -static bool -_equalRenameStmt(const RenameStmt *a, const RenameStmt *b) -{ - COMPARE_SCALAR_FIELD(renameType); - COMPARE_SCALAR_FIELD(relationType); - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(object); - COMPARE_STRING_FIELD(subname); - COMPARE_STRING_FIELD(newname); - COMPARE_SCALAR_FIELD(behavior); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalAlterObjectDependsStmt(const AlterObjectDependsStmt *a, const AlterObjectDependsStmt *b) -{ - COMPARE_SCALAR_FIELD(objectType); - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(object); - COMPARE_NODE_FIELD(extname); - COMPARE_SCALAR_FIELD(remove); - - return true; -} - -static bool -_equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt *a, const AlterObjectSchemaStmt *b) -{ - COMPARE_SCALAR_FIELD(objectType); - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(object); - COMPARE_STRING_FIELD(newschema); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalAlterOwnerStmt(const AlterOwnerStmt *a, const AlterOwnerStmt *b) -{ - COMPARE_SCALAR_FIELD(objectType); - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(object); - COMPARE_NODE_FIELD(newowner); - - return true; -} - -static bool -_equalAlterOperatorStmt(const AlterOperatorStmt *a, const AlterOperatorStmt *b) -{ - COMPARE_NODE_FIELD(opername); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterTypeStmt(const AlterTypeStmt *a, const AlterTypeStmt *b) -{ - COMPARE_NODE_FIELD(typeName); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalRuleStmt(const RuleStmt *a, const RuleStmt *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_STRING_FIELD(rulename); - COMPARE_NODE_FIELD(whereClause); - COMPARE_SCALAR_FIELD(event); - COMPARE_SCALAR_FIELD(instead); - COMPARE_NODE_FIELD(actions); - COMPARE_SCALAR_FIELD(replace); - - return true; -} - -static bool -_equalNotifyStmt(const NotifyStmt *a, const NotifyStmt *b) -{ - COMPARE_STRING_FIELD(conditionname); - COMPARE_STRING_FIELD(payload); - - return true; -} - -static bool -_equalListenStmt(const ListenStmt *a, const ListenStmt *b) -{ - COMPARE_STRING_FIELD(conditionname); - - return true; -} - -static bool -_equalUnlistenStmt(const UnlistenStmt *a, const UnlistenStmt *b) -{ - COMPARE_STRING_FIELD(conditionname); - - return true; -} - -static bool -_equalTransactionStmt(const TransactionStmt *a, const TransactionStmt *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_NODE_FIELD(options); - COMPARE_STRING_FIELD(savepoint_name); - COMPARE_STRING_FIELD(gid); - COMPARE_SCALAR_FIELD(chain); - - return true; -} - -static bool -_equalCompositeTypeStmt(const CompositeTypeStmt *a, const CompositeTypeStmt *b) -{ - COMPARE_NODE_FIELD(typevar); - COMPARE_NODE_FIELD(coldeflist); - - return true; -} - -static bool -_equalCreateEnumStmt(const CreateEnumStmt *a, const CreateEnumStmt *b) -{ - COMPARE_NODE_FIELD(typeName); - COMPARE_NODE_FIELD(vals); - - return true; -} - -static bool -_equalCreateRangeStmt(const CreateRangeStmt *a, const CreateRangeStmt *b) -{ - COMPARE_NODE_FIELD(typeName); - COMPARE_NODE_FIELD(params); - - return true; -} - -static bool -_equalAlterEnumStmt(const AlterEnumStmt *a, const AlterEnumStmt *b) -{ - COMPARE_NODE_FIELD(typeName); - COMPARE_STRING_FIELD(oldVal); - COMPARE_STRING_FIELD(newVal); - COMPARE_STRING_FIELD(newValNeighbor); - COMPARE_SCALAR_FIELD(newValIsAfter); - COMPARE_SCALAR_FIELD(skipIfNewValExists); - - return true; -} - -static bool -_equalViewStmt(const ViewStmt *a, const ViewStmt *b) -{ - COMPARE_NODE_FIELD(view); - COMPARE_NODE_FIELD(aliases); - COMPARE_NODE_FIELD(query); - COMPARE_SCALAR_FIELD(replace); - COMPARE_NODE_FIELD(options); - COMPARE_SCALAR_FIELD(withCheckOption); - - return true; -} - -static bool -_equalLoadStmt(const LoadStmt *a, const LoadStmt *b) -{ - COMPARE_STRING_FIELD(filename); - - return true; -} - -static bool -_equalCreatedbStmt(const CreatedbStmt *a, const CreatedbStmt *b) -{ - COMPARE_STRING_FIELD(dbname); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterDatabaseStmt(const AlterDatabaseStmt *a, const AlterDatabaseStmt *b) -{ - COMPARE_STRING_FIELD(dbname); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterDatabaseRefreshCollStmt(const AlterDatabaseRefreshCollStmt *a, const AlterDatabaseRefreshCollStmt *b) -{ - COMPARE_STRING_FIELD(dbname); - - return true; -} - -static bool -_equalAlterDatabaseSetStmt(const AlterDatabaseSetStmt *a, const AlterDatabaseSetStmt *b) -{ - COMPARE_STRING_FIELD(dbname); - COMPARE_NODE_FIELD(setstmt); - - return true; -} - -static bool -_equalDropdbStmt(const DropdbStmt *a, const DropdbStmt *b) -{ - COMPARE_STRING_FIELD(dbname); - COMPARE_SCALAR_FIELD(missing_ok); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterSystemStmt(const AlterSystemStmt *a, const AlterSystemStmt *b) -{ - COMPARE_NODE_FIELD(setstmt); - - return true; -} - -static bool -_equalClusterStmt(const ClusterStmt *a, const ClusterStmt *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_STRING_FIELD(indexname); - COMPARE_NODE_FIELD(params); - - return true; -} - -static bool -_equalVacuumStmt(const VacuumStmt *a, const VacuumStmt *b) -{ - COMPARE_NODE_FIELD(options); - COMPARE_NODE_FIELD(rels); - COMPARE_SCALAR_FIELD(is_vacuumcmd); - - return true; -} - -static bool -_equalVacuumRelation(const VacuumRelation *a, const VacuumRelation *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_SCALAR_FIELD(oid); - COMPARE_NODE_FIELD(va_cols); - - return true; -} - -static bool -_equalExplainStmt(const ExplainStmt *a, const ExplainStmt *b) -{ - COMPARE_NODE_FIELD(query); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalCreateTableAsStmt(const CreateTableAsStmt *a, const CreateTableAsStmt *b) -{ - COMPARE_NODE_FIELD(query); - COMPARE_NODE_FIELD(into); - COMPARE_SCALAR_FIELD(objtype); - COMPARE_SCALAR_FIELD(is_select_into); - COMPARE_SCALAR_FIELD(if_not_exists); - - return true; -} - -static bool -_equalRefreshMatViewStmt(const RefreshMatViewStmt *a, const RefreshMatViewStmt *b) -{ - COMPARE_SCALAR_FIELD(concurrent); - COMPARE_SCALAR_FIELD(skipData); - COMPARE_NODE_FIELD(relation); - - return true; -} - -static bool -_equalCheckPointStmt(const CheckPointStmt *a, const CheckPointStmt *b) -{ - - return true; -} - -static bool -_equalDiscardStmt(const DiscardStmt *a, const DiscardStmt *b) -{ - COMPARE_SCALAR_FIELD(target); - - return true; -} - -static bool -_equalLockStmt(const LockStmt *a, const LockStmt *b) -{ - COMPARE_NODE_FIELD(relations); - COMPARE_SCALAR_FIELD(mode); - COMPARE_SCALAR_FIELD(nowait); - - return true; -} - -static bool -_equalConstraintsSetStmt(const ConstraintsSetStmt *a, const ConstraintsSetStmt *b) -{ - COMPARE_NODE_FIELD(constraints); - COMPARE_SCALAR_FIELD(deferred); - - return true; -} - -static bool -_equalReindexStmt(const ReindexStmt *a, const ReindexStmt *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_NODE_FIELD(relation); - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(params); - - return true; -} - -static bool -_equalCreateConversionStmt(const CreateConversionStmt *a, const CreateConversionStmt *b) -{ - COMPARE_NODE_FIELD(conversion_name); - COMPARE_STRING_FIELD(for_encoding_name); - COMPARE_STRING_FIELD(to_encoding_name); - COMPARE_NODE_FIELD(func_name); - COMPARE_SCALAR_FIELD(def); - - return true; -} - -static bool -_equalCreateCastStmt(const CreateCastStmt *a, const CreateCastStmt *b) -{ - COMPARE_NODE_FIELD(sourcetype); - COMPARE_NODE_FIELD(targettype); - COMPARE_NODE_FIELD(func); - COMPARE_SCALAR_FIELD(context); - COMPARE_SCALAR_FIELD(inout); - - return true; -} - -static bool -_equalCreateTransformStmt(const CreateTransformStmt *a, const CreateTransformStmt *b) -{ - COMPARE_SCALAR_FIELD(replace); - COMPARE_NODE_FIELD(type_name); - COMPARE_STRING_FIELD(lang); - COMPARE_NODE_FIELD(fromsql); - COMPARE_NODE_FIELD(tosql); - - return true; -} - -static bool -_equalPrepareStmt(const PrepareStmt *a, const PrepareStmt *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(argtypes); - COMPARE_NODE_FIELD(query); - - return true; -} - -static bool -_equalExecuteStmt(const ExecuteStmt *a, const ExecuteStmt *b) -{ - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(params); - - return true; -} - -static bool -_equalDeallocateStmt(const DeallocateStmt *a, const DeallocateStmt *b) -{ - COMPARE_STRING_FIELD(name); - - return true; -} - -static bool -_equalDropOwnedStmt(const DropOwnedStmt *a, const DropOwnedStmt *b) -{ - COMPARE_NODE_FIELD(roles); - COMPARE_SCALAR_FIELD(behavior); - - return true; -} - -static bool -_equalReassignOwnedStmt(const ReassignOwnedStmt *a, const ReassignOwnedStmt *b) -{ - COMPARE_NODE_FIELD(roles); - COMPARE_NODE_FIELD(newrole); - - return true; -} - -static bool -_equalAlterTSDictionaryStmt(const AlterTSDictionaryStmt *a, const AlterTSDictionaryStmt *b) -{ - COMPARE_NODE_FIELD(dictname); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterTSConfigurationStmt(const AlterTSConfigurationStmt *a, const AlterTSConfigurationStmt *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_NODE_FIELD(cfgname); - COMPARE_NODE_FIELD(tokentype); - COMPARE_NODE_FIELD(dicts); - COMPARE_SCALAR_FIELD(override); - COMPARE_SCALAR_FIELD(replace); - COMPARE_SCALAR_FIELD(missing_ok); - - return true; -} - -static bool -_equalPublicationTable(const PublicationTable *a, const PublicationTable *b) -{ - COMPARE_NODE_FIELD(relation); - COMPARE_NODE_FIELD(whereClause); - COMPARE_NODE_FIELD(columns); - - return true; -} - -static bool -_equalPublicationObjSpec(const PublicationObjSpec *a, const PublicationObjSpec *b) -{ - COMPARE_SCALAR_FIELD(pubobjtype); - COMPARE_STRING_FIELD(name); - COMPARE_NODE_FIELD(pubtable); - COMPARE_LOCATION_FIELD(location); - - return true; -} - -static bool -_equalCreatePublicationStmt(const CreatePublicationStmt *a, const CreatePublicationStmt *b) -{ - COMPARE_STRING_FIELD(pubname); - COMPARE_NODE_FIELD(options); - COMPARE_NODE_FIELD(pubobjects); - COMPARE_SCALAR_FIELD(for_all_tables); - - return true; -} - -static bool -_equalAlterPublicationStmt(const AlterPublicationStmt *a, const AlterPublicationStmt *b) -{ - COMPARE_STRING_FIELD(pubname); - COMPARE_NODE_FIELD(options); - COMPARE_NODE_FIELD(pubobjects); - COMPARE_SCALAR_FIELD(for_all_tables); - COMPARE_SCALAR_FIELD(action); - - return true; -} - -static bool -_equalCreateSubscriptionStmt(const CreateSubscriptionStmt *a, const CreateSubscriptionStmt *b) -{ - COMPARE_STRING_FIELD(subname); - COMPARE_STRING_FIELD(conninfo); - COMPARE_NODE_FIELD(publication); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalAlterSubscriptionStmt(const AlterSubscriptionStmt *a, const AlterSubscriptionStmt *b) -{ - COMPARE_SCALAR_FIELD(kind); - COMPARE_STRING_FIELD(subname); - COMPARE_STRING_FIELD(conninfo); - COMPARE_NODE_FIELD(publication); - COMPARE_NODE_FIELD(options); - - return true; -} - -static bool -_equalDropSubscriptionStmt(const DropSubscriptionStmt *a, const DropSubscriptionStmt *b) -{ - COMPARE_STRING_FIELD(subname); - COMPARE_SCALAR_FIELD(missing_ok); - COMPARE_SCALAR_FIELD(behavior); - - return true; -} - -static bool -_equalPathKey(const PathKey *a, const PathKey *b) -{ - COMPARE_SCALAR_FIELD(pk_eclass); - COMPARE_SCALAR_FIELD(pk_opfamily); - COMPARE_SCALAR_FIELD(pk_strategy); - COMPARE_SCALAR_FIELD(pk_nulls_first); - - return true; -} - -static bool -_equalRestrictInfo(const RestrictInfo *a, const RestrictInfo *b) -{ - COMPARE_NODE_FIELD(clause); - COMPARE_SCALAR_FIELD(is_pushed_down); - COMPARE_SCALAR_FIELD(has_clone); - COMPARE_SCALAR_FIELD(is_clone); - COMPARE_SCALAR_FIELD(security_level); - COMPARE_BITMAPSET_FIELD(required_relids); - COMPARE_BITMAPSET_FIELD(incompatible_relids); - COMPARE_BITMAPSET_FIELD(outer_relids); - COMPARE_SCALAR_FIELD(rinfo_serial); - - return true; -} - -static bool -_equalPlaceHolderVar(const PlaceHolderVar *a, const PlaceHolderVar *b) -{ - COMPARE_BITMAPSET_FIELD(phnullingrels); - COMPARE_SCALAR_FIELD(phid); - COMPARE_SCALAR_FIELD(phlevelsup); - - return true; -} - -static bool -_equalSpecialJoinInfo(const SpecialJoinInfo *a, const SpecialJoinInfo *b) -{ - COMPARE_BITMAPSET_FIELD(min_lefthand); - COMPARE_BITMAPSET_FIELD(min_righthand); - COMPARE_BITMAPSET_FIELD(syn_lefthand); - COMPARE_BITMAPSET_FIELD(syn_righthand); - COMPARE_SCALAR_FIELD(jointype); - COMPARE_SCALAR_FIELD(ojrelid); - COMPARE_BITMAPSET_FIELD(commute_above_l); - COMPARE_BITMAPSET_FIELD(commute_above_r); - COMPARE_BITMAPSET_FIELD(commute_below_l); - COMPARE_BITMAPSET_FIELD(commute_below_r); - COMPARE_SCALAR_FIELD(lhs_strict); - COMPARE_SCALAR_FIELD(semi_can_btree); - COMPARE_SCALAR_FIELD(semi_can_hash); - COMPARE_NODE_FIELD(semi_operators); - COMPARE_NODE_FIELD(semi_rhs_exprs); - - return true; -} - -static bool -_equalAppendRelInfo(const AppendRelInfo *a, const AppendRelInfo *b) -{ - COMPARE_SCALAR_FIELD(parent_relid); - COMPARE_SCALAR_FIELD(child_relid); - COMPARE_SCALAR_FIELD(parent_reltype); - COMPARE_SCALAR_FIELD(child_reltype); - COMPARE_NODE_FIELD(translated_vars); - COMPARE_SCALAR_FIELD(num_child_cols); - COMPARE_POINTER_FIELD(parent_colnos, a->num_child_cols * sizeof(AttrNumber)); - COMPARE_SCALAR_FIELD(parent_reloid); - - return true; -} - -static bool -_equalPlaceHolderInfo(const PlaceHolderInfo *a, const PlaceHolderInfo *b) -{ - COMPARE_SCALAR_FIELD(phid); - COMPARE_NODE_FIELD(ph_var); - COMPARE_BITMAPSET_FIELD(ph_eval_at); - COMPARE_BITMAPSET_FIELD(ph_lateral); - COMPARE_BITMAPSET_FIELD(ph_needed); - COMPARE_SCALAR_FIELD(ph_width); - - return true; -} - -static bool -_equalInteger(const Integer *a, const Integer *b) -{ - COMPARE_SCALAR_FIELD(ival); - - return true; -} - -static bool -_equalFloat(const Float *a, const Float *b) -{ - COMPARE_STRING_FIELD(fval); - - return true; -} - -static bool -_equalBoolean(const Boolean *a, const Boolean *b) -{ - COMPARE_SCALAR_FIELD(boolval); - - return true; -} - -static bool -_equalString(const String *a, const String *b) -{ - COMPARE_STRING_FIELD(sval); - - return true; -} - -static bool -_equalBitString(const BitString *a, const BitString *b) -{ - COMPARE_STRING_FIELD(bsval); - - return true; -} diff --git a/parser/include/utils/pidfile.h b/parser/include/utils/pidfile.h deleted file mode 100644 index 1393a534..00000000 --- a/parser/include/utils/pidfile.h +++ /dev/null @@ -1,56 +0,0 @@ -/*------------------------------------------------------------------------- - * - * pidfile.h - * Declarations describing the data directory lock file (postmaster.pid) - * - * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * src/include/utils/pidfile.h - * - *------------------------------------------------------------------------- - */ -#ifndef UTILS_PIDFILE_H -#define UTILS_PIDFILE_H - -/* - * As of Postgres 10, the contents of the data-directory lock file are: - * - * line # - * 1 postmaster PID (or negative of a standalone backend's PID) - * 2 data directory path - * 3 postmaster start timestamp (time_t representation) - * 4 port number - * 5 first Unix socket directory path (empty if none) - * 6 first listen_address (IP address or "*"; empty if no TCP port) - * 7 shared memory key (empty on Windows) - * 8 postmaster status (see values below) - * - * Lines 6 and up are added via AddToDataDirLockFile() after initial file - * creation; also, line 5 is initially empty and is changed after the first - * Unix socket is opened. Onlookers should not assume that lines 4 and up - * are filled in any particular order. - * - * Socket lock file(s), if used, have the same contents as lines 1-5, with - * line 5 being their own directory. - */ -#define LOCK_FILE_LINE_PID 1 -#define LOCK_FILE_LINE_DATA_DIR 2 -#define LOCK_FILE_LINE_START_TIME 3 -#define LOCK_FILE_LINE_PORT 4 -#define LOCK_FILE_LINE_SOCKET_DIR 5 -#define LOCK_FILE_LINE_LISTEN_ADDR 6 -#define LOCK_FILE_LINE_SHMEM_KEY 7 -#define LOCK_FILE_LINE_PM_STATUS 8 - -/* - * The PM_STATUS line may contain one of these values. All these strings - * must be the same length, per comments for AddToDataDirLockFile(). - * We pad with spaces as needed to make that true. - */ -#define PM_STATUS_STARTING "starting" /* still starting up */ -#define PM_STATUS_STOPPING "stopping" /* in shutdown sequence */ -#define PM_STATUS_READY "ready " /* ready for connections */ -#define PM_STATUS_STANDBY "standby " /* up, won't accept connections */ - -#endif /* UTILS_PIDFILE_H */ diff --git a/parser/parser.go b/parser/parser.go index 99e67fa5..c866a124 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -1,7 +1,8 @@ package parser /* -#cgo CFLAGS: -Iinclude -g -fstack-protector -std=gnu99 -Wno-unknown-warning-option +#cgo CFLAGS: -Iinclude -Iinclude/postgres -g -fstack-protector -std=gnu99 -Wno-unknown-warning-option +#cgo windows CFLAGS: -Iinclude/postgres/port/win32 #cgo LDFLAGS: #include "pg_query.h" #include "xxhash.h" diff --git a/parser/pg_query.c b/parser/pg_query.c index e49b874b..4505cb8f 100644 --- a/parser/pg_query.c +++ b/parser/pg_query.c @@ -5,15 +5,20 @@ #include #include +#ifdef HAVE_PTHREAD #include +#endif + #include const char* progname = "pg_query"; __thread sig_atomic_t pg_query_initialized = 0; +#ifdef HAVE_PTHREAD static pthread_key_t pg_query_thread_exit_key; static void pg_query_thread_exit(void *key); +#endif void pg_query_init(void) { @@ -23,8 +28,10 @@ void pg_query_init(void) MemoryContextInit(); SetDatabaseEncoding(PG_UTF8); +#ifdef HAVE_PTHREAD pthread_key_create(&pg_query_thread_exit_key, pg_query_thread_exit); pthread_setspecific(pg_query_thread_exit_key, TopMemoryContext); +#endif } void pg_query_free_top_memory_context(MemoryContext context) @@ -55,11 +62,13 @@ void pg_query_free_top_memory_context(MemoryContext context) ErrorContext = NULL; } +#ifdef HAVE_PTHREAD static void pg_query_thread_exit(void *key) { MemoryContext context = (MemoryContext) key; pg_query_free_top_memory_context(context); } +#endif void pg_query_exit(void) { diff --git a/parser/pg_query_fingerprint.c b/parser/pg_query_fingerprint.c index a8fcd0cd..8e15b821 100644 --- a/parser/pg_query_fingerprint.c +++ b/parser/pg_query_fingerprint.c @@ -1,5 +1,3 @@ -// Ensure we have asprintf's definition on glibc-based platforms to avoid compiler warnings -#define _GNU_SOURCE #include #include "pg_query.h" @@ -369,12 +367,13 @@ PgQueryFingerprintResult pg_query_fingerprint_with_opts(const char* input, int p _fingerprintFreeContext(&ctx); XXH64_canonicalFromHash(&chash, result.fingerprint); - int err = asprintf(&result.fingerprint_str, "%02x%02x%02x%02x%02x%02x%02x%02x", + result.fingerprint_str = malloc(17 * sizeof(char)); + int n = snprintf(result.fingerprint_str, 17, "%02x%02x%02x%02x%02x%02x%02x%02x", chash.digest[0], chash.digest[1], chash.digest[2], chash.digest[3], chash.digest[4], chash.digest[5], chash.digest[6], chash.digest[7]); - if (err == -1) { + if (n < 0 || n >= 17) { PgQueryError* error = malloc(sizeof(PgQueryError)); - error->message = strdup("Failed to output fingerprint string due to asprintf failure"); + error->message = strdup("Failed to output fingerprint string due to snprintf failure"); result.error = error; } } diff --git a/parser/pg_query_outfuncs_json.c b/parser/pg_query_outfuncs_json.c index cfd71297..328b1f82 100644 --- a/parser/pg_query_outfuncs_json.c +++ b/parser/pg_query_outfuncs_json.c @@ -36,6 +36,12 @@ appendStringInfo(out, "\"" CppAsString(outname_json) "\":%u,", node->fldname); \ } +/* Write an unsigned integer field */ +#define WRITE_UINT64_FIELD(outname, outname_json, fldname) \ + if (node->fldname != 0) { \ + appendStringInfo(out, "\"" CppAsString(outname_json) "\":" UINT64_FORMAT ",", node->fldname); \ + } + /* Write a long-integer field */ #define WRITE_LONG_FIELD(outname, outname_json, fldname) \ if (node->fldname != 0) { \ diff --git a/parser/pg_query_outfuncs_protobuf.c b/parser/pg_query_outfuncs_protobuf.c index 10dd35f0..64ccdf1b 100644 --- a/parser/pg_query_outfuncs_protobuf.c +++ b/parser/pg_query_outfuncs_protobuf.c @@ -23,6 +23,7 @@ #define WRITE_INT_FIELD(outname, outname_json, fldname) out->outname = node->fldname; #define WRITE_UINT_FIELD(outname, outname_json, fldname) out->outname = node->fldname; +#define WRITE_UINT64_FIELD(outname, outname_json, fldname) out->outname = node->fldname; #define WRITE_LONG_FIELD(outname, outname_json, fldname) out->outname = node->fldname; #define WRITE_FLOAT_FIELD(outname, outname_json, fldname) out->outname = node->fldname; #define WRITE_BOOL_FIELD(outname, outname_json, fldname) out->outname = node->fldname; diff --git a/parser/pg_query_parse.c b/parser/pg_query_parse.c index 5307c0c0..3f2c111a 100644 --- a/parser/pg_query_parse.c +++ b/parser/pg_query_parse.c @@ -153,7 +153,7 @@ PgQueryProtobufParseResult pg_query_parse_protobuf_opts(const char* input, int p { MemoryContext ctx = NULL; PgQueryInternalParsetreeAndError parsetree_and_error; - PgQueryProtobufParseResult result = {}; + PgQueryProtobufParseResult result = {0}; ctx = pg_query_enter_memory_context(); diff --git a/parser/pg_query_parse_plpgsql.c b/parser/pg_query_parse_plpgsql.c index fc7845b0..99c09d2a 100644 --- a/parser/pg_query_parse_plpgsql.c +++ b/parser/pg_query_parse_plpgsql.c @@ -486,14 +486,17 @@ PgQueryPlpgsqlParseResult pg_query_parse_plpgsql(const char* input) if (func_and_error.func != NULL) { char *func_json; char *new_out; + size_t new_out_len; func_json = plpgsqlToJSON(func_and_error.func); plpgsql_free_function_memory(func_and_error.func); - int err = asprintf(&new_out, "%s%s,\n", result.plpgsql_funcs, func_json); - if (err == -1) { + new_out_len = strlen(result.plpgsql_funcs) + strlen(func_json) + 3; + new_out = malloc(new_out_len); + int n = snprintf(new_out, new_out_len, "%s%s,\n", result.plpgsql_funcs, func_json); + if (n < 0 || n >= new_out_len) { PgQueryError* error = malloc(sizeof(PgQueryError)); - error->message = strdup("Failed to output PL/pgSQL functions due to asprintf failure"); + error->message = strdup("Failed to output PL/pgSQL functions due to snprintf failure"); result.error = error; } else { free(result.plpgsql_funcs); diff --git a/parser/pg_query_readfuncs_protobuf.c b/parser/pg_query_readfuncs_protobuf.c index c531c72e..b3f80d1e 100644 --- a/parser/pg_query_readfuncs_protobuf.c +++ b/parser/pg_query_readfuncs_protobuf.c @@ -14,6 +14,7 @@ #define READ_INT_FIELD(outname, outname_json, fldname) node->fldname = msg->outname; #define READ_UINT_FIELD(outname, outname_json, fldname) node->fldname = msg->outname; +#define READ_UINT64_FIELD(outname, outname_json, fldname) node->fldname = msg->outname; #define READ_LONG_FIELD(outname, outname_json, fldname) node->fldname = msg->outname; #define READ_FLOAT_FIELD(outname, outname_json, fldname) node->fldname = msg->outname; #define READ_BOOL_FIELD(outname, outname_json, fldname) node->fldname = msg->outname; diff --git a/parser/pg_query_split.c b/parser/pg_query_split.c index b34b0f38..2319d2da 100644 --- a/parser/pg_query_split.c +++ b/parser/pg_query_split.c @@ -166,7 +166,7 @@ PgQuerySplitResult pg_query_split_with_parser(const char* input) { MemoryContext ctx = NULL; PgQueryInternalParsetreeAndError parsetree_and_error; - PgQuerySplitResult result = {}; + PgQuerySplitResult result = {0}; ctx = pg_query_enter_memory_context(); diff --git a/parser/src_backend_nodes_nodes.c b/parser/src_backend_nodes_nodes.c new file mode 100644 index 00000000..69d302ca --- /dev/null +++ b/parser/src_backend_nodes_nodes.c @@ -0,0 +1,38 @@ +/*-------------------------------------------------------------------- + * Symbols referenced in this file: + * - newNodeMacroHolder + *-------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * + * nodes.c + * support code for nodes (now that we have removed the home-brew + * inheritance system, our support code for nodes is much simpler) + * + * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * src/backend/nodes/nodes.c + * + * HISTORY + * Andrew Yu Oct 20, 1994 file creation + * + *------------------------------------------------------------------------- + */ +#include "postgres.h" + +#include "nodes/nodes.h" + +/* + * Support for newNode() macro + * + * In a GCC build there is no need for the global variable newNodeMacroHolder. + * However, we create it anyway, to support the case of a non-GCC-built + * loadable module being loaded into a GCC-built backend. + */ + +__thread Node *newNodeMacroHolder; + diff --git a/parser/src_backend_postmaster_postmaster.c b/parser/src_backend_postmaster_postmaster.c deleted file mode 100644 index 46cf7d55..00000000 --- a/parser/src_backend_postmaster_postmaster.c +++ /dev/null @@ -1,2220 +0,0 @@ -/*-------------------------------------------------------------------- - * Symbols referenced in this file: - * - ClientAuthInProgress - *-------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------- - * - * postmaster.c - * This program acts as a clearing house for requests to the - * POSTGRES system. Frontend programs send a startup message - * to the Postmaster and the postmaster uses the info in the - * message to setup a backend process. - * - * The postmaster also manages system-wide operations such as - * startup and shutdown. The postmaster itself doesn't do those - * operations, mind you --- it just forks off a subprocess to do them - * at the right times. It also takes care of resetting the system - * if a backend crashes. - * - * The postmaster process creates the shared memory and semaphore - * pools during startup, but as a rule does not touch them itself. - * In particular, it is not a member of the PGPROC array of backends - * and so it cannot participate in lock-manager operations. Keeping - * the postmaster away from shared memory operations makes it simpler - * and more reliable. The postmaster is almost always able to recover - * from crashes of individual backends by resetting shared memory; - * if it did much with shared memory then it would be prone to crashing - * along with the backends. - * - * When a request message is received, we now fork() immediately. - * The child process performs authentication of the request, and - * then becomes a backend if successful. This allows the auth code - * to be written in a simple single-threaded style (as opposed to the - * crufty "poor man's multitasking" code that used to be needed). - * More importantly, it ensures that blockages in non-multithreaded - * libraries like SSL or PAM cannot cause denial of service to other - * clients. - * - * - * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * src/backend/postmaster/postmaster.c - * - * NOTES - * - * Initialization: - * The Postmaster sets up shared memory data structures - * for the backends. - * - * Synchronization: - * The Postmaster shares memory with the backends but should avoid - * touching shared memory, so as not to become stuck if a crashing - * backend screws up locks or shared memory. Likewise, the Postmaster - * should never block on messages from frontend clients. - * - * Garbage Collection: - * The Postmaster cleans up after backends if they have an emergency - * exit and/or core dump. - * - * Error Reporting: - * Use write_stderr() only for reporting "interactive" errors - * (essentially, bogus arguments on the command line). Once the - * postmaster is launched, use ereport(). - * - *------------------------------------------------------------------------- - */ - -#include "postgres.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef USE_BONJOUR -#include -#endif - -#ifdef USE_SYSTEMD -#include -#endif - -#ifdef HAVE_PTHREAD_IS_THREADED_NP -#include -#endif - -#include "access/transam.h" -#include "access/xlog.h" -#include "access/xlogrecovery.h" -#include "catalog/pg_control.h" -#include "common/file_perm.h" -#include "common/ip.h" -#include "common/pg_prng.h" -#include "common/string.h" -#include "lib/ilist.h" -#include "libpq/auth.h" -#include "libpq/libpq.h" -#include "libpq/pqformat.h" -#include "libpq/pqsignal.h" -#include "nodes/queryjumble.h" -#include "pg_getopt.h" -#include "pgstat.h" -#include "port/pg_bswap.h" -#include "postmaster/autovacuum.h" -#include "postmaster/auxprocess.h" -#include "postmaster/bgworker_internals.h" -#include "postmaster/fork_process.h" -#include "postmaster/interrupt.h" -#include "postmaster/pgarch.h" -#include "postmaster/postmaster.h" -#include "postmaster/syslogger.h" -#include "replication/logicallauncher.h" -#include "replication/walsender.h" -#include "storage/fd.h" -#include "storage/ipc.h" -#include "storage/pg_shmem.h" -#include "storage/pmsignal.h" -#include "storage/proc.h" -#include "tcop/tcopprot.h" -#include "utils/builtins.h" -#include "utils/datetime.h" -#include "utils/memutils.h" -#include "utils/pidfile.h" -#include "utils/ps_status.h" -#include "utils/timeout.h" -#include "utils/timestamp.h" -#include "utils/varlena.h" - -#ifdef EXEC_BACKEND -#include "storage/spin.h" -#endif - - -/* - * Possible types of a backend. Beyond being the possible bkend_type values in - * struct bkend, these are OR-able request flag bits for SignalSomeChildren() - * and CountChildren(). - */ -#define BACKEND_TYPE_NORMAL 0x0001 /* normal backend */ -#define BACKEND_TYPE_AUTOVAC 0x0002 /* autovacuum worker process */ -#define BACKEND_TYPE_WALSND 0x0004 /* walsender process */ -#define BACKEND_TYPE_BGWORKER 0x0008 /* bgworker process */ -#define BACKEND_TYPE_ALL 0x000F /* OR of all the above */ - -/* - * List of active backends (or child processes anyway; we don't actually - * know whether a given child has become a backend or is still in the - * authorization phase). This is used mainly to keep track of how many - * children we have and send them appropriate signals when necessary. - * - * As shown in the above set of backend types, this list includes not only - * "normal" client sessions, but also autovacuum workers, walsenders, and - * background workers. (Note that at the time of launch, walsenders are - * labeled BACKEND_TYPE_NORMAL; we relabel them to BACKEND_TYPE_WALSND - * upon noticing they've changed their PMChildFlags entry. Hence that check - * must be done before any operation that needs to distinguish walsenders - * from normal backends.) - * - * Also, "dead_end" children are in it: these are children launched just for - * the purpose of sending a friendly rejection message to a would-be client. - * We must track them because they are attached to shared memory, but we know - * they will never become live backends. dead_end children are not assigned a - * PMChildSlot. dead_end children have bkend_type NORMAL. - * - * "Special" children such as the startup, bgwriter and autovacuum launcher - * tasks are not in this list. They are tracked via StartupPID and other - * pid_t variables below. (Thus, there can't be more than one of any given - * "special" child process type. We use BackendList entries for any child - * process there can be more than one of.) - */ -typedef struct bkend -{ - pid_t pid; /* process id of backend */ - int32 cancel_key; /* cancel key for cancels for this backend */ - int child_slot; /* PMChildSlot for this backend, if any */ - int bkend_type; /* child process flavor, see above */ - bool dead_end; /* is it going to send an error and quit? */ - bool bgworker_notify; /* gets bgworker start/stop notifications */ - dlist_node elem; /* list link in BackendList */ -} Backend; - - - -#ifdef EXEC_BACKEND -static Backend *ShmemBackendArray; -#endif - - - - - -/* The socket number we are listening for connections on */ - - -/* The directory names for Unix socket(s) */ - - -/* The TCP listen address(es) */ - - -/* - * SuperuserReservedConnections is the number of backends reserved for - * superuser use, and ReservedConnections is the number of backends reserved - * for use by roles with privileges of the pg_use_reserved_connections - * predefined role. These are taken out of the pool of MaxConnections backend - * slots, so the number of backend slots available for roles that are neither - * superuser nor have privileges of pg_use_reserved_connections is - * (MaxConnections - SuperuserReservedConnections - ReservedConnections). - * - * If the number of remaining slots is less than or equal to - * SuperuserReservedConnections, only superusers can make new connections. If - * the number of remaining slots is greater than SuperuserReservedConnections - * but less than or equal to - * (SuperuserReservedConnections + ReservedConnections), only superusers and - * roles with privileges of pg_use_reserved_connections can make new - * connections. Note that pre-existing superuser and - * pg_use_reserved_connections connections don't count against the limits. - */ - - - -/* The socket(s) we're listening to. */ -#define MAXLISTEN 64 - - -/* still more option variables */ - - - - - - /* for ps display and logging */ - - - - - - - - - - -/* PIDs of special child processes; 0 when not running */ - - - - - - - - - -/* Startup process's status */ -typedef enum -{ - STARTUP_NOT_RUNNING, - STARTUP_RUNNING, - STARTUP_SIGNALED, /* we sent it a SIGQUIT or SIGKILL */ - STARTUP_CRASHED -} StartupStatusEnum; - - - -/* Startup/shutdown state */ -#define NoShutdown 0 -#define SmartShutdown 1 -#define FastShutdown 2 -#define ImmediateShutdown 3 - - - - /* T if recovering from backend crash */ - -/* - * We use a simple state machine to control startup, shutdown, and - * crash recovery (which is rather like shutdown followed by startup). - * - * After doing all the postmaster initialization work, we enter PM_STARTUP - * state and the startup process is launched. The startup process begins by - * reading the control file and other preliminary initialization steps. - * In a normal startup, or after crash recovery, the startup process exits - * with exit code 0 and we switch to PM_RUN state. However, archive recovery - * is handled specially since it takes much longer and we would like to support - * hot standby during archive recovery. - * - * When the startup process is ready to start archive recovery, it signals the - * postmaster, and we switch to PM_RECOVERY state. The background writer and - * checkpointer are launched, while the startup process continues applying WAL. - * If Hot Standby is enabled, then, after reaching a consistent point in WAL - * redo, startup process signals us again, and we switch to PM_HOT_STANDBY - * state and begin accepting connections to perform read-only queries. When - * archive recovery is finished, the startup process exits with exit code 0 - * and we switch to PM_RUN state. - * - * Normal child backends can only be launched when we are in PM_RUN or - * PM_HOT_STANDBY state. (connsAllowed can also restrict launching.) - * In other states we handle connection requests by launching "dead_end" - * child processes, which will simply send the client an error message and - * quit. (We track these in the BackendList so that we can know when they - * are all gone; this is important because they're still connected to shared - * memory, and would interfere with an attempt to destroy the shmem segment, - * possibly leading to SHMALL failure when we try to make a new one.) - * In PM_WAIT_DEAD_END state we are waiting for all the dead_end children - * to drain out of the system, and therefore stop accepting connection - * requests at all until the last existing child has quit (which hopefully - * will not be very long). - * - * Notice that this state variable does not distinguish *why* we entered - * states later than PM_RUN --- Shutdown and FatalError must be consulted - * to find that out. FatalError is never true in PM_RECOVERY, PM_HOT_STANDBY, - * or PM_RUN states, nor in PM_SHUTDOWN states (because we don't enter those - * states when trying to recover from a crash). It can be true in PM_STARTUP - * state, because we don't clear it until we've successfully started WAL redo. - */ -typedef enum -{ - PM_INIT, /* postmaster starting */ - PM_STARTUP, /* waiting for startup subprocess */ - PM_RECOVERY, /* in archive recovery mode */ - PM_HOT_STANDBY, /* in hot standby mode */ - PM_RUN, /* normal "database is alive" state */ - PM_STOP_BACKENDS, /* need to stop remaining backends */ - PM_WAIT_BACKENDS, /* waiting for live backends to exit */ - PM_SHUTDOWN, /* waiting for checkpointer to do shutdown - * ckpt */ - PM_SHUTDOWN_2, /* waiting for archiver and walsenders to - * finish */ - PM_WAIT_DEAD_END, /* waiting for dead_end children to exit */ - PM_NO_CHILDREN /* all important children have exited */ -} PMState; - - - -/* - * While performing a "smart shutdown", we restrict new connections but stay - * in PM_RUN or PM_HOT_STANDBY state until all the client backends are gone. - * connsAllowed is a sub-state indicator showing the active restriction. - * It is of no interest unless pmState is PM_RUN or PM_HOT_STANDBY. - */ - - -/* Start time of SIGKILL timeout during immediate shutdown or child crash */ -/* Zero means timeout is not running */ - - -/* Length of said timeout */ -#define SIGKILL_CHILDREN_AFTER_SECS 5 - - /* T if we've reached PM_RUN */ - -__thread bool ClientAuthInProgress = false; - /* T during new-client - * authentication */ - - /* stderr redirected for syslogger? */ - -/* received START_AUTOVAC_LAUNCHER signal */ - - -/* the launcher needs to be signaled to communicate some condition */ - - -/* received START_WALRECEIVER signal */ - - -/* set when there's a worker that needs to be started up */ - - - -/* set when signals arrive */ - - - - - - - -/* event multiplexing object */ - - -#ifdef USE_SSL -/* Set when and if SSL has been initialized properly */ -static bool LoadedSSL = false; -#endif - -#ifdef USE_BONJOUR -static DNSServiceRef bonjour_sdref = NULL; -#endif - -/* - * postmaster.c - function prototypes - */ -static void CloseServerPorts(int status, Datum arg); -static void unlink_external_pid_file(int status, Datum arg); -static void getInstallationPaths(const char *argv0); -static void checkControlFile(void); -static Port *ConnCreate(int serverFd); -static void ConnFree(Port *port); -static void handle_pm_pmsignal_signal(SIGNAL_ARGS); -static void handle_pm_child_exit_signal(SIGNAL_ARGS); -static void handle_pm_reload_request_signal(SIGNAL_ARGS); -static void handle_pm_shutdown_request_signal(SIGNAL_ARGS); -static void process_pm_pmsignal(void); -static void process_pm_child_exit(void); -static void process_pm_reload_request(void); -static void process_pm_shutdown_request(void); -static void process_startup_packet_die(SIGNAL_ARGS); -static void dummy_handler(SIGNAL_ARGS); -static void StartupPacketTimeoutHandler(void); -static void CleanupBackend(int pid, int exitstatus); -static bool CleanupBackgroundWorker(int pid, int exitstatus); -static void HandleChildCrash(int pid, int exitstatus, const char *procname); -static void LogChildExit(int lev, const char *procname, - int pid, int exitstatus); -static void PostmasterStateMachine(void); -static void BackendInitialize(Port *port); -static void BackendRun(Port *port) pg_attribute_noreturn(); -static void ExitPostmaster(int status) pg_attribute_noreturn(); -static int ServerLoop(void); -static int BackendStartup(Port *port); -static int ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done); -static void SendNegotiateProtocolVersion(List *unrecognized_protocol_options); -static void processCancelRequest(Port *port, void *pkt); -static void report_fork_failure_to_client(Port *port, int errnum); -static CAC_state canAcceptConnections(int backend_type); -static bool RandomCancelKey(int32 *cancel_key); -static void signal_child(pid_t pid, int signal); -static void sigquit_child(pid_t pid); -static bool SignalSomeChildren(int signal, int target); -static void TerminateChildren(int signal); - -#define SignalChildren(sig) SignalSomeChildren(sig, BACKEND_TYPE_ALL) - -static int CountChildren(int target); -static bool assign_backendlist_entry(RegisteredBgWorker *rw); -static void maybe_start_bgworkers(void); -static bool CreateOptsFile(int argc, char *argv[], char *fullprogname); -static pid_t StartChildProcess(AuxProcType type); -static void StartAutovacuumWorker(void); -static void MaybeStartWalReceiver(void); -static void InitPostmasterDeathWatchHandle(void); - -/* - * Archiver is allowed to start up at the current postmaster state? - * - * If WAL archiving is enabled always, we are allowed to start archiver - * even during recovery. - */ -#define PgArchStartupAllowed() \ - (((XLogArchivingActive() && pmState == PM_RUN) || \ - (XLogArchivingAlways() && \ - (pmState == PM_RECOVERY || pmState == PM_HOT_STANDBY))) && \ - PgArchCanRestart()) - -#ifdef EXEC_BACKEND - -#ifdef WIN32 -#define WNOHANG 0 /* ignored, so any integer value will do */ - -static pid_t waitpid(pid_t pid, int *exitstatus, int options); -static void WINAPI pgwin32_deadchild_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired); - -static HANDLE win32ChildQueue; - -typedef struct -{ - HANDLE waitHandle; - HANDLE procHandle; - DWORD procId; -} win32_deadchild_waitinfo; -#endif /* WIN32 */ - -static pid_t backend_forkexec(Port *port); -static pid_t internal_forkexec(int argc, char *argv[], Port *port); - -/* Type for a socket that can be inherited to a client process */ -#ifdef WIN32 -typedef struct -{ - SOCKET origsocket; /* Original socket value, or PGINVALID_SOCKET - * if not a socket */ - WSAPROTOCOL_INFO wsainfo; -} InheritableSocket; -#else -typedef int InheritableSocket; -#endif - -/* - * Structure contains all variables passed to exec:ed backends - */ -typedef struct -{ - Port port; - InheritableSocket portsocket; - char DataDir[MAXPGPATH]; - pgsocket ListenSocket[MAXLISTEN]; - int32 MyCancelKey; - int MyPMChildSlot; -#ifndef WIN32 - unsigned long UsedShmemSegID; -#else - void *ShmemProtectiveRegion; - HANDLE UsedShmemSegID; -#endif - void *UsedShmemSegAddr; - slock_t *ShmemLock; - VariableCache ShmemVariableCache; - Backend *ShmemBackendArray; -#ifndef HAVE_SPINLOCKS - PGSemaphore *SpinlockSemaArray; -#endif - int NamedLWLockTrancheRequests; - NamedLWLockTranche *NamedLWLockTrancheArray; - LWLockPadded *MainLWLockArray; - slock_t *ProcStructLock; - PROC_HDR *ProcGlobal; - PGPROC *AuxiliaryProcs; - PGPROC *PreparedXactProcs; - PMSignalData *PMSignalState; - pid_t PostmasterPid; - TimestampTz PgStartTime; - TimestampTz PgReloadTime; - pg_time_t first_syslogger_file_time; - bool redirection_done; - bool IsBinaryUpgrade; - bool query_id_enabled; - int max_safe_fds; - int MaxBackends; -#ifdef WIN32 - HANDLE PostmasterHandle; - HANDLE initial_signal_pipe; - HANDLE syslogPipe[2]; -#else - int postmaster_alive_fds[2]; - int syslogPipe[2]; -#endif - char my_exec_path[MAXPGPATH]; - char pkglib_path[MAXPGPATH]; -} BackendParameters; - -static void read_backend_variables(char *id, Port *port); -static void restore_backend_variables(BackendParameters *param, Port *port); - -#ifndef WIN32 -static bool save_backend_variables(BackendParameters *param, Port *port); -#else -static bool save_backend_variables(BackendParameters *param, Port *port, - HANDLE childProcess, pid_t childPid); -#endif - -static void ShmemBackendArrayAdd(Backend *bn); -static void ShmemBackendArrayRemove(Backend *bn); -#endif /* EXEC_BACKEND */ - -#define StartupDataBase() StartChildProcess(StartupProcess) -#define StartArchiver() StartChildProcess(ArchiverProcess) -#define StartBackgroundWriter() StartChildProcess(BgWriterProcess) -#define StartCheckpointer() StartChildProcess(CheckpointerProcess) -#define StartWalWriter() StartChildProcess(WalWriterProcess) -#define StartWalReceiver() StartChildProcess(WalReceiverProcess) - -/* Macros to check exit status of a child process */ -#define EXIT_STATUS_0(st) ((st) == 0) -#define EXIT_STATUS_1(st) (WIFEXITED(st) && WEXITSTATUS(st) == 1) -#define EXIT_STATUS_3(st) (WIFEXITED(st) && WEXITSTATUS(st) == 3) - -#ifndef WIN32 -/* - * File descriptors for pipe used to monitor if postmaster is alive. - * First is POSTMASTER_FD_WATCH, second is POSTMASTER_FD_OWN. - */ - -#else -/* Process handle of postmaster used for the same purpose on Windows */ -HANDLE PostmasterHandle; -#endif - -/* - * Postmaster main entry point - */ -#ifdef WIN32 -#endif -#ifdef SIGTTIN -#endif -#ifdef SIGTTOU -#endif -#ifdef SIGXFSZ -#endif -#ifdef HAVE_INT_OPTRESET -#endif -#ifdef USE_SSL -#endif -#ifdef WIN32 -#endif -#ifdef EXEC_BACKEND -#endif -#ifdef USE_BONJOUR -#endif -#ifdef HAVE_PTHREAD_IS_THREADED_NP -#endif - - -/* - * on_proc_exit callback to close server's listen sockets - */ - - -/* - * on_proc_exit callback to delete external_pid_file - */ - - - -/* - * Compute and check the directory paths to files that are part of the - * installation (as deduced from the postgres executable's own location) - */ -#ifdef EXEC_BACKEND -#endif - -/* - * Check that pg_control exists in the correct location in the data directory. - * - * No attempt is made to validate the contents of pg_control here. This is - * just a sanity check to see if we are looking at a real data directory. - */ - - -/* - * Determine how long should we let ServerLoop sleep, in milliseconds. - * - * In normal conditions we wait at most one minute, to ensure that the other - * background tasks handled by ServerLoop get done even when no requests are - * arriving. However, if there are background workers waiting to be started, - * we don't actually sleep so that they are quickly serviced. Other exception - * cases are as shown in the code. - */ - - -/* - * Activate or deactivate notifications of server socket events. Since we - * don't currently have a way to remove events from an existing WaitEventSet, - * we'll just destroy and recreate the whole thing. This is called during - * shutdown so we can wait for backends to exit without accepting new - * connections, and during crash reinitialization when we need to start - * listening for new connections again. The WaitEventSet will be freed in fork - * children by ClosePostmasterPorts(). - */ - - -/* - * Main idle loop of postmaster - */ -#ifdef HAVE_PTHREAD_IS_THREADED_NP -#endif - -/* - * Read a client's startup packet and do something according to it. - * - * Returns STATUS_OK or STATUS_ERROR, or might call ereport(FATAL) and - * not return at all. - * - * (Note that ereport(FATAL) stuff is sent to the client, so only use it - * if that's what you want. Return STATUS_ERROR if you don't want to - * send anything to the client, which would typically be appropriate - * if we detect a communications failure.) - * - * Set ssl_done and/or gss_done when negotiation of an encrypted layer - * (currently, TLS or GSSAPI) is completed. A successful negotiation of either - * encryption layer sets both flags, but a rejected negotiation sets only the - * flag for that layer, since the client may wish to try the other one. We - * should make no assumption here about the order in which the client may make - * requests. - */ -#ifdef USE_SSL -#else -#endif -#ifdef USE_SSL -#endif -#ifdef ENABLE_GSS -#endif -#ifdef ENABLE_GSS -#endif - -/* - * Send a NegotiateProtocolVersion to the client. This lets the client know - * that they have requested a newer minor protocol version than we are able - * to speak. We'll speak the highest version we know about; the client can, - * of course, abandon the connection if that's a problem. - * - * We also include in the response a list of protocol options we didn't - * understand. This allows clients to include optional parameters that might - * be present either in newer protocol versions or third-party protocol - * extensions without fear of having to reconnect if those options are not - * understood, while at the same time making certain that the client is aware - * of which options were actually accepted. - */ - - -/* - * The client has sent a cancel request packet, not a normal - * start-a-new-connection packet. Perform the necessary processing. - * Nothing is sent back to the client. - */ -#ifndef EXEC_BACKEND -#else -#endif -#ifndef EXEC_BACKEND -#else -#endif -#ifndef EXEC_BACKEND /* make GNU Emacs 26.1 see brace balance */ -#else -#endif - -/* - * canAcceptConnections --- check to see if database state allows connections - * of the specified type. backend_type can be BACKEND_TYPE_NORMAL, - * BACKEND_TYPE_AUTOVAC, or BACKEND_TYPE_BGWORKER. (Note that we don't yet - * know whether a NORMAL connection might turn into a walsender.) - */ - - - -/* - * ConnCreate -- create a local connection data structure - * - * Returns NULL on failure, other than out-of-memory which is fatal. - */ - - - -/* - * ConnFree -- free a local connection data structure - * - * Caller has already closed the socket if any, so there's not much - * to do here. - */ - - - -/* - * ClosePostmasterPorts -- close all the postmaster's open sockets - * - * This is called during child process startup to release file descriptors - * that are not needed by that child process. The postmaster still has - * them open, of course. - * - * Note: we pass am_syslogger as a boolean because we don't want to set - * the global variable yet when this is called. - */ -#ifndef WIN32 -#endif -#ifndef WIN32 -#else -#endif -#ifdef USE_BONJOUR -#endif - - -/* - * InitProcessGlobals -- set MyProcPid, MyStartTime[stamp], random seeds - * - * Called early in the postmaster and every backend. - */ -#ifndef WIN32 -#endif - -/* - * Child processes use SIGUSR1 to notify us of 'pmsignals'. pg_ctl uses - * SIGUSR1 to ask postmaster to check for logrotate and promote files. - */ - - -/* - * pg_ctl uses SIGHUP to request a reload of the configuration files. - */ - - -/* - * Re-read config files, and tell children to do same. - */ -#ifdef USE_SSL -#endif -#ifdef EXEC_BACKEND -#endif - -/* - * pg_ctl uses SIGTERM, SIGINT and SIGQUIT to request different types of - * shutdown. - */ - - -/* - * Process shutdown request. - */ -#ifdef USE_SYSTEMD -#endif -#ifdef USE_SYSTEMD -#endif -#ifdef USE_SYSTEMD -#endif - - - -/* - * Cleanup after a child process dies. - */ -#ifdef USE_SYSTEMD -#endif - -/* - * Scan the bgworkers list and see if the given PID (which has just stopped - * or crashed) is in it. Handle its shutdown if so, and return true. If not a - * bgworker, return false. - * - * This is heavily based on CleanupBackend. One important difference is that - * we don't know yet that the dying process is a bgworker, so we must be silent - * until we're sure it is. - */ -#ifdef WIN32 -#endif -#ifdef EXEC_BACKEND -#endif - -/* - * CleanupBackend -- cleanup after terminated backend. - * - * Remove all local state associated with backend. - * - * If you change this, see also CleanupBackgroundWorker. - */ -#ifdef WIN32 -#endif -#ifdef EXEC_BACKEND -#endif - -/* - * HandleChildCrash -- cleanup after failed backend, bgwriter, checkpointer, - * walwriter, autovacuum, archiver or background worker. - * - * The objectives here are to clean up our local state about the child - * process, and to signal all other remaining children to quickdie. - */ -#ifdef EXEC_BACKEND -#endif -#ifdef EXEC_BACKEND -#endif - -/* - * Log the death of a child process. - */ -#if defined(WIN32) -#else -#endif - -/* - * Advance the postmaster's state machine and take actions as appropriate - * - * This is common code for process_pm_shutdown_request(), - * process_pm_child_exit() and process_pm_pmsignal(), which process the signals - * that might mean we need to change state. - */ - - - -/* - * Send a signal to a postmaster child process - * - * On systems that have setsid(), each child process sets itself up as a - * process group leader. For signals that are generally interpreted in the - * appropriate fashion, we signal the entire process group not just the - * direct child process. This allows us to, for example, SIGQUIT a blocked - * archive_recovery script, or SIGINT a script being run by a backend via - * system(). - * - * There is a race condition for recently-forked children: they might not - * have executed setsid() yet. So we signal the child directly as well as - * the group. We assume such a child will handle the signal before trying - * to spawn any grandchild processes. We also assume that signaling the - * child twice will not cause any problems. - */ -#ifdef HAVE_SETSID -#endif - -/* - * Convenience function for killing a child process after a crash of some - * other child process. We log the action at a higher level than we would - * otherwise do, and we apply send_abort_for_crash to decide which signal - * to send. Normally it's SIGQUIT -- and most other comments in this file - * are written on the assumption that it is -- but developers might prefer - * to use SIGABRT to collect per-child core dumps. - */ - - -/* - * Send a signal to the targeted children (but NOT special children; - * dead_end children are never signaled, either). - */ - - -/* - * Send a termination signal to children. This considers all of our children - * processes, except syslogger and dead_end backends. - */ - - -/* - * BackendStartup -- start backend process - * - * returns: STATUS_ERROR if the fork failed, STATUS_OK otherwise. - * - * Note: if you change this code, also consider StartAutovacuumWorker. - */ -#ifdef EXEC_BACKEND -#else /* !EXEC_BACKEND */ -#endif /* EXEC_BACKEND */ -#ifdef EXEC_BACKEND -#endif - -/* - * Try to report backend fork() failure to client before we close the - * connection. Since we do not care to risk blocking the postmaster on - * this connection, we set the connection to non-blocking and try only once. - * - * This is grungy special-purpose code; we cannot use backend libpq since - * it's not up and running. - */ - - - -/* - * BackendInitialize -- initialize an interactive (postmaster-child) - * backend process, and collect the client's startup packet. - * - * returns: nothing. Will not return at all if there's any failure. - * - * Note: this code does not depend on having any access to shared memory. - * Indeed, our approach to SIGTERM/timeout handling *requires* that - * shared memory not have been touched yet; see comments within. - * In the EXEC_BACKEND case, we are physically attached to shared memory - * but have not yet set up most of our local pointers to shmem structures. - */ - - - -/* - * BackendRun -- set up the backend's argument list and invoke PostgresMain() - * - * returns: - * Doesn't return at all. - */ - - - -#ifdef EXEC_BACKEND - -/* - * postmaster_forkexec -- fork and exec a postmaster subprocess - * - * The caller must have set up the argv array already, except for argv[2] - * which will be filled with the name of the temp variable file. - * - * Returns the child process PID, or -1 on fork failure (a suitable error - * message has been logged on failure). - * - * All uses of this routine will dispatch to SubPostmasterMain in the - * child process. - */ -pid_t -postmaster_forkexec(int argc, char *argv[]) -{ - Port port; - - /* This entry point passes dummy values for the Port variables */ - memset(&port, 0, sizeof(port)); - return internal_forkexec(argc, argv, &port); -} - -/* - * backend_forkexec -- fork/exec off a backend process - * - * Some operating systems (WIN32) don't have fork() so we have to simulate - * it by storing parameters that need to be passed to the child and - * then create a new child process. - * - * returns the pid of the fork/exec'd process, or -1 on failure - */ -static pid_t -backend_forkexec(Port *port) -{ - char *av[4]; - int ac = 0; - - av[ac++] = "postgres"; - av[ac++] = "--forkbackend"; - av[ac++] = NULL; /* filled in by internal_forkexec */ - - av[ac] = NULL; - Assert(ac < lengthof(av)); - - return internal_forkexec(ac, av, port); -} - -#ifndef WIN32 - -/* - * internal_forkexec non-win32 implementation - * - * - writes out backend variables to the parameter file - * - fork():s, and then exec():s the child process - */ -static pid_t -internal_forkexec(int argc, char *argv[], Port *port) -{ - static unsigned long tmpBackendFileNum = 0; - pid_t pid; - char tmpfilename[MAXPGPATH]; - BackendParameters param; - FILE *fp; - - if (!save_backend_variables(¶m, port)) - return -1; /* log made by save_backend_variables */ - - /* Calculate name for temp file */ - snprintf(tmpfilename, MAXPGPATH, "%s/%s.backend_var.%d.%lu", - PG_TEMP_FILES_DIR, PG_TEMP_FILE_PREFIX, - MyProcPid, ++tmpBackendFileNum); - - /* Open file */ - fp = AllocateFile(tmpfilename, PG_BINARY_W); - if (!fp) - { - /* - * As in OpenTemporaryFileInTablespace, try to make the temp-file - * directory, ignoring errors. - */ - (void) MakePGDirectory(PG_TEMP_FILES_DIR); - - fp = AllocateFile(tmpfilename, PG_BINARY_W); - if (!fp) - { - ereport(LOG, - (errcode_for_file_access(), - errmsg("could not create file \"%s\": %m", - tmpfilename))); - return -1; - } - } - - if (fwrite(¶m, sizeof(param), 1, fp) != 1) - { - ereport(LOG, - (errcode_for_file_access(), - errmsg("could not write to file \"%s\": %m", tmpfilename))); - FreeFile(fp); - return -1; - } - - /* Release file */ - if (FreeFile(fp)) - { - ereport(LOG, - (errcode_for_file_access(), - errmsg("could not write to file \"%s\": %m", tmpfilename))); - return -1; - } - - /* Make sure caller set up argv properly */ - Assert(argc >= 3); - Assert(argv[argc] == NULL); - Assert(strncmp(argv[1], "--fork", 6) == 0); - Assert(argv[2] == NULL); - - /* Insert temp file name after --fork argument */ - argv[2] = tmpfilename; - - /* Fire off execv in child */ - if ((pid = fork_process()) == 0) - { - if (execv(postgres_exec_path, argv) < 0) - { - ereport(LOG, - (errmsg("could not execute server process \"%s\": %m", - postgres_exec_path))); - /* We're already in the child process here, can't return */ - exit(1); - } - } - - return pid; /* Parent returns pid, or -1 on fork failure */ -} -#else /* WIN32 */ - -/* - * internal_forkexec win32 implementation - * - * - starts backend using CreateProcess(), in suspended state - * - writes out backend variables to the parameter file - * - during this, duplicates handles and sockets required for - * inheritance into the new process - * - resumes execution of the new process once the backend parameter - * file is complete. - */ -static pid_t -internal_forkexec(int argc, char *argv[], Port *port) -{ - int retry_count = 0; - STARTUPINFO si; - PROCESS_INFORMATION pi; - int i; - int j; - char cmdLine[MAXPGPATH * 2]; - HANDLE paramHandle; - BackendParameters *param; - SECURITY_ATTRIBUTES sa; - char paramHandleStr[32]; - win32_deadchild_waitinfo *childinfo; - - /* Make sure caller set up argv properly */ - Assert(argc >= 3); - Assert(argv[argc] == NULL); - Assert(strncmp(argv[1], "--fork", 6) == 0); - Assert(argv[2] == NULL); - - /* Resume here if we need to retry */ -retry: - - /* Set up shared memory for parameter passing */ - ZeroMemory(&sa, sizeof(sa)); - sa.nLength = sizeof(sa); - sa.bInheritHandle = TRUE; - paramHandle = CreateFileMapping(INVALID_HANDLE_VALUE, - &sa, - PAGE_READWRITE, - 0, - sizeof(BackendParameters), - NULL); - if (paramHandle == INVALID_HANDLE_VALUE) - { - ereport(LOG, - (errmsg("could not create backend parameter file mapping: error code %lu", - GetLastError()))); - return -1; - } - - param = MapViewOfFile(paramHandle, FILE_MAP_WRITE, 0, 0, sizeof(BackendParameters)); - if (!param) - { - ereport(LOG, - (errmsg("could not map backend parameter memory: error code %lu", - GetLastError()))); - CloseHandle(paramHandle); - return -1; - } - - /* Insert temp file name after --fork argument */ -#ifdef _WIN64 - sprintf(paramHandleStr, "%llu", (LONG_PTR) paramHandle); -#else - sprintf(paramHandleStr, "%lu", (DWORD) paramHandle); -#endif - argv[2] = paramHandleStr; - - /* Format the cmd line */ - cmdLine[sizeof(cmdLine) - 1] = '\0'; - cmdLine[sizeof(cmdLine) - 2] = '\0'; - snprintf(cmdLine, sizeof(cmdLine) - 1, "\"%s\"", postgres_exec_path); - i = 0; - while (argv[++i] != NULL) - { - j = strlen(cmdLine); - snprintf(cmdLine + j, sizeof(cmdLine) - 1 - j, " \"%s\"", argv[i]); - } - if (cmdLine[sizeof(cmdLine) - 2] != '\0') - { - ereport(LOG, - (errmsg("subprocess command line too long"))); - UnmapViewOfFile(param); - CloseHandle(paramHandle); - return -1; - } - - memset(&pi, 0, sizeof(pi)); - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - - /* - * Create the subprocess in a suspended state. This will be resumed later, - * once we have written out the parameter file. - */ - if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED, - NULL, NULL, &si, &pi)) - { - ereport(LOG, - (errmsg("CreateProcess() call failed: %m (error code %lu)", - GetLastError()))); - UnmapViewOfFile(param); - CloseHandle(paramHandle); - return -1; - } - - if (!save_backend_variables(param, port, pi.hProcess, pi.dwProcessId)) - { - /* - * log made by save_backend_variables, but we have to clean up the - * mess with the half-started process - */ - if (!TerminateProcess(pi.hProcess, 255)) - ereport(LOG, - (errmsg_internal("could not terminate unstarted process: error code %lu", - GetLastError()))); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - UnmapViewOfFile(param); - CloseHandle(paramHandle); - return -1; /* log made by save_backend_variables */ - } - - /* Drop the parameter shared memory that is now inherited to the backend */ - if (!UnmapViewOfFile(param)) - ereport(LOG, - (errmsg("could not unmap view of backend parameter file: error code %lu", - GetLastError()))); - if (!CloseHandle(paramHandle)) - ereport(LOG, - (errmsg("could not close handle to backend parameter file: error code %lu", - GetLastError()))); - - /* - * Reserve the memory region used by our main shared memory segment before - * we resume the child process. Normally this should succeed, but if ASLR - * is active then it might sometimes fail due to the stack or heap having - * gotten mapped into that range. In that case, just terminate the - * process and retry. - */ - if (!pgwin32_ReserveSharedMemoryRegion(pi.hProcess)) - { - /* pgwin32_ReserveSharedMemoryRegion already made a log entry */ - if (!TerminateProcess(pi.hProcess, 255)) - ereport(LOG, - (errmsg_internal("could not terminate process that failed to reserve memory: error code %lu", - GetLastError()))); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - if (++retry_count < 100) - goto retry; - ereport(LOG, - (errmsg("giving up after too many tries to reserve shared memory"), - errhint("This might be caused by ASLR or antivirus software."))); - return -1; - } - - /* - * Now that the backend variables are written out, we start the child - * thread so it can start initializing while we set up the rest of the - * parent state. - */ - if (ResumeThread(pi.hThread) == -1) - { - if (!TerminateProcess(pi.hProcess, 255)) - { - ereport(LOG, - (errmsg_internal("could not terminate unstartable process: error code %lu", - GetLastError()))); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - return -1; - } - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - ereport(LOG, - (errmsg_internal("could not resume thread of unstarted process: error code %lu", - GetLastError()))); - return -1; - } - - /* - * Queue a waiter to signal when this child dies. The wait will be handled - * automatically by an operating system thread pool. The memory will be - * freed by a later call to waitpid(). - */ - childinfo = palloc(sizeof(win32_deadchild_waitinfo)); - childinfo->procHandle = pi.hProcess; - childinfo->procId = pi.dwProcessId; - - if (!RegisterWaitForSingleObject(&childinfo->waitHandle, - pi.hProcess, - pgwin32_deadchild_callback, - childinfo, - INFINITE, - WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD)) - ereport(FATAL, - (errmsg_internal("could not register process for wait: error code %lu", - GetLastError()))); - - /* Don't close pi.hProcess here - waitpid() needs access to it */ - - CloseHandle(pi.hThread); - - return pi.dwProcessId; -} -#endif /* WIN32 */ - - -/* - * SubPostmasterMain -- Get the fork/exec'd process into a state equivalent - * to what it would be if we'd simply forked on Unix, and then - * dispatch to the appropriate place. - * - * The first two command line arguments are expected to be "--forkFOO" - * (where FOO indicates which postmaster child we are to become), and - * the name of a variables file that we can read to load data that would - * have been inherited by fork() on Unix. Remaining arguments go to the - * subprocess FooMain() routine. - */ -void -SubPostmasterMain(int argc, char *argv[]) -{ - Port port; - - /* In EXEC_BACKEND case we will not have inherited these settings */ - IsPostmasterEnvironment = true; - whereToSendOutput = DestNone; - - /* Setup essential subsystems (to ensure elog() behaves sanely) */ - InitializeGUCOptions(); - - /* Check we got appropriate args */ - if (argc < 3) - elog(FATAL, "invalid subpostmaster invocation"); - - /* Read in the variables file */ - memset(&port, 0, sizeof(Port)); - read_backend_variables(argv[2], &port); - - /* Close the postmaster's sockets (as soon as we know them) */ - ClosePostmasterPorts(strcmp(argv[1], "--forklog") == 0); - - /* Setup as postmaster child */ - InitPostmasterChild(); - - /* - * If appropriate, physically re-attach to shared memory segment. We want - * to do this before going any further to ensure that we can attach at the - * same address the postmaster used. On the other hand, if we choose not - * to re-attach, we may have other cleanup to do. - * - * If testing EXEC_BACKEND on Linux, you should run this as root before - * starting the postmaster: - * - * sysctl -w kernel.randomize_va_space=0 - * - * This prevents using randomized stack and code addresses that cause the - * child process's memory map to be different from the parent's, making it - * sometimes impossible to attach to shared memory at the desired address. - * Return the setting to its old value (usually '1' or '2') when finished. - */ - if (strcmp(argv[1], "--forkbackend") == 0 || - strcmp(argv[1], "--forkavlauncher") == 0 || - strcmp(argv[1], "--forkavworker") == 0 || - strcmp(argv[1], "--forkaux") == 0 || - strncmp(argv[1], "--forkbgworker=", 15) == 0) - PGSharedMemoryReAttach(); - else - PGSharedMemoryNoReAttach(); - - /* autovacuum needs this set before calling InitProcess */ - if (strcmp(argv[1], "--forkavlauncher") == 0) - AutovacuumLauncherIAm(); - if (strcmp(argv[1], "--forkavworker") == 0) - AutovacuumWorkerIAm(); - - /* Read in remaining GUC variables */ - read_nondefault_variables(); - - /* - * Check that the data directory looks valid, which will also check the - * privileges on the data directory and update our umask and file/group - * variables for creating files later. Note: this should really be done - * before we create any files or directories. - */ - checkDataDir(); - - /* - * (re-)read control file, as it contains config. The postmaster will - * already have read this, but this process doesn't know about that. - */ - LocalProcessControlFile(false); - - /* - * Reload any libraries that were preloaded by the postmaster. Since we - * exec'd this process, those libraries didn't come along with us; but we - * should load them into all child processes to be consistent with the - * non-EXEC_BACKEND behavior. - */ - process_shared_preload_libraries(); - - /* Run backend or appropriate child */ - if (strcmp(argv[1], "--forkbackend") == 0) - { - Assert(argc == 3); /* shouldn't be any more args */ - - /* - * Need to reinitialize the SSL library in the backend, since the - * context structures contain function pointers and cannot be passed - * through the parameter file. - * - * If for some reason reload fails (maybe the user installed broken - * key files), soldier on without SSL; that's better than all - * connections becoming impossible. - * - * XXX should we do this in all child processes? For the moment it's - * enough to do it in backend children. - */ -#ifdef USE_SSL - if (EnableSSL) - { - if (secure_initialize(false) == 0) - LoadedSSL = true; - else - ereport(LOG, - (errmsg("SSL configuration could not be loaded in child process"))); - } -#endif - - /* - * Perform additional initialization and collect startup packet. - * - * We want to do this before InitProcess() for a couple of reasons: 1. - * so that we aren't eating up a PGPROC slot while waiting on the - * client. 2. so that if InitProcess() fails due to being out of - * PGPROC slots, we have already initialized libpq and are able to - * report the error to the client. - */ - BackendInitialize(&port); - - /* Restore basic shared memory pointers */ - InitShmemAccess(UsedShmemSegAddr); - - /* Need a PGPROC to run CreateSharedMemoryAndSemaphores */ - InitProcess(); - - /* Attach process to shared data structures */ - CreateSharedMemoryAndSemaphores(); - - /* And run the backend */ - BackendRun(&port); /* does not return */ - } - if (strcmp(argv[1], "--forkaux") == 0) - { - AuxProcType auxtype; - - Assert(argc == 4); - - /* Restore basic shared memory pointers */ - InitShmemAccess(UsedShmemSegAddr); - - /* Need a PGPROC to run CreateSharedMemoryAndSemaphores */ - InitAuxiliaryProcess(); - - /* Attach process to shared data structures */ - CreateSharedMemoryAndSemaphores(); - - auxtype = atoi(argv[3]); - AuxiliaryProcessMain(auxtype); /* does not return */ - } - if (strcmp(argv[1], "--forkavlauncher") == 0) - { - /* Restore basic shared memory pointers */ - InitShmemAccess(UsedShmemSegAddr); - - /* Need a PGPROC to run CreateSharedMemoryAndSemaphores */ - InitProcess(); - - /* Attach process to shared data structures */ - CreateSharedMemoryAndSemaphores(); - - AutoVacLauncherMain(argc - 2, argv + 2); /* does not return */ - } - if (strcmp(argv[1], "--forkavworker") == 0) - { - /* Restore basic shared memory pointers */ - InitShmemAccess(UsedShmemSegAddr); - - /* Need a PGPROC to run CreateSharedMemoryAndSemaphores */ - InitProcess(); - - /* Attach process to shared data structures */ - CreateSharedMemoryAndSemaphores(); - - AutoVacWorkerMain(argc - 2, argv + 2); /* does not return */ - } - if (strncmp(argv[1], "--forkbgworker=", 15) == 0) - { - int shmem_slot; - - /* do this as early as possible; in particular, before InitProcess() */ - IsBackgroundWorker = true; - - /* Restore basic shared memory pointers */ - InitShmemAccess(UsedShmemSegAddr); - - /* Need a PGPROC to run CreateSharedMemoryAndSemaphores */ - InitProcess(); - - /* Attach process to shared data structures */ - CreateSharedMemoryAndSemaphores(); - - /* Fetch MyBgworkerEntry from shared memory */ - shmem_slot = atoi(argv[1] + 15); - MyBgworkerEntry = BackgroundWorkerEntry(shmem_slot); - - StartBackgroundWorker(); - } - if (strcmp(argv[1], "--forklog") == 0) - { - /* Do not want to attach to shared memory */ - - SysLoggerMain(argc, argv); /* does not return */ - } - - abort(); /* shouldn't get here */ -} -#endif /* EXEC_BACKEND */ - - -/* - * ExitPostmaster -- cleanup - * - * Do NOT call exit() directly --- always go through here! - */ -#ifdef HAVE_PTHREAD_IS_THREADED_NP -#endif - -/* - * Handle pmsignal conditions representing requests from backends, - * and check for promote and logrotate requests from pg_ctl. - */ -#ifdef USE_SYSTEMD -#endif -#ifdef USE_SYSTEMD -#endif - -/* - * SIGTERM while processing startup packet. - * - * Running proc_exit() from a signal handler would be quite unsafe. - * However, since we have not yet touched shared memory, we can just - * pull the plug and exit without running any atexit handlers. - * - * One might be tempted to try to send a message, or log one, indicating - * why we are disconnecting. However, that would be quite unsafe in itself. - * Also, it seems undesirable to provide clues about the database's state - * to a client that has not yet completed authentication, or even sent us - * a startup packet. - */ - - -/* - * Dummy signal handler - * - * We use this for signals that we don't actually use in the postmaster, - * but we do use in backends. If we were to SIG_IGN such signals in the - * postmaster, then a newly started backend might drop a signal that arrives - * before it's able to reconfigure its signal processing. (See notes in - * tcop/postgres.c.) - */ - - -/* - * Timeout while processing startup packet. - * As for process_startup_packet_die(), we exit via _exit(1). - */ - - - -/* - * Generate a random cancel key. - */ - - -/* - * Count up number of child processes of specified types (dead_end children - * are always excluded). - */ - - - -/* - * StartChildProcess -- start an auxiliary process for the postmaster - * - * "type" determines what kind of child will be started. All child types - * initially go to AuxiliaryProcessMain, which will handle common setup. - * - * Return value of StartChildProcess is subprocess' PID, or 0 if failed - * to start subprocess. - */ -#ifdef EXEC_BACKEND -#else /* !EXEC_BACKEND */ -#endif /* EXEC_BACKEND */ - -/* - * StartAutovacuumWorker - * Start an autovac worker process. - * - * This function is here because it enters the resulting PID into the - * postmaster's private backends list. - * - * NB -- this code very roughly matches BackendStartup. - */ -#ifdef EXEC_BACKEND -#endif - -/* - * MaybeStartWalReceiver - * Start the WAL receiver process, if not running and our state allows. - * - * Note: if WalReceiverPID is already nonzero, it might seem that we should - * clear WalReceiverRequested. However, there's a race condition if the - * walreceiver terminates and the startup process immediately requests a new - * one: it's quite possible to get the signal for the request before reaping - * the dead walreceiver process. Better to risk launching an extra - * walreceiver than to miss launching one we need. (The walreceiver code - * has logic to recognize that it should go away if not needed.) - */ - - - -/* - * Create the opts file - */ -#define OPTS_FILE "postmaster.opts" - - -/* - * MaxLivePostmasterChildren - * - * This reports the number of entries needed in per-child-process arrays - * (the PMChildFlags array, and if EXEC_BACKEND the ShmemBackendArray). - * These arrays include regular backends, autovac workers, walsenders - * and background workers, but not special children nor dead_end children. - * This allows the arrays to have a fixed maximum size, to wit the same - * too-many-children limit enforced by canAcceptConnections(). The exact value - * isn't too critical as long as it's more than MaxBackends. - */ - - -/* - * Connect background worker to a database. - */ - - -/* - * Connect background worker to a database using OIDs. - */ - - -/* - * Block/unblock signals in a background worker - */ - - - - -#ifdef EXEC_BACKEND -static pid_t -bgworker_forkexec(int shmem_slot) -{ - char *av[10]; - int ac = 0; - char forkav[MAXPGPATH]; - - snprintf(forkav, MAXPGPATH, "--forkbgworker=%d", shmem_slot); - - av[ac++] = "postgres"; - av[ac++] = forkav; - av[ac++] = NULL; /* filled in by postmaster_forkexec */ - av[ac] = NULL; - - Assert(ac < lengthof(av)); - - return postmaster_forkexec(ac, av); -} -#endif - -/* - * Start a new bgworker. - * Starting time conditions must have been checked already. - * - * Returns true on success, false on failure. - * In either case, update the RegisteredBgWorker's state appropriately. - * - * This code is heavily based on autovacuum.c, q.v. - */ -#ifdef EXEC_BACKEND -#else -#endif -#ifndef EXEC_BACKEND -#endif -#ifdef EXEC_BACKEND -#endif - -/* - * Does the current postmaster state require starting a worker with the - * specified start_time? - */ - - -/* - * Allocate the Backend struct for a connected background worker, but don't - * add it to the list of backends just yet. - * - * On failure, return false without changing any worker state. - * - * Some info from the Backend is copied into the passed rw. - */ - - -/* - * If the time is right, start background worker(s). - * - * As a side effect, the bgworker control variables are set or reset - * depending on whether more workers may need to be started. - * - * We limit the number of workers started per call, to avoid consuming the - * postmaster's attention for too long when many such requests are pending. - * As long as StartWorkerNeeded is true, ServerLoop will not block and will - * call this function again after dealing with any other issues. - */ -#define MAX_BGWORKERS_TO_LAUNCH 100 - -/* - * When a backend asks to be notified about worker state changes, we - * set a flag in its backend entry. The background worker machinery needs - * to know when such backends exit. - */ - - -#ifdef EXEC_BACKEND - -/* - * The following need to be available to the save/restore_backend_variables - * functions. They are marked NON_EXEC_STATIC in their home modules. - */ -extern slock_t *ShmemLock; -extern slock_t *ProcStructLock; -extern PGPROC *AuxiliaryProcs; -extern PMSignalData *PMSignalState; -extern pg_time_t first_syslogger_file_time; - -#ifndef WIN32 -#define write_inheritable_socket(dest, src, childpid) ((*(dest) = (src)), true) -#define read_inheritable_socket(dest, src) (*(dest) = *(src)) -#else -static bool write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE child); -static bool write_inheritable_socket(InheritableSocket *dest, SOCKET src, - pid_t childPid); -static void read_inheritable_socket(SOCKET *dest, InheritableSocket *src); -#endif - - -/* Save critical backend variables into the BackendParameters struct */ -#ifndef WIN32 -static bool -save_backend_variables(BackendParameters *param, Port *port) -#else -static bool -save_backend_variables(BackendParameters *param, Port *port, - HANDLE childProcess, pid_t childPid) -#endif -{ - memcpy(¶m->port, port, sizeof(Port)); - if (!write_inheritable_socket(¶m->portsocket, port->sock, childPid)) - return false; - - strlcpy(param->DataDir, DataDir, MAXPGPATH); - - memcpy(¶m->ListenSocket, &ListenSocket, sizeof(ListenSocket)); - - param->MyCancelKey = MyCancelKey; - param->MyPMChildSlot = MyPMChildSlot; - -#ifdef WIN32 - param->ShmemProtectiveRegion = ShmemProtectiveRegion; -#endif - param->UsedShmemSegID = UsedShmemSegID; - param->UsedShmemSegAddr = UsedShmemSegAddr; - - param->ShmemLock = ShmemLock; - param->ShmemVariableCache = ShmemVariableCache; - param->ShmemBackendArray = ShmemBackendArray; - -#ifndef HAVE_SPINLOCKS - param->SpinlockSemaArray = SpinlockSemaArray; -#endif - param->NamedLWLockTrancheRequests = NamedLWLockTrancheRequests; - param->NamedLWLockTrancheArray = NamedLWLockTrancheArray; - param->MainLWLockArray = MainLWLockArray; - param->ProcStructLock = ProcStructLock; - param->ProcGlobal = ProcGlobal; - param->AuxiliaryProcs = AuxiliaryProcs; - param->PreparedXactProcs = PreparedXactProcs; - param->PMSignalState = PMSignalState; - - param->PostmasterPid = PostmasterPid; - param->PgStartTime = PgStartTime; - param->PgReloadTime = PgReloadTime; - param->first_syslogger_file_time = first_syslogger_file_time; - - param->redirection_done = redirection_done; - param->IsBinaryUpgrade = IsBinaryUpgrade; - param->query_id_enabled = query_id_enabled; - param->max_safe_fds = max_safe_fds; - - param->MaxBackends = MaxBackends; - -#ifdef WIN32 - param->PostmasterHandle = PostmasterHandle; - if (!write_duplicated_handle(¶m->initial_signal_pipe, - pgwin32_create_signal_listener(childPid), - childProcess)) - return false; -#else - memcpy(¶m->postmaster_alive_fds, &postmaster_alive_fds, - sizeof(postmaster_alive_fds)); -#endif - - memcpy(¶m->syslogPipe, &syslogPipe, sizeof(syslogPipe)); - - strlcpy(param->my_exec_path, my_exec_path, MAXPGPATH); - - strlcpy(param->pkglib_path, pkglib_path, MAXPGPATH); - - return true; -} - - -#ifdef WIN32 -/* - * Duplicate a handle for usage in a child process, and write the child - * process instance of the handle to the parameter file. - */ -static bool -write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE childProcess) -{ - HANDLE hChild = INVALID_HANDLE_VALUE; - - if (!DuplicateHandle(GetCurrentProcess(), - src, - childProcess, - &hChild, - 0, - TRUE, - DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) - { - ereport(LOG, - (errmsg_internal("could not duplicate handle to be written to backend parameter file: error code %lu", - GetLastError()))); - return false; - } - - *dest = hChild; - return true; -} - -/* - * Duplicate a socket for usage in a child process, and write the resulting - * structure to the parameter file. - * This is required because a number of LSPs (Layered Service Providers) very - * common on Windows (antivirus, firewalls, download managers etc) break - * straight socket inheritance. - */ -static bool -write_inheritable_socket(InheritableSocket *dest, SOCKET src, pid_t childpid) -{ - dest->origsocket = src; - if (src != 0 && src != PGINVALID_SOCKET) - { - /* Actual socket */ - if (WSADuplicateSocket(src, childpid, &dest->wsainfo) != 0) - { - ereport(LOG, - (errmsg("could not duplicate socket %d for use in backend: error code %d", - (int) src, WSAGetLastError()))); - return false; - } - } - return true; -} - -/* - * Read a duplicate socket structure back, and get the socket descriptor. - */ -static void -read_inheritable_socket(SOCKET *dest, InheritableSocket *src) -{ - SOCKET s; - - if (src->origsocket == PGINVALID_SOCKET || src->origsocket == 0) - { - /* Not a real socket! */ - *dest = src->origsocket; - } - else - { - /* Actual socket, so create from structure */ - s = WSASocket(FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - &src->wsainfo, - 0, - 0); - if (s == INVALID_SOCKET) - { - write_stderr("could not create inherited socket: error code %d\n", - WSAGetLastError()); - exit(1); - } - *dest = s; - - /* - * To make sure we don't get two references to the same socket, close - * the original one. (This would happen when inheritance actually - * works.. - */ - closesocket(src->origsocket); - } -} -#endif - -static void -read_backend_variables(char *id, Port *port) -{ - BackendParameters param; - -#ifndef WIN32 - /* Non-win32 implementation reads from file */ - FILE *fp; - - /* Open file */ - fp = AllocateFile(id, PG_BINARY_R); - if (!fp) - { - write_stderr("could not open backend variables file \"%s\": %s\n", - id, strerror(errno)); - exit(1); - } - - if (fread(¶m, sizeof(param), 1, fp) != 1) - { - write_stderr("could not read from backend variables file \"%s\": %s\n", - id, strerror(errno)); - exit(1); - } - - /* Release file */ - FreeFile(fp); - if (unlink(id) != 0) - { - write_stderr("could not remove file \"%s\": %s\n", - id, strerror(errno)); - exit(1); - } -#else - /* Win32 version uses mapped file */ - HANDLE paramHandle; - BackendParameters *paramp; - -#ifdef _WIN64 - paramHandle = (HANDLE) _atoi64(id); -#else - paramHandle = (HANDLE) atol(id); -#endif - paramp = MapViewOfFile(paramHandle, FILE_MAP_READ, 0, 0, 0); - if (!paramp) - { - write_stderr("could not map view of backend variables: error code %lu\n", - GetLastError()); - exit(1); - } - - memcpy(¶m, paramp, sizeof(BackendParameters)); - - if (!UnmapViewOfFile(paramp)) - { - write_stderr("could not unmap view of backend variables: error code %lu\n", - GetLastError()); - exit(1); - } - - if (!CloseHandle(paramHandle)) - { - write_stderr("could not close handle to backend parameter variables: error code %lu\n", - GetLastError()); - exit(1); - } -#endif - - restore_backend_variables(¶m, port); -} - -/* Restore critical backend variables from the BackendParameters struct */ -static void -restore_backend_variables(BackendParameters *param, Port *port) -{ - memcpy(port, ¶m->port, sizeof(Port)); - read_inheritable_socket(&port->sock, ¶m->portsocket); - - SetDataDir(param->DataDir); - - memcpy(&ListenSocket, ¶m->ListenSocket, sizeof(ListenSocket)); - - MyCancelKey = param->MyCancelKey; - MyPMChildSlot = param->MyPMChildSlot; - -#ifdef WIN32 - ShmemProtectiveRegion = param->ShmemProtectiveRegion; -#endif - UsedShmemSegID = param->UsedShmemSegID; - UsedShmemSegAddr = param->UsedShmemSegAddr; - - ShmemLock = param->ShmemLock; - ShmemVariableCache = param->ShmemVariableCache; - ShmemBackendArray = param->ShmemBackendArray; - -#ifndef HAVE_SPINLOCKS - SpinlockSemaArray = param->SpinlockSemaArray; -#endif - NamedLWLockTrancheRequests = param->NamedLWLockTrancheRequests; - NamedLWLockTrancheArray = param->NamedLWLockTrancheArray; - MainLWLockArray = param->MainLWLockArray; - ProcStructLock = param->ProcStructLock; - ProcGlobal = param->ProcGlobal; - AuxiliaryProcs = param->AuxiliaryProcs; - PreparedXactProcs = param->PreparedXactProcs; - PMSignalState = param->PMSignalState; - - PostmasterPid = param->PostmasterPid; - PgStartTime = param->PgStartTime; - PgReloadTime = param->PgReloadTime; - first_syslogger_file_time = param->first_syslogger_file_time; - - redirection_done = param->redirection_done; - IsBinaryUpgrade = param->IsBinaryUpgrade; - query_id_enabled = param->query_id_enabled; - max_safe_fds = param->max_safe_fds; - - MaxBackends = param->MaxBackends; - -#ifdef WIN32 - PostmasterHandle = param->PostmasterHandle; - pgwin32_initial_signal_pipe = param->initial_signal_pipe; -#else - memcpy(&postmaster_alive_fds, ¶m->postmaster_alive_fds, - sizeof(postmaster_alive_fds)); -#endif - - memcpy(&syslogPipe, ¶m->syslogPipe, sizeof(syslogPipe)); - - strlcpy(my_exec_path, param->my_exec_path, MAXPGPATH); - - strlcpy(pkglib_path, param->pkglib_path, MAXPGPATH); - - /* - * We need to restore fd.c's counts of externally-opened FDs; to avoid - * confusion, be sure to do this after restoring max_safe_fds. (Note: - * BackendInitialize will handle this for port->sock.) - */ -#ifndef WIN32 - if (postmaster_alive_fds[0] >= 0) - ReserveExternalFD(); - if (postmaster_alive_fds[1] >= 0) - ReserveExternalFD(); -#endif -} - - -Size -ShmemBackendArraySize(void) -{ - return mul_size(MaxLivePostmasterChildren(), sizeof(Backend)); -} - -void -ShmemBackendArrayAllocation(void) -{ - Size size = ShmemBackendArraySize(); - - ShmemBackendArray = (Backend *) ShmemAlloc(size); - /* Mark all slots as empty */ - memset(ShmemBackendArray, 0, size); -} - -static void -ShmemBackendArrayAdd(Backend *bn) -{ - /* The array slot corresponding to my PMChildSlot should be free */ - int i = bn->child_slot - 1; - - Assert(ShmemBackendArray[i].pid == 0); - ShmemBackendArray[i] = *bn; -} - -static void -ShmemBackendArrayRemove(Backend *bn) -{ - int i = bn->child_slot - 1; - - Assert(ShmemBackendArray[i].pid == bn->pid); - /* Mark the slot as empty */ - ShmemBackendArray[i].pid = 0; -} -#endif /* EXEC_BACKEND */ - - -#ifdef WIN32 - -/* - * Subset implementation of waitpid() for Windows. We assume pid is -1 - * (that is, check all child processes) and options is WNOHANG (don't wait). - */ -static pid_t -waitpid(pid_t pid, int *exitstatus, int options) -{ - win32_deadchild_waitinfo *childinfo; - DWORD exitcode; - DWORD dwd; - ULONG_PTR key; - OVERLAPPED *ovl; - - /* Try to consume one win32_deadchild_waitinfo from the queue. */ - if (!GetQueuedCompletionStatus(win32ChildQueue, &dwd, &key, &ovl, 0)) - { - errno = EAGAIN; - return -1; - } - - childinfo = (win32_deadchild_waitinfo *) key; - pid = childinfo->procId; - - /* - * Remove handle from wait - required even though it's set to wait only - * once - */ - UnregisterWaitEx(childinfo->waitHandle, NULL); - - if (!GetExitCodeProcess(childinfo->procHandle, &exitcode)) - { - /* - * Should never happen. Inform user and set a fixed exitcode. - */ - write_stderr("could not read exit code for process\n"); - exitcode = 255; - } - *exitstatus = exitcode; - - /* - * Close the process handle. Only after this point can the PID can be - * recycled by the kernel. - */ - CloseHandle(childinfo->procHandle); - - /* - * Free struct that was allocated before the call to - * RegisterWaitForSingleObject() - */ - pfree(childinfo); - - return pid; -} - -/* - * Note! Code below executes on a thread pool! All operations must - * be thread safe! Note that elog() and friends must *not* be used. - */ -static void WINAPI -pgwin32_deadchild_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired) -{ - /* Should never happen, since we use INFINITE as timeout value. */ - if (TimerOrWaitFired) - return; - - /* - * Post the win32_deadchild_waitinfo object for waitpid() to deal with. If - * that fails, we leak the object, but we also leak a whole process and - * get into an unrecoverable state, so there's not much point in worrying - * about that. We'd like to panic, but we can't use that infrastructure - * from this thread. - */ - if (!PostQueuedCompletionStatus(win32ChildQueue, - 0, - (ULONG_PTR) lpParameter, - NULL)) - write_stderr("could not post child completion status\n"); - - /* Queue SIGCHLD signal. */ - pg_queue_signal(SIGCHLD); -} -#endif /* WIN32 */ - -/* - * Initialize one and only handle for monitoring postmaster death. - * - * Called once in the postmaster, so that child processes can subsequently - * monitor if their parent is dead. - */ -#ifndef WIN32 -#else -#endif /* WIN32 */ diff --git a/parser/src_backend_utils_error_elog.c b/parser/src_backend_utils_error_elog.c index c0c67340..872d2fdf 100644 --- a/parser/src_backend_utils_error_elog.c +++ b/parser/src_backend_utils_error_elog.c @@ -4,7 +4,6 @@ * - errstart * - PG_exception_stack * - write_stderr - * - err_gettext * - in_error_recursion_trouble * - error_context_stack * - errordata_stack_depth @@ -27,6 +26,7 @@ * - emit_log_hook * - send_message_to_server_log * - send_message_to_frontend + * - pgwin32_dispatch_queued_signals * - set_stack_entry_location * - matches_backtrace_functions * - backtrace_symbol_list @@ -45,6 +45,9 @@ * - errcontext_msg * - CopyErrorData * - FlushErrorState + * - pg_signal_queue + * - pg_signal_mask + * - pgwin32_dispatch_queued_signals *-------------------------------------------------------------------- */ @@ -302,24 +305,8 @@ should_output_to_server(int elevel) /* * should_output_to_client --- should message of given elevel go to the client? */ -static inline bool -should_output_to_client(int elevel) -{ - if (whereToSendOutput == DestRemote && elevel != LOG_SERVER_ONLY) - { - /* - * client_min_messages is honored only after we complete the - * authentication handshake. This is required both for security - * reasons and because many clients can't handle NOTICE messages - * during authentication. - */ - if (ClientAuthInProgress) - return (elevel >= ERROR); - else - return (elevel >= client_min_messages || elevel == INFO); - } - return false; -} +static inline bool should_output_to_client(int elevel) { return false; } + /* @@ -352,18 +339,9 @@ in_error_recursion_trouble(void) * message, since there's a significant probability that that's exactly * what's causing the recursion. */ -static inline const char * -err_gettext(const char *str) -{ #ifdef ENABLE_NLS - if (in_error_recursion_trouble()) - return str; - else - return gettext(str); #else - return str; #endif -} /* * errstart_cold @@ -1766,108 +1744,12 @@ pg_re_throw(void) * interfaces (e.g. CreateFileA()) expect string arguments in this encoding. * Every process in a given system will find the same value at all times. */ -static int -GetACPEncoding(void) -{ - static int encoding = -2; - - if (encoding == -2) - encoding = pg_codepage_to_encoding(GetACP()); - return encoding; -} /* * Write a message line to the windows event log */ -static void -write_eventlog(int level, const char *line, int len) -{ - WCHAR *utf16; - int eventlevel = EVENTLOG_ERROR_TYPE; - static HANDLE evtHandle = INVALID_HANDLE_VALUE; - - if (evtHandle == INVALID_HANDLE_VALUE) - { - evtHandle = RegisterEventSource(NULL, - event_source ? event_source : DEFAULT_EVENT_SOURCE); - if (evtHandle == NULL) - { - evtHandle = INVALID_HANDLE_VALUE; - return; - } - } - switch (level) - { - case DEBUG5: - case DEBUG4: - case DEBUG3: - case DEBUG2: - case DEBUG1: - case LOG: - case LOG_SERVER_ONLY: - case INFO: - case NOTICE: - eventlevel = EVENTLOG_INFORMATION_TYPE; - break; - case WARNING: - case WARNING_CLIENT_ONLY: - eventlevel = EVENTLOG_WARNING_TYPE; - break; - case ERROR: - case FATAL: - case PANIC: - default: - eventlevel = EVENTLOG_ERROR_TYPE; - break; - } - - /* - * If message character encoding matches the encoding expected by - * ReportEventA(), call it to avoid the hazards of conversion. Otherwise, - * try to convert the message to UTF16 and write it with ReportEventW(). - * Fall back on ReportEventA() if conversion failed. - * - * Since we palloc the structure required for conversion, also fall - * through to writing unconverted if we have not yet set up - * CurrentMemoryContext. - * - * Also verify that we are not on our way into error recursion trouble due - * to error messages thrown deep inside pgwin32_message_to_UTF16(). - */ - if (!in_error_recursion_trouble() && - CurrentMemoryContext != NULL && - GetMessageEncoding() != GetACPEncoding()) - { - utf16 = pgwin32_message_to_UTF16(line, len, NULL); - if (utf16) - { - ReportEventW(evtHandle, - eventlevel, - 0, - 0, /* All events are Id 0 */ - NULL, - 1, - 0, - (LPCWSTR *) &utf16, - NULL); - /* XXX Try ReportEventA() when ReportEventW() fails? */ - - pfree(utf16); - return; - } - } - ReportEventA(evtHandle, - eventlevel, - 0, - 0, /* All events are Id 0 */ - NULL, - 1, - 0, - &line, - NULL); -} #endif /* WIN32 */ #ifdef WIN32 @@ -2012,44 +1894,20 @@ static void send_message_to_frontend(ErrorData *edata) {} * not available). Used before ereport/elog can be used * safely (memory context, GUC load etc) */ + void write_stderr(const char *fmt,...) { - va_list ap; - -#ifdef WIN32 - char errbuf[2048]; /* Arbitrary size? */ -#endif - - fmt = _(fmt); - + va_list ap; va_start(ap, fmt); -#ifndef WIN32 - /* On Unix, we just fprintf to stderr */ vfprintf(stderr, fmt, ap); fflush(stderr); -#else - vsnprintf(errbuf, sizeof(errbuf), fmt, ap); - - /* - * On Win32, we print to stderr if running on a console, or write to - * eventlog if running as a service - */ - if (pgwin32_is_service()) /* Running as a service */ - { - write_eventlog(ERROR, errbuf, strlen(errbuf)); - } - else - { - /* Not running as service, write to stderr */ - write_console(errbuf, strlen(errbuf)); - fflush(stderr); - } -#endif va_end(ap); } + + /* * Write a message to STDERR using only async-signal-safe functions. This can * be used to safely emit a message from a signal handler. @@ -2076,3 +1934,10 @@ write_stderr(const char *fmt,...) * hard-to-explain kluge. */ +#ifdef WIN32 +__thread volatile int pg_signal_queue; + +__thread int pg_signal_mask; + +void pgwin32_dispatch_queued_signals(void) {} +#endif diff --git a/parser/src_backend_utils_init_globals.c b/parser/src_backend_utils_init_globals.c index 7a61bfbf..85100ca3 100644 --- a/parser/src_backend_utils_init_globals.c +++ b/parser/src_backend_utils_init_globals.c @@ -91,7 +91,7 @@ __thread volatile uint32 CritSectionCount = 0; /* full path to lib directory */ #ifdef EXEC_BACKEND -char postgres_exec_path[MAXPGPATH]; /* full path to backend */ + /* full path to backend */ /* note: currently this is not valid in backend processes */ #endif diff --git a/parser/src_backend_utils_mb_mbutils.c b/parser/src_backend_utils_mb_mbutils.c index 05a33729..dc863298 100644 --- a/parser/src_backend_utils_mb_mbutils.c +++ b/parser/src_backend_utils_mb_mbutils.c @@ -17,6 +17,8 @@ * - pg_mbstrlen_with_len * - pg_mblen * - SetDatabaseEncoding + * - GetMessageEncoding + * - MessageEncoding *-------------------------------------------------------------------- */ @@ -105,6 +107,7 @@ static __thread const pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCI static __thread const pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; +static __thread const pg_enc2name *MessageEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; /* @@ -595,7 +598,11 @@ GetDatabaseEncodingName(void) * not attached to a database, and under a database encoding lacking iconv * support (MULE_INTERNAL). */ - +int +GetMessageEncoding(void) +{ + return MessageEncoding->encoding; +} /* @@ -770,68 +777,6 @@ report_invalid_encoding(int encoding, const char *mbstr, int len) * null. Returns NULL iff failed. Before MessageEncoding initialization, "str" * should be ASCII-only; this will function as though MessageEncoding is UTF8. */ -WCHAR * -pgwin32_message_to_UTF16(const char *str, int len, int *utf16len) -{ - int msgenc = GetMessageEncoding(); - WCHAR *utf16; - int dstlen; - UINT codepage; - - if (msgenc == PG_SQL_ASCII) - /* No conversion is possible, and SQL_ASCII is never utf16. */ - return NULL; - codepage = pg_enc2name_tbl[msgenc].codepage; - - /* - * Use MultiByteToWideChar directly if there is a corresponding codepage, - * or double conversion through UTF8 if not. Double conversion is needed, - * for example, in an ENCODING=LATIN8, LC_CTYPE=C database. - */ - if (codepage != 0) - { - utf16 = (WCHAR *) palloc(sizeof(WCHAR) * (len + 1)); - dstlen = MultiByteToWideChar(codepage, 0, str, len, utf16, len); - utf16[dstlen] = (WCHAR) 0; - } - else - { - char *utf8; - - /* - * XXX pg_do_encoding_conversion() requires a transaction. In the - * absence of one, hope for the input to be valid UTF8. - */ - if (IsTransactionState()) - { - utf8 = (char *) pg_do_encoding_conversion((unsigned char *) str, - len, - msgenc, - PG_UTF8); - if (utf8 != str) - len = strlen(utf8); - } - else - utf8 = (char *) str; - - utf16 = (WCHAR *) palloc(sizeof(WCHAR) * (len + 1)); - dstlen = MultiByteToWideChar(CP_UTF8, 0, utf8, len, utf16, len); - utf16[dstlen] = (WCHAR) 0; - - if (utf8 != str) - pfree(utf8); - } - - if (dstlen == 0 && len > 0) - { - pfree(utf16); - return NULL; /* error */ - } - - if (utf16len) - *utf16len = dstlen; - return utf16; -} #endif /* WIN32 */ diff --git a/parser/src_backend_utils_misc_guc_tables.c b/parser/src_backend_utils_misc_guc_tables.c index 7188a5a8..60b1e577 100644 --- a/parser/src_backend_utils_misc_guc_tables.c +++ b/parser/src_backend_utils_misc_guc_tables.c @@ -1,7 +1,6 @@ /*-------------------------------------------------------------------- * Symbols referenced in this file: * - log_min_messages - * - client_min_messages * - backtrace_functions * - check_function_bodies *-------------------------------------------------------------------- @@ -285,7 +284,6 @@ __thread bool check_function_bodies = true; __thread int log_min_messages = WARNING; -__thread int client_min_messages = NOTICE; diff --git a/parser/src_port_pg_bitutils.c b/parser/src_port_pg_bitutils.c index aa6514ad..a9b8e0d0 100644 --- a/parser/src_port_pg_bitutils.c +++ b/parser/src_port_pg_bitutils.c @@ -2,6 +2,11 @@ * Symbols referenced in this file: * - pg_popcount64 * - pg_popcount64_slow + * - pg_popcount32 + * - pg_popcount32_slow + * - pg_leftmost_one_pos + * - pg_rightmost_one_pos + * - pg_number_of_ones *-------------------------------------------------------------------- */ @@ -38,7 +43,24 @@ * HAVE__BUILTIN_CLZ is defined, but we provide it anyway, so that * extensions possibly compiled with a different compiler can use it. */ - +const uint8 pg_leftmost_one_pos[256] = { + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 +}; /* * Array giving the position of the right-most set bit for each possible @@ -49,7 +71,24 @@ * HAVE__BUILTIN_CTZ is defined, but we provide it anyway, so that * extensions possibly compiled with a different compiler can use it. */ - +const uint8 pg_rightmost_one_pos[256] = { + 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 +}; /* * Array giving the number of 1-bits in each possible byte value. @@ -57,7 +96,24 @@ * Note: we export this for use by functions in which explicit use * of the popcount functions seems unlikely to be a win. */ - +const uint8 pg_number_of_ones[256] = { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 +}; static int pg_popcount32_slow(uint32 word); static int pg_popcount64_slow(uint64 word); @@ -175,9 +231,23 @@ __asm__ __volatile__(" popcntq %1,%0\n":"=q"(res):"rm"(word):"cc"); * pg_popcount32_slow * Return the number of 1 bits set in word */ +static int +pg_popcount32_slow(uint32 word) +{ #ifdef HAVE__BUILTIN_POPCOUNT + return __builtin_popcount(word); #else /* !HAVE__BUILTIN_POPCOUNT */ + int result = 0; + + while (word != 0) + { + result += pg_number_of_ones[word & 255]; + word >>= 8; + } + + return result; #endif /* HAVE__BUILTIN_POPCOUNT */ +} /* * pg_popcount64_slow @@ -216,7 +286,11 @@ pg_popcount64_slow(uint64 word) * TRY_POPCNT_FAST is not defined. The compiler should be able to inline * the slow versions here. */ - +int +pg_popcount32(uint32 word) +{ + return pg_popcount32_slow(word); +} int pg_popcount64(uint64 word) diff --git a/parser/src_port_snprintf.c b/parser/src_port_snprintf.c index d119ca05..1764554b 100644 --- a/parser/src_port_snprintf.c +++ b/parser/src_port_snprintf.c @@ -1,11 +1,11 @@ /*-------------------------------------------------------------------- * Symbols referenced in this file: - * - pg_vfprintf + * - pg_vsnprintf * - dopr * - pg_snprintf - * - pg_vsnprintf * - strchrnul * - dostr + * - flushbuffer * - find_arguments * - fmtint * - adjust_sign @@ -18,8 +18,8 @@ * - fmtptr * - fmtfloat * - dopr_outch - * - flushbuffer * - pg_fprintf + * - pg_vfprintf * - pg_sprintf * - pg_vsprintf * - pg_printf diff --git a/parser/src_port_strlcpy.c b/parser/src_port_strlcpy.c new file mode 100644 index 00000000..e19a9d4d --- /dev/null +++ b/parser/src_port_strlcpy.c @@ -0,0 +1,79 @@ +/*-------------------------------------------------------------------- + * Symbols referenced in this file: + * - strlcpy + *-------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * + * strlcpy.c + * strncpy done right + * + * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group + * + * + * IDENTIFICATION + * src/port/strlcpy.c + * + * This file was taken from OpenBSD and is used on platforms that don't + * provide strlcpy(). The OpenBSD copyright terms follow. + *------------------------------------------------------------------------- + */ + +/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */ + +/* + * Copyright (c) 1998 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "c.h" +#if HAVE_DECL_STRLCPY == 0 + + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + * Function creation history: http://www.gratisoft.us/todd/papers/strlcpy.html + */ +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0) + { + while (--n != 0) + { + if ((*d++ = *s++) == '\0') + break; + } + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) + { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return (s - src - 1); /* count does not include NUL */ +} +#endif // HAVE_DECL_STRLCPY == 0 diff --git a/parser/src_port_strnlen.c b/parser/src_port_strnlen.c deleted file mode 100644 index 477436af..00000000 --- a/parser/src_port_strnlen.c +++ /dev/null @@ -1,39 +0,0 @@ -/*-------------------------------------------------------------------- - * Symbols referenced in this file: - * - strnlen - *-------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------- - * - * strnlen.c - * Fallback implementation of strnlen(). - * - * - * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * IDENTIFICATION - * src/port/strnlen.c - * - *------------------------------------------------------------------------- - */ - -#include "c.h" - -/* - * Implementation of posix' strnlen for systems where it's not available. - * - * Returns the number of characters before a null-byte in the string pointed - * to by str, unless there's no null-byte before maxlen. In the latter case - * maxlen is returned. - */ -size_t -strnlen(const char *str, size_t maxlen) -{ - const char *p = str; - - while (maxlen-- > 0 && *p) - p++; - return p - str; -} diff --git a/pg_query.go b/pg_query.go index 8fca99db..fc9e6372 100644 --- a/pg_query.go +++ b/pg_query.go @@ -1,5 +1,5 @@ -//go:build cgo && !windows -// +build cgo,!windows +//go:build cgo +// +build cgo package pg_query diff --git a/pg_query.pb.go b/pg_query.pb.go index 07a816b0..4a323dd2 100644 --- a/pg_query.pb.go +++ b/pg_query.pb.go @@ -17988,7 +17988,7 @@ type RTEPermissionInfo struct { Relid uint32 `protobuf:"varint,1,opt,name=relid,proto3" json:"relid,omitempty"` Inh bool `protobuf:"varint,2,opt,name=inh,proto3" json:"inh,omitempty"` - RequiredPerms int64 `protobuf:"varint,3,opt,name=required_perms,json=requiredPerms,proto3" json:"required_perms,omitempty"` + RequiredPerms uint64 `protobuf:"varint,3,opt,name=required_perms,json=requiredPerms,proto3" json:"required_perms,omitempty"` CheckAsUser uint32 `protobuf:"varint,4,opt,name=check_as_user,json=checkAsUser,proto3" json:"check_as_user,omitempty"` SelectedCols []uint64 `protobuf:"varint,5,rep,packed,name=selected_cols,json=selectedCols,proto3" json:"selected_cols,omitempty"` InsertedCols []uint64 `protobuf:"varint,6,rep,packed,name=inserted_cols,json=insertedCols,proto3" json:"inserted_cols,omitempty"` @@ -18041,7 +18041,7 @@ func (x *RTEPermissionInfo) GetInh() bool { return false } -func (x *RTEPermissionInfo) GetRequiredPerms() int64 { +func (x *RTEPermissionInfo) GetRequiredPerms() uint64 { if x != nil { return x.RequiredPerms } @@ -32170,7 +32170,7 @@ var file_pg_query_proto_rawDesc = []byte{ 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x72, 0x65, 0x6c, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x6e, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x69, 0x6e, 0x68, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x72, - 0x6d, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, + 0x6d, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x65, 0x72, 0x6d, 0x73, 0x12, 0x22, 0x0a, 0x0d, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x73, 0x55, 0x73, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x73,