Skip to content

Commit 283939a

Browse files
committed
varstr_cmp and any comparison function that piggybacks on it can return
any negative or positive number, not just -1 or 1. Fix comment on varstr_cmp and citext test case accordingly. As pointed out by Zdenek Kotala, and buildfarm member gothic moth.
1 parent 8d4f2ec commit 283939a

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

contrib/citext/expected/citext.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ SELECT citext_cmp('AARDVARK'::citext, 'AARDVARK'::citext) AS zero;
213213
0
214214
(1 row)
215215

216-
SELECT citext_cmp('B'::citext, 'a'::citext) AS one;
217-
one
218-
-----
219-
1
216+
SELECT citext_cmp('B'::citext, 'a'::citext) > 0 AS true;
217+
true
218+
------
219+
t
220220
(1 row)
221221

222222
-- Do some tests using a table and index.

contrib/citext/expected/citext_1.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ SELECT citext_cmp('AARDVARK'::citext, 'AARDVARK'::citext) AS zero;
213213
0
214214
(1 row)
215215

216-
SELECT citext_cmp('B'::citext, 'a'::citext) AS one;
217-
one
218-
-----
219-
1
216+
SELECT citext_cmp('B'::citext, 'a'::citext) > 0 AS true;
217+
true
218+
------
219+
t
220220
(1 row)
221221

222222
-- Do some tests using a table and index.

contrib/citext/sql/citext.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ SELECT 'aardvark'::citext = 'aardVark'::citext AS t;
9090
SELECT citext_cmp('aardvark'::citext, 'aardvark'::citext) AS zero;
9191
SELECT citext_cmp('aardvark'::citext, 'aardVark'::citext) AS zero;
9292
SELECT citext_cmp('AARDVARK'::citext, 'AARDVARK'::citext) AS zero;
93-
SELECT citext_cmp('B'::citext, 'a'::citext) AS one;
93+
SELECT citext_cmp('B'::citext, 'a'::citext) > 0 AS true;
9494

9595
-- Do some tests using a table and index.
9696

src/backend/utils/adt/varlena.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.169 2009/01/01 17:23:50 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.170 2009/04/23 07:19:09 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1138,7 +1138,8 @@ text_position_cleanup(TextPositionState *state)
11381138
* Comparison function for text strings with given lengths.
11391139
* Includes locale support, but must copy strings to temporary memory
11401140
* to allow null-termination for inputs to strcoll().
1141-
* Returns -1, 0 or 1
1141+
* Returns an integer less than, equal to, or greater than zero, indicating
1142+
* whether arg1 is less than, equal to, or greater than arg2.
11421143
*/
11431144
int
11441145
varstr_cmp(char *arg1, int len1, char *arg2, int len2)

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