mirror of https://github.com/citusdata/citus.git
Fixes create index concurrently bug
parent
ef841115de
commit
38b72ddd66
|
@ -411,6 +411,16 @@ PostprocessIndexStmt(Node *node, const char *queryString)
|
|||
return NIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* We make sure schema name is not null in the PreprocessIndexStmt
|
||||
*/
|
||||
Oid schemaId = get_namespace_oid(indexStmt->relation->schemaname, true);
|
||||
Oid relationId = get_relname_relid(indexStmt->relation->relname, schemaId);
|
||||
if (!IsCitusTable(relationId))
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
/* commit the current transaction and start anew */
|
||||
CommitTransactionCommand();
|
||||
StartTransactionCommand();
|
||||
|
@ -418,7 +428,7 @@ PostprocessIndexStmt(Node *node, const char *queryString)
|
|||
/* get the affected relation and index */
|
||||
Relation relation = heap_openrv(indexStmt->relation, ShareUpdateExclusiveLock);
|
||||
Oid indexRelationId = get_relname_relid(indexStmt->idxname,
|
||||
RelationGetNamespace(relation));
|
||||
schemaId);
|
||||
Relation indexRelation = index_open(indexRelationId, RowExclusiveLock);
|
||||
|
||||
/* close relations but retain locks */
|
||||
|
|
|
@ -86,15 +86,16 @@ CREATE INDEX IF NOT EXISTS lineitem_orderkey_index on index_test_hash(a);
|
|||
NOTICE: relation "lineitem_orderkey_index" already exists, skipping
|
||||
-- Verify that we can create indexes concurrently
|
||||
CREATE INDEX CONCURRENTLY lineitem_concurrently_index ON lineitem (l_orderkey);
|
||||
-- Verify that no-name local CREATE INDEX CONCURRENTLY works
|
||||
CREATE TABLE local_table (id integer, name text);
|
||||
CREATE INDEX CONCURRENTLY ON local_table(id);
|
||||
-- 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
|
||||
CREATE TABLE local_table (id integer, name text);
|
||||
CREATE INDEX CONCURRENTLY local_table_index ON local_table(id);
|
||||
-- Vefify we don't warn out on CLUSTER command for local tables
|
||||
CREATE INDEX CONCURRENTLY local_table_index ON local_table(id);
|
||||
CLUSTER local_table USING local_table_index;
|
||||
DROP TABLE local_table;
|
||||
-- Verify that all indexes got created on the master node and one of the workers
|
||||
|
|
|
@ -64,15 +64,16 @@ CREATE INDEX IF NOT EXISTS lineitem_orderkey_index on index_test_hash(a);
|
|||
-- Verify that we can create indexes concurrently
|
||||
CREATE INDEX CONCURRENTLY lineitem_concurrently_index ON lineitem (l_orderkey);
|
||||
|
||||
-- Verify that no-name local CREATE INDEX CONCURRENTLY works
|
||||
CREATE TABLE local_table (id integer, name text);
|
||||
CREATE INDEX CONCURRENTLY ON local_table(id);
|
||||
|
||||
-- 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
|
||||
CREATE TABLE local_table (id integer, name text);
|
||||
CREATE INDEX CONCURRENTLY local_table_index ON local_table(id);
|
||||
|
||||
-- Vefify we don't warn out on CLUSTER command for local tables
|
||||
CREATE INDEX CONCURRENTLY local_table_index ON local_table(id);
|
||||
CLUSTER local_table USING local_table_index;
|
||||
|
||||
DROP TABLE local_table;
|
||||
|
|
Loading…
Reference in New Issue