From 95e00fd2c3c63599323b587d6473fc9a303be8ab Mon Sep 17 00:00:00 2001 From: naisila Date: Sun, 7 Dec 2025 21:52:54 +0300 Subject: [PATCH] Remove pg_version_compat.h '>= PGVERSION_16' entries --- src/backend/columnar/columnar_customscan.c | 7 +- src/backend/columnar/columnar_metadata.c | 14 +- src/backend/columnar/columnar_reader.c | 3 +- src/backend/columnar/columnar_storage.c | 4 +- src/backend/columnar/columnar_tableam.c | 22 +-- src/backend/columnar/columnar_writer.c | 2 +- src/backend/columnar/write_state_management.c | 4 +- src/backend/distributed/commands/domain.c | 3 +- src/backend/distributed/commands/role.c | 2 +- src/backend/distributed/commands/truncate.c | 2 +- src/backend/distributed/commands/type.c | 7 +- .../distributed/metadata/metadata_sync.c | 2 +- .../metadata/pg_get_object_address_13_14_15.c | 4 +- .../distributed/operations/shard_rebalancer.c | 2 +- .../planner/query_colocation_checker.c | 2 +- src/backend/distributed/shared_library_init.c | 4 +- .../transaction/transaction_management.c | 1 + .../distributed/utils/function_utils.c | 3 +- .../worker/worker_create_or_replace.c | 3 +- src/include/distributed/errormessage.h | 2 +- src/include/pg_version_compat.h | 172 ------------------ 21 files changed, 41 insertions(+), 224 deletions(-) diff --git a/src/backend/columnar/columnar_customscan.c b/src/backend/columnar/columnar_customscan.c index 1359a25ee..b8a051ace 100644 --- a/src/backend/columnar/columnar_customscan.c +++ b/src/backend/columnar/columnar_customscan.c @@ -42,6 +42,7 @@ #include "parser/parse_relation.h" #include "parser/parsetree.h" #include "utils/builtins.h" +#include "utils/guc.h" #include "utils/lsyscache.h" #include "utils/relcache.h" #include "utils/ruleutils.h" @@ -547,7 +548,7 @@ ColumnarIndexScanAdditionalCost(PlannerInfo *root, RelOptInfo *rel, * "anti-correlated" (-1) since both help us avoiding from reading the * same stripe again and again. */ - double absIndexCorrelation = float_abs(indexCorrelation); + double absIndexCorrelation = fabs(indexCorrelation); /* * To estimate the number of stripes that we need to read, we do linear @@ -666,7 +667,7 @@ CheckVarStats(PlannerInfo *root, Var *var, Oid sortop, float4 *absVarCorrelation * If the Var is not highly correlated, then the chunk's min/max bounds * will be nearly useless. */ - if (float_abs(varCorrelation) < ColumnarQualPushdownCorrelationThreshold) + if (fabs(varCorrelation) < ColumnarQualPushdownCorrelationThreshold) { if (absVarCorrelation) { @@ -674,7 +675,7 @@ CheckVarStats(PlannerInfo *root, Var *var, Oid sortop, float4 *absVarCorrelation * Report absVarCorrelation if caller wants to know why given * var is rejected. */ - *absVarCorrelation = float_abs(varCorrelation); + *absVarCorrelation = fabs(varCorrelation); } return false; } diff --git a/src/backend/columnar/columnar_metadata.c b/src/backend/columnar/columnar_metadata.c index 76714a382..dc9f90c3d 100644 --- a/src/backend/columnar/columnar_metadata.c +++ b/src/backend/columnar/columnar_metadata.c @@ -726,7 +726,7 @@ ReadStripeSkipList(Relation rel, uint64 stripe, ScanKeyData scanKey[2]; uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel), - RelationPhysicalIdentifier_compat(rel)); + rel->rd_locator); Oid columnarChunkOid = ColumnarChunkRelationId(); Relation columnarChunk = table_open(columnarChunkOid, AccessShareLock); @@ -1273,7 +1273,7 @@ List * StripesForRelfilelocator(Relation rel) { uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel), - RelationPhysicalIdentifier_compat(rel)); + rel->rd_locator); /* * PG18 requires snapshot to be active or registered before it's used @@ -1305,7 +1305,7 @@ uint64 GetHighestUsedAddress(Relation rel) { uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel), - RelationPhysicalIdentifier_compat(rel)); + rel->rd_locator); uint64 highestUsedAddress = 0; uint64 highestUsedId = 0; @@ -1326,10 +1326,8 @@ GetHighestUsedAddress(Relation rel) Oid ColumnarRelationId(Oid relid, RelFileLocator relfilelocator) { - return OidIsValid(relid) ? relid : RelidByRelfilenumber(RelationTablespace_compat( - relfilelocator), - RelationPhysicalIdentifierNumber_compat( - relfilelocator)); + return OidIsValid(relid) ? relid : RelidByRelfilenumber(relfilelocator.spcOid, + relfilelocator.relNumber); } @@ -1620,7 +1618,7 @@ DeleteMetadataRows(Relation rel) } uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel), - RelationPhysicalIdentifier_compat(rel)); + rel->rd_locator); DeleteStorageFromColumnarMetadataTable(ColumnarStripeRelationId(), Anum_columnar_stripe_storageid, diff --git a/src/backend/columnar/columnar_reader.c b/src/backend/columnar/columnar_reader.c index 17c4061f1..573bed39e 100644 --- a/src/backend/columnar/columnar_reader.c +++ b/src/backend/columnar/columnar_reader.c @@ -255,8 +255,7 @@ ColumnarReadFlushPendingWrites(ColumnarReadState *readState) { Assert(!readState->snapshotRegisteredByUs); - RelFileNumber relfilenumber = RelationPhysicalIdentifierNumber_compat( - RelationPhysicalIdentifier_compat(readState->relation)); + RelFileNumber relfilenumber = readState->relation->rd_locator.relNumber; FlushWriteStateForRelfilenumber(relfilenumber, GetCurrentSubTransactionId()); if (readState->snapshot == InvalidSnapshot || !IsMVCCSnapshot(readState->snapshot)) diff --git a/src/backend/columnar/columnar_storage.c b/src/backend/columnar/columnar_storage.c index 56d4df798..caa6f5a68 100644 --- a/src/backend/columnar/columnar_storage.c +++ b/src/backend/columnar/columnar_storage.c @@ -188,7 +188,7 @@ ColumnarStorageInit(SMgrRelation srel, uint64 storageId) (char *) &metapage, sizeof(ColumnarMetapage)); phdr->pd_lower += sizeof(ColumnarMetapage); - log_newpage(RelationPhysicalIdentifierBackend_compat(&srel), MAIN_FORKNUM, + log_newpage(&srel->smgr_rlocator.locator, MAIN_FORKNUM, COLUMNAR_METAPAGE_BLOCKNO, page, true); PageSetChecksumInplace(page, COLUMNAR_METAPAGE_BLOCKNO); smgrextend(srel, MAIN_FORKNUM, COLUMNAR_METAPAGE_BLOCKNO, page, true); @@ -196,7 +196,7 @@ ColumnarStorageInit(SMgrRelation srel, uint64 storageId) /* write empty page */ PageInit(page, BLCKSZ, 0); - log_newpage(RelationPhysicalIdentifierBackend_compat(&srel), MAIN_FORKNUM, + log_newpage(&srel->smgr_rlocator.locator, MAIN_FORKNUM, COLUMNAR_EMPTY_BLOCKNO, page, true); PageSetChecksumInplace(page, COLUMNAR_EMPTY_BLOCKNO); smgrextend(srel, MAIN_FORKNUM, COLUMNAR_EMPTY_BLOCKNO, page, true); diff --git a/src/backend/columnar/columnar_tableam.c b/src/backend/columnar/columnar_tableam.c index 53b3e9069..7162d18aa 100644 --- a/src/backend/columnar/columnar_tableam.c +++ b/src/backend/columnar/columnar_tableam.c @@ -208,8 +208,7 @@ columnar_beginscan_extended(Relation relation, Snapshot snapshot, uint32 flags, Bitmapset *attr_needed, List *scanQual) { CheckCitusColumnarVersion(ERROR); - RelFileNumber relfilenumber = RelationPhysicalIdentifierNumber_compat( - RelationPhysicalIdentifier_compat(relation)); + RelFileNumber relfilenumber = relation->rd_locator.relNumber; /* * A memory context to use for scan-wide data, including the lazily @@ -435,8 +434,7 @@ columnar_index_fetch_begin(Relation rel) { CheckCitusColumnarVersion(ERROR); - RelFileNumber relfilenumber = RelationPhysicalIdentifierNumber_compat( - RelationPhysicalIdentifier_compat(rel)); + RelFileNumber relfilenumber = rel->rd_locator.relNumber; if (PendingWritesInUpperTransactions(relfilenumber, GetCurrentSubTransactionId())) { /* XXX: maybe we can just flush the data and continue */ @@ -865,11 +863,9 @@ columnar_relation_set_new_filelocator(Relation rel, * state. If they are equal, this is a new relation object and we don't * need to clean anything. */ - if (RelationPhysicalIdentifierNumber_compat(RelationPhysicalIdentifier_compat(rel)) != - RelationPhysicalIdentifierNumberPtr_compat(newrlocator)) + if (rel->rd_locator.relNumber != newrlocator->relNumber) { - MarkRelfilenumberDropped(RelationPhysicalIdentifierNumber_compat( - RelationPhysicalIdentifier_compat(rel)), + MarkRelfilenumberDropped(rel->rd_locator.relNumber, GetCurrentSubTransactionId()); DeleteMetadataRows(rel); @@ -892,9 +888,9 @@ static void columnar_relation_nontransactional_truncate(Relation rel) { CheckCitusColumnarVersion(ERROR); - RelFileLocator relfilelocator = RelationPhysicalIdentifier_compat(rel); + RelFileLocator relfilelocator = rel->rd_locator; - NonTransactionDropWriteState(RelationPhysicalIdentifierNumber_compat(relfilelocator)); + NonTransactionDropWriteState(relfilelocator.relNumber); /* Delete old relfilenode metadata */ DeleteMetadataRows(rel); @@ -1843,7 +1839,7 @@ TupleSortSkipSmallerItemPointers(Tuplesortstate *tupleSort, ItemPointer targetIt Datum *abbrev = NULL; Datum tsDatum; bool tsDatumIsNull; - if (!tuplesort_getdatum_compat(tupleSort, forwardDirection, false, + if (!tuplesort_getdatum(tupleSort, forwardDirection, false, &tsDatum, &tsDatumIsNull, abbrev)) { ItemPointerSetInvalid(&tsItemPointerData); @@ -2085,12 +2081,12 @@ ColumnarTableDropHook(Oid relid) * tableam tables storage is managed by postgres. */ Relation rel = table_open(relid, AccessExclusiveLock); - RelFileLocator relfilelocator = RelationPhysicalIdentifier_compat(rel); + RelFileLocator relfilelocator = rel->rd_locator; DeleteMetadataRows(rel); DeleteColumnarTableOptions(rel->rd_id, true); - MarkRelfilenumberDropped(RelationPhysicalIdentifierNumber_compat(relfilelocator), + MarkRelfilenumberDropped(relfilelocator.relNumber, GetCurrentSubTransactionId()); /* keep the lock since we did physical changes to the relation */ diff --git a/src/backend/columnar/columnar_writer.c b/src/backend/columnar/columnar_writer.c index a48b1e02e..f86713cb8 100644 --- a/src/backend/columnar/columnar_writer.c +++ b/src/backend/columnar/columnar_writer.c @@ -99,7 +99,7 @@ ColumnarBeginWrite(Relation rel, ColumnarOptions options, TupleDesc tupleDescriptor) { - RelFileLocator relfilelocator = RelationPhysicalIdentifier_compat(rel); + RelFileLocator relfilelocator = rel->rd_locator; /* get comparison function pointers for each of the columns */ uint32 columnCount = tupleDescriptor->natts; diff --git a/src/backend/columnar/write_state_management.c b/src/backend/columnar/write_state_management.c index a4e0240d6..3d9ae9006 100644 --- a/src/backend/columnar/write_state_management.c +++ b/src/backend/columnar/write_state_management.c @@ -146,9 +146,7 @@ columnar_init_write_state(Relation relation, TupleDesc tupdesc, } WriteStateMapEntry *hashEntry = hash_search(WriteStateMap, - &RelationPhysicalIdentifierNumber_compat( - RelationPhysicalIdentifier_compat( - relation)), + &(relation->rd_locator.relNumber), HASH_ENTER, &found); if (!found) { diff --git a/src/backend/distributed/commands/domain.c b/src/backend/distributed/commands/domain.c index d62428ce4..0f09d8655 100644 --- a/src/backend/distributed/commands/domain.c +++ b/src/backend/distributed/commands/domain.c @@ -64,8 +64,7 @@ CreateDomainStmt * RecreateDomainStmt(Oid domainOid) { CreateDomainStmt *stmt = makeNode(CreateDomainStmt); - stmt->domainname = stringToQualifiedNameList_compat(format_type_be_qualified( - domainOid)); + stmt->domainname = stringToQualifiedNameList(format_type_be_qualified(domainOid), NULL); HeapTuple tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(domainOid)); if (!HeapTupleIsValid(tup)) diff --git a/src/backend/distributed/commands/role.c b/src/backend/distributed/commands/role.c index 98f6ce141..173bcd48e 100644 --- a/src/backend/distributed/commands/role.c +++ b/src/backend/distributed/commands/role.c @@ -734,7 +734,7 @@ MakeSetStatementArguments(char *configurationName, char *configurationValue) * using this function */ int gucCount = 0; - struct config_generic **gucVariables = get_guc_variables_compat(&gucCount); + struct config_generic **gucVariables = get_guc_variables(&gucCount); struct config_generic **matchingConfig = (struct config_generic **) SafeBsearch((void *) &key, diff --git a/src/backend/distributed/commands/truncate.c b/src/backend/distributed/commands/truncate.c index 46cf5e602..f71f779a5 100644 --- a/src/backend/distributed/commands/truncate.c +++ b/src/backend/distributed/commands/truncate.c @@ -184,7 +184,7 @@ truncate_local_data_after_distributing_table(PG_FUNCTION_ARGS) TruncateStmt *truncateStmt = makeNode(TruncateStmt); char *relationName = generate_qualified_relation_name(relationId); - List *names = stringToQualifiedNameList_compat(relationName); + List *names = stringToQualifiedNameList(relationName, NULL); truncateStmt->relations = list_make1(makeRangeVarFromNameList(names)); truncateStmt->restart_seqs = false; truncateStmt->behavior = DROP_CASCADE; diff --git a/src/backend/distributed/commands/type.c b/src/backend/distributed/commands/type.c index b1e573638..f1fd47305 100644 --- a/src/backend/distributed/commands/type.c +++ b/src/backend/distributed/commands/type.c @@ -189,7 +189,7 @@ RecreateCompositeTypeStmt(Oid typeOid) Assert(get_typtype(typeOid) == TYPTYPE_COMPOSITE); CompositeTypeStmt *stmt = makeNode(CompositeTypeStmt); - List *names = stringToQualifiedNameList_compat(format_type_be_qualified(typeOid)); + List *names = stringToQualifiedNameList(format_type_be_qualified(typeOid), NULL); stmt->typevar = makeRangeVarFromNameList(names); stmt->coldeflist = CompositeTypeColumnDefList(typeOid); @@ -254,7 +254,7 @@ RecreateEnumStmt(Oid typeOid) Assert(get_typtype(typeOid) == TYPTYPE_ENUM); CreateEnumStmt *stmt = makeNode(CreateEnumStmt); - stmt->typeName = stringToQualifiedNameList_compat(format_type_be_qualified(typeOid)); + stmt->typeName = stringToQualifiedNameList(format_type_be_qualified(typeOid), NULL); stmt->vals = EnumValsList(typeOid); return stmt; @@ -567,8 +567,7 @@ CreateTypeDDLCommandsIdempotent(const ObjectAddress *typeAddress) char * GenerateBackupNameForTypeCollision(const ObjectAddress *address) { - List *names = stringToQualifiedNameList_compat(format_type_be_qualified( - address->objectId)); + List *names = stringToQualifiedNameList(format_type_be_qualified(address->objectId), NULL); RangeVar *rel = makeRangeVarFromNameList(names); char *newName = palloc0(NAMEDATALEN); diff --git a/src/backend/distributed/metadata/metadata_sync.c b/src/backend/distributed/metadata/metadata_sync.c index 391444856..7de68af5d 100644 --- a/src/backend/distributed/metadata/metadata_sync.c +++ b/src/backend/distributed/metadata/metadata_sync.c @@ -3195,7 +3195,7 @@ SignalMetadataSyncDaemon(Oid database, int sig) int backendCount = pgstat_fetch_stat_numbackends(); for (int backend = 1; backend <= backendCount; backend++) { - LocalPgBackendStatus *localBeEntry = pgstat_fetch_stat_local_beentry(backend); + LocalPgBackendStatus *localBeEntry = pgstat_get_local_beentry_by_index(backend); if (!localBeEntry) { continue; diff --git a/src/backend/distributed/metadata/pg_get_object_address_13_14_15.c b/src/backend/distributed/metadata/pg_get_object_address_13_14_15.c index bd9b84e81..5e54b0bf5 100644 --- a/src/backend/distributed/metadata/pg_get_object_address_13_14_15.c +++ b/src/backend/distributed/metadata/pg_get_object_address_13_14_15.c @@ -96,7 +96,7 @@ PgGetObjectAddress(char *ttype, ArrayType *namearr, ArrayType *argsarr) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("name or argument lists may not contain nulls"))); } - typename = typeStringToTypeName_compat(TextDatumGetCString(elems[0]), NULL); + typename = typeStringToTypeName(TextDatumGetCString(elems[0]), NULL); } else if (type == OBJECT_LARGEOBJECT) { @@ -163,7 +163,7 @@ PgGetObjectAddress(char *ttype, ArrayType *namearr, ArrayType *argsarr) errmsg("name or argument lists may not contain nulls"))); } args = lappend(args, - typeStringToTypeName_compat(TextDatumGetCString(elems[i]), + typeStringToTypeName(TextDatumGetCString(elems[i]), NULL)); } } diff --git a/src/backend/distributed/operations/shard_rebalancer.c b/src/backend/distributed/operations/shard_rebalancer.c index 899bd7b54..5d1a5829d 100644 --- a/src/backend/distributed/operations/shard_rebalancer.c +++ b/src/backend/distributed/operations/shard_rebalancer.c @@ -2476,7 +2476,7 @@ GetSetCommandListForNewConnections(void) List *commandList = NIL; int gucCount = 0; - struct config_generic **guc_vars = get_guc_variables_compat(&gucCount); + struct config_generic **guc_vars = get_guc_variables(&gucCount); for (int gucIndex = 0; gucIndex < gucCount; gucIndex++) { diff --git a/src/backend/distributed/planner/query_colocation_checker.c b/src/backend/distributed/planner/query_colocation_checker.c index 4dcb0362c..98dd0146a 100644 --- a/src/backend/distributed/planner/query_colocation_checker.c +++ b/src/backend/distributed/planner/query_colocation_checker.c @@ -129,7 +129,7 @@ static RangeTblEntry * AnchorRte(Query *subquery) { FromExpr *joinTree = subquery->jointree; - Relids joinRelIds = get_relids_in_jointree_compat((Node *) joinTree, false, false); + Relids joinRelIds = get_relids_in_jointree((Node *) joinTree, false, false); int currentRTEIndex = -1; RangeTblEntry *anchorRangeTblEntry = NULL; diff --git a/src/backend/distributed/shared_library_init.c b/src/backend/distributed/shared_library_init.c index ac8b0a7d6..08cbd1099 100644 --- a/src/backend/distributed/shared_library_init.c +++ b/src/backend/distributed/shared_library_init.c @@ -2803,7 +2803,7 @@ static void OverridePostgresConfigProperties(void) { int gucCount = 0; - struct config_generic **guc_vars = get_guc_variables_compat(&gucCount); + struct config_generic **guc_vars = get_guc_variables(&gucCount); for (int gucIndex = 0; gucIndex < gucCount; gucIndex++) { @@ -2982,7 +2982,7 @@ ShowShardsForAppNamePrefixesCheckHook(char **newval, void **extra, GucSource sou } char *prefixAscii = pstrdup(appNamePrefix); - pg_clean_ascii_compat(prefixAscii, 0); + pg_clean_ascii(prefixAscii, 0); if (strcmp(prefixAscii, appNamePrefix) != 0) { diff --git a/src/backend/distributed/transaction/transaction_management.c b/src/backend/distributed/transaction/transaction_management.c index 3d1157815..bca0663a8 100644 --- a/src/backend/distributed/transaction/transaction_management.c +++ b/src/backend/distributed/transaction/transaction_management.c @@ -25,6 +25,7 @@ #include "storage/fd.h" #include "utils/datum.h" #include "utils/guc.h" +#include "utils/guc_tables.h" #include "utils/hsearch.h" #include "utils/memutils.h" diff --git a/src/backend/distributed/utils/function_utils.c b/src/backend/distributed/utils/function_utils.c index 0770b8cb9..f5c2f82e9 100644 --- a/src/backend/distributed/utils/function_utils.c +++ b/src/backend/distributed/utils/function_utils.c @@ -42,8 +42,7 @@ FunctionOidExtended(const char *schemaName, const char *functionName, int argume bool missingOK) { char *qualifiedFunctionName = quote_qualified_identifier(schemaName, functionName); - List *qualifiedFunctionNameList = stringToQualifiedNameList_compat( - qualifiedFunctionName); + List *qualifiedFunctionNameList = stringToQualifiedNameList(qualifiedFunctionName, NULL); List *argumentList = NIL; const bool findVariadics = false; const bool findDefaults = false; diff --git a/src/backend/distributed/worker/worker_create_or_replace.c b/src/backend/distributed/worker/worker_create_or_replace.c index 451649969..64824dd9d 100644 --- a/src/backend/distributed/worker/worker_create_or_replace.c +++ b/src/backend/distributed/worker/worker_create_or_replace.c @@ -526,8 +526,7 @@ CreateRenameTypeStmt(const ObjectAddress *address, char *newName) RenameStmt *stmt = makeNode(RenameStmt); stmt->renameType = OBJECT_TYPE; - stmt->object = (Node *) stringToQualifiedNameList_compat(format_type_be_qualified( - address->objectId)); + stmt->object = (Node *) stringToQualifiedNameList(format_type_be_qualified(address->objectId), NULL); stmt->newname = newName; diff --git a/src/include/distributed/errormessage.h b/src/include/distributed/errormessage.h index 7a38d513c..3cdb3d056 100644 --- a/src/include/distributed/errormessage.h +++ b/src/include/distributed/errormessage.h @@ -38,7 +38,7 @@ typedef struct DeferredErrorMessage */ #define DeferredError(code, message, detail, hint) \ DeferredErrorInternal(code, message, detail, hint, __FILE__, __LINE__, \ - PG_FUNCNAME_MACRO) + __func__) DeferredErrorMessage * DeferredErrorInternal(int code, const char *message, const char *detail, const char *hint, diff --git a/src/include/pg_version_compat.h b/src/include/pg_version_compat.h index a30925e4e..8e4757c6b 100644 --- a/src/include/pg_version_compat.h +++ b/src/include/pg_version_compat.h @@ -461,178 +461,6 @@ getStxstattarget_compat(HeapTuple tup) #endif -#if PG_VERSION_NUM >= PG_VERSION_16 - -#include "utils/guc_tables.h" - -#define pg_clean_ascii_compat(a, b) pg_clean_ascii(a, b) - -#define RelationPhysicalIdentifier_compat(a) ((a)->rd_locator) -#define RelationTablespace_compat(a) (a.spcOid) -#define RelationPhysicalIdentifierNumber_compat(a) (a.relNumber) -#define RelationPhysicalIdentifierNumberPtr_compat(a) (a->relNumber) -#define RelationPhysicalIdentifierBackend_compat(a) (a->smgr_rlocator.locator) - -#define float_abs(a) fabs(a) - -#define tuplesort_getdatum_compat(a, b, c, d, e, f) tuplesort_getdatum(a, b, c, d, e, f) - -static inline struct config_generic ** -get_guc_variables_compat(int *gucCount) -{ - return get_guc_variables(gucCount); -} - - -#define PG_FUNCNAME_MACRO __func__ - -#define stringToQualifiedNameList_compat(a) stringToQualifiedNameList(a, NULL) -#define typeStringToTypeName_compat(a, b) typeStringToTypeName(a, b) - -#define get_relids_in_jointree_compat(a, b, c) get_relids_in_jointree(a, b, c) - -#define object_ownercheck(a, b, c) object_ownercheck(a, b, c) -#define object_aclcheck(a, b, c, d) object_aclcheck(a, b, c, d) - -#define pgstat_fetch_stat_local_beentry(a) pgstat_get_local_beentry_by_index(a) - -#define have_createdb_privilege() have_createdb_privilege() - -#else - -#include "miscadmin.h" - -#include "catalog/pg_authid.h" -#include "catalog/pg_class_d.h" -#include "catalog/pg_database_d.h" -#include "catalog/pg_namespace.h" -#include "catalog/pg_proc_d.h" -#include "storage/relfilenode.h" -#include "utils/guc.h" -#include "utils/guc_tables.h" -#include "utils/syscache.h" - -#define pg_clean_ascii_compat(a, b) pg_clean_ascii(a) - -#define RelationPhysicalIdentifier_compat(a) ((a)->rd_node) -#define RelationTablespace_compat(a) (a.spcNode) -#define RelationPhysicalIdentifierNumber_compat(a) (a.relNode) -#define RelationPhysicalIdentifierNumberPtr_compat(a) (a->relNode) -#define RelationPhysicalIdentifierBackend_compat(a) (a->smgr_rnode.node) -typedef RelFileNode RelFileLocator; -typedef Oid RelFileNumber; -#define RelidByRelfilenumber(a, b) RelidByRelfilenode(a, b) - -#define float_abs(a) Abs(a) - -#define tuplesort_getdatum_compat(a, b, c, d, e, f) tuplesort_getdatum(a, b, d, e, f) - -static inline struct config_generic ** -get_guc_variables_compat(int *gucCount) -{ - *gucCount = GetNumConfigOptions(); - return get_guc_variables(); -} - - -#define stringToQualifiedNameList_compat(a) stringToQualifiedNameList(a) -#define typeStringToTypeName_compat(a, b) typeStringToTypeName(a) - -#define get_relids_in_jointree_compat(a, b, c) get_relids_in_jointree(a, b) - -static inline bool -object_ownercheck(Oid classid, Oid objectid, Oid roleid) -{ - switch (classid) - { - case RelationRelationId: - { - return pg_class_ownercheck(objectid, roleid); - } - - case NamespaceRelationId: - { - return pg_namespace_ownercheck(objectid, roleid); - } - - case ProcedureRelationId: - { - return pg_proc_ownercheck(objectid, roleid); - } - - case DatabaseRelationId: - { - return pg_database_ownercheck(objectid, roleid); - } - - default: - { - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Missing classid:%d", - classid))); - } - } -} - - -static inline AclResult -object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode) -{ - switch (classid) - { - case NamespaceRelationId: - { - return pg_namespace_aclcheck(objectid, roleid, mode); - } - - case ProcedureRelationId: - { - return pg_proc_aclcheck(objectid, roleid, mode); - } - - default: - { - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Missing classid:%d", - classid))); - } - } -} - - -static inline bool -have_createdb_privilege(void) -{ - bool result = false; - HeapTuple utup; - - /* Superusers can always do everything */ - if (superuser()) - { - return true; - } - - utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetUserId())); - if (HeapTupleIsValid(utup)) - { - result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreatedb; - ReleaseSysCache(utup); - } - return result; -} - - -typedef bool TU_UpdateIndexes; - -/* - * we define RTEPermissionInfo for PG16 compatibility - * There are some functions that need to include RTEPermissionInfo in their signature - * for PG14/PG15 we pass a NULL argument in these functions - */ -typedef RangeTblEntry RTEPermissionInfo; - -#endif - #define SetListCellPtr(a, b) ((a)->ptr_value = (b)) #define RangeTableEntryFromNSItem(a) ((a)->p_rte) #define fcGetArgValue(fc, n) ((fc)->args[n].value)