1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-09 13:09:39 +03:00

Fix problems with rewriter failing to set Query.hasSubLinks when inserting

a SubLink expression into a rule query.  Pre-8.1 we essentially did this
unconditionally; 8.1 tries to do it only when needed, but was missing a
couple of cases.  Per report from Kyle Bateman.  Add some regression test
cases covering this area.
This commit is contained in:
Tom Lane
2005-11-23 17:21:04 +00:00
parent baa6b22fcb
commit 19ff959bff
4 changed files with 125 additions and 6 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.93 2005/11/22 18:17:19 momjian Exp $
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.94 2005/11/23 17:21:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -930,6 +930,7 @@ ResolveNew(Node *node, int target_varno, int sublevels_up,
RangeTblEntry *target_rte,
List *targetlist, int event, int update_varno)
{
Node *result;
ResolveNew_context context;
context.target_varno = target_varno;
@@ -944,8 +945,21 @@ ResolveNew(Node *node, int target_varno, int sublevels_up,
* Must be prepared to start with a Query or a bare expression tree; if
* it's a Query, we don't want to increment sublevels_up.
*/
return query_or_expression_tree_mutator(node,
ResolveNew_mutator,
(void *) &context,
0);
result = query_or_expression_tree_mutator(node,
ResolveNew_mutator,
(void *) &context,
0);
if (context.inserted_sublink)
{
if (IsA(result, Query))
((Query *) result)->hasSubLinks = true;
/*
* Note: if we're called on a non-Query node then it's the caller's
* responsibility to update hasSubLinks in the ancestor Query.
* This is pretty fragile and perhaps should be rethought ...
*/
}
return result;
}