ERROR: comparetup_datum() should not be called - Mailing list pgsql-bugs

From yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Subject ERROR: comparetup_datum() should not be called
Date
Msg-id 20120406140425.49EAC14A1FA@mail.netbsd.org
Whole thread Raw
Responses Re: ERROR: comparetup_datum() should not be called  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
hi,

commit 337b6f5ecf05b21b5e997986884d097d60e4e3d0 marked comparetup_datum
"should not be called" but actually it is called for eg. tape-based sort.

a testcase:
    select generate_series(1,1000000) a into t;
    set maintenance_work_mem=1024;
    create index concurrently i on t (a);

YAMAMOTO Takashi

diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index d8e5d68..ea8eca6 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -3243,9 +3243,9 @@ reversedirection_index_hash(Tuplesortstate *state)
 static int
 comparetup_datum(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
 {
-    /* Not currently needed */
-    elog(ERROR, "comparetup_datum() should not be called");
-    return 0;
+    return ApplySortComparator(a->datum1, a->isnull1,
+                               b->datum1, b->isnull1,
+                               state->onlyKey);
 }

 static void

pgsql-bugs by date:

Previous
From: Lucian Curelaru
Date:
Subject: Re: pg_ctl wrong status info on Windows
Next
From: Tom Lane
Date:
Subject: Re: ERROR: comparetup_datum() should not be called