Обсуждение: pgsql: Doc: improve documentation about composite-value usage.

Поиск
Список
Период
Сортировка

pgsql: Doc: improve documentation about composite-value usage.

От
Tom Lane
Дата:
Doc: improve documentation about composite-value usage.

Create a section specifically for the syntactic rules around whole-row
variable usage, such as expansion of "foo.*".  This was previously
documented only haphazardly, with some critical info buried in
unexpected places like xfunc-sql-composite-functions.  Per repeated
questions in different mailing lists.

Discussion: <16288.1479610770@sss.pgh.pa.us>

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/ff9730aa15d4f964c0f4bb3bc73b12a9e5312e9a

Modified Files
--------------
doc/src/sgml/queries.sgml  |   3 +-
doc/src/sgml/rowtypes.sgml | 214 +++++++++++++++++++++++++++++++++++++++++++--
doc/src/sgml/syntax.sgml   |  16 ++--
doc/src/sgml/xfunc.sgml    |  69 +++------------
4 files changed, 231 insertions(+), 71 deletions(-)


Re: pgsql: Doc: improve documentation about composite-value usage.

От
"David G. Johnston"
Дата:
On Tue, Nov 22, 2016 at 3:56 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Doc: improve documentation about composite-value usage.

Create a section specifically for the syntactic rules around whole-row
variable usage, such as expansion of "foo.*".  This was previously
documented only haphazardly, with some critical info buried in
unexpected places like xfunc-sql-composite-functions.  Per repeated
questions in different mailing lists.

​Tom,​

​I found it notable that you choose to introduce the OFFSET 0 hack instead of writing a LATERAL query in the "optimization failure" example.​

SELECT (m).* FROM (SELECT myfunc(x) AS m FROM some_table OFFSET 0) ss;

instead of​

SELECT (m).* FROM some_table, LATERAL myfunc(some_table.x) m

​​Skipping or having a different example in 9.2 seems worth it in order to introduce the now preferred way of writing such queries.

Or maybe in addition, so that some familiarity with the hack is gained should the reader encounter it in the wild.

David J.

Re: pgsql: Doc: improve documentation about composite-value usage.

От
Tom Lane
Дата:
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> ​I found it notable that you choose to introduce the OFFSET 0 hack instead
> of writing a LATERAL query in the "optimization failure" example.​
> SELECT (m).* FROM (SELECT myfunc(x) AS m FROM some_table OFFSET 0) ss;
> instead of​
> SELECT (m).* FROM some_table, LATERAL myfunc(some_table.x) m

Meh ... I'm not really sure that the latter is any less of a hack for this
purpose, or that we'd never optimize it into the unwanted form.  LATERAL
is a good way to fix the weird semantics of set-returning functions in the
tlist, but this is not that case.

            regards, tom lane