Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A warning about partial indexes and uniqueness #10

Open
bugthunk opened this issue Nov 27, 2017 · 3 comments
Open

A warning about partial indexes and uniqueness #10

bugthunk opened this issue Nov 27, 2017 · 3 comments
Labels

Comments

@bugthunk
Copy link
Contributor

bugthunk commented Nov 27, 2017

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).

@23Skidoo
Copy link
Contributor

23Skidoo commented Dec 8, 2017

Fixed by #12.

@23Skidoo 23Skidoo closed this as completed Dec 8, 2017
@bugthunk
Copy link
Contributor Author

bugthunk commented Dec 8, 2017

I think we misunderstood each other (private chat). #12 does not address this. Sorry if I was unclear.

@bugthunk bugthunk reopened this Dec 8, 2017
@23Skidoo
Copy link
Contributor

23Skidoo commented Dec 8, 2017

Oops, sorry, closed the wrong one by mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants