@@ -1043,6 +1043,7 @@ create table boolpart (a bool) partition by list (a);
1043
1043
create table boolpart_default partition of boolpart default;
1044
1044
create table boolpart_t partition of boolpart for values in ('true');
1045
1045
create table boolpart_f partition of boolpart for values in ('false');
1046
+ insert into boolpart values (true), (false), (null);
1046
1047
explain (costs off) select * from boolpart where a in (true, false);
1047
1048
QUERY PLAN
1048
1049
------------------------------------------------
@@ -1077,22 +1078,27 @@ explain (costs off) select * from boolpart where a is true or a is not true;
1077
1078
Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1078
1079
-> Seq Scan on boolpart_t
1079
1080
Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1080
- (5 rows)
1081
+ -> Seq Scan on boolpart_default
1082
+ Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1083
+ (7 rows)
1081
1084
1082
1085
explain (costs off) select * from boolpart where a is not true;
1083
- QUERY PLAN
1084
- ---------------------------------
1086
+ QUERY PLAN
1087
+ ------------------------------------
1085
1088
Append
1086
1089
-> Seq Scan on boolpart_f
1087
1090
Filter: (a IS NOT TRUE)
1088
- (3 rows)
1091
+ -> Seq Scan on boolpart_default
1092
+ Filter: (a IS NOT TRUE)
1093
+ (5 rows)
1089
1094
1090
1095
explain (costs off) select * from boolpart where a is not true and a is not false;
1091
- QUERY PLAN
1092
- --------------------------
1093
- Result
1094
- One-Time Filter: false
1095
- (2 rows)
1096
+ QUERY PLAN
1097
+ --------------------------------------------------------
1098
+ Append
1099
+ -> Seq Scan on boolpart_default
1100
+ Filter: ((a IS NOT TRUE) AND (a IS NOT FALSE))
1101
+ (3 rows)
1096
1102
1097
1103
explain (costs off) select * from boolpart where a is unknown;
1098
1104
QUERY PLAN
@@ -1118,6 +1124,207 @@ explain (costs off) select * from boolpart where a is not unknown;
1118
1124
Filter: (a IS NOT UNKNOWN)
1119
1125
(7 rows)
1120
1126
1127
+ select * from boolpart where a in (true, false);
1128
+ a
1129
+ ---
1130
+ f
1131
+ t
1132
+ (2 rows)
1133
+
1134
+ select * from boolpart where a = false;
1135
+ a
1136
+ ---
1137
+ f
1138
+ (1 row)
1139
+
1140
+ select * from boolpart where not a = false;
1141
+ a
1142
+ ---
1143
+ t
1144
+ (1 row)
1145
+
1146
+ select * from boolpart where a is true or a is not true;
1147
+ a
1148
+ ---
1149
+ f
1150
+ t
1151
+
1152
+ (3 rows)
1153
+
1154
+ select * from boolpart where a is not true;
1155
+ a
1156
+ ---
1157
+ f
1158
+
1159
+ (2 rows)
1160
+
1161
+ select * from boolpart where a is not true and a is not false;
1162
+ a
1163
+ ---
1164
+
1165
+ (1 row)
1166
+
1167
+ select * from boolpart where a is unknown;
1168
+ a
1169
+ ---
1170
+
1171
+ (1 row)
1172
+
1173
+ select * from boolpart where a is not unknown;
1174
+ a
1175
+ ---
1176
+ f
1177
+ t
1178
+ (2 rows)
1179
+
1180
+ -- inverse boolean partitioning - a seemingly unlikely design, but we've got
1181
+ -- code for it, so we'd better test it.
1182
+ create table iboolpart (a bool) partition by list ((not a));
1183
+ create table iboolpart_default partition of iboolpart default;
1184
+ create table iboolpart_f partition of iboolpart for values in ('true');
1185
+ create table iboolpart_t partition of iboolpart for values in ('false');
1186
+ insert into iboolpart values (true), (false), (null);
1187
+ explain (costs off) select * from iboolpart where a in (true, false);
1188
+ QUERY PLAN
1189
+ ------------------------------------------------
1190
+ Append
1191
+ -> Seq Scan on iboolpart_t
1192
+ Filter: (a = ANY ('{t,f}'::boolean[]))
1193
+ -> Seq Scan on iboolpart_f
1194
+ Filter: (a = ANY ('{t,f}'::boolean[]))
1195
+ -> Seq Scan on iboolpart_default
1196
+ Filter: (a = ANY ('{t,f}'::boolean[]))
1197
+ (7 rows)
1198
+
1199
+ explain (costs off) select * from iboolpart where a = false;
1200
+ QUERY PLAN
1201
+ -------------------------------
1202
+ Append
1203
+ -> Seq Scan on iboolpart_f
1204
+ Filter: (NOT a)
1205
+ (3 rows)
1206
+
1207
+ explain (costs off) select * from iboolpart where not a = false;
1208
+ QUERY PLAN
1209
+ -------------------------------
1210
+ Append
1211
+ -> Seq Scan on iboolpart_t
1212
+ Filter: a
1213
+ (3 rows)
1214
+
1215
+ explain (costs off) select * from iboolpart where a is true or a is not true;
1216
+ QUERY PLAN
1217
+ --------------------------------------------------
1218
+ Append
1219
+ -> Seq Scan on iboolpart_t
1220
+ Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1221
+ -> Seq Scan on iboolpart_f
1222
+ Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1223
+ -> Seq Scan on iboolpart_default
1224
+ Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1225
+ (7 rows)
1226
+
1227
+ explain (costs off) select * from iboolpart where a is not true;
1228
+ QUERY PLAN
1229
+ -------------------------------------
1230
+ Append
1231
+ -> Seq Scan on iboolpart_t
1232
+ Filter: (a IS NOT TRUE)
1233
+ -> Seq Scan on iboolpart_f
1234
+ Filter: (a IS NOT TRUE)
1235
+ -> Seq Scan on iboolpart_default
1236
+ Filter: (a IS NOT TRUE)
1237
+ (7 rows)
1238
+
1239
+ explain (costs off) select * from iboolpart where a is not true and a is not false;
1240
+ QUERY PLAN
1241
+ --------------------------------------------------------
1242
+ Append
1243
+ -> Seq Scan on iboolpart_t
1244
+ Filter: ((a IS NOT TRUE) AND (a IS NOT FALSE))
1245
+ -> Seq Scan on iboolpart_f
1246
+ Filter: ((a IS NOT TRUE) AND (a IS NOT FALSE))
1247
+ -> Seq Scan on iboolpart_default
1248
+ Filter: ((a IS NOT TRUE) AND (a IS NOT FALSE))
1249
+ (7 rows)
1250
+
1251
+ explain (costs off) select * from iboolpart where a is unknown;
1252
+ QUERY PLAN
1253
+ -------------------------------------
1254
+ Append
1255
+ -> Seq Scan on iboolpart_t
1256
+ Filter: (a IS UNKNOWN)
1257
+ -> Seq Scan on iboolpart_f
1258
+ Filter: (a IS UNKNOWN)
1259
+ -> Seq Scan on iboolpart_default
1260
+ Filter: (a IS UNKNOWN)
1261
+ (7 rows)
1262
+
1263
+ explain (costs off) select * from iboolpart where a is not unknown;
1264
+ QUERY PLAN
1265
+ -------------------------------------
1266
+ Append
1267
+ -> Seq Scan on iboolpart_t
1268
+ Filter: (a IS NOT UNKNOWN)
1269
+ -> Seq Scan on iboolpart_f
1270
+ Filter: (a IS NOT UNKNOWN)
1271
+ -> Seq Scan on iboolpart_default
1272
+ Filter: (a IS NOT UNKNOWN)
1273
+ (7 rows)
1274
+
1275
+ select * from iboolpart where a in (true, false);
1276
+ a
1277
+ ---
1278
+ t
1279
+ f
1280
+ (2 rows)
1281
+
1282
+ select * from iboolpart where a = false;
1283
+ a
1284
+ ---
1285
+ f
1286
+ (1 row)
1287
+
1288
+ select * from iboolpart where not a = false;
1289
+ a
1290
+ ---
1291
+ t
1292
+ (1 row)
1293
+
1294
+ select * from iboolpart where a is true or a is not true;
1295
+ a
1296
+ ---
1297
+ t
1298
+ f
1299
+
1300
+ (3 rows)
1301
+
1302
+ select * from iboolpart where a is not true;
1303
+ a
1304
+ ---
1305
+ f
1306
+
1307
+ (2 rows)
1308
+
1309
+ select * from iboolpart where a is not true and a is not false;
1310
+ a
1311
+ ---
1312
+
1313
+ (1 row)
1314
+
1315
+ select * from iboolpart where a is unknown;
1316
+ a
1317
+ ---
1318
+
1319
+ (1 row)
1320
+
1321
+ select * from iboolpart where a is not unknown;
1322
+ a
1323
+ ---
1324
+ t
1325
+ f
1326
+ (2 rows)
1327
+
1121
1328
create table boolrangep (a bool, b bool, c int) partition by range (a,b,c);
1122
1329
create table boolrangep_tf partition of boolrangep for values from ('true', 'false', 0) to ('true', 'false', 100);
1123
1330
create table boolrangep_ft partition of boolrangep for values from ('false', 'true', 0) to ('false', 'true', 100);
@@ -1524,7 +1731,7 @@ explain (costs off) select * from rparted_by_int2 where a > 100000000000000;
1524
1731
Filter: (a > '100000000000000'::bigint)
1525
1732
(3 rows)
1526
1733
1527
- drop table lp, coll_pruning, rlp, mc3p, mc2p, boolpart, boolrangep, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2;
1734
+ drop table lp, coll_pruning, rlp, mc3p, mc2p, boolpart, iboolpart, boolrangep, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2;
1528
1735
--
1529
1736
-- Test Partition pruning for HASH partitioning
1530
1737
--
0 commit comments