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

Commitee69221

Browse files
committed
Rename columns in new pg_statistic_ext catalog
The new catalog reused a column prefix "sta" from pg_statistic, but thisis undesirable, so change the catalog to use prefix "stx" instead.Also, rename the column that lists enabled statistic kinds as "stxkind"rather than "enabled".Discussion:https://postgr.es/m/CAKJS1f_2t5jhSN7huYRFH3w3rrHfG2QU7hiUHsu-Vdjd1rYT3w@mail.gmail.com
1 parent8c5cdb7 commitee69221

File tree

22 files changed

+142
-140
lines changed

22 files changed

+142
-140
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4291,21 +4291,21 @@
42914291
<tbody>
42924292

42934293
<row>
4294-
<entry><structfield>starelid</structfield></entry>
4294+
<entry><structfield>stxrelid</structfield></entry>
42954295
<entry><type>oid</type></entry>
42964296
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
42974297
<entry>The table that the described columns belongs to</entry>
42984298
</row>
42994299

43004300
<row>
4301-
<entry><structfield>staname</structfield></entry>
4301+
<entry><structfield>stxname</structfield></entry>
43024302
<entry><type>name</type></entry>
43034303
<entry></entry>
43044304
<entry>Name of the statistic.</entry>
43054305
</row>
43064306

43074307
<row>
4308-
<entry><structfield>stanamespace</structfield></entry>
4308+
<entry><structfield>stxnamespace</structfield></entry>
43094309
<entry><type>oid</type></entry>
43104310
<entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
43114311
<entry>
@@ -4314,24 +4314,26 @@
43144314
</row>
43154315

43164316
<row>
4317-
<entry><structfield>staowner</structfield></entry>
4317+
<entry><structfield>stxowner</structfield></entry>
43184318
<entry><type>oid</type></entry>
43194319
<entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
43204320
<entry>Owner of the statistic</entry>
43214321
</row>
43224322

43234323
<row>
4324-
<entry><structfield>staenabled</structfield></entry>
4324+
<entry><structfield>stxkind</structfield></entry>
43254325
<entry><type>char[]</type></entry>
43264326
<entry></entry>
43274327
<entry>
4328-
An array with the modes of the enabled statistic types, encoded as
4329-
<literal>d</literal> for ndistinct coefficients.
4328+
An array with the modes of the enabled statistic types. Valid values
4329+
are:
4330+
<literal>d</literal> for ndistinct coefficients,
4331+
<literal>f</literal> for functional dependencies.
43304332
</entry>
43314333
</row>
43324334

43334335
<row>
4334-
<entry><structfield>stakeys</structfield></entry>
4336+
<entry><structfield>stxkeys</structfield></entry>
43354337
<entry><type>int2vector</type></entry>
43364338
<entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
43374339
<entry>
@@ -4342,7 +4344,7 @@
43424344
</row>
43434345

43444346
<row>
4345-
<entry><structfield>standistinct</structfield></entry>
4347+
<entry><structfield>stxndistinct</structfield></entry>
43464348
<entry><type>pg_ndistinct</type></entry>
43474349
<entry></entry>
43484350
<entry>
@@ -4351,7 +4353,7 @@
43514353
</row>
43524354

43534355
<row>
4354-
<entry><structfield>stadependencies</structfield></entry>
4356+
<entry><structfield>stxdependencies</structfield></entry>
43554357
<entry><type>pg_dependencies</type></entry>
43564358
<entry></entry>
43574359
<entry>

‎doc/src/sgml/planstats.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ EXPLAIN ANALYZE SELECT * FROM t WHERE a = 1 AND b = 1;
525525
you may do this:
526526

527527
<programlisting>
528-
SELECTstaname,stadependencies FROM pg_statistic_ext WHEREstaname = 's1';
529-
staname |stadependencies
528+
SELECTstxname,stxdependencies FROM pg_statistic_ext WHEREstxname = 's1';
529+
stxname |stxdependencies
530530
---------+--------------------------------------------
531531
s1 | [{1 => 2 : 1.000000}, {2 => 1 : 1.000000}]
532532
(1 row)

