JSQLParser / JSqlParser

JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern
https://github.com/JSQLParser/JSqlParser/wiki
Apache License 2.0
5.33k stars 1.34k forks source link

[FEATURE] Support for CockroachDB #1743

Open andyfrith-rm opened 1 year ago

andyfrith-rm commented 1 year ago

Grammar or Syntax Description

Can support be added for CockroachDB? It is based on Postgres however there are a few differences which means there are some SQL statements that are considered valid.

SQL Example

Example of missing SQL is the "USING" statement for https://www.cockroachlabs.com/docs/v22.1/hash-sharded-indexes

ALTER TABLE FEATURE_SWITCH_CONFIG ALTER PRIMARY KEY USING COLUMNS (FEATURE_NAME) USING HASH

Caused by: net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "USING" "USING"
    at line 1, column 53.

Additional context

Tested in version 4.5

manticore-projects commented 1 year ago

Greetings.

Unfortunately the whole ALTER TABLE statement needs a serious refactoring.

ALTER TABLE ... ALTER PRIMARY KEY ... seems to be completely broken to me, not only regarding to your specific syntax.

This thing is so messy, that I would only touch it when a sponsor shows up.

We could maybe start with a SQL:2016 compliant implementation from scratch.