pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Dropped table screws referential integrity?
4+ messages / 4 participants
[nested] [flat]

* Dropped table screws referential integrity?
@ 2002-03-07 14:56 Joel Mc Graw <jmcgraw@databill.com>
  2002-03-07 16:57 ` Re: Dropped table screws referential integrity? Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2002-03-07 18:37 ` Re: Dropped table screws referential integrity? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 4+ messages in thread

From: Joel Mc Graw @ 2002-03-07 14:56 UTC (permalink / raw)
  To: pgsql-admin

I had a table (job_documents) that referenced another (jobs).  I no
longer needed job_documents, so I dropped it.  Now, any attempt to
delete rows from jobs fails--it complains that job_documents doesn't
exist.  Is there a way to fix this?

PostgreSQL 7.1.3/FreeBSD 4.2R


TIA





------------------------------------------------------
Joel Mc Graw
DataBill, LLC
602-415-1234 ext. 13

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d-@ s: a C++++ UB++++ P-- L- E? W++ N w--- O? M+ V
PS+++ PE++ Y+ PGP++ t+ 5++ X tv+ b+ DI++ G e++ h---- r+++ y++++
-----END GEEK CODE BLOCK-----






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Dropped table screws referential integrity?
  2002-03-07 14:56 Dropped table screws referential integrity? Joel Mc Graw <jmcgraw@databill.com>
@ 2002-03-07 16:57 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2002-03-07 19:08   ` Re: Dropped table screws referential integrity? Joel Burton <joel@joelburton.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Stephan Szabo @ 2002-03-07 16:57 UTC (permalink / raw)
  To: Joel Mc Graw <jmcgraw@databill.com>; +Cc: pgsql-admin


On Thu, 7 Mar 2002, Joel Mc Graw wrote:

> I had a table (job_documents) that referenced another (jobs).  I no
> longer needed job_documents, so I dropped it.  Now, any attempt to
> delete rows from jobs fails--it complains that job_documents doesn't
> exist.  Is there a way to fix this?

You'll need to find the two triggers on jobs that reference job_documents
(do a select * from pg_trigger and look at the argument list to find
them) and drop them and you should be fine.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Dropped table screws referential integrity?
  2002-03-07 14:56 Dropped table screws referential integrity? Joel Mc Graw <jmcgraw@databill.com>
  2002-03-07 16:57 ` Re: Dropped table screws referential integrity? Stephan Szabo <sszabo@megazone23.bigpanda.com>
@ 2002-03-07 19:08   ` Joel Burton <joel@joelburton.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Joel Burton @ 2002-03-07 19:08 UTC (permalink / raw)
  To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; +Cc: Joel Mc Graw <jmcgraw@databill.com>; pgsql-admin

On Thu, 7 Mar 2002, Stephan Szabo wrote:

>
> On Thu, 7 Mar 2002, Joel Mc Graw wrote:
>
> > I had a table (job_documents) that referenced another (jobs).  I no
> > longer needed job_documents, so I dropped it.  Now, any attempt to
> > delete rows from jobs fails--it complains that job_documents doesn't
> > exist.  Is there a way to fix this?
>
> You'll need to find the two triggers on jobs that reference job_documents
> (do a select * from pg_trigger and look at the argument list to find
> them) and drop them and you should be fine.

In techdocs.postgresql.org, I have a HOWTO on referential integrity that
provides some views that make it easier to find the ref rules in effect in
your tables. These are helpful for debugging.

-- 

Joel BURTON  |  joel@joelburton.com  |  joelburton.com  |  aim: wjoelburton
Independent Knowledge Management Consultant




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Dropped table screws referential integrity?
  2002-03-07 14:56 Dropped table screws referential integrity? Joel Mc Graw <jmcgraw@databill.com>
@ 2002-03-07 18:37 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 4+ messages in thread

From: Tom Lane @ 2002-03-07 18:37 UTC (permalink / raw)
  To: jmcgraw@databill.com; +Cc: pgsql-admin

Joel Mc Graw <jmcgraw@databill.com> writes:
> I had a table (job_documents) that referenced another (jobs).  I no
> longer needed job_documents, so I dropped it.  Now, any attempt to
> delete rows from jobs fails--it complains that job_documents doesn't
> exist.  Is there a way to fix this?

Drop the triggers on jobs that enforce the RI check.  They should've
been dropped automatically, but I believe there used to be a bug in
pg_dump that caused the necessary linkage data not to be included in
dumps --- so if your DB has been dumped and reloaded since the triggers
were made, I'm not surprised you'd have got into this state.

See mail list archives of past discussions if you need help finding
the triggers (hint: look in pg_trigger, and beware that the triggers
you want to drop have mixed-case names which you will have to double
quote).  There will be either one or two triggers to get rid of
depending on which end of the RI check this table was.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2002-03-07 19:08 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-07 14:56 Dropped table screws referential integrity? Joel Mc Graw <jmcgraw@databill.com>
2002-03-07 16:57 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-03-07 19:08   ` Joel Burton <joel@joelburton.com>
2002-03-07 18:37 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox