mirror of https://github.com/citusdata/citus.git
Error out if inheriting a distributed table (#4871)
* Error out if inheriting a distributed table * Add test inheriting a distirbuted tablepull/4873/head
parent
e4c4a9b683
commit
52e467a9a0
|
@ -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")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue