[MDEV-7381] Reversed executable comments Created: 2014-12-26 Updated: 2020-11-16 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Parser |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Federico Razzoli | Assignee: | Anel Husakovic |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | beginner-friendly | ||
| Description |
|
It would be great to have "reversed executable comments", that is, commented code that is only parsed on versions older ##.##.##. An example is when we want to execute CREATE OR REPLACE TABLE on 10.0, and CREATE TABLE IF NOT EXISTS on older versions. |
| Comments |
| Comment by Elena Stepanova [ 2014-12-26 ] | ||||||||||||||||||||||||
|
It looks like a generic feature request, not a bug anyhow related to CREATE OR REPLACE TABLE. a) indeed, CREATE OR REPLACE TABLE IF NOT EXISTS does not work, simply because it makes no logical sense, Of course, in some specific situations (and yours might be one of those, I can't know) it can make sense. I suggest you modify the subject to the request about reversed executable comments, having CREATE OR REPLACE vs NOT EXISTS as a mere example of what you're trying to achieve, and I'll convert the issue into a task. | ||||||||||||||||||||||||
| Comment by Federico Razzoli [ 2014-12-27 ] | ||||||||||||||||||||||||
|
I agree, so I made the changes. But I can't change a bug to feature request. | ||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2018-01-09 ] | ||||||||||||||||||||||||
|
A possible syntax could be
| ||||||||||||||||||||||||
| Comment by Gabriel Ciciliani [ 2020-02-11 ] | ||||||||||||||||||||||||
|
I'll start working on this ticket | ||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-10-24 ] | ||||||||||||||||||||||||
|
Hi gabocic still wanting to work on this MDEV? Some background around lex and this MDEV.
So there is a function lex_one_token() -> sql/sql_lex.cc, which is checking the next state of the token from list of possible values found include/m_ctype.h using my_lex_states.
For comments handling there are 2 members of this structure (found in sql/sql_lex.h):
where enum can be:
The best situation we can observe on debugging an example:
Now in sql/sql_lex.cc there is a logic for handling versioned comments for MySQL version higher or equal than 5.7 and {{MariaDB}}specific:
Note: MYSQL_VERSION_ID defined in include/mysql_version.h.in and represents latest version of server (in my case 10.2.35 latest Debug build atm). So regarding the suggested syntax of reversed comments:
Note: after testing found that nesting of comments doesn't work and should it?
f_razzoli serg please let me know your thoughts regarding above questions. | ||||||||||||||||||||||||
| Comment by Gabriel Ciciliani [ 2020-11-12 ] | ||||||||||||||||||||||||
|
Hi @Anel Husakovic Yes, I'm still interested in working on this ticket, although I'm currently not finding the time to do it. If you can keep this ticket with me for a few more weeks, I'll do my best to start digging into it. Thanks! | ||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-11-16 ] | ||||||||||||||||||||||||
|
Hi gabocic sure, take your time, probably will be free couple more weeks. |