On Sat, Apr 23, 2005, Ilja Booij <[EMAIL PROTECTED]> said:

> On 4/22/05, Geo Carncross <[EMAIL PROTECTED]> wrote:
>> 
>> I'm thinking about allowing database drivers to abstract away any
>> function in db.c (or anything else that "generates" SQL).
>> 
>> It was brought up before for some postgresql-specific things or mysql-
>> specific things, but it seems to me that it could be used for a SQL-free
>> database interface like metakit [or something more nefarious]
>> 
>> Any thoughts on those abstractions? My "easy" methods all involve
>> mucking about with ELF-specific nonsense or the dynamic linker...

Really easy:
http://developer.gnome.org/doc/API/glib/glib-dynamic-loading-of-modules.html

We can handle the overrides by importing a symbol like this:

char * db_driver_overrides = { "db_foo", "db_bar", NULL };

We might need to change all db_* function calls to a function table:

db_connect() would become db.connect() or db->connect(); (whatever)

That makes it really easy to do this:

    g_module_symbol(GModule *module,
                    "connect",
                    &(db->connect));

> Wouldn't it be possible to *abuse* gettext for this kind of thing.
> Mind you, it would only buy one the ability to have different SQL
> queries for different drivers, and not something fancy like different
> C-functions for different drivers. 

Wow, that's rather creative! But you'd still need different C functions to
handle anything more than the simplest of differences in syntax. Plus it
introduces a dependency on gettext, and possibly would make life difficult
if we were to gettextify the UI of the command line utilities (since we'd
be working with two different sets of files and 'language' domains).

Aaron



Reply via email to