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

Check table syntax support. #4673

Open
winkyao opened this issue Sep 28, 2017 · 4 comments
Open

Check table syntax support. #4673

winkyao opened this issue Sep 28, 2017 · 4 comments

Comments

@winkyao
Copy link
Contributor

winkyao commented Sep 28, 2017

See https://dev.mysql.com/doc/refman/5.7/en/check-table.html

@winkyao
Copy link
Contributor Author

winkyao commented Sep 28, 2017

In mysql-test analyze.test use the statement.

@morgo
Copy link
Contributor

morgo commented Nov 24, 2018

This syntax is really a MyISAM-ism. In InnoDB I believe it just reads the pages from the table to make sure the page checksums are verified. I assume in TiDB it could be just mapped to SELECT * FROM table + SELECT indexName from table (for each of the indexes other than the primary key).

@morgo
Copy link
Contributor

morgo commented Jan 14, 2019

A correction to my previous comment, there is a strong use-case for CHECK TABLE on a view:

The MySQL server will allow tables that a view references to be removed without dependency checking, so CHECK TABLE serves a useful purpose of ensuring a view is queryable.

@ghost
Copy link

ghost commented Jul 30, 2020

Confirming this issue still exists in master:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
CHECK TABLE t1;

CREATE OR REPLACE VIEW v1 AS SELECT 1;
CHECK TABLE v1;

..

mysql> CHECK TABLE t1;
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 5 near "CHECK TABLE t1" 
mysql> 
mysql> CREATE OR REPLACE VIEW v1 AS SELECT 1;
Query OK, 0 rows affected (0.10 sec)

mysql> CHECK TABLE v1;
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 5 near "CHECK TABLE v1" 
mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-859-gccfc9b2ad
Edition: Community
Git Commit Hash: ccfc9b2ad0dcf8e447210de5f559d7fc208db968
Git Branch: master
UTC Build Time: 2020-07-29 09:37:45
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@ghost ghost added the component/parser label Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants