forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9511304
committed
Rearrange the querytree representation of ORDER BY/GROUP BY/DISTINCT items
as per my recent proposal:1. Fold SortClause and GroupClause into a single node type SortGroupClause.We were already relying on them to be struct-equivalent, so using two nodetags wasn't accomplishing much except to get in the way of comparing itemswith equal().2. Add an "eqop" field to SortGroupClause to carry the associated equalityoperator. This is cheap for the parser to get at the same time it's lookingup the sort operator, and storing it eliminates the need for repeatednot-so-cheap lookups during planning. In future this will also let usrepresent GROUP/DISTINCT operations on datatypes that have hash opclassesbut no btree opclasses (ie, they have equality but no natural sort order).The previous representation simply didn't work for that, since its onlyindicator of comparison semantics was a sort operator.3. Add a hasDistinctOn boolean to struct Query to explicitly record whetherthe distinctClause came from DISTINCT or DISTINCT ON. This allows removingsome complicated and not 100% bulletproof code that attempted to figurethat out from the distinctClause alone.This patch doesn't in itself create any new capability, but it's necessaryinfrastructure for future attempts to use hash-based grouping for DISTINCTand UNION/INTERSECT/EXCEPT.1 parent49f001d commit9511304
File tree
33 files changed
+747
-840
lines changed- src
- backend
- catalog
- commands
- executor
- nodes
- optimizer
- path
- plan
- prep
- util
- parser
- utils
- adt
- cache
- include
- catalog
- nodes
- optimizer
- parser
- utils
33 files changed
+747
-840
lines changedLines changed: 34 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
1335 | 1335 |
| |
1336 | 1336 |
| |
1337 | 1337 |
| |
1338 |
| - | |
| 1338 | + | |
1339 | 1339 |
| |
1340 | 1340 |
| |
1341 | 1341 |
| |
| |||
1408 | 1408 |
| |
1409 | 1409 |
| |
1410 | 1410 |
| |
1411 |
| - | |
| 1411 | + | |
1412 | 1412 |
| |
1413 | 1413 |
| |
1414 | 1414 |
| |
1415 | 1415 |
| |
1416 | 1416 |
| |
1417 | 1417 |
| |
1418 | 1418 |
| |
1419 |
| - | |
| 1419 | + | |
1420 | 1420 |
| |
1421 | 1421 |
| |
1422 | 1422 |
| |
1423 | 1423 |
| |
1424 | 1424 |
| |
1425 | 1425 |
| |
1426 | 1426 |
| |
1427 |
| - | |
| 1427 | + | |
1428 | 1428 |
| |
1429 | 1429 |
| |
1430 | 1430 |
| |
1431 | 1431 |
| |
1432 | 1432 |
| |
1433 | 1433 |
| |
1434 | 1434 |
| |
1435 |
| - | |
| 1435 | + | |
1436 | 1436 |
| |
1437 | 1437 |
| |
1438 | 1438 |
| |
1439 | 1439 |
| |
1440 | 1440 |
| |
1441 | 1441 |
| |
1442 | 1442 |
| |
1443 |
| - | |
| 1443 | + | |
1444 | 1444 |
| |
1445 | 1445 |
| |
1446 | 1446 |
| |
1447 | 1447 |
| |
1448 | 1448 |
| |
1449 | 1449 |
| |
1450 | 1450 |
| |
1451 |
| - | |
| 1451 | + | |
1452 | 1452 |
| |
1453 | 1453 |
| |
1454 | 1454 |
| |
1455 | 1455 |
| |
1456 | 1456 |
| |
1457 | 1457 |
| |
1458 | 1458 |
| |
1459 |
| - | |
| 1459 | + | |
1460 | 1460 |
| |
1461 | 1461 |
| |
1462 | 1462 |
| |
1463 | 1463 |
| |
1464 | 1464 |
| |
1465 | 1465 |
| |
1466 | 1466 |
| |
1467 |
| - | |
| 1467 | + | |
1468 | 1468 |
| |
1469 | 1469 |
| |
1470 | 1470 |
| |
1471 | 1471 |
| |
1472 |
| - | |
| 1472 | + | |
1473 | 1473 |
| |
1474 | 1474 |
| |
1475 | 1475 |
| |
1476 | 1476 |
| |
1477 | 1477 |
| |
1478 | 1478 |
| |
1479 | 1479 |
| |
1480 |
| - | |
| 1480 | + | |
1481 | 1481 |
| |
1482 | 1482 |
| |
1483 | 1483 |
| |
1484 | 1484 |
| |
1485 | 1485 |
| |
1486 | 1486 |
| |
1487 | 1487 |
| |
1488 |
| - | |
| 1488 | + | |
1489 | 1489 |
| |
1490 | 1490 |
| |
1491 | 1491 |
| |
| |||
1496 | 1496 |
| |
1497 | 1497 |
| |
1498 | 1498 |
| |
1499 |
| - | |
| 1499 | + | |
1500 | 1500 |
| |
1501 | 1501 |
| |
1502 | 1502 |
| |
1503 | 1503 |
| |
1504 | 1504 |
| |
1505 | 1505 |
| |
1506 | 1506 |
| |
1507 |
| - | |
| 1507 | + | |
1508 | 1508 |
| |
1509 | 1509 |
| |
1510 | 1510 |
| |
1511 | 1511 |
| |
1512 | 1512 |
| |
1513 | 1513 |
| |
1514 |
| - | |
| 1514 | + | |
1515 | 1515 |
| |
1516 | 1516 |
| |
1517 | 1517 |
| |
| |||
1528 | 1528 |
| |
1529 | 1529 |
| |
1530 | 1530 |
| |
1531 |
| - | |
| 1531 | + | |
1532 | 1532 |
| |
1533 | 1533 |
| |
1534 | 1534 |
| |
1535 | 1535 |
| |
1536 | 1536 |
| |
1537 | 1537 |
| |
1538 |
| - | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
1539 | 1550 |
| |
1540 | 1551 |
| |
1541 | 1552 |
| |
| |||
1572 | 1583 |
| |
1573 | 1584 |
| |
1574 | 1585 |
| |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
1575 | 1591 |
| |
1576 | 1592 |
| |
1577 | 1593 |
| |
|
Lines changed: 10 additions & 22 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
1490 | 1490 |
| |
1491 | 1491 |
| |
1492 | 1492 |
| |
1493 |
| - | |
1494 |
| - | |
1495 |
| - | |
1496 |
| - | |
| 1493 | + | |
| 1494 | + | |
1497 | 1495 |
| |
1498 | 1496 |
| |
1499 | 1497 |
| |
1500 | 1498 |
| |
1501 | 1499 |
| |
1502 | 1500 |
| |
1503 | 1501 |
| |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
1504 | 1507 |
| |
1505 |
| - | |
1506 |
| - | |
1507 |
| - | |
1508 |
| - | |
1509 |
| - | |
1510 |
| - | |
1511 |
| - | |
1512 |
| - | |
| 1508 | + | |
1513 | 1509 |
| |
1514 | 1510 |
| |
1515 |
| - | |
1516 |
| - | |
1517 |
| - | |
1518 |
| - | |
1519 |
| - | |
1520 |
| - | |
1521 |
| - | |
1522 |
| - | |
1523 | 1511 |
| |
1524 | 1512 |
| |
1525 | 1513 |
| |
1526 |
| - | |
| 1514 | + | |
1527 | 1515 |
| |
1528 | 1516 |
| |
1529 | 1517 |
| |
|
Lines changed: 8 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
61 | 61 |
| |
62 | 62 |
| |
63 | 63 |
| |
64 |
| - | |
| 64 | + | |
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
| |||
1496 | 1496 |
| |
1497 | 1497 |
| |
1498 | 1498 |
| |
1499 |
| - | |
| 1499 | + | |
| 1500 | + | |
1500 | 1501 |
| |
1501 | 1502 |
| |
1502 | 1503 |
| |
| |||
1524 | 1525 |
| |
1525 | 1526 |
| |
1526 | 1527 |
| |
1527 |
| - | |
1528 |
| - | |
1529 |
| - | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
1530 | 1533 |
| |
1531 | 1534 |
| |
1532 | 1535 |
| |
|
Lines changed: 8 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 |
| - | |
| 18 | + | |
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
| |||
1542 | 1542 |
| |
1543 | 1543 |
| |
1544 | 1544 |
| |
1545 |
| - | |
1546 |
| - | |
| 1545 | + | |
| 1546 | + | |
1547 | 1547 |
| |
1548 |
| - | |
1549 |
| - | |
1550 |
| - | |
1551 |
| - | |
1552 |
| - | |
1553 |
| - | |
1554 |
| - | |
1555 |
| - | |
1556 |
| - | |
1557 |
| - | |
1558 |
| - | |
1559 |
| - | |
1560 |
| - | |
| 1548 | + | |
1561 | 1549 |
| |
1562 | 1550 |
| |
| 1551 | + | |
1563 | 1552 |
| |
1564 | 1553 |
| |
1565 | 1554 |
| |
| |||
1861 | 1850 |
| |
1862 | 1851 |
| |
1863 | 1852 |
| |
| 1853 | + | |
1864 | 1854 |
| |
1865 | 1855 |
| |
1866 | 1856 |
| |
| |||
3586 | 3576 |
| |
3587 | 3577 |
| |
3588 | 3578 |
| |
3589 |
| - | |
3590 |
| - | |
3591 |
| - | |
3592 |
| - | |
3593 |
| - | |
| 3579 | + | |
| 3580 | + | |
3594 | 3581 |
| |
3595 | 3582 |
| |
3596 | 3583 |
| |
|
Lines changed: 6 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
21 |
| - | |
| 21 | + | |
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
| |||
756 | 756 |
| |
757 | 757 |
| |
758 | 758 |
| |
| 759 | + | |
759 | 760 |
| |
760 | 761 |
| |
761 | 762 |
| |
| |||
1885 | 1886 |
| |
1886 | 1887 |
| |
1887 | 1888 |
| |
1888 |
| - | |
| 1889 | + | |
1889 | 1890 |
| |
1890 | 1891 |
| |
| 1892 | + | |
1891 | 1893 |
| |
1892 | 1894 |
| |
1893 | 1895 |
| |
| |||
2515 | 2517 |
| |
2516 | 2518 |
| |
2517 | 2519 |
| |
2518 |
| - | |
2519 |
| - | |
2520 |
| - | |
2521 |
| - | |
2522 |
| - | |
2523 |
| - | |
| 2520 | + | |
| 2521 | + | |
2524 | 2522 |
| |
2525 | 2523 |
| |
2526 | 2524 |
| |
|
0 commit comments
Comments
(0)