Skip to content

fix: avoid crash init index constraint type (1.5)#509

Merged
staticlibs merged 1 commit into
duckdb:v1.5-variegatafrom
staticlibs:constraint_init_15
Jul 9, 2026
Merged

fix: avoid crash init index constraint type (1.5)#509
staticlibs merged 1 commit into
duckdb:v1.5-variegatafrom
staticlibs:constraint_init_15

Conversation

@staticlibs

Copy link
Copy Markdown
Member

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:

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

CreateIndexInfo info;
info.constraint_type = IndexConstraintType::NONE;
info.SetQualifiedName(...);

This is a backport of the PR duckdb#508 to `v1.5-variegata` stable branch.

Resolves duckdb#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(...);
```
@staticlibs staticlibs merged commit 73396b5 into duckdb:v1.5-variegata Jul 9, 2026
7 checks passed
@staticlibs staticlibs deleted the constraint_init_15 branch July 9, 2026 09:09
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