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

sql: error in create ... interleave due to type aliases #24932

Closed
danhhz opened this issue Apr 19, 2018 · 8 comments
Closed

sql: error in create ... interleave due to type aliases #24932

danhhz opened this issue Apr 19, 2018 · 8 comments
Labels
A-sql-name-resolution SQL name resolution rules and CTEs. A-sql-semantics C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3-erroneous-edge-case Database produces or stores erroneous data without visible error/warning, in rare edge cases.

Comments

@danhhz
Copy link
Contributor

danhhz commented Apr 19, 2018

From gitter: https://gitter.im/cockroachdb/cockroach?at=5ad7c30f5d7286b43a42e80a

+--------------+--------------------------------------------------------------------------+
|    Table     |                               CreateTable                                |
+--------------+--------------------------------------------------------------------------+
| marketplaces | CREATE TABLE marketplaces (                                              |
|              |                                                                          |
|              |     id INTEGER NOT NULL,                                                 |
|              |                                                                          |
|              |     marketplace STRING NOT NULL,                                         |
|              |                                                                          |
|              |     status INTEGER NOT NULL DEFAULT 0:::INT,                             |
|              |                                                                          |
|              |     CONSTRAINT "primary" PRIMARY KEY (id ASC),                           |
|              |                                                                          |
|              |     UNIQUE INDEX uq_marketplace (marketplace ASC),                       |
|              |                                                                          |
|              |     CONSTRAINT fk_status FOREIGN KEY (status) REFERENCES                 |
|              | marketplace_status (enum),                                               |
|              |                                                                          |
|              |     INDEX marketplaces_auto_index_fk_status (status ASC),                |
|              |                                                                          |
|              |     FAMILY "primary" (id, marketplace, status)                           |
|              |                                                                          |
|              | )                                                                        |
+--------------+--------------------------------------------------------------------------+
(1 row)

Time: 16.267986ms

root@c1.vultr.zuberglobal.com:26257/zuber> create table sellers ( marketplace int, id int, seller_marketplace_id string, primary key (marketplace, id) ) interleave in parent marketplaces (marketplace);
pq: declared interleaved columns (marketplace) must match type and sort direction of the parent's primary index (id)
root@c1.vultr.zuberglobal.com:26257/zuber> ```

This is unexpected because they do match.
@danhhz danhhz self-assigned this Apr 19, 2018
@danhhz danhhz added this to the 2.1 milestone Apr 19, 2018
@danhhz
Copy link
Contributor Author

danhhz commented Apr 19, 2018

Aha, the issue here is that one table uses INTEGER and the other uses INT. I don't know much about our type aliases, but I think this should work and the code in question should be ignoring the VisibleType field of ColumnDescriptor.

@knz
Copy link
Contributor

knz commented Apr 19, 2018

thanks for figuring the cause out. This seems closely related to #24686 .

@knz knz changed the title sql: declared interleaved columns ... must match type and sort direction sql: error in create ... interleave due to type aliases Apr 23, 2018
@knz knz added A-sql-semantics A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-name-resolution SQL name resolution rules and CTEs. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. and removed A-sql-pgcompat Semantic compatibility with PostgreSQL labels Apr 24, 2018
@nstewart nstewart added the S-3-erroneous-edge-case Database produces or stores erroneous data without visible error/warning, in rare edge cases. label Sep 18, 2018
@knz
Copy link
Contributor

knz commented Oct 5, 2018

This has been fixed in #28690.

Will be available in 2.1.

@knz knz closed this as completed Oct 5, 2018
@bithavoc
Copy link

bithavoc commented Nov 5, 2018

was this included in 2.1? I'm running 2.1 stable and I'm still getting it:

Main table was created using INT, the child table is trying to use INT and I'm getting the mismatch error.

In order to fix it I had to a SHOW CREATE TABLE over the parent table to find out it really created it with INT8 data type, as soon as I used INT8 in the child table prefix key column then it worked.

@knz
Copy link
Contributor

knz commented Nov 6, 2018

You are right, this is actually not entirely fixed yet. Thanks for noticing.

@knz knz reopened this Nov 6, 2018
@knz knz unassigned danhhz Nov 6, 2018
@knz knz removed this from the 2.1 milestone Nov 6, 2018
@knz
Copy link
Contributor

knz commented Nov 6, 2018

@bobvawter you don't need to look at this issue specifically, but I'd like to take the opportunity to underline we need to entirely eradicate the current coltype called "INT" (and only keep the fixed-size types), because it would become ambiguous with the resolution rules we discussed last week.

@knz
Copy link
Contributor

knz commented Dec 19, 2018

@bobvawter I think your recent PR has fixed this by doing the INT->INT8 substitution upfront. Can you verify and close this issue?

@knz
Copy link
Contributor

knz commented Jan 3, 2019

This issue has indeed been fixed.

@knz knz closed this as completed Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-name-resolution SQL name resolution rules and CTEs. A-sql-semantics C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3-erroneous-edge-case Database produces or stores erroneous data without visible error/warning, in rare edge cases.
Projects
None yet
Development

No branches or pull requests

4 participants