Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Non-key columns in unique index affect constraint enforcement #1412

Closed
srhickma opened this issue May 20, 2019 · 1 comment
Closed
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug

Comments

@srhickma
Copy link
Contributor

Summary: Adding INCLUDE (non-key) columns in a unique index affects the enforcement of uniqueness on the key columns. This should not be the case.

Reproduction Steps:

postgres=# CREATE TABLE tst (c1 int, c2 int);
CREATE TABLE
postgres=# INSERT INTO tst (c1, c2) VALUES
postgres-# (1, 1),
postgres-# (1, 2);
INSERT 0 2
postgres=# CREATE UNIQUE INDEX tst_uidx ON tst USING lsm (c1) INCLUDE (c2);
CREATE INDEX

Expected Results: It is expected that the CREATE INDEX statement will produce an error, since there are duplicate values in c1.

Note: If INCLUDE (c2) is removed, then the correct error is displayed:

postgres=# CREATE UNIQUE INDEX tst_uidx2 ON tst USING lsm (c1);
ERROR:  duplicate key value violates unique constraint "tst_uidx2"
@srhickma srhickma added the kind/bug This issue is a bug label May 20, 2019
@kmuthukk kmuthukk added the area/ysql Yugabyte SQL (YSQL) label May 20, 2019
@ndeodhar ndeodhar changed the title Non-key columns in unique index affect constraint enforcement [YSQL] Non-key columns in unique index affect constraint enforcement May 21, 2019
yugabyte-ci pushed a commit that referenced this issue May 28, 2019
Summary:
This revision fixes an issue with the included index columns where they should be included as the
non-primary-key columns in the index.

Test Plan: yb_create_index

Reviewers: mihnea, neil, neha

Reviewed By: neha

Subscribers: srhickma, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D6650
@robertpang
Copy link
Contributor

This issue is fixed in commit 3de20a3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug
Projects
None yet
Development

No branches or pull requests

3 participants