Forum OpenACS Q&A: Bizarre Postgres Behavior
lta=# begin; BEGIN lta=# select count(*) from sec_sessions where user_id = 71; count ------- 2 (1 row) lta=# delete from sec_sessions where user_id = 71; DELETE 0 lta=#So the WHERE clause returns two rows from a SELECT but deletes zero rows! Anyone have any ideas?
2) postgres will complain, "ERROR: Cannot delete from a view without an appropriate rule" if you try it
understanding of foreign keys and such. sec_sessions and
sec_session_properties are linked by a foreign key
create trigger clean_up_other_tables
before delete on sec_sesssions
Where clean_up_other_tables_tr looked a little like this:
delete from foo where session_id = OLD.session_id;
So the return null was breaking the delete and when I think about it, It makes some sense.
(to abort the entire transaction you'd use RAISE ERROR)