forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9218689
committed
Attached are two patches to implement and document anonymous composite
types for Table Functions, as previously proposed on HACKERS. Here is abrief explanation:1. Creates a new pg_type typtype: 'p' for pseudo type (currently either 'b' for base or 'c' for catalog, i.e. a class).2. Creates new builtin type of typtype='p' named RECORD. This is the first of potentially several pseudo types.3. Modify FROM clause grammer to accept: SELECT * FROM my_func() AS m(colname1 type1, colname2 type1, ...) where m is the table alias, colname1, etc are the column names, and type1, etc are the column types.4. When typtype == 'p' and the function return type is RECORD, a list of column defs is required, and when typtype != 'p', it isdisallowed.5. A check was added to ensure that the tupdesc provide via the parser and the actual return tupdesc match in number and type ofattributes.When creating a function you can do: CREATE FUNCTION foo(text) RETURNS setof RECORD ...When using it you can do: SELECT * from foo(sqlstmt) AS (f1 int, f2 text, f3 timestamp) or SELECT * from foo(sqlstmt) AS f(f1 int, f2 text, f3 timestamp) or SELECT * from foo(sqlstmt) f(f1 int, f2 text, f3 timestamp)Included in the patches are adjustments to the regression test sql andexpected files, and documentation.p.s. This potentially solves (or at least improves) the issue of builtin Table Functions. They can be bootstrapped as returning RECORD, and we can wrap system views around them with properly specified column defs. For example: CREATE VIEW pg_settings AS SELECT s.name, s.setting FROM show_all_settings()AS s(name text, setting text); Then we can also add the UPDATE RULE that I previously posted to pg_settings, and have pg_settings act like a virtual table, allowing settings to be queried and set.Joe Conway1 parent35d39ba commit9218689
File tree
19 files changed
+670
-273
lines changed- doc/src/sgml/ref
- src
- backend
- access/common
- catalog
- executor
- nodes
- parser
- include
- catalog
- nodes
- parser
- test/regress
- expected
- sql
19 files changed
+670
-273
lines changedLines changed: 75 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 |
| - | |
| 2 | + | |
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| |||
40 | 40 |
| |
41 | 41 |
| |
42 | 42 |
| |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
43 | 49 |
| |
44 | 50 |
| |
45 | 51 |
| |
| |||
82 | 88 |
| |
83 | 89 |
| |
84 | 90 |
| |
85 |
| - | |
| 91 | + | |
86 | 92 |
| |
87 | 93 |
| |
88 | 94 |
| |
| |||
156 | 162 |
| |
157 | 163 |
| |
158 | 164 |
| |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
159 | 182 |
| |
160 | 183 |
| |
161 | 184 |
| |
| |||
380 | 403 |
| |
381 | 404 |
| |
382 | 405 |
| |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
383 | 419 |
| |
384 | 420 |
| |
385 | 421 |
| |
| |||
925 | 961 |
| |
926 | 962 |
| |
927 | 963 |
| |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
928 | 1001 |
| |
929 | 1002 |
| |
930 | 1003 |
| |
|
Lines changed: 40 additions & 27 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 |
| |
| |||
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
| 27 | + | |
27 | 28 |
| |
28 | 29 |
| |
29 | 30 |
| |
| |||
600 | 601 |
| |
601 | 602 |
| |
602 | 603 |
| |
603 |
| - | |
604 |
| - | |
| 604 | + | |
| 605 | + | |
605 | 606 |
| |
606 | 607 |
| |
607 | 608 |
| |
608 | 609 |
| |
609 |
| - | |
| 610 | + | |
610 | 611 |
| |
611 | 612 |
| |
612 |
| - | |
613 |
| - | |
614 |
| - | |
615 |
| - | |
616 |
| - | |
617 |
| - | |
618 |
| - | |
| 613 | + | |
619 | 614 |
| |
620 |
| - | |
621 |
| - | |
| 615 | + | |
622 | 616 |
| |
623 |
| - | |
624 |
| - | |
| 617 | + | |
| 618 | + | |
625 | 619 |
| |
626 |
| - | |
627 |
| - | |
628 |
| - | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
629 | 624 |
| |
630 |
| - | |
631 |
| - | |
| 625 | + | |
| 626 | + | |
632 | 627 |
| |
633 |
| - | |
634 |
| - | |
635 |
| - | |
636 |
| - | |
637 |
| - | |
638 |
| - | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
639 | 645 |
| |
640 | 646 |
| |
| 647 | + | |
| 648 | + | |
641 | 649 |
| |
642 |
| - | |
| 650 | + | |
643 | 651 |
| |
644 | 652 |
| |
645 | 653 |
| |
| |||
664 | 672 |
| |
665 | 673 |
| |
666 | 674 |
| |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
667 | 680 |
| |
668 | 681 |
| |
669 | 682 |
|
0 commit comments
Comments
(0)