mirror of https://github.com/citusdata/citus.git
Early error out when creating citus local from a temp table (#4592)
parent
e96db9b407
commit
bb5962ee79
|
@ -362,6 +362,21 @@ ErrorIfUnsupportedCitusLocalTableKind(Oid relationId)
|
|||
"tables and foreign tables can be added to citus metadata ",
|
||||
relationName)));
|
||||
}
|
||||
|
||||
if (get_rel_persistence(relationId) == RELPERSISTENCE_TEMP)
|
||||
{
|
||||
/*
|
||||
* Currently, we use citus local tables only to support foreign keys
|
||||
* between local tables and reference tables. Citus already doesn't
|
||||
* support creating reference tables from temp tables.
|
||||
* So now we are creating a citus local table from a temp table that
|
||||
* has a foreign key from/to a reference table with persistent storage.
|
||||
* In that case, we want to give the same error as postgres would do.
|
||||
*/
|
||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("constraints on temporary tables may reference only "
|
||||
"temporary tables")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,12 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
|
|||
(1 row)
|
||||
|
||||
RESET client_min_messages;
|
||||
BEGIN;
|
||||
CREATE TEMPORARY TABLE temp_table (a int);
|
||||
-- errors out as we don't support creating citus local table from a temp table
|
||||
SELECT citus_add_local_table_to_metadata('temp_table');
|
||||
ERROR: constraints on temporary tables may reference only temporary tables
|
||||
ROLLBACK;
|
||||
-- creating citus local table having no data initially would work
|
||||
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
|
||||
citus_add_local_table_to_metadata
|
||||
|
|
|
@ -40,6 +40,12 @@ set client_min_messages to ERROR;
|
|||
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
|
||||
RESET client_min_messages;
|
||||
|
||||
BEGIN;
|
||||
CREATE TEMPORARY TABLE temp_table (a int);
|
||||
-- errors out as we don't support creating citus local table from a temp table
|
||||
SELECT citus_add_local_table_to_metadata('temp_table');
|
||||
ROLLBACK;
|
||||
|
||||
-- creating citus local table having no data initially would work
|
||||
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
|
||||
|
||||
|
|
Loading…
Reference in New Issue