Merge pull request #3644 from citusdata/refactor/small-typos-etc

Move MakeNameListFromRangeVar function and some other small changes
pull/3648/head
Onur Tirtir 2020-03-25 11:36:50 +03:00 committed by GitHub
commit eaaf302795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 41 additions and 80 deletions

View File

@ -167,7 +167,7 @@ CallFuncExprRemotely(CallStmt *callStmt, DistObjectCacheEntry *procedure,
Task *task = CitusMakeNode(Task); Task *task = CitusMakeNode(Task);
task->jobId = INVALID_JOB_ID; task->jobId = INVALID_JOB_ID;
task->taskId = 0; task->taskId = INVALID_TASK_ID;
task->taskType = DDL_TASK; task->taskType = DDL_TASK;
SetTaskQueryString(task, callCommand->data); SetTaskQueryString(task, callCommand->data);
task->replicationModel = REPLICATION_MODEL_INVALID; task->replicationModel = REPLICATION_MODEL_INVALID;

View File

@ -619,7 +619,7 @@ ColocationIdForNewTable(Oid relationId, Var *distributionColumn,
* distributing table here. If there is an unsatisfied requirement, we error out * distributing table here. If there is an unsatisfied requirement, we error out
* and do not distribute the table. * and do not distribute the table.
* *
* This function assumes, callers have already acquried necessary locks to ensure * This function assumes, callers have already acquired necessary locks to ensure
* there will not be any change in the given relation. * there will not be any change in the given relation.
*/ */
static void static void

View File

@ -1503,3 +1503,32 @@ AlterTableSchemaStmtObjectAddress(Node *node, bool missing_ok)
return address; return address;
} }
/*
* MakeNameListFromRangeVar makes a namelist from a RangeVar. Its behaviour
* should be the exact opposite of postgres' makeRangeVarFromNameList.
*/
List *
MakeNameListFromRangeVar(const RangeVar *rel)
{
if (rel->catalogname != NULL)
{
Assert(rel->schemaname != NULL);
Assert(rel->relname != NULL);
return list_make3(makeString(rel->catalogname),
makeString(rel->schemaname),
makeString(rel->relname));
}
else if (rel->schemaname != NULL)
{
Assert(rel->relname != NULL);
return list_make2(makeString(rel->schemaname),
makeString(rel->relname));
}
else
{
Assert(rel->relname != NULL);
return list_make1(makeString(rel->relname));
}
}

View File

@ -56,7 +56,6 @@
#include "distributed/deparser.h" #include "distributed/deparser.h"
#include "distributed/listutils.h" #include "distributed/listutils.h"
#include "distributed/metadata/distobject.h" #include "distributed/metadata/distobject.h"
#include "distributed/metadata/namespace.h"
#include "distributed/metadata_sync.h" #include "distributed/metadata_sync.h"
#include "distributed/multi_executor.h" #include "distributed/multi_executor.h"
#include "distributed/relation_access_tracking.h" #include "distributed/relation_access_tracking.h"

View File

@ -26,7 +26,6 @@
#include "distributed/citus_ruleutils.h" #include "distributed/citus_ruleutils.h"
#include "distributed/commands.h" #include "distributed/commands.h"
#include "distributed/deparser.h" #include "distributed/deparser.h"
#include "distributed/metadata/namespace.h"
#define AlterEnumIsRename(stmt) (stmt->oldVal != NULL) #define AlterEnumIsRename(stmt) (stmt->oldVal != NULL)
#define AlterEnumIsAddValue(stmt) (stmt->oldVal == NULL) #define AlterEnumIsAddValue(stmt) (stmt->oldVal == NULL)

View File

@ -23,8 +23,8 @@
#include "catalog/namespace.h" #include "catalog/namespace.h"
#include "catalog/objectaddress.h" #include "catalog/objectaddress.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "distributed/commands.h"
#include "distributed/deparser.h" #include "distributed/deparser.h"
#include "distributed/metadata/namespace.h"
#include "nodes/makefuncs.h" #include "nodes/makefuncs.h"
#include "parser/parse_type.h" #include "parser/parse_type.h"
#include "utils/syscache.h" #include "utils/syscache.h"

View File

@ -2015,7 +2015,7 @@ ShouldRunTasksSequentially(List *taskList)
/* /*
* SequentialRunDistributedExecution gets a distributed execution and * SequentialRunDistributedExecution gets a distributed execution and
* executes each individual task in the exection sequentially, one * executes each individual task in the execution sequentially, one
* task at a time. See related function ShouldRunTasksSequentially() * task at a time. See related function ShouldRunTasksSequentially()
* for more detail on the definition of SequentialRun. * for more detail on the definition of SequentialRun.
*/ */

View File

