|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.122 2008/06/08 22:00:47 alvherre Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.123 2008/07/01 10:33:09 heikki Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -684,6 +684,7 @@ examine_attribute(Relation onerel, int attnum)
|
684 | 684 | Form_pg_attributeattr=onerel->rd_att->attrs[attnum-1];
|
685 | 685 | HeapTupletyptuple;
|
686 | 686 | VacAttrStats*stats;
|
| 687 | +inti; |
687 | 688 | boolok;
|
688 | 689 |
|
689 | 690 | /* Never analyze dropped columns */
|
@@ -711,6 +712,20 @@ examine_attribute(Relation onerel, int attnum)
|
711 | 712 | stats->anl_context=anl_context;
|
712 | 713 | stats->tupattnum=attnum;
|
713 | 714 |
|
| 715 | +/* |
| 716 | + * The fields describing the stats->stavalues[n] element types default |
| 717 | + * to the type of the field being analyzed, but the type-specific |
| 718 | + * typanalyze function can change them if it wants to store something |
| 719 | + * else. |
| 720 | + */ |
| 721 | +for (i=0;i<STATISTIC_NUM_SLOTS;i++) |
| 722 | +{ |
| 723 | +stats->statypid[i]=stats->attr->atttypid; |
| 724 | +stats->statyplen[i]=stats->attrtype->typlen; |
| 725 | +stats->statypbyval[i]=stats->attrtype->typbyval; |
| 726 | +stats->statypalign[i]=stats->attrtype->typalign; |
| 727 | +} |
| 728 | + |
714 | 729 | /*
|
715 | 730 | * Call the type-specific typanalyze function.If none is specified, use
|
716 | 731 | * std_typanalyze().
|
@@ -1322,10 +1337,10 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
|
1322 | 1337 |
|
1323 | 1338 | arry=construct_array(stats->stavalues[k],
|
1324 | 1339 | stats->numvalues[k],
|
1325 |
| -stats->attr->atttypid, |
1326 |
| -stats->attrtype->typlen, |
1327 |
| -stats->attrtype->typbyval, |
1328 |
| -stats->attrtype->typalign); |
| 1340 | +stats->statypid[k], |
| 1341 | +stats->statyplen[k], |
| 1342 | +stats->statypbyval[k], |
| 1343 | +stats->statypalign[k]); |
1329 | 1344 | values[i++]=PointerGetDatum(arry);/* stavaluesN */
|
1330 | 1345 | }
|
1331 | 1346 | else
|
@@ -1855,6 +1870,10 @@ compute_minimal_stats(VacAttrStatsP stats,
|
1855 | 1870 | stats->numnumbers[0]=num_mcv;
|
1856 | 1871 | stats->stavalues[0]=mcv_values;
|
1857 | 1872 | stats->numvalues[0]=num_mcv;
|
| 1873 | +/* |
| 1874 | + * Accept the defaults for stats->statypid and others. |
| 1875 | + * They have been set before we were called (see vacuum.h) |
| 1876 | + */ |
1858 | 1877 | }
|
1859 | 1878 | }
|
1860 | 1879 | elseif (null_cnt>0)
|
@@ -2198,6 +2217,10 @@ compute_scalar_stats(VacAttrStatsP stats,
|
2198 | 2217 | stats->numnumbers[slot_idx]=num_mcv;
|
2199 | 2218 | stats->stavalues[slot_idx]=mcv_values;
|
2200 | 2219 | stats->numvalues[slot_idx]=num_mcv;
|
| 2220 | +/* |
| 2221 | + * Accept the defaults for stats->statypid and others. |
| 2222 | + * They have been set before we were called (see vacuum.h) |
| 2223 | + */ |
2201 | 2224 | slot_idx++;
|
2202 | 2225 | }
|
2203 | 2226 |
|
@@ -2282,6 +2305,10 @@ compute_scalar_stats(VacAttrStatsP stats,
|
2282 | 2305 | stats->staop[slot_idx]=mystats->ltopr;
|
2283 | 2306 | stats->stavalues[slot_idx]=hist_values;
|
2284 | 2307 | stats->numvalues[slot_idx]=num_hist;
|
| 2308 | +/* |
| 2309 | + * Accept the defaults for stats->statypid and others. |
| 2310 | + * They have been set before we were called (see vacuum.h) |
| 2311 | + */ |
2285 | 2312 | slot_idx++;
|
2286 | 2313 | }
|
2287 | 2314 |
|
|