Early error out when creating citus local from a temp table (#4592)

pull/4596/head
Onur Tirtir 2021-01-28 14:18:06 +03:00 committed by GitHub
parent e96db9b407
commit bb5962ee79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -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")));
}
}

View File

@ -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

View File

@ -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');