Cover cases: ALTER TABLE .. ADD CONSTRAINT ..

talha_tes1
Ahmet Gedemenli 2021-09-24 16:59:04 +03:00
parent 2d20fa37ad
commit e07d5c8530
4 changed files with 13 additions and 1 deletions

View File

@ -448,6 +448,15 @@ ErrorIfAddingPartitionTableToMetadata(Oid relationId)
} }
/*
* SetAutoConverted is the setter function for variable autoConverted.
*/
void SetAutoConverted(bool autoConvertedValue)
{
autoConverted = autoConvertedValue;
}
/* /*
* ErrorIfUnsupportedCreateCitusLocalTable errors out if we cannot create the * ErrorIfUnsupportedCreateCitusLocalTable errors out if we cannot create the
* citus local table from the relation. * citus local table from the relation.

View File

@ -1289,7 +1289,9 @@ ConvertPostgresLocalTablesToCitusLocalTables(AlterTableStmt *alterTableStatement
} }
else else
{ {
SetAutoConverted(true);
CreateCitusLocalTable(relationId, cascade); CreateCitusLocalTable(relationId, cascade);
SetAutoConverted(false);
} }
} }
PG_CATCH(); PG_CATCH();

View File

@ -533,6 +533,7 @@ extern void ExecuteForeignKeyCreateCommandList(List *ddlCommandList,
bool skip_validation); bool skip_validation);
/* create_citus_local_table.c */ /* create_citus_local_table.c */
extern void SetAutoConverted(bool autoConvertedValue);
extern void CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys); extern void CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys);
extern List * GetExplicitIndexOidList(Oid relationId); extern List * GetExplicitIndexOidList(Oid relationId);

View File

@ -317,7 +317,7 @@ BEGIN;
SET client_min_messages TO ERROR; SET client_min_messages TO ERROR;
SELECT remove_local_tables_from_metadata(); SELECT remove_local_tables_from_metadata();
-- should not see any citus local tables -- should see only local_table_3, since it's the only one that is converted by the user
SELECT logicalrelid::regclass::text FROM pg_dist_partition, pg_tables SELECT logicalrelid::regclass::text FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND WHERE tablename=logicalrelid::regclass::text AND
schemaname='citus_local_tables_test_schema' AND schemaname='citus_local_tables_test_schema' AND