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

The result of "show create table" cannot be used directly in mysql #3530

Closed
MichaelScofield opened this issue Mar 18, 2024 · 10 comments
Closed
Labels
C-bug Category Bugs

Comments

@MichaelScofield
Copy link
Collaborator

What type of bug is this?

User Experience

What subsystems are affected?

Standalone mode

Minimal reproduce step

Just execute "show create table" against any table in the Dashboard. Copy, paste and run the result in the mysql cli.

What did you expect to see?

The result can be executed in mysql cli successfully.

What did you see instead?

Server returns an error:

mysql> create table bar ("ts" timestamp time index);
ERROR 1815 (HY000): sql parser error: Expected column name or constraint definition, found: "ts"

The result of "show create table" displays the column name as double quoted string, which is not valid in mysql.

For mysql, the only valid quotes here are backtick, or none. For postgresql, it's double quote or none. So maybe we can make the result not quoted at all?

What operating system did you use?

macos

What version of GreptimeDB did you use?

main

Relevant log output and stack trace

No response

@MichaelScofield MichaelScofield added the C-bug Category Bugs label Mar 18, 2024
@waynexia
Copy link
Member

waynexia commented Mar 18, 2024

Just execute "show create table" against any table in the Dashboard. Copy, paste and run the result in the mysql cli.

This is an expected behavior. Different protocol has different quote escape schemes. The SQL you got can only be used at where you got it. You cannot use the SQL from PG in MySQL either

@MichaelScofield
Copy link
Collaborator Author

There's no "show create table" like statement in postgresql, it's mysql only. So it's a little counterintuitive that the output cannot be directly executed in mysql again.

@waynexia
Copy link
Member

HTTP protocol is the third SQL interface. Its behavior is "closer" to PG and it supports "SHOW CREATE TABLE" clause.

@MichaelScofield
Copy link
Collaborator Author

If it's "third", it's supposed to be neutral. Actually in this case, it should be biased to mysql, because "show create table" is mysql only.

@waynexia
Copy link
Member

Then you won't be able to execute the SQL you get right in where you get it. Result of SHOW CREATE TABLE in the dashboard cannot be run in the dashboard. This is more wired to me.

Given the SQL itself is a mess of substandard things, I won't recommend you mix different protocols in any case. We are compatible with many SQL clients doesn't mean we can (and it's not even possible) fill the gap between different protocols.

@tisonkun
Copy link
Collaborator

One more point is that quote is significant for case sensitive, so we cannot simply drop the quote.

This happens commonly when we accept "measurements" in influxdb line protocol or prometheus that are in camelCase.

@killme2008
Copy link
Contributor

Agree with @waynexia , the HTTP endpoint in the dashboard is another SQL protocol, you can't expect the result to be executed directly in MySQL Client, but you should able to run it in the dashboard too.

@tisonkun
Copy link
Collaborator

Closed as not a bug.

@tisonkun tisonkun closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2024
@killme2008
Copy link
Contributor

I have a new idea that makes dashboard support sql dialect selection, the user can choose their favorite dialect including:

  • MySQL
  • PG
  • GreptimeDB(or generic, the default chosen)

@waynexia
Copy link
Member

We can support this via another SET clause. I remember MySQL also provides an ORACLE-compatible mode by setting, which will change some behaviors.

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

No branches or pull requests

4 participants