move MakeNameListFromRangeVar function to a more appropriate file

pull/3644/head
Onur Tirtir 2020-03-17 15:20:27 +03:00
parent 2396b66ac5
commit 52fd58d51f
7 changed files with 31 additions and 58 deletions

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

@ -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

@ -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 */