squawk icon indicating copy to clipboard operation
squawk copied to clipboard

ERROR: access method "hash" does not support unique indexes

Open froque opened this issue 2 months ago • 1 comments

squawk could check for index types for unique indexes

postgres@localhost postgres=# create table foo (id int); 
CREATE TABLE
postgres@localhost postgres=# create unique index concurrently if not exists idx_foo_id_hash on foo using hash(id);
ERROR:  access method "hash" does not support unique indexes
postgres@localhost postgres=# create table points(p point); 
CREATE TABLE
postgres@localhost postgres=# create unique index concurrently if not exists idx_points_p_gist on points using gist(p);  
ERROR:  access method "gist" does not support unique indexes

Currently, only B-tree indexes can be declared unique. https://www.postgresql.org/docs/18/indexes-unique.html

froque avatar Nov 13 '25 16:11 froque

Yeah I think this makes sense to include, I wonder if we need more semantic info, like checking that hash refers to the actual postgres hash or if going off syntax is good enough.

sbdchd avatar Nov 13 '25 23:11 sbdchd