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

« back to all changes in this revision

Viewing changes to src/pl/plperl/plperl.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt, Peter Eisentraut, Martin Pitt
  • Date: 2009-12-14 19:02:38 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20091214190238-ubwqbnzwbhbc9b9f
Tags: 8.4.2-1
Medium urgency due to security fixes.

[ Peter Eisentraut ]
* debian/control: Added Homepage
* debian/control: Added ${misc:Depends} on all packages, per lintian
* debian/control: Added versioned dependencies on the shared libraries used 
  by the libecpg-dev package
* debian/control: Removed obsolete build dependency bzip2
* debian/control: Added Vcs fields

[ Martin Pitt ]
* New upstream security/bug fix release:
  - Protect against indirect security threats caused by index functions
    changing session-local state. This change prevents allegedly-immutable
    index functions from possibly subverting a superuser's session
    (CVE-2009-4136).
  - Reject SSL certificates containing an embedded null byte in the
    common name (CN) field. This prevents unintended matching of a
    certificate to a server or client name during SSL validation
    (CVE-2009-4034).
  - Fix hash index corruption. The 8.4 change that made hash indexes keep
    entries sorted by hash value failed to update the bucket splitting and
    compaction routines to preserve the ordering. So application of either
    of those operations could lead to permanent corruption of an index, in
    the sense that searches might fail to find entries that are present. To
    deal with this, it is recommended to REINDEX any hash indexes you may
    have after installing this update.
  - Fix possible crash during backend-startup-time cache initialization.
  - Avoid crash on empty thesaurus dictionary.
  - Prevent signals from interrupting VACUUM at unsafe times.
  - Fix possible crash due to integer overflow in hash table size
    calculation.
  - Fix crash if a DROP is attempted on an internally-dependent object.
  - Fix very rare crash in inet/cidr comparisons.
  - Ensure that shared tuple-level locks held by prepared transactions
    are not ignored.
  - Fix premature drop of temporary files used for a cursor that is
    accessed within a subtransaction.
  - Fix memory leak in syslogger process when rotating to a new CSV
    logfile.
  - Fix memory leak in postmaster when re-parsing "pg_hba.conf".
  - Make FOR UPDATE/SHARE in the primary query not propagate into WITH
    queries.
  - Fix bug with a WITH RECURSIVE query immediately inside another one.
  - Fix concurrency bug in hash indexes.
  - Fix incorrect logic for GiST index page splits, when the split
    depends on a non-first column of the index.
  - Fix wrong search results for a multi-column GIN index with
    fastupdate enabled.
  - Fix bugs in WAL entry creation for GIN indexes.
  - Don't error out if recycling or removing an old WAL file fails at
    the end of checkpoint.
  - Fix PAM password processing to be more robust.
    The previous code is known to fail with the combination of the
    Linux pam_krb5 PAM module with Microsoft Active Directory as the
    domain controller. It might have problems elsewhere too, since it
    was making unjustified assumptions about what arguments the PAM
    stack would pass to it.
  - Raise the maximum authentication token (Kerberos ticket) size in
    GSSAPI and SSPI authentication methods. While the old 2000-byte limit
    was more than enough for Unix Kerberos implementations, tickets issued
    by Windows Domain Controllers can be much larger.
  - Ensure that domain constraints are enforced in constructs like
    ARRAY[...]::domain, where the domain is over an array type.
  - Fix foreign-key logic for some cases involving composite-type
    columns as foreign keys.
  - Ensure that a cursor's snapshot is not modified after it is created.
  - Fix CREATE TABLE to properly merge default expressions coming from
    different inheritance parent tables. This used to work but was broken in
    8.4.
  - Re-enable collection of access statistics for sequences. This used to
    work but was broken in 8.3.
  - Fix processing of ownership dependencies during CREATE OR REPLACE
    FUNCTION.
  - Fix incorrect handling of WHERE "x"="x" conditions.
    In some cases these could get ignored as redundant, but they aren't
    -- they're equivalent to "x" IS NOT NULL.
  - Fix incorrect plan construction when using hash aggregation to
    implement DISTINCT for textually identical volatile expressions
  - Fix Assert failure for a volatile SELECT DISTINCT ON expression
  - Fix ts_stat() to not fail on an empty tsvector value
  - Make text search parser accept underscores in XML attributes
  - Fix encoding handling in xml binary input.
    If the XML header doesn't specify an encoding, we now assume UTF-8
    by default; the previous handling was inconsistent.
  - Fix bug with calling plperl from plperlu or vice versa.
  - Fix session-lifespan memory leak when a PL/Perl function is
    redefined.
  - Ensure that Perl arrays are properly converted to PostgreSQL arrays
    when returned by a set-returning PL/Perl function.
  - Fix rare crash in exception processing in PL/Python.
  - Fix ecpg problem with comments in DECLARE CURSOR statements
  - Fix ecpg to not treat recently-added keywords as reserved words
    This affected the keywords CALLED, CATALOG, DEFINER, ENUM,
    FOLLOWING, INVOKER, OPTIONS, PARTITION, PRECEDING, RANGE, SECURITY,
    SERVER, UNBOUNDED, and WRAPPER.
  - Re-allow regular expression special characters in psql's \df
    function name parameter.
  - Put FREEZE and VERBOSE options in the right order in the VACUUM
    command that "contrib/vacuumdb" produces.
  - Fix possible leak of connections when "contrib/dblink" encounters
    an error
  - Make the postmaster ignore any application_name parameter in
    connection request packets, to improve compatibility with future
    libpq versions.
