Skip to content

Conversation

JanJakes
Copy link
Member

@JanJakes JanJakes commented Jun 4, 2025

This PR implements ADD INDEX and DROP INDEX statements in the new driver.

It was necessary to reorganize some bits of the information schema builder, as indexes and constraints overlap in both the grammar (ALTER TABLE uses a tableConstraintDef node for both indexes and constraints), and in reality (UNIQUE index needs a constraint, UNIQUE constraint needs an index, making them equivalent).

@JanJakes JanJakes requested a review from adamziel June 4, 2025 13:58
@JanJakes JanJakes force-pushed the index-operations branch from 543814d to 2b20845 Compare June 4, 2025 14:09
@adamziel
Copy link
Collaborator

adamziel commented Jun 4, 2025

Let's add some more test cases, e.g. composite unique index with mixed data types, alternating parentheses and no parentheses (colname(14), col2), column ordering (CREATE INDEX reverse_name_idx ON companies (name DESC)) etc. Let's see how far we can stretch the syntax.

@JanJakes
Copy link
Member Author

JanJakes commented Jun 5, 2025

@adamziel Good point! I also forgot about IF NOT EXISTS and IF EXISTS, I will add those as well.

@adamziel
Copy link
Collaborator

adamziel commented Jun 5, 2025

It's also fine to skip some things in this PR as long as we document the limitations. My only concern is merging "ADD INDEX support" without realizing we don't support this or that case.

@JanJakes
Copy link
Member Author

JanJakes commented Jun 6, 2025

@adamziel Good point! I also forgot about IF NOT EXISTS and IF EXISTS, I will add those as well.

I take this back 😄 Neither of these seem to be supported:

@JanJakes
Copy link
Member Author

JanJakes commented Jun 6, 2025

@adamziel It turns out DESC indexes were not fully implemented. Thanks for the catch! I've also added more complex tests and better assertions.

@adamziel adamziel merged commit f762693 into develop Jun 6, 2025
12 checks passed
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.

2 participants