~ubuntu-branches/ubuntu/lucid/postgresql-8.4/lucid-proposed

« back to all changes in this revision

Viewing changes to src/backend/optimizer/util/restrictinfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-09-06 14:11:13 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090906141113-qf5f3hkw7n036jfy
Tags: 8.4.1-1
* Urgency medium due to security fix.
* New upstream security/bug fix release:
  - Disallow "RESET ROLE" and "RESET SESSION AUTHORIZATION" inside
    security-definer functions. This covers a case that was missed in the
    previous patch that disallowed "SET ROLE" and "SET SESSION
    AUTHORIZATION" inside security-definer functions. [CVE-2007-6600]
  - Fix WAL page header initialization at the end of archive recovery.
    This could lead to failure to process the WAL in a subsequent archive
    recovery.
  - Fix "cannot make new WAL entries during recovery" error.
  - Fix problem that could make expired rows visible after a crash.
    This bug involved a page status bit potentially not being set
    correctly after a server crash.
  - Make "LOAD" of an already-loaded loadable module into a no-op.
    Formerly, "LOAD" would attempt to unload and re-load the module,
    but this is unsafe and not all that useful.
  - Make window function PARTITION BY and ORDER BY items always be
    interpreted as simple expressions.
    In 8.4.0 these lists were parsed following the rules used for
    top-level GROUP BY and ORDER BY lists. But this was not correct per
    the SQL standard, and it led to possible circularity.
  - Fix several errors in planning of semi-joins. These led to wrong query
    results in some cases where IN or EXISTS was used together with another
    join.
  - Fix handling of whole-row references to subqueries that are within
    an outer join. An example is SELECT COUNT(ss.-) FROM ... LEFT JOIN
    (SELECT ...) ss ON .... Here, ss.- would be treated as
    ROW(NULL,NULL,...) for null-extended join rows, which is not the same as
    a simple NULL.  Now it is treated as a simple NULL.
  - Fix locale handling with plperl. This bug could cause the server's
    locale setting to change when a plperl function is called, leading to
    data corruption.
  - Fix handling of reloptions to ensure setting one option doesn't
    force default values for others.
  - Ensure that a "fast shutdown" request will forcibly terminate open
    sessions, even if a "smart shutdown" was already in progress.
  - Avoid memory leak for array_agg() in GROUP BY queries.
  - Treat to_char(..., 'TH') as an uppercase ordinal suffix with
    'HH'/'HH12'.  It was previously handled as 'th'.
  - Include the fractional part in the result of EXTRACT(second) and
    EXTRACT(milliseconds) for time and time with time zone inputs.
    This has always worked for floating-point datetime configurations,
    but was broken in the integer datetime code.
  - Fix overflow for INTERVAL 'x ms' when "x" is more than 2 million
    and integer datetimes are in use.
  - Improve performance when processing toasted values in index scans.
    This is particularly useful for PostGIS.
  - Fix a typo that disabled commit_delay.
  - Output early-startup messages to "postmaster.log" if the server is
    started in silent mode. Previously such error messages were discarded,
    leading to difficulty in debugging.
  - Remove translated FAQs. They are now on the wiki. The main FAQ was moved
    to the wiki some time ago.
  - Fix pg_ctl to not go into an infinite loop if "postgresql.conf" is
    empty.
  - Fix several errors in pg_dump's --binary-upgrade mode. pg_dump
    --binary-upgrade is used by pg_migrator.
  - Fix "contrib/xml2"'s xslt_process() to properly handle the maximum
    number of parameters (twenty).
  - Improve robustness of libpq's code to recover from errors during
    "COPY FROM STDIN".
  - Avoid including conflicting readline and editline header files when
    both libraries are installed.
  - Work around gcc bug that causes "floating-point exception" instead
    of "division by zero" on some platforms.
* debian/control: Bump Standards-Version to 3.8.3 (no changes necessary).

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *
9
9
 *
10
10
 * IDENTIFICATION
11
 
 *        $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.60 2009/06/11 14:48:59 momjian Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.60.2.1 2009/07/06 18:26:39 tgl Exp $
12
12
 *
13
13
 *-------------------------------------------------------------------------
14
14
 */
272
272
}
273
273
 
274
274
/*
 
275
 * make_restrictinfos_from_actual_clauses
 
276
 *
 
277
 * Given a list of implicitly-ANDed restriction clauses, produce a list
 
278
 * of RestrictInfo nodes.  This is used to reconstitute the RestrictInfo
 
279
 * representation after doing transformations of a list of clauses.
 
280
 *
 
281
 * We assume that the clauses are relation-level restrictions and therefore
 
282
 * we don't have to worry about is_pushed_down, outerjoin_delayed, or
 
283
 * nullable_relids (these can be assumed true, false, and NULL, respectively).
 
284
 * We do take care to recognize pseudoconstant clauses properly.
 
285
 */
 
286
List *
 
287
make_restrictinfos_from_actual_clauses(PlannerInfo *root,
 
288
                                                                           List *clause_list)
 
289
{
 
290
        List       *result = NIL;
 
291
        ListCell   *l;
 
292
 
 
293
        foreach(l, clause_list)
 
294
        {
 
295
                Expr   *clause = (Expr *) lfirst(l);
 
296
                bool    pseudoconstant;
 
297
                RestrictInfo *rinfo;
 
298
 
 
299
                /*
 
300
                 * It's pseudoconstant if it contains no Vars and no volatile
 
301
                 * functions.  We probably can't see any sublinks here, so
 
302
                 * contain_var_clause() would likely be enough, but for safety
 
303
                 * use contain_vars_of_level() instead.
 
304
                 */
 
305
                pseudoconstant =
 
306
                        !contain_vars_of_level((Node *) clause, 0) &&
 
307
                        !contain_volatile_functions((Node *) clause);
 
308
                if (pseudoconstant)
 
309
                {
 
310
                        /* tell createplan.c to check for gating quals */
 
311
                        root->hasPseudoConstantQuals = true;
 
312
                }
 
313
 
 
314
                rinfo = make_restrictinfo(clause,
 
315
                                                                  true,
 
316
                                                                  false,
 
317
                                                                  pseudoconstant,
 
318
                                                                  NULL,
 
319
                                                                  NULL);
 
320
                result = lappend(result, rinfo);
 
321
        }
 
322
        return result;
 
323
}
 
324
 
 
325
/*
275
326
 * make_restrictinfo_internal
276
327
 *
277
328
 * Common code for the main entry points and the recursive cases.
482
533
}
483
534
 
484
535
/*
 
536
 * get_all_actual_clauses
 
537
 *
 
538
 * Returns a list containing the bare clauses from 'restrictinfo_list'.
 
539
 *
 
540
 * This loses the distinction between regular and pseudoconstant clauses,
 
541
 * so be careful what you use it for.
 
542
 */
 
543
List *
 
544
get_all_actual_clauses(List *restrictinfo_list)
 
545
{
 
546
        List       *result = NIL;
 
547
        ListCell   *l;
 
548
 
 
549
        foreach(l, restrictinfo_list)
 
550
        {
 
551
                RestrictInfo *rinfo = (RestrictInfo *) lfirst(l);
 
552
 
 
553
                Assert(IsA(rinfo, RestrictInfo));
 
554
 
 
555
                result = lappend(result, rinfo->clause);
 
556
        }
 
557
        return result;
 
558
}
 
559
 
 
560
/*
485
561
 * extract_actual_clauses
486
562
 *
487
563
 * Extract bare clauses from 'restrictinfo_list', returning either the