‎src/backend/catalog/aclchk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5148,7 +5148,7 @@ pg_statistics_ownercheck(Oid stat_oid, Oid roleid)
51485148
(errcode(ERRCODE_UNDEFINED_OBJECT),
51495149
errmsg("statistics with OID %u do not exist",stat_oid)));
51505150

5151-
ownerId= ((Form_pg_statistic_ext)GETSTRUCT(tuple))->staowner;
5151+
ownerId= ((Form_pg_statistic_ext)GETSTRUCT(tuple))->stxowner;
51525152

51535153
ReleaseSysCache(tuple);
51545154

‎src/backend/catalog/heap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,7 @@ RemoveStatisticsExt(Oid relid, AttrNumber attnum)
28052805
pgstatisticext=heap_open(StatisticExtRelationId,RowExclusiveLock);
28062806

28072807
ScanKeyInit(&key,
2808-
Anum_pg_statistic_ext_starelid,
2808+
Anum_pg_statistic_ext_stxrelid,
28092809
BTEqualStrategyNumber,F_OIDEQ,
28102810
ObjectIdGetDatum(relid));
28112811

@@ -2825,13 +2825,13 @@ RemoveStatisticsExt(Oid relid, AttrNumber attnum)
28252825
inti;
28262826

28272827
/*
2828-
* Decode thestakeys array and delete any stats that involve the
2828+
* Decode thestxkeys array and delete any stats that involve the
28292829
* specified column.
28302830
*/
28312831
staForm= (Form_pg_statistic_ext)GETSTRUCT(tuple);
2832-
for (i=0;i<staForm->stakeys.dim1;i++)
2832+
for (i=0;i<staForm->stxkeys.dim1;i++)
28332833
{
2834-
if (staForm->stakeys.values[i]==attnum)
2834+
if (staForm->stxkeys.values[i]==attnum)
28352835
{
28362836
delete= true;
28372837
break;

‎src/backend/catalog/objectaddress.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,9 @@ static const ObjectPropertyType ObjectProperty[] =
485485
StatisticExtOidIndexId,
486486
STATEXTOID,
487487
STATEXTNAMENSP,
488-
Anum_pg_statistic_ext_staname,
489-
Anum_pg_statistic_ext_stanamespace,
490-
Anum_pg_statistic_ext_staowner,
488+
Anum_pg_statistic_ext_stxname,
489+
Anum_pg_statistic_ext_stxnamespace,
490+
Anum_pg_statistic_ext_stxowner,
491491
InvalidAttrNumber,/* no ACL (same as relation) */
492492
ACL_KIND_STATISTICS,
493493
true
@@ -4936,13 +4936,13 @@ getObjectIdentityParts(const ObjectAddress *object,
49364936
elog(ERROR,"cache lookup failed for statistics %u",
49374937
object->objectId);
49384938
formStatistic= (Form_pg_statistic_ext)GETSTRUCT(tup);
4939-
schema=get_namespace_name_or_temp(formStatistic->stanamespace);
4939+
schema=get_namespace_name_or_temp(formStatistic->stxnamespace);
49404940
appendStringInfoString(&buffer,
49414941
quote_qualified_identifier(schema,
4942-
NameStr(formStatistic->staname)));
4942+
NameStr(formStatistic->stxname)));
49434943
if (objname)
49444944
*objname=list_make2(schema,
4945-
pstrdup(NameStr(formStatistic->staname)));
4945+
pstrdup(NameStr(formStatistic->stxname)));
49464946
ReleaseSysCache(tup);
49474947
}
49484948
break;

