Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaJsL-00014m-24 for pgsql-general@arkaria.postgresql.org; Mon, 19 Sep 2022 16:44:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oaJsJ-0006Mh-VX for pgsql-general@arkaria.postgresql.org; Mon, 19 Sep 2022 16:44:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaJsJ-0006MY-KK for pgsql-general@lists.postgresql.org; Mon, 19 Sep 2022 16:44:03 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oaJsD-0005ky-2l for pgsql-general@lists.postgresql.org; Mon, 19 Sep 2022 16:44:02 +0000 Received: by mail-pj1-x1035.google.com with SMTP id y11so158873pjv.4 for ; Mon, 19 Sep 2022 09:43:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yugabyte.com; s=google; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date; bh=NODsip5WriT9lFwkncimbedAbdyZmmtMHiLBxs2teYs=; b=N3tpmwmkN4SpLlzFVx8kV+7p58uUeNPmcPY09wiLGwEKqFeCmn9E4gp4shGxtyyUTZ fl6EmwO0P2pzZOtW9lsechFQYjhj/fpU0o4FJeVPqLlnwBmd1jcblNR6KYbNqzFjBVXR yjpSJB434PV7/W6nNWAsPU/Mkoq53EJ6/z4DE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date; bh=NODsip5WriT9lFwkncimbedAbdyZmmtMHiLBxs2teYs=; b=g/8qEHd2oMPtuJqPLR21HftTugjkNYJacXIP2y4zJKT4o6y2AeqRsM9dEp2tyq0m9x MwuUxz2mhrSczLsFWElBA2+m3nA6Kksws54cOzLBUoJjydWPWr9pHaGevmE4x8QXi7z1 /Pq9uJPAWdrUp8EUZ2iLXHwhru6CN0egocr4MUWdAw5vQZSW/o1atYNrnrzijnwemT79 4zlxSPklgH+siXjG4InpWcrA4Z1DAq3Um34pSnS+QEAgawDre30ov0z+UrauZNJmpHP/ G21Kr7Lf1cLas1bdyNWQ5jlyUJM9jQ3RGGdXsR65dDuiE1fKm/XglKMK2qB+Z31w60Xu HLDg== X-Gm-Message-State: ACrzQf2eOI+eAiImVej2Cg93ddMh4zHDJ/2wqXIV6LdHiiCD70JjNFm8 KijMRDUbN6iZrWDxYaGSyFLvfu5wKnbjvA== X-Google-Smtp-Source: AMsMyM75JvOKyjOKOKBYaIV0vx9lSIFcj26o7gYs1b7IEY/J81+L2p4mqOpN82LLhN4ZJOOeai9epw== X-Received: by 2002:a17:902:efce:b0:178:5d52:9e4b with SMTP id ja14-20020a170902efce00b001785d529e4bmr591964plb.101.1663605835989; Mon, 19 Sep 2022 09:43:55 -0700 (PDT) Received: from smtpclient.apple ([2601:646:101:7fda:ddd0:9f02:85c1:78ec]) by smtp.gmail.com with ESMTPSA id l4-20020a622504000000b0054bcc370441sm6249168pfl.104.2022.09.19.09.43.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Sep 2022 09:43:55 -0700 (PDT) From: Bryn Llewellyn Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_7374CEBF-7AFA-4FC6-91AE-0D4B7B66CC80" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: =?utf-8?B?UmU6IFdoZXJlJ3MgdGhlIGRvYyBmb3IgImFycmF5KCkiIOKAlCBh?= =?utf-8?B?cyBpbiAic2VsZWN0IGFycmF5KHZhbHVlcyAoMTcpLCAoNDIpKSI=?= Date: Mon, 19 Sep 2022 09:43:54 -0700 In-Reply-To: <257592.1663561881@sss.pgh.pa.us> Cc: Adrian Klaver , pgsql-general list To: Tom Lane PostgreSQL References: <257592.1663561881@sss.pgh.pa.us> X-Mailer: Apple Mail (2.3654.120.0.1.13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_7374CEBF-7AFA-4FC6-91AE-0D4B7B66CC80 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > tgl@sss.pgh.pa.us wrote: >=20 >> bryn@yugabyte.com wrote: >>=20 >> Why is the "array()" constructor not found in "pg_proc"? >=20 > 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. >=20 > 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 =E2=80=94 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. --Apple-Mail=_7374CEBF-7AFA-4FC6-91AE-0D4B7B66CC80 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
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 =E2=80=94 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.

= --Apple-Mail=_7374CEBF-7AFA-4FC6-91AE-0D4B7B66CC80--