Merge branch 'master' into changelog-10.1.3

pull/5301/head
Hanefi Onaldi 2021-09-17 14:53:51 +03:00 committed by GitHub
commit 0d67b7f479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View File

@ -126,6 +126,7 @@ static void DoCopyFromLocalTableIntoShards(Relation distributedRelation,
DestReceiver *copyDest,
TupleTableSlot *slot,
EState *estate);
static void ErrorIfTemporaryTable(Oid relationId);
/* exports for SQL callable functions */
PG_FUNCTION_INFO_V1(master_create_distributed_table);
@ -329,6 +330,7 @@ EnsureCitusTableCanBeCreated(Oid relationOid)
EnsureCoordinator();
EnsureRelationExists(relationOid);
EnsureTableOwner(relationOid);
ErrorIfTemporaryTable(relationOid);
/*
* We should do this check here since the codes in the following lines rely
@ -1166,6 +1168,20 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
}
/*
* ErrorIfTemporaryTable errors out if the given table is a temporary table.
*/
static void
ErrorIfTemporaryTable(Oid relationId)
{
if (get_rel_persistence(relationId) == RELPERSISTENCE_TEMP)
{
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot distribute a temporary table")));
}
}
/*
* ErrorIfTableIsACatalogTable is a helper function to error out for citus
* table creation from a catalog table.

View File

@ -406,4 +406,11 @@ SELECT shardcount FROM pg_dist_colocation WHERE colocationid IN
13
(1 row)
CREATE TEMP TABLE temp_table(a int);
-- make sure temp table cannot be distributed and we give a good error
select create_distributed_table('temp_table', 'a');
ERROR: cannot distribute a temporary table
select create_reference_table('temp_table');
ERROR: cannot distribute a temporary table
DROP TABLE temp_table;
DROP TABLE shard_count_table_3;

View File

@ -265,4 +265,10 @@ SELECT shardcount FROM pg_dist_colocation WHERE colocationid IN
SELECT colocation_id FROM citus_tables WHERE table_name = 'shard_count_table_3'::regclass
);
CREATE TEMP TABLE temp_table(a int);
-- make sure temp table cannot be distributed and we give a good error
select create_distributed_table('temp_table', 'a');
select create_reference_table('temp_table');
DROP TABLE temp_table;
DROP TABLE shard_count_table_3;