Missing constraint when duplicated unique index ?

From: Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Missing constraint when duplicated unique index ?
Date: 2025-03-12 19:52:16
Message-ID: CAB-JLwbyBSq8diW2=-nKm+n=iPZcuWdwm25D_=EUEDDALzWGKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

CREATE TABLE table_test (
foo text NOT NULL,
CONSTRAINT test_pk PRIMARY KEY (foo),
CONSTRAINT test_uq UNIQUE (foo)
);
building index "pg_toast_29364884_index" on table "pg_toast_29364884"
serially
building index "test_pk" on table "table_test" serially

pg_class has 3 records, table, its pk and unique indexes.
select * from pg_class where relname ~ '
pg_toast_29364884_index|test_pk|table_test';

but pg_constraint has just one record.
select * from pg_constraint where conrelid::regclass::text ~
'table_test|pg_toast_29364884'

Is that correct ? That second index exists but not its constraint.
This happens only when the primary key field is text, so it needs toast.

regards
Marcos

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-03-12 19:58:50 Re: making EXPLAIN extensible
Previous Message Tom Lane 2025-03-12 19:50:08 Re: making EXPLAIN extensible