diff options
author | Marc G. Fournier <scrappy@hub.org> | 1998-01-25 05:18:34 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 1998-01-25 05:18:34 +0000 |
commit | c58fb21bd444458d3b1790404c81d80bcc6339b7 (patch) | |
tree | a472466b5954f1dd5dc7ea3294421b2310651827 | |
parent | c16ebb0f67eca76a4a33faca1b5ea6633bb90c8a (diff) | |
download | postgresql-c58fb21bd444458d3b1790404c81d80bcc6339b7.tar.gz postgresql-c58fb21bd444458d3b1790404c81d80bcc6339b7.zip |
From: Jeroen van Vianen <jeroenv@design.nl>
This patch solves the problem with multiple order by columns, with the
first one having NULL values.
-rw-r--r-- | src/backend/utils/sort/psort.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/backend/utils/sort/psort.c b/src/backend/utils/sort/psort.c index b00ecaf42de..d6b53a54ffe 100644 --- a/src/backend/utils/sort/psort.c +++ b/src/backend/utils/sort/psort.c @@ -7,7 +7,7 @@ * * * 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 * Sorts the first relation into the second relation. @@ -1094,7 +1094,7 @@ _psort_cmp (HeapTuple *ltup, HeapTuple *rtup) int result = 0; bool isnull1, isnull2; - while ( nkey < PsortNkeys && !result ) + for (nkey = 0; nkey < PsortNkeys && !result; nkey++ ) { lattr = heap_getattr(*ltup, InvalidBuffer, PsortKeys[nkey].sk_attno, @@ -1106,14 +1106,13 @@ _psort_cmp (HeapTuple *ltup, HeapTuple *rtup) &isnull2); if ( isnull1 ) { - if ( isnull2 ) - return (0); - return(1); + if ( !isnull2 ) + result = 1; } 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))) result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (lattr, rattr); |