diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 1c2ebe1bf6..f68e86467b 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8066,7 +8066,11 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options, castNode(List, options), NULL, NULL, false, isReset); /* Validate new options */ - (void) attribute_reloptions(newOptions, true); + if (rel->rd_rel->relkind == RELKIND_INDEX || + rel->rd_rel->relkind == RELKIND_PARTITIONED_INDEX) + (void) index_opclass_options(rel, attnum, newOptions, true); + else + (void) attribute_reloptions(newOptions, true); /* Build new tuple. */ memset(repl_null, false, sizeof(repl_null)); diff --git a/src/test/regress/expected/btree_index.out b/src/test/regress/expected/btree_index.out index bc113a70b4..fc5f8b5fb1 100644 --- a/src/test/regress/expected/btree_index.out +++ b/src/test/regress/expected/btree_index.out @@ -329,3 +329,6 @@ INSERT INTO delete_test_table SELECT i, 1, 2, 3 FROM generate_series(1,1000) i; -- Test unsupported btree opclass parameters create index on btree_tall_tbl (id int4_ops(foo=1)); ERROR: operator class int4_ops has no options +create index on btree_tall_tbl (id); +alter index btree_tall_tbl_id_idx alter column id set (ndistinct=100); +ERROR: operator class int4_ops has no options diff --git a/src/test/regress/expected/tsearch.out b/src/test/regress/expected/tsearch.out index 45b92a6338..48561d4853 100644 --- a/src/test/regress/expected/tsearch.out +++ b/src/test/regress/expected/tsearch.out @@ -513,6 +513,21 @@ SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'; (1 row) -- Test siglen parameter of GiST tsvector_ops +CREATE INDEX wowidx1 ON test_tsvector USING gist (a); +ALTER INDEX wowidx1 ALTER COLUMN a SET (foo=1); +ERROR: unrecognized parameter "foo" +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=0); +ERROR: value 0 out of bounds for option "siglen" +DETAIL: Valid values are between "1" and "2024". +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=2048); +ERROR: value 2048 out of bounds for option "siglen" +DETAIL: Valid values are between "1" and "2024". +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=100,foo='bar'); +ERROR: unrecognized parameter "foo" +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=100, siglen = 200); +ERROR: parameter "siglen" specified more than once +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=1); +DROP INDEX wowidx1; CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(foo=1)); ERROR: unrecognized parameter "foo" CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=0)); diff --git a/src/test/regress/sql/btree_index.sql b/src/test/regress/sql/btree_index.sql index c60312db2d..7552c39a01 100644 --- a/src/test/regress/sql/btree_index.sql +++ b/src/test/regress/sql/btree_index.sql @@ -172,3 +172,5 @@ INSERT INTO delete_test_table SELECT i, 1, 2, 3 FROM generate_series(1,1000) i; -- Test unsupported btree opclass parameters create index on btree_tall_tbl (id int4_ops(foo=1)); +create index on btree_tall_tbl (id); +alter index btree_tall_tbl_id_idx alter column id set (ndistinct=100); diff --git a/src/test/regress/sql/tsearch.sql b/src/test/regress/sql/tsearch.sql index d929210998..96998fdcf6 100644 --- a/src/test/regress/sql/tsearch.sql +++ b/src/test/regress/sql/tsearch.sql @@ -130,6 +130,15 @@ SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'; -- Test siglen parameter of GiST tsvector_ops +CREATE INDEX wowidx1 ON test_tsvector USING gist (a); +ALTER INDEX wowidx1 ALTER COLUMN a SET (foo=1); +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=0); +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=2048); +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=100,foo='bar'); +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=100, siglen = 200); +ALTER INDEX wowidx1 ALTER COLUMN a SET (siglen=1); +DROP INDEX wowidx1; + CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(foo=1)); CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=0)); CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=2048));