pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Guyren Howe <guyren@gmail.com>
Cc: Pg Docs <pgsql-docs@lists.postgresql.org>
Subject: Re: Please provide examples of rows from
Date: Sat, 19 Sep 2020 21:38:46 -0400
Message-ID: <20200920013846.GC22746@momjian.us> (raw)
In-Reply-To: <798909.1600562993@sss.pgh.pa.us>
References: <158638264419.662.2482095087061084020@wrigleys.postgresql.org>
	<20200904014618.GB13932@momjian.us>
	<CAKFQuwbBDr22KJRyJQRECO_XU6cyouwz3ocn0Tv4JgG4Gm5hMQ@mail.gmail.com>
	<20200920003910.GA22746@momjian.us>
	<798909.1600562993@sss.pgh.pa.us>

On Sat, Sep 19, 2020 at 08:49:53PM -0400, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > 	test=> \df pg_get_keywords
> > 	                                                                   List of functions
> > 	   Schema   |      Name       | Result data type |                                      Argument data types                                      | Type
> > 	------------+-----------------+------------------+-----------------------------------------------------------------------------------------------+------
> > 	 pg_catalog | pg_get_keywords | SETOF record     | OUT word text, OUT catcode "char", OUT barelabel boolean, OUT catdesc text, OUT baredesc text | func
> > 	(1 row)
> 
> > 	test=> select * from pg_get_keywords() AS f(word text);
> > -->	ERROR:  a column definition list is only allowed for functions returning "record"
> > 	LINE 1: select * from pg_get_keywords() AS f(word text);
> 
> Yeah, this error message needs some help.  With a function having
> multiple OUT parameters, the prorettype is indeed "record", but
> the specific record type is implied by the OUT parameters so you
> do not need to (and can't) specify it in the query.
> 
> The point of the AS feature is to allow specifying the concrete
> record type for record-returning functions that don't have a
> predefined result record type, like dblink().
> 
> I think this error text was written before we had multiple OUT
> parameters, so it was okay at the time; but now it needs to be
> more precise.

OK, thanks.  It seems this area needs some work, in general. 
Unfortunately I don't see any system functions that return RECORD and
don't use OUT parameters, except dblink(), json(b)_to_record(),
json(b)_to_recordset(), and record_*.  This is going to be hard to
illustrate.  :-(  I did get this working:

	test=> select * FROM json_to_record('{"a": 1, "b": 2}'::json) as (b
	text);
	 b
	---
	 2

but doing this to illustrate ROWS FROM is going to be complex.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee






view thread (16+ messages)  latest in thread

Message-ID: <20200920013846.GC22746@momjian.us>
Permalink:  ../20200920013846.GC22746@momjian.us/
Also on:    postgresql.org/message-id/20200920013846.GC22746@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: bruce@momjian.us, tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, guyren@gmail.com, pgsql-docs@lists.postgresql.org
  Subject: Re: Please provide examples of rows from
  In-Reply-To: <20200920013846.GC22746@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox