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

Commitf04c9a6

Browse files
committed
Standardize terminology for pg_statistic_ext entries.
Consistently refer to such an entry as a "statistics object", not just"statistics" or "extended statistics". Previously we had a mismash ofterms, accompanied by utter confusion as to whether the term wassingular or plural. That's not only grating (at least to the ear ofa native English speaker) but could be outright misleading, eg in errormessages that seemed to be referring to multiple objects where only onecould be meant.This commit fixes the code and a lot of comments (though I may havemissed a few). I also renamed two new SQL functions,pg_get_statisticsextdef -> pg_get_statisticsobjdefpg_statistic_ext_is_visible -> pg_statistics_obj_is_visibleto conform better with this terminology.I have not touched the SGML docs other than fixing those functionnames; the docs certainly need work but it seems like a separable task.Discussion:https://postgr.es/m/22676.1494557205@sss.pgh.pa.us
1 parent12ad38b commitf04c9a6

31 files changed

+133
-125
lines changed

‎doc/src/sgml/func.sgml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16681,7 +16681,7 @@ SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
1668116681
<entry>is operator family visible in search path</entry>
1668216682
</row>
1668316683
<row>
16684-
<entry><literal><function>pg_statistic_ext_is_visible(<parameter>stat_oid</parameter>)</function></literal>
16684+
<entry><literal><function>pg_statistics_obj_is_visible(<parameter>stat_oid</parameter>)</function></literal>
1668516685
</entry>
1668616686
<entry><type>boolean</type></entry>
1668716687
<entry>is statistics object visible in search path</entry>
@@ -16745,7 +16745,7 @@ SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
1674516745
<primary>pg_opfamily_is_visible</primary>
1674616746
</indexterm>
1674716747
<indexterm>
16748-
<primary>pg_statistic_ext_is_visible</primary>
16748+
<primary>pg_statistics_obj_is_visible</primary>
1674916749
</indexterm>
1675016750
<indexterm>
1675116751
<primary>pg_table_is_visible</primary>
@@ -16836,7 +16836,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
1683616836
</indexterm>
1683716837

1683816838
<indexterm>
16839-
<primary>pg_get_statisticsextdef</primary>
16839+
<primary>pg_get_statisticsobjdef</primary>
1684016840
</indexterm>
1684116841

1684216842
<indexterm>
@@ -17009,9 +17009,9 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
1700917009
uses</entry>
1701017010
</row>
1701117011
<row>
17012-
<entry><literal><function>pg_get_statisticsextdef(<parameter>statext_oid</parameter>)</function></literal></entry>
17012+
<entry><literal><function>pg_get_statisticsobjdef(<parameter>statobj_oid</parameter>)</function></literal></entry>
1701317013
<entry><type>text</type></entry>
17014-
<entry>get <command>CREATE STATISTICS</> command for extended statisticsobjects</entry>
17014+
<entry>get <command>CREATE STATISTICS</> command for extended statisticsobject</entry>
1701517015
</row>
1701617016
<row>
1701717017
<entry><function>pg_get_triggerdef</function>(<parameter>trigger_oid</parameter>)</entry>
@@ -17158,7 +17158,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
1715817158
<para>
1715917159
<function>pg_get_constraintdef</function>,
1716017160
<function>pg_get_indexdef</function>, <function>pg_get_ruledef</function>,
17161-
<function>pg_get_statisticsextdef</function>, and
17161+
<function>pg_get_statisticsobjdef</function>, and
1716217162
<function>pg_get_triggerdef</function>, respectively reconstruct the
1716317163
creating command for a constraint, index, rule, extended statistics object,
1716417164
or trigger. (Note that this is a decompiled reconstruction, not the

‎src/backend/catalog/aclchk.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,7 +3321,7 @@ static const char *const no_priv_msg[MAX_ACL_KIND] =
33213321
/* ACL_KIND_CONVERSION */
33223322
gettext_noop("permission denied for conversion %s"),
33233323
/* ACL_KIND_STATISTICS */
3324-
gettext_noop("permission denied for statistics %s"),
3324+
gettext_noop("permission denied for statisticsobject%s"),
33253325
/* ACL_KIND_TABLESPACE */
33263326
gettext_noop("permission denied for tablespace %s"),
33273327
/* ACL_KIND_TSDICTIONARY */
@@ -3373,7 +3373,7 @@ static const char *const not_owner_msg[MAX_ACL_KIND] =
33733373
/* ACL_KIND_CONVERSION */
33743374
gettext_noop("must be owner of conversion %s"),
33753375
/* ACL_KIND_STATISTICS */
3376-
gettext_noop("must be owner of statistics %s"),
3376+
gettext_noop("must be owner of statisticsobject%s"),
33773377
/* ACL_KIND_TABLESPACE */
33783378
gettext_noop("must be owner of tablespace %s"),
33793379
/* ACL_KIND_TSDICTIONARY */
@@ -3490,7 +3490,7 @@ pg_aclmask(AclObjectKind objkind, Oid table_oid, AttrNumber attnum, Oid roleid,
34903490
caseACL_KIND_NAMESPACE:
34913491
returnpg_namespace_aclmask(table_oid,roleid,mask,how);
34923492
caseACL_KIND_STATISTICS:
3493-
elog(ERROR,"grantable rights not supported for statistics");
3493+
elog(ERROR,"grantable rights not supported for statistics objects");
34943494
/* not reached, but keep compiler quiet */
34953495
returnACL_NO_RIGHTS;
34963496
caseACL_KIND_TABLESPACE:
@@ -5130,10 +5130,10 @@ pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
51305130
}
51315131

51325132
/*
5133-
* Ownership check for aextendedstatistics (specified by OID).
5133+
* Ownership check for a statistics object (specified by OID).
51345134
*/
51355135
bool
5136-
pg_statistics_ownercheck(Oidstat_oid,Oidroleid)
5136+
pg_statistics_object_ownercheck(Oidstat_oid,Oidroleid)
51375137
{
51385138
HeapTupletuple;
51395139
OidownerId;
@@ -5146,7 +5146,8 @@ pg_statistics_ownercheck(Oid stat_oid, Oid roleid)
51465146
if (!HeapTupleIsValid(tuple))
51475147
ereport(ERROR,
51485148
(errcode(ERRCODE_UNDEFINED_OBJECT),
5149-
errmsg("statistics with OID %u do not exist",stat_oid)));
5149+
errmsg("statistics object with OID %u does not exist",
5150+
stat_oid)));
51505151

51515152
ownerId= ((Form_pg_statistic_ext)GETSTRUCT(tuple))->stxowner;
51525153

‎src/backend/catalog/namespace.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,12 +2087,12 @@ ConversionIsVisible(Oid conid)
20872087
}
20882088

20892089
/*
2090-
*get_statistics_oid - find a statistics by possibly qualified name
2090+
*get_statistics_object_oid - find a statistics object by possibly qualified name
20912091
*
20922092
* If not found, returns InvalidOid if missing_ok, else throws error
20932093
*/
20942094
Oid
2095-
get_statistics_oid(List*names,boolmissing_ok)
2095+
get_statistics_object_oid(List*names,boolmissing_ok)
20962096
{
20972097
char*schemaname;
20982098
char*stats_name;
@@ -2136,7 +2136,7 @@ get_statistics_oid(List *names, bool missing_ok)
21362136
if (!OidIsValid(stats_oid)&& !missing_ok)
21372137
ereport(ERROR,
21382138
(errcode(ERRCODE_UNDEFINED_OBJECT),
2139-
errmsg("statistics \"%s\"do not exist",
2139+
errmsg("statisticsobject\"%s\"does not exist",
21402140
NameListToString(names))));
21412141

21422142
returnstats_oid;
@@ -4303,7 +4303,7 @@ pg_conversion_is_visible(PG_FUNCTION_ARGS)
43034303
}
43044304

43054305
Datum
4306-
pg_statistic_ext_is_visible(PG_FUNCTION_ARGS)
4306+
pg_statistics_obj_is_visible(PG_FUNCTION_ARGS)
43074307
{
43084308
Oidoid=PG_GETARG_OID(0);
43094309

‎src/backend/catalog/objectaddress.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ static const struct object_type_map
712712
},
713713
/* OBJECT_STATISTIC_EXT */
714714
{
715-
"statistics",OBJECT_STATISTIC_EXT
715+
"statistics object",OBJECT_STATISTIC_EXT
716716
}
717717
};
718718

@@ -993,8 +993,8 @@ get_object_address(ObjectType objtype, Node *object,
993993
break;
994994
caseOBJECT_STATISTIC_EXT:
995995
address.classId=StatisticExtRelationId;
996-
address.objectId=get_statistics_oid(castNode(List,object),
997-
missing_ok);
996+
address.objectId=get_statistics_object_oid(castNode(List,object),
997+
missing_ok);
998998
address.objectSubId=0;
999999
break;
10001000
default:
@@ -2398,7 +2398,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
23982398
errmsg("must be superuser")));
23992399
break;
24002400
caseOBJECT_STATISTIC_EXT:
2401-
if (!pg_statistics_ownercheck(address.objectId,roleid))
2401+
if (!pg_statistics_object_ownercheck(address.objectId,roleid))
24022402
aclcheck_error_type(ACLCHECK_NOT_OWNER,address.objectId);
24032403
break;
24042404
default:
@@ -3907,11 +3907,12 @@ getObjectTypeDescription(const ObjectAddress *object)
39073907
break;
39083908

