[Gambas-devel] Database driver update in 1.9.23

Benoit Minisini gambas at ...1...
Mon Jan 2 11:16:27 CET 2006


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,

-- 
Benoit Minisini





More information about the Devel mailing list