*** pgsql/src/backend/utils/cache/lsyscache.c 2003/12/03 17:45:37 1.108.2.1 --- pgsql/src/backend/utils/cache/lsyscache.c 2010/07/09 22:58:25 1.108.2.2 *************** *** 7,13 **** * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION ! * $Header: /projects/cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.108.2.1 2003/12/03 17:45:37 tgl Exp $ * * NOTES * Eventually, the index information should go through here, too. --- 7,13 ---- * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION ! * $Header: /projects/cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.108.2.2 2010/07/09 22:58:25 tgl Exp $ * * NOTES * Eventually, the index information should go through here, too. *************** get_attavgwidth(Oid relid, AttrNumber at *** 1796,1801 **** --- 1796,1805 ---- * If the attribute type is pass-by-reference, the values referenced by * the values array are themselves palloc'd. The palloc'd stuff can be * freed by calling free_attstatsslot. + * + * Note: at present, atttype/atttypmod aren't actually used here at all. + * But the caller must have the correct (or at least binary-compatible) + * type ID to pass to free_attstatsslot later. */ bool get_attstatsslot(HeapTuple statstuple, *************** get_attstatsslot(HeapTuple statstuple, *** 1810,1815 **** --- 1814,1820 ---- Datum val; bool isnull; ArrayType *statarray; + Oid arrayelemtype; int narrayelem; HeapTuple typeTuple; Form_pg_type typeForm; *************** get_attstatsslot(HeapTuple statstuple, *** 1832,1848 **** elog(ERROR, "stavalues is null"); statarray = DatumGetArrayTypeP(val); ! /* Need to get info about the array element type */ typeTuple = SearchSysCache(TYPEOID, ! ObjectIdGetDatum(atttype), 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) ! elog(ERROR, "cache lookup failed for type %u", atttype); typeForm = (Form_pg_type) GETSTRUCT(typeTuple); /* Deconstruct array into Datum elements */ deconstruct_array(statarray, ! atttype, typeForm->typlen, typeForm->typbyval, typeForm->typalign, --- 1837,1860 ---- elog(ERROR, "stavalues is null"); statarray = DatumGetArrayTypeP(val); ! /* ! * Need to get info about the array element type. We look at the ! * actual element type embedded in the array, which might be only ! * binary-compatible with the passed-in atttype. The info we ! * extract here should be the same either way, but deconstruct_array ! * is picky about having an exact type OID match. ! */ ! arrayelemtype = ARR_ELEMTYPE(statarray); typeTuple = SearchSysCache(TYPEOID, ! ObjectIdGetDatum(arrayelemtype), 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) ! elog(ERROR, "cache lookup failed for type %u", arrayelemtype); typeForm = (Form_pg_type) GETSTRUCT(typeTuple); /* Deconstruct array into Datum elements */ deconstruct_array(statarray, ! arrayelemtype, typeForm->typlen, typeForm->typbyval, typeForm->typalign,