From: steven.winfield@cantabcapital.com
To: pgsql-bugs@postgresql.org
Cc: steven.winfield@cantabcapital.com
Subject: BUG #14953: pg_blocking_pids / array_length inconsistency
Date: Thu, 07 Dec 2017 14:40:28 +0000
Message-ID: <20171207144028.21691.76008@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 14953
Logged by: Steven Winfield
Email address: steven.winfield@cantabcapital.com
PostgreSQL version: 10.0
Operating system: Linux
Description:
It seems as though pg_blocking_pids() can return a zero-length,
one-dimensional array whereas users can only create NULL-length,
zero-dimensional arrays (even though the type suggests it is one
dimensional: 'integer[]')
test=# SELECT pg_blocking_pids(pg_backend_pid()),
array_length(pg_blocking_pids(pg_backend_pid()), 1), '{}'::integer[],
array_length('{}'::integer[], 1);
pg_blocking_pids | array_length | int4 | array_length
------------------+--------------+------+--------------
{} | 0 | {} |
(1 row)
This means that, for example, the code to check for an empty array of PIDs
must be special-cased.
For what it's worth, I think having array_length('{}'::integer[], 1) = 0 is
far more sensible, and
making differently-dimensioned empty arrays compare equal (as mentioned
previously[1]) is quite confusing.
[1]
https://www.postgresql.org/message-id/tencent_5D502954744B7F744ED6F34E%40qq.com
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-bugs@postgresql.org
Cc: steven.winfield@cantabcapital.com
Subject: Re: BUG #14953: pg_blocking_pids / array_length inconsistency
In-Reply-To: <20171207144028.21691.76008@wrigleys.postgresql.org>
References: <20171207144028.21691.76008@wrigleys.postgresql.org>
* 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