mirror of https://github.com/citusdata/citus.git
Change alter check position
Alter table checks are implemented after master commandpull/1288/head
parent
8f7e69fd0d
commit
e8aa52f90e
|
@ -379,7 +379,6 @@ multi_ProcessUtility(Node *parsetree,
|
||||||
ErrorIfUnsupportedAlterTableStmt(alterTableStatement);
|
ErrorIfUnsupportedAlterTableStmt(alterTableStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (commandMustRunAsOwner)
|
if (commandMustRunAsOwner)
|
||||||
{
|
{
|
||||||
SetUserIdAndSecContext(savedUserId, savedSecurityContext);
|
SetUserIdAndSecContext(savedUserId, savedSecurityContext);
|
||||||
|
@ -1379,6 +1378,19 @@ ErrorIfUnsupportedAlterTableStmt(AlterTableStmt *alterTableStatement)
|
||||||
{
|
{
|
||||||
List *commandList = alterTableStatement->cmds;
|
List *commandList = alterTableStatement->cmds;
|
||||||
ListCell *commandCell = NULL;
|
ListCell *commandCell = NULL;
|
||||||
|
Oid leftRelationId = InvalidOid;
|
||||||
|
bool isDistributedRelation = false;
|
||||||
|
LOCKMODE lockmode = 0;
|
||||||
|
|
||||||
|
/* error out if table is not distributed */
|
||||||
|
lockmode = AlterTableGetLockLevel(alterTableStatement->cmds);
|
||||||
|
leftRelationId = AlterTableLookupRelation(alterTableStatement, lockmode);
|
||||||
|
|
||||||
|
isDistributedRelation = IsDistributedTable(leftRelationId);
|
||||||
|
if(!isDistributedRelation)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* error out if any of the subcommands are unsupported */
|
/* error out if any of the subcommands are unsupported */
|
||||||
foreach(commandCell, commandList)
|
foreach(commandCell, commandList)
|
||||||
|
@ -1482,31 +1494,28 @@ ErrorIfUnsupportedAlterTableStmt(AlterTableStmt *alterTableStatement)
|
||||||
|
|
||||||
Constraint *constraint = (Constraint *) command->def;
|
Constraint *constraint = (Constraint *) command->def;
|
||||||
|
|
||||||
/* extra checks for alter table */
|
|
||||||
if (constraint->contype == CONSTR_FOREIGN)
|
/* we only allow foreign constraints if they are only subcommand */
|
||||||
|
if (commandList->length > 1)
|
||||||
{
|
{
|
||||||
/* we only allow foreign constraints if they are only subcommand */
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
if (commandList->length > 1)
|
errmsg("cannot create constraint"),
|
||||||
{
|
errdetail("Citus cannot execute ADD CONSTRAINT "
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
"command together with other subcommands."),
|
||||||
errmsg("cannot create foreign key constraint"),
|
errhint("You can issue each subcommand separately")));
|
||||||
errdetail("Citus cannot execute ADD CONSTRAINT "
|
}
|
||||||
"FOREIGN KEY command together with other "
|
|
||||||
"subcommands."),
|
/*
|
||||||
errhint("You can issue each subcommand separately")));
|
* We will use constraint name in each placement by extending it at
|
||||||
}
|
* workers. Therefore we require it to be exist.
|
||||||
/*
|
*/
|
||||||
* We will use constraint name in each placement by extending it at
|
if (constraint->conname == NULL)
|
||||||
* workers. Therefore we require it to be exist.
|
{
|
||||||
*/
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
if (constraint->conname == NULL)
|
errmsg("cannot create constraint"),
|
||||||
{
|
errdetail("Creating constraint without a name on a "
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
"distributed table is currently not "
|
||||||
errmsg("cannot create foreign key constraint"),
|
"supported.")));
|
||||||
errdetail("Creating foreign constraint without a "
|
|
||||||
"name on a distributed table is currently "
|
|
||||||
"not supported.")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorIfNotSupportedConstraint(relation, distributionMethod,
|
ErrorIfNotSupportedConstraint(relation, distributionMethod,
|
||||||
|
|
Loading…
Reference in New Issue