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

distsql: roundtrip to string does not respect precedence of ::: and - #15617

Closed
eisenstatdavid opened this issue May 2, 2017 · 5 comments
Closed

Comments

@eisenstatdavid
Copy link

Run

CREATE TABLE t (c int PRIMARY KEY);
INSERT INTO t VALUES (1), (2), (3);
SELECT (-9223372036854775808) ::: INT;
SELECT c FROM t WHERE (c, c) < (1, -9223372036854775808);

and get

Error: pq: ($0, $0) < (1, - 9223372036854775808:::INT): tuples ($0, $0), (1, - 9223372036854775808:::INT) are not comparable at index 2: numeric constant out of int64 range

Turn off distsql and the problem goes away.

@eisenstatdavid eisenstatdavid added this to the 1.0 milestone May 2, 2017
@eisenstatdavid eisenstatdavid self-assigned this May 2, 2017
@petermattis
Copy link
Collaborator

For known-limitations, we've been setting the milestone to when we expect the issue to be fixed.

@vivekmenezes
Copy link
Contributor

This is still an issue:

root@:26257/test> SELECT c FROM t WHERE (c, c) < (1, -9223372036854775808);
pq: ($0, $0) < (1, -9223372036854775808:::INT): tuples ($0, $0), (1, -9223372036854775808:::INT) are not comparable at index 2: numeric constant out of int64 range
root@:26257/test> set distsql=off;
SET

Time: 319.448µs

root@:26257/test> SELECT c FROM t WHERE (c, c) < (1, -9223372036854775808);
+---+
| c |
+---+
+---+
(0 rows)

Time: 1.292733ms

@vivekmenezes
Copy link
Contributor

I'm still looking at this, but the problem is that via the distsql path -9223372036854775808 is converted to an intVal type, while using the normal path it is converted to an int64Val

@RaduBerinde
Copy link
Member

RaduBerinde commented Sep 6, 2017

The problem is that we are serializing the filter expression as (@1, @1) < (1:::INT, -9223372036854775808:::INT).

This doesn't work:

root@:26257/test> SELECT -9223372036854775808:::INT;
pq: numeric constant out of int64 range

The correct serialization would be (@1, @1) < (1:::INT, '-9223372036854775808':::INT)

@RaduBerinde RaduBerinde assigned RaduBerinde and unassigned richardwu Sep 6, 2017
@RaduBerinde
Copy link
Member

I can take this, I know what piece of code needs to be fixed.

@RaduBerinde RaduBerinde changed the title sql: roundtrip to string does not respect precedence of ::: and - distsql: roundtrip to string does not respect precedence of ::: and - Sep 6, 2017
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Sep 6, 2017
Correcting the serialization of negative integers from `-5:::INT` to
`'-5':::INT`.

Fixes cockroachdb#15617.
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Sep 7, 2017
Correcting the serialization of negative integers from `-5:::INT` to
`'-5':::INT`.

Fixes cockroachdb#15617.
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Sep 7, 2017
Correcting the serialization of negative integers from `-5:::INT` to
`'-5':::INT`.

Fixes cockroachdb#15617.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants