Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3ccb2c5

Browse files
committed
Extend VacAttrStats to allow typanalyze functions to store statistic values
of different types than the underlying column. The capability isn't yetused for anything, but will be required by upcoming patch to analyzetsvector columns.Jan Urbanski
1 parentbaaad23 commit3ccb2c5

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

‎src/backend/commands/analyze.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -684,6 +684,7 @@ examine_attribute(Relation onerel, int attnum)
684684
Form_pg_attributeattr=onerel->rd_att->attrs[attnum-1];
685685
HeapTupletyptuple;
686686
VacAttrStats*stats;
687+
inti;
687688
boolok;
688689

689690
/* Never analyze dropped columns */
@@ -711,6 +712,20 @@ examine_attribute(Relation onerel, int attnum)
711712
stats->anl_context=anl_context;
712713
stats->tupattnum=attnum;
713714

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+
714729
/*
715730
* Call the type-specific typanalyze function.If none is specified, use
716731
* std_typanalyze().
@@ -1322,10 +1337,10 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
13221337

13231338
arry=construct_array(stats->stavalues[k],
13241339
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]);
13291344
values[i++]=PointerGetDatum(arry);/* stavaluesN */
13301345
}
13311346
else
@@ -1855,6 +1870,10 @@ compute_minimal_stats(VacAttrStatsP stats,
18551870
stats->numnumbers[0]=num_mcv;
18561871
stats->stavalues[0]=mcv_values;
18571872
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+
*/
18581877
}
18591878
}
18601879
elseif (null_cnt>0)
@@ -2198,6 +2217,10 @@ compute_scalar_stats(VacAttrStatsP stats,
21982217
stats->numnumbers[slot_idx]=num_mcv;
21992218
stats->stavalues[slot_idx]=mcv_values;
22002219
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+
*/
22012224
slot_idx++;
22022225
}
22032226

@@ -2282,6 +2305,10 @@ compute_scalar_stats(VacAttrStatsP stats,
22822305
stats->staop[slot_idx]=mystats->ltopr;
22832306
stats->stavalues[slot_idx]=hist_values;
22842307
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+
*/
22852312
slot_idx++;
22862313
}
22872314

‎src/include/commands/vacuum.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.78 2008/06/19 00:46:06 alvherre Exp $
10+
* $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.79 2008/07/01 10:33:09 heikki Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -93,6 +93,18 @@ typedef struct VacAttrStats
9393
intnumvalues[STATISTIC_NUM_SLOTS];
9494
Datum*stavalues[STATISTIC_NUM_SLOTS];
9595

96+
/*
97+
* These fields describe the stavalues[n] element types. They will
98+
* be initialized to be the same as the column's that's underlying the
99+
* slot, but a custom typanalyze function might want to store an array of
100+
* something other than the analyzed column's elements. It should then
101+
* overwrite these fields.
102+
*/
103+
Oidstatypid[STATISTIC_NUM_SLOTS];
104+
int2statyplen[STATISTIC_NUM_SLOTS];
105+
boolstatypbyval[STATISTIC_NUM_SLOTS];
106+
charstatypalign[STATISTIC_NUM_SLOTS];
107+
96108
/*
97109
* These fields are private to the main ANALYZE code and should not be
98110
* looked at by type-specific functions.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp