pingcap / parser

A MySQL Compatible SQL Parser
Apache License 2.0
1.41k stars 489 forks source link

Cannot parse 2 consecutive identifiers that both start with digit #1203

Closed kolbe closed 3 years ago

kolbe commented 3 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do? If possible, provide a recipe for reproducing the error.
select * from 1db.1table;
  1. What did you expect to see?
ERROR 1146 (42S02): Table '1db.1table' doesn't exist
  1. What did you see instead?
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 19 near ".1table"
  1. What version of TiDB SQL Parser are you using?
Release Version: v4.0.0-beta.2-2135-gd6a2b9a37-dirty
Edition: Community
Git Commit Hash: d6a2b9a372edd3638c0ed88e1d2a5e6b702a69ed
Git Branch: master
UTC Build Time: 2021-02-11 02:48:59
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
kolbe commented 3 years ago

This occurs whether it's 1db.1table or 1table.1col et cetera:

tidb> select * from 1table.1col;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 22 near ".1col"
tidb> select * from table.1col;
ERROR 1146 (42S02): Table 'table.1col' doesn't exist
tidb> select * from db.1table.1col;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 24 near ".1col"
morgo commented 3 years ago

I bisected this to a regression of https://github.com/pingcap/tidb/pull/21908

@xiongjiwei do you mind taking a look?