‎src/backend/commands/statscmds.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ CreateStatistics(CreateStatsStmt *stmt)
5050
intnumcols=0;
5151
ObjectAddressaddress=InvalidObjectAddress;
5252
char*namestr;
53-
NameDatastaname;
53+
NameDatastxname;
5454
Oidstatoid;
5555
OidnamespaceId;
5656
HeapTuplehtup;
5757
Datumvalues[Natts_pg_statistic_ext];
5858
boolnulls[Natts_pg_statistic_ext];
59-
int2vector*stakeys;
59+
int2vector*stxkeys;
6060
Relationstatrel;
6161
Relationrel;
6262
Oidrelid;
6363
ObjectAddressparentobject,
6464
childobject;
6565
Datumtypes[2];/* one for each possible type of statistics */
6666
intntypes;
67-
ArrayType*staenabled;
67+
ArrayType*stxkind;
6868
boolbuild_ndistinct;
6969
boolbuild_dependencies;
7070
boolrequested_type= false;
@@ -73,13 +73,13 @@ CreateStatistics(CreateStatsStmt *stmt)
7373

7474
/* resolve the pieces of the name (namespace etc.) */
7575
namespaceId=QualifiedNameGetCreationNamespace(stmt->defnames,&namestr);
76-
namestrcpy(&staname,namestr);
76+
namestrcpy(&stxname,namestr);
7777

7878
/*
7979
* If if_not_exists was given and the statistics already exists, bail out.
8080
*/
8181
if (SearchSysCacheExists2(STATEXTNAMENSP,
82-
PointerGetDatum(&staname),
82+
PointerGetDatum(&stxname),
8383
ObjectIdGetDatum(namespaceId)))
8484
{
8585
if (stmt->if_not_exists)
@@ -184,7 +184,7 @@ CreateStatistics(CreateStatsStmt *stmt)
184184
(errcode(ERRCODE_UNDEFINED_COLUMN),
185185
errmsg("duplicate column name in statistics definition")));
186186

187-
stakeys=buildint2vector(attnums,numcols);
187+
stxkeys=buildint2vector(attnums,numcols);
188188

189189
/*
190190
* Parse the statistics options. Currently only statistics types are
@@ -226,23 +226,23 @@ CreateStatistics(CreateStatsStmt *stmt)
226226
if (build_dependencies)
227227
types[ntypes++]=CharGetDatum(STATS_EXT_DEPENDENCIES);
228228
Assert(ntypes>0);
229-
staenabled=construct_array(types,ntypes,CHAROID,1, true,'c');
229+
stxkind=construct_array(types,ntypes,CHAROID,1, true,'c');
230230

231231
/*
232232
* Everything seems fine, so let's build the pg_statistic_ext tuple.
233233
*/
234234
memset(values,0,sizeof(values));
235235
memset(nulls, false,sizeof(nulls));
236-
values[Anum_pg_statistic_ext_starelid-1]=ObjectIdGetDatum(relid);
237-
values[Anum_pg_statistic_ext_staname-1]=NameGetDatum(&staname);
238-
values[Anum_pg_statistic_ext_stanamespace-1]=ObjectIdGetDatum(namespaceId);
239-
values[Anum_pg_statistic_ext_staowner-1]=ObjectIdGetDatum(GetUserId());
240-
values[Anum_pg_statistic_ext_stakeys-1]=PointerGetDatum(stakeys);
241-
values[Anum_pg_statistic_ext_staenabled-1]=PointerGetDatum(staenabled);
236+
values[Anum_pg_statistic_ext_stxrelid-1]=ObjectIdGetDatum(relid);
237+
values[Anum_pg_statistic_ext_stxname-1]=NameGetDatum(&stxname);
238+
values[Anum_pg_statistic_ext_stxnamespace-1]=ObjectIdGetDatum(namespaceId);
239+
values[Anum_pg_statistic_ext_stxowner-1]=ObjectIdGetDatum(GetUserId());
240+
values[Anum_pg_statistic_ext_stxkeys-1]=PointerGetDatum(stxkeys);
241+
values[Anum_pg_statistic_ext_stxkind-1]=PointerGetDatum(stxkind);
242242

