From 8f57850924fe5bdeb72c7ef034b6abc49fe0e68f Mon Sep 17 00:00:00 2001 From: heikki Date: Thu, 23 Apr 2009 07:19:09 +0000 Subject: [PATCH] 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. --- contrib/citext/expected/citext.out | 8 ++++---- contrib/citext/expected/citext_1.out | 8 ++++---- contrib/citext/sql/citext.sql | 2 +- src/backend/utils/adt/varlena.c | 3 ++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/contrib/citext/expected/citext.out b/contrib/citext/expected/citext.out index 4d8f1ac066..c3dfc95803 100644 --- a/contrib/citext/expected/citext.out +++ b/contrib/citext/expected/citext.out @@ -213,10 +213,10 @@ SELECT citext_cmp('AARDVARK'::citext, 'AARDVARK'::citext) AS zero; 0 (1 row) -SELECT citext_cmp('B'::citext, 'a'::citext) AS one; - one ------ - 1 +SELECT citext_cmp('B'::citext, 'a'::citext) > 0 AS true; + true +------ + t (1 row) -- Do some tests using a table and index. diff --git a/contrib/citext/expected/citext_1.out b/contrib/citext/expected/citext_1.out index e9bb6124c8..49a6817aef 100644 --- a/contrib/citext/expected/citext_1.out +++ b/contrib/citext/expected/citext_1.out @@ -213,10 +213,10 @@ SELECT citext_cmp('AARDVARK'::citext, 'AARDVARK'::citext) AS zero; 0 (1 row) -SELECT citext_cmp('B'::citext, 'a'::citext) AS one; - one ------ - 1 +SELECT citext_cmp('B'::citext, 'a'::citext) > 0 AS true; + true +------ + t (1 row) -- Do some tests using a table and index. diff --git a/contrib/citext/sql/citext.sql b/contrib/citext/sql/citext.sql index 379c0786f1..52999c2e63 100644 --- a/contrib/citext/sql/citext.sql +++ b/contrib/citext/sql/citext.sql @@ -90,7 +90,7 @@ SELECT 'aardvark'::citext = 'aardVark'::citext AS t; SELECT citext_cmp('aardvark'::citext, 'aardvark'::citext) AS zero; SELECT citext_cmp('aardvark'::citext, 'aardVark'::citext) AS zero; SELECT citext_cmp('AARDVARK'::citext, 'AARDVARK'::citext) AS zero; -SELECT citext_cmp('B'::citext, 'a'::citext) AS one; +SELECT citext_cmp('B'::citext, 'a'::citext) > 0 AS true; -- Do some tests using a table and index. diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index c73ddae4d0..4cf396683b 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -1138,7 +1138,8 @@ text_position_cleanup(TextPositionState *state) * Comparison function for text strings with given lengths. * Includes locale support, but must copy strings to temporary memory * to allow null-termination for inputs to strcoll(). - * Returns -1, 0 or 1 + * Returns an integer less than, equal to, or greater than zero, indicating + * whether arg1 is less than, equal to, or greater than arg2. */ int varstr_cmp(char *arg1, int len1, char *arg2, int len2) -- 2.11.4.GIT