Commit 18b3493
committed
Fix text substring search for non-deterministic collations.
Due to an off-by-one error, the code failed to find matches at the
end of the haystack. Fix by rewriting the loop.
While at it, fix a comment that claimed that the function could find
a zero-length match. Such a match could send a caller into an endless
loop. However, zero-length matches only make sense with an empty
search string, and that case is explicitly excluded by all callers.
To make sure it stays that way, add an Assert and a comment.
Bug: #19341
Reported-by: Adam Warland <adam.warland@infor.com>
Author: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19341-1d9a22915edfec58@postgresql.org
Backpatch-through: 181 parent 02ba5e3 commit 18b3493
File tree
3 files changed
+28
-7
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+28
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1424 | 1424 | | |
1425 | 1425 | | |
1426 | 1426 | | |
| 1427 | + | |
1427 | 1428 | | |
1428 | 1429 | | |
1429 | 1430 | | |
| |||
1436 | 1437 | | |
1437 | 1438 | | |
1438 | 1439 | | |
1439 | | - | |
1440 | | - | |
1441 | | - | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
1442 | 1443 | | |
1443 | 1444 | | |
1444 | 1445 | | |
1445 | 1446 | | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
1446 | 1452 | | |
1447 | 1453 | | |
1448 | 1454 | | |
1449 | 1455 | | |
1450 | 1456 | | |
1451 | 1457 | | |
| 1458 | + | |
| 1459 | + | |
1452 | 1460 | | |
1453 | 1461 | | |
1454 | 1462 | | |
| |||
1459 | 1467 | | |
1460 | 1468 | | |
1461 | 1469 | | |
1462 | | - | |
1463 | | - | |
| 1470 | + | |
| 1471 | + | |
1464 | 1472 | | |
1465 | | - | |
| 1473 | + | |
| 1474 | + | |
1466 | 1475 | | |
| 1476 | + | |
1467 | 1477 | | |
1468 | 1478 | | |
1469 | 1479 | | |
1470 | 1480 | | |
1471 | 1481 | | |
1472 | 1482 | | |
1473 | 1483 | | |
1474 | | - | |
| 1484 | + | |
| 1485 | + | |
1475 | 1486 | | |
1476 | 1487 | | |
1477 | 1488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1484 | 1484 | | |
1485 | 1485 | | |
1486 | 1486 | | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
1487 | 1494 | | |
1488 | 1495 | | |
1489 | 1496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
571 | 574 | | |
572 | 575 | | |
573 | 576 | | |
| |||
0 commit comments