@@ -802,10 +802,12 @@ exprCollation(const Node *expr)
802
802
coll = ((const NullIfExpr * ) expr )-> opcollid ;
803
803
break ;
804
804
case T_ScalarArrayOpExpr :
805
- coll = InvalidOid ; /* result is always boolean */
805
+ /* ScalarArrayOpExpr's result is boolean ... */
806
+ coll = InvalidOid ; /* ... so it has no collation */
806
807
break ;
807
808
case T_BoolExpr :
808
- coll = InvalidOid ; /* result is always boolean */
809
+ /* BoolExpr's result is boolean ... */
810
+ coll = InvalidOid ; /* ... so it has no collation */
809
811
break ;
810
812
case T_SubLink :
811
813
{
@@ -827,8 +829,8 @@ exprCollation(const Node *expr)
827
829
}
828
830
else
829
831
{
830
- /* otherwise, result is RECORD or BOOLEAN */
831
- coll = InvalidOid ;
832
+ /* otherwise, SubLink's result is RECORD or BOOLEAN */
833
+ coll = InvalidOid ; /* ... so it has no collation */
832
834
}
833
835
}
834
836
break ;
@@ -845,8 +847,8 @@ exprCollation(const Node *expr)
845
847
}
846
848
else
847
849
{
848
- /* otherwise, result is RECORD or BOOLEAN */
849
- coll = InvalidOid ;
850
+ /* otherwise, SubPlan's result is RECORD or BOOLEAN */
851
+ coll = InvalidOid ; /* ... so it has no collation */
850
852
}
851
853
}
852
854
break ;
@@ -862,7 +864,8 @@ exprCollation(const Node *expr)
862
864
coll = ((const FieldSelect * ) expr )-> resultcollid ;
863
865
break ;
864
866
case T_FieldStore :
865
- coll = InvalidOid ; /* result is always composite */
867
+ /* FieldStore's result is composite ... */
868
+ coll = InvalidOid ; /* ... so it has no collation */
866
869
break ;
867
870
case T_RelabelType :
868
871
coll = ((const RelabelType * ) expr )-> resultcollid ;
@@ -874,7 +877,8 @@ exprCollation(const Node *expr)
874
877
coll = ((const ArrayCoerceExpr * ) expr )-> resultcollid ;
875
878
break ;
876
879
case T_ConvertRowtypeExpr :
877
- coll = InvalidOid ; /* result is always composite */
880
+ /* ConvertRowtypeExpr's result is composite ... */
881
+ coll = InvalidOid ; /* ... so it has no collation */
878
882
break ;
879
883
case T_CollateExpr :
880
884
coll = ((const CollateExpr * ) expr )-> collOid ;
@@ -889,10 +893,12 @@ exprCollation(const Node *expr)
889
893
coll = ((const ArrayExpr * ) expr )-> array_collid ;
890
894
break ;
891
895
case T_RowExpr :
892
- coll = InvalidOid ; /* result is always composite */
896
+ /* RowExpr's result is composite ... */
897
+ coll = InvalidOid ; /* ... so it has no collation */
893
898
break ;
894
899
case T_RowCompareExpr :
895
- coll = InvalidOid ; /* result is always boolean */
900
+ /* RowCompareExpr's result is boolean ... */
901
+ coll = InvalidOid ; /* ... so it has no collation */
896
902
break ;
897
903
case T_CoalesceExpr :
898
904
coll = ((const CoalesceExpr * ) expr )-> coalescecollid ;
@@ -920,10 +926,12 @@ exprCollation(const Node *expr)
920
926
coll = InvalidOid ;
921
927
break ;
922
928
case T_NullTest :
923
- coll = InvalidOid ; /* result is always boolean */
929
+ /* NullTest's result is boolean ... */
930
+ coll = InvalidOid ; /* ... so it has no collation */
924
931
break ;
925
932
case T_BooleanTest :
926
- coll = InvalidOid ; /* result is always boolean */
933
+ /* BooleanTest's result is boolean ... */
934
+ coll = InvalidOid ; /* ... so it has no collation */
927
935
break ;
928
936
case T_CoerceToDomain :
929
937
coll = ((const CoerceToDomain * ) expr )-> resultcollid ;
@@ -935,10 +943,12 @@ exprCollation(const Node *expr)
935
943
coll = ((const SetToDefault * ) expr )-> collation ;
936
944
break ;
937
945
case T_CurrentOfExpr :
938
- coll = InvalidOid ; /* result is always boolean */
946
+ /* CurrentOfExpr's result is boolean ... */
947
+ coll = InvalidOid ; /* ... so it has no collation */
939
948
break ;
940
949
case T_NextValueExpr :
941
- coll = InvalidOid ; /* result is always an integer type */
950
+ /* NextValueExpr's result is an integer type ... */
951
+ coll = InvalidOid ; /* ... so it has no collation */
942
952
break ;
943
953
case T_InferenceElem :
944
954
coll = exprCollation ((Node * ) ((const InferenceElem * ) expr )-> expr );
@@ -1050,10 +1060,12 @@ exprSetCollation(Node *expr, Oid collation)
1050
1060
((NullIfExpr * ) expr )-> opcollid = collation ;
1051
1061
break ;
1052
1062
case T_ScalarArrayOpExpr :
1053
- Assert (!OidIsValid (collation )); /* result is always boolean */
1063
+ /* ScalarArrayOpExpr's result is boolean ... */
1064
+ Assert (!OidIsValid (collation )); /* ... so never set a collation */
1054
1065
break ;
1055
1066
case T_BoolExpr :
1056
- Assert (!OidIsValid (collation )); /* result is always boolean */
1067
+ /* BoolExpr's result is boolean ... */
1068
+ Assert (!OidIsValid (collation )); /* ... so never set a collation */
1057
1069
break ;
1058
1070
case T_SubLink :
1059
1071
#ifdef USE_ASSERT_CHECKING
@@ -1085,7 +1097,8 @@ exprSetCollation(Node *expr, Oid collation)
1085
1097
((FieldSelect * ) expr )-> resultcollid = collation ;
1086
1098
break ;
1087
1099
case T_FieldStore :
1088
- Assert (!OidIsValid (collation )); /* result is always composite */
1100
+ /* FieldStore's result is composite ... */
1101
+ Assert (!OidIsValid (collation )); /* ... so never set a collation */
1089
1102
break ;
1090
1103
case T_RelabelType :
1091
1104
((RelabelType * ) expr )-> resultcollid = collation ;
@@ -1097,7 +1110,8 @@ exprSetCollation(Node *expr, Oid collation)
1097
1110
((ArrayCoerceExpr * ) expr )-> resultcollid = collation ;
1098
1111
break ;
1099
1112
case T_ConvertRowtypeExpr :
1100
- Assert (!OidIsValid (collation )); /* result is always composite */
1113
+ /* ConvertRowtypeExpr's result is composite ... */
1114
+ Assert (!OidIsValid (collation )); /* ... so never set a collation */
1101
1115
break ;
1102
1116
case T_CaseExpr :
1103
1117
((CaseExpr * ) expr )-> casecollid = collation ;
@@ -1106,10 +1120,12 @@ exprSetCollation(Node *expr, Oid collation)
1106
1120
((ArrayExpr * ) expr )-> array_collid = collation ;
1107
1121
break ;
1108
1122
case T_RowExpr :
1109
- Assert (!OidIsValid (collation )); /* result is always composite */
1123
+ /* RowExpr's result is composite ... */
1124
+ Assert (!OidIsValid (collation )); /* ... so never set a collation */
1110
1125
break ;
1111
1126
case T_RowCompareExpr :
1112
- Assert (!OidIsValid (collation )); /* result is always boolean */
1127
+ /* RowCompareExpr's result is boolean ... */
1128
+ Assert (!OidIsValid (collation )); /* ... so never set a collation */
1113
1129
break ;
1114
1130
case T_CoalesceExpr :
1115
1131
((CoalesceExpr * ) expr )-> coalescecollid = collation ;
@@ -1128,10 +1144,12 @@ exprSetCollation(Node *expr, Oid collation)
1128
1144
(collation == InvalidOid ));
1129
1145
break ;
1130
1146
case T_NullTest :
1131
- Assert (!OidIsValid (collation )); /* result is always boolean */
1147
+ /* NullTest's result is boolean ... */
1148
+ Assert (!OidIsValid (collation )); /* ... so never set a collation */
1132
1149
break ;
1133
1150
case T_BooleanTest :
1134
- Assert (!OidIsValid (collation )); /* result is always boolean */
1151
+ /* BooleanTest's result is boolean ... */
1152
+ Assert (!OidIsValid (collation )); /* ... so never set a collation */
1135
1153
break ;
1136
1154
case T_CoerceToDomain :
1137
1155
((CoerceToDomain * ) expr )-> resultcollid = collation ;
@@ -1143,11 +1161,12 @@ exprSetCollation(Node *expr, Oid collation)
1143
1161
((SetToDefault * ) expr )-> collation = collation ;
1144
1162
break ;
1145
1163
case T_CurrentOfExpr :
1146
- Assert (!OidIsValid (collation )); /* result is always boolean */
1164
+ /* CurrentOfExpr's result is boolean ... */
1165
+ Assert (!OidIsValid (collation )); /* ... so never set a collation */
1147
1166
break ;
1148
1167
case T_NextValueExpr :
1149
- Assert (! OidIsValid ( collation )); /* result is always an integer
1150
- * type */
1168
+ /* NextValueExpr's result is an integer type ... */
1169
+ Assert (! OidIsValid ( collation )); /* ... so never set a collation */
1151
1170
break ;
1152
1171
default :
1153
1172
elog (ERROR , "unrecognized node type: %d" , (int ) nodeTag (expr ));
0 commit comments