From 3f6f9260e308a331e6809d5309b17d1613ff900f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 24 Sep 2014 15:59:34 -0400 Subject: Fix bogus variable-mangling in security_barrier_replace_vars(). This function created new Vars with varno different from varnoold, which is a condition that should never prevail before setrefs.c does the final variable-renumbering pass. The created Vars could not be seen as equal() to normal Vars, which among other things broke equivalence-class processing for them. The consequences of this were indeed visible in the regression tests, in the form of failure to propagate constants as one would expect. I stumbled across it while poking at bug #11457 --- after intentionally disabling join equivalence processing, the security-barrier regression tests started falling over with fun errors like "could not find pathkey item to sort", because of failure to match the corrupted Vars to normal ones. --- src/backend/optimizer/prep/prepsecurity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/backend/optimizer/prep/prepsecurity.c') diff --git a/src/backend/optimizer/prep/prepsecurity.c b/src/backend/optimizer/prep/prepsecurity.c index 2420f97a219..51f10a488a8 100644 --- a/src/backend/optimizer/prep/prepsecurity.c +++ b/src/backend/optimizer/prep/prepsecurity.c @@ -432,7 +432,7 @@ security_barrier_replace_vars_walker(Node *node, /* New variable for subquery targetlist */ newvar = copyObject(var); - newvar->varno = 1; + newvar->varno = newvar->varnoold = 1; attno = list_length(context->targetlist) + 1; tle = makeTargetEntry((Expr *) newvar, -- cgit v1.2.3