mirror of https://github.com/citusdata/citus.git
allow "alter table set schema" from any node for Postgres tables - postgres tables
parent
0629766e57
commit
c14b135780
|
|
@ -4330,11 +4330,6 @@ ConvertToTenantTableIfNecessary(AlterObjectSchemaStmt *stmt)
|
|||
{
|
||||
Assert(stmt->objectType == OBJECT_TABLE || stmt->objectType == OBJECT_FOREIGN_TABLE);
|
||||
|
||||
if (!IsCoordinator())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* We will let Postgres deal with missing_ok
|
||||
*/
|
||||
|
|
@ -4345,16 +4340,24 @@ ConvertToTenantTableIfNecessary(AlterObjectSchemaStmt *stmt)
|
|||
|
||||
/* We have already asserted that we have exactly 1 address in the addresses. */
|
||||
ObjectAddress *tableAddress = linitial(tableAddresses);
|
||||
char relKind = get_rel_relkind(tableAddress->objectId);
|
||||
|
||||
Oid relationId = tableAddress->objectId;
|
||||
if (!OidIsValid(relationId))
|
||||
{
|
||||
Assert(stmt->missing_ok);
|
||||
return;
|
||||
}
|
||||
|
||||
char relKind = get_rel_relkind(relationId);
|
||||
if (relKind == RELKIND_SEQUENCE || relKind == RELKIND_VIEW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Oid relationId = tableAddress->objectId;
|
||||
Oid schemaId = get_namespace_oid(stmt->newschema, stmt->missing_ok);
|
||||
if (!OidIsValid(schemaId))
|
||||
{
|
||||
Assert(stmt->missing_ok);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -4364,16 +4367,22 @@ ConvertToTenantTableIfNecessary(AlterObjectSchemaStmt *stmt)
|
|||
* that by seeing the table is still a single shard table. (i.e. not undistributed
|
||||
* at `preprocess` step)
|
||||
*/
|
||||
if (!IsCitusTableType(relationId, SINGLE_SHARD_DISTRIBUTED) &&
|
||||
IsTenantSchema(schemaId))
|
||||
if (IsCitusTableType(relationId, SINGLE_SHARD_DISTRIBUTED))
|
||||
{
|
||||
EnsureTenantTable(relationId, "ALTER TABLE SET SCHEMA");
|
||||
|
||||
char *schemaName = get_namespace_name(schemaId);
|
||||
char *tableName = stmt->relation->relname;
|
||||
ereport(NOTICE, (errmsg("Moving %s into distributed schema %s",
|
||||
tableName, schemaName)));
|
||||
|
||||
CreateTenantSchemaTable(relationId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ShouldCreateTenantSchemaTable(relationId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureTenantTable(relationId, "ALTER TABLE SET SCHEMA");
|
||||
|
||||
char *schemaName = get_namespace_name(schemaId);
|
||||
char *tableName = stmt->relation->relname;
|
||||
ereport(NOTICE, (errmsg("Moving %s into distributed schema %s",
|
||||
tableName, schemaName)));
|
||||
|
||||
CreateTenantSchemaTable(relationId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue