Re: BUG #5748: Invalid oidvector data during binary recv

From: Yeb Havinga <yebhavinga(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5748: Invalid oidvector data during binary recv
Date: 2010-11-15 10:08:23
Message-ID: 4CE10697.3050309@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2010-11-11 17:02, Heikki Linnakangas wrote:
> On 11.11.2010 17:48, Tom Lane wrote:
>> "Yeb Havinga"<yebhavinga(at)gmail(dot)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.

diff --git a/src/backend/utils/adt/arrayfuncs.c
b/src/backend/utils/adt/arrayfuncs.c
index 4ceb256..98e725a 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -1288,7 +1288,7 @@ array_recv(PG_FUNCTION_ARGS)
my_extra->element_type = element_type;
}

- if (nitems == 0)
+ if (ndim == 0)
{
/* Return empty array ... but not till we've validated
element_type */
PG_RETURN_ARRAYTYPE_P(construct_empty_array(element_type));

Make check passes.

regards,
Yeb Havinga

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2010-11-15 10:40:57 Re: BUG #5748: Invalid oidvector data during binary recv
Previous Message Tom Lane 2010-11-13 22:13:49 Re: BUG #5753: Existing Functions No Longer Work