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

Vitess does not like parenthesis around selects #6305

Closed
Topographic0cean opened this issue Jun 11, 2020 · 1 comment
Closed

Vitess does not like parenthesis around selects #6305

Topographic0cean opened this issue Jun 11, 2020 · 1 comment

Comments

@Topographic0cean
Copy link

#5737 ## Overview of the Issue

We are evaluating using Vitess with our existing application. We simply put Vitess in front of our mysql 5.6 db and directed the app to Vitess with no sharding. We have seen a couple of queries fail with syntax errors that we were not expecting. If they are documented, we could not find them. The first is when there are extra parenthesis around the select. Here is vtexplain with a simplified example:

if I remove the parenthesis, vitess is happy. Note that mysql is happy with either. You may argue that the parens are not needed in this case, but we were wondering why vitess fails.

Reproduction Steps

Steps to reproduce this issue, example:

  1. Deploy the following vschema which is basically empty:

{
"mainkeyspace": {
"sharded": false,
"vindexes": {
"hash": {
"type": "hash"
},
"md5": {
"type": "unicode_loose_md5",
"params": {},
"owner": ""
},
"users_name_idx": {
"type": "lookup_hash",
"params": {
"from": "name",
"table": "users_name_idx",
"to": "user_id"
},
"owner": "users"
}
},
"tables": {
}
}
}
```

  1. Deploy the following schema:

CREATE TABLE notification (
name varchar(255) DEFAULT NULL,
sys_created_on datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
```

  1. Run vtexplain
    vtexplain -sql-file stmt.sql -schema-file schema.sql -vschema-file vschema.json

  2. View error
    ERROR: vtexplain execute error in '(SELECT notification.name, notification.sys_created_on AS order FROM notification WHERE notification.sys_created_on >= '2020-04-24') ORDER BY order': syntax error at position 147 near 'ORDER'

  3. Show non-error case
    If we remove the extra parens, it works:
    vtexplain -sql-file stmt.sql -schema-file schema.sql -vschema-file vschema.json


SELECT notification.name, notification.sys_created_on AS order FROM notification WHERE notification.sys_created_on >= '2020-04-24' ORDER BY order

1 mainkeyspace/-: select notification.name, notification.sys_created_on as order from notification where notification.sys_created_on >= '2020-04-24' order by order asc limit 10001


Operating system and Environment details

We are testing this on a Mac OSX Catalina (10.15.5) as that is our development environment.

sougou added a commit to planetscale/vitess that referenced this issue Jun 17, 2020
Start of fix for vitessio#6305

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
@harshit-gangal
Copy link
Member

PR: #6342 fixes this issue

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

No branches or pull requests

2 participants