[GENERAL] dump/restore with a hidden dependency?

2014-08-07 Thread Chris Curvey
I have a database with the following structure: Create table bar... Create function subset_of_bar ... (which does a select on a subset of bar) Create table foo... Alter table foo add constraint mycheck check subset_of_bar(id); I pg_dumped my database, and tried to pg_restore it on another

Re: [GENERAL] dump/restore with a hidden dependency?

2014-08-07 Thread Shaun Thomas
On 08/07/2014 10:00 AM, Chris Curvey wrote: I’ve done some searching and am coming up empty. Is there a way to get pg_restore to apply constraints AFTER loading all the tables Kinda. PostgreSQL applies constraints with hidden system-level triggers. An easy way to turn them off is to use

Re: [GENERAL] dump/restore with a hidden dependency?

2014-08-07 Thread Shaun Thomas
On 08/07/2014 01:09 PM, Chris Curvey wrote: The disable trigger statement runs without error, but does not seem to have any effect. :( Apparently this trick only works for disabling foreign keys. I'm not sure how to temporarily disable check constraints. You might have to drop the

Re: [GENERAL] dump/restore with a hidden dependency?

2014-08-07 Thread Chris Curvey
-Original Message- From: Shaun Thomas [mailto:stho...@optionshouse.com] Sent: Thursday, August 07, 2014 12:43 PM To: Chris Curvey; pgsql-general@postgresql.org Subject: Re: [GENERAL] dump/restore with a hidden dependency? On 08/07/2014 10:00 AM, Chris Curvey wrote: I've done

Re: [GENERAL] dump/restore with a hidden dependency?

2014-08-07 Thread Tom Lane
Chris Curvey ccur...@zuckergoldberg.com writes: I have a database with the following structure: Create table bar... Create function subset_of_bar ... (which does a select on a subset of bar) Create table foo... Alter table foo add constraint mycheck check subset_of_bar(id); Basically, that's

Re: [GENERAL] dump/restore with a hidden dependency?

2014-08-07 Thread Chris Curvey
-Original Message- From: Tom Lane [mailto:t...@sss.pgh.pa.us] Sent: Thursday, August 07, 2014 2:50 PM To: Chris Curvey Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] dump/restore with a hidden dependency? Chris Curvey ccur...@zuckergoldberg.com writes: I have a database

Re: [GENERAL] dump/restore with a hidden dependency?

2014-08-07 Thread David G Johnston
Chris Curvey-3 wrote -Original Message- From: Tom Lane [mailto: tgl@.pa ] Sent: Thursday, August 07, 2014 2:50 PM To: Chris Curvey Cc: pgsql-general@ Subject: Re: [GENERAL] dump/restore with a hidden dependency? Chris Curvey lt; ccurvey@ gt; writes: I have a database

Re: [GENERAL] dump/restore with a hidden dependency?

2014-08-07 Thread Kevin Grittner
Chris Curvey ccur...@zuckergoldberg.com wrote: Perhaps a pair of triggers?  An insert-or-update trigger on foo, and a delete-or-update trigger on bar? Using a foreign key constraint is best if that can do the right thing.  If that doesn't work, triggers like you describe are probably the best