mirror of https://github.com/citusdata/citus.git
Merge pull request #410 from citusdata/350-error-during-duplicate-index-creation
Error out earlier when creating an index with a name collision.pull/441/head
commit
0b35c47932
|
@ -572,6 +572,25 @@ ProcessAlterTableStmt(AlterTableStmt *alterTableStatement, const char *alterTabl
|
|||
static void
|
||||
ErrorIfUnsupportedIndexStmt(IndexStmt *createIndexStatement)
|
||||
{
|
||||
Oid namespaceId;
|
||||
Oid indexRelationId;
|
||||
char* indexRelationName = createIndexStatement->idxname;
|
||||
|
||||
if (indexRelationName == NULL)
|
||||
{
|
||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("creating index without a name on a distributed table is "
|
||||
"currently unsupported")));
|
||||
}
|
||||
|
||||
namespaceId = get_namespace_oid(createIndexStatement->relation->schemaname, false);
|
||||
indexRelationId = get_relname_relid(indexRelationName, namespaceId);
|
||||
if (indexRelationId != InvalidOid)
|
||||
{
|
||||
ereport(ERROR, (errcode(ERRCODE_DUPLICATE_TABLE),
|
||||
errmsg("relation \"%s\" already exists", indexRelationName)));
|
||||
}
|
||||
|
||||
if (createIndexStatement->tableSpace != NULL)
|
||||
{
|
||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
|
|
|
@ -135,9 +135,7 @@ ERROR: creating unique indexes on append-partitioned tables is currently unsupp
|
|||
-- Verify that we error out in case of postgres errors on supported statement
|
||||
-- types.
|
||||
CREATE INDEX lineitem_orderkey_index ON lineitem (l_orderkey);
|
||||
WARNING: could not receive query results from localhost:57638
|
||||
DETAIL: Client error: relation "lineitem_orderkey_index_102014" already exists
|
||||
ERROR: could not execute DDL command on worker node shards
|
||||
ERROR: relation "lineitem_orderkey_index" already exists
|
||||
CREATE INDEX try_index ON lineitem USING gist (l_orderkey);
|
||||
WARNING: could not receive query results from localhost:57638
|
||||
DETAIL: Client error: data type bigint has no default operator class for access method "gist"
|
||||
|
@ -146,6 +144,8 @@ CREATE INDEX try_index ON lineitem (non_existent_column);
|
|||
WARNING: could not receive query results from localhost:57638
|
||||
DETAIL: Client error: column "non_existent_column" does not exist
|
||||
ERROR: could not execute DDL command on worker node shards
|
||||
CREATE INDEX ON lineitem (l_orderkey);
|
||||
ERROR: creating index without a name on a distributed table is currently unsupported
|
||||
-- Verify that none of failed indexes got created on the master node
|
||||
SELECT * FROM pg_indexes WHERE tablename = 'lineitem' or tablename like 'index_test_%' ORDER BY indexname;
|
||||
schemaname | tablename | indexname | tablespace | indexdef
|
||||
|
|
|
@ -73,6 +73,7 @@ CREATE UNIQUE INDEX try_unique_append_index_a_b ON index_test_append(a,b);
|
|||
CREATE INDEX lineitem_orderkey_index ON lineitem (l_orderkey);
|
||||
CREATE INDEX try_index ON lineitem USING gist (l_orderkey);
|
||||
CREATE INDEX try_index ON lineitem (non_existent_column);
|
||||
CREATE INDEX ON lineitem (l_orderkey);
|
||||
|
||||
-- Verify that none of failed indexes got created on the master node
|
||||
SELECT * FROM pg_indexes WHERE tablename = 'lineitem' or tablename like 'index_test_%' ORDER BY indexname;
|
||||
|
|
Loading…
Reference in New Issue