[unixODBC-dev] odbcinst-less configuration

Brian Bruns brian at bruns.com
Tue Jun 28 22:28:54 BST 2011


Hi all,

I couldn't figure out any way to connect to a database without having
an odbcinst.ini entry for the driver.  iODBC allows for the DRIVER
attribute to specify the fullpath of the shared library file, but it
appears to my cursory reading of SQLDriverConnect that unixODBC does
not.  Attached is a patch that makes it happen.  If I'm totally
off-base and unixODBC does indeed allow this, please let me know.

Cheers,

Brian

--------


--- unixODBC-2.3.0/DriverManager/SQLDriverConnect.c     2010-04-13
12:38:26.000000000 -0400
+++ SQLDriverConnect.c.new      2011-06-28 17:20:44.000000000 -0400
@@ -1066,14 +1066,21 @@
     driver = __get_attribute_value( &con_struct, "DRIVER" );
     if ( driver )
     {
-        /*
-         * look up the driver in the ini file
-         */
+        if ( driver[0] == '/') {
+           /*
+            * DRIVER is the fullpath to the library
+            */
+           strncpy ( lib_name, driver, INI_MAX_PROPERTY_VALUE );
+           lib_name[INI_MAX_PROPERTY_VALUE] = '\0';
+        } else {
+           /*
+            * look up the driver in the ini file
+            */

-        strcpy( driver_name, driver );
+           strcpy( driver_name, driver );

 #ifdef PLATFORM64
-        SQLGetPrivateProfileString( driver, "Driver64", "",
+           SQLGetPrivateProfileString( driver, "Driver64", "",
                 lib_name, sizeof( lib_name ), "ODBCINST.INI" );

                if ( lib_name[ 0 ] == '\0' )
@@ -1082,9 +1089,10 @@
                        lib_name, sizeof( lib_name ), "ODBCINST.INI" );
                }
 #else
-        SQLGetPrivateProfileString( driver, "Driver", "",
+           SQLGetPrivateProfileString( driver, "Driver", "",
                 lib_name, sizeof( lib_name ), "ODBCINST.INI" );
 #endif
+        }

         if ( lib_name[ 0 ] == '\0' )
         {


More information about the unixODBC-dev mailing list