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

« back to all changes in this revision

Viewing changes to src/backend/executor/nodeIndexscan.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/executor/nodeIndexscan.c,v 1.132 2009/06/11 14:48:57 momjian Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.132.2.2 2009/08/23 18:26:15 tgl Exp $
12
12
 *
13
13
 *-------------------------------------------------------------------------
14
14
 */
238
238
                                                 IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys)
239
239
{
240
240
        int                     j;
 
241
        MemoryContext oldContext;
 
242
 
 
243
        /* We want to keep the key values in per-tuple memory */
 
244
        oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
241
245
 
242
246
        for (j = 0; j < numRuntimeKeys; j++)
243
247
        {
256
260
                 * econtext->ecxt_per_tuple_memory.  We assume that the outer tuple
257
261
                 * will stay put throughout our scan.  If this is wrong, we could copy
258
262
                 * the result into our context explicitly, but I think that's not
259
 
                 * necessary...
 
263
                 * necessary.
 
264
                 *
 
265
                 * It's also entirely possible that the result of the eval is a
 
266
                 * toasted value.  In this case we should forcibly detoast it,
 
267
                 * to avoid repeat detoastings each time the value is examined
 
268
                 * by an index support function.
260
269
                 */
261
 
                scanvalue = ExecEvalExprSwitchContext(key_expr,
262
 
                                                                                          econtext,
263
 
                                                                                          &isNull,
264
 
                                                                                          NULL);
265
 
                scan_key->sk_argument = scanvalue;
 
270
                scanvalue = ExecEvalExpr(key_expr,
 
271
                                                                 econtext,
 
272
                                                                 &isNull,
 
273
                                                                 NULL);
266
274
                if (isNull)
 
275
                {
 
276
                        scan_key->sk_argument = scanvalue;
267
277
                        scan_key->sk_flags |= SK_ISNULL;
 
278
                }
268
279
                else
 
280
                {
 
281
                        if (runtimeKeys[j].key_toastable)
 
282
                                scanvalue = PointerGetDatum(PG_DETOAST_DATUM(scanvalue));
 
283
                        scan_key->sk_argument = scanvalue;
269
284
                        scan_key->sk_flags &= ~SK_ISNULL;
 
285
                }
270
286
        }
 
287
 
 
288
        MemoryContextSwitchTo(oldContext);
271
289
}
272
290
 
273
291
/*
423
441
#ifdef NOT_USED
424
442
        ExecFreeExprContext(&node->ss.ps);
425
443
        if (node->iss_RuntimeContext)
426
 
                FreeExprContext(node->iss_RuntimeContext);
 
444
                FreeExprContext(node->iss_RuntimeContext, true);
427
445
#endif
428
446
 
429
447
        /*
795
813
                                runtime_keys[n_runtime_keys].scan_key = this_scan_key;
796
814
                                runtime_keys[n_runtime_keys].key_expr =
797
815
                                        ExecInitExpr(rightop, planstate);
 
816
                                runtime_keys[n_runtime_keys].key_toastable =
 
817
                                        TypeIsToastable(op_righttype);
798
818
                                n_runtime_keys++;
799
819
                                scanvalue = (Datum) 0;
800
820
                        }
844
864
                                varattno = ((Var *) leftop)->varattno;
845
865
 
846
866
                                /*
 
867
                                 * We have to look up the operator's associated btree support
 
868
                                 * function
 
869
                                 */
 
870
                                opno = lfirst_oid(opnos_cell);
 
871
                                opnos_cell = lnext(opnos_cell);
 
872
 
 
873
                                if (index->rd_rel->relam != BTREE_AM_OID ||
 
874
                                        varattno < 1 || varattno > index->rd_index->indnatts)
 
875
                                        elog(ERROR, "bogus RowCompare index qualification");
 
876
                                opfamily = index->rd_opfamily[varattno - 1];
 
877
 
 
878
                                get_op_opfamily_properties(opno, opfamily,
 
879
                                                                                   &op_strategy,
 
880
                                                                                   &op_lefttype,
 
881
                                                                                   &op_righttype);
 
882
 
 
883
                                if (op_strategy != rc->rctype)
 
884
                                        elog(ERROR, "RowCompare index qualification contains wrong operator");
 
885
 
 
886
                                opfuncid = get_opfamily_proc(opfamily,
 
887
                                                                                         op_lefttype,
 
888
                                                                                         op_righttype,
 
889
                                                                                         BTORDER_PROC);
 
890
 
 
891
                                /*
847
892
                                 * rightop is the constant or variable comparison value
848
893
                                 */
849
894
                                rightop = (Expr *) lfirst(rargs_cell);
867
912
                                        runtime_keys[n_runtime_keys].scan_key = this_sub_key;
868
913
                                        runtime_keys[n_runtime_keys].key_expr =
869
914
                                                ExecInitExpr(rightop, planstate);
 
915
                                        runtime_keys[n_runtime_keys].key_toastable =
 
916
                                                TypeIsToastable(op_righttype);
870
917
                                        n_runtime_keys++;
871
918
                                        scanvalue = (Datum) 0;
872
919
                                }
873
920
 
874
921
                                /*
875
 
                                 * We have to look up the operator's associated btree support
876
 
                                 * function
877
 
                                 */
878
 
                                opno = lfirst_oid(opnos_cell);
879
 
                                opnos_cell = lnext(opnos_cell);
880
 
 
881
 
                                if (index->rd_rel->relam != BTREE_AM_OID ||
882
 
                                        varattno < 1 || varattno > index->rd_index->indnatts)
883
 
                                        elog(ERROR, "bogus RowCompare index qualification");
884
 
                                opfamily = index->rd_opfamily[varattno - 1];
885
 
 
886
 
                                get_op_opfamily_properties(opno, opfamily,
887
 
                                                                                   &op_strategy,
888
 
                                                                                   &op_lefttype,
889
 
                                                                                   &op_righttype);
890
 
 
891
 
                                if (op_strategy != rc->rctype)
892
 
                                        elog(ERROR, "RowCompare index qualification contains wrong operator");
893
 
 
894
 
                                opfuncid = get_opfamily_proc(opfamily,
895
 
                                                                                         op_lefttype,
896
 
                                                                                         op_righttype,
897
 
                                                                                         BTORDER_PROC);
898
 
 
899
 
                                /*
900
922
                                 * initialize the subsidiary scan key's fields appropriately
901
923
                                 */
902
924
                                ScanKeyEntryInitialize(this_sub_key,