mirror of https://github.com/citusdata/citus.git
Fixes the non existing table bug (#4058)
parent
770610ab11
commit
e9f89ed651
|
@ -269,7 +269,10 @@ PostprocessAlterTableSchemaStmt(Node *node, const char *queryString)
|
|||
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
|
||||
Assert(stmt->objectType == OBJECT_TABLE);
|
||||
|
||||
ObjectAddress tableAddress = GetObjectAddressFromParseTree((Node *) stmt, false);
|
||||
/*
|
||||
* We will let Postgres deal with missing_ok
|
||||
*/
|
||||
ObjectAddress tableAddress = GetObjectAddressFromParseTree((Node *) stmt, true);
|
||||
|
||||
if (!ShouldPropagate() || !IsCitusTable(tableAddress.objectId))
|
||||
{
|
||||
|
@ -1481,7 +1484,7 @@ AlterTableSchemaStmtObjectAddress(Node *node, bool missing_ok)
|
|||
if (stmt->relation->schemaname)
|
||||
{
|
||||
const char *schemaName = stmt->relation->schemaname;
|
||||
Oid schemaOid = get_namespace_oid(schemaName, false);
|
||||
Oid schemaOid = get_namespace_oid(schemaName, missing_ok);
|
||||
tableOid = get_relname_relid(tableName, schemaOid);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1196,6 +1196,25 @@ ALTER TABLE existing_schema.non_existent_table SET SCHEMA non_existent_schema;
|
|||
ERROR: relation "existing_schema.non_existent_table" does not exist
|
||||
ALTER TABLE existing_schema.table_set_schema SET SCHEMA non_existent_schema;
|
||||
ERROR: schema "non_existent_schema" does not exist
|
||||
-- test ALTER TABLE IF EXISTS SET SCHEMA with nonexisting schemas and table
|
||||
ALTER TABLE IF EXISTS non_existent_schema.table_set_schema SET SCHEMA another_existing_schema;
|
||||
NOTICE: relation "table_set_schema" does not exist, skipping
|
||||
ALTER TABLE IF EXISTS non_existent_schema.non_existent_table SET SCHEMA another_existing_schema;
|
||||
NOTICE: relation "non_existent_table" does not exist, skipping
|
||||
ALTER TABLE IF EXISTS non_existent_schema.table_set_schema SET SCHEMA another_non_existent_schema;
|
||||
NOTICE: relation "table_set_schema" does not exist, skipping
|
||||
ALTER TABLE IF EXISTS non_existent_schema.non_existent_table SET SCHEMA another_non_existent_schema;
|
||||
NOTICE: relation "non_existent_table" does not exist, skipping
|
||||
ALTER TABLE IF EXISTS existing_schema.non_existent_table SET SCHEMA another_existing_schema;
|
||||
NOTICE: relation "non_existent_table" does not exist, skipping
|
||||
ALTER TABLE IF EXISTS existing_schema.non_existent_table SET SCHEMA non_existent_schema;
|
||||
NOTICE: relation "non_existent_table" does not exist, skipping
|
||||
ALTER TABLE IF EXISTS existing_schema.table_set_schema SET SCHEMA non_existent_schema;
|
||||
ERROR: schema "non_existent_schema" does not exist
|
||||
ALTER TABLE IF EXISTS non_existent_table SET SCHEMA another_existing_schema;
|
||||
NOTICE: relation "non_existent_table" does not exist, skipping
|
||||
ALTER TABLE IF EXISTS non_existent_table SET SCHEMA non_existent_schema;
|
||||
NOTICE: relation "non_existent_table" does not exist, skipping
|
||||
DROP SCHEMA existing_schema, another_existing_schema CASCADE;
|
||||
NOTICE: drop cascades to table existing_schema.table_set_schema
|
||||
-- test ALTER TABLE SET SCHEMA with interesting names
|
||||
|
|
|
@ -842,6 +842,18 @@ ALTER TABLE non_existent_schema.non_existent_table SET SCHEMA another_non_existe
|
|||
ALTER TABLE existing_schema.non_existent_table SET SCHEMA another_existing_schema;
|
||||
ALTER TABLE existing_schema.non_existent_table SET SCHEMA non_existent_schema;
|
||||
ALTER TABLE existing_schema.table_set_schema SET SCHEMA non_existent_schema;
|
||||
|
||||
|
||||
-- test ALTER TABLE IF EXISTS SET SCHEMA with nonexisting schemas and table
|
||||
ALTER TABLE IF EXISTS non_existent_schema.table_set_schema SET SCHEMA another_existing_schema;
|
||||
ALTER TABLE IF EXISTS non_existent_schema.non_existent_table SET SCHEMA another_existing_schema;
|
||||
ALTER TABLE IF EXISTS non_existent_schema.table_set_schema SET SCHEMA another_non_existent_schema;
|
||||
ALTER TABLE IF EXISTS non_existent_schema.non_existent_table SET SCHEMA another_non_existent_schema;
|
||||
ALTER TABLE IF EXISTS existing_schema.non_existent_table SET SCHEMA another_existing_schema;
|
||||
ALTER TABLE IF EXISTS existing_schema.non_existent_table SET SCHEMA non_existent_schema;
|
||||
ALTER TABLE IF EXISTS existing_schema.table_set_schema SET SCHEMA non_existent_schema;
|
||||
ALTER TABLE IF EXISTS non_existent_table SET SCHEMA another_existing_schema;
|
||||
ALTER TABLE IF EXISTS non_existent_table SET SCHEMA non_existent_schema;
|
||||
DROP SCHEMA existing_schema, another_existing_schema CASCADE;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue