Skip to content

Commit

Permalink
[#23118] YSQL: Add support for ADD PRIMARY KEY ... USING INDEX
Browse files Browse the repository at this point in the history
Summary:
This diff adds support for adding a primary key using a unique index by performing table rewrite.

Code changes:
- ATExecAddIndexConstraint in tablecmds.c:
     - If we are adding a primary key constraint on a YB relation, mark the table to be rewritten by alter table phase 3.
     - Skip copying split options (number of tablets) when we are adding a range based primary key.
     - Since primary keys are implicit to the DocDB table, drop the DocDB table associated with the secondary unique index.
- pg_yb_utils.c:
     - Add function `YbGetIndexKeySortOrdering` to retrieve the sort ordering of the first key element of an index.
     - YbATIsRangePk: minor change to make the function take the sort ordering instead as a parameter instead of the index statement.

Note: This operation is not supported when the unique index has key columns in descending order -- this limitation exists in Postgres, as Postgres does not allow adding primary keys with `DESC` ordering. Although we can support this in YB, it is omitted for now as the motivation for this feature is to facilitate migrations.
Jira: DB-12051

Test Plan:
new tests in `yb_alter_table_rewrite`, `yb_pg_create_index`, `yb_pg_index_including`
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressTable'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPgMisc'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPgMiscIndependent'

Reviewers: myang

Reviewed By: myang

Subscribers: smishra, yql

Differential Revision: https://phorge.dev.yugabyte.com/D37741
  • Loading branch information
fizaaluthra committed Sep 13, 2024
1 parent 24a5af0 commit 2ac2e98
Show file tree
Hide file tree
Showing 9 changed files with 278 additions and 41 deletions.
54 changes: 38 additions & 16 deletions src/postgres/src/backend/commands/tablecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static ObjectAddress ATExecAddConstraint(List **wqueue,
Constraint *newConstraint, bool recurse, bool is_readd,
LOCKMODE lockmode);
static ObjectAddress ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
IndexStmt *stmt, LOCKMODE lockmode);
IndexStmt *stmt, LOCKMODE lockmode, List **yb_wqueue);
static ObjectAddress ATAddCheckConstraint(List **wqueue,
AlteredTableInfo *tab, Relation rel,
Constraint *constr,
Expand Down Expand Up @@ -551,8 +551,8 @@ static Relation YbATCloneRelationSetColumnType(Relation old_rel,
Oid altered_collation_id,
TypeName *altered_type_name,
List *new_column_values);
static bool YbATIsRangePk(IndexStmt *stmt,
bool is_colocated, bool is_tablegroup);
static bool YbATIsRangePk(SortByDir ordering, bool is_colocated,
bool is_tablegroup);
static void YbATSetPKRewriteChildPartitions(List **yb_wqueue,
AlteredTableInfo *tab,
bool skip_copy_split_options);
Expand Down Expand Up @@ -4631,7 +4631,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation *mutable_rel,
break;
case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */
address = ATExecAddIndexConstraint(tab, rel, (IndexStmt *) cmd->def,
lockmode);
lockmode, wqueue);
break;
case AT_AlterConstraint: /* ALTER CONSTRAINT */
address = ATExecAlterConstraint(rel, cmd, false, false, lockmode);
Expand Down Expand Up @@ -7639,7 +7639,8 @@ ATExecAddIndex(List **yb_wqueue, AlteredTableInfo *tab, Relation *mutable_rel,
{
YbGetTableProperties(*mutable_rel);
/* Don't copy split options if we are creating a range key. */
bool skip_copy_split_options = YbATIsRangePk(stmt,
bool skip_copy_split_options = YbATIsRangePk(
linitial_node(IndexElem, stmt->indexParams)->ordering,
(*mutable_rel)->yb_table_properties->is_colocated, OidIsValid(
(*mutable_rel)->yb_table_properties->tablegroup_oid));
if (!skip_build)
Expand Down Expand Up @@ -7683,7 +7684,8 @@ ATExecAddIndex(List **yb_wqueue, AlteredTableInfo *tab, Relation *mutable_rel,
*/
static ObjectAddress
ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
IndexStmt *stmt, LOCKMODE lockmode)
IndexStmt *stmt, LOCKMODE lockmode,
List **yb_wqueue)
{
Oid index_oid = stmt->indexOid;
Relation indexRel;
Expand All @@ -7707,11 +7709,6 @@ ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("ALTER TABLE / ADD CONSTRAINT USING INDEX is not supported on partitioned tables")));

if (IsYugaByteEnabled() && stmt->primary)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("ALTER TABLE / ADD CONSTRAINT PRIMARY KEY USING INDEX is not supported")));

indexRel = index_open(index_oid, AccessShareLock);

indexName = pstrdup(RelationGetRelationName(indexRel));
Expand All @@ -7722,6 +7719,29 @@ ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
if (!indexInfo->ii_Unique)
elog(ERROR, "index \"%s\" is not unique", indexName);

/*
* YB: Adding a primary key requires table rewrite.
* We do not need to rewrite any children as this operation is not supported
* on partitioned tables (checked above).
*/
if (IsYBRelation(rel) && stmt->primary)
{
YbGetTableProperties(rel);
/* Don't copy split options if we are creating a range key. */
bool skip_copy_split_options = YbATIsRangePk(
YbGetIndexKeySortOrdering(indexRel),
rel->yb_table_properties->is_colocated, OidIsValid(
rel->yb_table_properties->tablegroup_oid));
tab->rewrite |= YB_AT_REWRITE_ALTER_PRIMARY_KEY;
tab->yb_skip_copy_split_options = tab->yb_skip_copy_split_options
|| skip_copy_split_options;
/*
* Since this index is going to be upgraded to a pkey, we can drop the
* DocDB table associated with the secondary index.
*/
YBCDropIndex(indexRel);
}

/*
* Determine name to assign to constraint. We require a constraint to
* have the same name as the underlying index; therefore, use the index's
Expand Down Expand Up @@ -16249,7 +16269,8 @@ AttachPartitionEnsureIndexes(Relation rel, Relation attachrel, List **yb_wqueue)
tab->rewrite = YB_AT_REWRITE_ALTER_PRIMARY_KEY;
YbGetTableProperties(attachrel);
/* Don't copy split options if we are creating a range key. */
bool skip_copy_split_options = YbATIsRangePk(stmt,
bool skip_copy_split_options = YbATIsRangePk(
linitial_node(IndexElem, stmt->indexParams)->ordering,
attachrel->yb_table_properties->is_colocated,
OidIsValid(
attachrel->yb_table_properties->tablegroup_oid));
Expand Down Expand Up @@ -17596,11 +17617,11 @@ YbATGetRenameStmt(const char *namespace_name, const char *current_name,
}

static bool
YbATIsRangePk(IndexStmt *stmt, bool is_colocated, bool is_tablegroup)
YbATIsRangePk(SortByDir ordering, bool is_colocated, bool is_tablegroup)
{
SortByDir yb_ordering =
YbSortOrdering(linitial_node(IndexElem, stmt->indexParams)->ordering,
is_colocated, is_tablegroup, true /* is_first_key */);
YbSortOrdering(ordering, is_colocated, is_tablegroup,
true /* is_first_key */);

if (yb_ordering == SORTBY_ASC || yb_ordering == SORTBY_DESC)
return true;
Expand Down Expand Up @@ -18924,7 +18945,8 @@ YbATCloneRelationSetPrimaryKey(Relation old_rel, IndexStmt *stmt,

if (stmt)
is_range_pk = YbATIsRangePk(
stmt, old_rel->yb_table_properties->is_colocated,
linitial_node(IndexElem, stmt->indexParams)->ordering,
old_rel->yb_table_properties->is_colocated,
OidIsValid(old_rel->yb_table_properties->tablegroup_oid));

/*
Expand Down
16 changes: 16 additions & 0 deletions src/postgres/src/backend/utils/misc/pg_yb_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -5012,3 +5012,19 @@ bool YbIsAttrPrimaryKeyColumn(Relation rel, AttrNumber attnum)
return bms_is_member(attnum -
YBGetFirstLowInvalidAttributeNumber(rel), pkey);
}

/* Retrieve the sort ordering of the first key element of an index. */
SortByDir YbGetIndexKeySortOrdering(Relation indexRel)
{
if (IndexRelationGetNumberOfKeyAttributes(indexRel) == 0)
return SORTBY_DEFAULT;
/*
* If there are key columns, check the indoption of the first
* key attribute.
*/
if (indexRel->rd_indoption[0] & INDOPTION_HASH)
return SORTBY_HASH;
if (indexRel->rd_indoption[0] & INDOPTION_DESC)
return SORTBY_DESC;
return SORTBY_ASC;
}
2 changes: 2 additions & 0 deletions src/postgres/src/include/pg_yb_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1177,4 +1177,6 @@ extern bool YbIsYsqlConnMgrWarmupModeEnabled();

bool YbIsAttrPrimaryKeyColumn(Relation rel, AttrNumber attnum);

SortByDir YbGetIndexKeySortOrdering(Relation indexRel);

#endif /* PG_YB_UTILS_H */
77 changes: 74 additions & 3 deletions src/postgres/src/test/regress/expected/yb_alter_table_rewrite.out
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,21 @@ SELECT num_tablets, num_hash_key_columns, is_colocated FROM
1 | 0 | t
(1 row)

CREATE UNIQUE INDEX base_idx_unique ON base(col);
ALTER TABLE base ADD PRIMARY KEY USING INDEX base_idx_unique;
INSERT INTO base VALUES (1, 1); -- should fail.
ERROR: duplicate key value violates unique constraint "base_idx_unique"
INSERT INTO base VALUES (4, 4), (5, 5);
SELECT col, col2 FROM base;
col | col2
-----+------
1 | 3
2 | 2
3 | 1
4 | 4
5 | 5
(5 rows)

CREATE TABLE base2 (col int, col2 int) WITH (COLOCATION=false);
CREATE INDEX base2_idx ON base2(col2);
INSERT INTO base2 VALUES (1, 3), (2, 2), (3, 1);
Expand Down Expand Up @@ -592,10 +607,66 @@ CREATE TABLE nopk_udt (id typeid, v int);
ALTER TABLE nopk_udt ADD PRIMARY KEY (id); -- should fail.
ERROR: PRIMARY KEY containing column of type 'user_defined_type' not yet supported
-- test pk USING INDEX.
CREATE TABLE nopk_usingindex (id int);
CREATE UNIQUE INDEX nopk_idx ON nopk_usingindex (id ASC);
CREATE TABLE nopk_usingindex (id int) SPLIT INTO 5 TABLETS;
INSERT INTO nopk_usingindex VALUES (1), (2), (3);
CREATE INDEX nopk_idx ON nopk_usingindex(id);
CREATE UNIQUE INDEX nopk_idx2 ON nopk_usingindex (id HASH);
CREATE UNIQUE INDEX nopk_idx3 ON nopk_usingindex (id ASC);
CREATE UNIQUE INDEX nopk_idx4 ON nopk_usingindex (id DESC);
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx; -- should fail.
ERROR: ALTER TABLE / ADD CONSTRAINT PRIMARY KEY USING INDEX is not supported
ERROR: "nopk_idx" is not a unique index
LINE 1: ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk...
^
DETAIL: Cannot create a primary key or unique constraint using such an index.
INSERT INTO nopk_usingindex VALUES (null);
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx2; -- should fail.
ERROR: column "id" contains null values
DELETE FROM nopk_usingindex WHERE id IS NULL;
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx2;
SELECT num_tablets, num_hash_key_columns FROM yb_table_properties('nopk_usingindex'::regclass);
num_tablets | num_hash_key_columns
-------------+----------------------
5 | 1
(1 row)

INSERT INTO nopk_usingindex VALUES (4);
INSERT INTO nopk_usingindex VALUES (1); -- should fail.
ERROR: duplicate key value violates unique constraint "nopk_idx2"
INSERT INTO nopk_usingindex VALUES (null); -- should fail.
ERROR: null value in column "id" violates not-null constraint
DETAIL: Failing row contains (null).
SELECT * FROM nopk_usingindex ORDER BY id;
id
----
1
2
3
4
(4 rows)

DROP INDEX nopk_idx2; -- should fail.
ERROR: cannot drop index nopk_idx2 because constraint nopk_idx2 on table nopk_usingindex requires it
HINT: You can drop constraint nopk_idx2 on table nopk_usingindex instead.
ALTER TABLE nopk_usingindex DROP CONSTRAINT nopk_idx2;
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx3;
SELECT * FROM nopk_usingindex;
id
----
1
2
3
4
(4 rows)

DROP INDEX nopk_idx3; -- should fail.
ERROR: cannot drop index nopk_idx3 because constraint nopk_idx3 on table nopk_usingindex requires it
HINT: You can drop constraint nopk_idx3 on table nopk_usingindex instead.
ALTER TABLE nopk_usingindex DROP CONSTRAINT nopk_idx3;
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx4; -- should fail (not supported in PG).
ERROR: index "nopk_idx4" does not have default sorting behavior
LINE 1: ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk...
^
DETAIL: Cannot create a primary key or unique constraint using such an index.
-- test adding/dropping pks on partitioned tables.
CREATE TABLE nopk_whole (id int) PARTITION BY LIST (id);
CREATE TABLE nopk_part1 PARTITION OF nopk_whole FOR VALUES IN (1, 2, 3);
Expand Down
65 changes: 65 additions & 0 deletions src/postgres/src/test/regress/expected/yb_pg_create_index.out
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,71 @@ LINE 1: REINDEX TABLE concur_heap;
^
HINT: Please report the issue on https://github.com/YugaByte/yugabyte-db/issues
--
-- Test ADD CONSTRAINT USING INDEX
--
CREATE TABLE cwi_test( a int , b varchar(10), c char);
-- add some data so that all tests have something to work with.
INSERT INTO cwi_test VALUES(1, 2), (3, 4), (5, 6);
CREATE UNIQUE INDEX cwi_uniq_idx ON cwi_test(a , b);
ALTER TABLE cwi_test ADD primary key USING INDEX cwi_uniq_idx;
NOTICE: table rewrite may lead to inconsistencies
DETAIL: Concurrent DMLs may not be reflected in the new table.
HINT: See https://github.com/yugabyte/yugabyte-db/issues/19860. Set 'ysql_suppress_unsafe_alter_notice' yb-tserver gflag to true to suppress this notice.
\d cwi_test
Table "public.cwi_test"
Column | Type | Collation | Nullable | Default
--------+-----------------------+-----------+----------+---------
a | integer | | not null |
b | character varying(10) | | not null |
c | character(1) | | |
Indexes:
"cwi_uniq_idx" PRIMARY KEY, lsm (a HASH, b ASC)

\d cwi_uniq_idx
Index "public.cwi_uniq_idx"
Column | Type | Key? | Definition
--------+-----------------------+------+------------
a | integer | yes | a
b | character varying(10) | yes | b
primary key, lsm, for table "public.cwi_test"

CREATE UNIQUE INDEX cwi_uniq2_idx ON cwi_test(b , a);
ALTER TABLE cwi_test DROP CONSTRAINT cwi_uniq_idx,
ADD CONSTRAINT cwi_replaced_pkey PRIMARY KEY
USING INDEX cwi_uniq2_idx;
NOTICE: ALTER TABLE / ADD CONSTRAINT USING INDEX will rename index "cwi_uniq2_idx" to "cwi_replaced_pkey"
NOTICE: table rewrite may lead to inconsistencies
DETAIL: Concurrent DMLs may not be reflected in the new table.
HINT: See https://github.com/yugabyte/yugabyte-db/issues/19860. Set 'ysql_suppress_unsafe_alter_notice' yb-tserver gflag to true to suppress this notice.
\d cwi_test
Table "public.cwi_test"
Column | Type | Collation | Nullable | Default
--------+-----------------------+-----------+----------+---------
a | integer | | not null |
b | character varying(10) | | not null |
c | character(1) | | |
Indexes:
"cwi_replaced_pkey" PRIMARY KEY, lsm (b HASH, a ASC)

\d cwi_replaced_pkey
Index "public.cwi_replaced_pkey"
Column | Type | Key? | Definition
--------+-----------------------+------+------------
b | character varying(10) | yes | b
a | integer | yes | a
primary key, lsm, for table "public.cwi_test"

DROP INDEX cwi_replaced_pkey; -- Should fail; a constraint depends on it
ERROR: cannot drop index cwi_replaced_pkey because constraint cwi_replaced_pkey on table cwi_test requires it
HINT: You can drop constraint cwi_replaced_pkey on table cwi_test instead.
DROP TABLE cwi_test;
-- ADD CONSTRAINT USING INDEX is forbidden on partitioned tables
CREATE TABLE cwi_test(a int) PARTITION BY hash (a);
create unique index on cwi_test (a);
alter table cwi_test add primary key using index cwi_test_a_idx ;
ERROR: ALTER TABLE / ADD CONSTRAINT USING INDEX is not supported on partitioned tables
DROP TABLE cwi_test;
--
-- REINDEX (VERBOSE)
--
CREATE TABLE reindex_verbose(id integer primary key);
Expand Down
25 changes: 15 additions & 10 deletions src/postgres/src/test/regress/expected/yb_pg_index_including.out
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,21 @@ WHERE i.indrelid = 'tbl_include_pk'::regclass ORDER BY c.relname;
CREATE UNIQUE INDEX tbl_include_pk_pkey ON public.tbl_include_pk USING lsm (c1 HASH, c2 ASC) INCLUDE (c3, c4)
(1 row)

-- NOT SUPPORTED
--
-- CREATE TABLE tbl_include_c4 (c1 int, c2 int, c3 int, c4 int);
-- INSERT INTO tbl_include_c4 SELECT 1, 2*x, 3*x, 4 FROM generate_series(1,10) AS x;
-- CREATE UNIQUE INDEX tbl_include_c4_idx_unique ON tbl_include_c4 using lsm (c1, c2) INCLUDE (c3, c4);
-- ALTER TABLE tbl_include_c4 add PRIMARY KEY USING INDEX tbl_include_c4_idx_unique;
-- SELECT pg_get_indexdef(i.indexrelid)
-- FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid
-- WHERE i.indrelid = 'tbl_include_c4'::regclass ORDER BY c.relname;
--
CREATE TABLE tbl_include_c4 (c1 int, c2 int, c3 int, c4 int);
INSERT INTO tbl_include_c4 SELECT 1, 2*x, 3*x, 4 FROM generate_series(1,10) AS x;
CREATE UNIQUE INDEX tbl_include_c4_idx_unique ON tbl_include_c4 using lsm (c1, c2) INCLUDE (c3, c4);
ALTER TABLE tbl_include_c4 add PRIMARY KEY USING INDEX tbl_include_c4_idx_unique;
NOTICE: table rewrite may lead to inconsistencies
DETAIL: Concurrent DMLs may not be reflected in the new table.
HINT: See https://github.com/yugabyte/yugabyte-db/issues/19860. Set 'ysql_suppress_unsafe_alter_notice' yb-tserver gflag to true to suppress this notice.
SELECT pg_get_indexdef(i.indexrelid)
FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid
WHERE i.indrelid = 'tbl_include_c4'::regclass ORDER BY c.relname;
pg_get_indexdef
---------------------------------------------------------------------------------------------------------------------
CREATE UNIQUE INDEX tbl_include_c4_idx_unique ON public.tbl_include_c4 USING lsm (c1 HASH, c2 ASC) INCLUDE (c3, c4)
(1 row)

-- PK constraint. Must fail.
CREATE TABLE tbl_include_c4_pk (c1 int, c2 int, c3 int, c4 int);
INSERT INTO tbl_include_c4_pk SELECT 1, 2, 3*x, 4 FROM generate_series(1,10) AS x;
Expand Down
29 changes: 27 additions & 2 deletions src/postgres/src/test/regress/sql/yb_alter_table_rewrite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ SELECT col, col2, col4 FROM base ORDER BY col;
\d+ base;
SELECT num_tablets, num_hash_key_columns, is_colocated FROM
yb_table_properties('base_idx'::regclass);
CREATE UNIQUE INDEX base_idx_unique ON base(col);
ALTER TABLE base ADD PRIMARY KEY USING INDEX base_idx_unique;
INSERT INTO base VALUES (1, 1); -- should fail.
INSERT INTO base VALUES (4, 4), (5, 5);
SELECT col, col2 FROM base;
CREATE TABLE base2 (col int, col2 int) WITH (COLOCATION=false);
CREATE INDEX base2_idx ON base2(col2);
INSERT INTO base2 VALUES (1, 3), (2, 2), (3, 1);
Expand Down Expand Up @@ -246,9 +251,29 @@ CREATE TYPE typeid AS (i int);
CREATE TABLE nopk_udt (id typeid, v int);
ALTER TABLE nopk_udt ADD PRIMARY KEY (id); -- should fail.
-- test pk USING INDEX.
CREATE TABLE nopk_usingindex (id int);
CREATE UNIQUE INDEX nopk_idx ON nopk_usingindex (id ASC);
CREATE TABLE nopk_usingindex (id int) SPLIT INTO 5 TABLETS;
INSERT INTO nopk_usingindex VALUES (1), (2), (3);
CREATE INDEX nopk_idx ON nopk_usingindex(id);
CREATE UNIQUE INDEX nopk_idx2 ON nopk_usingindex (id HASH);
CREATE UNIQUE INDEX nopk_idx3 ON nopk_usingindex (id ASC);
CREATE UNIQUE INDEX nopk_idx4 ON nopk_usingindex (id DESC);
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx; -- should fail.
INSERT INTO nopk_usingindex VALUES (null);
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx2; -- should fail.
DELETE FROM nopk_usingindex WHERE id IS NULL;
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx2;
SELECT num_tablets, num_hash_key_columns FROM yb_table_properties('nopk_usingindex'::regclass);
INSERT INTO nopk_usingindex VALUES (4);
INSERT INTO nopk_usingindex VALUES (1); -- should fail.
INSERT INTO nopk_usingindex VALUES (null); -- should fail.
SELECT * FROM nopk_usingindex ORDER BY id;
DROP INDEX nopk_idx2; -- should fail.
ALTER TABLE nopk_usingindex DROP CONSTRAINT nopk_idx2;
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx3;
SELECT * FROM nopk_usingindex;
DROP INDEX nopk_idx3; -- should fail.
ALTER TABLE nopk_usingindex DROP CONSTRAINT nopk_idx3;
ALTER TABLE nopk_usingindex ADD PRIMARY KEY USING INDEX nopk_idx4; -- should fail (not supported in PG).
-- test adding/dropping pks on partitioned tables.
CREATE TABLE nopk_whole (id int) PARTITION BY LIST (id);
CREATE TABLE nopk_part1 PARTITION OF nopk_whole FOR VALUES IN (1, 2, 3);
Expand Down
Loading

0 comments on commit 2ac2e98

Please sign in to comment.