Re: postgres 9.0 beta libpq empty binary array error

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: vshahov(at)alliedtesting(dot)com, pgsql-bugs(at)postgresql(dot)org, pgagarinov(at)alliedtesting(dot)com, depstein(at)alliedtesting(dot)com
Subject: Re: postgres 9.0 beta libpq empty binary array error
Date: 2010-08-09 18:18:04
Message-ID: 4C60465C.60705@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 09/08/10 17:56, Tom Lane wrote:
> <vshahov(at)alliedtesting(dot)com> writes:
>> I have the problem:
>> the code sending empty binary array works on 8.3 and 8.4
>> but stopped working on postgres 9.0 beta2/3/4, it fails with '22003','integer out of range error'.
>
> I think you are right --- this rejects dim[i] == 0, but it should not.

Yeah, this is also reproducible with COPY:

postgres=# CREATE TABLE arrtest (a int4[]);
CREATE TABLE
postgres=# COPY ( SELECT array_fill(7, ARRAY[0], ARRAY[1]) ) TO '/tmp/a'
BINARY;
COPY 1
postgres=# COPY arrtest FROM '/tmp/a' BINARY;ERROR: integer out of range
CONTEXT: COPY arrtest, line 1, column a

The behavior of empty arrays with dimensions is weird in general. For
example:

postgres=# SELECT array_dims(array_fill(7, ARRAY[0, 1]));
array_dims
------------
[1:0][1:1]
(1 row)

postgres=# SELECT array_fill(7, ARRAY[0, 1]);
array_fill
------------
{}
(1 row)

postgres=# SELECT array_dims('{}'::int4[]);
array_dims
------------

(1 row)

The text representation of such an array is simply '{}', but that loses
information about the dimensions.

I agree that array_recv() should rather accept that than throw an error,
patch attached, but this is pretty weird stuff...

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
accept-empty-arrays.patch text/x-diff 980 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2010-08-09 18:26:22 Re: postgres 9.0 beta libpq empty binary array error
Previous Message Tom Lane 2010-08-09 16:54:58 Re: Assertion failure with assignment to array elem