* debian/control: libreadline5-dev → libreadline-dev. (Closes: #553831)
* Add 03-sh-architecture.patch: Support Renesas' SuperH architecture, thanks
  Nobuhiro Iwamatsu! (Closes: #548847)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**********************************************************************
2
2
 * plperl.c - perl as a procedural language for PostgreSQL
3
3
 *
4
 
 *        $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.150 2009/06/11 14:49:14 momjian Exp $
 
4
 *        $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.150.2.3 2009/11/29 21:02:22 tgl Exp $
5
5
 *
6
6
 **********************************************************************/
7
7
 
150
150
static void plperl_init_interp(void);
151
151
 
152
152
static Datum plperl_func_handler(PG_FUNCTION_ARGS);
153
 
 
154
153
static Datum plperl_trigger_handler(PG_FUNCTION_ARGS);
 
154
 
155
155
static plperl_proc_desc *compile_plperl_function(Oid fn_oid, bool is_trigger);
156
156
 
157
157
static SV  *plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc);
378
378
        }
379
379
}
380
380
 
381
 
 
 
381
/*
 
382
 * Restore previous interpreter selection, if two are active
 
383
 */
382
384
static void
383
385
restore_context(bool old_context)
384
386
{
385
 
        if (trusted_context != old_context)
 
387
        if (interp_state == INTERP_BOTH && trusted_context != old_context)
386
388
        {
387
389
                if (old_context)
388
390
                        PERL_SET_CONTEXT(plperl_trusted_interp);
868
870
plperl_call_handler(PG_FUNCTION_ARGS)
869
871
{
870
872
        Datum           retval;
871
 
        plperl_call_data *save_call_data;
 
873
        plperl_call_data *save_call_data = current_call_data;
 
874
        bool            oldcontext = trusted_context;
872
875
 
873
 
        save_call_data = current_call_data;
874
876
        PG_TRY();
875
877
        {
876
878
                if (CALLED_AS_TRIGGER(fcinfo))
881
883
        PG_CATCH();
882
884
        {
883
885
                current_call_data = save_call_data;
 
886
                restore_context(oldcontext);
884
887
                PG_RE_THROW();
885
888
        }
886
889
        PG_END_TRY();
887
890
 
888
891
        current_call_data = save_call_data;
 
892
        restore_context(oldcontext);
889
893
        return retval;
890
894
}
891
895
 
1230
1234
        Datum           retval;
1231
1235
        ReturnSetInfo *rsi;
1232
1236
        SV                 *array_ret = NULL;
1233
 
        bool            oldcontext = trusted_context;
1234
1237
 
1235
1238
        /*
1236
1239
         * Create the call_data beforing connecting to SPI, so that it is not
1370
1373
        if (array_ret == NULL)
1371
1374
                SvREFCNT_dec(perlret);
1372
1375
 
1373
 
        current_call_data = NULL;
1374
 
        restore_context(oldcontext);
1375
 
 
1376
1376
        return retval;
1377
1377
}
1378
1378
 
1385
1385
        Datum           retval;
1386
1386
        SV                 *svTD;
1387
1387
        HV                 *hvTD;
1388
 
        bool            oldcontext = trusted_context;
1389
1388
 
1390
1389
        /*
1391
1390
         * Create the call_data beforing connecting to SPI, so that it is not
1475
1474
        if (perlret)
1476
1475
                SvREFCNT_dec(perlret);
1477
1476
 
1478
 
        current_call_data = NULL;
1479
 
        restore_context(oldcontext);
1480
1477
        return retval;
1481
1478
}
1482
1479
 
1531
1528
 
1532
1529
                if (!uptodate)
1533
1530
                {
1534
 
                        free(prodesc->proname);
1535
 
                        free(prodesc);
1536
 
                        prodesc = NULL;
1537
1531
                        hash_search(plperl_proc_hash, internal_proname,
1538
1532
                                                HASH_REMOVE, NULL);
 
1533
                        if (prodesc->reference)
 
1534
                                SvREFCNT_dec(prodesc->reference);
 
1535
                        free(prodesc->proname);
 
1536
                        free(prodesc);
 
1537
                        prodesc = NULL;
1539
1538
                }
1540
1539
        }
1541
1540
 
1995
1994
 
1996
1995
                if (SvOK(sv))
1997
1996
                {
1998
 
                        char       *val = SvPV(sv, PL_na);
 
1997
                        char       *val;
 
1998
 
 
1999
                        if (prodesc->fn_retisarray && SvROK(sv) &&
 
2000
                                SvTYPE(SvRV(sv)) == SVt_PVAV)
 
2001
                        {
 
2002
                                sv = plperl_convert_to_pg_array(sv);
 
2003
                        }
 
2004
 
 
2005
                        val = SvPV(sv, PL_na);
1999
2006
 
2000
2007
                        ret = InputFunctionCall(&prodesc->result_in_func, val,
2001
2008
                                                                        prodesc->result_typioparam, -1);