diff --git a/src/backend/distributed/commands/policy.c b/src/backend/distributed/commands/policy.c index afe539565..3ec45bc13 100644 --- a/src/backend/distributed/commands/policy.c +++ b/src/backend/distributed/commands/policy.c @@ -69,14 +69,6 @@ ErrorIfUnsupportedPolicy(Relation relation) } -/* placeholder for ErrorIfUnsupportedPolicyExpr */ -void -ErrorIfUnsupportedPolicyExpr(Node *expr) -{ - /* placeholder for future implementation */ -} - - /* placeholder for PreprocessDropPolicyStmt */ List * PreprocessDropPolicyStmt(Node *node, const char *queryString) diff --git a/src/backend/distributed/connection/connection_management.c b/src/backend/distributed/connection/connection_management.c index c25c0a67b..2e6bce06b 100644 --- a/src/backend/distributed/connection/connection_management.c +++ b/src/backend/distributed/connection/connection_management.c @@ -232,41 +232,6 @@ GetNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port, } -/* - * StartWorkerListConnections starts connections to the given worker list and - * returns them as a MultiConnection list. - */ -List * -StartWorkerListConnections(List *workerNodeList, uint32 flags, const char *user, - const char *database) -{ - List *connectionList = NIL; - - WorkerNode *workerNode = NULL; - foreach_ptr(workerNode, workerNodeList) - { - const char *nodeName = workerNode->workerName; - int nodePort = workerNode->workerPort; - int connectionFlags = 0; - - MultiConnection *connection = StartNodeUserDatabaseConnection(connectionFlags, - nodeName, nodePort, - user, database); - - /* - * connection can only be NULL for optional connections, which we don't - * support in this codepath. - */ - Assert((flags & OPTIONAL_CONNECTION) == 0); - Assert(connection != NULL); - - connectionList = lappend(connectionList, connection); - } - - return connectionList; -} - - /* * StartNodeUserDatabaseConnection() initiates a connection to a remote node. * diff --git a/src/backend/distributed/connection/placement_connection.c b/src/backend/distributed/connection/placement_connection.c index 90d6f24d9..74c42d95d 100644 --- a/src/backend/distributed/connection/placement_connection.c +++ b/src/backend/distributed/connection/placement_connection.c @@ -861,17 +861,6 @@ ConnectionModifiedPlacement(MultiConnection *connection) } -/* - * ConnectionUsedForAnyPlacements returns true if the connection - * has not been associated with any placement. - */ -bool -ConnectionUsedForAnyPlacements(MultiConnection *connection) -{ - return !dlist_is_empty(&connection->referencedPlacements); -} - - /* * AssociatePlacementWithShard records shard->placement relation in * ConnectionShardHash. diff --git a/src/backend/distributed/connection/remote_commands.c b/src/backend/distributed/connection/remote_commands.c index 84d3d4838..da484a13b 100644 --- a/src/backend/distributed/connection/remote_commands.c +++ b/src/backend/distributed/connection/remote_commands.c @@ -230,35 +230,6 @@ ClearResultsIfReady(MultiConnection *connection) } -/* - * SqlStateMatchesCategory returns true if the given sql state (which may be - * NULL if unknown) is in the given error category. Note that we use - * ERRCODE_TO_CATEGORY macro to determine error category of the sql state and - * expect the caller to use the same macro for the error category. - */ -bool -SqlStateMatchesCategory(char *sqlStateString, int category) -{ - bool sqlStateMatchesCategory = false; - - if (sqlStateString == NULL) - { - return false; - } - - int sqlState = MAKE_SQLSTATE(sqlStateString[0], sqlStateString[1], sqlStateString[2], - sqlStateString[3], sqlStateString[4]); - - int sqlStateCategory = ERRCODE_TO_CATEGORY(sqlState); - if (sqlStateCategory == category) - { - sqlStateMatchesCategory = true; - } - - return sqlStateMatchesCategory; -} - - /* report errors & warnings */ /* diff --git a/src/backend/distributed/deparser/citus_ruleutils.c b/src/backend/distributed/deparser/citus_ruleutils.c index 73efcd67d..1e3884bd2 100644 --- a/src/backend/distributed/deparser/citus_ruleutils.c +++ b/src/backend/distributed/deparser/citus_ruleutils.c @@ -72,7 +72,6 @@ static void deparse_index_columns(StringInfo buffer, List *indexParameterList, static void AppendOptionListToString(StringInfo stringData, List *options); static void AppendStorageParametersToString(StringInfo stringBuffer, List *optionList); -static const char * convert_aclright_to_string(int aclright); static void simple_quote_literal(StringInfo buf, const char *val); static char * flatten_reloptions(Oid relid); @@ -904,138 +903,6 @@ pg_get_indexclusterdef_string(Oid indexRelationId) } -/* - * pg_get_table_grants returns a list of sql statements which recreate the - * permissions for a specific table. - * - * This function is modeled after aclexplode(), don't change too heavily. - */ -List * -pg_get_table_grants(Oid relationId) -{ - /* *INDENT-OFF* */ - StringInfoData buffer; - List *defs = NIL; - bool isNull = false; - - Relation relation = relation_open(relationId, AccessShareLock); - char *relationName = generate_relation_name(relationId, NIL); - - initStringInfo(&buffer); - - /* lookup all table level grants */ - HeapTuple classTuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relationId)); - if (!HeapTupleIsValid(classTuple)) - { - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("relation with OID %u does not exist", - relationId))); - } - - Datum aclDatum = SysCacheGetAttr(RELOID, classTuple, Anum_pg_class_relacl, - &isNull); - - ReleaseSysCache(classTuple); - - if (!isNull) - { - - /* - * First revoke all default permissions, so we can start adding the - * exact permissions from the master. Note that we only do so if there - * are any actual grants; an empty grant set signals default - * permissions. - * - * Note: This doesn't work correctly if default permissions have been - * changed with ALTER DEFAULT PRIVILEGES - but that's hard to fix - * properly currently. - */ - appendStringInfo(&buffer, "REVOKE ALL ON %s FROM PUBLIC", - relationName); - defs = lappend(defs, pstrdup(buffer.data)); - resetStringInfo(&buffer); - - /* iterate through the acl datastructure, emit GRANTs */ - - Acl *acl = DatumGetAclP(aclDatum); - AclItem *aidat = ACL_DAT(acl); - - int offtype = -1; - int i = 0; - while (i < ACL_NUM(acl)) - { - AclItem *aidata = NULL; - AclMode priv_bit = 0; - - offtype++; - - if (offtype == N_ACL_RIGHTS) - { - offtype = 0; - i++; - if (i >= ACL_NUM(acl)) /* done */ - { - break; - } - } - - aidata = &aidat[i]; - priv_bit = 1 << offtype; - - if (ACLITEM_GET_PRIVS(*aidata) & priv_bit) - { - const char *roleName = NULL; - const char *withGrant = ""; - - if (aidata->ai_grantee != 0) - { - - HeapTuple htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aidata->ai_grantee)); - if (HeapTupleIsValid(htup)) - { - Form_pg_authid authForm = ((Form_pg_authid) GETSTRUCT(htup)); - - roleName = quote_identifier(NameStr(authForm->rolname)); - - ReleaseSysCache(htup); - } - else - { - elog(ERROR, "cache lookup failed for role %u", aidata->ai_grantee); - } - } - else - { - roleName = "PUBLIC"; - } - - if ((ACLITEM_GET_GOPTIONS(*aidata) & priv_bit) != 0) - { - withGrant = " WITH GRANT OPTION"; - } - - appendStringInfo(&buffer, "GRANT %s ON %s TO %s%s", - convert_aclright_to_string(priv_bit), - relationName, - roleName, - withGrant); - - defs = lappend(defs, pstrdup(buffer.data)); - - resetStringInfo(&buffer); - } - } - } - - resetStringInfo(&buffer); - - relation_close(relation, NoLock); - return defs; - /* *INDENT-ON* */ -} - - /* * generate_qualified_relation_name computes the schema-qualified name to display for a * relation specified by OID. @@ -1139,45 +1006,6 @@ AppendStorageParametersToString(StringInfo stringBuffer, List *optionList) } -/* copy of postgresql's function, which is static as well */ -static const char * -convert_aclright_to_string(int aclright) -{ - /* *INDENT-OFF* */ - switch (aclright) - { - case ACL_INSERT: - return "INSERT"; - case ACL_SELECT: - return "SELECT"; - case ACL_UPDATE: - return "UPDATE"; - case ACL_DELETE: - return "DELETE"; - case ACL_TRUNCATE: - return "TRUNCATE"; - case ACL_REFERENCES: - return "REFERENCES"; - case ACL_TRIGGER: - return "TRIGGER"; - case ACL_EXECUTE: - return "EXECUTE"; - case ACL_USAGE: - return "USAGE"; - case ACL_CREATE: - return "CREATE"; - case ACL_CREATE_TEMP: - return "TEMPORARY"; - case ACL_CONNECT: - return "CONNECT"; - default: - elog(ERROR, "unrecognized aclright: %d", aclright); - return NULL; - } - /* *INDENT-ON* */ -} - - /* * contain_nextval_expression_walker walks over expression tree and returns * true if it contains call to 'nextval' function. diff --git a/src/backend/distributed/deparser/format_collate.c b/src/backend/distributed/deparser/format_collate.c index 6ed1177bb..7e04efcf7 100644 --- a/src/backend/distributed/deparser/format_collate.c +++ b/src/backend/distributed/deparser/format_collate.c @@ -21,18 +21,6 @@ #include "distributed/deparser.h" -/* - * This version is for use within the backend in error messages, etc. - * One difference is that it will fail for an invalid collate. - * - * The result is always a palloc'd string. - */ -char * -FormatCollateBE(Oid collate_oid) -{ - return FormatCollateExtended(collate_oid, 0); -} - /* * This version returns a name that is always qualified. diff --git a/src/backend/distributed/deparser/objectaddress.c b/src/backend/distributed/deparser/objectaddress.c index a1ef82b0b..a9f1663bc 100644 --- a/src/backend/distributed/deparser/objectaddress.c +++ b/src/backend/distributed/deparser/objectaddress.c @@ -89,35 +89,3 @@ CreateExtensionStmtObjectAddress(Node *node, bool missing_ok) return address; } - - -/* - * AlterExtensionStmtObjectAddress finds the ObjectAddress for the extension described - * by the AlterExtensionStmt. If missing_ok is false, then this function throws an - * error if the extension is not created before. - * - * Never returns NULL, but the objid in the address could be invalid if missing_ok was set - * to true. - */ -ObjectAddress -AlterExtensionStmtObjectAddress(Node *node, bool missing_ok) -{ - AlterExtensionStmt *stmt = castNode(AlterExtensionStmt, node); - ObjectAddress address = { 0 }; - - const char *extensionName = stmt->extname; - - Oid extensionoid = get_extension_oid(extensionName, missing_ok); - - /* if we couldn't find the extension, error if missing_ok is false */ - if (!missing_ok && extensionoid == InvalidOid) - { - ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("extension \"%s\" does not exist", - extensionName))); - } - - ObjectAddressSet(address, ExtensionRelationId, extensionoid); - - return address; -} diff --git a/src/backend/distributed/executor/adaptive_executor.c b/src/backend/distributed/executor/adaptive_executor.c index d87be78d8..b5442dbab 100644 --- a/src/backend/distributed/executor/adaptive_executor.c +++ b/src/backend/distributed/executor/adaptive_executor.c @@ -926,24 +926,6 @@ ExecuteTaskListOutsideTransaction(RowModifyLevel modLevel, List *taskList, } -/* - * ExecuteTaskList is a proxy to ExecuteTaskListExtended() with defaults - * for some of the arguments. - */ -uint64 -ExecuteTaskList(RowModifyLevel modLevel, List *taskList, - int targetPoolSize, bool localExecutionSupported) -{ - ExecutionParams *executionParams = CreateBasicExecutionParams( - modLevel, taskList, targetPoolSize, localExecutionSupported - ); - executionParams->xactProperties = DecideTransactionPropertiesForTaskList( - modLevel, taskList, false); - - return ExecuteTaskListExtended(executionParams); -} - - /* * ExecuteTaskListIntoTupleStore is a proxy to ExecuteTaskListExtended() with defaults * for some of the arguments. diff --git a/src/backend/distributed/executor/multi_client_executor.c b/src/backend/distributed/executor/multi_client_executor.c index 26ef5384c..64edb2014 100644 --- a/src/backend/distributed/executor/multi_client_executor.c +++ b/src/backend/distributed/executor/multi_client_executor.c @@ -45,11 +45,6 @@ static MultiConnection *ClientConnectionArray[MAX_CONNECTION_COUNT]; static PostgresPollingStatusType ClientPollingStatusArray[MAX_CONNECTION_COUNT]; -/* Local functions forward declarations */ -static bool ClientConnectionReady(MultiConnection *connection, - PostgresPollingStatusType pollingStatus); - - /* AllocateConnectionId returns a connection id from the connection pool. */ static int32 AllocateConnectionId(void) @@ -121,118 +116,6 @@ MultiClientConnect(const char *nodeName, uint32 nodePort, const char *nodeDataba } -/* - * MultiClientConnectStart asynchronously tries to establish a connection. If it - * succeeds, it returns the connection id. Otherwise, it reports connection - * error and returns INVALID_CONNECTION_ID. - */ -int32 -MultiClientConnectStart(const char *nodeName, uint32 nodePort, const char *nodeDatabase, - const char *userName) -{ - int32 connectionId = AllocateConnectionId(); - int connectionFlags = FORCE_NEW_CONNECTION; /* no cached connections for now */ - - if (connectionId == INVALID_CONNECTION_ID) - { - ereport(WARNING, (errmsg("could not allocate connection in connection pool"))); - return connectionId; - } - - if (XactModificationLevel > XACT_MODIFICATION_NONE) - { - ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), - errmsg("cannot open new connections after the first modification " - "command within a transaction"))); - } - - /* prepare asynchronous request for worker node connection */ - MultiConnection *connection = StartNodeUserDatabaseConnection(connectionFlags, - nodeName, nodePort, - userName, nodeDatabase); - - /* - * connection can only be NULL for optional connections, which we don't - * support in this codepath. - */ - Assert((connectionFlags & OPTIONAL_CONNECTION) == 0); - Assert(connection != NULL); - ConnStatusType connStatusType = PQstatus(connection->pgConn); - - /* - * If prepared, we save the connection, and set its initial polling status - * to PGRES_POLLING_WRITING as specified in "Database Connection Control - * Functions" section of the PostgreSQL documentation. - */ - if (connStatusType != CONNECTION_BAD) - { - ClientConnectionArray[connectionId] = connection; - ClientPollingStatusArray[connectionId] = PGRES_POLLING_WRITING; - } - else - { - ReportConnectionError(connection, WARNING); - CloseConnection(connection); - - connectionId = INVALID_CONNECTION_ID; - } - - return connectionId; -} - - -/* MultiClientConnectPoll returns the status of client connection. */ -ConnectStatus -MultiClientConnectPoll(int32 connectionId) -{ - ConnectStatus connectStatus = CLIENT_INVALID_CONNECT; - - Assert(connectionId != INVALID_CONNECTION_ID); - MultiConnection *connection = ClientConnectionArray[connectionId]; - Assert(connection != NULL); - - PostgresPollingStatusType pollingStatus = ClientPollingStatusArray[connectionId]; - if (pollingStatus == PGRES_POLLING_OK) - { - connectStatus = CLIENT_CONNECTION_READY; - } - else if (pollingStatus == PGRES_POLLING_READING) - { - bool readReady = ClientConnectionReady(connection, PGRES_POLLING_READING); - if (readReady) - { - ClientPollingStatusArray[connectionId] = PQconnectPoll(connection->pgConn); - connectStatus = CLIENT_CONNECTION_BUSY; - } - else - { - connectStatus = CLIENT_CONNECTION_BUSY_READ; - } - } - else if (pollingStatus == PGRES_POLLING_WRITING) - { - bool writeReady = ClientConnectionReady(connection, PGRES_POLLING_WRITING); - if (writeReady) - { - ClientPollingStatusArray[connectionId] = PQconnectPoll(connection->pgConn); - connectStatus = CLIENT_CONNECTION_BUSY; - } - else - { - connectStatus = CLIENT_CONNECTION_BUSY_WRITE; - } - } - else if (pollingStatus == PGRES_POLLING_FAILED) - { - ReportConnectionError(connection, WARNING); - - connectStatus = CLIENT_CONNECTION_BAD; - } - - return connectStatus; -} - - /* MultiClientDisconnect disconnects the connection. */ void MultiClientDisconnect(int32 connectionId) @@ -250,29 +133,6 @@ MultiClientDisconnect(int32 connectionId) } -/* - * MultiClientConnectionUp checks if the connection status is up, in other words, - * it is not bad. - */ -bool -MultiClientConnectionUp(int32 connectionId) -{ - bool connectionUp = true; - - Assert(connectionId != INVALID_CONNECTION_ID); - MultiConnection *connection = ClientConnectionArray[connectionId]; - Assert(connection != NULL); - - ConnStatusType connStatusType = PQstatus(connection->pgConn); - if (connStatusType == CONNECTION_BAD) - { - connectionUp = false; - } - - return connectionUp; -} - - /* MultiClientSendQuery sends the given query over the given connection. */ bool MultiClientSendQuery(int32 connectionId, const char *query) @@ -306,20 +166,6 @@ MultiClientSendQuery(int32 connectionId, const char *query) } -/* MultiClientCancel cancels the running query on the given connection. */ -bool -MultiClientCancel(int32 connectionId) -{ - Assert(connectionId != INVALID_CONNECTION_ID); - MultiConnection *connection = ClientConnectionArray[connectionId]; - Assert(connection != NULL); - - bool canceled = SendCancelationRequest(connection); - - return canceled; -} - - /* MultiClientResultStatus checks result status for an asynchronous query. */ ResultStatus MultiClientResultStatus(int32 connectionId) @@ -361,85 +207,6 @@ MultiClientResultStatus(int32 connectionId) } -/* - * MultiClientBatchResult returns results for a "batch" of queries, meaning a - * string containing multiple select statements separated by semicolons. This - * function should be called multiple times to retrieve the results for all the - * queries, until CLIENT_BATCH_QUERY_DONE is returned (even if a failure occurs). - * If a query in the batch fails, the remaining queries will not be executed. On - * success, queryResult, rowCount and columnCount will be set to the appropriate - * values. After use, queryResult should be cleared using ClientClearResult. - */ -BatchQueryStatus -MultiClientBatchResult(int32 connectionId, void **queryResult, int *rowCount, - int *columnCount) -{ - BatchQueryStatus queryStatus = CLIENT_INVALID_BATCH_QUERY; - bool raiseInterrupts = true; - - Assert(connectionId != INVALID_CONNECTION_ID); - MultiConnection *connection = ClientConnectionArray[connectionId]; - Assert(connection != NULL); - - /* set default result */ - (*queryResult) = NULL; - (*rowCount) = -1; - (*columnCount) = -1; - - ConnStatusType connStatusType = PQstatus(connection->pgConn); - if (connStatusType == CONNECTION_BAD) - { - ereport(WARNING, (errmsg("could not maintain connection to worker node"))); - return CLIENT_BATCH_QUERY_FAILED; - } - - PGresult *result = GetRemoteCommandResult(connection, raiseInterrupts); - if (result == NULL) - { - return CLIENT_BATCH_QUERY_DONE; - } - - ExecStatusType resultStatus = PQresultStatus(result); - if (resultStatus == PGRES_TUPLES_OK) - { - (*queryResult) = (void **) result; - (*rowCount) = PQntuples(result); - (*columnCount) = PQnfields(result); - queryStatus = CLIENT_BATCH_QUERY_CONTINUE; - } - else if (resultStatus == PGRES_COMMAND_OK) - { - (*queryResult) = (void **) result; - queryStatus = CLIENT_BATCH_QUERY_CONTINUE; - } - else - { - ReportResultError(connection, result, WARNING); - PQclear(result); - queryStatus = CLIENT_BATCH_QUERY_FAILED; - } - - return queryStatus; -} - - -/* MultiClientGetValue returns the value of field at the given position. */ -char * -MultiClientGetValue(void *queryResult, int rowIndex, int columnIndex) -{ - char *value = PQgetvalue((PGresult *) queryResult, rowIndex, columnIndex); - return value; -} - - -/* MultiClientClearResult free's the memory associated with a PGresult. */ -void -MultiClientClearResult(void *queryResult) -{ - PQclear((PGresult *) queryResult); -} - - /* MultiClientQueryStatus returns the query status. */ QueryStatus MultiClientQueryStatus(int32 connectionId) @@ -609,101 +376,3 @@ MultiClientCopyData(int32 connectionId, int32 fileDescriptor, uint64 *returnByte return copyStatus; } - - -/* - * ClientConnectionReady checks if the given connection is ready for non-blocking - * reads or writes. This function is loosely based on pqSocketCheck() at fe-misc.c - * and libpq_select() at libpqwalreceiver.c. - */ -static bool -ClientConnectionReady(MultiConnection *connection, - PostgresPollingStatusType pollingStatus) -{ - bool clientConnectionReady = false; - int pollResult = 0; - - /* we use poll(2) if available, otherwise select(2) */ -#ifdef HAVE_POLL - int fileDescriptorCount = 1; - int immediateTimeout = 0; - int pollEventMask = 0; - struct pollfd pollFileDescriptor; - - if (pollingStatus == PGRES_POLLING_READING) - { - pollEventMask = POLLERR | POLLIN; - } - else if (pollingStatus == PGRES_POLLING_WRITING) - { - pollEventMask = POLLERR | POLLOUT; - } - - pollFileDescriptor.fd = PQsocket(connection->pgConn); - pollFileDescriptor.events = pollEventMask; - pollFileDescriptor.revents = 0; - - pollResult = poll(&pollFileDescriptor, fileDescriptorCount, immediateTimeout); -#else - fd_set readFileDescriptorSet; - fd_set writeFileDescriptorSet; - fd_set exceptionFileDescriptorSet; - struct timeval immediateTimeout = { 0, 0 }; - int connectionFileDescriptor = PQsocket(connection->pgConn); - - FD_ZERO(&readFileDescriptorSet); - FD_ZERO(&writeFileDescriptorSet); - FD_ZERO(&exceptionFileDescriptorSet); - - if (pollingStatus == PGRES_POLLING_READING) - { - FD_SET(connectionFileDescriptor, &exceptionFileDescriptorSet); - FD_SET(connectionFileDescriptor, &readFileDescriptorSet); - } - else if (pollingStatus == PGRES_POLLING_WRITING) - { - FD_SET(connectionFileDescriptor, &exceptionFileDescriptorSet); - FD_SET(connectionFileDescriptor, &writeFileDescriptorSet); - } - - pollResult = (select) (connectionFileDescriptor + 1, &readFileDescriptorSet, - &writeFileDescriptorSet, &exceptionFileDescriptorSet, - &immediateTimeout); -#endif /* HAVE_POLL */ - - if (pollResult > 0) - { - clientConnectionReady = true; - } - else if (pollResult == 0) - { - clientConnectionReady = false; - } - else if (pollResult < 0) - { - if (errno == EINTR) - { - /* - * If a signal was caught, we return false so the caller polls the - * connection again. - */ - clientConnectionReady = false; - } - else - { - /* - * poll() can set errno to EFAULT (when socket is not - * contained in the calling program's address space), EBADF (invalid - * file descriptor), EINVAL (invalid arguments to select or poll), - * and ENOMEM (no space to allocate file descriptor tables). Out of - * these, only ENOMEM is likely here, and it is a fatal error, so we - * error out. - */ - Assert(errno == ENOMEM); - ereport(ERROR, (errcode_for_socket_access(), - errmsg("select()/poll() failed: %m"))); - } - } - - return clientConnectionReady; -} diff --git a/src/backend/distributed/metadata/metadata_cache.c b/src/backend/distributed/metadata/metadata_cache.c index e9ade9d56..bc5c809ba 100644 --- a/src/backend/distributed/metadata/metadata_cache.c +++ b/src/backend/distributed/metadata/metadata_cache.c @@ -132,7 +132,6 @@ typedef struct MetadataCacheData bool extensionLoaded; Oid distShardRelationId; Oid distPlacementRelationId; - Oid distRebalanceStrategyRelationId; Oid distNodeRelationId; Oid distNodeNodeIdIndexId; Oid distLocalGroupRelationId; @@ -140,7 +139,6 @@ typedef struct MetadataCacheData Oid distObjectPrimaryKeyIndexId; Oid distColocationRelationId; Oid distColocationConfigurationIndexId; - Oid distColocationColocationidIndexId; Oid distPartitionRelationId; Oid distPartitionLogicalRelidIndexId; Oid distPartitionColocationidIndexId; @@ -151,7 +149,6 @@ typedef struct MetadataCacheData Oid distPlacementGroupidIndexId; Oid distTransactionRelationId; Oid distTransactionGroupIndexId; - Oid distTransactionRecordIndexId; Oid citusCatalogNamespaceId; Oid copyFormatTypeId; Oid readIntermediateResultFuncId; @@ -165,7 +162,6 @@ typedef struct MetadataCacheData Oid textCopyFormatId; Oid primaryNodeRoleId; Oid secondaryNodeRoleId; - Oid unavailableNodeRoleId; Oid pgTableIsVisibleFuncId; Oid citusTableIsVisibleFuncId; Oid jsonbExtractPathFuncId; @@ -449,18 +445,6 @@ IsCitusLocalTableByDistParams(char partitionMethod, char replicationModel) } -/* - * IsReferenceTableByDistParams returns true if given partitionMethod and - * replicationModel would identify a reference table. - */ -bool -IsReferenceTableByDistParams(char partitionMethod, char replicationModel) -{ - return partitionMethod == DISTRIBUTE_BY_NONE && - replicationModel == REPLICATION_MODEL_2PC; -} - - /* * CitusTableList returns a list that includes all the valid distributed table * cache entries. @@ -2069,17 +2053,6 @@ DistLocalGroupIdRelationId(void) } -/* return oid of pg_dist_rebalance_strategy relation */ -Oid -DistRebalanceStrategyRelationId(void) -{ - CachedRelationLookup("pg_dist_rebalance_strategy", - &MetadataCache.distRebalanceStrategyRelationId); - - return MetadataCache.distRebalanceStrategyRelationId; -} - - /* return the oid of citus namespace */ Oid CitusCatalogNamespaceId(void) @@ -2134,17 +2107,6 @@ DistColocationConfigurationIndexId(void) } -/* return oid of pg_dist_colocation_pkey index */ -Oid -DistColocationColocationidIndexId(void) -{ - CachedRelationLookup("pg_dist_colocation_pkey", - &MetadataCache.distColocationColocationidIndexId); - - return MetadataCache.distColocationColocationidIndexId; -} - - /* return oid of pg_dist_partition relation */ Oid DistPartitionRelationId(void) @@ -2244,17 +2206,6 @@ DistTransactionGroupIndexId(void) } -/* return oid of pg_dist_transaction_unique_constraint */ -Oid -DistTransactionRecordIndexId(void) -{ - CachedRelationLookup("pg_dist_transaction_unique_constraint", - &MetadataCache.distTransactionRecordIndexId); - - return MetadataCache.distTransactionRecordIndexId; -} - - /* return oid of pg_dist_placement_groupid_index */ Oid DistPlacementGroupidIndexId(void) @@ -2370,25 +2321,6 @@ CitusExtraDataContainerFuncId(void) } -/* return oid of the worker_hash function */ -Oid -CitusWorkerHashFunctionId(void) -{ - if (MetadataCache.workerHashFunctionId == InvalidOid) - { - Oid citusExtensionOid = get_extension_oid("citus", false); - Oid citusSchemaOid = get_extension_schema(citusExtensionOid); - char *citusSchemaName = get_namespace_name(citusSchemaOid); - const int argCount = 1; - - MetadataCache.workerHashFunctionId = - FunctionOid(citusSchemaName, "worker_hash", argCount); - } - - return MetadataCache.workerHashFunctionId; -} - - /* return oid of the any_value aggregate function */ Oid CitusAnyValueFunctionId(void) @@ -2404,24 +2336,6 @@ CitusAnyValueFunctionId(void) } -/* return oid of the citus_text_send_as_jsonb(text) function */ -Oid -CitusTextSendAsJsonbFunctionId(void) -{ - if (MetadataCache.textSendAsJsonbFunctionId == InvalidOid) - { - List *nameList = list_make2(makeString("pg_catalog"), - makeString("citus_text_send_as_jsonb")); - Oid paramOids[1] = { TEXTOID }; - - MetadataCache.textSendAsJsonbFunctionId = - LookupFuncName(nameList, 1, paramOids, false); - } - - return MetadataCache.textSendAsJsonbFunctionId; -} - - /* * PgTableVisibleFuncId returns oid of the pg_table_is_visible function. */ @@ -2682,20 +2596,6 @@ SecondaryNodeRoleId(void) } -/* return the Oid of the 'unavailable' nodeRole enum value */ -Oid -UnavailableNodeRoleId(void) -{ - if (!MetadataCache.unavailableNodeRoleId) - { - MetadataCache.unavailableNodeRoleId = LookupStringEnumValueId("noderole", - "unavailable"); - } - - return MetadataCache.unavailableNodeRoleId; -} - - /* * master_dist_partition_cache_invalidate is a trigger function that performs * relcache invalidations when the contents of pg_dist_partition are changed diff --git a/src/backend/distributed/metadata/metadata_sync.c b/src/backend/distributed/metadata/metadata_sync.c index 968cb1299..8e5394f72 100644 --- a/src/backend/distributed/metadata/metadata_sync.c +++ b/src/backend/distributed/metadata/metadata_sync.c @@ -854,35 +854,6 @@ ShardListInsertCommand(List *shardIntervalList) } -/* - * ShardListDeleteCommand generates a command list that can be executed to delete - * shard and shard placement metadata for the given shard. - */ -List * -ShardDeleteCommandList(ShardInterval *shardInterval) -{ - uint64 shardId = shardInterval->shardId; - List *commandList = NIL; - - /* create command to delete shard placements */ - StringInfo deletePlacementCommand = makeStringInfo(); - appendStringInfo(deletePlacementCommand, - "DELETE FROM pg_dist_placement WHERE shardid = " UINT64_FORMAT, - shardId); - - commandList = lappend(commandList, deletePlacementCommand->data); - - /* create command to delete shard */ - StringInfo deleteShardCommand = makeStringInfo(); - appendStringInfo(deleteShardCommand, - "DELETE FROM pg_dist_shard WHERE shardid = " UINT64_FORMAT, shardId); - - commandList = lappend(commandList, deleteShardCommand->data); - - return commandList; -} - - /* * NodeDeleteCommand generate a command that can be * executed to delete the metadata for a worker node. diff --git a/src/backend/distributed/metadata/metadata_utility.c b/src/backend/distributed/metadata/metadata_utility.c index 52efc3b83..10a4ff5b6 100644 --- a/src/backend/distributed/metadata/metadata_utility.c +++ b/src/backend/distributed/metadata/metadata_utility.c @@ -631,24 +631,6 @@ CopyShardInterval(ShardInterval *srcInterval) } -/* - * CopyShardPlacement copies the values of the source placement into the - * target placement. - */ -void -CopyShardPlacement(ShardPlacement *srcPlacement, ShardPlacement *destPlacement) -{ - /* first copy all by-value fields */ - *destPlacement = *srcPlacement; - - /* and then the fields pointing to external values */ - if (srcPlacement->nodeName) - { - destPlacement->nodeName = pstrdup(srcPlacement->nodeName); - } -} - - /* * ShardLength finds shard placements for the given shardId, extracts the length * of an active shard, and returns the shard's length. This function errors @@ -1392,21 +1374,6 @@ EnsureSchemaOwner(Oid schemaId) } -/* - * Check that the current user has owner rights to sequenceRelationId, error out if - * not. Superusers are regarded as owners. - */ -void -EnsureSequenceOwner(Oid sequenceOid) -{ - if (!pg_class_ownercheck(sequenceOid, GetUserId())) - { - aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SEQUENCE, - get_rel_name(sequenceOid)); - } -} - - /* * Check that the current user has owner rights to functionId, error out if * not. Superusers are regarded as owners. Functions and procedures are diff --git a/src/backend/distributed/operations/repair_shards.c b/src/backend/distributed/operations/repair_shards.c index 284d5657a..79b355ce8 100644 --- a/src/backend/distributed/operations/repair_shards.c +++ b/src/backend/distributed/operations/repair_shards.c @@ -517,8 +517,8 @@ EnsureTableListSuitableForReplication(List *tableIdList) /* - * CopyColocatedShardPlacement copies a shard along with its co-located shards from a - * source node to target node. CopyShardPlacement does not make any checks about state + * CopyColocatedShardPlacement copies a shard along with its co-located shards + * from a source node to target node. It does not make any checks about state * of the shards. It is caller's responsibility to make those checks if they are * necessary. */ diff --git a/src/backend/distributed/planner/multi_logical_planner.c b/src/backend/distributed/planner/multi_logical_planner.c index fb208ef02..14a57032e 100644 --- a/src/backend/distributed/planner/multi_logical_planner.c +++ b/src/backend/distributed/planner/multi_logical_planner.c @@ -334,18 +334,6 @@ IsCitusTableRTE(Node *node) } -/* - * IsPostgresLocalTableRte gets a node and returns true if the node is a - * range table relation entry that points to a postgres local table. - */ -bool -IsPostgresLocalTableRte(Node *node) -{ - Oid relationId = NodeTryGetRteRelid(node); - return OidIsValid(relationId) && !IsCitusTable(relationId); -} - - /* * IsDistributedTableRTE gets a node and returns true if the node * is a range table relation entry that points to a distributed relation, @@ -371,18 +359,6 @@ IsReferenceTableRTE(Node *node) } -/* - * IsCitusLocalTableRTE gets a node and returns true if the node - * is a range table relation entry that points to a citus local table. - */ -bool -IsCitusLocalTableRTE(Node *node) -{ - Oid relationId = NodeTryGetRteRelid(node); - return OidIsValid(relationId) && IsCitusTableType(relationId, CITUS_LOCAL_TABLE); -} - - /* * FullCompositeFieldList gets a composite field list, and checks if all fields * of composite type are used in the list. diff --git a/src/backend/distributed/planner/multi_physical_planner.c b/src/backend/distributed/planner/multi_physical_planner.c index a258924af..a07cb0849 100644 --- a/src/backend/distributed/planner/multi_physical_planner.c +++ b/src/backend/distributed/planner/multi_physical_planner.c @@ -3340,36 +3340,6 @@ SimpleOpExpression(Expr *clause) } -/* - * OpExpressionContainsColumn checks if the operator expression contains the - * given partition column. We assume that given operator expression is a simple - * operator expression which means it is a binary operator expression with - * operands of a var and a non-null constant. - */ -bool -OpExpressionContainsColumn(OpExpr *operatorExpression, Var *partitionColumn) -{ - Node *leftOperand; - Node *rightOperand; - if (!BinaryOpExpression((Expr *) operatorExpression, &leftOperand, &rightOperand)) - { - return false; - } - Var *column = NULL; - - if (IsA(leftOperand, Var)) - { - column = (Var *) leftOperand; - } - else - { - column = (Var *) rightOperand; - } - - return equal(column, partitionColumn); -} - - /* * MakeInt4Column creates a column of int4 type with invalid table id and max * attribute number. @@ -3390,27 +3360,6 @@ MakeInt4Column() } -/* - * MakeInt4Constant creates a new constant of int4 type and assigns the given - * value as a constant value. - */ -Const * -MakeInt4Constant(Datum constantValue) -{ - Oid constantType = INT4OID; - int32 constantTypeMode = -1; - Oid constantCollationId = InvalidOid; - int constantLength = sizeof(int32); - bool constantIsNull = false; - bool constantByValue = true; - - Const *int4Constant = makeConst(constantType, constantTypeMode, constantCollationId, - constantLength, constantValue, constantIsNull, - constantByValue); - return int4Constant; -} - - /* Updates the base constraint with the given min/max values. */ void UpdateConstraint(Node *baseConstraint, ShardInterval *shardInterval) @@ -4943,47 +4892,6 @@ TasksEqual(const Task *a, const Task *b) } -/* - * TaskListAppendUnique returns a list that contains the elements of the - * input task list and appends the input task parameter if it doesn't already - * exists the list. - */ -List * -TaskListAppendUnique(List *list, Task *task) -{ - if (TaskListMember(list, task)) - { - return list; - } - - return lappend(list, task); -} - - -/* - * TaskListConcatUnique append to list1 each member of list2 that isn't - * already in list1. Whether an element is already a member of the list - * is determined via TaskListMember(). - */ -List * -TaskListConcatUnique(List *list1, List *list2) -{ - ListCell *taskCell = NULL; - - foreach(taskCell, list2) - { - Task *currentTask = (Task *) lfirst(taskCell); - - if (!TaskListMember(list1, currentTask)) - { - list1 = lappend(list1, currentTask); - } - } - - return list1; -} - - /* Is the passed in Task a member of the list. */ bool TaskListMember(const List *taskList, const Task *task) diff --git a/src/backend/distributed/planner/postgres_planning_functions.c b/src/backend/distributed/planner/postgres_planning_functions.c deleted file mode 100644 index 064bf7713..000000000 --- a/src/backend/distributed/planner/postgres_planning_functions.c +++ /dev/null @@ -1,133 +0,0 @@ -/*------------------------------------------------------------------------- - * - * postgres_planning_function.c - * Includes planning routines copied from - * src/backend/optimizer/plan/createplan.c - * - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * This needs to be closely in sync with the core code. - *------------------------------------------------------------------------- - */ - -#include "postgres.h" - -#include "distributed/pg_version_constants.h" - -#include "distributed/combine_query_planner.h" -#include "nodes/plannodes.h" -#if PG_VERSION_NUM >= PG_VERSION_12 -#include "nodes/nodeFuncs.h" -#include "optimizer/optimizer.h" -#else -#include "optimizer/tlist.h" -#endif - -/* - * make_unique_from_sortclauses creates and returns a unique node - * from provided distinct clause list. - * The functions is copied from postgresql from - * src/backend/optimizer/plan/createplan.c. - */ - -#if PG_VERSION_NUM >= PG_VERSION_12 - -/* - * distinctList is a list of SortGroupClauses, identifying the targetlist items - * that should be considered by the Unique filter. The input path must - * already be sorted accordingly. - */ -Unique * -make_unique_from_sortclauses(Plan *lefttree, List *distinctList) -{ - Unique *node = makeNode(Unique); - Plan *plan = &node->plan; - int numCols = list_length(distinctList); - int keyno = 0; - ListCell *slitem; - - plan->targetlist = lefttree->targetlist; - plan->qual = NIL; - plan->lefttree = lefttree; - plan->righttree = NULL; - - /* - * convert SortGroupClause list into arrays of attr indexes and equality - * operators, as wanted by executor - */ - Assert(numCols > 0); - AttrNumber *uniqColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols); - Oid *uniqOperators = (Oid *) palloc(sizeof(Oid) * numCols); - Oid *uniqCollations = (Oid *) palloc(sizeof(Oid) * numCols); - - foreach(slitem, distinctList) - { - SortGroupClause *sortcl = (SortGroupClause *) lfirst(slitem); - TargetEntry *tle = get_sortgroupclause_tle(sortcl, plan->targetlist); - - uniqColIdx[keyno] = tle->resno; - uniqOperators[keyno] = sortcl->eqop; - uniqCollations[keyno] = exprCollation((Node *) tle->expr); - Assert(OidIsValid(uniqOperators[keyno])); - keyno++; - } - - node->numCols = numCols; - node->uniqColIdx = uniqColIdx; - node->uniqOperators = uniqOperators; - node->uniqCollations = uniqCollations; - - return node; -} - - -#else - -/* - * distinctList is a list of SortGroupClauses, identifying the targetlist items - * that should be considered by the Unique filter. The input path must - * already be sorted accordingly. - */ -Unique * -make_unique_from_sortclauses(Plan *lefttree, List *distinctList) -{ - Unique *node = makeNode(Unique); - Plan *plan = &node->plan; - int numCols = list_length(distinctList); - int keyno = 0; - ListCell *slitem; - - plan->targetlist = lefttree->targetlist; - plan->qual = NIL; - plan->lefttree = lefttree; - plan->righttree = NULL; - - /* - * convert SortGroupClause list into arrays of attr indexes and equality - * operators, as wanted by executor - */ - Assert(numCols > 0); - AttrNumber *uniqColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols); - Oid *uniqOperators = (Oid *) palloc(sizeof(Oid) * numCols); - - foreach(slitem, distinctList) - { - SortGroupClause *sortcl = (SortGroupClause *) lfirst(slitem); - TargetEntry *tle = get_sortgroupclause_tle(sortcl, plan->targetlist); - - uniqColIdx[keyno] = tle->resno; - uniqOperators[keyno] = sortcl->eqop; - Assert(OidIsValid(uniqOperators[keyno])); - keyno++; - } - - node->numCols = numCols; - node->uniqColIdx = uniqColIdx; - node->uniqOperators = uniqOperators; - - return node; -} - - -#endif diff --git a/src/backend/distributed/transaction/remote_transaction.c b/src/backend/distributed/transaction/remote_transaction.c index 4dcf3957d..27d25091d 100644 --- a/src/backend/distributed/transaction/remote_transaction.c +++ b/src/backend/distributed/transaction/remote_transaction.c @@ -562,18 +562,6 @@ FinishRemoteTransactionPrepare(struct MultiConnection *connection) } -/* - * RemoteTransactionPrepare prepares a remote transaction in a blocking - * manner. - */ -void -RemoteTransactionPrepare(struct MultiConnection *connection) -{ - StartRemoteTransactionPrepare(connection); - FinishRemoteTransactionPrepare(connection); -} - - /* * RemoteTransactionBeginIfNecessary is a convenience wrapper around * RemoteTransactionsBeginIfNecessary(), for a single connection. @@ -746,19 +734,6 @@ MarkRemoteTransactionCritical(struct MultiConnection *connection) } -/* - * IsRemoteTransactionCritical returns whether the remote transaction on - * the given connection has been marked as critical. - */ -bool -IsRemoteTransactionCritical(struct MultiConnection *connection) -{ - RemoteTransaction *transaction = &connection->remoteTransaction; - - return transaction->transactionCritical; -} - - /* * CloseRemoteTransaction handles closing a connection that, potentially, is * part of a coordinated transaction. This should only ever be called from diff --git a/src/backend/distributed/transaction/transaction_management.c b/src/backend/distributed/transaction/transaction_management.c index d54bd3edf..1999c836c 100644 --- a/src/backend/distributed/transaction/transaction_management.c +++ b/src/backend/distributed/transaction/transaction_management.c @@ -659,26 +659,6 @@ PopSubXact(SubTransactionId subId) } -/* ActiveSubXacts returns list of active sub-transactions in temporal order. */ -List * -ActiveSubXacts(void) -{ - List *activeSubXactsReversed = NIL; - - /* - * activeSubXactContexts is in reversed temporal order, so we reverse it to get it - * in temporal order. - */ - SubXactContext *state = NULL; - foreach_ptr(state, activeSubXactContexts) - { - activeSubXactsReversed = lcons_int(state->subId, activeSubXactsReversed); - } - - return activeSubXactsReversed; -} - - /* ActiveSubXactContexts returns the list of active sub-xact context in temporal order. */ List * ActiveSubXactContexts(void) diff --git a/src/backend/distributed/utils/hash_helpers.c b/src/backend/distributed/utils/hash_helpers.c index 6bbf14938..0ed090dca 100644 --- a/src/backend/distributed/utils/hash_helpers.c +++ b/src/backend/distributed/utils/hash_helpers.c @@ -32,18 +32,3 @@ hash_delete_all(HTAB *htab) Assert(found); } } - - -/* - * foreach_htab_cleanup cleans up the hash iteration state after the iteration - * is done. This is only needed when break statements are present in the - * foreach block. - */ -void -foreach_htab_cleanup(void *var, HASH_SEQ_STATUS *status) -{ - if ((var) != NULL) - { - hash_seq_term(status); - } -} diff --git a/src/backend/distributed/utils/resource_lock.c b/src/backend/distributed/utils/resource_lock.c index 231252e40..ba5a41824 100644 --- a/src/backend/distributed/utils/resource_lock.c +++ b/src/backend/distributed/utils/resource_lock.c @@ -366,26 +366,6 @@ LockShardDistributionMetadata(int64 shardId, LOCKMODE lockMode) } -/* - * TryLockShardDistributionMetadata tries to grab a lock for distribution - * metadata related to the specified shard, returning false if the lock - * is currently taken. Any locks acquired using this method are released - * at transaction end. - */ -bool -TryLockShardDistributionMetadata(int64 shardId, LOCKMODE lockMode) -{ - LOCKTAG tag; - const bool sessionLock = false; - const bool dontWait = true; - - SetLocktagForShardDistributionMetadata(shardId, &tag); - bool lockAcquired = LockAcquire(&tag, lockMode, sessionLock, dontWait); - - return lockAcquired; -} - - static void SetLocktagForShardDistributionMetadata(int64 shardId, LOCKTAG *tag) { @@ -530,19 +510,6 @@ LockShardResource(uint64 shardId, LOCKMODE lockmode) } -/* Releases the lock associated with the relay file fetching/DML task. */ -void -UnlockShardResource(uint64 shardId, LOCKMODE lockmode) -{ - LOCKTAG tag; - const bool sessionLock = false; - - SET_LOCKTAG_SHARD_RESOURCE(tag, MyDatabaseId, shardId); - - LockRelease(&tag, lockmode, sessionLock); -} - - /* LockTransactionRecovery acquires a lock for transaction recovery */ void LockTransactionRecovery(LOCKMODE lockmode) diff --git a/src/backend/distributed/utils/shardinterval_utils.c b/src/backend/distributed/utils/shardinterval_utils.c index e40d31523..431a8edb9 100644 --- a/src/backend/distributed/utils/shardinterval_utils.c +++ b/src/backend/distributed/utils/shardinterval_utils.c @@ -27,29 +27,6 @@ #include "utils/memutils.h" -/* - * LowestShardIntervalById returns the shard interval with the lowest shard - * ID from a list of shard intervals. - */ -ShardInterval * -LowestShardIntervalById(List *shardIntervalList) -{ - ShardInterval *lowestShardInterval = NULL; - - ShardInterval *shardInterval = NULL; - foreach_ptr(shardInterval, shardIntervalList) - { - if (lowestShardInterval == NULL || - lowestShardInterval->shardId > shardInterval->shardId) - { - lowestShardInterval = shardInterval; - } - } - - return lowestShardInterval; -} - - /* * SortedShardIntervalArray sorts the input shardIntervalArray. Shard intervals with * no min/max values are placed at the end of the array. diff --git a/src/backend/distributed/worker/worker_data_fetch_protocol.c b/src/backend/distributed/worker/worker_data_fetch_protocol.c index 329c8dd5f..9c9982a6f 100644 --- a/src/backend/distributed/worker/worker_data_fetch_protocol.c +++ b/src/backend/distributed/worker/worker_data_fetch_protocol.c @@ -525,32 +525,6 @@ ExtractShardIdFromTableName(const char *tableName, bool missingOk) } -/* - * TableDDLCommandList takes in the given table name, and fetches the list of - * DDL commands used in creating the table. If an error occurs during fetching, - * the function returns an empty list. - */ -List * -TableDDLCommandList(const char *nodeName, uint32 nodePort, const char *tableName) -{ - PGresult *result = NULL; - uint32 connectionFlag = FORCE_NEW_CONNECTION; - - StringInfo queryString = makeStringInfo(); - appendStringInfo(queryString, GET_TABLE_DDL_EVENTS, tableName); - MultiConnection *connection = GetNodeConnection(connectionFlag, nodeName, nodePort); - - ExecuteOptionalRemoteCommand(connection, queryString->data, &result); - List *ddlCommandList = ReadFirstColumnAsText(result); - - PQclear(result); - ForgetResults(connection); - CloseConnection(connection); - - return ddlCommandList; -} - - /* * Parses the given DDL command, and returns the tree node for parsed command. */ diff --git a/src/backend/distributed/worker/worker_partition_protocol.c b/src/backend/distributed/worker/worker_partition_protocol.c index e1697de93..671e8e04c 100644 --- a/src/backend/distributed/worker/worker_partition_protocol.c +++ b/src/backend/distributed/worker/worker_partition_protocol.c @@ -564,31 +564,6 @@ UserPartitionFilename(StringInfo directoryName, uint32 partitionId) } -/* - * JobDirectoryElement takes in a filename, and checks if this name lives in the - * directory path that is used for task output files. Note that this function's - * implementation is coupled with JobDirectoryName(). - */ -bool -JobDirectoryElement(const char *filename) -{ - bool directoryElement = false; - - StringInfo directoryPath = makeStringInfo(); - appendStringInfo(directoryPath, "base/%s/%s", PG_JOB_CACHE_DIR, JOB_DIRECTORY_PREFIX); - - char *directoryPathFound = strstr(filename, directoryPath->data); - if (directoryPathFound != NULL) - { - directoryElement = true; - } - - pfree(directoryPath); - - return directoryElement; -} - - /* * CacheDirectoryElement takes in a filename, and checks if this name lives in * the directory path that is used for job, task, table etc. files. diff --git a/src/include/distributed/adaptive_executor.h b/src/include/distributed/adaptive_executor.h index f12058284..ae28e4385 100644 --- a/src/include/distributed/adaptive_executor.h +++ b/src/include/distributed/adaptive_executor.h @@ -11,8 +11,6 @@ extern bool EnableBinaryProtocol; /* GUC, number of ms to wait between opening connections to the same worker */ extern int ExecutorSlowStartInterval; -extern uint64 ExecuteTaskList(RowModifyLevel modLevel, List *taskList, - int targetPoolSize, bool localExecutionSupported); extern uint64 ExecuteUtilityTaskList(List *utilityTaskList, bool localExecutionSupported); extern uint64 ExecuteUtilityTaskListExtended(List *utilityTaskList, int poolSize, bool localExecutionSupported); diff --git a/src/include/distributed/citus_ruleutils.h b/src/include/distributed/citus_ruleutils.h index 6de98c626..1d80d6447 100644 --- a/src/include/distributed/citus_ruleutils.h +++ b/src/include/distributed/citus_ruleutils.h @@ -38,7 +38,6 @@ extern void deparse_shard_index_statement(IndexStmt *origStmt, Oid distrelid, extern void deparse_shard_reindex_statement(ReindexStmt *origStmt, Oid distrelid, int64 shardid, StringInfo buffer); extern char * pg_get_indexclusterdef_string(Oid indexRelationId); -extern List * pg_get_table_grants(Oid relationId); extern bool contain_nextval_expression_walker(Node *node, void *context); extern char * pg_get_replica_identity_command(Oid tableRelationId); extern const char * RoleSpecString(RoleSpec *spec, bool withQuoteIdentifier); diff --git a/src/include/distributed/combine_query_planner.h b/src/include/distributed/combine_query_planner.h index c7ea7c6e8..d91442f6b 100644 --- a/src/include/distributed/combine_query_planner.h +++ b/src/include/distributed/combine_query_planner.h @@ -31,7 +31,6 @@ extern Path * CreateCitusCustomScanPath(PlannerInfo *root, RelOptInfo *relOptInf CustomScan *remoteScan); extern PlannedStmt * PlanCombineQuery(struct DistributedPlan *distributedPlan, struct CustomScan *dataScan); -extern Unique * make_unique_from_sortclauses(Plan *lefttree, List *distinctList); extern bool ReplaceCitusExtraDataContainer; extern CustomScan *ReplaceCitusExtraDataContainerWithCustomScan; diff --git a/src/include/distributed/commands.h b/src/include/distributed/commands.h index b39b42109..292521641 100644 --- a/src/include/distributed/commands.h +++ b/src/include/distributed/commands.h @@ -186,13 +186,11 @@ extern void MarkIndexValid(IndexStmt *indexStmt); /* objectaddress.c - forward declarations */ extern ObjectAddress CreateExtensionStmtObjectAddress(Node *stmt, bool missing_ok); -extern ObjectAddress AlterExtensionStmtObjectAddress(Node *stmt, bool missing_ok); /* policy.c - forward declarations */ extern List * CreatePolicyCommands(Oid relationId); extern void ErrorIfUnsupportedPolicy(Relation relation); -extern void ErrorIfUnsupportedPolicyExpr(Node *expr); extern List * PreprocessCreatePolicyStmt(Node *node, const char *queryString); extern List * PreprocessAlterPolicyStmt(Node *node, const char *queryString); extern List * PreprocessDropPolicyStmt(Node *stmt, const char *queryString); diff --git a/src/include/distributed/connection_management.h b/src/include/distributed/connection_management.h index 189d695e6..2bdfcb640 100644 --- a/src/include/distributed/connection_management.h +++ b/src/include/distributed/connection_management.h @@ -230,8 +230,6 @@ extern MultiConnection * StartNodeConnection(uint32 flags, const char *hostname, extern MultiConnection * GetNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port, const char *user, const char *database); -extern List * StartWorkerListConnections(List *workerList, uint32 flags, const char *user, - const char *database); extern MultiConnection * StartNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port, diff --git a/src/include/distributed/deparser.h b/src/include/distributed/deparser.h index 590391f31..62d8dd707 100644 --- a/src/include/distributed/deparser.h +++ b/src/include/distributed/deparser.h @@ -24,7 +24,6 @@ /* Control flags for FormatCollateExtended, compatible with format_type_extended */ #define FORMAT_COLLATE_ALLOW_INVALID 0x02 /* allow invalid types */ #define FORMAT_COLLATE_FORCE_QUALIFY 0x04 /* force qualification of collate */ -extern char * FormatCollateBE(Oid collate_oid); extern char * FormatCollateBEQualified(Oid collate_oid); extern char * FormatCollateExtended(Oid collid, bits16 flags); diff --git a/src/include/distributed/hash_helpers.h b/src/include/distributed/hash_helpers.h index 5d329e423..b25cd1cd8 100644 --- a/src/include/distributed/hash_helpers.h +++ b/src/include/distributed/hash_helpers.h @@ -48,6 +48,4 @@ extern void hash_delete_all(HTAB *htab); (var) != NULL; \ (var) = hash_seq_search(status)) -extern void foreach_htab_cleanup(void *var, HASH_SEQ_STATUS *status); - #endif diff --git a/src/include/distributed/metadata_cache.h b/src/include/distributed/metadata_cache.h index 30ecc2eb9..7303e55fe 100644 --- a/src/include/distributed/metadata_cache.h +++ b/src/include/distributed/metadata_cache.h @@ -140,7 +140,6 @@ extern bool IsCitusTableTypeCacheEntry(CitusTableCacheEntry *tableEtnry, extern bool IsCitusTable(Oid relationId); extern bool IsCitusLocalTableByDistParams(char partitionMethod, char replicationModel); -extern bool IsReferenceTableByDistParams(char partitionMethod, char replicationModel); extern List * CitusTableList(void); extern ShardInterval * LoadShardInterval(uint64 shardId); extern Oid RelationIdForShard(uint64 shardId); @@ -203,12 +202,10 @@ extern Oid CitusCatalogNamespaceId(void); /* relation oids */ extern Oid DistColocationRelationId(void); extern Oid DistColocationConfigurationIndexId(void); -extern Oid DistColocationColocationidIndexId(void); extern Oid DistPartitionRelationId(void); extern Oid DistShardRelationId(void); extern Oid DistPlacementRelationId(void); extern Oid DistNodeRelationId(void); -extern Oid DistRebalanceStrategyRelationId(void); extern Oid DistLocalGroupIdRelationId(void); extern Oid DistObjectRelationId(void); extern Oid DistEnabledCustomAggregatesId(void); @@ -223,7 +220,6 @@ extern Oid DistPlacementShardidIndexId(void); extern Oid DistPlacementPlacementidIndexId(void); extern Oid DistTransactionRelationId(void); extern Oid DistTransactionGroupIndexId(void); -extern Oid DistTransactionRecordIndexId(void); extern Oid DistPlacementGroupidIndexId(void); extern Oid DistObjectPrimaryKeyIndexId(void); @@ -235,9 +231,7 @@ extern Oid CitusCopyFormatTypeId(void); extern Oid CitusReadIntermediateResultFuncId(void); Oid CitusReadIntermediateResultArrayFuncId(void); extern Oid CitusExtraDataContainerFuncId(void); -extern Oid CitusWorkerHashFunctionId(void); extern Oid CitusAnyValueFunctionId(void); -extern Oid CitusTextSendAsJsonbFunctionId(void); extern Oid PgTableVisibleFuncId(void); extern Oid CitusTableVisibleFuncId(void); extern Oid JsonbExtractPathFuncId(void); @@ -245,7 +239,6 @@ extern Oid JsonbExtractPathFuncId(void); /* enum oids */ extern Oid PrimaryNodeRoleId(void); extern Oid SecondaryNodeRoleId(void); -extern Oid UnavailableNodeRoleId(void); extern Oid CitusCopyFormatTypeId(void); extern Oid TextCopyFormatId(void); extern Oid BinaryCopyFormatId(void); diff --git a/src/include/distributed/metadata_sync.h b/src/include/distributed/metadata_sync.h index 78391ebbf..88f1e63a9 100644 --- a/src/include/distributed/metadata_sync.h +++ b/src/include/distributed/metadata_sync.h @@ -39,7 +39,6 @@ extern char * DistributionDeleteCommand(const char *schemaName, extern char * TableOwnerResetCommand(Oid distributedRelationId); extern char * NodeListInsertCommand(List *workerNodeList); extern List * ShardListInsertCommand(List *shardIntervalList); -extern List * ShardDeleteCommandList(ShardInterval *shardInterval); extern char * NodeDeleteCommand(uint32 nodeId); extern char * NodeStateUpdateCommand(uint32 nodeId, bool isActive); extern char * ShouldHaveShardsUpdateCommand(uint32 nodeId, bool shouldHaveShards); diff --git a/src/include/distributed/metadata_utility.h b/src/include/distributed/metadata_utility.h index b7b4e9457..5db5b0b69 100644 --- a/src/include/distributed/metadata_utility.h +++ b/src/include/distributed/metadata_utility.h @@ -103,8 +103,6 @@ extern ShardInterval * LoadShardIntervalWithLongestShardName(Oid relationId); extern int ShardIntervalCount(Oid relationId); extern List * LoadShardList(Oid relationId); extern ShardInterval * CopyShardInterval(ShardInterval *srcInterval); -extern void CopyShardPlacement(ShardPlacement *srcPlacement, - ShardPlacement *destPlacement); extern uint64 ShardLength(uint64 shardId); extern bool NodeGroupHasShardPlacements(int32 groupId, bool onlyConsiderActivePlacements); @@ -151,7 +149,6 @@ extern void EnsureTablePermissions(Oid relationId, AclMode mode); extern void EnsureTableOwner(Oid relationId); extern void EnsureSchemaOwner(Oid schemaId); extern void EnsureHashDistributedTable(Oid relationId); -extern void EnsureSequenceOwner(Oid sequenceOid); extern void EnsureFunctionOwner(Oid functionId); extern void EnsureSuperUser(void); extern void ErrorIfTableIsACatalogTable(Relation relation); diff --git a/src/include/distributed/multi_client_executor.h b/src/include/distributed/multi_client_executor.h index 529929aef..9bb9b5293 100644 --- a/src/include/distributed/multi_client_executor.h +++ b/src/include/distributed/multi_client_executor.h @@ -100,21 +100,12 @@ typedef struct WaitInfo /* Function declarations for executing client-side (libpq) logic. */ extern int32 MultiClientConnect(const char *nodeName, uint32 nodePort, const char *nodeDatabase, const char *nodeUser); -extern int32 MultiClientConnectStart(const char *nodeName, uint32 nodePort, - const char *nodeDatabase, const char *nodeUser); -extern ConnectStatus MultiClientConnectPoll(int32 connectionId); extern void MultiClientDisconnect(int32 connectionId); -extern bool MultiClientConnectionUp(int32 connectionId); extern bool MultiClientSendQuery(int32 connectionId, const char *query); -extern bool MultiClientCancel(int32 connectionId); extern ResultStatus MultiClientResultStatus(int32 connectionId); extern QueryStatus MultiClientQueryStatus(int32 connectionId); extern CopyStatus MultiClientCopyData(int32 connectionId, int32 fileDescriptor, uint64 *returnBytesReceived); -extern BatchQueryStatus MultiClientBatchResult(int32 connectionId, void **queryResult, - int *rowCount, int *columnCount); -extern char * MultiClientGetValue(void *queryResult, int rowIndex, int columnIndex); -extern void MultiClientClearResult(void *queryResult); #endif /* MULTI_CLIENT_EXECUTOR_H */ diff --git a/src/include/distributed/multi_logical_planner.h b/src/include/distributed/multi_logical_planner.h index 55655a2f3..993e8b819 100644 --- a/src/include/distributed/multi_logical_planner.h +++ b/src/include/distributed/multi_logical_planner.h @@ -195,10 +195,8 @@ extern bool TargetListOnPartitionColumn(Query *query, List *targetEntryList); extern bool FindNodeMatchingCheckFunctionInRangeTableList(List *rtable, bool (*check)( Node *)); extern bool IsCitusTableRTE(Node *node); -extern bool IsPostgresLocalTableRte(Node *node); extern bool IsDistributedTableRTE(Node *node); extern bool IsReferenceTableRTE(Node *node); -extern bool IsCitusLocalTableRTE(Node *node); extern bool QueryContainsDistributedTableRTE(Query *query); extern bool IsCitusExtraDataContainerRelation(RangeTblEntry *rte); extern bool ContainsReadIntermediateResultFunction(Node *node); diff --git a/src/include/distributed/multi_physical_planner.h b/src/include/distributed/multi_physical_planner.h index 1518756fa..9f90798da 100644 --- a/src/include/distributed/multi_physical_planner.h +++ b/src/include/distributed/multi_physical_planner.h @@ -544,11 +544,9 @@ extern Node * BuildBaseConstraint(Var *column); extern void UpdateConstraint(Node *baseConstraint, ShardInterval *shardInterval); extern bool BinaryOpExpression(Expr *clause, Node **leftOperand, Node **rightOperand); extern bool SimpleOpExpression(Expr *clause); -extern bool OpExpressionContainsColumn(OpExpr *operatorExpression, Var *partitionColumn); /* helper functions */ extern Var * MakeInt4Column(void); -extern Const * MakeInt4Constant(Datum constantValue); extern int CompareShardPlacements(const void *leftElement, const void *rightElement); extern bool ShardIntervalsOverlap(ShardInterval *firstInterval, ShardInterval *secondInterval); @@ -561,8 +559,6 @@ extern StringInfo ArrayObjectToString(ArrayType *arrayObject, /* function declarations for Task and Task list operations */ extern bool TasksEqual(const Task *a, const Task *b); -extern List * TaskListAppendUnique(List *list, Task *task); -extern List * TaskListConcatUnique(List *list1, List *list2); extern bool TaskListMember(const List *taskList, const Task *task); extern List * TaskListDifference(const List *list1, const List *list2); extern List * AssignAnchorShardTaskList(List *taskList); diff --git a/src/include/distributed/placement_connection.h b/src/include/distributed/placement_connection.h index df1688d63..0e7eb605b 100644 --- a/src/include/distributed/placement_connection.h +++ b/src/include/distributed/placement_connection.h @@ -41,7 +41,6 @@ extern void ResetShardPlacementAssociation(struct MultiConnection *connection); extern void InitPlacementConnectionManagement(void); extern bool ConnectionModifiedPlacement(MultiConnection *connection); -extern bool ConnectionUsedForAnyPlacements(MultiConnection *connection); extern bool UseConnectionPerPlacement(void); #endif /* PLACEMENT_CONNECTION_H */ diff --git a/src/include/distributed/remote_commands.h b/src/include/distributed/remote_commands.h index f7be3fc5a..b4b7c11e9 100644 --- a/src/include/distributed/remote_commands.h +++ b/src/include/distributed/remote_commands.h @@ -28,7 +28,6 @@ extern void ForgetResults(MultiConnection *connection); extern bool ClearResults(MultiConnection *connection, bool raiseErrors); extern bool ClearResultsDiscardWarnings(MultiConnection *connection, bool raiseErrors); extern bool ClearResultsIfReady(MultiConnection *connection); -extern bool SqlStateMatchesCategory(char *sqlStateString, int category); /* report errors & warnings */ extern void ReportConnectionError(MultiConnection *connection, int elevel); diff --git a/src/include/distributed/remote_transaction.h b/src/include/distributed/remote_transaction.h index 4adf10516..f827bd9ec 100644 --- a/src/include/distributed/remote_transaction.h +++ b/src/include/distributed/remote_transaction.h @@ -102,7 +102,6 @@ extern void RemoteTransactionListBegin(List *connectionList); extern void StartRemoteTransactionPrepare(struct MultiConnection *connection); extern void FinishRemoteTransactionPrepare(struct MultiConnection *connection); -extern void RemoteTransactionPrepare(struct MultiConnection *connection); extern void StartRemoteTransactionCommit(struct MultiConnection *connection); extern void FinishRemoteTransactionCommit(struct MultiConnection *connection); @@ -124,7 +123,6 @@ extern void HandleRemoteTransactionResultError(struct MultiConnection *connectio extern void MarkRemoteTransactionFailed(struct MultiConnection *connection, bool allowErrorPromotion); extern void MarkRemoteTransactionCritical(struct MultiConnection *connection); -extern bool IsRemoteTransactionCritical(struct MultiConnection *connection); /* diff --git a/src/include/distributed/resource_lock.h b/src/include/distributed/resource_lock.h index 010e318ae..ddfd7c1fa 100644 --- a/src/include/distributed/resource_lock.h +++ b/src/include/distributed/resource_lock.h @@ -100,7 +100,6 @@ typedef enum CitusOperations /* Lock shard/relation metadata for safe modifications */ extern void LockShardDistributionMetadata(int64 shardId, LOCKMODE lockMode); -extern bool TryLockShardDistributionMetadata(int64 shardId, LOCKMODE lockMode); extern void LockShardListMetadataOnWorkers(LOCKMODE lockmode, List *shardIntervalList); extern void BlockWritesToShardList(List *shardList); @@ -110,7 +109,6 @@ extern void LockReferencedReferenceShardDistributionMetadata(uint64 shardId, /* Lock shard data, for DML commands or remote fetches */ extern void LockShardResource(uint64 shardId, LOCKMODE lockmode); -extern void UnlockShardResource(uint64 shardId, LOCKMODE lockmode); /* Lock a job schema or partition task directory */ extern void LockJobResource(uint64 jobId, LOCKMODE lockmode); diff --git a/src/include/distributed/shardinterval_utils.h b/src/include/distributed/shardinterval_utils.h index 26d49416a..4cc99e6d5 100644 --- a/src/include/distributed/shardinterval_utils.h +++ b/src/include/distributed/shardinterval_utils.h @@ -38,7 +38,6 @@ typedef struct SortShardIntervalContext extern ShardInterval ** SortShardIntervalArray(ShardInterval **shardIntervalArray, int shardCount, Oid collation, FmgrInfo *shardIntervalSortCompareFunction); -extern ShardInterval * LowestShardIntervalById(List *shardIntervalList); extern int CompareShardIntervals(const void *leftElement, const void *rightElement, SortShardIntervalContext *sortContext); extern int CompareShardIntervalsById(const void *leftElement, const void *rightElement); diff --git a/src/include/distributed/transaction_management.h b/src/include/distributed/transaction_management.h index 317e5df69..a0a595fac 100644 --- a/src/include/distributed/transaction_management.h +++ b/src/include/distributed/transaction_management.h @@ -119,7 +119,6 @@ extern void EnsureDistributedTransactionId(void); extern void InitializeTransactionManagement(void); /* other functions */ -extern List * ActiveSubXacts(void); extern List * ActiveSubXactContexts(void); extern StringInfo BeginAndSetDistributedTransactionIdCommand(void); diff --git a/src/include/distributed/worker_protocol.h b/src/include/distributed/worker_protocol.h index 7cd88c3b3..192701fe2 100644 --- a/src/include/distributed/worker_protocol.h +++ b/src/include/distributed/worker_protocol.h @@ -113,7 +113,6 @@ extern StringInfo JobDirectoryName(uint64 jobId); extern StringInfo TaskDirectoryName(uint64 jobId, uint32 taskId); extern StringInfo PartitionFilename(StringInfo directoryName, uint32 partitionId); extern bool CacheDirectoryElement(const char *filename); -extern bool JobDirectoryElement(const char *filename); extern bool DirectoryExists(StringInfo directoryName); extern void CitusCreateDirectory(StringInfo directoryName); extern void CitusRemoveDirectory(const char *filename); @@ -123,8 +122,6 @@ extern Datum * DeconstructArrayObject(ArrayType *arrayObject); extern int32 ArrayObjectCount(ArrayType *arrayObject); extern FmgrInfo * GetFunctionInfo(Oid typeId, Oid accessMethodId, int16 procedureId); extern uint64 ExtractShardIdFromTableName(const char *tableName, bool missingOk); -extern List * TableDDLCommandList(const char *nodeName, uint32 nodePort, - const char *tableName); extern void RepartitionCleanupJobDirectories(void);