Forum OpenACS Development: Error in deleting a version in file-storage

Hi,
I have the error reported at the end of the message when i'im trying to delete a version in file-storage package.
Can someone help me? I'm also interested to understand how can i locate a generic error like this and fix it.

Thanks a lot,
Giampiero Granatella

Database operation "0or1row" failed (exception NSDB, "Query was not a statement returning rows.")

ERROR: Function content_revision__del(integer) does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts

SQL:

select file_storage__delete_version(
'921',
'923'
);

while executing
"ns_pg_bind 0or1row nsdb0 {

select file_storage__delete_version(
:item_id,
:version_id
);
}"
("uplevel" body line 1)
invoked from within
"uplevel $ulevel [list ns_pg_bind $type $db $sql"
("postgresql" arm line 2)
invoked from within
"switch $driverkey {
oracle {
return [uplevel $ulevel [list ns_ora $type $db $sql] $args]
}
..."
invoked from within
"db_exec 0or1row $db $full_statement_name $sql"
invoked from within
"if {[regexp -nocase -- {^\s*select} $test_sql match]} {
ns_log Debug "PLPGSQL: bypassed anon function"
set selection [..."
("uplevel" body line 6)
invoked from within
"uplevel 1 $code_block "
invoked from within
"db_with_handle -dbn $dbn db {
# plsql calls that are simple selects bypass the plpgsql
# mechanism for creating anonymous fun..."
(procedure "db_exec_plsql" line 57)
invoked from within
"db_exec_plsql delete_version "
begin

:1 := file_storage.delete_version(:item_id,:version_id);

end;""
invoked from within
"set parent_id [db_exec_plsql delete_version "
begin

:1 := file_storage.delete_version(:item_id,:version_id);

end;"]"
("uplevel" body line 3)
invoked from within
"uplevel #$level $on_submit"
("1" arm line 1)
invoked from within
"switch $errno {
0 {
# TCL_OK
}
1 {
# TCL_E..."
(procedure "ad_form" line 612)
invoked from within
"ad_form -export version_id -cancel_url "file?[export_vars {{file_id $item_id}}]" -form {
{delete_message:text(inform) {label $delete_message}}
} -..."
("uplevel" body line 42)
invoked from within
"uplevel {
ad_page_contract {
confirmation page for version deletion

@author Kevin Scaldeferri (mailto:kevin@arsdigita.com)
@creation-date..."
(procedure "code::tcl::/var/lib/aolserver/CRC/packages/file-storage/www/..." line 2)
invoked from within
"code::tcl::$__adp_stub"
invoked from within
"if { [file exists $__adp_stub.tcl] } {

# ensure that data source preparation procedure exists and is up-to-date
adp_init tcl $__adp_stub
..."
("uplevel" body line 3)
invoked from within
"uplevel {

if { [file exists $__adp_stub.tcl] } {

# ensure that data source preparation procedure exists and is up-to-date
adp_init t..."
(procedure "adp_prepare" line 2)
invoked from within
"adp_prepare "
(procedure "template::adp_parse" line 30)
invoked from within
"template::adp_parse [file root [ad_conn file]] {}"
(procedure "adp_parse_ad_conn_file" line 5)
invoked from within
"$handler"
("uplevel" body line 2)
invoked from within
"uplevel $code"
invoked from within
"ad_try {
$handler
} ad_script_abort val {
# do nothing
}"
invoked from within
"rp_serve_concrete_file [ad_conn file]"
(procedure "rp_serve_abstract_file" line 60)
invoked from within
"rp_serve_abstract_file "$root/$path""
("uplevel" body line 2)
invoked from within
"uplevel $code"
invoked from within
"ad_try {
rp_serve_abstract_file "$root/$path"
set tcl_url2file([ad_conn url]) [ad_conn file]
set tcl_url2path_info..."

Collapse
Posted by Dave Bauer on
It looks like one of two things happened here

1) Your version of file-storage is not compatible with the version of acs-content-repository you have installed.

2) Your version of acs-content-repository has a bug that was fixed in a newer version.

What version of file-storage and acs-content-repository do you have installed.

Visit /acs-admin/apm/ on your installation to find out.

Collapse
Posted by Giampiero Granatella on
file-storage File Storage 5.1.5d3
acs-content-repository Content Repository 5.1.5
Collapse
Posted by Giampiero Granatella on
I looked at the DM
i had a function content_revision__delete with the line
'PERFORM content_revision__del(...)'

But there isn't a function content_revision__del in my Data Model.

I'm the only one with this problem?
Can someone send me the body of the content_revision__del function to add it on my DM.

Thanks a lot
Giampiero Granatella

Collapse
Posted by Claudio Pasolini on
I had the same problem and fixed it changing the call to content_revision__del with content_revision__delete.
The problem is that content_revision__delete call content_revision__del so I cannot fix it in this way.

How is defined your content_revision__delete? Can you post it?

Collapse
Posted by Claudio Pasolini on
I remember that there was two funcions with the same name, one of wich was broken. You should therefore drop the function calling content_revision__del and keep only this:
create or replace function content_revision__delete (integer)
returns integer as '
declare
  delete__revision_id    alias for $1;
  v_item_id              cr_items.item_id%TYPE;
  v_latest_revision      cr_revisions.revision_id%TYPE;
  v_live_revision        cr_revisions.revision_id%TYPE;
  v_rec                  record;
begin

  -- Get item id and latest/live revisions
  select item_id into v_item_id from cr_revisions
    where revision_id = delete__revision_id;

  select
    latest_revision, live_revision
  into
    v_latest_revision, v_live_revision
  from
    cr_items
  where
    item_id = v_item_id;

  -- Recalculate latest revision
  if v_latest_revision = delete__revision_id then
      for v_rec in
          select r.revision_id
            from cr_revisions r, acs_objects o
           where o.object_id = r.revision_id
             and r.item_id = v_item_id
             and r.revision_id <> delete__revision_id
        order by o.creation_date desc
      LOOP

          v_latest_revision := v_rec.revision_id;
          exit;
      end LOOP;
      if NOT FOUND then
         v_latest_revision := null;
      end if;

      update cr_items set latest_revision = v_latest_revision
      where item_id = v_item_id;
  end if;

  -- Clear live revision
  if v_live_revision = delete__revision_id then
    update cr_items set live_revision = null
      where item_id = v_item_id;
  end if;

  -- Clear the audit
  delete from cr_item_publish_audit
    where old_revision = delete__revision_id
       or new_revision = delete__revision_id;

  -- Delete the revision
  PERFORM acs_object__delete(delete__revision_id);

  return 0;
end;' language 'plpgsql';

select define_function_args('content_revision__delete','revision_id');

create or replace function content_revision__delete (integer) returns integer as ' declare delete__revision_id alias for $1; begin PERFORM content_revision__del(delete__revision_id); return 0; end;' language 'plpgsql';

Collapse
Posted by Claudio Pasolini on
At the bottom of the sql posted there is also the broken function, wich obviously must not be created.
Collapse
Posted by Giampiero Granatella on
I Fixed it.
Thanks a lot Claudio.