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

Commit c58fb21

Browse files
committed
From: Jeroen van Vianen <jeroenv@design.nl>
This patch solves the problem with multiple order by columns, with the first one having NULL values.
1 parent c16ebb0 commit c58fb21

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/backend/utils/sort/psort.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.33 1998/01/25 05:14:49 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.34 1998/01/25 05:18:34 scrappy Exp $
1111
*
1212
* NOTES
1313
* Sorts the first relation into the second relation.
@@ -1094,7 +1094,7 @@ _psort_cmp (HeapTuple *ltup, HeapTuple *rtup)
10941094
int result = 0;
10951095
bool isnull1, isnull2;
10961096

1097-
while ( nkey < PsortNkeys && !result )
1097+
for (nkey = 0; nkey < PsortNkeys && !result; nkey++ )
10981098
{
10991099
lattr = heap_getattr(*ltup, InvalidBuffer,
11001100
PsortKeys[nkey].sk_attno,
@@ -1106,14 +1106,13 @@ _psort_cmp (HeapTuple *ltup, HeapTuple *rtup)
11061106
&isnull2);
11071107
if ( isnull1 )
11081108
{
1109-
if ( isnull2 )
1110-
return (0);
1111-
return(1);
1109+
if ( !isnull2 )
1110+
result = 1;
11121111
}
11131112
else if ( isnull2 )
1114-
return (-1);
1113+
result = -1;
11151114

1116-
if (PsortKeys[nkey].sk_flags & SK_COMMUTE)
1115+
else if (PsortKeys[nkey].sk_flags & SK_COMMUTE)
11171116
{
11181117
if (!(result = -(long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (rattr, lattr)))
11191118
result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (lattr, rattr);

0 commit comments

Comments
 (0)