declare constraint as valid - Mailing list pgsql-general

From Torsten Förtsch
Subject declare constraint as valid
Date
Msg-id 5255A41B.6010305@gmx.net
Whole thread Raw
Responses Re: declare constraint as valid
List 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


pgsql-general by date:

Previous
From: Jim Nasby
Date:
Subject: Re: [HACKERS] Urgent Help Required
Next
From: 高健
Date:
Subject: Re: streaming replication timeout error