Seeking Clarification on Function Definitions in PostgreSQL Extensions

Поиск
Список
Период
Сортировка
От Ayush Vatsa
Тема Seeking Clarification on Function Definitions in PostgreSQL Extensions
Дата
Msg-id CACX+KaPBaSW+0PyMC7dmY6W9W8mPSbWpkJRhAOQOC9Qb0TjCQA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions
Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions
Список pgsql-general
Hi PostgreSQL community,
Recently I am exploring extensions in postgres and got a little confused regarding the function definition present in SQL file. For example consider below three functions:

CREATE FUNCTION fun1(integer)
RETURNS TABLE(
        col1 integer,
        col2 text
)
AS 'MODULE_PATHNAME', 'fun1'
LANGUAGE C;

CREATE FUNCTION fun2(
    IN  input integer,
    OUT col1 integer,
    OUT col2 text
)
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'fun2'
LANGUAGE C;

CREATE FUNCTION fun3(
    IN  input integer,
    OUT col1 integer,
    OUT col2 text
)
AS 'MODULE_PATHNAME', 'fun3'
LANGUAGE C;

1/ I wanted to know what's the difference between the above three definitions.
As per my understanding, "fun1" and "fun2" look the same, taking one integer and returning two columns with multiple rows.
Whereas "fun3" is used when we are returning only one row, but my doubt for "fun3" is that, Can the above definition (used for fun1 and fun2) cover both single and multiple row scenarios.

2/ How does someone decide which type of definition is to be used?

Regards
Ayush Vatsa

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: set search_path "$owner". And name versus literal for schemas.
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions