~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/backend/utils/cache/lsyscache.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-01-03 08:57:10 UTC
  • mfrom: (5.3.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110103085710-v9u121v7u7oq8qca
Tags: 8.4.6-1~hardy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * Portions Copyright (c) 1994, Regents of the University of California
8
8
 *
9
9
 * IDENTIFICATION
10
 
 *        $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.162 2009/06/11 14:49:05 momjian Exp $
 
10
 *        $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.162.2.1 2010/07/09 22:57:54 tgl Exp $
11
11
 *
12
12
 * NOTES
13
13
 *        Eventually, the index information should go through here, too.
2554
2554
 * If the attribute type is pass-by-reference, the values referenced by
2555
2555
 * the values array are themselves palloc'd.  The palloc'd stuff can be
2556
2556
 * freed by calling free_attstatsslot.
 
2557
 *
 
2558
 * Note: at present, atttype/atttypmod aren't actually used here at all.
 
2559
 * But the caller must have the correct (or at least binary-compatible)
 
2560
 * type ID to pass to free_attstatsslot later.
2557
2561
 */
2558
2562
bool
2559
2563
get_attstatsslot(HeapTuple statstuple,
2568
2572
        Datum           val;
2569
2573
        bool            isnull;
2570
2574
        ArrayType  *statarray;
 
2575
        Oid                     arrayelemtype;
2571
2576
        int                     narrayelem;
2572
2577
        HeapTuple       typeTuple;
2573
2578
        Form_pg_type typeForm;
2590
2595
                        elog(ERROR, "stavalues is null");
2591
2596
                statarray = DatumGetArrayTypeP(val);
2592
2597
 
2593
 
                /* Need to get info about the array element type */
 
2598
                /*
 
2599
                 * Need to get info about the array element type.  We look at the
 
2600
                 * actual element type embedded in the array, which might be only
 
2601
                 * binary-compatible with the passed-in atttype.  The info we
 
2602
                 * extract here should be the same either way, but deconstruct_array
 
2603
                 * is picky about having an exact type OID match.
 
2604
                 */
 
2605
                arrayelemtype = ARR_ELEMTYPE(statarray);
2594
2606
                typeTuple = SearchSysCache(TYPEOID,
2595
 
                                                                   ObjectIdGetDatum(atttype),
 
2607
                                                                   ObjectIdGetDatum(arrayelemtype),
2596
2608
                                                                   0, 0, 0);
2597
2609
                if (!HeapTupleIsValid(typeTuple))
2598
 
                        elog(ERROR, "cache lookup failed for type %u", atttype);
 
2610
                        elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
2599
2611
                typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
2600
2612
 
2601
2613
                /* Deconstruct array into Datum elements; NULLs not expected */
2602
2614
                deconstruct_array(statarray,
2603
 
                                                  atttype,
 
2615
                                                  arrayelemtype,
2604
2616
                                                  typeForm->typlen,
2605
2617
                                                  typeForm->typbyval,
2606
2618
                                                  typeForm->typalign,