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] Range columns of a primary key out-of-order #1250

Closed
robertpang opened this issue Apr 24, 2019 · 0 comments
Closed

[YSQL] Range columns of a primary key out-of-order #1250

robertpang opened this issue Apr 24, 2019 · 0 comments
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug kind/disk-format-change This feature will change the on-disk format. priority/high High Priority
Milestone

Comments

@robertpang
Copy link
Contributor

robertpang commented Apr 24, 2019

When a user creates a YSQL table with a compound primary key, the range columns after the first implicit hash column are incorrectly created in the same order as they are in the columns' cardinal order, not in the order listed in the primary key. For example,

postgres=# create table t (r2 int, r1 int, h int, primary key (h, r1, r2));
CREATE TABLE
postgres=# \d t
                 Table "public.t"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 r2     | integer |           | not null |
 r1     | integer |           | not null |
 h      | integer |           | not null |
Indexes:
    "t_pkey" PRIMARY KEY, btree (h, r1, r2)

The column order as appeared in yb-master is:

Column | ID | Type
------ | -- | ----------------------------
h      |  0 | int32 NOT NULL PARTITION KEY
r2     |  1 | int32 NOT NULL NOT A PARTITION KEY
r1     |  2 | int32 NOT NULL NOT A PARTITION KEY
@robertpang robertpang added kind/bug This issue is a bug area/ysql Yugabyte SQL (YSQL) labels Apr 24, 2019
@ndeodhar ndeodhar added this to the v2.0 milestone Aug 28, 2019
@ndeodhar ndeodhar assigned ndeodhar and d-uspenskiy and unassigned OlegLoginov Aug 28, 2019
@ndeodhar ndeodhar added kind/disk-format-change This feature will change the on-disk format. priority/high High Priority labels Aug 28, 2019
d-uspenskiy added a commit that referenced this issue Sep 4, 2019
…ion [format change]

Summary:
Table columns are added in the following order:
- hash component of compound primary key (first column in compound primary key description)
- range components of compound primary key (same order as described in compound primary key)
- non key columns (same order as described in `CREATE TABLE` statement)

Test Plan:
New unit test was introduced

```
yb_build.sh --cxx-test pg_libpq-test --gtest_filter PgLibPqTest.CompoundKeyColumnOrder
```

Reviewers: neil, mihnea, neha

Reviewed By: neha

Subscribers: kannan, neha, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D7134
d-uspenskiy added a commit to d-uspenskiy/yugabyte-db that referenced this issue Sep 5, 2019
…description [format change]

Summary:
Table columns are added in the following order:
- hash component of compound primary key (first column in compound primary key description)
- range components of compound primary key (same order as described in compound primary key)
- non key columns (same order as described in `CREATE TABLE` statement)

Test Plan:
New unit test was introduced

```
yb_build.sh --cxx-test pg_libpq-test --gtest_filter PgLibPqTest.CompoundKeyColumnOrder
```

Reviewers: neil, mihnea, neha

Reviewed By: neha

Subscribers: kannan, neha, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D7134
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 kind/disk-format-change This feature will change the on-disk format. priority/high High Priority
Projects
None yet
Development

No branches or pull requests

4 participants