pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.41k stars 5.85k forks source link

Add comment syntax for TiDB to ignore sections of queries #19163

Open kolbe opened 4 years ago

kolbe commented 4 years ago

Feature Request

Is your feature request related to a problem? Please describe:

Sometimes, there are syntax elements that are required in MySQL (or MariaDB, etc.) but might be unnecessary in TiDB or might cause errors.

Describe the feature you'd like:

It would be nice if there was a way to tell TiDB to ignore sections of a query while still allowing them to be parsed by other database systems.

For example:

ALTER TABLE t1 /*T!<--*/ ALGORITHM=INPLACE /*T!-->*/;

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

This would be really useful during migrations and PoCs where a user may want code that can run on TiDB as well as on other databases.

kolbe commented 4 years ago

Maybe instead of doing the weird syntax with commented out comments, it's better to be more explicit?

ALTER TABLE X
   MODIFY COLUMN Y ...
   /*+ tidb_comment_start */
   ALGORITHM INPLACE
   /*+ tidb_comment_end */
;
zz-jason commented 4 years ago

I'm going to mark this feature request as accepted, but the solution needs more discussion.