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: UPSERT causes a decoding error in collated string column #46394

Closed
mrigger opened this issue Mar 21, 2020 · 3 comments · Fixed by #46570
Closed

sql: UPSERT causes a decoding error in collated string column #46394

mrigger opened this issue Mar 21, 2020 · 3 comments · Fixed by #46570
Assignees
Labels
A-sql-mutations Mutation statements: UPDATE/INSERT/UPSERT/DELETE. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community

Comments

@mrigger
Copy link

mrigger commented Mar 21, 2020

Consider the following test case:

CREATE TABLE t0(c0 BOOL, c1 STRING COLLATE en);
CREATE INDEX ON t0(rowid, c1 DESC);
INSERT INTO t0(c1, rowid) VALUES('' COLLATE en, 0);
UPSERT INTO t0(rowid) VALUES (0), (1); -- error decoding 11 bytes: did not find marker 0x12 in buffer 0x13ff00ff00ff00ff00fffe

Unexpectedly, the UPSERT results in an error error decoding 11 bytes: did not find marker 0x12 in buffer 0x13ff00ff00ff00ff00fffe. When, for example, dropping column c0, the error does not occur.

I found this issue based on commit 322f83364bc0807c3147af0631cb7317c584ce43.

@knz
Copy link
Contributor

knz commented Mar 21, 2020

@mrigger can you provide the output of cockroach version? Thanks

cc @asubiotto @jordanlewis for triage.

@knz knz changed the title UPSERT causes a decoding error sql: UPSERT causes a decoding error in collated string column Mar 21, 2020
@awoods187 awoods187 added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Mar 21, 2020
@knz knz added A-sql-mutations Mutation statements: UPDATE/INSERT/UPSERT/DELETE. O-community Originated from the community labels Mar 21, 2020
@mrigger
Copy link
Author

mrigger commented Mar 21, 2020

Here is the output of cockroach version:

Build Tag:    v20.1.0-beta.2-988-g322f83364b
Build Time:   2020/03/21 09:45:52
Distribution: CCL
Platform:     linux amd64 (x86_64-linux-gnu)
Go Version:   go1.13.4
C Compiler:   gcc 8.3.0
Build SHA-1:  322f83364bc0807c3147af0631cb7317c584ce43
Build Type:   development

@asubiotto
Copy link
Contributor

@rohany could you take a look at this given your encoding/decoding expertise?

@rohany rohany assigned rohany and unassigned asubiotto Mar 25, 2020
craig bot pushed a commit that referenced this issue Mar 25, 2020
46570: sql: fix bug with decoding descending collated strings r=otan a=rohany

Fixes #46394.

Fixes a bug where the decoding logic for collated strings
would assume the collated string was always in encoded
to be sorted in ascending order.

Release justification: fixes a bug
Release note (bug fix): Fixes a bug where operations on an index
that contained a collated string in descending order would fail.

Co-authored-by: Rohan Yadav <rohany@alumni.cmu.edu>
@craig craig bot closed this as completed in ac17921 Mar 25, 2020
rohany added a commit to rohany/cockroach that referenced this issue Mar 25, 2020
Fixes cockroachdb#46394.

Fixes a bug where the decoding logic for collated strings
would assume the collated string was always in encoded
to be sorted in ascending order.

Release justification: fixes a bug
Release note (bug fix): Fixes a bug where operations on an index
that contained a collated string in descending order would fail.
rohany added a commit to rohany/cockroach that referenced this issue Mar 25, 2020
Fixes cockroachdb#46394.

Fixes a bug where the decoding logic for collated strings
would assume the collated string was always in encoded
to be sorted in ascending order.

Release justification: fixes a bug
Release note (bug fix): Fixes a bug where operations on an index
that contained a collated string in descending order would fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-mutations Mutation statements: UPDATE/INSERT/UPSERT/DELETE. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants