Skip to content

fix(sql): preserve index operator classes when cloning - #6737

Open
cangen185-sudo wants to merge 1 commit into
alibaba:masterfrom
cangen185-sudo:codex/fix-index-operator-class-clone
Open

cangen185-sudo wants to merge 1 commit into
alibaba:masterfrom
cangen185-sudo:codex/fix-index-operator-class-clone

Conversation

@cangen185-sudo

@cangen185-sudo cangen185-sudo commented Oct 15, 2026 •

Copy link
Copy Markdown

Description

Cloning a parsed PostgreSQL CREATE INDEX statement drops the indexed column's operator class. The parser and SQL output visitor support opclass, but SQLSelectOrderByItem.clone() does not copy it; SQLIndexDefinition.cloneTo() and SQLCreateIndexStatement.clone() use that method.

Deep-clone opclass through its setter, and attach the expression's parent in setOpclass() consistently with setExpr(). Collation, direction and NULL ordering continue to be copied as before.

Reproduction and validation

The added regression parses an index column containing "pg_catalog"."text_ops", COLLATE, ASC and NULLS LAST, then compares the original and cloned SQL. Before the fix, the cloned SQL omits "pg_catalog"."text_ops". Two further regressions check the parsed/set operator class's parent and the null/clear path.

Test stage Code under test Result
Expanded local recheck after the fix Current PR commit fcc35ec7207f46d50b7578d5598108502168747f 82 tests passed, 0 failed, 0 errors, 0 skipped, across the explicitly enumerated PostgreSQL BVT classes and order-by equality regression.
Defect reproduction before the fix Original production code The 3 new regression tests failed as expected, confirming the defect; 0 execution errors.

Focused verification command (5 tests passed):

mvn -B -ntp -pl core -Dtest=PGIndexOpclassCloneTest,Issue5780,EqualTest_orderBy surefire:test
  • Maven test lifecycle compiled the core production/test sources; repository Checkstyle reported 0 violations.
  • git diff --check: passed.
  • Windows 11, Microsoft OpenJDK 17.0.20.1, Maven 3.9.11. No external database or full-repository runtime test pass is claimed.

The expanded recheck followed a clean compilation. A broad name-based probe also selected legacy tests outside the configured BVT suite: PGUpsertTest differs only by a trailing semicolon, and PGAlterTest reports an existing OWNER TO parser gap. Both reproduce unchanged on a clean upstream checkout. They are not included in the 82 passing BVT results; no whole-repository pass is claimed.

Searches for opclass, SQLSelectOrderByItem and clone/index PRs found no equivalent contribution. This is a new locally reproduced defect; it does not claim to fix #6731, whose lexer boundary is already corrected on current master.

The contributor has signed the CLA; the live license/cla check passed. GitHub Actions still requires maintainer approval.

Codex assisted with audit, reproduction, implementation and validation; a bounded read-only review checked the AST call path. Ready for maintainer review.

@CLAassistant

CLAassistant commented Oct 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cangen185-sudo
cangen185-sudo marked this pull request as ready for review October 15, 2026 01:27
@cangen185-sudo
cangen185-sudo marked this pull request as draft October 15, 2026 01:28
@cangen185-sudo
cangen185-sudo marked this pull request as ready for review October 15, 2026 01:42
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.

[Bug] MySqlLexer.isIdentifierChar throws ArrayIndexOutOfBoundsException when char == 256 (U+0100)

2 participants