aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-06-12 19:38:30 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-06-12 19:38:30 +0000
commitaaf244247287b671db2d55098ed6aa774049a058 (patch)
tree9f4486aef0bc1a6b6264a05a34e9ee71f0963915
parentacf242da971bdb2b47c5e23196b63ed079420b29 (diff)
downloadpostgresql-aaf244247287b671db2d55098ed6aa774049a058.tar.gz
postgresql-aaf244247287b671db2d55098ed6aa774049a058.zip
Remove query_planner's overhasty rejection of cases where
tlist and qual are NULL. It ought to handle these the same as the cases where tlist contains only constant expressions, ie, be willing to generate a Result-node plan. This did not use to matter, but it does now because union_planner will flatten the tlist when aggregates are present. Thus, 'select count(1) from table' now causes query_planner to be given a null tlist, and to duplicate 6.4's behavior we need it to give back a Result plan rather than refusing the query. 6.4 was arguably doing the Wrong Thing for this query, but I'm not going to open a semantics issue right before 6.5 release ... can revisit that problem later.
-rw-r--r--src/backend/optimizer/plan/planmain.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c
index dae0443e1e8..80eaaf9a055 100644
--- a/src/backend/optimizer/plan/planmain.c
+++ b/src/backend/optimizer/plan/planmain.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.36 1999/05/25 16:09:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.37 1999/06/12 19:38:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -68,9 +68,9 @@ query_planner(Query *root,
List *qual)
{
List *constant_qual = NIL;
- List *var_only_tlist = NIL;
- List *level_tlist = NIL;
- Plan *subplan = NULL;
+ List *var_only_tlist;
+ List *level_tlist;
+ Plan *subplan;
if (PlannerQueryLevel > 1)
{
@@ -88,28 +88,14 @@ query_planner(Query *root,
#endif
/*
- * A command without a target list or qualification is an error,
- * except for "delete foo".
- */
- if (tlist == NIL && qual == NULL)
- {
- if (command_type == CMD_DELETE)
- {
- return ((Plan *) make_seqscan(NIL,
- NIL,
- root->resultRelation,
- (Plan *) NULL));
- }
- else
- return (Plan *) NULL;
- }
-
- /*
* Pull out any non-variable qualifications so these can be put in the
- * topmost result node. The opids for the remaining qualifications
- * will be changed to regprocs later.
+ * topmost result node.
*/
qual = pull_constant_clauses(qual, &constant_qual);
+ /*
+ * The opids for the variable qualifications will be fixed later, but
+ * someone seems to think that the constant quals need to be fixed here.
+ */
fix_opids(constant_qual);
/*
@@ -143,13 +129,13 @@ query_planner(Query *root,
case CMD_UPDATE:
{
SeqScan *scan = make_seqscan(tlist,
- (List *) NULL,
+ NIL,
root->resultRelation,
(Plan *) NULL);
if (constant_qual != NULL)
return ((Plan *) make_result(tlist,
- (Node *) constant_qual,
+ (Node *) constant_qual,
(Plan *) scan));
else
return (Plan *) scan;