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 1lGsLh-0002me-82 for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Mar 2021 23:53:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lGsLe-0006d9-Hb for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Mar 2021 23:53:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lGsLe-0006d2-Aa for pgsql-hackers@lists.postgresql.org; Mon, 01 Mar 2021 23:53:10 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lGsLb-0002ak-ND for pgsql-hackers@lists.postgresql.org; Mon, 01 Mar 2021 23:53:09 +0000 X-Originating-IP: 79.88.149.14 Received: from [172.16.255.146] (14.149.88.79.rev.sfr.net [79.88.149.14]) (Authenticated sender: vik@postgresfriends.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id EB57B1C0002; Mon, 1 Mar 2021 23:53:04 +0000 (UTC) Subject: Re: TRIM_ARRAY To: Dian Fay , pgsql-hackers@lists.postgresql.org Cc: Vik Fearing References: <931d94fa-9238-47ba-6f17-01600a845417@postgresfriends.org> <161464047991.29967.8270411748023500393.pgcf@coridan.postgresql.org> From: Vik Fearing Message-ID: Date: Tue, 2 Mar 2021 00:53:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <161464047991.29967.8270411748023500393.pgcf@coridan.postgresql.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/2/21 12:14 AM, Dian Fay wrote: > The following review has been posted through the commitfest application: > make installcheck-world: tested, passed > Implements feature: tested, passed > Spec compliant: tested, failed > Documentation: tested, failed Thank you for looking at my patch! > This basically does what it says, and the code looks good. The > documentation is out of alphabetical order (trim_array should appear > under cardinality rather than over)) but good otherwise. Hmm. It appears between cardinality and unnest in the source code and also my compiled html. Can you say more about where you're seeing the wrong order? > I was able to > "break" the function with an untyped null in psql: > > select trim_array(null, 2); > ERROR: could not determine polymorphic type because input has type unknown > > I don't know whether there are any circumstances other than manual entry > in psql where this could happen, since column values and variables will > always be typed. I don't have access to the standard, but DB2's docs[1] > note "if any argument is null, the result is the null value", so an > up-front null check might be preferable to a slightly arcane user-facing > error, even if it's a silly invocation of a silly function :) > > [1] https://www.ibm.com/support/knowledgecenter/en/SSEPEK_12.0.0/sqlref/src/tpc/db2z_bif_trimarray.html The standard also says that if either argument is null, the result is null. The problem here is that postgres needs to know what the return type is and it can only determine that from the input. If you give the function a typed null, it returns null as expected. > The new status of this patch is: Waiting on Author I put it back to Needs Review without a new patch because I don't know what I would change. -- Vik Fearing