Skip to content

Support CockroachDB ALTER PRIMARY KEY with structured hash options - #2585

Merged
manticore-projects merged 4 commits into
JSQLParser:masterfrom
minleejae:feat/cockroach-alter-primary-key
Sep 11, 2026
Merged

Support CockroachDB ALTER PRIMARY KEY with structured hash options#2585
manticore-projects merged 4 commits into
JSQLParser:masterfrom
minleejae:feat/cockroach-alter-primary-key

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

With parser.withDialect(Dialect.COCKROACHDB), ALTER TABLE ... ALTER PRIMARY KEY USING COLUMNS (...) now parses into a dedicated AlterExpressionPrimaryKey action. It preserves key ordering, expression keys, optional USING HASH, legacy WITH BUCKET_COUNT = ..., and parenthesized storage parameters such as WITH (bucket_count = 8).

Reuse structured Index.ColumnParams and Index.Option values, share action rendering between the AST and AlterDeParser, and centralize ALTER definition traversal for StatementVisitorAdapter and TablesNamesFinder. Hash and storage expressions participate in custom expression visitors. The new production requires the CockroachDB dialect; existing ALTER forms keep their behavior.

Validation: the original issue reproducer, optional sharding/storage syntax, AST round-trips and mutation, expression traversal and rewriting, statement/action boundaries, malformed input, and isolation from other dialects; full Gradle check and Maven verify.

Syntax reference: CockroachDB SQL grammar (alter_table_cmd, index_elem, and opt_hash_sharded).

Fixes #1743.

@manticore-projects
manticore-projects merged commit 7c6a9fc into JSQLParser:master Sep 11, 2026
9 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

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

Successfully merging this pull request may close these issues.

[FEATURE] Support for CockroachDB

2 participants