Error out if inheriting a distributed table (#4871)

* Error out if inheriting a distributed table

* Add test inheriting a distirbuted table
pull/4873/head
Ahmet Gedemenli 2021-04-07 11:21:06 +03:00 committed by GitHub
parent e4c4a9b683
commit 52e467a9a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 3 deletions

View File

@ -184,10 +184,32 @@ PostprocessCreateTableStmt(CreateStmt *createStatement, const char *queryString)
{
PostprocessCreateTableStmtForeignKeys(createStatement);
if (createStatement->inhRelations != NIL && createStatement->partbound != NULL)
if (createStatement->inhRelations != NIL)
{
/* process CREATE TABLE ... PARTITION OF command */
PostprocessCreateTableStmtPartitionOf(createStatement, queryString);
if (createStatement->partbound != NULL)
{
/* process CREATE TABLE ... PARTITION OF command */
PostprocessCreateTableStmtPartitionOf(createStatement, queryString);
}
else
{
/* process CREATE TABLE ... INHERITS ... */
RangeVar *parentRelation = NULL;
foreach_ptr(parentRelation, createStatement->inhRelations)
{
bool missingOk = false;
Oid parentRelationId = RangeVarGetRelid(parentRelation, NoLock,
missingOk);
Assert(parentRelationId != InvalidOid);
if (IsCitusTable(parentRelationId))
{
/* here we error out if inheriting a distributed table */
ereport(ERROR, (errmsg("non-distributed tables cannot inherit "
"distributed tables")));
}
}
}
}
}

View File

@ -2067,6 +2067,17 @@ SELECT * FROM time_partition_range('list_partitioned_p1');
ERROR: relation "list_partitioned_p1" is not a range partition
DETAIL: time_partition_range can only be used for partitions of range-partitioned tables with a single partition column
DROP TABLE list_partitioned;
-- error out when inheriting a distributed table
CREATE TABLE test_inheritance(a int, b int);
SELECT create_distributed_table('test_inheritance','a');
create_distributed_table
---------------------------------------------------------------------
(1 row)
CREATE TABLE local_inheritance (k int) INHERITS (test_inheritance);
ERROR: non-distributed tables cannot inherit distributed tables
DROP TABLE test_inheritance;
DROP SCHEMA partitioning_schema CASCADE;
NOTICE: drop cascades to table partitioning_schema."schema-test"
DROP TABLE IF EXISTS

View File

@ -1219,6 +1219,12 @@ SELECT parent_table, partition_column, partition, from_value, to_value FROM time
SELECT * FROM time_partition_range('list_partitioned_p1');
DROP TABLE list_partitioned;
-- error out when inheriting a distributed table
CREATE TABLE test_inheritance(a int, b int);
SELECT create_distributed_table('test_inheritance','a');
CREATE TABLE local_inheritance (k int) INHERITS (test_inheritance);
DROP TABLE test_inheritance;
DROP SCHEMA partitioning_schema CASCADE;
DROP TABLE IF EXISTS
partitioning_hash_test,