diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-03-23 05:14:37 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-03-23 05:14:37 +0000 |
commit | 8d9e025e7fcc68737d5a0e99b457417ed595af46 (patch) | |
tree | feca4424957b7784e94428b5ed938454a4c71fdf /src/backend/commands/analyze.c | |
parent | efeffae2457c69802eed7e4c45c1c3c97528a6fe (diff) |
Instead of storing pg_statistic stavalues entries as text strings, store
them as arrays of the internal datatype. This requires treating the
stavalues columns as 'anyarray' rather than 'text[]', which is not 100%
kosher but seems to work fine for the purposes we need for pg_statistic.
Perhaps in the future 'anyarray' will be allowed more generally.
Diffstat (limited to 'src/backend/commands/analyze.c')
-rw-r--r-- | src/backend/commands/analyze.c | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 2af7a3cd7c3..09862f6d840 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.51 2002/11/29 21:39:10 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.52 2003/03/23 05:14:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1694,7 +1694,6 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats) for (attno = 0; attno < natts; attno++) { VacAttrStats *stats = vacattrstats[attno]; - FmgrInfo out_function; HeapTuple stup, oldtup; int i, @@ -1708,8 +1707,6 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats) if (!stats->stats_valid) continue; - fmgr_info(stats->attrtype->typoutput, &out_function); - /* * Construct a new pg_statistic tuple */ @@ -1758,33 +1755,16 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats) } for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - int ntxt = stats->numvalues[k]; - - if (ntxt > 0) + if (stats->numvalues[k] > 0) { - Datum *txtdatums = (Datum *) palloc(ntxt * sizeof(Datum)); ArrayType *arry; - for (n = 0; n < ntxt; n++) - { - /* - * Convert data values to a text string to be inserted - * into the text array. - */ - Datum stringdatum; - - stringdatum = - FunctionCall3(&out_function, - stats->stavalues[k][n], - ObjectIdGetDatum(stats->attrtype->typelem), - Int32GetDatum(stats->attr->atttypmod)); - txtdatums[n] = DirectFunctionCall1(textin, stringdatum); - pfree(DatumGetPointer(stringdatum)); - } - /* XXX knows more than it should about type text: */ - arry = construct_array(txtdatums, ntxt, - TEXTOID, - -1, false, 'i'); + arry = construct_array(stats->stavalues[k], + stats->numvalues[k], + stats->attr->atttypid, + stats->attrtype->typlen, + stats->attrtype->typbyval, + stats->attrtype->typalign); values[i++] = PointerGetDatum(arry); /* stavaluesN */ } else |