Re: Oracle porting sample instr function

Roberto Mello <roberto.mello@gmail.com>

From: Roberto Mello <roberto.mello@gmail.com>
To: Greg Smith <greg@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Date: 2012-07-06T11:04:33Z
Lists: pgsql-hackers
On Mon, Jul 2, 2012 at 8:51 PM, Greg Smith <greg@2ndquadrant.com> wrote:
>

<snip>

> The INSTR implementation in the docs will instead search backwards from the
> end of the string if you tell it to start at 0, same as if you gave it a
> negative input.  I think it's therefore possible to get the plpgsql version
> to return a value in cases Oracle would instead return 0.  Seems like a
> straightforward thing to confirm and change the sample to do differently;
> just have to add an explicit test for a 0 value of beg_index.

I wrote that sample eons ago with the plpgsql-porting doc. I probably
overlooked the 0 behavior. Thanks for reporting Greg, and thanks Albe
for providing a patch.

Roberto