forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit569ed7f
committed
Redesign the API for list sorting (list_qsort becomes list_sort).
In the wake of commit1cff1b9, the obvious way to sort a Listis to apply qsort() directly to the array of ListCells. list_qsortwas building an intermediate array of pointers-to-ListCells, whichwe no longer need, but getting rid of it forces an API change:the comparator functions need to do one less level of indirection.Since we're having to touch the callers anyway, let's do two additionalchanges: sort the given list in-place rather than making a copy (asnone of the existing callers have any use for the copying behavior),and rename list_qsort to list_sort. It was argued that the old nameexposes more about the implementation than it should, which I findpretty questionable, but a better reason to rename it is to be surewe get the attention of any external callers about the need to fixtheir comparator functions.While we're at it, change four existing callers of qsort() to uselist_sort instead; previously, they all had local reinventionsof list_qsort, ie build-an-array-from-a-List-and-qsort-it.(There are some other places where changing to list_sort perhapswould be worthwhile, but they're less obviously wins.)Discussion:https://postgr.es/m/29361.1563220190@sss.pgh.pa.us1 parent0896ae5 commit569ed7f
File tree
7 files changed
+82
-157
lines changed- src
- backend
- nodes
- optimizer/util
- parser
- replication
- logical
- rewrite
- include/nodes
7 files changed
+82
-157
lines changedLines changed: 18 additions & 35 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1419 | 1419 |
| |
1420 | 1420 |
| |
1421 | 1421 |
| |
1422 |
| - | |
| 1422 | + | |
1423 | 1423 |
| |
1424 |
| - | |
1425 |
| - | |
| 1424 | + | |
1426 | 1425 |
| |
1427 |
| - | |
1428 |
| - | |
1429 |
| - | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
1430 | 1433 |
| |
1431 |
| - | |
1432 |
| - | |
| 1434 | + | |
| 1435 | + | |
1433 | 1436 |
| |
1434 |
| - | |
1435 |
| - | |
1436 |
| - | |
1437 |
| - | |
1438 |
| - | |
1439 |
| - | |
1440 |
| - | |
1441 |
| - | |
1442 |
| - | |
| 1437 | + | |
| 1438 | + | |
1443 | 1439 |
| |
1444 |
| - | |
1445 |
| - | |
1446 |
| - | |
1447 |
| - | |
1448 |
| - | |
1449 |
| - | |
1450 |
| - | |
1451 |
| - | |
1452 |
| - | |
1453 |
| - | |
1454 |
| - | |
1455 |
| - | |
1456 |
| - | |
1457 |
| - | |
1458 |
| - | |
1459 |
| - | |
| 1440 | + | |
1460 | 1441 |
| |
1461 |
| - | |
1462 |
| - | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
1463 | 1446 |
|
Lines changed: 16 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
52 | 52 |
| |
53 | 53 |
| |
54 | 54 |
| |
55 |
| - | |
56 |
| - | |
| 55 | + | |
| 56 | + | |
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
| |||
1239 | 1239 |
| |
1240 | 1240 |
| |
1241 | 1241 |
| |
1242 |
| - | |
1243 |
| - | |
1244 |
| - | |
| 1242 | + | |
| 1243 | + | |
1245 | 1244 |
| |
1246 | 1245 |
| |
1247 | 1246 |
| |
| |||
1296 | 1295 |
| |
1297 | 1296 |
| |
1298 | 1297 |
| |
1299 |
| - | |
| 1298 | + | |
| 1299 | + | |
1300 | 1300 |
| |
1301 | 1301 |
| |
1302 | 1302 |
| |
1303 |
| - | |
| 1303 | + | |
1304 | 1304 |
| |
1305 | 1305 |
| |
1306 |
| - | |
| 1306 | + | |
1307 | 1307 |
| |
1308 |
| - | |
1309 |
| - | |
| 1308 | + | |
| 1309 | + | |
1310 | 1310 |
| |
1311 | 1311 |
| |
1312 | 1312 |
| |
| |||
1317 | 1317 |
| |
1318 | 1318 |
| |
1319 | 1319 |
| |
1320 |
| - | |
| 1320 | + | |
| 1321 | + | |
1321 | 1322 |
| |
1322 | 1323 |
| |
1323 | 1324 |
| |
1324 |
| - | |
| 1325 | + | |
1325 | 1326 |
| |
1326 | 1327 |
| |
1327 |
| - | |
| 1328 | + | |
1328 | 1329 |
| |
1329 |
| - | |
1330 |
| - | |
| 1330 | + | |
| 1331 | + | |
1331 | 1332 |
| |
1332 | 1333 |
| |
1333 | 1334 |
| |
|
Lines changed: 6 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1722 | 1722 |
| |
1723 | 1723 |
| |
1724 | 1724 |
| |
| 1725 | + | |
1725 | 1726 |
| |
1726 |
| - | |
| 1727 | + | |
1727 | 1728 |
| |
1728 |
| - | |
1729 |
| - | |
| 1729 | + | |
| 1730 | + | |
1730 | 1731 |
| |
1731 | 1732 |
| |
1732 | 1733 |
| |
| |||
1797 | 1798 |
| |
1798 | 1799 |
| |
1799 | 1800 |
| |
1800 |
| - | |
1801 |
| - | |
1802 |
| - | |
1803 |
| - | |
1804 |
| - | |
1805 |
| - | |
1806 |
| - | |
1807 |
| - | |
1808 |
| - | |
1809 |
| - | |
1810 |
| - | |
1811 |
| - | |
1812 |
| - | |
1813 |
| - | |
1814 |
| - | |
1815 |
| - | |
1816 |
| - | |
1817 |
| - | |
1818 |
| - | |
1819 |
| - | |
1820 |
| - | |
| 1801 | + | |
| 1802 | + | |
1821 | 1803 |
| |
1822 | 1804 |
| |
1823 | 1805 |
| |
|
Lines changed: 22 additions & 29 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
73 |
| - | |
| 73 | + | |
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
| |||
379 | 379 |
| |
380 | 380 |
| |
381 | 381 |
| |
382 |
| - | |
383 |
| - | |
384 | 382 |
| |
385 | 383 |
| |
386 | 384 |
| |
387 | 385 |
| |
388 |
| - | |
389 | 386 |
| |
390 | 387 |
| |
391 | 388 |
| |
| |||
428 | 425 |
| |
429 | 426 |
| |
430 | 427 |
| |
431 |
| - | |
432 |
| - | |
433 |
| - | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
434 | 431 |
| |
435 |
| - | |
436 |
| - | |
437 |
| - | |
438 |
| - | |
439 |
| - | |
440 |
| - | |
441 |
| - | |
442 |
| - | |
| 432 | + | |
443 | 433 |
| |
444 | 434 |
| |
445 | 435 |
| |
446 | 436 |
| |
447 | 437 |
| |
448 |
| - | |
| 438 | + | |
449 | 439 |
| |
450 | 440 |
| |
451 | 441 |
| |
452 | 442 |
| |
453 | 443 |
| |
454 | 444 |
| |
455 | 445 |
| |
456 |
| - | |
| 446 | + | |
| 447 | + | |
457 | 448 |
| |
458 | 449 |
| |
459 | 450 |
| |
| |||
463 | 454 |
| |
464 | 455 |
| |
465 | 456 |
| |
466 |
| - | |
| 457 | + | |
467 | 458 |
| |
| 459 | + | |
468 | 460 |
| |
469 | 461 |
| |
470 | 462 |
| |
471 |
| - | |
| 463 | + | |
472 | 464 |
| |
473 | 465 |
| |
474 | 466 |
| |
| |||
489 | 481 |
| |
490 | 482 |
| |
491 | 483 |
| |
492 |
| - | |
| 484 | + | |
493 | 485 |
| |
| 486 | + | |
494 | 487 |
| |
495 | 488 |
| |
496 | 489 |
| |
497 | 490 |
| |
498 | 491 |
| |
499 |
| - | |
500 |
| - | |
| 492 | + | |
| 493 | + | |
501 | 494 |
| |
502 | 495 |
| |
503 | 496 |
| |
| |||
527 | 520 |
| |
528 | 521 |
| |
529 | 522 |
| |
530 |
| - | |
| 523 | + | |
531 | 524 |
| |
532 | 525 |
| |
533 | 526 |
| |
| |||
555 | 548 |
| |
556 | 549 |
| |
557 | 550 |
| |
558 |
| - | |
| 551 | + | |
559 | 552 |
| |
560 | 553 |
| |
561 | 554 |
| |
| |||
568 | 561 |
| |
569 | 562 |
| |
570 | 563 |
| |
571 |
| - | |
| 564 | + | |
572 | 565 |
| |
573 | 566 |
| |
574 | 567 |
| |
| |||
618 | 611 |
| |
619 | 612 |
| |
620 | 613 |
| |
621 |
| - | |
| 614 | + | |
622 | 615 |
| |
623 | 616 |
| |
624 | 617 |
| |
625 |
| - | |
| 618 | + | |
626 | 619 |
| |
627 |
| - | |
628 |
| - | |
| 620 | + | |
| 621 | + | |
629 | 622 |
| |
630 | 623 |
| |
631 | 624 |
| |
|
Lines changed: 8 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3236 | 3236 |
| |
3237 | 3237 |
| |
3238 | 3238 |
| |
3239 |
| - | |
| 3239 | + | |
3240 | 3240 |
| |
3241 | 3241 |
| |
3242 | 3242 |
| |
| |||
3378 | 3378 |
| |
3379 | 3379 |
| |
3380 | 3380 |
| |
3381 |
| - | |
| 3381 | + | |
3382 | 3382 |
| |
3383 | 3383 |
| |
3384 |
| - | |
| 3384 | + | |
3385 | 3385 |
| |
3386 |
| - | |
3387 |
| - | |
| 3386 | + | |
| 3387 | + | |
3388 | 3388 |
| |
3389 | 3389 |
| |
3390 | 3390 |
| |
| |||
3404 | 3404 |
| |
3405 | 3405 |
| |
3406 | 3406 |
| |
3407 |
| - | |
3408 |
| - | |
3409 | 3407 |
| |
3410 | 3408 |
| |
3411 | 3409 |
| |
| |||
3459 | 3457 |
| |
3460 | 3458 |
| |
3461 | 3459 |
| |
3462 |
| - | |
3463 |
| - | |
3464 |
| - | |
3465 |
| - | |
3466 |
| - | |
3467 |
| - | |
3468 |
| - | |
3469 |
| - | |
3470 | 3460 |
| |
3471 |
| - | |
3472 |
| - | |
| 3461 | + | |
3473 | 3462 |
| |
3474 |
| - | |
| 3463 | + | |
3475 | 3464 |
| |
3476 |
| - | |
| 3465 | + | |
3477 | 3466 |
| |
3478 | 3467 |
| |
3479 | 3468 |
| |
|
0 commit comments
Comments
(0)