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

No support for LOCK TABLES #1142

Closed
ksqsf opened this issue Mar 27, 2021 · 3 comments
Closed

No support for LOCK TABLES #1142

ksqsf opened this issue Mar 27, 2021 · 3 comments

Comments

@ksqsf
Copy link

ksqsf commented Mar 27, 2021

Describe the bug
JSqlParser doesn't support LOCK TABLES and throws ParseException: Encountered unexpected token.

To Reproduce
SQL:

-- Other Parsable Statements;
LOCK TABLES `table` WRITE;
-- Other Parsable Statements;
-- UNLOCK...

Parsing:

        val file = File(path).bufferedReader()
        val parser = CCJSqlParser(file.readText())

Exception:

Exception in thread "main" net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "LOCK" <S_IDENTIFIER>
    at line 42, column 1.

Was expecting one of:

    "("
    ";"
    "ALTER"
    "BEGIN"
    "CALL"
    "COMMENT"
    "COMMIT"
    "CREATE"
    "DECLARE"
    "DELETE"
    "DESCRIBE"
    "DROP"
    "EXEC"
    "EXECUTE"
    "EXPLAIN"
    "GRANT"
    "INSERT"
    "MERGE"
    "REPLACE"
    "SET"
    "SHOW"
    "TRUNCATE"
    "UPDATE"
    "UPSERT"
    "USE"
    "VALUES"
    "WITH"
    <K_SELECT>

	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:26538)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:26377)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statements(CCJSqlParser.java:511)

Expected behavior
Parse it into an AST.

System
Ref: https://dev.mysql.com/doc/refman/8.0/en/lock-tables.html

@ksqsf
Copy link
Author

ksqsf commented Mar 27, 2021

Is there a way to ignore such unparsable statements?

@wumpz
Copy link
Member

wumpz commented Apr 10, 2021

Look into StatementsTest. There are examples of parser.setErrorRecovery(true);. This skips unparsable statements.

@manticore-projects
Copy link
Contributor

See UnsupportedStatements as explain in #1945 (unless you will sponsor or provide a specific implementation of this feature.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants