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

Incompatible with MySQL 8.0 about create table with default expression #10377

Closed
lonng opened this issue May 7, 2019 · 3 comments · Fixed by #32608
Closed

Incompatible with MySQL 8.0 about create table with default expression #10377

lonng opened this issue May 7, 2019 · 3 comments · Fixed by #32608
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. type/compatibility

Comments

@lonng
Copy link
Contributor

lonng commented May 7, 2019

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.
➜  ~ tidiff 'create table ttest ( a int(10) default (rand()))'
MySQL(127.0.0.1:3306)> create table ttest ( a int(10) default (rand()))
Query OK (0.007 sec)

TiDB(127.0.0.1:4000)> create table ttest ( a int(10) default (rand()))
Error 1105: line 1 column 40 near "rand()))" (total length 48)

➜  ~ tidiff 'desc ttest'
MySQL(127.0.0.1:3306)> desc ttest
+------------------------------------------------------------+
| Field | Type    | Null | Key | Default | Extra             |
+------------------------------------------------------------+
| a     | int(10) | YES  |     | rand()  | DEFAULT_GENERATED |
+------------------------------------------------------------+
1 row in set (0.003 sec)

TiDB(127.0.0.1:4000)> desc ttest
Error 1146: Table 'test.ttest' doesn't exist
  1. What did you expect to see?

Create table successfully.

  1. What did you see instead?

Error message show above.

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
TiDB(127.0.0.1:4000)> select tidb_version()
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                                            |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v2.1.8-24-g7b36cdfb6-dirty
Git Commit Hash: 7b36cdfb6e8a4c279fc360ed79cf1c499b553688
Git Branch: failpoint-2.1
UTC Build Time: 2019-04-30 08:26:17
GoVersion: go version go1.12 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.002 sec)
@lonng lonng added type/bug The issue is confirmed as a bug. type/compatibility good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels May 7, 2019
@lonng lonng changed the title Incompatible issues about create table with default expression Incompatible with MySQL 8.0 about create table with default expression May 7, 2019
@ghost ghost removed the type/bug The issue is confirmed as a bug. label Jul 14, 2020
@ghost
Copy link

ghost commented Jul 14, 2020

This is not a bug, but a MySQL 8.0 compatibility issue. Functions as default values was added after 8.0 GA. Here is the output from MySQL 5.7-latest:

mysql [localhost:5731] {msandbox} (test) > create table ttest ( a int(10) default (rand()));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(rand()))' at line 1

@morgo morgo mentioned this issue Jul 14, 2020
70 tasks
@morgo
Copy link
Contributor

morgo commented Sep 20, 2021

The matching parser issue is pingcap/parser#1347

@CbcWestwolf
Copy link
Member

Implement curdate()/current_date in #40326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants