Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f04c9a6

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 of terms, accompanied by utter confusion as to whether the term was singular or plural. That's not only grating (at least to the ear of a native English speaker) but could be outright misleading, eg in error messages that seemed to be referring to multiple objects where only one could be meant. This commit fixes the code and a lot of comments (though I may have missed a few). I also renamed two new SQL functions, pg_get_statisticsextdef -> pg_get_statisticsobjdef pg_statistic_ext_is_visible -> pg_statistics_obj_is_visible to conform better with this terminology. I have not touched the SGML docs other than fixing those function names; the docs certainly need work but it seems like a separable task. Discussion: https://postgr.es/m/22676.1494557205@sss.pgh.pa.us
1 parent 12ad38b commit f04c9a6

31 files changed

+133
-125
lines changed

doc/src/sgml/func.sgml

+6-6
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 statistics objects</entry>
17014+
<entry>get <command>CREATE STATISTICS</> command for extended statistics object</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

+7-6
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 statistics object %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 statistics object %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
case ACL_KIND_NAMESPACE:
34913491
return pg_namespace_aclmask(table_oid, roleid, mask, how);
34923492
case ACL_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
return ACL_NO_RIGHTS;
34963496
case ACL_KIND_TABLESPACE:
@@ -5130,10 +5130,10 @@ pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
51305130
}
51315131

51325132
/*
5133-
* Ownership check for a extended statistics (specified by OID).
5133+
* Ownership check for a statistics object (specified by OID).
51345134
*/
51355135
bool
5136-
pg_statistics_ownercheck(Oid stat_oid, Oid roleid)
5136+
pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid)
51375137
{
51385138
HeapTuple tuple;
51395139
Oid ownerId;
@@ -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

+4-4
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, bool missing_ok)
2095+
get_statistics_object_oid(List *names, bool missing_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("statistics object \"%s\" does not exist",
21402140
NameListToString(names))));
21412141

21422142
return stats_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
Oid oid = PG_GETARG_OID(0);
43094309

src/backend/catalog/objectaddress.c

+8-7
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
case OBJECT_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
case OBJECT_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
case OCLASS_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 statistics object %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

+1-1
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
case StatisticExtRelationId:
125125
Assert(OidIsValid(nspOid));
126-
msgfmt = gettext_noop("statistics \"%s\" already exists in schema \"%s\"");
126+
msgfmt = gettext_noop("statistics object \"%s\" already exists in schema \"%s\"");
127127
break;
128128
case TSParserRelationId:
129129
Assert(OidIsValid(nspOid));

src/backend/commands/dropcmds.c

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

src/backend/commands/statscmds.c

+9-9
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
Oid relid;
6565
ObjectAddress parentobject,
6666
myself;
67-
Datum types[2]; /* one for each possible type of statistics */
67+
Datum types[2]; /* one for each possible type of statistic */
6868
int ntypes;
6969
ArrayType *stxkind;
7070
bool build_ndistinct;
@@ -80,7 +80,7 @@ CreateStatistics(CreateStatsStmt *stmt)
8080
namestrcpy(&stxname, namestr);
8181

8282
/*
83-
* Deal with the possibility that the named statistics already exist.
83+
* Deal with the possibility that the statistics object already exists.
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\" already exist, skipping",
93+
errmsg("statistics object \"%s\" already exists, skipping",
9494
namestr)));
9595
return InvalidObjectAddress;
9696
}
9797

9898
ereport(ERROR,
9999
(errcode(ERRCODE_DUPLICATE_OBJECT),
100-
errmsg("statistics \"%s\" already exist", namestr)));
100+
errmsg("statistics object \"%s\" already exists", namestr)));
101101
}
102102

103103
/*
@@ -263,7 +263,7 @@ CreateStatistics(CreateStatsStmt *stmt)
263263
else
264264
ereport(ERROR,
265265
(errcode(ERRCODE_SYNTAX_ERROR),
266-
errmsg("unrecognized statistics type \"%s\"",
266+
errmsg("unrecognized statistic 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 statistics object deletion.
350350
*/
351351
void
352352
RemoveStatisticsById(Oid statsOid)
@@ -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 statistics object %u", statsOid);
369369

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

src/backend/optimizer/util/plancat.c

+3-3
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 statistics object %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 stats are actually built, but it doesn't seem worth
1294-
* troubling over that case.
1293+
* wasted if no stats within the object have actually been built, but
1294+
* it doesn't seem worth troubling 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

+5-4
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 are currently two 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 as a future work.
97+
seems to work reasonably well for now, so we leave this as future work.

src/backend/statistics/README.dependencies

+1-1
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 statistics implements "soft" functional dependencies,
51+
For this reason, extended statistics implement "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.

src/backend/statistics/dependencies.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ dependency_degree(int numrows, HeapTuple *rows, int k, AttrNumber *dependency,
342342
* detects functional dependencies between groups of columns
343343
*
344344
* Generates all possible subsets of columns (variations) and computes
345-
* the degree of validity for each one. For example with a statistic on
346-
* three columns (a,b,c) there are 9 possible dependencies
345+
* the degree of validity for each one. For example when creating statistics
346+
* on three columns (a,b,c) there are 9 possible dependencies
347347
*
348348
* two columns three columns
349349
* ----------- -------------
@@ -383,8 +383,8 @@ statext_dependencies_build(int numrows, HeapTuple *rows, Bitmapset *attrs,
383383
/*
384384
* We'll try build functional dependencies starting from the smallest ones
385385
* covering just 2 columns, to the largest ones, covering all columns
386-
* included in the statistics. We start from the smallest ones because we
387-
* want to be able to skip already implied ones.
386+
* included in the statistics object. We start from the smallest ones
387+
* because we want to be able to skip already implied ones.
388388
*/
389389
for (k = 2; k <= numattrs; k++)
390390
{
@@ -644,7 +644,7 @@ staext_dependencies_load(Oid mvoid)
644644
HeapTuple htup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(mvoid));
645645

646646
if (!HeapTupleIsValid(htup))
647-
elog(ERROR, "cache lookup failed for extended statistics %u", mvoid);
647+
elog(ERROR, "cache lookup failed for statistics object %u", mvoid);
648648

649649
deps = SysCacheGetAttr(STATEXTOID, htup,
650650
Anum_pg_statistic_ext_stxdependencies, &isnull);
@@ -975,7 +975,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
975975
return 1.0;
976976
}
977977

978-
/* find the best suited statistics for these attnums */
978+
/* find the best suited statistics object for these attnums */
979979
stat = choose_best_statistics(rel->statlist, clauses_attnums,
980980
STATS_EXT_DEPENDENCIES);
981981

@@ -986,7 +986,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
986986
return 1.0;
987987
}
988988

989-
/* load the dependency items stored in the statistics */
989+
/* load the dependency items stored in the statistics object */
990990
dependencies = staext_dependencies_load(stat->statOid);
991991

992992
/*

0 commit comments

Comments
 (0)