pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yeb Havinga <yebhavinga@gmail.com>
To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5748: Invalid oidvector data during binary recv
Date: Mon, 15 Nov 2010 11:56:22 +0100
Message-ID: <4CE111D6.5070801@gmail.com> (raw)
In-Reply-To: <4CE10E39.9080806@enterprisedb.com>
References: <201011111430.oABEUVPe067398@wwwmaster.postgresql.org>
	<15298.1289490490@sss.pgh.pa.us>
	<4CDC1380.2090309@enterprisedb.com>
	<4CE10697.3050309@gmail.com>
	<4CE10E39.9080806@enterprisedb.com>

On 2010-11-15 11:40, Heikki Linnakangas wrote:
> On 15.11.2010 12:08, Yeb Havinga wrote:
>> On 2010-11-11 17:02, Heikki Linnakangas wrote:
>>> On 11.11.2010 17:48, Tom Lane wrote:
>>>> "Yeb Havinga"<yebhavinga@gmail.com> writes:
>>>>> postgres=# create table a as select ''::oidvector;
>>>>> SELECT 1
>>>>> postgres=# copy a to '/tmp/test' with binary;
>>>>> COPY 1
>>>>> postgres=# copy a from '/tmp/test' with binary;
>>>>> ERROR: invalid oidvector data
>>>>
>>>> The problem seems to be that array_recv passes back a zero-dimensional
>>>> array, *not* a 1-D array, when it observes that the input has no
>>>> elements. A zero-D array is not part of the subset of possible arrays
>>>> that we allow for oidvector.
>>>
>>> Yeah, I just reached that conclusion too..
>> The patch below changes array_recv, so that it returns an empty 1-D
>> array when an empty 1-D array was written binary. No changes in
>> oidvectorrecv or int2vectorrecv are needed.
>
> That seems like a bad idea. array_in() represents an empty array with 
> zero dimensions, we're not going to change the generic array_recv() 
> function used for all arrays to behave differently because of some 
> corner-case in oidvectorrecv.
It's possible to trigger it with any element type, as long as the use 
manages to construct a 1-D array. E.g. with contrib/_int.sql loaded, 
array substraction is possible. Now:
postgres=# select ARRAY[1]::int4[] - ARRAY[1]::int4[];
  ?column?
----------
  {}
(1 row)

postgres=# select array_ndims(ARRAY[1]::int4[] - ARRAY[1]::int4[]);
  array_ndims
-------------
            1
(1 row)

Binary send and recv of the value at hand would change it into a 0-D vector.

>
> If we want do anything about this, the right fix is to add a special 
> case in oidvectorrecv/int2vectorrecv to handle empty array.
Judging from the fact that it also happens with int4 arrays, this seems 
like the wrong place.

regards,
Yeb Havinga






view thread (21+ messages)  latest in thread

Message-ID: <4CE111D6.5070801@gmail.com>
Permalink:  ../4CE111D6.5070801@gmail.com/
Also on:    postgresql.org/message-id/4CE111D6.5070801@gmail.com

 · 

reply

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: yebhavinga@gmail.com, heikki.linnakangas@enterprisedb.com, tgl@sss.pgh.pa.us
  Subject: Re: BUG #5748: Invalid oidvector data during binary recv
  In-Reply-To: <4CE111D6.5070801@gmail.com>
  References: <201011111430.oABEUVPe067398@wwwmaster.postgresql.org> <15298.1289490490@sss.pgh.pa.us> <4CDC1380.2090309@enterprisedb.com> <4CE10697.3050309@gmail.com> <4CE10E39.9080806@enterprisedb.com> <4CE111D6.5070801@gmail.com>

* 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