[MDEV-14680] Possible parser mistake - VERSIONING is allowed as identifier Created: 2017-12-16  Updated: 2017-12-27  Resolved: 2017-12-17

Status: Closed
Project: MariaDB Server
Component/s: Parser, Versioned Tables
Affects Version/s: N/A
Fix Version/s: 10.3.4

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

The following erroneous statement

MariaDB [test]> create or replace table t1 (i int) with versioning partition by system_time interval 1 day (partition p0 versioning, partition pn as of current_timestamp);

naturally ends with a syntax error, however the hint about the error location is not helpful:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'partition by system_time interval 1 day (partition p0 versioning, partition pn a' at line 1

WITH <something> clause is accepted here because we can have a CTE in the CREATE statement

MariaDB [test]> create table t1 (i int) with foo as (select 1) select * from foo;
Query OK, 1 row affected (0.16 sec)

and versioning is accepted as a CTE name (or as any other identifier, for that matter):

MariaDB [test]> with versioning as (select 1) select * from versioning;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
 
MariaDB [test]> create table versioning (i int);
Query OK, 0 rows affected (0.19 sec)

The standard says VERSIONING is a reserved word, so I'm not sure it should be allowed as an identifier.



 Comments   
Comment by Sergei Golubchik [ 2017-12-17 ]

What behavior is expected?

create or replace table t1 (i int) with foo partition by system_time interval 1 day (partition p0 versioning, partition pn as of current_timestamp);

also gets ...right syntax to use near 'partition by system_time interval 1 day (partition p0 versioning, partition pn a'

You're right, versioning is allowed as an identifier, because it doesn't introduce ambiguities into the grammar, as far as I know. Or does it? If you have an example where it does, we might need to make versioning reserved.

Comment by Elena Stepanova [ 2017-12-17 ]

I don't have an example for ambiguity, not yet anyway. The behavior caught me by surprise, because the initial statement (create table t (..) with versioning partition ...), was not intentional, I honestly missed system there and then was very confused because the parser complained about PARTITION, which seemed to be in a valid place, it took me a while to realize where the actual problem was. If it complained right syntax to use near 'versioning ...', it would have been much easier (which would have happened if versioning was not allowed as an identifier). That said, I realize that this confusion is not enough reason for extra restrictions, so as long as it's intentional behavior, I'm closing it as not a bug. If we do end up with ambiguity in the final syntax, I'll re-open it.

Generated at Thu Feb 08 08:15:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.