Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 62A0A1337B43 for ; Mon, 15 Nov 2010 06:03:59 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 77584-07 for ; Mon, 15 Nov 2010 10:03:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f46.google.com (mail-ew0-f46.google.com [209.85.215.46]) by mail.postgresql.org (Postfix) with ESMTP id 50F111337B51 for ; Mon, 15 Nov 2010 06:03:51 -0400 (AST) Received: by ewy8 with SMTP id 8so579573ewy.19 for ; Mon, 15 Nov 2010 02:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=rDTZTTpSw6FpzSA9YZBQd/BML6UjkJyHflLXegXLAzo=; b=fvSKXFTNOIYJyFjzSC6GW+8eqkIXp88A9LDeJ+xnaCGSG8gDUUS9RXtErdrjFcgb73 voRvhXTDt4QOZagO8O0zD3M4L+XWkysCzQGwNanX60FuYKl6cCYfqTlWGpy4Jer5V4JC Ms0xctnIExnxAWM4sie0GS+k/dG1rTLn1tn2c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=g30SJlYYXqGJc8hWV9y983jkuINU/pz1jL9pQvyqR1FSCXUAs1ojJFVoElHieDJZC1 Eiz7qGJRX72i4XsFcKhuZ4lYBUOaApTmfq/EKimq/mFxnivUat5E3aQChLdJZpjspk0b DFOctBODVY5+4+BN4zock4KJ+EIAyfK7v9BXM= Received: by 10.213.4.72 with SMTP id 8mr4528467ebq.70.1289815430457; Mon, 15 Nov 2010 02:03:50 -0800 (PST) Received: from [0.0.0.0] (5357DA75.cm-6-8d.dynamic.ziggo.nl [83.87.218.117]) by mx.google.com with ESMTPS id x54sm6460486eeh.23.2010.11.15.02.03.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 15 Nov 2010 02:03:49 -0800 (PST) Message-ID: <4CE10697.3050309@gmail.com> Date: Mon, 15 Nov 2010 11:08:23 +0100 From: Yeb Havinga User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.12) Gecko/20101027 Lightning/1.0b2 Thunderbird/3.1.6 MIME-Version: 1.0 To: Heikki Linnakangas CC: Tom Lane , pgsql-bugs@postgresql.org Subject: Re: BUG #5748: Invalid oidvector data during binary recv References: <201011111430.oABEUVPe067398@wwwmaster.postgresql.org> <15298.1289490490@sss.pgh.pa.us> <4CDC1380.2090309@enterprisedb.com> In-Reply-To: <4CDC1380.2090309@enterprisedb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201011/100 X-Sequence-Number: 28680 On 2010-11-11 17:02, Heikki Linnakangas wrote: > On 11.11.2010 17:48, Tom Lane wrote: >> "Yeb Havinga" 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