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