Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 4F9D81337990 for ; Mon, 15 Nov 2010 06:51:58 -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 03088-06 for ; Mon, 15 Nov 2010 10:51:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ey0-f174.google.com (mail-ey0-f174.google.com [209.85.215.174]) by mail.postgresql.org (Postfix) with ESMTP id B75BD1335B36 for ; Mon, 15 Nov 2010 06:51:50 -0400 (AST) Received: by eye27 with SMTP id 27so2813980eye.19 for ; Mon, 15 Nov 2010 02:51: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=2x9HzEElckSdFDAC/F80429aCeIVW3n3/NVKmHi8n0o=; b=lLqY5wCzYUPSyJ3VwoWlkfHL5NksWGUkUjvja6mrcKlO+jLYSSrA+VOdInwyTxMrZ0 /pNSrsquFDKgs6jKCQSSedIFKc/DAMiU/70Sz8iAThpidYfNokxdDx1hNWlGGyaHLpXe esARwlBuwAomAcaVAqhrjfjtAfUGpFP/dilX0= 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=ebpykNsLkpl3VCmfarJo1fFEztGDFVdlcA+/RHKYBCuDmmtU9iaYqXZ9W2GP0Q8OQd S44ES3dRZuwinQOD3NYrJFjbr4FGrW3mSosj6bWYNRrQq9mlUZ4nj1z3f8hBcHdPqEf3 2oXIpnZiDPgHnAxH6xwNlSsB7exTt+h5U7ceQ= Received: by 10.14.119.144 with SMTP id n16mr3820932eeh.44.1289818309944; Mon, 15 Nov 2010 02:51:49 -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 v51sm6496276eeh.10.2010.11.15.02.51.47 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 15 Nov 2010 02:51:48 -0800 (PST) Message-ID: <4CE111D6.5070801@gmail.com> Date: Mon, 15 Nov 2010 11:56:22 +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> <4CE10697.3050309@gmail.com> <4CE10E39.9080806@enterprisedb.com> In-Reply-To: <4CE10E39.9080806@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/102 X-Sequence-Number: 28682 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" 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