Re: postgres 9.0 beta libpq empty binary array error - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: postgres 9.0 beta libpq empty binary array error
Date
Msg-id 4C60465C.60705@enterprisedb.com
Whole thread Raw
In response to Re: postgres 9.0 beta libpq empty binary array error  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: postgres 9.0 beta libpq empty binary array error
List pgsql-bugs
On 09/08/10 17:56, Tom Lane wrote:
> <vshahov@alliedtesting.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Assertion failure with assignment to array elem
Next
From: Tom Lane
Date:
Subject: Re: postgres 9.0 beta libpq empty binary array error