Re: pg_restore order and check constraints

From: Martín Marqués <martin(at)2ndquadrant(dot)com>
To: Moshe Jacobson <moshe(at)neadwerx(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_restore order and check constraints
Date: 2013-06-23 21:04:52
Message-ID: 51C762F4.7030609@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Moshe Jacobson 2013-06-24 01:47:09 Re: pg_restore order and check constraints
Previous Message Tom Lane 2013-06-23 17:28:05 Re: Postgres DB crashing