Forum OpenACS Development: Is the OACS/postgres instr() function broken?

I am helping port an OpenACS module from Oracle to Postgres and am having trouble with one of the functions that uses instr().

First, the instr functions that I see in /packages/acs-kernel/sql/postgresql/postgresql.sql are intended to exactly emulate the Oracle instr() function, right? In my hands, they are not. Oracle (10.2.0):

SQL> select instr('abcdefabcd', 'c', 1) from dual;
-------------------------
                        3

SQL> select instr('abcdefabcd', 'c', 4) from dual;
-------------------------
                        9

Postgres (8.1.11) with OpenACS 5.5.0d1 (aka HEAD)

# select instr('abcdefabcd', 'c', '1');
 -------
     3
# select instr('abcdefabcd', 'c', '4');
-------
     3

Some further archeological excivations seem to indicate that the OACS instr() is similar but not the same as Oracle's. It looks like the syntax may turn out to be the same if you are searching backwards through a string, but comparing the Oracle and Postgres content repository files for content-item.sql seems to indicate that when searching forwards, you need to keep the third argument as '1' and do your own counting and pass that as the forth argument.

e.g. Oracle 
LOOP
    end_pos := instr(v_item_path, '/', start_pos);

    if end_pos = 0 then
      item_name := substr(v_item_path, start_pos);
    else
      item_name := substr(v_item_path, start_pos, end_pos - start_pos);
    end if;
(omitted stuff)
    exit when end_pos = 0;
    start_pos := end_pos + 1;
END LOOP;

Postgresql
LOOP
    end_pos := instr(v_item_path, ''/'', 1, counter);

    if end_pos = 0 then
      item_name := substr(v_item_path, start_pos);
    else
      item_name := substr(v_item_path, start_pos, end_pos - start_pos);
      counter := counter + 1;
    end if;
(omitted stuff)
    exit when end_pos = 0;
    start_pos := end_pos + 1;
END LOOP;