odbc help ( PATCH )

Vladimir Sekissov <>
Fri Nov 29 00:47:17 CET 2002


Hi,

olgeni> Looking for clues... I compiled the odbc application (R9B) using
olgeni> libiodbc, installed odbcserver in priv/bin by hand, and found a
olgeni> working DSN using the sample iodbc's odbctest application. I'm using
olgeni> the postgresql driver (7.2.3).
olgeni> 

The problem is that PostgreSQL ODBC driver is version 2.5 and knows
nothing about scrollable cursors. This patch solves the
problem with one small restriction. The followed function calls return
{error,driver_does_not_support_function}:

odbc:select(Conn, Pos, N) when Pos = {relative, P} | {absolute, P}
odbc:prev(ConnectionReference)

But most databases don't support back scrolling so we can live
without it too. All other functionality is ok at least for me.

Best Regards,
Vladimir Sekissov

-------------------------- cut here ----------------------------------
--- otp_src_R9B-0/lib/odbc/c_src/odbcserver.c.orig	2002-11-29 03:41:50.000000000 +0500
+++ tp_src_R9B-0/lib/odbc/c_src/odbcserver.c	2002-11-29 04:01:04.000000000 +0500
@@ -1332,23 +1332,26 @@
 			     (SQLPOINTER)&supportMask,
 			     sizeof(supportMask),
 			     NULL))) {
-    exit_on_failure("SQLGetInfo failed in dbInfo");
-  }
-     
-  if (supportMask & SQL_CA1_ABSOLUTE ) {
-    ei_x_encode_atom(&dynamic_buffer(state), "true");
-  }
-  else {
-    ei_x_encode_atom(&dynamic_buffer(state), "false");    
-  }
-  
-  if (supportMask & SQL_CA1_RELATIVE) {
-    ei_x_encode_atom(&dynamic_buffer(state), "true");    
-  }
-  else {
+    /*exit_on_failure("SQLGetInfo failed in dbInfo");*/
+    ei_x_encode_atom(&dynamic_buffer(state), "false");
     ei_x_encode_atom(&dynamic_buffer(state), "false");
+  } else {
+	
+     if (supportMask & SQL_CA1_ABSOLUTE ) {
+	ei_x_encode_atom(&dynamic_buffer(state), "true");
+     }
+     else {
+	ei_x_encode_atom(&dynamic_buffer(state), "false");    
+     }
+  
+     if (supportMask & SQL_CA1_RELATIVE) {
+	ei_x_encode_atom(&dynamic_buffer(state), "true");    
+     }
+     else {
+	ei_x_encode_atom(&dynamic_buffer(state), "false");
+     }
   }
-  
+   
   msg.buffer = (byte *)dynamic_buffer(state).buff;
   msg.length = dynamic_buffer(state).index;
   msg.dyn_alloc = TRUE;

-------------------------- cut here ----------------------------------

olgeni> Looking for clues... I compiled the odbc application (R9B) using
olgeni> libiodbc, installed odbcserver in priv/bin by hand, and found a
olgeni> working DSN using the sample iodbc's odbctest application. I'm using
olgeni> the postgresql driver (7.2.3).
olgeni> 
olgeni> The odbc app complains:
olgeni> 
olgeni> ()12> odbc:connect ("dsn=octopus;server=localhost;port=5432;database=octopus;uid=octopus", []).
olgeni> SQLGetInfo failed in dbInfo
olgeni> =ERROR REPORT==== 13-Nov-2002::15:57:08 ===
olgeni> ODBC: exit signal from port program:normal
olgeni> {error,{port_exit,normal}}
olgeni> ()13>
olgeni> =ERROR REPORT==== 13-Nov-2002::15:57:08 ===
olgeni> ** Generic server <0.81.0> terminating
olgeni> ** Last message in was {'EXIT',#Port<0.63>,normal}
olgeni> ** When Server state == {state,#Port<0.63>,
olgeni>                                {<0.79.0>,#Ref<0.0.0.285>},
olgeni>                                <0.79.0>,
olgeni>                                undefined,
olgeni>                                on,
olgeni>                                undefined,
olgeni>                                undefined,
olgeni>                                connecting,
olgeni>                                false,
olgeni>                                false,
olgeni>                                []}
olgeni> ** Reason for termination ==
olgeni> ** {port_exit,normal}
olgeni> 
olgeni> odbc:connect performs application:start (odbc), so it should be sufficient (?).
olgeni> 
olgeni> Has anybody managed to get postgresql/iodbc/odbc working? =)
olgeni> 
olgeni> -- 
olgeni> jimmy



More information about the erlang-questions mailing list