HERE!! :-) Thread safe abstraction layer
Posted on 2002-07-08
I've got to develop a database abstraction layer to be used with Oracle and PostgreSQL. It'll have to be fast, so I'm using a bunch of ifdefs and letting the compiler do the work. (so, only one will be compiled).
ODBC is not an option because we need native data handling.
The problem is that this abstraction layer must be fully transparent (IE, the program will call just one function without taking care of handle casts) AND thread safe (we'll open more than one connection -- will be using posix threads).
There's more than one function, so the easiest solution would be placing a global variable for the connection handle/result, but this would break the thread safety. Another option is to give/get the handle variables from/to the functions, but this would break the "full transparency" of the abstraction layer, which is (unfortunatelly) essential to the project.
I'd like to hear you suggestions. If necessary, I can post some of the code here or email it to you.
Thanks a lot.