Thread: RE: [cx-oracle-users] Re: Choosing client libraries
Brought to you by:
atuining
From: Amaury F. <Ama...@gl...> - 2006-01-24 16:14:57
|
Anthony wrote: > To understand what I mean, try loading a cx_Oracle module compiled=20 > against Oracle 9i with an Oracle 8i client. You will get a=20 > messagebox indicating that the symbol OCISessionGet could=20 > not be located in oci.dll. If you have a suggestion about how=20 > to get around that problem __without__ involving a huge=20 > rewrite of cx_Oracle to call everything dynamically I'm all ears. This is what I did some years ago with the old OCI7 function. At the time, it was the only way to have a program run with=20 both Oracle7 and Oracle 8i, even if you use only functions=20 that belong to both libraries. My solution is: - cx_Oracle does not link with any Oracle library. - instead, we provide an implementation for each OCI* function, which simply loads dynamically the Oracle client, bind the function, and call it. (I just counted 54 different OCI functions in cx_Oracle!) Below is a sample, for the old 'olog' function. This change would not touch any existing cx_Oracle file, Only one more file is compiled and linked with cx_Oracle. I think the same trick would also work on some other platforms. At the end, we could have a "dynamic" version of cx_Oracle! ----------------------------- typedef sword (*OCIPROC)(); HINSTANCE hOCI =3D NULL; // Find the OCI library HINSTANCE check_dll() { // This could be enhanced to choose the desired library if (!hOCI) hOCI =3D LoadLibrary("oci.dll"); return hOCI; } // Load the OCI library and find the function OCIPROC check_function(char *name, OCIPROC *fn) { if( *fn ) return *fn; if( !check_dll() ) return NULL; *fn =3D (OCIPROC)GetProcAddress( hOCI, name ); return *fn; } // All OCI functions must be written like this sword olog(LDA *lda, ub1 *hda, text *uid, sword uidl, text *pswd, sword pswdl, text *conn, sword connl, ub4 mode) { static OCIPROC p_olog=3DNULL; if( check_function("olog", &p_olog)) return p_olog(lda,hda,uid,uidl,pswd,pswdl,conn,connl,mode); else return 1; // error } --=20 Amaury Forgeot d'Arc Ubix Development www.ubitrade.com |
From: Amaury F. d'A. <ama...@gm...> - 2006-01-25 10:07:49
|
Anthony wrote: > Ok. It sounds like a bunch of grunt work but nothing particularly > difficult. There is the necessity of "copying" the Oracle header files Not necessarily. You may require that compiling a cx_Oracle distribution needs the latest Oracle header files for the module to contain all features= . Then, when installed on another machine, the module will silently disable some features if they do not match the Oracle version. > and there is the question of performance as well. Any thoughts on > those? Well, if the code is carefully written and uses inline functions, the overhead could be reduced to a simple check on a static variable. -- Amaury |
From: Anthony T. <ant...@gm...> - 2006-01-25 23:31:52
|
On 1/25/06, Amaury Forgeot d'Arc <ama...@gm...> wrote: > Anthony wrote: > > Ok. It sounds like a bunch of grunt work but nothing particularly > > difficult. There is the necessity of "copying" the Oracle header files > > Not necessarily. You may require that compiling a cx_Oracle distribution > needs the latest Oracle header files for the module to contain all featur= es. > > Then, when installed on another machine, the module will silently > disable some features if they do not match the Oracle version. What I meant is that shadow functions will have to be defined which call the real functions. These will look very similar to the ones defined in the Oracle include files. If/when such things change those changes will have to be reflected. Note that this technique assumes that Oracle __never__ changes or removes their API for a particular function. They only add functions. I'm not convinced this will always be the case which makes this technique somewhat of a risk -- fairly low but still a risk. > > and there is the question of performance as well. Any thoughts on > > those? > > Well, if the code is carefully written and uses inline functions, > the overhead could be reduced to a simple check on a static > variable. True. The only overhead would be during import or first reference of a particular function and that would be relatively small. > -- > Amaury > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmdlnk&kid=103432&bid#0486&dat=121642 > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |
From: Anthony T. <ant...@gm...> - 2006-01-24 20:31:11
|
On 1/24/06, Amaury Forgeotdarc <Ama...@gl...> wrote: > Anthony wrote: > > To understand what I mean, try loading a cx_Oracle module compiled > > against Oracle 9i with an Oracle 8i client. You will get a > > messagebox indicating that the symbol OCISessionGet could > > not be located in oci.dll. If you have a suggestion about how > > to get around that problem __without__ involving a huge > > rewrite of cx_Oracle to call everything dynamically I'm all ears. > > This is what I did some years ago with the old OCI7 function. > At the time, it was the only way to have a program run with > both Oracle7 and Oracle 8i, even if you use only functions > that belong to both libraries. > > My solution is: > - cx_Oracle does not link with any Oracle library. > - instead, we provide an implementation for each OCI* function, > which simply loads dynamically the Oracle client, bind the > function, and call it. > (I just counted 54 different OCI functions in cx_Oracle!) > > Below is a sample, for the old 'olog' function. > > This change would not touch any existing cx_Oracle file, > Only one more file is compiled and linked with cx_Oracle. > > I think the same trick would also work on some other platforms. > At the end, we could have a "dynamic" version of cx_Oracle! Ok. It sounds like a bunch of grunt work but nothing particularly difficult. There is the necessity of "copying" the Oracle header files and there is the question of performance as well. Any thoughts on those? Anthony |