Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T7cAB-0001pG-DP for pgsql-jdbc@postgresql.org; Sat, 01 Sep 2012 01:06:15 +0000 Received: from mail-pb0-f46.google.com ([209.85.160.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T7cA7-0006ff-IM for pgsql-jdbc@postgresql.org; Sat, 01 Sep 2012 01:06:14 +0000 Received: by pbbrr13 with SMTP id rr13so5644106pbb.19 for ; Fri, 31 Aug 2012 18:06:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=1rjSJQl88NwSDjpVxhoCpOnTVsPGQfxUwImynizIlRo=; b=naBgdfp+YhVlJgsxpOxq7MfNwqrmsVS91I9IzowPFXemzRQZN3OxoxjQZ2S1dbX4DR BaJm9C04vuVoWzvMkEV6PgyEQ36RhGp7pzt4ptbl2DrFEYY+HJKO8CrrihkwOx3Xu/hq FNeoaeR3jePOlmrdY756W9OroulTr2JIYKBBYoaLnDY50xNAlFzPznTk06x6PvJcM7Or 9IBH/USmrwrw5pbHKsI9vm035LfmNitWtQlWYhjHkMEJIPEEXaDlsnjK7I7U124HeUsn YRcBd90RIwiK8BpgKPsP0O3LE8K1uZ192W6B7HNuhzN3wDkpuZmmTfuo1B+1kGj+peC8 rANA== Received: by 10.66.77.71 with SMTP id q7mr18583478paw.0.1346461569700; Fri, 31 Aug 2012 18:06:09 -0700 (PDT) Received: from ayaki.localdomain ([106.71.213.25]) by mx.google.com with ESMTPS id ty1sm4495795pbc.76.2012.08.31.18.06.04 (version=SSLv3 cipher=OTHER); Fri, 31 Aug 2012 18:06:08 -0700 (PDT) Message-ID: <50415F0B.9020504@ringerc.id.au> Date: Sat, 01 Sep 2012 09:04:11 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Werner_Donn=E9?= CC: pgsql-jdbc@postgresql.org Subject: Re: Streaming bytea implementation offered References: <6EA298B8-34D9-4832-A722-161911A22AB6@pincette.biz> In-Reply-To: <6EA298B8-34D9-4832-A722-161911A22AB6@pincette.biz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Gm-Message-State: ALoCoQnl1A+IF0TvdiyQHlNnQYKOJKJ2RB5YlUNtqks8xHi/xCIFB4okAbhOvXY+xK5Ve+vt+J70 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201209/1 X-Sequence-Number: 23237 On 09/01/2012 12:49 AM, Werner Donné wrote: > Hello, > > I have modified version 9.1-902 of the driver in order for it to stream bytea values when calling ResultSet.getBinaryStream(). The implementation is here: > > http://www.pincette.biz/home/werner/postgresql-jdbc-9.1-902-patched.src.zip > > When a bytea value is larger than 1MB it is streamed to a temporary file instead of being copied in the "answer" array. When the stream is later accessed, either with "getBinaryInputStream" or "getBytes", the bytes are fetched from the temporary file, which is subsequently deleted. The "getBytes" method copies the bytes in the result array, while "getBinaryInputStream" returns a FileInputStream with an overridden "close" method that deletes the temporary file Sounds potentially good, but what happens if it's run inside the SecurityManager, or in an environment with no ability to create temporary files? What about out-of-disk causing failures that wouldn't occur with OOM? Do you propose to make this always-on, or configurable? How (if at all) does this interact with JDBC-standard BLOB support, and with large objects? If you'd like this change considered, it'd be great if you could create a patch against the current PgJDBC sources, rather than just publishing patched sources. I'd recommend that you clone PgJDBC (https://github.com/pgjdbc/pgjdbc): git://github.com/pgjdbc/pgjdbc.git then copy your changes into that working tree and use `git diff`. Alternately, you can , `git add` them, `git commit`, then use `git format-patch` to get a diff; see http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html Make sure not to include any generated files, and please add some unit tests demonstrating the functionality if possible. -- Craig Ringer