mirror of https://github.com/citusdata/citus.git
Adds AlterTableStmtObjType macro
AlterTableStmt's relkind field is changed into objtype New AlterTableStmtObjType macro uses the appropriate one Relevant PG commit: cc35d8933a211d9965eb1c1d2749a903d5735db2pull/5209/head
parent
1b6c8348fb
commit
63cdb4b70a
|
@ -15,6 +15,7 @@
|
|||
#include "distributed/commands.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/pg_version_constants.h"
|
||||
#include "distributed/version_compat.h"
|
||||
|
||||
static DistributeObjectOps NoDistributeOps = {
|
||||
.deparse = NULL,
|
||||
|
@ -772,7 +773,7 @@ GetDistributeObjectOps(Node *node)
|
|||
case T_AlterTableStmt:
|
||||
{
|
||||
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
||||
switch (stmt->relkind)
|
||||
switch (AlterTableStmtObjType_compat(stmt))
|
||||
{
|
||||
case OBJECT_TYPE:
|
||||
{
|
||||
|
|
|
@ -595,7 +595,7 @@ PreprocessAlterSequenceOwnerStmt(Node *node, const char *queryString,
|
|||
ProcessUtilityContext processUtilityContext)
|
||||
{
|
||||
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
||||
Assert(stmt->relkind == OBJECT_SEQUENCE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_SEQUENCE);
|
||||
|
||||
ObjectAddress sequenceAddress = GetObjectAddressFromParseTree((Node *) stmt, false);
|
||||
if (!ShouldPropagateObject(&sequenceAddress))
|
||||
|
@ -623,7 +623,7 @@ ObjectAddress
|
|||
AlterSequenceOwnerStmtObjectAddress(Node *node, bool missing_ok)
|
||||
{
|
||||
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
||||
Assert(stmt->relkind == OBJECT_SEQUENCE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_SEQUENCE);
|
||||
|
||||
RangeVar *sequence = stmt->relation;
|
||||
Oid seqOid = RangeVarGetRelid(sequence, NoLock, missing_ok);
|
||||
|
@ -643,7 +643,7 @@ List *
|
|||
PostprocessAlterSequenceOwnerStmt(Node *node, const char *queryString)
|
||||
{
|
||||
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
||||
Assert(stmt->relkind == OBJECT_SEQUENCE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_SEQUENCE);
|
||||
|
||||
ObjectAddress sequenceAddress = GetObjectAddressFromParseTree((Node *) stmt, false);
|
||||
if (!ShouldPropagateObject(&sequenceAddress))
|
||||
|
|
|
@ -536,7 +536,7 @@ PreprocessAlterTableStmt(Node *node, const char *alterTableCommand,
|
|||
if (get_rel_relkind(leftRelationId) == RELKIND_SEQUENCE)
|
||||
{
|
||||
AlterTableStmt *stmtCopy = copyObject(alterTableStatement);
|
||||
stmtCopy->relkind = OBJECT_SEQUENCE;
|
||||
AlterTableStmtObjType_compat(stmtCopy) = OBJECT_SEQUENCE;
|
||||
return PreprocessAlterSequenceOwnerStmt((Node *) stmtCopy, alterTableCommand,
|
||||
processUtilityContext);
|
||||
}
|
||||
|
@ -1629,7 +1629,7 @@ PostprocessAlterTableStmt(AlterTableStmt *alterTableStatement)
|
|||
*/
|
||||
if (get_rel_relkind(relationId) == RELKIND_SEQUENCE)
|
||||
{
|
||||
alterTableStatement->relkind = OBJECT_SEQUENCE;
|
||||
AlterTableStmtObjType_compat(alterTableStatement) = OBJECT_SEQUENCE;
|
||||
PostprocessAlterSequenceOwnerStmt((Node *) alterTableStatement, NULL);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ PreprocessAlterTypeStmt(Node *node, const char *queryString,
|
|||
ProcessUtilityContext processUtilityContext)
|
||||
{
|
||||
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
||||
Assert(stmt->relkind == OBJECT_TYPE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_TYPE);
|
||||
|
||||
ObjectAddress typeAddress = GetObjectAddressFromParseTree((Node *) stmt, false);
|
||||
if (!ShouldPropagateObject(&typeAddress))
|
||||
|
@ -789,7 +789,7 @@ ObjectAddress
|
|||
AlterTypeStmtObjectAddress(Node *node, bool missing_ok)
|
||||
{
|
||||
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
||||
Assert(stmt->relkind == OBJECT_TYPE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_TYPE);
|
||||
|
||||
TypeName *typeName = MakeTypeNameFromRangeVar(stmt->relation);
|
||||
Oid typeOid = LookupTypeNameOid(NULL, typeName, missing_ok);
|
||||
|
|
|
@ -484,8 +484,8 @@ ProcessUtilityInternal(PlannedStmt *pstmt,
|
|||
if (IsA(parsetree, AlterTableStmt))
|
||||
{
|
||||
AlterTableStmt *alterTableStmt = (AlterTableStmt *) parsetree;
|
||||
if (alterTableStmt->relkind == OBJECT_TABLE ||
|
||||
alterTableStmt->relkind == OBJECT_FOREIGN_TABLE)
|
||||
if (AlterTableStmtObjType_compat(alterTableStmt) == OBJECT_TABLE ||
|
||||
AlterTableStmtObjType_compat(alterTableStmt) == OBJECT_FOREIGN_TABLE)
|
||||
{
|
||||
ErrorIfAlterDropsPartitionColumn(alterTableStmt);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "catalog/namespace.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "utils/acl.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/lsyscache.h"
|
||||
|
@ -193,7 +194,7 @@ DeparseAlterSequenceOwnerStmt(Node *node)
|
|||
StringInfoData str = { 0 };
|
||||
initStringInfo(&str);
|
||||
|
||||
Assert(stmt->relkind == OBJECT_SEQUENCE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_SEQUENCE);
|
||||
|
||||
AppendAlterSequenceOwnerStmt(&str, stmt);
|
||||
|
||||
|
@ -208,7 +209,7 @@ DeparseAlterSequenceOwnerStmt(Node *node)
|
|||
static void
|
||||
AppendAlterSequenceOwnerStmt(StringInfo buf, AlterTableStmt *stmt)
|
||||
{
|
||||
Assert(stmt->relkind == OBJECT_SEQUENCE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_SEQUENCE);
|
||||
RangeVar *seq = stmt->relation;
|
||||
char *qualifiedSequenceName = quote_qualified_identifier(seq->schemaname,
|
||||
seq->relname);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "postgres.h"
|
||||
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "nodes/nodes.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "parser/parse_type.h"
|
||||
|
@ -63,7 +64,7 @@ DeparseAlterTableStmt(Node *node)
|
|||
StringInfoData str = { 0 };
|
||||
initStringInfo(&str);
|
||||
|
||||
Assert(stmt->relkind == OBJECT_TABLE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_TABLE);
|
||||
|
||||
AppendAlterTableStmt(&str, stmt);
|
||||
return str.data;
|
||||
|
@ -82,7 +83,7 @@ AppendAlterTableStmt(StringInfo buf, AlterTableStmt *stmt)
|
|||
stmt->relation->relname);
|
||||
ListCell *cmdCell = NULL;
|
||||
|
||||
Assert(stmt->relkind == OBJECT_TABLE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_TABLE);
|
||||
|
||||
appendStringInfo(buf, "ALTER TABLE %s", identifier);
|
||||
foreach(cmdCell, stmt->cmds)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "distributed/citus_ruleutils.h"
|
||||
#include "distributed/commands.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/version_compat.h"
|
||||
|
||||
#define AlterEnumIsRename(stmt) (stmt->oldVal != NULL)
|
||||
#define AlterEnumIsAddValue(stmt) (stmt->oldVal == NULL)
|
||||
|
@ -121,7 +122,7 @@ DeparseAlterTypeStmt(Node *node)
|
|||
StringInfoData str = { 0 };
|
||||
initStringInfo(&str);
|
||||
|
||||
Assert(stmt->relkind == OBJECT_TYPE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_TYPE);
|
||||
|
||||
AppendAlterTypeStmt(&str, stmt);
|
||||
|
||||
|
@ -136,7 +137,7 @@ AppendAlterTypeStmt(StringInfo buf, AlterTableStmt *stmt)
|
|||
stmt->relation->relname);
|
||||
ListCell *cmdCell = NULL;
|
||||
|
||||
Assert(stmt->relkind == OBJECT_TYPE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_TYPE);
|
||||
|
||||
appendStringInfo(buf, "ALTER TYPE %s", identifier);
|
||||
foreach(cmdCell, stmt->cmds)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "postgres.h"
|
||||
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "parser/parse_func.h"
|
||||
#include "utils/lsyscache.h"
|
||||
|
||||
|
@ -31,7 +32,7 @@ void
|
|||
QualifyAlterSequenceOwnerStmt(Node *node)
|
||||
{
|
||||
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
||||
Assert(stmt->relkind == OBJECT_SEQUENCE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_SEQUENCE);
|
||||
|
||||
RangeVar *seq = stmt->relation;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "catalog/pg_type.h"
|
||||
#include "distributed/commands.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "parser/parse_type.h"
|
||||
#include "utils/syscache.h"
|
||||
|
@ -125,7 +126,7 @@ void
|
|||
QualifyAlterTypeStmt(Node *node)
|
||||
{
|
||||
AlterTableStmt *stmt = castNode(AlterTableStmt, node);
|
||||
Assert(stmt->relkind == OBJECT_TYPE);
|
||||
Assert(AlterTableStmtObjType_compat(stmt) == OBJECT_TYPE);
|
||||
|
||||
if (stmt->relation->schemaname == NULL)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
#endif
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
#define AlterTableStmtObjType(a) ((a)->objtype)
|
||||
#else
|
||||
#define AlterTableStmtObjType(a) ((a)->relkind)
|
||||
#endif
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_13
|
||||
|
|
Loading…
Reference in New Issue