• Tom Lane's avatar
    Better fix for permissions tests in excluded subqueries. · a7b96538
    Tom Lane authored
    This reverts the code changes in 50c13748,
    which turned out to induce crashes and not completely fix the problem
    anyway.  That commit only considered single subqueries that were excluded
    by constraint-exclusion logic, but actually the problem also exists for
    subqueries that are appendrel members (ie part of a UNION ALL list).  In
    such cases we can't add a dummy subpath to the appendrel's AppendPath list
    without defeating the logic that recognizes when an appendrel is completely
    excluded.  Instead, fix the problem by having setrefs.c scan the rangetable
    an extra time looking for subqueries that didn't get into the plan tree.
    (This approach depends on the 9.2 change that made set_subquery_pathlist
    generate dummy paths for excluded single subqueries, so that the exclusion
    behavior is the same for single subqueries and appendrel members.)
    
    Note: it turns out that the appendrel form of the missed-permissions-checks
    bug exists as far back as 8.4.  However, since the practical effect of that
    bug seems pretty minimal, consensus is to not attempt to fix it in the back
    branches, at least not yet.  Possibly we could back-port this patch once
    it's gotten a reasonable amount of testing in HEAD.  For the moment I'm
    just going to revert the previous patch in 9.2.
    a7b96538
createplan.c 139 KB