Builder + BDE + OBDC + MySQL + BLOB -> What a mess!


2005-07-06 11:29:31 PM
off-topic9
Hello everybody:
I'm developing an app that deals with large blobs (several hundreds of
MB). Unfortunatelly I have to use an old developing tool such Builder
5.0 and BDE. I use the ODBC driver to access databases. I have found
the known limit of MySQL queries controlled by the max_allowed_packet
variable when storing and retrieving LONGBLOBS.
I have tried to set the max_allowed_packet to it's limit of 1GB, but
the problem continues. I have set the following ODBC flags:
* Don't Optimize Column Width
* Return Matching Rows
* Allow Big Results
* Read Options From my.cnf
And in my.ini I have this for [client], [odbc] and [mysqld]
max_allowed_packet=1024M
After many hours of testing I have found that the error was not on
MySQL, nor ODBC or BDE because i could upload a large BLOB (5 MB) from
command line and SQLExplorer (a BDE tool), then the error has to be in
my code so there is my TDatabase init and the BLOB upload:
// Database init
database = new TDatabase(NULL);
database->DatabaseName = Alias.c_str();
database->AliasName = Alias.c_str();
database->Connected = true;
database->Open();
// Blob upload
// ... here I have a TQUERY that insert a row with a
// NULL BLOB, this TQUERY is query.
TField* field = query->FieldByName("myBlobField");
TBlobField* blob = dynamic_cast<TBlobField*>(field);
if(!blob)
throw runtime_error("Is not a BLOB");
query->Edit();
blob->LoadFromFile(fileName.c_str());
query->CheckBrowseMode();
This code does well with BLOBS less than 1MB, above this limit a
EBDEException with "Invalid Blob Length" is throw. As I have said the
server is well configured and also is the ODBC and the BDE because I
COULD upload a BLOB of 5MB with this query in SQLExplorer
Insert Into MyTable Values(1, 2, LOAD_FILE("c:/data"));
Someone has some idea ... It will be apreciated so much ... I'm
clueless.
Thanks!!