From 94e4778a31daf3524a2f807b4f830f23a9c2a889 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 23 Jan 2005 02:21:36 +0000 Subject: =?UTF-8?q?The=20result=20of=20a=20FULL=20or=20RIGHT=20join=20can'?= =?UTF-8?q?t=20be=20assumed=20to=20be=20sorted=20by=20the=20left=20input's?= =?UTF-8?q?=20sorting,=20because=20null=20rows=20may=20be=20inserted=20at?= =?UTF-8?q?=20various=20points.=20Per=20report=20from=20Ferenc=20Lutisch?= =?UTF-8?q?=C3=A1=C2=B8n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/optimizer/path/pathkeys.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/backend/optimizer/path/pathkeys.c') diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index e10a41b951..d2c6de54dd 100644 --- a/src/backend/optimizer/path/pathkeys.c +++ b/src/backend/optimizer/path/pathkeys.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.63 2004/12/31 22:00:04 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.64 2005/01/23 02:21:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -858,7 +858,12 @@ build_subquery_pathkeys(Query *root, RelOptInfo *rel, Query *subquery) * vars they were joined with; furthermore, it doesn't matter what kind * of join algorithm is actually used. * + * EXCEPTION: in a FULL or RIGHT join, we cannot treat the result as + * having the outer path's path keys, because null lefthand rows may be + * inserted at random points. It must be treated as unsorted. + * * 'joinrel' is the join relation that paths are being formed for + * 'jointype' is the join type (inner, left, full, etc) * 'outer_pathkeys' is the list of the current outer path's path keys * * Returns the list of new path keys. @@ -866,8 +871,12 @@ build_subquery_pathkeys(Query *root, RelOptInfo *rel, Query *subquery) List * build_join_pathkeys(Query *root, RelOptInfo *joinrel, + JoinType jointype, List *outer_pathkeys) { + if (jointype == JOIN_FULL || jointype == JOIN_RIGHT) + return NIL; + /* * This used to be quite a complex bit of code, but now that all * pathkey sublists start out life canonicalized, we don't have to do -- cgit v1.2.1