Skip to content

Commit 0fc32c0

Browse files
committed
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.
1 parent 72dd629 commit 0fc32c0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/src/sgml/plpgsql.sgml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5115,7 +5115,7 @@ BEGIN
51155115
ELSE
51165116
RETURN pos + beg_index - 1;
51175117
END IF;
5118-
ELSE
5118+
ELSIF beg_index < 0 THEN
51195119
ss_length := char_length(string_to_search);
51205120
length := char_length(string);
51215121
beg := length + beg_index - ss_length + 2;
@@ -5131,6 +5131,8 @@ BEGIN
51315131
beg := beg - 1;
51325132
END LOOP;
51335133

5134+
RETURN 0;
5135+
ELSE
51345136
RETURN 0;
51355137
END IF;
51365138
END;
@@ -5170,7 +5172,7 @@ BEGIN
51705172
ELSE
51715173
RETURN beg;
51725174
END IF;
5173-
ELSE
5175+
ELSIF beg_index < 0 THEN
51745176
ss_length := char_length(string_to_search);
51755177
length := char_length(string);
51765178
beg := length + beg_index - ss_length + 2;
@@ -5190,6 +5192,8 @@ BEGIN
51905192
beg := beg - 1;
51915193
END LOOP;
51925194

5195+
RETURN 0;
5196+
ELSE
51935197
RETURN 0;
51945198
END IF;
51955199
END;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy