pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bryn Llewellyn <bryn@yugabyte.com>
To: Tom Lane PostgreSQL <tgl@sss.pgh.pa.us>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Where's the doc for "array()" — as in "select array(values (17), (42))"
Date: Mon, 19 Sep 2022 09:43:54 -0700
Message-ID: <FD968796-42C5-4FA1-AB61-66DD34049F79@yugabyte.com> (raw)
In-Reply-To: <257592.1663561881@sss.pgh.pa.us>
References: <F2DA0774-0B4D-4E72-8944-116154A57D98@yugabyte.com>
	<e6ac86e5-39f4-9704-7260-3f6c40c63b2d@aklaver.com>
	<C167E3BD-B650-4A8E-80A3-3307E70883C0@yugabyte.com>
	<257592.1663561881@sss.pgh.pa.us>

> tgl@sss.pgh.pa.us wrote:
> 
>> bryn@yugabyte.com wrote:
>> 
>> Why is the "array()" constructor not found in "pg_proc"?
> 
> Because it isn't a function. Yeah, it kind of looks like one, but its argument is a subquery. If SQL had first-class functions and closures, maybe ARRAY() could be implemented as an ordinary function. But I don't see any plausible way to do that as things stand.
> 
> There are a bunch of other things that look like functions but aren't in pg_proc, too :-(. Most of them are just catering to the SQL committee's weird allergy to writing functions with plain function syntax. But ARRAY()'s problem is semantic not syntactic.

There must be a significant difference between this:

  select 'dog'

and this:

  (select 'dog')

This works fine:

  select length( (select 'dog') )

But without the doubled parentheses, it causes a syntax error.

On the other hand, an extra pair of surrounding parentheses here

  select array( (values (17), (42)) )

while not necessary, *is* tolerated.

All this started because I had wrongly assumed that "pg_terminate_backend()" would have the same character as "array()" by not being subject to the "execute" privilege — just as is the case for all SQL built-ins in Oracle database, like "length()". I have a better mental model now.

Anyway, I know what to do in future. I'll simply look in pg_proc on a case-by-case basis.

view thread (12+ messages)  latest in thread

Message-ID: <FD968796-42C5-4FA1-AB61-66DD34049F79@yugabyte.com>
Permalink:  ../FD968796-42C5-4FA1-AB61-66DD34049F79@yugabyte.com/
Also on:    postgresql.org/message-id/FD968796-42C5-4FA1-AB61-66DD34049F79@yugabyte.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: bryn@yugabyte.com, tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com
  Subject: Re: Where's the doc for "array()" — as in "select array(values (17), (42))"
  In-Reply-To: <FD968796-42C5-4FA1-AB61-66DD34049F79@yugabyte.com>
  References: <F2DA0774-0B4D-4E72-8944-116154A57D98@yugabyte.com> <e6ac86e5-39f4-9704-7260-3f6c40c63b2d@aklaver.com> <C167E3BD-B650-4A8E-80A3-3307E70883C0@yugabyte.com> <257592.1663561881@sss.pgh.pa.us> <FD968796-42C5-4FA1-AB61-66DD34049F79@yugabyte.com>

* 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