Skip to content
Snippets Groups Projects
Commit c58fb21b authored by Marc G. Fournier's avatar Marc G. Fournier
Browse files

From: Jeroen van Vianen <jeroenv@design.nl>

This patch solves the problem with multiple order by columns, with the
first one having NULL values.
parent c16ebb0f
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.33 1998/01/25 05:14:49 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.34 1998/01/25 05:18:34 scrappy Exp $
* *
* NOTES * NOTES
* Sorts the first relation into the second relation. * Sorts the first relation into the second relation.
...@@ -1094,7 +1094,7 @@ _psort_cmp (HeapTuple *ltup, HeapTuple *rtup) ...@@ -1094,7 +1094,7 @@ _psort_cmp (HeapTuple *ltup, HeapTuple *rtup)
int result = 0; int result = 0;
bool isnull1, isnull2; bool isnull1, isnull2;
while ( nkey < PsortNkeys && !result ) for (nkey = 0; nkey < PsortNkeys && !result; nkey++ )
{ {
lattr = heap_getattr(*ltup, InvalidBuffer, lattr = heap_getattr(*ltup, InvalidBuffer,
PsortKeys[nkey].sk_attno, PsortKeys[nkey].sk_attno,
...@@ -1106,14 +1106,13 @@ _psort_cmp (HeapTuple *ltup, HeapTuple *rtup) ...@@ -1106,14 +1106,13 @@ _psort_cmp (HeapTuple *ltup, HeapTuple *rtup)
&isnull2); &isnull2);
if ( isnull1 ) if ( isnull1 )
{ {
if ( isnull2 ) if ( !isnull2 )
return (0); result = 1;
return(1);
} }
else if ( isnull2 ) else if ( isnull2 )
return (-1); result = -1;
if (PsortKeys[nkey].sk_flags & SK_COMMUTE) else if (PsortKeys[nkey].sk_flags & SK_COMMUTE)
{ {
if (!(result = -(long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (rattr, lattr))) if (!(result = -(long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (rattr, lattr)))
result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (lattr, rattr); result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (lattr, rattr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment