declare constraint as valid

From: Torsten Förtsch <torsten(dot)foertsch(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: declare constraint as valid
Date: 2013-10-09 18:44:43
Message-ID: 5255A41B.6010305@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

assuming a constraint is added to a table as NOT VALID. Now I know it IS
valid. Can I simply declare it as valid by

update pg_constraint
set convalidated='t'
where conrelid=(select c.oid
from pg_class c
join pg_namespace n on (n.oid=c.relnamespace)
where c.relname='tablename'
and n.nspname='schemaname')
and conname='constraintname';

instead of

alter table tablename validate constraint ...

Or does the latter have other side effects?

I am asking because I want to avoid the ACCESS EXCLUSIVE lock required
by the ALTER TABLE. I am sure there are no rows violating the constraint.

Thanks,
Torsten

Responses

Browse pgsql-general by date

  From Date Subject
Next Message 高健 2013-10-10 00:51:57 Re: streaming replication timeout error
Previous Message Jim Nasby 2013-10-09 18:11:30 Re: Urgent Help Required