Re: pg_restore order and check constraints - Mailing list pgsql-general

From Martín Marqués
Subject Re: pg_restore order and check constraints
Date
Msg-id 51C762F4.7030609@2ndquadrant.com
Whole thread Raw
In response to pg_restore order and check constraints  (Moshe Jacobson <moshe@neadwerx.com>)
Responses Re: pg_restore order and check constraints
List pgsql-general
El 23/06/13 13:34, Moshe Jacobson escribió:
> Hi,
>
> I recently added a check constraint onto a table in my database, that
> uses a stored procedure to check one of the inserted columns against the
> data of another table.

Is it possible to see the function?

> I know that this is stretching the limit of what a check constraint is
> meant to be, but is there a way, short of editing the pg_restore list
> manually every time, to guarantee that the table used for validation is
> populated before the table with the data being validated?

What for? If the dumps actually are taken without contraints, data
restored (much faster as no constraints have to be checked, and just
then constraints are added via ALTER TABLE.

> Right now it is restoring out of order, and the table is not getting
> populated correctly.

Why not?

> if I have to rewrite as a trigger, I will do that, but I like the check
> constraint because it checks all of the entries when it's applied. Any
> suggestions?

We'd need to see how the constraint is added, and the function you say
is used for checking the constrants.

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Postgres DB crashing
Next
From: Moshe Jacobson
Date:
Subject: Re: pg_restore order and check constraints