diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-08-13 02:50:35 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-08-13 02:50:35 +0000 |
commit | 37168b8da43d9a6f7471cf757119ece6c96fb2b9 (patch) | |
tree | ce7059e77ac05a045f9de7c6272c7e1c8210d96a /src/backend/optimizer/plan/initsplan.c | |
parent | 766fb7f707f9527be219353f5f970aab3d786554 (diff) | |
download | postgresql-37168b8da43d9a6f7471cf757119ece6c96fb2b9.tar.gz postgresql-37168b8da43d9a6f7471cf757119ece6c96fb2b9.zip |
Clean up handling of variable-free qual clauses. System now does the
right thing with variable-free clauses that contain noncachable functions,
such as 'WHERE random() < 0.5' --- these are evaluated once per
potential output tuple. Expressions that contain only Params are
now candidates to be indexscan quals --- for example, 'var = ($1 + 1)'
can now be indexed. Cope with RelabelType nodes atop potential indexscan
variables --- this oversight prevents 7.0.* from recognizing some
potentially indexscanable situations.
Diffstat (limited to 'src/backend/optimizer/plan/initsplan.c')
-rw-r--r-- | src/backend/optimizer/plan/initsplan.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index d2bbff7e600..8ffd35c9bb0 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.48 2000/08/08 15:41:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.49 2000/08/13 02:50:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -184,7 +184,7 @@ add_restrict_and_join_to_rel(Query *root, Node *clause) /* * There is only one relation participating in 'clause', so - * 'clause' must be a restriction clause for that relation. + * 'clause' is a restriction clause for that relation. */ RelOptInfo *rel = get_base_rel(root, lfirsti(relids)); @@ -201,11 +201,11 @@ add_restrict_and_join_to_rel(Query *root, Node *clause) */ check_mergejoinable(restrictinfo); } - else + else if (relids != NIL) { /* - * 'clause' is a join clause, since there is more than one atom in + * 'clause' is a join clause, since there is more than one rel in * the relid list. Set additional RestrictInfo fields for * joining. * @@ -219,8 +219,6 @@ add_restrict_and_join_to_rel(Query *root, Node *clause) /* * Add clause to the join lists of all the relevant relations. - * (If, perchance, 'clause' contains NO vars, then nothing will - * happen...) */ add_join_info_to_rels(root, restrictinfo, relids); @@ -232,6 +230,15 @@ add_restrict_and_join_to_rel(Query *root, Node *clause) */ add_vars_to_targetlist(root, vars); } + else + { + /* + * 'clause' references no rels, and therefore we have no place to + * attach it. This means query_planner() screwed up --- it should + * treat variable-less clauses separately. + */ + elog(ERROR, "add_restrict_and_join_to_rel: can't cope with variable-free clause"); + } /* * If the clause has a mergejoinable operator, then the two sides |