Forum OpenACS Q&A: Response to Postgres Problem -again

Collapse
Posted by Dan Wickstrom on
Maybe it is a referential integrity problem and postgresql is not complaining about it properly. Referenial integrity is new for pg 7.x, so it's possible that there might be some bugs in it. Try dropping all of the referential inegrity triggers from one of the tables that you are having trouble deleting from, and see if you can then delete from that same table. An easy way to do this would be to save the table data in a tmp table and then drop the original table. Then recreate the original table from the tmp table by either using create table followed by insert-select or by using create table as select *...

for example (you might want to run pg_dump first, in case you need to restore the original data):

-- save the original data in a tmp table.
create table tmp_user_classes as
select * from ec_user_classes;

-- this will also drop the referential integrity triggers.
drop table ec_user_classes;

-- do this or...
create table ec_user_classes as
select * from tmp_user_classes;

-- use the original table definition
create table ec_user_classes...

-- followed by 
insert into ec_user_classes
select * from tmp_user_classes;

-- now try and delete from ec_user_classes
delete from ec_user_classes;

The only difference should be that ec_user_classes now has no referential integrity triggers enabled.