pgsql-server/ oc/src/sgml/ref/select.sgml rc/b ...

Поиск
Список
Период
Сортировка
От momjian@postgresql.org (Bruce Momjian - CVS)
Тема pgsql-server/ oc/src/sgml/ref/select.sgml rc/b ...
Дата
Msg-id 20020804194811.2559047546C@postgresql.org
обсуждение исходный текст
Список pgsql-committers
CVSROOT:    /cvsroot
Module name:    pgsql-server
Changes by:    momjian@postgresql.org    02/08/04 15:48:11

Modified files:
    doc/src/sgml/ref: select.sgml
    src/backend/access/common: tupdesc.c
    src/backend/catalog: pg_proc.c
    src/backend/executor: functions.c nodeFunctionscan.c
    src/backend/nodes: copyfuncs.c equalfuncs.c outfuncs.c
                       readfuncs.c
    src/backend/parser: gram.y parse_clause.c parse_relation.c
    src/include/catalog: catversion.h pg_type.h
    src/include/nodes: execnodes.h parsenodes.h
    src/include/parser: parse_relation.h
    src/test/regress/expected: type_sanity.out
    src/test/regress/sql: type_sanity.sql

Log message:
    Attached are two patches to implement and document anonymous composite
    types for Table Functions, as previously proposed on HACKERS. Here is a
    brief 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 is
    disallowed.

    5. A check was added to ensure that the tupdesc provide via the parser
    and the actual return tupdesc match in number and type of
    attributes.

    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 and
    expected 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 Conway


В списке pgsql-committers по дате отправления:

Предыдущее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql-server/src/backend/utils/cache relcache.c
Следующее
От: momjian@postgresql.org (Bruce Momjian - CVS)
Дата:
Сообщение: pgsql-server/ oc/src/sgml/func.sgml oc/src/sgm ...