~ubuntu-branches/ubuntu/utopic/postgresql-9.4/utopic-security

« back to all changes in this revision

Viewing changes to src/backend/optimizer/plan/createplan.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt, CVE-2014-8161
  • Date: 2015-02-06 12:31:46 UTC
  • mfrom: (1.1.5) (7.1.2 utopic-proposed)
  • Revision ID: package-import@ubuntu.com-20150206123146-vtmf30jbkm7w16p8
Tags: 9.4.1-0ubuntu0.14.10
* New upstream security/bug fix release (LP: #1418928)
  - Fix buffer overruns in to_char() [CVE-2015-0241]
  - Fix buffer overruns in contrib/pgcrypto [CVE-2015-0243]
  - Fix possible loss of frontend/backend protocol synchronization after an
    error [CVE-2015-0244]
  - Fix information leak via constraint-violation error messages
    [CVE-2014-8161]
  - See release notes for details about other fixes:
    http://www.postgresql.org/about/news/1569/

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <math.h>
21
21
 
22
22
#include "access/skey.h"
 
23
#include "access/sysattr.h"
23
24
#include "catalog/pg_class.h"
24
25
#include "foreign/fdwapi.h"
25
26
#include "miscadmin.h"
33
34
#include "optimizer/planmain.h"
34
35
#include "optimizer/planner.h"
35
36
#include "optimizer/predtest.h"
 
37
#include "optimizer/prep.h"
36
38
#include "optimizer/restrictinfo.h"
37
39
#include "optimizer/subselect.h"
38
40
#include "optimizer/tlist.h"
1218
1220
                        if (best_path->indexinfo->indpred)
1219
1221
                        {
1220
1222
                                if (baserelid != root->parse->resultRelation &&
1221
 
                                        get_parse_rowmark(root->parse, baserelid) == NULL)
 
1223
                                        get_plan_rowmark(root->rowMarks, baserelid) == NULL)
1222
1224
                                        if (predicate_implied_by(clausel,
1223
1225
                                                                                         best_path->indexinfo->indpred))
1224
1226
                                                continue;               /* implied by index predicate */
1945
1947
        RelOptInfo *rel = best_path->path.parent;
1946
1948
        Index           scan_relid = rel->relid;
1947
1949
        RangeTblEntry *rte;
 
1950
        Bitmapset  *attrs_used = NULL;
 
1951
        ListCell   *lc;
1948
1952
        int                     i;
1949
1953
 
1950
1954
        /* it should be a base rel... */
1992
1996
         * Detect whether any system columns are requested from rel.  This is a
1993
1997
         * bit of a kluge and might go away someday, so we intentionally leave it
1994
1998
         * out of the API presented to FDWs.
 
1999
         *
 
2000
         * First, examine all the attributes needed for joins or final output.
 
2001
         * Note: we must look at reltargetlist, not the attr_needed data, because
 
2002
         * attr_needed isn't computed for inheritance child rels.
1995
2003
         */
 
2004
        pull_varattnos((Node *) rel->reltargetlist, rel->relid, &attrs_used);
 
2005
 
 
2006
        /* Add all the attributes used by restriction clauses. */
 
2007
        foreach(lc, rel->baserestrictinfo)
 
2008
        {
 
2009
                RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc);
 
2010
 
 
2011
                pull_varattnos((Node *) rinfo->clause, rel->relid, &attrs_used);
 
2012
        }
 
2013
 
 
2014
        /* Now, are any system columns requested from rel? */
1996
2015
        scan_plan->fsSystemCol = false;
1997
 
        for (i = rel->min_attr; i < 0; i++)
 
2016
        for (i = FirstLowInvalidHeapAttributeNumber + 1; i < 0; i++)
1998
2017
        {
1999
 
                if (!bms_is_empty(rel->attr_needed[i - rel->min_attr]))
 
2018
                if (bms_is_member(i - FirstLowInvalidHeapAttributeNumber, attrs_used))
2000
2019
                {
2001
2020
                        scan_plan->fsSystemCol = true;
2002
2021
                        break;
2003
2022
                }
2004
2023
        }
2005
2024
 
 
2025
        bms_free(attrs_used);
 
2026
 
2006
2027
        return scan_plan;
2007
2028
}
2008
2029