From: Robert Haas Date: Wed, 4 Jul 2012 21:19:23 +0000 (-0400) Subject: Fix sample INSTR function to return 0 if third arg is 0. X-Git-Tag: REL9_3_BETA1~1241 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0fc32c00d74404a9a535e0e1b8d9437dfd8075db;p=postgresql Fix sample INSTR function to return 0 if third arg is 0. Albe Laurenz, per a report by Greg Smith that our sample function doesn't quite match Oracle's behavior. --- diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index ba2c57b687..4840f6ea9c 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -5115,7 +5115,7 @@ BEGIN ELSE RETURN pos + beg_index - 1; END IF; - ELSE + ELSIF beg_index < 0 THEN ss_length := char_length(string_to_search); length := char_length(string); beg := length + beg_index - ss_length + 2; @@ -5131,6 +5131,8 @@ BEGIN beg := beg - 1; END LOOP; + RETURN 0; + ELSE RETURN 0; END IF; END; @@ -5170,7 +5172,7 @@ BEGIN ELSE RETURN beg; END IF; - ELSE + ELSIF beg_index < 0 THEN ss_length := char_length(string_to_search); length := char_length(string); beg := length + beg_index - ss_length + 2; @@ -5190,6 +5192,8 @@ BEGIN beg := beg - 1; END LOOP; + RETURN 0; + ELSE RETURN 0; END IF; END;