From f68e11f373de8b7b1d19203b8edac1a13a8d406d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 15 Nov 1999 02:00:15 +0000 Subject: 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. --- src/backend/parser/analyze.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/backend/parser/analyze.c') diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index b83e1372962..4ad72439b36 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -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; } -- cgit v1.2.3