pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Jan Wieck <JanWieck@yahoo.com>
Cc: Stephan Szabo <sszabo@megazone.bigpanda.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Enio Schutt Junior <enio@pmpf.rs.gov.br>
Cc: pgsql-sql@postgresql.org
Subject: Re: Sometimes referential integrity seems not to work
Date: Tue, 3 Feb 2004 09:27:13 -0700 (MST)
Message-ID: <Pine.LNX.4.33.0402030926190.23444-100000@css120.ihs.com> (raw)
In-Reply-To: <401FA2EC.2090308@Yahoo.com>

On Tue, 3 Feb 2004, Jan Wieck wrote:

> scott.marlowe wrote:
> 
> > On Mon, 2 Feb 2004, Jan Wieck wrote:
> > 
> >> Stephan Szabo wrote:
> >> 
> >> > On Sat, 31 Jan 2004, Tom Lane wrote:
> >> > 
> >> >> Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> >> >> > On Mon, 26 Jan 2004, Enio Schutt Junior wrote:
> >> >> >> In a database I am working, I sometimes have to delete all the records in
> >> >> >> some tables. According to the referential integrity defined in the creation
> >> >> >> of the tables, postmaster should not delete the records, but it does. I have
> >> >> >> used the following commands: "delete from table_1" and "truncate table_1".
> >> >> >> ...
> >> >> >> can the postgres user delete records despite referential integrity?
> >> >>
> >> >> I think the first PG release or two that had TRUNCATE TABLE would allow
> >> >> you to apply it despite the existence of foreign-key constraints on the
> >> >> table.  Recent releases won't though.
> >> > 
> >> > Yeah, truncate didn't worry me much, but the implication that delete from
> >> > table_1; worked did.
> >> 
> >> TRUNCATE cannot be used inside of a transaction, and since 7.3 it checks 
> >> for foreign keys. So I guess Enio is getting but ignoring the error 
> >> message when trying the delete, but then the truncate does the job in 
> >> his pre-7.3 database.
> > 
> > Yes it can.  I think it was starting in 7.3.
> 
> Okay, so you're the third one correcting me on this. Now can any of you 
> violate a foreign key constraint with anything else than using truncate 
> in a pre-7.3 database? Because I can't do that and that was the original 
> problem.

Our production machine is running 7.2, and I get this:

begin;
BEGIN
=# truncate test;
ERROR:  TRUNCATE TABLE cannot run inside a transaction block
=# commit;
COMMIT
=# select * from test;
 info | id
------+----
 abc  |  1
 def  |  2
(2 rows)

So, at least in 7.2, it won't let me truncate.  I'm not running any 7.3 
boxes, just 7.4 and 7.2, so I can't test it on 7.3.




view thread (10+ messages)  latest in thread

Message-ID: <Pine.LNX.4.33.0402030926190.23444-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0402030926190.23444-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0402030926190.23444-100000@css120.ihs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: scott.marlowe@ihs.com, JanWieck@yahoo.com, sszabo@megazone.bigpanda.com, tgl@sss.pgh.pa.us, enio@pmpf.rs.gov.br
  Subject: Re: Sometimes referential integrity seems not to work
  In-Reply-To: <Pine.LNX.4.33.0402030926190.23444-100000@css120.ihs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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