Forum OpenACS Development: Problem calling content_item__delete()

When calling content_item__delete() i get an error from the after delete trigger for the cr_revisions table (cr_revision_del_rev_ri_trg).

ERROR: Referential Integrity: attempting to delete live_revision: 213142

This is with postgres 7.4.1. The cr-triggers do not seems to have changed since quite some time, so i suppose the problem is based on some change in postgres. In content_item__delete() the function acs_object__delete is called for every revision and fails because the trigger does not allow to remove the live revision.

I thought that every function was one transaction and that all the triggers are running at the end of the function?! If this was the case the trigger should run at the end of content_item__delete where the content item itself should be deleted as well. But it seems as if the trigger is running immediately after the revision is removed.

When setting live_revision = null and latest_revision = null prior to removing the revisions the problem goes away.

Collapse
Posted by Peter Alberer on
hmmm very interesting. i have another database (also pg741) with a openacs installation from a few weeks earlier and there the problem is not present. But i cannot find a difference in the functions involved...
Collapse
Posted by Dave Bauer on
Right.

I think this is how it is supposed to work. The function does not let you delete the live revision.

Maybe an optional delete_live_revision_p parameter is in order?

Collapse
Posted by Peter Alberer on
<blockquote>I think this is how it is supposed to work. The function does not let you delete the live revision
</blockquote>

Are you sure? I think the content_item__delete() function should not care about whether it is removing the live revision?! I think there is some error in my second installation or something has changed in the relevant parts of the code...

Collapse
Posted by Dave Bauer on
Ah that is interesting. If I recall I can delete items via webdav without getting that error message.

Are you using an existing package, or your own code to do the deleting?

Collapse
Posted by Peter Alberer on
<blockquote>Are you using an existing package, or your own code to do the deleting?
</blockquote>

I am using the standard "content_item__delete()" function to remove the content items. Other data for the object is stored in custom tables, but that is removed prior to calling content_item__delete() and does not cause the problem.

Collapse
Posted by Dave Bauer on
Right. Is your call to db_exec_plsql in a db_transaction or another function call? Just calling db_exec_plsql query_name "select content_item__delete(:item_id)" seems to work.
Collapse
Posted by Peter Alberer on
I am testing this from the psql command shell and call "select content_item__delete(SOMEID)" directly. But it is quite likely that you cannot reproduce the error as even in the first of my dbs it does not come up :) GRR, i think i will have to dig deeper into the cr-triggers, as the db where it does not work is my production database.
Collapse
Posted by Jun Yamog on
You mean to say that its not consistent?  I thought it was, so in bcms I modified content_item__delete to set them to null.