@@ -1018,6 +1018,7 @@ create table boolpart (a bool) partition by list (a);
1018
1018
create table boolpart_default partition of boolpart default;
1019
1019
create table boolpart_t partition of boolpart for values in ('true');
1020
1020
create table boolpart_f partition of boolpart for values in ('false');
1021
+ insert into boolpart values (true), (false), (null);
1021
1022
explain (costs off) select * from boolpart where a in (true, false);
1022
1023
QUERY PLAN
1023
1024
------------------------------------------------
@@ -1050,20 +1051,25 @@ explain (costs off) select * from boolpart where a is true or a is not true;
1050
1051
Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1051
1052
-> Seq Scan on boolpart_t
1052
1053
Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1053
- (5 rows)
1054
+ -> Seq Scan on boolpart_default
1055
+ Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1056
+ (7 rows)
1054
1057
1055
1058
explain (costs off) select * from boolpart where a is not true;
1056
- QUERY PLAN
1057
- ---------------------------
1058
- Seq Scan on boolpart_f
1059
- Filter: (a IS NOT TRUE)
1060
- (2 rows)
1059
+ QUERY PLAN
1060
+ ------------------------------------
1061
+ Append
1062
+ -> Seq Scan on boolpart_f
1063
+ Filter: (a IS NOT TRUE)
1064
+ -> Seq Scan on boolpart_default
1065
+ Filter: (a IS NOT TRUE)
1066
+ (5 rows)
1061
1067
1062
1068
explain (costs off) select * from boolpart where a is not true and a is not false;
1063
- QUERY PLAN
1064
- --------------------------
1065
- Result
1066
- One-Time Filter: false
1069
+ QUERY PLAN
1070
+ --------------------------------------------------
1071
+ Seq Scan on boolpart_default
1072
+ Filter: ((a IS NOT TRUE) AND (a IS NOT FALSE))
1067
1073
(2 rows)
1068
1074
1069
1075
explain (costs off) select * from boolpart where a is unknown;
@@ -1090,6 +1096,205 @@ explain (costs off) select * from boolpart where a is not unknown;
1090
1096
Filter: (a IS NOT UNKNOWN)
1091
1097
(7 rows)
1092
1098
1099
+ select * from boolpart where a in (true, false);
1100
+ a
1101
+ ---
1102
+ f
1103
+ t
1104
+ (2 rows)
1105
+
1106
+ select * from boolpart where a = false;
1107
+ a
1108
+ ---
1109
+ f
1110
+ (1 row)
1111
+
1112
+ select * from boolpart where not a = false;
1113
+ a
1114
+ ---
1115
+ t
1116
+ (1 row)
1117
+
1118
+ select * from boolpart where a is true or a is not true;
1119
+ a
1120
+ ---
1121
+ f
1122
+ t
1123
+
1124
+ (3 rows)
1125
+
1126
+ select * from boolpart where a is not true;
1127
+ a
1128
+ ---
1129
+ f
1130
+
1131
+ (2 rows)
1132
+
1133
+ select * from boolpart where a is not true and a is not false;
1134
+ a
1135
+ ---
1136
+
1137
+ (1 row)
1138
+
1139
+ select * from boolpart where a is unknown;
1140
+ a
1141
+ ---
1142
+
1143
+ (1 row)
1144
+
1145
+ select * from boolpart where a is not unknown;
1146
+ a
1147
+ ---
1148
+ f
1149
+ t
1150
+ (2 rows)
1151
+
1152
+ -- inverse boolean partitioning - a seemingly unlikely design, but we've got
1153
+ -- code for it, so we'd better test it.
1154
+ create table iboolpart (a bool) partition by list ((not a));
1155
+ create table iboolpart_default partition of iboolpart default;
1156
+ create table iboolpart_f partition of iboolpart for values in ('true');
1157
+ create table iboolpart_t partition of iboolpart for values in ('false');
1158
+ insert into iboolpart values (true), (false), (null);
1159
+ explain (costs off) select * from iboolpart where a in (true, false);
1160
+ QUERY PLAN
1161
+ ------------------------------------------------
1162
+ Append
1163
+ -> Seq Scan on iboolpart_t
1164
+ Filter: (a = ANY ('{t,f}'::boolean[]))
1165
+ -> Seq Scan on iboolpart_f
1166
+ Filter: (a = ANY ('{t,f}'::boolean[]))
1167
+ -> Seq Scan on iboolpart_default
1168
+ Filter: (a = ANY ('{t,f}'::boolean[]))
1169
+ (7 rows)
1170
+
1171
+ explain (costs off) select * from iboolpart where a = false;
1172
+ QUERY PLAN
1173
+ -------------------------
1174
+ Seq Scan on iboolpart_f
1175
+ Filter: (NOT a)
1176
+ (2 rows)
1177
+
1178
+ explain (costs off) select * from iboolpart where not a = false;
1179
+ QUERY PLAN
1180
+ -------------------------
1181
+ Seq Scan on iboolpart_t
1182
+ Filter: a
1183
+ (2 rows)
1184
+
1185
+ explain (costs off) select * from iboolpart where a is true or a is not true;
1186
+ QUERY PLAN
1187
+ --------------------------------------------------
1188
+ Append
1189
+ -> Seq Scan on iboolpart_t
1190
+ Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1191
+ -> Seq Scan on iboolpart_f
1192
+ Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1193
+ -> Seq Scan on iboolpart_default
1194
+ Filter: ((a IS TRUE) OR (a IS NOT TRUE))
1195
+ (7 rows)
1196
+
1197
+ explain (costs off) select * from iboolpart where a is not true;
1198
+ QUERY PLAN
1199
+ -------------------------------------
1200
+ Append
1201
+ -> Seq Scan on iboolpart_t
1202
+ Filter: (a IS NOT TRUE)
1203
+ -> Seq Scan on iboolpart_f
1204
+ Filter: (a IS NOT TRUE)
1205
+ -> Seq Scan on iboolpart_default
1206
+ Filter: (a IS NOT TRUE)
1207
+ (7 rows)
1208
+
1209
+ explain (costs off) select * from iboolpart where a is not true and a is not false;
1210
+ QUERY PLAN
1211
+ --------------------------------------------------------
1212
+ Append
1213
+ -> Seq Scan on iboolpart_t
1214
+ Filter: ((a IS NOT TRUE) AND (a IS NOT FALSE))
1215
+ -> Seq Scan on iboolpart_f
1216
+ Filter: ((a IS NOT TRUE) AND (a IS NOT FALSE))
1217
+ -> Seq Scan on iboolpart_default
1218
+ Filter: ((a IS NOT TRUE) AND (a IS NOT FALSE))
1219
+ (7 rows)
1220
+
1221
+ explain (costs off) select * from iboolpart where a is unknown;
1222
+ QUERY PLAN
1223
+ -------------------------------------
1224
+ Append
1225
+ -> Seq Scan on iboolpart_t
1226
+ Filter: (a IS UNKNOWN)
1227
+ -> Seq Scan on iboolpart_f
1228
+ Filter: (a IS UNKNOWN)
1229
+ -> Seq Scan on iboolpart_default
1230
+ Filter: (a IS UNKNOWN)
1231
+ (7 rows)
1232
+
1233
+ explain (costs off) select * from iboolpart where a is not unknown;
1234
+ QUERY PLAN
1235
+ -------------------------------------
1236
+ Append
1237
+ -> Seq Scan on iboolpart_t
1238
+ Filter: (a IS NOT UNKNOWN)
1239
+ -> Seq Scan on iboolpart_f
1240
+ Filter: (a IS NOT UNKNOWN)
1241
+ -> Seq Scan on iboolpart_default
1242
+ Filter: (a IS NOT UNKNOWN)
1243
+ (7 rows)
1244
+
1245
+ select * from iboolpart where a in (true, false);
1246
+ a
1247
+ ---
1248
+ t
1249
+ f
1250
+ (2 rows)
1251
+
1252
+ select * from iboolpart where a = false;
1253
+ a
1254
+ ---
1255
+ f
1256
+ (1 row)
1257
+
1258
+ select * from iboolpart where not a = false;
1259
+ a
1260
+ ---
1261
+ t
1262
+ (1 row)
1263
+
1264
+ select * from iboolpart where a is true or a is not true;
1265
+ a
1266
+ ---
1267
+ t
1268
+ f
1269
+
1270
+ (3 rows)
1271
+
1272
+ select * from iboolpart where a is not true;
1273
+ a
1274
+ ---
1275
+ f
1276
+
1277
+ (2 rows)
1278
+
1279
+ select * from iboolpart where a is not true and a is not false;
1280
+ a
1281
+ ---
1282
+
1283
+ (1 row)
1284
+
1285
+ select * from iboolpart where a is unknown;
1286
+ a
1287
+ ---
1288
+
1289
+ (1 row)
1290
+
1291
+ select * from iboolpart where a is not unknown;
1292
+ a
1293
+ ---
1294
+ t
1295
+ f
1296
+ (2 rows)
1297
+
1093
1298
create table boolrangep (a bool, b bool, c int) partition by range (a,b,c);
1094
1299
create table boolrangep_tf partition of boolrangep for values from ('true', 'false', 0) to ('true', 'false', 100);
1095
1300
create table boolrangep_ft partition of boolrangep for values from ('false', 'true', 0) to ('false', 'true', 100);
@@ -1489,7 +1694,7 @@ explain (costs off) select * from rparted_by_int2 where a > 100000000000000;
1489
1694
Filter: (a > '100000000000000'::bigint)
1490
1695
(2 rows)
1491
1696
1492
- drop table lp, coll_pruning, rlp, mc3p, mc2p, boolpart, boolrangep, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2;
1697
+ drop table lp, coll_pruning, rlp, mc3p, mc2p, boolpart, iboolpart, boolrangep, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2;
1493
1698
--
1494
1699
-- Test Partition pruning for HASH partitioning
1495
1700
--
0 commit comments