1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Implement subselects in target lists. Also, relax requirement that

subselects can only appear on the righthand side of a binary operator.
That's still true for quantified predicates like x = ANY (SELECT ...),
but a subselect that delivers a single result can now appear anywhere
in an expression.  This is implemented by changing EXPR_SUBLINK sublinks
to represent just the (SELECT ...) expression, without any 'left hand
side' or combining operator --- so they're now more like EXISTS_SUBLINK.
To handle the case of '(x, y, z) = (SELECT ...)', I added a new sublink
type MULTIEXPR_SUBLINK, which acts just like EXPR_SUBLINK used to.
But the grammar will only generate one for a multiple-left-hand-side
row expression.
This commit is contained in:
Tom Lane
1999-11-15 02:00:15 +00:00
parent 1ecb129d20
commit f68e11f373
12 changed files with 364 additions and 566 deletions

View File

@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: analyze.c,v 1.123 1999/11/07 23:08:10 momjian Exp $
* $Id: analyze.c,v 1.124 1999/11/15 02:00:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -231,11 +231,11 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
/* fix where clause */
qry->qual = transformWhereClause(pstate, stmt->whereClause, NULL);
qry->hasSubLinks = pstate->p_hasSubLinks;
qry->rtable = pstate->p_rtable;
qry->resultRelation = refnameRangeTablePosn(pstate, stmt->relname, NULL);
qry->hasSubLinks = pstate->p_hasSubLinks;
qry->hasAggs = pstate->p_hasAggs;
if (pstate->p_hasAggs)
parseCheckAggregates(pstate, qry);
@ -423,6 +423,9 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
if (stmt->forUpdate != NULL)
transformForUpdate(qry, stmt->forUpdate);
/* in case of subselects in default clauses... */
qry->hasSubLinks = pstate->p_hasSubLinks;
return (Query *) qry;
}