diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-07-07 20:46:45 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-07-07 20:46:45 +0000 |
| commit | 48d9d8e1318eb1d4b94d7f02a86b9e9716369947 (patch) | |
| tree | 74882cf6f02188ddda36ce202135d772d3e2d3e2 /src/backend/optimizer/plan/planmain.c | |
| parent | d5eaa637ce4b579a6c22c880ba9f60745526a031 (diff) | |
Fix a couple of planner bugs introduced by the new ability to discard
ORDER BY <constant> as redundant. One is that this means query_planner()
has to canonicalize pathkeys even when the query jointree is empty;
the canonicalization was always a no-op in such cases before, but no more.
Also, we have to guard against thinking that a set-returning function is
"constant" for this purpose. Add a couple of regression tests for these
evidently under-tested cases. Per report from Greg Stark and subsequent
experimentation.
Diffstat (limited to 'src/backend/optimizer/plan/planmain.c')
| -rw-r--r-- | src/backend/optimizer/plan/planmain.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index c31f7d5aa65..f8ff3a71508 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/planmain.c,v 1.101 2007/05/04 01:13:44 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/planmain.c,v 1.102 2007/07/07 20:46:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -106,9 +106,21 @@ query_planner(PlannerInfo *root, List *tlist, */ if (parse->jointree->fromlist == NIL) { + /* We need a trivial path result */ *cheapest_path = (Path *) create_result_path((List *) parse->jointree->quals); *sorted_path = NULL; + /* + * We still are required to canonicalize any pathkeys, in case + * it's something like "SELECT 2+2 ORDER BY 1". + */ + root->canon_pathkeys = NIL; + root->query_pathkeys = canonicalize_pathkeys(root, + root->query_pathkeys); + root->group_pathkeys = canonicalize_pathkeys(root, + root->group_pathkeys); + root->sort_pathkeys = canonicalize_pathkeys(root, + root->sort_pathkeys); return; } |
