forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcebe10a

Etsuro Fujita
Fix some issues with step generation in partition pruning.
In the case of range partitioning, get_steps_using_prefix() assumes thatthe passed-in prefix list contains at least one clause for each of thepartition keys earlier than one specified in the passed-instep_lastkeyno, but the caller (ie, gen_prune_steps_from_opexps())didn't take it into account, which led to a server crash or incorrectresults when the list contained no clauses for such partition keys, asreported in bug #16500 and #16501 from Kobayashi Hisanori. Update thecaller to call that function only when the list created there containsat least one clause for each of the earlier partition keys in the caseof range partitioning.While at it, fix some other issues:* The list to pass to get_steps_using_prefix() is allowed to contain multiple clauses for the same partition key, as described in the comment for that function, but that function actually assumed that the list contained just a single clause for each of middle partition keys, which led to an assertion failure when the list contained multiple clauses for such partition keys. Update that function to match the comment.* In the case of hash partitioning, partition keys are allowed to be NULL, in which case the list to pass to get_steps_using_prefix() contains no clauses for NULL partition keys, but that function treats that case as like the case of range partitioning, which led to the assertion failure. Update the assertion test to take into account NULL partition keys in the case of hash partitioning.* Fix a typo in a comment in get_steps_using_prefix_recurse().* gen_partprune_steps() failed to detect self-contradiction from strict-qual clauses and an IS NULL clause for the same partition key in some cases, producing incorrect partition-pruning steps, which led to incorrect results of partition pruning, but didn't cause any user-visible problems fortunately, as the self-contradiction is detected later in the query planning. Update that function to detect the self-contradiction.Per bug #16500 and #16501 from Kobayashi Hisanori. Patch by me, initialdiagnosis for the reported issue and review by Dmitry Dolgov.Back-patch to v11, where partition pruning was introduced.Discussion:https://postgr.es/m/16500-d1613f2a78e1e090%40postgresql.orgDiscussion:https://postgr.es/m/16501-5234a9a0394f6754%40postgresql.org1 parent5a6cc6f commitcebe10a
File tree
3 files changed
+294
-56
lines changed- src
- backend/partitioning
- test/regress
- expected
- sql
3 files changed
+294
-56
lines changedLines changed: 131 additions & 56 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1058 | 1058 |
| |
1059 | 1059 |
| |
1060 | 1060 |
| |
1061 |
| - | |
1062 |
| - | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1063 | 1067 |
| |
1064 | 1068 |
| |
1065 | 1069 |
| |
| |||
1308 | 1312 |
| |
1309 | 1313 |
| |
1310 | 1314 |
| |
1311 |
| - | |
1312 |
| - | |
1313 |
| - | |
1314 |
| - | |
1315 |
| - | |
1316 |
| - | |
1317 |
| - | |
1318 |
| - | |
1319 |
| - | |
1320 |
| - | |
1321 |
| - | |
1322 |
| - | |
1323 |
| - | |
1324 |
| - | |
1325 |
| - | |
1326 |
| - | |
1327 |
| - | |
| 1315 | + | |
| 1316 | + | |
1328 | 1317 |
| |
1329 |
| - | |
1330 |
| - | |
1331 |
| - | |
1332 |
| - | |
1333 |
| - | |
1334 |
| - | |
1335 |
| - | |
1336 |
| - | |
1337 |
| - | |
1338 |
| - | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
1339 | 1327 |
| |
1340 | 1328 |
| |
1341 | 1329 |
| |
| |||
1374 | 1362 |
| |
1375 | 1363 |
| |
1376 | 1364 |
| |
| 1365 | + | |
1377 | 1366 |
| |
1378 | 1367 |
| |
1379 | 1368 |
| |
| |||
1396 | 1385 |
| |
1397 | 1386 |
| |
1398 | 1387 |
| |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
1399 | 1417 |
| |
1400 | 1418 |
| |
1401 | 1419 |
| |
| |||
1408 | 1426 |
| |
1409 | 1427 |
| |
1410 | 1428 |
| |
| 1429 | + | |
1411 | 1430 |
| |
| 1431 | + | |
| 1432 | + | |
1412 | 1433 |
| |
1413 | 1434 |
| |
1414 | 1435 |
| |
| |||
1426 | 1447 |
| |
1427 | 1448 |
| |
1428 | 1449 |
| |
| 1450 | + | |
1429 | 1451 |
| |
| 1452 | + | |
| 1453 | + | |
1430 | 1454 |
| |
1431 | 1455 |
| |
1432 | 1456 |
| |
| |||
1445 | 1469 |
| |
1446 | 1470 |
| |
1447 | 1471 |
| |
| 1472 | + | |
1448 | 1473 |
| |
| 1474 | + | |
| 1475 | + | |
1449 | 1476 |
| |
1450 | 1477 |
| |
1451 | 1478 |
| |
1452 | 1479 |
| |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
1453 | 1499 |
| |
1454 | 1500 |
| |
1455 | 1501 |
| |
| |||
1459 | 1505 |
| |
1460 | 1506 |
| |
1461 | 1507 |
| |
1462 |
| - | |
1463 |
| - | |
1464 |
| - | |
1465 |
| - | |
1466 |
| - | |
1467 |
| - | |
1468 |
| - | |
1469 |
| - | |
1470 |
| - | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
1471 | 1522 |
| |
1472 | 1523 |
| |
1473 | 1524 |
| |
| |||
2182 | 2233 |
| |
2183 | 2234 |
| |
2184 | 2235 |
| |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
2185 | 2244 |
| |
2186 | 2245 |
| |
2187 | 2246 |
| |
| |||
2193 | 2252 |
| |
2194 | 2253 |
| |
2195 | 2254 |
| |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
2196 | 2258 |
| |
2197 | 2259 |
| |
2198 | 2260 |
| |
| |||
2261 | 2323 |
| |
2262 | 2324 |
| |
2263 | 2325 |
| |
2264 |
| - | |
| 2326 | + | |
2265 | 2327 |
| |
2266 | 2328 |
| |
2267 | 2329 |
| |
| |||
2278 | 2340 |
| |
2279 | 2341 |
| |
2280 | 2342 |
| |
| 2343 | + | |
| 2344 | + | |
2281 | 2345 |
| |
2282 | 2346 |
| |
2283 | 2347 |
| |
2284 | 2348 |
| |
2285 |
| - | |
2286 |
| - | |
2287 |
| - | |
2288 |
| - | |
2289 |
| - | |
2290 |
| - | |
2291 |
| - | |
2292 |
| - | |
2293 |
| - | |
2294 |
| - | |
2295 |
| - | |
2296 |
| - | |
2297 |
| - | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
2298 | 2356 |
| |
2299 | 2357 |
| |
2300 | 2358 |
| |
| |||
2311 | 2369 |
| |
2312 | 2370 |
| |
2313 | 2371 |
| |
2314 |
| - | |
2315 |
| - | |
| 2372 | + | |
| 2373 | + | |
2316 | 2374 |
| |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
2317 | 2378 |
| |
2318 | 2379 |
| |
2319 | 2380 |
| |
2320 | 2381 |
| |
2321 | 2382 |
| |
2322 | 2383 |
| |
2323 | 2384 |
| |
2324 |
| - | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
2325 | 2397 |
| |
2326 |
| - | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
2327 | 2402 |
| |
2328 | 2403 |
| |
2329 | 2404 |
| |
|
Lines changed: 92 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3671 | 3671 |
| |
3672 | 3672 |
| |
3673 | 3673 |
| |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
| 3765 | + |
0 commit comments
Comments
(0)