Merge pull request #1782 from citusdata/warn_on_cluster_command

Warn on CLUSTER command for distributed tables
pull/1790/head
Metin Döşlü 2017-11-10 11:31:08 +02:00 committed by GitHub
commit a4d3002b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 2 deletions

View File

@ -568,6 +568,37 @@ multi_ProcessUtility(PlannedStmt *pstmt,
ProcessVacuumStmt(vacuumStmt, queryString); ProcessVacuumStmt(vacuumStmt, queryString);
} }
/* warn for CLUSTER command on distributed tables */
if (IsA(parsetree, ClusterStmt))
{
ClusterStmt *clusterStmt = (ClusterStmt *) parsetree;
bool showPropagationWarning = false;
/* CLUSTER all */
if (clusterStmt->relation == NULL)
{
showPropagationWarning = true;
}
else
{
Oid relationId = InvalidOid;
bool missingOK = false;
relationId = RangeVarGetRelid(clusterStmt->relation, AccessShareLock,
missingOK);
if (OidIsValid(relationId))
{
showPropagationWarning = IsDistributedTable(relationId);
}
}
if (showPropagationWarning)
{
ereport(WARNING, (errmsg("not propagating CLUSTER command to worker nodes")));
}
}
/* /*
* Ensure value is valid, we can't do some checks during CREATE * Ensure value is valid, we can't do some checks during CREATE
* EXTENSION. This is important to register some invalidation callbacks. * EXTENSION. This is important to register some invalidation callbacks.

View File

@ -92,9 +92,16 @@ CREATE INDEX IF NOT EXISTS lineitem_orderkey_index on index_test_hash(a);
NOTICE: relation "lineitem_orderkey_index" already exists, skipping NOTICE: relation "lineitem_orderkey_index" already exists, skipping
-- Verify that we can create indexes concurrently -- Verify that we can create indexes concurrently
CREATE INDEX CONCURRENTLY lineitem_concurrently_index ON lineitem (l_orderkey); CREATE INDEX CONCURRENTLY lineitem_concurrently_index ON lineitem (l_orderkey);
-- Verify that we warn out on CLUSTER command for distributed tables and no parameter
CLUSTER index_test_hash USING index_test_hash_index_a;
WARNING: not propagating CLUSTER command to worker nodes
CLUSTER;
WARNING: not propagating CLUSTER command to worker nodes
-- Verify that no-name local CREATE INDEX CONCURRENTLY works -- Verify that no-name local CREATE INDEX CONCURRENTLY works
CREATE TABLE local_table (id integer, name text); CREATE TABLE local_table (id integer, name text);
CREATE INDEX CONCURRENTLY ON local_table(id); CREATE INDEX CONCURRENTLY local_table_index ON local_table(id);
-- Vefify we don't warn out on CLUSTER command for local tables
CLUSTER local_table USING local_table_index;
DROP TABLE local_table; DROP TABLE local_table;
-- Verify that all indexes got created on the master node and one of the workers -- Verify that all indexes got created on the master node and one of the workers
SELECT * FROM pg_indexes WHERE tablename = 'lineitem' or tablename like 'index_test_%' ORDER BY indexname; SELECT * FROM pg_indexes WHERE tablename = 'lineitem' or tablename like 'index_test_%' ORDER BY indexname;

View File

@ -66,9 +66,17 @@ CREATE INDEX IF NOT EXISTS lineitem_orderkey_index on index_test_hash(a);
-- Verify that we can create indexes concurrently -- Verify that we can create indexes concurrently
CREATE INDEX CONCURRENTLY lineitem_concurrently_index ON lineitem (l_orderkey); CREATE INDEX CONCURRENTLY lineitem_concurrently_index ON lineitem (l_orderkey);
-- Verify that we warn out on CLUSTER command for distributed tables and no parameter
CLUSTER index_test_hash USING index_test_hash_index_a;
CLUSTER;
-- Verify that no-name local CREATE INDEX CONCURRENTLY works -- Verify that no-name local CREATE INDEX CONCURRENTLY works
CREATE TABLE local_table (id integer, name text); CREATE TABLE local_table (id integer, name text);
CREATE INDEX CONCURRENTLY ON local_table(id); CREATE INDEX CONCURRENTLY local_table_index ON local_table(id);
-- Vefify we don't warn out on CLUSTER command for local tables
CLUSTER local_table USING local_table_index;
DROP TABLE local_table; DROP TABLE local_table;
-- Verify that all indexes got created on the master node and one of the workers -- Verify that all indexes got created on the master node and one of the workers