fix: avoid crash by setting default index constraint type#508
Merged
staticlibs merged 1 commit intoJul 9, 2026
Merged
Conversation
staticlibs
pushed a commit
that referenced
this pull request
Jul 9, 2026
This is a backport of the PR #508 to `v1.5-variegata` stable branch. Resolves #507 `duckdb_indexes()` scanning an attached Postgres catalog can crash with an internal assertion: ```text INTERNAL Error: Assertion triggered in file "duckdb/src/parser/parsed_data/create_index_info.cpp" on line 65: constraint_type == IndexConstraintType::UNIQUE || constraint_type == IndexConstraintType::NONE ``` `PostgresIndexSet::LoadEntries` constructs a `CreateIndexInfo` for every Postgres index then lazily loads into the catalog. But it doesn't assign `constraint_type`. Since the field has no default it ends up being whatever garbage memory that happens to be sitting at the address at the time, which then flows straight into the catalog entry. Anything that later calls `ToSQL()`/`ToString()` on it asserts if the value isn't `UNIQUE` or `NONE`. That then causes a crash in some scenario Explicitly initializing `constraint_type` to `NONE` right where the entry is built, the same place every other field on `info` is already set ```cpp CreateIndexInfo info; info.constraint_type = IndexConstraintType::NONE; info.SetQualifiedName(...); ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #507
Problem
duckdb_indexes()scanning an attached Postgres catalog can crash with an internal assertion:PostgresIndexSet::LoadEntriesconstructs aCreateIndexInfofor every Postgres index then lazily loads into the catalog. But it doesn't assignconstraint_type. Since the field has no default it ends up being whatever garbage memory that happens to be sitting at the address at the time, which then flows straight into the catalog entry. Anything that later callsToSQL()/ToString()on it asserts if the value isn'tUNIQUEorNONE. That then causes a crash in some scenarioFix
Explicitly initializing
constraint_typetoNONEright where the entry is built, the same place every other field oninfois already setCreateIndexInfo info; info.constraint_type = IndexConstraintType::NONE; info.SetQualifiedName(...);