39093909
caseOCLASS_STATISTIC_EXT:
3910-
appendStringInfoString(&buffer,"statistics");
3910+
appendStringInfoString(&buffer,"statistics object");
39113911
break;
39123912

39133913
default:
3914-
appendStringInfo(&buffer,"unrecognized %u",object->classId);
3914+
appendStringInfo(&buffer,"unrecognized object class %u",
3915+
object->classId);
39153916
break;
39163917
}
39173918

@@ -4946,7 +4947,7 @@ getObjectIdentityParts(const ObjectAddress *object,
49464947
tup=SearchSysCache1(STATEXTOID,
49474948
ObjectIdGetDatum(object->objectId));
49484949
if (!HeapTupleIsValid(tup))
4949-
elog(ERROR,"cache lookup failed for statistics %u",
4950+
elog(ERROR,"cache lookup failed for statisticsobject%u",
49504951
object->objectId);
49514952
formStatistic= (Form_pg_statistic_ext)GETSTRUCT(tup);
49524953
schema=get_namespace_name_or_temp(formStatistic->stxnamespace);

‎src/backend/commands/alter.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ report_namespace_conflict(Oid classId, const char *name, Oid nspOid)
123123
break;
124124
caseStatisticExtRelationId:
125125
Assert(OidIsValid(nspOid));
126-
msgfmt=gettext_noop("statistics \"%s\" already exists in schema \"%s\"");
126+
msgfmt=gettext_noop("statisticsobject\"%s\" already exists in schema \"%s\"");
127127
break;
128128
caseTSParserRelationId:
129129
Assert(OidIsValid(nspOid));

‎src/backend/commands/dropcmds.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
289289
caseOBJECT_STATISTIC_EXT:
290290
if (!schema_does_not_exist_skipping(castNode(List,object),&msg,&name))
291291
{
292-
msg=gettext_noop("extendedstatistics \"%s\"do not exist, skipping");
292+
msg=gettext_noop("statisticsobject\"%s\"does not exist, skipping");
293293
name=NameListToString(castNode(List,object));
294294
}
295295
break;

‎src/backend/commands/statscmds.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*-------------------------------------------------------------------------
22
*
33
* statscmds.c
4-
* Commands for creating and altering extended statistics
4+
* Commands for creating and altering extended statistics objects
55
*
66
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
@@ -64,7 +64,7 @@ CreateStatistics(CreateStatsStmt *stmt)
6464
Oidrelid;
6565
ObjectAddressparentobject,
6666
myself;
67-
Datumtypes[2];/* one for each possible type ofstatistics */
67+
Datumtypes[2];/* one for each possible type ofstatistic */
6868
intntypes;
6969
ArrayType*stxkind;
7070
boolbuild_ndistinct;
@@ -80,7 +80,7 @@ CreateStatistics(CreateStatsStmt *stmt)
8080
namestrcpy(&stxname,namestr);
8181

8282
/*
83-
* Deal with the possibility that thenamedstatistics alreadyexist.
83+
* Deal with the possibility that the statisticsobjectalreadyexists.
8484
*/
8585
if (SearchSysCacheExists2(STATEXTNAMENSP,
8686
NameGetDatum(&stxname),
@@ -90,14 +90,14 @@ CreateStatistics(CreateStatsStmt *stmt)
9090
{
9191
ereport(NOTICE,
9292
(errcode(ERRCODE_DUPLICATE_OBJECT),
93-
errmsg("statistics \"%s\" alreadyexist, skipping",
93+
errmsg("statisticsobject\"%s\" alreadyexists, skipping",
9494
namestr)));
9595
returnInvalidObjectAddress;
9696
}
9797

9898
ereport(ERROR,
9999
(errcode(ERRCODE_DUPLICATE_OBJECT),
100-
errmsg("statistics \"%s\" alreadyexist",namestr)));
100+
errmsg("statisticsobject\"%s\" alreadyexists",namestr)));
101101
}
102102

103103
/*
@@ -263,7 +263,7 @@ CreateStatistics(CreateStatsStmt *stmt)
263263
else
264264
ereport(ERROR,
265265
(errcode(ERRCODE_SYNTAX_ERROR),
266-
errmsg("unrecognizedstatistics type \"%s\"",
266+
errmsg("unrecognizedstatistic type \"%s\"",
267267
type)));
268268
}
269269
/* If no statistic type was specified, build them all. */
@@ -307,7 +307,7 @@ CreateStatistics(CreateStatsStmt *stmt)
307307
relation_close(statrel,RowExclusiveLock);
308308

309309
/*
310-
* Invalidate relcache so that others see the new statistics.
310+
* Invalidate relcache so that others see the new statistics object.
311311
*/
312312
CacheInvalidateRelcache(rel);
313313

@@ -346,7 +346,7 @@ CreateStatistics(CreateStatsStmt *stmt)
346346
}
347347

348348
/*
349-
* Guts of statistics deletion.
349+
* Guts of statisticsobjectdeletion.
350350
*/
351351
void
352352
RemoveStatisticsById(OidstatsOid)
@@ -365,7 +365,7 @@ RemoveStatisticsById(Oid statsOid)
365365
tup=SearchSysCache1(STATEXTOID,ObjectIdGetDatum(statsOid));
366366

367367
if (!HeapTupleIsValid(tup))/* should not happen */
368-
elog(ERROR,"cache lookup failed for statistics %u",statsOid);
368+
elog(ERROR,"cache lookup failed for statisticsobject%u",statsOid);
369369

370370
statext= (Form_pg_statistic_ext)GETSTRUCT(tup);
371371
relid=statext->stxrelid;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,13 +1285,13 @@ get_relation_statistics(RelOptInfo *rel, Relation relation)
12851285

12861286
htup=SearchSysCache1(STATEXTOID,ObjectIdGetDatum(statOid));
12871287
if (!htup)
1288-
elog(ERROR,"cache lookup failed for statistics %u",statOid);
1288+
elog(ERROR,"cache lookup failed for statisticsobject%u",statOid);
12891289
staForm= (Form_pg_statistic_ext)GETSTRUCT(htup);
12901290

12911291
/*
12921292
* First, build the array of columns covered. This is ultimately
1293-
* wasted if no statsare actually built, but it doesn't seem worth
1294-
* troubling over that case.
1293+
* wasted if no statswithin the object have actually been built, but
1294+
*it doesn't seem worthtroubling over that case.
12951295
*/
12961296
for (i=0;i<staForm->stxkeys.dim1;i++)
12971297
keys=bms_add_member(keys,staForm->stxkeys.values[i]);

‎src/backend/statistics/README‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ hopefully improving the estimates and producing better plans.
1212
Types of statistics
1313
-------------------
1414

15-
There are two kinds of extended statistics:
15+
There arecurrentlytwo kinds of extended statistics:
1616

1717
(a) ndistinct coefficients
1818

@@ -36,7 +36,7 @@ Complex clauses
3636

3737
We also support estimating more complex clauses - essentially AND/OR clauses
3838
with (Var op Const) as leaves, as long as all the referenced attributes are
39-
covered by a single statistics.
39+
covered by a single statistics object.
4040

4141
For example this condition
4242

@@ -59,7 +59,7 @@ Selectivity estimation
5959
Throughout the planner clauselist_selectivity() still remains in charge of
6060
most selectivity estimate requests. clauselist_selectivity() can be instructed
6161
to try to make use of any extended statistics on the given RelOptInfo, which
62-
it will do, if:
62+
it will do if:
6363

6464
(a) An actual valid RelOptInfo was given. Join relations are passed in as
6565
NULL, therefore are invalid.
@@ -77,6 +77,7 @@ performing estimations knows which clauses are to be skipped.
7777

7878
Size of sample in ANALYZE
7979
-------------------------
80+
8081
When performing ANALYZE, the number of rows to sample is determined as
8182

8283
(300 * statistics_target)
@@ -93,4 +94,4 @@ those are not necessarily limited by statistics_target.
9394
This however merits further discussion, because collecting the sample is quite
9495
expensive and increasing it further would make ANALYZE even more painful.
9596
Judging by the experiments with the current implementation, the fixed size
96-
seems to work reasonably well for now, so we leave this asafuture work.
97+
seems to work reasonably well for now, so we leave this as future work.

‎src/backend/statistics/README.dependencies‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ rendering the approach mostly useless even for slightly noisy data sets, or
4848
result in sudden changes in behavior depending on minor differences between
4949
samples provided to ANALYZE.
5050

51-
For this reason,the statisticsimplements "soft" functional dependencies,
51+
For this reason,extended statisticsimplement "soft" functional dependencies,
5252
associating each functional dependency with a degree of validity (a number
5353
between 0 and 1). This degree is then used to combine selectivities in a
5454
smooth manner.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp