Skip to content

A warning about partial indexes and uniqueness #10

@bugthunk

Description

@bugthunk

To make names unique for partial indexes, hpqtypes-extras hashes the WHERE clause and appends it to the name. PostgreSQL has a hard upper limit for identifiers set to 63 characters, cf. the manual. Now, since take 63 is done after processing the whole name, we could end up dropping the hash altogether; suppose the hash is deadbeef and witness:

psql> create index idx__some_long_table_name__some_column_with_a_really_long_name__deadbeef on some_long_table_name (some_column_with_a_really_long_name) where $CONDITION;
NOTICE:  identifier "idx__some_table__some_column_with_a_really_long_name__deadbeef" will be truncated to "idx__some_long_table_name__some_column_with_a_really_long_name_"
CREATE INDEX

It would thus be impossible to have hpqtypes-extras define two indexes differing only in the condition for partiality (i.e. differing only in the WHERE clause).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions