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

Commit 6b610ae

Browse files
author
Nikita Glukhov
committed
Fix XXX comments
1 parent 59d95cc commit 6b610ae

File tree

2 files changed

+21
-28
lines changed

2 files changed

+21
-28
lines changed

src/backend/commands/operatorcmds.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@
5252

5353
static Oid ValidateRestrictionEstimator(List *restrictionName);
5454
static Oid ValidateJoinEstimator(List *joinName);
55-
56-
/*
57-
* XXX Maybe not the right name, because "estimator" implies we're calculating
58-
* selectivity. But we're actually deriving statistics for an expression.
59-
*/
60-
static Oid ValidateStatisticsEstimator(List *joinName);
55+
static Oid ValidateStatisticsDerivator(List *joinName);
6156

6257
/*
6358
* DefineOperator
@@ -139,8 +134,7 @@ DefineOperator(List *names, List *parameters)
139134
restrictionName = defGetQualifiedName(defel);
140135
else if (strcmp(defel->defname, "join") == 0)
141136
joinName = defGetQualifiedName(defel);
142-
/* XXX perhaps full "statistics" wording would be better */
143-
else if (strcmp(defel->defname, "stats") == 0)
137+
else if (strcmp(defel->defname, "statistics") == 0)
144138
statisticsName = defGetQualifiedName(defel);
145139
else if (strcmp(defel->defname, "hashes") == 0)
146140
canHash = defGetBoolean(defel);
@@ -258,7 +252,7 @@ DefineOperator(List *names, List *parameters)
258252
else
259253
joinOid = InvalidOid;
260254
if (statisticsName)
261-
statisticsOid = ValidateStatisticsEstimator(statisticsName);
255+
statisticsOid = ValidateStatisticsDerivator(statisticsName);
262256
else
263257
statisticsOid = InvalidOid;
264258

@@ -378,7 +372,7 @@ ValidateJoinEstimator(List *joinName)
378372
* correct signature and we have the permissions to attach it to an operator.
379373
*/
380374
static Oid
381-
ValidateStatisticsEstimator(List *statName)
375+
ValidateStatisticsDerivator(List *statName)
382376
{
383377
Oid typeId[4];
384378
Oid statOid;
@@ -392,11 +386,11 @@ ValidateStatisticsEstimator(List *statName)
392386
statOid = LookupFuncName(statName, 4, typeId, false);
393387

394388
/* statistics estimators must return void */
395-
if (get_func_rettype(statOid) != BOOLOID)
389+
if (get_func_rettype(statOid) != VOIDOID)
396390
ereport(ERROR,
397391
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
398392
errmsg("statistics estimator function %s must return type %s",
399-
NameListToString(statName), "boolean")));
393+
NameListToString(statName), "void")));
400394

401395
/* Require EXECUTE rights for the estimator */
402396
aclresult = pg_proc_aclcheck(statOid, GetUserId(), ACL_EXECUTE);
@@ -555,7 +549,7 @@ AlterOperator(AlterOperatorStmt *stmt)
555549
else
556550
joinOid = InvalidOid;
557551
if (statName)
558-
statOid = ValidateStatisticsEstimator(statName);
552+
statOid = ValidateStatisticsDerivator(statName);
559553
else
560554
statOid = InvalidOid;
561555

src/backend/utils/adt/selfuncs.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4922,25 +4922,23 @@ ReleaseDummy(HeapTuple tuple)
49224922
* Try to derive optimizer statistics for the operator expression using
49234923
* operator's oprstat function.
49244924
*
4925-
* XXX Not sure why this returns bool - we ignore the return value anyway. We
4926-
* might as well return the calculated vardata (or NULL).
4927-
*
4928-
* XXX Not sure what to do about recursion - there can be another OpExpr in
4929-
* one of the arguments, and we should call this recursively from the oprstat
4930-
* procedure. But that's not possible, because it's marked as static.
4925+
* There can be another OpExpr in one of the arguments, and it will be called
4926+
* recursively from the oprstat procedure through the following chain:
4927+
* get_restriction_variable() => examine_variable() =>
4928+
* examine_operator_expression().
49314929
*/
4932-
static bool
4930+
static void
49334931
examine_operator_expression(PlannerInfo *root, OpExpr *opexpr, int varRelid,
49344932
VariableStatData *vardata)
49354933
{
49364934
RegProcedure oprstat = get_oprstat(opexpr->opno);
49374935

4938-
return OidIsValid(oprstat) &&
4939-
DatumGetBool(OidFunctionCall4(oprstat,
4940-
PointerGetDatum(root),
4941-
PointerGetDatum(opexpr),
4942-
Int32GetDatum(varRelid),
4943-
PointerGetDatum(vardata)));
4936+
if (OidIsValid(oprstat))
4937+
OidFunctionCall4(oprstat,
4938+
PointerGetDatum(root),
4939+
PointerGetDatum(opexpr),
4940+
Int32GetDatum(varRelid),
4941+
PointerGetDatum(vardata));
49444942
}
49454943

49464944
/*
@@ -5365,8 +5363,9 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid,
53655363
* operator expression (OpExpr). We do this last because it may be quite
53665364
* expensive, and it's unclear how accurate the statistics will be.
53675365
*
5368-
* XXX Shouldn't this put more restrictions on the OpExpr? E.g. that
5369-
* one of the arguments has to be a Const or something?
5366+
* More restrictions on the OpExpr (e.g. that one of the arguments
5367+
* has to be a Const or something) can be put by the operator itself
5368+
* in its oprstat function.
53705369
*/
53715370
if (!vardata->statsTuple && IsA(basenode, OpExpr))
53725371
examine_operator_expression(root, (OpExpr *) basenode, varRelid,

0 commit comments

Comments
 (0)