[Gambas-devel] Database driver update in 1.9.23

Daniel daniel at ...413...
Sat Jan 14 01:20:30 CET 2006


Benoit Minisini wrote:

>On Friday 13 January 2006 17:14, Daniel wrote:
>  
>
>>Benoit Minisini wrote:
>>    
>>
>>>Here is more explanations about the database driver update of 1.9.23:
>>>
>>>
>>>(1) The DB_DATABASE structure has changed.
>>>
>>>Before, it was just a cast to the underlying connection handle. Now it is
>>>the following structure:
>>>
>>>typedef
>>> struct {
>>>   void *handle;	/* Connection handle */
>>>   long version;	/* Version of the database system */
>>>   char *charset;	/* Charset used by the database */
>>>   void *data;		/* Can be used by the driver for storing its
>>>			own private data */
>>>   struct {
>>>     unsigned no_table_type : 1;	/* Tables do not have types */
>>>     unsigned no_serial : 1;		/* Serial fields are not supported */
>>>     unsigned no_blob : 1;		/* Blob fields are not supported */
>>>     unsigned no_seek : 1;		/* Cannot seek anywhere in a Result */
>>>     }
>>>     flags;
>>> }
>>>DB_DATABASE;
>>>
>>>All drivers functions that took a DB_DATABASE argument were (or have to
>>>be) modified so that they receive now a DB_DATABASE pointer argument.
>>>
>>>The interface of open_database() driver function has changed. Now this
>>>function must fill the DB_DATABASE structure.
>>>
>>>As the database version is stored in this structure, the 'version'
>>>argument of some driver functions has been removed.
>>>
>>>
>>>(2) Two new functions must be implemented in a database driver:
>>>
>>>* format_blob(): This function transforms a blob value into a string value
>>>that can be inserted into a SQL query.
>>>
>>>* blob_read(): Returns the value of a BLOB field.
>>>
>>>As usual, these functions are documented in the postgresql driver.
>>>
>>>They are void stubs in the sqlite2 driver, as sqlite2 does not support
>>>blobs.
>>>
>>>
>>>(3) Two new constants were added that represent new field datatypes:
>>>
>>>* DB_T_SERIAL, for autoincrement fields.
>>>* DB_T_BLOB, for blob fields.
>>>
>>>
>>>(4) A special comment for Nigel :-)
>>>
>>>SQLite driver dataset C++ function is a mess. The guy who wrote it did a
>>>very bad C++ job.
>>>
>>>At the moment, I had to hack them to support blobs. But when you read a
>>>blob field, its contents are copied three times by this API before
>>>raising the Gambas user variables!
>>>
>>>I think all that *@#! must be destroyed, and that I should make an
>>>emulation of direct-access result set in the database component for
>>>database backends that only support forward-only result set. It will
>>>benefits ODBC drivers that are in the same situation.
>>>
>>>
>>>(5) A special comment for Andrea :-)
>>>
>>>The implementation of autoincrement field and blob is just a stub at the
>>>moment. I don't know ODBC enough to do the job. Good luck!
>>>
>>>
>>>(6) A special comment for Daniel :-)
>>>
>>>Same remark for Firebird. I have the source, but I can't compile it
>>>because of missing libraries on Mandriva :-(
>>>
>>>Best regards to all three,
>>>      
>>>
>>hi benoit
>>i don't understand
>>i read the postgres driver and i don't see who call read_blob and
>>format_blob
>>the call is in the driver or in gambas
>>i make more test and it is any time query_fill called for blob!!!
>>
>>daniel
>>
>>    
>>
>
>format_blob() and blob_read() are two new driver functions that are used by 
>the database component. No other function in the driver should call them.
>
>query_fill() should return NULL for blob fields. The database component will 
>call blob_read() instead, when detecting that a result field has the 
>DB_T_BLOB datatype, as returned by the field_type() driver function.
>
>format_blob() is used by the database component when it creates a SQL query.
>
>I hope things are clearer now :-)
>
>Regards,
>
>  
>
yes clear now
but i have now a error "type mismatch: wanted string. got blob instead" 
when i want to fill a tableview
and if i use a command look like this
result = con1.Exec("select * from mytable")
  result.MoveLast()
  PRINT result!my_blob.data
it's ok the blob is printed (blob_read and blob_unquote is called)

daniel





More information about the Devel mailing list