FDB (firebird) adapter can't store blobs greater than 64k

342 views
Skip to first unread message

Raul Monares

unread,
Jul 1, 2013, 1:21:03 PM7/1/13
to web...@googlegroups.com
When trying to store a value greater than 64k in a Blob Field, I get this error:

<class 'fdb.fbcore.DatabaseError'> ('Error while preparing SQL statement:\n- SQLCODE: -104\n- Dynamic SQL Error\n- SQL error code = -104\n- Unexpected end of command - line 1, column 25', -104, 335544569)

But with blobs smaller than 64k works fine.

Niphlod

unread,
Jul 1, 2013, 3:24:17 PM7/1/13
to
what driver are you using ? DAL creates 'blob' fields as BLOB SUB_TYPE 1.... can you please check that the field is created indeed as BLOB SUB_TYPE 1 watching your databases/sql.log file ?

This is an excerpt from firebird documentation

Sub-type is 1.

This blob field sub-type is designed for the storage and manipulation of text. Typically, this is free-form memo or notes data. Typically you would use this blob field sub-type is for storing large amounts of text data. This is more convenient that a large VARCHAR because, unlike a VARCHAR, there is no 32K limit.

Raul Monares

unread,
Jul 1, 2013, 6:55:43 PM7/1/13
to web...@googlegroups.com
I'm using python fdb 1.4. The field is defined as blob sub_type 0, because I'm storing PDF's



On Monday, July 1, 2013 1:23:42 PM UTC-6, Niphlod wrote:
what driver are you using ? DAL creates 'blob' fields as BLOB SUB_TYPE 1.... can you please check that the field is created indeed as BLOB SUB_TYPE 1 watching your databases/sql.log file ?

This is an excerpt from firebird documentation

Sub-type is 1.

This blob field sub-type is designed for the storage and manipulation of text. Typically, this is free-form memo or notes data. Typically you would use this blob field sub-type is for storing large amounts of text data. This is more convenient that a large VARCHAR because, unlike a VARCHAR, there is no 32K limit.


 

On Monday, July 1, 2013 7:21:03 PM UTC+2, Raul Monares wrote:

Niphlod

unread,
Jul 2, 2013, 2:26:17 AM7/2/13
to web...@googlegroups.com
Bummer, than it's probably a problem within the driver itself... need to debug it or wait that someone picks it and see what's going on.

Raul Monares

unread,
Jul 2, 2013, 11:43:07 AM7/2/13
to web...@googlegroups.com
According to the FDB documentation, an insert or update has to pass parameters using an file-like object, like this:

cur.execute("insert into blob_test values (?)", (StringIO('abcdef'),))
It appears that currently the DAL passes the parameter as a very long string, and Firebird has a 64k limit on the size of the parameters.

Massimo Di Pierro

unread,
Jul 2, 2013, 5:41:32 PM7/2/13
to web...@googlegroups.com
please open a ticket.

Jose

unread,
Nov 26, 2013, 4:16:12 PM11/26/13
to web...@googlegroups.com
Hi,

I was watching this. I have a little dizzy with the code. Now I can not prove. The solution is to redefine "represent_exceptions" in FireBirdAdapter? It is that way?

José

Raul Monares

unread,
Nov 28, 2013, 11:29:02 AM11/28/13
to web...@googlegroups.com
I think the solution is to use streamed blobs (from FDB documentation):

# Insertion:
cur.execute("insert into blob_test values (?)", (StringIO('abcdef'),))
# Retrieval using the "file-like" methods of BlobReader:
cur.execute("select a from blob_test")
cur.set_stream_blob('A') # Note the capital letter

readerA = cur.fetchone()[0]
value = readerA.read()
Reply all
Reply to author
Forward
0 new messages