@ -352,14 +352,8 @@ LocallyExecuteUtilityTask(const char *localTaskQueryCommand)
else else
{ {
/* /*
* It is a regular utility command or SELECT query with non-udf, * It is a regular utility command we should execute it locally via
* targets, then we should execute it locally via process utility. * process utility.
*
* If it is a regular utility command, CitusProcessUtility is the
* appropriate function to process that command. However, if it's
* a SELECT query with non-udf targets, CitusProcessUtility would
* error out as we are not expecting such SELECT queries triggered
* by utility commands.
*/ */
CitusProcessUtility(localTaskRawParseTree, localTaskQueryCommand, CitusProcessUtility(localTaskRawParseTree, localTaskQueryCommand,
PROCESS_UTILITY_TOPLEVEL, NULL, None_Receiver, NULL); PROCESS_UTILITY_TOPLEVEL, NULL, None_Receiver, NULL);

View File

@ -216,7 +216,6 @@ master_drop_all_shards(PG_FUNCTION_ARGS)
text *schemaNameText = PG_GETARG_TEXT_P(1); text *schemaNameText = PG_GETARG_TEXT_P(1);
text *relationNameText = PG_GETARG_TEXT_P(2); text *relationNameText = PG_GETARG_TEXT_P(2);
char *schemaName = text_to_cstring(schemaNameText); char *schemaName = text_to_cstring(schemaNameText);
char *relationName = text_to_cstring(relationNameText); char *relationName = text_to_cstring(relationNameText);
@ -237,7 +236,7 @@ master_drop_all_shards(PG_FUNCTION_ARGS)
/* /*
* master_drop_all_shards is typically called from the DROP TABLE trigger, * master_drop_all_shards is typically called from the DROP TABLE trigger,
* but could be called by a user directly. Make sure we have an * but could be called by a user directly. Make sure we have an
* AccessExlusiveLock to prevent any other commands from running on this table * AccessExclusiveLock to prevent any other commands from running on this table
* concurrently. * concurrently.
*/ */
LockRelationOid(relationId, AccessExclusiveLock); LockRelationOid(relationId, AccessExclusiveLock);

View File

@ -1,35 +0,0 @@
#include "postgres.h"
#include "nodes/primnodes.h"
#include "nodes/value.h"
#include "distributed/metadata/namespace.h"
/*
* MakeNameListFromRangeVar makes a namelist from a RangeVar. Its behaviour should be the
* exact opposite of postgres' makeRangeVarFromNameList.
*/
List *
MakeNameListFromRangeVar(const RangeVar *rel)
{
if (rel->catalogname != NULL)
{
Assert(rel->schemaname != NULL);
Assert(rel->relname != NULL);
return list_make3(makeString(rel->catalogname),
makeString(rel->schemaname),
makeString(rel->relname));
}
else if (rel->schemaname != NULL)
{
Assert(rel->relname != NULL);
return list_make2(makeString(rel->schemaname),
makeString(rel->relname));
}
else
{
Assert(rel->relname != NULL);
return list_make1(makeString(rel->relname));
}
}

View File

@ -368,11 +368,7 @@ ResetVisitedFields(HTAB *adjacencyList)
static bool static bool
AssociateDistributedTransactionWithBackendProc(TransactionNode *transactionNode) AssociateDistributedTransactionWithBackendProc(TransactionNode *transactionNode)
{ {
#ifdef USE_ASSERT_CHECKING int32 localGroupId PG_USED_FOR_ASSERTS_ONLY = GetLocalGroupId();
/* if assertions are disabled, it would give unused variable warning */
int32 localGroupId = GetLocalGroupId();
#endif
for (int backendIndex = 0; backendIndex < MaxBackends; ++backendIndex) for (int backendIndex = 0; backendIndex < MaxBackends; ++backendIndex)
{ {

View File

@ -31,11 +31,9 @@
#include "utils/rel.h" #include "utils/rel.h"
#include "utils/syscache.h" #include "utils/syscache.h"
static char * PartitionBound(Oid partitionId); static char * PartitionBound(Oid partitionId);
static Relation try_relation_open_nolock(Oid relationId); static Relation try_relation_open_nolock(Oid relationId);
/* /*
* Returns true if the given relation is a partitioned table. * Returns true if the given relation is a partitioned table.
*/ */
@ -43,7 +41,6 @@ bool
PartitionedTable(Oid relationId) PartitionedTable(Oid relationId)
{ {
Relation rel = try_relation_open(relationId, AccessShareLock); Relation rel = try_relation_open(relationId, AccessShareLock);
bool partitionedTable = false;
/* don't error out for tables that are dropped */ /* don't error out for tables that are dropped */
if (rel == NULL) if (rel == NULL)
@ -51,6 +48,8 @@ PartitionedTable(Oid relationId)
return false; return false;
} }
bool partitionedTable = false;
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE) if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{ {
partitionedTable = true; partitionedTable = true;

View File

@ -28,7 +28,7 @@ PG_FUNCTION_INFO_V1(worker_create_truncate_trigger);
/* /*
* worker_create_truncate_trigger creates a truncate trigger for the given distributed * worker_create_truncate_trigger creates a truncate trigger for the given distributed
* table on current metadata worker. The function is intented to be called by the * table on current metadata worker. The function is intended to be called by the
* coordinator node during metadata propagation of mx tables or during the upgrades from * coordinator node during metadata propagation of mx tables or during the upgrades from
* citus version <=5.2 to >=6.1. The function requires superuser permissions. * citus version <=5.2 to >=6.1. The function requires superuser permissions.
*/ */

View File

@ -226,6 +226,7 @@ extern void ErrorIfUnsupportedConstraint(Relation relation, char distributionMet
Var *distributionColumn, uint32 colocationId); Var *distributionColumn, uint32 colocationId);
extern ObjectAddress AlterTableSchemaStmtObjectAddress(Node *stmt, extern ObjectAddress AlterTableSchemaStmtObjectAddress(Node *stmt,
bool missing_ok); bool missing_ok);
extern List * MakeNameListFromRangeVar(const RangeVar *rel);
/* truncate.c - forward declarations */ /* truncate.c - forward declarations */

View File

@ -1,20 +0,0 @@
/*-------------------------------------------------------------------------
*
* namespace.h
* Helper functions for citus to work with postgres namespaces/schemas
*
* Copyright (c) Citus Data, Inc.
*
*-------------------------------------------------------------------------
*/
#ifndef CITUS_NAMESPACE_H
#define CITUS_NAMESPACE_H
#include "postgres.h"
#include "nodes/primnodes.h"
extern List * MakeNameListFromRangeVar(const RangeVar *rel);
#endif /*CITUS_NAMESPACE_H */