forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4de2d4f
committed
Explicitly track whether aggregate final functions modify transition state.
Up to now, there's been hard-wired assumptions that normal aggregates'final functions never modify their transition states, while ordered-setaggregates' final functions always do. This has always been a bitlimiting, and in particular it's getting in the way of improving thebuilt-in ordered-set aggregates to allow merging of transition states.Therefore, let's introduce catalog and CREATE AGGREGATE infrastructurethat lets the finalfn's behavior be declared explicitly.There are now three possibilities for the finalfn behavior: it's purelyread-only, it trashes the transition state irrecoverably, or it changesthe state in such a way that no more transfn calls are possible but thestate can still be passed to other, compatible finalfns. There are noexamples of this third case today, but we'll shortly make the built-inOSAs act like that.This change allows user-defined aggregates to explicitly disclaim supportfor use as window functions, and/or to prevent transition state merging,if their implementations cannot handle that. While it was previouslypossible to handle the window case with a run-time error check, there wasnot any way to prevent transition state merging, which in retrospect issomething commit804163b should have provided for. But better latethan never.In passing, split out pg_aggregate.c's extern function declarations intoa new header file pg_aggregate_fn.h, similarly to what we've done forsome other catalog headers, so that pg_aggregate.h itself can be safefor frontend files to include. This lets pg_dump use the symbolicnames for relevant constants.Discussion:https://postgr.es/m/4834.1507849699@sss.pgh.pa.us1 parent5f340cb commit4de2d4f
File tree
16 files changed
+555
-251
lines changed- doc/src/sgml
- ref
- src
- backend
- catalog
- commands
- executor
- bin/pg_dump
- t
- include/catalog
- test/regress
- expected
- sql
16 files changed
+555
-251
lines changedLines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
486 | 486 |
| |
487 | 487 |
| |
488 | 488 |
| |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
489 | 509 |
| |
490 | 510 |
| |
491 | 511 |
| |
|
Lines changed: 66 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
| 30 | + | |
30 | 31 |
| |
31 | 32 |
| |
32 | 33 |
| |
| |||
37 | 38 |
| |
38 | 39 |
| |
39 | 40 |
| |
| 41 | + | |
40 | 42 |
| |
41 | 43 |
| |
42 | 44 |
| |
| |||
49 | 51 |
| |
50 | 52 |
| |
51 | 53 |
| |
| 54 | + | |
52 | 55 |
| |
53 | 56 |
| |
54 | 57 |
| |
| |||
63 | 66 |
| |
64 | 67 |
| |
65 | 68 |
| |
| 69 | + | |
66 | 70 |
| |
67 | 71 |
| |
68 | 72 |
| |
| |||
73 | 77 |
| |
74 | 78 |
| |
75 | 79 |
| |
| 80 | + | |
76 | 81 |
| |
77 | 82 |
| |
78 | 83 |
| |
| |||
197 | 202 |
| |
198 | 203 |
| |
199 | 204 |
| |
200 |
| - | |
| 205 | + | |
| 206 | + | |
201 | 207 |
| |
202 | 208 |
| |
203 | 209 |
| |
| |||
412 | 418 |
| |
413 | 419 |
| |
414 | 420 |
| |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
415 | 436 |
| |
416 | 437 |
| |
417 | 438 |
| |
| |||
563 | 584 |
| |
564 | 585 |
| |
565 | 586 |
| |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
566 | 597 |
| |
567 | 598 |
| |
568 | 599 |
| |
| |||
587 | 618 |
| |
588 | 619 |
| |
589 | 620 |
| |
590 |
| - | |
| 621 | + | |
591 | 622 |
| |
592 | 623 |
| |
593 | 624 |
| |
594 | 625 |
| |
595 |
| - | |
| 626 | + | |
596 | 627 |
| |
597 | 628 |
| |
598 | 629 |
| |
| |||
624 | 655 |
| |
625 | 656 |
| |
626 | 657 |
| |
627 |
| - | |
628 |
| - | |
| 658 | + | |
| 659 | + | |
629 | 660 |
| |
630 | 661 |
| |
631 | 662 |
| |
| |||
634 | 665 |
| |
635 | 666 |
| |
636 | 667 |
| |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
637 | 696 |
| |
638 | 697 |
| |
639 | 698 |
| |
| |||
671 | 730 |
| |
672 | 731 |
| |
673 | 732 |
| |
674 |
| - | |
| 733 | + | |
| 734 | + | |
675 | 735 |
| |
676 | 736 |
| |
677 | 737 |
| |
|
Lines changed: 13 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
487 | 487 |
| |
488 | 488 |
| |
489 | 489 |
| |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
490 | 497 |
| |
491 | 498 |
| |
492 | 499 |
| |
| |||
622 | 629 |
| |
623 | 630 |
| |
624 | 631 |
| |
625 |
| - | |
626 |
| - | |
| 632 | + | |
627 | 633 |
| |
628 | 634 |
| |
629 | 635 |
| |
630 |
| - | |
631 |
| - | |
632 |
| - | |
633 |
| - | |
634 |
| - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
635 | 641 |
| |
636 | 642 |
| |
637 | 643 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
| 22 | + | |
22 | 23 |
| |
23 | 24 |
| |
24 | 25 |
| |
| |||
65 | 66 |
| |
66 | 67 |
| |
67 | 68 |
| |
| 69 | + | |
| 70 | + | |
68 | 71 |
| |
69 | 72 |
| |
70 | 73 |
| |
| |||
656 | 659 |
| |
657 | 660 |
| |
658 | 661 |
| |
| 662 | + | |
| 663 | + | |
659 | 664 |
| |
660 | 665 |
| |
661 | 666 |
| |
|
Lines changed: 42 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
| 29 | + | |
29 | 30 |
| |
30 | 31 |
| |
31 | 32 |
| |
| |||
39 | 40 |
| |
40 | 41 |
| |
41 | 42 |
| |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 |
| |
43 | 47 |
| |
44 | 48 |
| |
| |||
67 | 71 |
| |
68 | 72 |
| |
69 | 73 |
| |
| 74 | + | |
| 75 | + | |
70 | 76 |
| |
71 | 77 |
| |
72 | 78 |
| |
| |||
143 | 149 |
| |
144 | 150 |
| |
145 | 151 |
| |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
146 | 156 |
| |
147 | 157 |
| |
148 | 158 |
| |
| |||
235 | 245 |
| |
236 | 246 |
| |
237 | 247 |
| |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
238 | 257 |
| |
239 | 258 |
| |
240 | 259 |
| |
| |||
437 | 456 |
| |
438 | 457 |
| |
439 | 458 |
| |
| 459 | + | |
| 460 | + | |
440 | 461 |
| |
441 | 462 |
| |
442 | 463 |
| |
| |||
446 | 467 |
| |
447 | 468 |
| |
448 | 469 |
| |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + |
0 commit comments
Comments
(0)