Forum OpenACS Development: Response to Weird error invoking a plpgsql function (content_revision__delete)

Although posting any more on this topic might be flogging a dead horse, I thought I'd just verify that another error I'm seeing is also due to the data-change violation. The reason I'm not quite sure is that I'm getting a different error message about a foreign key.
[05/Jul/2001:10:28:24][6730.24581][-conn3-] Notice: Querying '
select content_item__delete('2364');'
NOTICE:  Deleting associated workflows...
NOTICE:  Deleting symlinks...
NOTICE:  Unscheduling item...
NOTICE:  Deleting associated revisions...
NOTICE:  Deleting associated item templates...
NOTICE:  Deleting item relationships...
NOTICE:  Deleting child relationships...
NOTICE:  Deleting parent relationships...
NOTICE:  Deleting associated permissions...
NOTICE:  Deleting keyword associations...
NOTICE:  Deleting associated comments...
NOTICE:  identifier "journal_entry__delete_for_object" will be truncated to "journal_entry__delete_for_objec"
NOTICE:  Deleting content item...
[05/Jul/2001:10:28:24][6730.24581][-conn3-] Error: Ns_PgExec: result
status: 7 message: ERROR:  cr_items_latest_fk referential integrity
violation - key referenced from cr_items not found in cr_revisions
The reason I think this is related to the above discussion? Looking at the code for content_item__delete, I see it calls content_revision__delete in a loop. Each of these calls potentially updates the item's "latest_revision" foreign key. I don't know why the error doesn't happen until you try to delete the item, but there you go.

I implemented a successful workaround, which is to set latest_revision and live_revision to null in a separate transaction, and then calling content_item__delete.

Is there any way to work around this problem in the definition of content_item__delete, or are we stuck waiting for the bug to get fixed in postgresql?