Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 69a5915

Browse files
committed
Defend against brain-dead QNX implementation of qsort().
Per report from Bernd Tegge, 10-Nov-01.
1 parent c5c9731 commit 69a5915

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/backend/utils/sort/tuplesort.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
* Portions Copyright (c) 1994, Regents of the University of California
7979
*
8080
* IDENTIFICATION
81-
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.20 2001/10/28 06:25:57 momjian Exp $
81+
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.21 2001/11/11 22:00:25 tgl Exp $
8282
*
8383
*-------------------------------------------------------------------------
8484
*/
@@ -1881,8 +1881,13 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b)
18811881
* equal they *must* get compared at some stage of the sort ---
18821882
* otherwise the sort algorithm wouldn't have checked whether one must
18831883
* appear before the other.
1884+
*
1885+
* Some rather brain-dead implementations of qsort will sometimes
1886+
* call the comparison routine to compare a value to itself. (At this
1887+
* writing only QNX 4 is known to do such silly things.) Don't raise
1888+
* a bogus error in that case.
18841889
*/
1885-
if (state->enforceUnique && !equal_hasnull)
1890+
if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2)
18861891
elog(ERROR, "Cannot create unique index. Table contains non-unique values");
18871892

18881893
return 0;

0 commit comments

Comments
 (0)