8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.71 2000/08/13 02:50:10 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.72 2000/08/21 17:22:34 tgl Exp $
12
12
*
13
13
* HISTORY
14
14
* AUTHORDATEMAJOR EVENT
@@ -353,7 +353,7 @@ make_ands_implicit(Expr *clause)
353
353
return clause -> args ;
354
354
else if (IsA (clause ,Const )&&
355
355
!((Const * )clause )-> constisnull &&
356
- DatumGetInt32 (((Const * )clause )-> constvalue ))
356
+ DatumGetBool (((Const * )clause )-> constvalue ))
357
357
return NIL ;/* constant TRUE input -> NIL list */
358
358
else
359
359
return lcons (clause ,NIL );
@@ -1111,12 +1111,15 @@ eval_const_expressions_mutator(Node *node, void *context)
1111
1111
case OR_EXPR :
1112
1112
{
1113
1113
1114
- /*
1115
- * OR arguments are handled as follows: non constant:
1116
- * keep FALSE: drop (does not affect result) TRUE:
1117
- * force result to TRUE NULL: keep only one We keep
1118
- * one NULL input because ExecEvalOr returns NULL when
1119
- * no input is TRUE and at least one is NULL.
1114
+ /*----------
1115
+ * OR arguments are handled as follows:
1116
+ *non constant: keep
1117
+ *FALSE: drop (does not affect result)
1118
+ *TRUE: force result to TRUE
1119
+ *NULL: keep only one
1120
+ * We keep one NULL input because ExecEvalOr returns NULL
1121
+ * when no input is TRUE and at least one is NULL.
1122
+ *----------
1120
1123
*/
1121
1124
List * newargs = NIL ;
1122
1125
List * arg ;
@@ -1133,7 +1136,7 @@ eval_const_expressions_mutator(Node *node, void *context)
1133
1136
const_input = (Const * )lfirst (arg );
1134
1137
if (const_input -> constisnull )
1135
1138
haveNull = true;
1136
- else if (DatumGetInt32 (const_input -> constvalue ))
1139
+ else if (DatumGetBool (const_input -> constvalue ))
1137
1140
forceTrue = true;
1138
1141
/* otherwise, we can drop the constant-false input */
1139
1142
}
@@ -1161,12 +1164,15 @@ eval_const_expressions_mutator(Node *node, void *context)
1161
1164
case AND_EXPR :
1162
1165
{
1163
1166
1164
- /*
1165
- * AND arguments are handled as follows: non constant:
1166
- * keep TRUE: drop (does not affect result) FALSE:
1167
- * force result to FALSE NULL: keep only one We keep
1168
- * one NULL input because ExecEvalAnd returns NULL
1167
+ /*----------
1168
+ * AND arguments are handled as follows:
1169
+ *non constant: keep
1170
+ *TRUE: drop (does not affect result)
1171
+ *FALSE: force result to FALSE
1172
+ *NULL: keep only one
1173
+ * We keep one NULL input because ExecEvalAnd returns NULL
1169
1174
* when no input is FALSE and at least one is NULL.
1175
+ *----------
1170
1176
*/
1171
1177
List * newargs = NIL ;
1172
1178
List * arg ;
@@ -1183,7 +1189,7 @@ eval_const_expressions_mutator(Node *node, void *context)
1183
1189
const_input = (Const * )lfirst (arg );
1184
1190
if (const_input -> constisnull )
1185
1191
haveNull = true;
1186
- else if (!DatumGetInt32 (const_input -> constvalue ))
1192
+ else if (!DatumGetBool (const_input -> constvalue ))
1187
1193
forceFalse = true;
1188
1194
/* otherwise, we can drop the constant-true input */
1189
1195
}
@@ -1217,7 +1223,7 @@ eval_const_expressions_mutator(Node *node, void *context)
1217
1223
if (const_input -> constisnull )
1218
1224
return MAKEBOOLCONST (false, true);
1219
1225
/* otherwise pretty easy */
1220
- return MAKEBOOLCONST (!DatumGetInt32 (const_input -> constvalue ),
1226
+ return MAKEBOOLCONST (!DatumGetBool (const_input -> constvalue ),
1221
1227
false);
1222
1228
case SUBPLAN_EXPR :
1223
1229
@@ -1330,7 +1336,7 @@ eval_const_expressions_mutator(Node *node, void *context)
1330
1336
}
1331
1337
const_input = (Const * )casewhen -> expr ;
1332
1338
if (const_input -> constisnull ||
1333
- !DatumGetInt32 (const_input -> constvalue ))
1339
+ !DatumGetBool (const_input -> constvalue ))
1334
1340
continue ;/* drop alternative with FALSE condition */
1335
1341
1336
1342
/*