Commit 152d33bc authored by David Rowley's avatar David Rowley

Improve slightly misleading comments in nodeFuncs.c

There were some comments in nodeFuncs.c that, depending on your
interpretation of the word "result", could lead you to believe that the
comments were badly copied and pasted from somewhere else.  If you thought
of "result" as the return value of the function that the comment is
written in, then you'd be misled.  However, if you'd correctly
interpreted "result" to mean the result type of the given node type,
you'd not have seen any issues.

Here we do a small cleanup to try to prevent any future
misinterpretations.  Per wording suggestion from Tom Lane.

Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/CAApHDvp+Bw=2Qiu5=uXMKfC7gd0+B=4JvexVgGJU=am2g9a1CA@mail.gmail.com
parent 9cae39b8
......@@ -802,10 +802,12 @@ exprCollation(const Node *expr)
coll = ((const NullIfExpr *) expr)->opcollid;
break;
case T_ScalarArrayOpExpr:
coll = InvalidOid; /* result is always boolean */
/* ScalarArrayOpExpr's result is boolean ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_BoolExpr:
coll = InvalidOid; /* result is always boolean */
/* BoolExpr's result is boolean ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_SubLink:
{
......@@ -827,8 +829,8 @@ exprCollation(const Node *expr)
}
else
{
/* otherwise, result is RECORD or BOOLEAN */
coll = InvalidOid;
/* otherwise, SubLink's result is RECORD or BOOLEAN */
coll = InvalidOid; /* ... so it has no collation */
}
}
break;
......@@ -845,8 +847,8 @@ exprCollation(const Node *expr)
}
else
{
/* otherwise, result is RECORD or BOOLEAN */
coll = InvalidOid;
/* otherwise, SubPlan's result is RECORD or BOOLEAN */
coll = InvalidOid; /* ... so it has no collation */
}
}
break;
......@@ -862,7 +864,8 @@ exprCollation(const Node *expr)
coll = ((const FieldSelect *) expr)->resultcollid;
break;
case T_FieldStore:
coll = InvalidOid; /* result is always composite */
/* FieldStore's result is composite ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_RelabelType:
coll = ((const RelabelType *) expr)->resultcollid;
......@@ -874,7 +877,8 @@ exprCollation(const Node *expr)
coll = ((const ArrayCoerceExpr *) expr)->resultcollid;
break;
case T_ConvertRowtypeExpr:
coll = InvalidOid; /* result is always composite */
/* ConvertRowtypeExpr's result is composite ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_CollateExpr:
coll = ((const CollateExpr *) expr)->collOid;
......@@ -889,10 +893,12 @@ exprCollation(const Node *expr)
coll = ((const ArrayExpr *) expr)->array_collid;
break;
case T_RowExpr:
coll = InvalidOid; /* result is always composite */
/* RowExpr's result is composite ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_RowCompareExpr:
coll = InvalidOid; /* result is always boolean */
/* RowCompareExpr's result is boolean ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_CoalesceExpr:
coll = ((const CoalesceExpr *) expr)->coalescecollid;
......@@ -920,10 +926,12 @@ exprCollation(const Node *expr)
coll = InvalidOid;
break;
case T_NullTest:
coll = InvalidOid; /* result is always boolean */
/* NullTest's result is boolean ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_BooleanTest:
coll = InvalidOid; /* result is always boolean */
/* BooleanTest's result is boolean ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_CoerceToDomain:
coll = ((const CoerceToDomain *) expr)->resultcollid;
......@@ -935,10 +943,12 @@ exprCollation(const Node *expr)
coll = ((const SetToDefault *) expr)->collation;
break;
case T_CurrentOfExpr:
coll = InvalidOid; /* result is always boolean */
/* CurrentOfExpr's result is boolean ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_NextValueExpr:
coll = InvalidOid; /* result is always an integer type */
/* NextValueExpr's result is an integer type ... */
coll = InvalidOid; /* ... so it has no collation */
break;
case T_InferenceElem:
coll = exprCollation((Node *) ((const InferenceElem *) expr)->expr);
......@@ -1050,10 +1060,12 @@ exprSetCollation(Node *expr, Oid collation)
((NullIfExpr *) expr)->opcollid = collation;
break;
case T_ScalarArrayOpExpr:
Assert(!OidIsValid(collation)); /* result is always boolean */
/* ScalarArrayOpExpr's result is boolean ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
case T_BoolExpr:
Assert(!OidIsValid(collation)); /* result is always boolean */
/* BoolExpr's result is boolean ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
case T_SubLink:
#ifdef USE_ASSERT_CHECKING
......@@ -1085,7 +1097,8 @@ exprSetCollation(Node *expr, Oid collation)
((FieldSelect *) expr)->resultcollid = collation;
break;
case T_FieldStore:
Assert(!OidIsValid(collation)); /* result is always composite */
/* FieldStore's result is composite ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
case T_RelabelType:
((RelabelType *) expr)->resultcollid = collation;
......@@ -1097,7 +1110,8 @@ exprSetCollation(Node *expr, Oid collation)
((ArrayCoerceExpr *) expr)->resultcollid = collation;
break;
case T_ConvertRowtypeExpr:
Assert(!OidIsValid(collation)); /* result is always composite */
/* ConvertRowtypeExpr's result is composite ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
case T_CaseExpr:
((CaseExpr *) expr)->casecollid = collation;
......@@ -1106,10 +1120,12 @@ exprSetCollation(Node *expr, Oid collation)
((ArrayExpr *) expr)->array_collid = collation;
break;
case T_RowExpr:
Assert(!OidIsValid(collation)); /* result is always composite */
/* RowExpr's result is composite ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
case T_RowCompareExpr:
Assert(!OidIsValid(collation)); /* result is always boolean */
/* RowCompareExpr's result is boolean ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
case T_CoalesceExpr:
((CoalesceExpr *) expr)->coalescecollid = collation;
......@@ -1128,10 +1144,12 @@ exprSetCollation(Node *expr, Oid collation)
(collation == InvalidOid));
break;
case T_NullTest:
Assert(!OidIsValid(collation)); /* result is always boolean */
/* NullTest's result is boolean ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
case T_BooleanTest:
Assert(!OidIsValid(collation)); /* result is always boolean */
/* BooleanTest's result is boolean ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
case T_CoerceToDomain:
((CoerceToDomain *) expr)->resultcollid = collation;
......@@ -1143,11 +1161,12 @@ exprSetCollation(Node *expr, Oid collation)
((SetToDefault *) expr)->collation = collation;
break;
case T_CurrentOfExpr:
Assert(!OidIsValid(collation)); /* result is always boolean */
/* CurrentOfExpr's result is boolean ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
case T_NextValueExpr:
Assert(!OidIsValid(collation)); /* result is always an integer
* type */
/* NextValueExpr's result is an integer type ... */
Assert(!OidIsValid(collation)); /* ... so never set a collation */
break;
default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment