@@ -572,7 +572,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
572
572
* If the appropriate flavor of the n_distinct option is
573
573
* specified, override with the corresponding value.
574
574
*/
575
- aopt = get_attribute_options (onerel -> rd_id , stats -> attr -> attnum );
575
+ aopt = get_attribute_options (onerel -> rd_id , stats -> tupattnum );
576
576
if (aopt != NULL )
577
577
{
578
578
float8 n_distinct ;
@@ -927,7 +927,7 @@ compute_index_stats(Relation onerel, double totalrows,
927
927
for (i = 0 ; i < attr_cnt ; i ++ )
928
928
{
929
929
VacAttrStats * stats = thisdata -> vacattrstats [i ];
930
- int attnum = stats -> attr -> attnum ;
930
+ int attnum = stats -> tupattnum ;
931
931
932
932
if (isnull [attnum - 1 ])
933
933
{
@@ -1014,12 +1014,10 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr)
1014
1014
return NULL ;
1015
1015
1016
1016
/*
1017
- * Create the VacAttrStats struct. Note that we only have a copy of the
1018
- * fixed fields of the pg_attribute tuple.
1017
+ * Create the VacAttrStats struct.
1019
1018
*/
1020
1019
stats = (VacAttrStats * ) palloc0 (sizeof (VacAttrStats ));
1021
- stats -> attr = (Form_pg_attribute ) palloc (ATTRIBUTE_FIXED_PART_SIZE );
1022
- memcpy (stats -> attr , attr , ATTRIBUTE_FIXED_PART_SIZE );
1020
+ stats -> attstattarget = attr -> attstattarget ;
1023
1021
1024
1022
/*
1025
1023
* When analyzing an expression index, believe the expression tree's type
@@ -1086,7 +1084,6 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr)
1086
1084
if (!ok || stats -> compute_stats == NULL || stats -> minrows <= 0 )
1087
1085
{
1088
1086
heap_freetuple (typtuple );
1089
- pfree (stats -> attr );
1090
1087
pfree (stats );
1091
1088
return NULL ;
1092
1089
}
@@ -1659,7 +1656,7 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
1659
1656
}
1660
1657
1661
1658
values [Anum_pg_statistic_starelid - 1 ] = ObjectIdGetDatum (relid );
1662
- values [Anum_pg_statistic_staattnum - 1 ] = Int16GetDatum (stats -> attr -> attnum );
1659
+ values [Anum_pg_statistic_staattnum - 1 ] = Int16GetDatum (stats -> tupattnum );
1663
1660
values [Anum_pg_statistic_stainherit - 1 ] = BoolGetDatum (inh );
1664
1661
values [Anum_pg_statistic_stanullfrac - 1 ] = Float4GetDatum (stats -> stanullfrac );
1665
1662
values [Anum_pg_statistic_stawidth - 1 ] = Int32GetDatum (stats -> stawidth );
@@ -1725,7 +1722,7 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
1725
1722
/* Is there already a pg_statistic tuple for this attribute? */
1726
1723
oldtup = SearchSysCache3 (STATRELATTINH ,
1727
1724
ObjectIdGetDatum (relid ),
1728
- Int16GetDatum (stats -> attr -> attnum ),
1725
+ Int16GetDatum (stats -> tupattnum ),
1729
1726
BoolGetDatum (inh ));
1730
1727
1731
1728
/* Open index information when we know we need it */
@@ -1860,15 +1857,13 @@ static int analyze_mcv_list(int *mcv_counts,
1860
1857
bool
1861
1858
std_typanalyze (VacAttrStats * stats )
1862
1859
{
1863
- Form_pg_attribute attr = stats -> attr ;
1864
1860
Oid ltopr ;
1865
1861
Oid eqopr ;
1866
1862
StdAnalyzeData * mystats ;
1867
1863
1868
1864
/* If the attstattarget column is negative, use the default value */
1869
- /* NB: it is okay to scribble on stats->attr since it's a copy */
1870
- if (attr -> attstattarget < 0 )
1871
- attr -> attstattarget = default_statistics_target ;
1865
+ if (stats -> attstattarget < 0 )
1866
+ stats -> attstattarget = default_statistics_target ;
1872
1867
1873
1868
/* Look for default "<" and "=" operators for column's type */
1874
1869
get_sort_group_operators (stats -> attrtypid ,
@@ -1909,21 +1904,21 @@ std_typanalyze(VacAttrStats *stats)
1909
1904
* know it at this point.
1910
1905
*--------------------
1911
1906
*/
1912
- stats -> minrows = 300 * attr -> attstattarget ;
1907
+ stats -> minrows = 300 * stats -> attstattarget ;
1913
1908
}
1914
1909
else if (OidIsValid (eqopr ))
1915
1910
{
1916
1911
/* We can still recognize distinct values */
1917
1912
stats -> compute_stats = compute_distinct_stats ;
1918
1913
/* Might as well use the same minrows as above */
1919
- stats -> minrows = 300 * attr -> attstattarget ;
1914
+ stats -> minrows = 300 * stats -> attstattarget ;
1920
1915
}
1921
1916
else
1922
1917
{
1923
1918
/* Can't do much but the trivial stuff */
1924
1919
stats -> compute_stats = compute_trivial_stats ;
1925
1920
/* Might as well use the same minrows as above */
1926
- stats -> minrows = 300 * attr -> attstattarget ;
1921
+ stats -> minrows = 300 * stats -> attstattarget ;
1927
1922
}
1928
1923
1929
1924
return true;
@@ -2051,7 +2046,7 @@ compute_distinct_stats(VacAttrStatsP stats,
2051
2046
TrackItem * track ;
2052
2047
int track_cnt ,
2053
2048
track_max ;
2054
- int num_mcv = stats -> attr -> attstattarget ;
2049
+ int num_mcv = stats -> attstattarget ;
2055
2050
StdAnalyzeData * mystats = (StdAnalyzeData * ) stats -> extra_data ;
2056
2051
2057
2052
/*
@@ -2392,8 +2387,8 @@ compute_scalar_stats(VacAttrStatsP stats,
2392
2387
int * tupnoLink ;
2393
2388
ScalarMCVItem * track ;
2394
2389
int track_cnt = 0 ;
2395
- int num_mcv = stats -> attr -> attstattarget ;
2396
- int num_bins = stats -> attr -> attstattarget ;
2390
+ int num_mcv = stats -> attstattarget ;
2391
+ int num_bins = stats -> attstattarget ;
2397
2392
StdAnalyzeData * mystats = (StdAnalyzeData * ) stats -> extra_data ;
2398
2393
2399
2394
values = (ScalarItem * ) palloc (samplerows * sizeof (ScalarItem ));
0 commit comments