243243
/* no statistics build yet */
244-
nulls[Anum_pg_statistic_ext_standistinct-1]= true;
245-
nulls[Anum_pg_statistic_ext_stadependencies-1]= true;
244+
nulls[Anum_pg_statistic_ext_stxndistinct-1]= true;
245+
nulls[Anum_pg_statistic_ext_stxdependencies-1]= true;
246246

247247
/* insert it into pg_statistic_ext */
248248
statrel=heap_open(StatisticExtRelationId,RowExclusiveLock);
@@ -303,7 +303,7 @@ RemoveStatisticsById(Oid statsOid)
303303
elog(ERROR,"cache lookup failed for statistics %u",statsOid);
304304

305305
statext= (Form_pg_statistic_ext)GETSTRUCT(tup);
306-
relid=statext->starelid;
306+
relid=statext->stxrelid;
307307

308308
rel=heap_open(relid,AccessExclusiveLock);
309309

‎src/backend/optimizer/util/plancat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,8 @@ get_relation_statistics(RelOptInfo *rel, Relation relation)
12931293
* wasted if no stats are actually built, but it doesn't seem worth
12941294
* troubling over that case.
12951295
*/
1296-
for (i=0;i<staForm->stakeys.dim1;i++)
1297-
keys=bms_add_member(keys,staForm->stakeys.values[i]);
1296+
for (i=0;i<staForm->stxkeys.dim1;i++)
1297+
keys=bms_add_member(keys,staForm->stxkeys.values[i]);
12981298

12991299
/* add one StatisticExtInfo for each kind built */
13001300
if (statext_is_kind_built(htup,STATS_EXT_NDISTINCT))

‎src/backend/statistics/dependencies.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ statext_dependencies_build(int numrows, HeapTuple *rows, Bitmapset *attrs,
411411
d= (MVDependency*)palloc0(offsetof(MVDependency,attributes)
412412
+k*sizeof(AttrNumber));
413413

414-
/* copy the dependency (and keep the indexes intostakeys) */
414+
/* copy the dependency (and keep the indexes intostxkeys) */
415415
d->degree=degree;
416416
d->nattributes=k;
417417
for (i=0;i<k;i++)
@@ -652,7 +652,7 @@ staext_dependencies_load(Oid mvoid)
652652
elog(ERROR,"cache lookup failed for extended statistics %u",mvoid);
653653

654654
deps=SysCacheGetAttr(STATEXTOID,htup,
655-
Anum_pg_statistic_ext_stadependencies,&isnull);
655+
Anum_pg_statistic_ext_stxdependencies,&isnull);
656656

657657
Assert(!isnull);
658658

‎src/backend/statistics/extended_stats.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ statext_is_kind_built(HeapTuple htup, char type)
145145
switch (type)
146146
{
147147
caseSTATS_EXT_NDISTINCT:
148-
attnum=Anum_pg_statistic_ext_standistinct;
148+
attnum=Anum_pg_statistic_ext_stxndistinct;
149149
break;
150150

151151
caseSTATS_EXT_DEPENDENCIES:
152-
attnum=Anum_pg_statistic_ext_stadependencies;
152+
attnum=Anum_pg_statistic_ext_stxdependencies;
153153
break;
154154

155155
default:
@@ -175,7 +175,7 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid)
175175
* rel.
176176
*/
177177
ScanKeyInit(&skey,
178-
Anum_pg_statistic_ext_starelid,
178+
Anum_pg_statistic_ext_stxrelid,
179179
BTEqualStrategyNumber,F_OIDEQ,
180180
ObjectIdGetDatum(relid));
181181

@@ -195,23 +195,23 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid)
195195
entry=palloc0(sizeof(StatExtEntry));
196196
entry->statOid=HeapTupleGetOid(htup);
197197
staForm= (Form_pg_statistic_ext)GETSTRUCT(htup);
198-
entry->schema=get_namespace_name(staForm->stanamespace);
199-
entry->name=pstrdup(NameStr(staForm->staname));
200-
for (i=0;i<staForm->stakeys.dim1;i++)
198+
entry->schema=get_namespace_name(staForm->stxnamespace);
199+
entry->name=pstrdup(NameStr(staForm->stxname));
200+
for (i=0;i<staForm->stxkeys.dim1;i++)
201201
{
202202
entry->columns=bms_add_member(entry->columns,
203-
staForm->stakeys.values[i]);
203+
staForm->stxkeys.values[i]);
204204
}
205205

