Re: Cannot Retrieve Binary Data - Mailing list pgsql-jdbc

From patrick
Subject Re: Cannot Retrieve Binary Data
Date
Msg-id f55fe783a729a522209c7390d92b2fec@freeshell.org
Whole thread Raw
In response to Cannot Retrieve Binary Data  (patrick <pch@freeshell.org>)
Responses Re: Cannot Retrieve Binary Data  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
Exactly the same error:

ERROR:  XX000: invalid memory alloc request size 2017394403
LOCATION:  MemoryContextAlloc, mcxt.c:502

the table is declared as:
backup=# \d images;
     Table "public.images"
  Column  | Type  | Modifiers
---------+-------+-----------
  imgname | text  |
  img     | bytea |

and the query is (there's only one record)

backup=# SELECT img from images ;
ERROR:  invalid memory alloc request size 2017394403


There's no way to stream a bytea ? how postgres support bytea with 1G
if is not possible to insert and select ?
FYI:
i tried the same Test with postgres 7.4.7 and earlier and is even worst
  i was not able to insert.
The  JDBC Driver  Return Out_Of_Memory during the query execution




On 11 Mar 2005, at 22:05, Oliver Jowett wrote:

> patrick wrote:
>
>> i'm following the example at
>> http://www.postgresql.org/docs/7.4/interactive/jdbc-binary-data.html
>> trying to retrieve previous stored  file (more than 600MB)
>
>> during the executeQuery() i got a the following exception
>> java.sql.SQLException: ERROR: invalid memory alloc request size
>> 2017394403
>
> What happens if you run an equivalent query via psql?
>
> I suspect what is happening is that you inserted the data earlier fine
> as JDBC sends it directly in binary form; however, when retrieving,
> the data asks for the text form, which expands the data by up to a
> factor of 5 (to >3GB for your file). The backend doesn't stream this
> data AFAIK, so it has to allocate space for the entire text
> representation. Then you hit a memory allocation sanity check in the
> backend, resulting in the error you see.
>
> -O
>


pgsql-jdbc by date:

Previous
From: Manohar Kaul
Date:
Subject: help with driver info
Next
From: Oliver Jowett
Date:
Subject: Re: Cannot Retrieve Binary Data