206-
/* decode thestaenabled char array into a list of chars */
206+
/* decode thestxkind char array into a list of chars */
207207
datum=SysCacheGetAttr(STATEXTOID,htup,
208-
Anum_pg_statistic_ext_staenabled,&isnull);
208+
Anum_pg_statistic_ext_stxkind,&isnull);
209209
Assert(!isnull);
210210
arr=DatumGetArrayTypeP(datum);
211211
if (ARR_NDIM(arr)!=1||
212212
ARR_HASNULL(arr)||
213213
ARR_ELEMTYPE(arr)!=CHAROID)
214-
elog(ERROR,"staenabled is not a 1-D char array");
214+
elog(ERROR,"stxkind is not a 1-D char array");
215215
enabled= (char*)ARR_DATA_PTR(arr);
216216
for (i=0;i<ARR_DIMS(arr)[0];i++)
217217
{
@@ -231,7 +231,7 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid)
231231
/*
232232
* Using 'vacatts' of size 'nvacatts' as input data, return a newly built
233233
* VacAttrStats array which includes only the items corresponding to
234-
* attributes indicated by 'stakeys'. If we don't have all of the per column
234+
* attributes indicated by 'stxkeys'. If we don't have all of the per column
235235
* stats available to compute the extended stats, then we return NULL to indicate
236236
* to the caller that the stats should not be built.
237237
*/
@@ -310,21 +310,21 @@ statext_store(Relation pg_stext, Oid statOid,
310310
{
311311
bytea*data=statext_ndistinct_serialize(ndistinct);
312312

313-
nulls[Anum_pg_statistic_ext_standistinct-1]= (data==NULL);
314-
values[Anum_pg_statistic_ext_standistinct-1]=PointerGetDatum(data);
313+
nulls[Anum_pg_statistic_ext_stxndistinct-1]= (data==NULL);
314+
values[Anum_pg_statistic_ext_stxndistinct-1]=PointerGetDatum(data);
315315
}
316316

317317
if (dependencies!=NULL)
318318
{
319319
bytea*data=statext_dependencies_serialize(dependencies);
320320

321-
nulls[Anum_pg_statistic_ext_stadependencies-1]= (data==NULL);
322-
values[Anum_pg_statistic_ext_stadependencies-1]=PointerGetDatum(data);
321+
nulls[Anum_pg_statistic_ext_stxdependencies-1]= (data==NULL);
322+
values[Anum_pg_statistic_ext_stxdependencies-1]=PointerGetDatum(data);
323323
}
324324

325325
/* always replace the value (either by bytea or NULL) */
326-
replaces[Anum_pg_statistic_ext_standistinct-1]= true;
327-
replaces[Anum_pg_statistic_ext_stadependencies-1]= true;
326+
replaces[Anum_pg_statistic_ext_stxndistinct-1]= true;
327+
replaces[Anum_pg_statistic_ext_stxdependencies-1]= true;
328328

329329
/* there should already be a pg_statistic_ext tuple */
330330
oldtup=SearchSysCache1(STATEXTOID,ObjectIdGetDatum(statOid));

‎src/backend/statistics/mvdistinct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ statext_ndistinct_load(Oid mvoid)
134134
elog(ERROR,"cache lookup failed for statistics %u",mvoid);
135135

136136
ndist=SysCacheGetAttr(STATEXTOID,htup,
137-
Anum_pg_statistic_ext_standistinct,&isnull);
137+
Anum_pg_statistic_ext_stxndistinct,&isnull);
138138
if (isnull)
139139
elog(ERROR,
140140
"requested statistic kind %c not yet built for statistics %u",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp