List:Commits« Previous MessageNext Message »
From:pharvey Date:March 6 2006 3:49am
Subject:Connector/ODBC 3.51 commit: r43 - / MYODBCDbg/MYODBCDbgLib MYODBCDbg/include myodbc3
View as plain text  
Added:
   MYODBCDbg/MYODBCDbgLib/MYODBCDbgGetFileDefault.c
Removed:
   MYODBCDbg/MYODBCDbgLib/MYODBCDbgInit.c
Modified:
   MYODBCDbg/MYODBCDbgLib/MYODBCDbgLib.vpj
   MYODBCDbg/include/MYODBCDbg.h
   README.debug
   connector-odbc3.vpw
   myodbc3/connect.c
Log:
refinements for debug/trace

Copied: MYODBCDbg/MYODBCDbgLib/MYODBCDbgGetFileDefault.c (from rev 41,
MYODBCDbg/MYODBCDbgLib/MYODBCDbgInit.c)
===================================================================
--- MYODBCDbg/MYODBCDbgLib/MYODBCDbgInit.c	2006-03-03 12:19:55 UTC (rev 41)
+++ MYODBCDbg/MYODBCDbgLib/MYODBCDbgGetFileDefault.c	2006-03-06 03:49:05 UTC (rev 43)
@@ -0,0 +1,45 @@
+/*! 
+    \file     MYODBCDbgGetFileDefault.c
+    \author   Peter Harvey <pharvey@stripped>
+              Copyright (C) MySQL AB 2004-2005, Released under GPL.
+    \version  Connector/ODBC v3
+    \date     2005          
+    \brief    Code to provide debug information.
+    
+    \license  Copyright (C) 2000-2005 MySQL AB
+
+              This program is free software; you can redistribute it and/or modify
+              it under the terms of the GNU General Public License as published by
+              the Free Software Foundation; either version 2 of the License, or
+              (at your option) any later version.
+            
+              There are special exceptions to the terms and conditions of the GPL as it
+              is applied to this software. View the full text of the exception in file
+              EXCEPTIONS in the directory of this software distribution.
+            
+              This program is distributed in the hope that it will be useful,
+              but WITHOUT ANY WARRANTY; without even the implied warranty of
+              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+              GNU General Public License for more details.
+            
+              You should have received a copy of the GNU General Public License
+              along with this program; if not, write to the Free Software
+              Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+#include "../include/MYODBCDbg.h"
+
+const char *MYODBCDbgGetFileDefault()
+{
+    if ( getenv( "MYODBC_LOG" ) )
+        return getenv( "MYODBC_LOG" );
+
+#ifdef _UNIX_
+    return "d:t:S:O,/tmp/myodbc.log";
+#else
+    return "d:t:S:O,c::\\myodbc.log";
+#endif /* _UNIX */
+
+/* MYODBCDbgPrint( "start", ("Driver name: Connector/ODBC  Version: %s", SETUP_VERSION)
); */
+}
+#endif
+

Deleted: MYODBCDbg/MYODBCDbgLib/MYODBCDbgInit.c
===================================================================
--- MYODBCDbg/MYODBCDbgLib/MYODBCDbgInit.c	2006-03-06 00:56:46 UTC (rev 42)
+++ MYODBCDbg/MYODBCDbgLib/MYODBCDbgInit.c	2006-03-06 03:49:05 UTC (rev 43)
@@ -1,48 +0,0 @@
-/*! 
-    \file     MYODBCDbgInit.c
-    \author   Peter Harvey <pharvey@stripped>
-              Copyright (C) MySQL AB 2004-2005, Released under GPL.
-    \version  Connector/ODBC v3
-    \date     2005          
-    \brief    Code to provide debug information.
-    
-    \license  Copyright (C) 2000-2005 MySQL AB
-
-              This program is free software; you can redistribute it and/or modify
-              it under the terms of the GNU General Public License as published by
-              the Free Software Foundation; either version 2 of the License, or
-              (at your option) any later version.
-            
-              There are special exceptions to the terms and conditions of the GPL as it
-              is applied to this software. View the full text of the exception in file
-              EXCEPTIONS in the directory of this software distribution.
-            
-              This program is distributed in the hope that it will be useful,
-              but WITHOUT ANY WARRANTY; without even the implied warranty of
-              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-              GNU General Public License for more details.
-            
-              You should have received a copy of the GNU General Public License
-              along with this program; if not, write to the Free Software
-              Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-#include "../include/MYODBCDbg.h"
-
-void MYODBCDbgInit( void )
-{
-    if ( getenv( "MYODBC_LOG" ) )
-    {
-        MYODBCDbgSetFile( getenv( "MYODBC_LOG" ) );
-    }
-    else
-    {
-#ifdef _UNIX_
-        MYODBCDbgSetFile( "d:t:S:O,/tmp/myodbc.log" );
-#else
-        MYODBCDbgSetFile( "d:t:S:O,c::\\myodbc.log" );
-#endif /* _UNIX */
-    }
-
-    MYODBCDbgPrint( "start", ("Driver name: Connector/ODBC  Version: %s", SETUP_VERSION)
);
-}
-

Modified: MYODBCDbg/MYODBCDbgLib/MYODBCDbgLib.vpj
===================================================================
--- MYODBCDbg/MYODBCDbgLib/MYODBCDbgLib.vpj	2006-03-06 00:56:46 UTC (rev 42)
+++ MYODBCDbg/MYODBCDbgLib/MYODBCDbgLib.vpj	2006-03-06 03:49:05 UTC (rev 43)
@@ -191,7 +191,6 @@
 			<F N="MYODBCDbgFunctionsString.c"/>
 			<F N="MYODBCDbgHandleTypeString.c"/>
 			<F N="MYODBCDbgInfoTypeString.c"/>
-			<F N="MYODBCDbgInit.c"/>
 			<F N="MYODBCDbgPosTypeString.c"/>
 			<F N="MYODBCDbgReturnString.c"/>
 			<F N="MYODBCDbgStmtAttrString.c"/>

Modified: MYODBCDbg/include/MYODBCDbg.h
===================================================================
--- MYODBCDbg/include/MYODBCDbg.h	2006-03-06 00:56:46 UTC (rev 42)
+++ MYODBCDbg/include/MYODBCDbg.h	2006-03-06 03:49:05 UTC (rev 43)
@@ -146,8 +146,13 @@
             Call this before using any of the MYODBCDbg functions.
             
     \sa     MYODBCDbgPrint
+            MYODBCDbgSetFile
 */
-void MYODBCDbgInit( void );
+#ifdef DBUG_OFF
+#define MYODBCDbgInit
+#else
+void MYODBCDbgInit();
+#endif
 
 /*! 
     \brief  Returns a string version of the position type as found in SQLSetPos.
@@ -233,11 +238,97 @@
 */
 const char *MYODBCDbgTransactionTypeString( SQLSMALLINT nType );
 
+/*! 
+    \brief  Sets debug control information.
+                
+            Sets debug control information including filename for output.
+
+    \note   This has not effect if DBUG_OFF is set.
+
+    \param  pszControl  This is a "const char *" which indicates the control
+                        information. Example;
+
+                        "d:t:S:O,/tmp/myodbc.log"
+    
+    \return void
+    
+    \sa     MYODBCDbgInit
+            MYODBCDbgFini
+            MYODBCDbgPrint
+*/
 #define MYODBCDbgSetFile DBUG_PUSH
+
+/*! 
+    \brief  Inits debug for a function.
+                
+            This declares some working vars for dbg interface and logs that
+            we have entered the function. 
+
+    \note   This has not effect if DBUG_OFF is set.
+
+    \param  pszMsg  This is a "const char *" which can be any message.
+    
+    \return void
+    
+    \sa     MYODBCDbgInit
+            MYODBCDbgFini
+            MYODBCDbgPrint
+            MYODBCDbgReturn
+*/
 #define MYODBCDbgEnter DBUG_ENTER
+
+/*! 
+    \brief  Prints useful debug information.
+                
+            This processes the given keyword & argslist and prints the result
according 
+            to the debug control information.
+
+    \note   This has not effect if DBUG_OFF is set.
+
+    \param  keyword
+    \param  arglist 
+    
+    \return void
+    
+    \sa     MYODBCDbgInit
+            MYODBCDbgFini
+*/
 #define MYODBCDbgPrint DBUG_PRINT
+
+/*! 
+    \brief  Stops the debug.
+
+            Stops the debug and frees resources allocated in MYODBCDbgInit.
+
+    \note   This has not effect if DBUG_OFF is set.
+
+    \return void
+    
+    \sa     MYODBCDbgInit
+            MYODBCDbgFini
+*/
 #define MYODBCDbgFini {}
 
+/*! 
+    \brief  Returns from a function.
+                
+            Prints that we are leaving a function and what the retval is.
+
+    \note   This has not effect if DBUG_OFF is set.
+
+    \param  SQLRETURN
+    
+    \return SQLRETURN
+    
+    \sa     MYODBCDbgInit
+            MYODBCDbgFini
+            MYODBCDbgEnter
+            MYODBCDbgReturn2
+            MYODBCDbgReturn3
+*/
+#ifdef DBUG_OFF
+#define MYODBCDbgReturn(A) return(A);
+#else
 #define MYODBCDbgReturn(STATUS) \
 { \
   SQLRETURN rc= (STATUS); \
@@ -245,7 +336,38 @@
   DBUG_RETURN( rc ); \
 }
 
+/*! 
+    \brief  Returns from a function.
+                
+            Prints that we are leaving a function and what the retval is.
+
+    \note   This has not effect if DBUG_OFF is set.
+
+    \param  SQLRETURN
+    
+    \return SQLRETURN
+    
+    \sa     MYODBCDbgInit
+            MYODBCDbgFini
+            MYODBCDbgEnter
+            MYODBCDbgReturn
+            MYODBCDbgReturn3
+*/
 #define MYODBCDbgReturn2 DBUG_RETURN
+
+/*! 
+    \brief  Returns from a function.
+                
+            Prints that we are leaving a function.
+
+    \note   This has not effect if DBUG_OFF is set.
+
+    \sa     MYODBCDbgInit
+            MYODBCDbgFini
+            MYODBCDbgEnter
+            MYODBCDbgReturn2
+            MYODBCDbgReturn
+*/
 #define MYODBCDbgReturn3 DBUG_VOID_RETURN
 
 #endif

Modified: README.debug
===================================================================
--- README.debug	2006-03-06 00:56:46 UTC (rev 42)
+++ README.debug	2006-03-06 03:49:05 UTC (rev 43)
@@ -90,13 +90,42 @@
 the compiler turns this feature off. Turning it off may make the
 driver perform a little bit faster.
 
+This is, 99%, implemented in the MySQL client.
+
+TRACE
+-----
+
+This is a DSN attribute which is used to indicate the relevance
+of TRACEFILE. TRACEFILE is relevant if this is set to "ON".
+
+This is supported for compat. with unixODBC - FLAG_DEBUG must be 
+turned on to get trace output. 
+
+This is meaningless if DBUG_OFF has been set at build-time.
+
+TRACEFILE
+---------
+
+This DSN attribute specifies the trace file name. The format
+string ("d:t:F:L:S:A") will automatically be used. This is only
+used if TRACE is turned "ON".
+
+TRACEFILE has precedence over MYODBC_LOG.
+ 
+This is supported for compat. with unixODBC - FLAG_DEBUG must be 
+turned on to get trace output. 
+
+This is meaningless if DBUG_OFF has been set at build-time.
+
 FLAG_DEBUG
 ----------
 
 This is a DSN config option which can be set to turn on trace 
-output. This does nothing if DBUG_OFF has been set. The location
-of the trace output is dependent upon MYODBC_LOG.
+output. The location of the trace output is dependent upon 
+MYODBC_LOG (or TRACEFILE).
 
+This is meaningless if DBUG_OFF has been set at build-time.
+
 MYODBC_LOG 
 ----------
 
@@ -108,15 +137,19 @@
            WIN : "d:t:S:O,c::\\myodbc.log"
            UNIX: "d:t:S:O,/tmp/myodbc.log"
 
+This is meaningless if DBUG_OFF has been set at build-time.
+
 FLAG_LOG_QUERY
 --------------
 
 This is a DSN config option which can be set to turn on feature
 to log queries to a file.
 
-This does nothing if DBUG_OFF has been set. The location
-of the trace output is dependent upon DRIVER_QUERY_LOGFILE.
+The location of the trace output is dependent upon 
+DRIVER_QUERY_LOGFILE.
 
+This is meaningless if DBUG_OFF has been set at build-time.
+
 DRIVER_QUERY_LOGFILE
 --------------------
 
@@ -126,6 +159,17 @@
            UNIX: "/tmp/myodbc.sql"
 
 
+SQL_OPT_TRACE
+-------------
+
+This connection attribute is implemented in the Driver Manager.
+
+SQL_OPT_TRACEFILE
+-----------------
+
+This connection attribute is implemented in the Driver Manager.
+
+
 SUMMARY
 ---------------------------------------------------------------
 

Modified: connector-odbc3.vpw
===================================================================
--- connector-odbc3.vpw	2006-03-06 00:56:46 UTC (rev 42)
+++ connector-odbc3.vpw	2006-03-06 03:49:05 UTC (rev 43)
@@ -20,6 +20,7 @@
 		<Project File="MYQTODBCCls/MYQTODBCCls.vpj"/>
 		<Project File="MYQTODBCCls/MYQTODBCClsApp/MYQTODBCClsApp.vpj"/>
 		<Project File="MYQTODBCCls/MYQTODBCClsLib/MYQTODBCClsLib.vpj"/>
+		<Project File="../mysql-include.vpj"/>
 		<Project File="scripts/scripts.vpj"/>
 		<Project File="test/test.vpj"/>
 	</Projects>

Modified: myodbc3/connect.c
===================================================================
--- myodbc3/connect.c	2006-03-06 00:56:46 UTC (rev 42)
+++ myodbc3/connect.c	2006-03-06 03:49:05 UTC (rev 43)
@@ -41,80 +41,80 @@
 #include "myodbc3.h"
 
 #ifndef _UNIX_
-#include <odbcinst.h>
+    #include <odbcinst.h>
 #endif
 
 #include "../myodbc3u/MYODBCUtil.h"
 
 #ifndef CLIENT_NO_SCHEMA
-#define CLIENT_NO_SCHEMA      16
+    #define CLIENT_NO_SCHEMA      16
 #endif
 
 static SQLRETURN set_connect_defaults(DBC *dbc)
 {
-  SQLRETURN error= 0;
-  MYODBCDbgEnter("set_connect_defaults");
+    SQLRETURN error= 0;
+    MYODBCDbgEnter("set_connect_defaults");
 #ifndef DBUG_OFF
-  if (dbc->flag & FLAG_LOG_QUERY && !dbc->query_log)
-    dbc->query_log= init_query_log();
+    if (dbc->flag & FLAG_LOG_QUERY && !dbc->query_log)
+        dbc->query_log= init_query_log();
 #endif
-  /* Set STMT error prefix, one time */
-  strxmov(dbc->st_error_prefix,MYODBC3_ERROR_PREFIX,"[mysqld-",
-	  dbc->mysql.server_version,"]",NullS);
+    /* Set STMT error prefix, one time */
+    strxmov(dbc->st_error_prefix,MYODBC3_ERROR_PREFIX,"[mysqld-",
+            dbc->mysql.server_version,"]",NullS);
 
-  /*
-    Validate pre-connection options like AUTOCOMMIT
-    and TXN_ISOLATIONS from SQLSetConnectAttr
-  */
+    /*
+      Validate pre-connection options like AUTOCOMMIT
+      and TXN_ISOLATIONS from SQLSetConnectAttr
+    */
 
-  /* AUTOCOMMIT */
-  if ((dbc->commit_flag == CHECK_AUTOCOMMIT_OFF))
-  {
-    if (!(trans_supported(dbc)) || (dbc->flag & FLAG_NO_TRANSACTIONS))
-      error= set_conn_error(dbc,MYERR_01S02,
-			    "\
+    /* AUTOCOMMIT */
+    if ((dbc->commit_flag == CHECK_AUTOCOMMIT_OFF))
+    {
+        if (!(trans_supported(dbc)) || (dbc->flag & FLAG_NO_TRANSACTIONS))
+            error= set_conn_error(dbc,MYERR_01S02,
+                                  "\
 Transactions are not enabled, Option value SQL_AUTOCOMMIT_OFF changed to \
 SQL_AUTOCOMMIT_ON",
-			    0);
-    else if (autocommit_on(dbc) &&
-	     (odbc_stmt(dbc,"SET AUTOCOMMIT=0") != SQL_SUCCESS))
-      MYODBCDbgReturn(SQL_ERROR);
-  }
-  else if ((dbc->commit_flag == CHECK_AUTOCOMMIT_ON) &&
-	   trans_supported(dbc) && !autocommit_on(dbc))
-  {
-    if (odbc_stmt(dbc,"SET AUTOCOMMIT=1") != SQL_SUCCESS)
-      MYODBCDbgReturn(SQL_ERROR);
-  }
-
-  if (!(dbc->txn_isolation & DEFAULT_TXN_ISOLATION))/* TXN_ISOLATION */
-  {
-    char buff[80];
-    const char *level;
-
-    if (dbc->txn_isolation & SQL_TXN_SERIALIZABLE)
-      level="SERIALIZABLE";
-    else if (dbc->txn_isolation & SQL_TXN_REPEATABLE_READ)
-      level="REPEATABLE READ";
-    else if (dbc->txn_isolation & SQL_TXN_READ_COMMITTED)
-      level="READ COMMITTED";
-    else
-      level="READ UNCOMMITTED";
-    if (trans_supported(dbc))
+                                  0);
+        else if (autocommit_on(dbc) &&
+                 (odbc_stmt(dbc,"SET AUTOCOMMIT=0") != SQL_SUCCESS))
+            MYODBCDbgReturn(SQL_ERROR);
+    }
+    else if ((dbc->commit_flag == CHECK_AUTOCOMMIT_ON) &&
+             trans_supported(dbc) && !autocommit_on(dbc))
     {
-      MYODBCDbgPrint("info",("setting transaction isolation to level '%s'",
-			 level));
-      sprintf(buff,"SET SESSION TRANSACTION ISOLATION LEVEL %s",level);
-      if (odbc_stmt(dbc,buff) != SQL_SUCCESS)
-	error= SQL_ERROR;
+        if (odbc_stmt(dbc,"SET AUTOCOMMIT=1") != SQL_SUCCESS)
+            MYODBCDbgReturn(SQL_ERROR);
     }
-    else
+
+    if (!(dbc->txn_isolation & DEFAULT_TXN_ISOLATION))/* TXN_ISOLATION */
     {
-      MYODBCDbgPrint("info",("SQL_ATTR_TXN_ISOLATION %ld ignored",
-			 dbc->txn_isolation));
+        char buff[80];
+        const char *level;
+
+        if (dbc->txn_isolation & SQL_TXN_SERIALIZABLE)
+            level="SERIALIZABLE";
+        else if (dbc->txn_isolation & SQL_TXN_REPEATABLE_READ)
+            level="REPEATABLE READ";
+        else if (dbc->txn_isolation & SQL_TXN_READ_COMMITTED)
+            level="READ COMMITTED";
+        else
+            level="READ UNCOMMITTED";
+        if (trans_supported(dbc))
+        {
+            MYODBCDbgPrint("info",("setting transaction isolation to level '%s'",
+                                   level));
+            sprintf(buff,"SET SESSION TRANSACTION ISOLATION LEVEL %s",level);
+            if (odbc_stmt(dbc,buff) != SQL_SUCCESS)
+                error= SQL_ERROR;
+        }
+        else
+        {
+            MYODBCDbgPrint("info",("SQL_ATTR_TXN_ISOLATION %ld ignored",
+                                   dbc->txn_isolation));
+        }
     }
-  }
-  MYODBCDbgReturn(error);
+    MYODBCDbgReturn(error);
 }
 
 
@@ -124,40 +124,40 @@
 */
 
 ulong get_client_flag(MYSQL *mysql, ulong option_flag,uint connect_timeout,
-		      char *init_stmt)
+                      char *init_stmt)
 {
-  ulong client_flag= CLIENT_ODBC;
-  MYODBCDbgEnter("get_client_flag");
+    ulong client_flag= CLIENT_ODBC;
+    MYODBCDbgEnter("get_client_flag");
 
-  mysql_init(mysql);
+    mysql_init(mysql);
 
-  if (option_flag & (FLAG_FOUND_ROWS | FLAG_SAFE))
-    client_flag|=   CLIENT_FOUND_ROWS;
-  if (option_flag & FLAG_NO_SCHEMA)
-    client_flag|=   CLIENT_NO_SCHEMA;
-  if (option_flag & (FLAG_BIG_PACKETS | FLAG_SAFE))
-    max_allowed_packet=~0L;
-  if (option_flag & FLAG_COMPRESSED_PROTO)
-    client_flag |=  CLIENT_COMPRESS;
-  if (option_flag & FLAG_IGNORE_SPACE)
-    client_flag |=  CLIENT_IGNORE_SPACE;
-    
-  client_flag |= CLIENT_MULTI_RESULTS;
+    if (option_flag & (FLAG_FOUND_ROWS | FLAG_SAFE))
+        client_flag|=   CLIENT_FOUND_ROWS;
+    if (option_flag & FLAG_NO_SCHEMA)
+        client_flag|=   CLIENT_NO_SCHEMA;
+    if (option_flag & (FLAG_BIG_PACKETS | FLAG_SAFE))
+        max_allowed_packet=~0L;
+    if (option_flag & FLAG_COMPRESSED_PROTO)
+        client_flag |=  CLIENT_COMPRESS;
+    if (option_flag & FLAG_IGNORE_SPACE)
+        client_flag |=  CLIENT_IGNORE_SPACE;
+
+    client_flag |= CLIENT_MULTI_RESULTS;
 #ifdef __WIN__
-  if (option_flag & FLAG_NAMED_PIPE)
-    mysql_options(mysql,MYSQL_OPT_NAMED_PIPE,NullS);
+    if (option_flag & FLAG_NAMED_PIPE)
+        mysql_options(mysql,MYSQL_OPT_NAMED_PIPE,NullS);
 #endif
 
-  if (option_flag & FLAG_USE_MYCNF)
-    mysql_options(mysql,MYSQL_READ_DEFAULT_GROUP,"odbc");
-  if (init_stmt && init_stmt[0])
-    mysql_options(mysql,MYSQL_INIT_COMMAND,init_stmt);
-  if (connect_timeout)
-    mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT,(char*) &connect_timeout);
+    if (option_flag & FLAG_USE_MYCNF)
+        mysql_options(mysql,MYSQL_READ_DEFAULT_GROUP,"odbc");
+    if (init_stmt && init_stmt[0])
+        mysql_options(mysql,MYSQL_INIT_COMMAND,init_stmt);
+    if (connect_timeout)
+        mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT,(char*) &connect_timeout);
 
-  MYODBCDbgPrint("info",("option_flag: %ld  client_flag: %ld", option_flag,
-		     client_flag));
-  MYODBCDbgReturn(client_flag);
+    MYODBCDbgPrint("info",("option_flag: %ld  client_flag: %ld", option_flag,
+                           client_flag));
+    MYODBCDbgReturn(client_flag);
 }
 
 
@@ -168,12 +168,12 @@
 
 void copy_if_not_empty(char *to,uint max_length, char *from,int length)
 {
-  if (from)
-  {
-    if (length == SQL_NTS)
-      length= max_length-1;
-    strmake(to,from,length);
-  }
+    if (from)
+    {
+        if (length == SQL_NTS)
+            length= max_length-1;
+        strmake(to,from,length);
+    }
 }
 
 
@@ -190,88 +190,90 @@
                               SQLCHAR FAR *  szAuthStr, 
                               SQLSMALLINT    cbAuthStr )
 {
-  char host[64],user[64],passwd[64],dsn[NAME_LEN+1],database[NAME_LEN+1];
-  char port[10],flag[10],init_stmt[256],*dsn_ptr;
-  char szTRACE[FILENAME_MAX+1]= "";
-  char socket[256]= "";
-  ulong flag_nr,client_flag;
-  uint port_nr= 0;
-  DBC FAR *dbc= (DBC FAR*) hdbc;
-  MYODBCDbgEnter("SQLConnect");
+    char host[64],user[64],passwd[64],dsn[NAME_LEN+1],database[NAME_LEN+1];
+    char port[10],flag[10],init_stmt[256],*dsn_ptr;
+    char szTRACE[FILENAME_MAX+1]= "";
+    char socket[256]= "";
+    ulong flag_nr,client_flag;
+    uint port_nr= 0;
+    DBC FAR *dbc= (DBC FAR*) hdbc;
+    MYODBCDbgEnter("SQLConnect");
 
-  if (dbc->mysql.net.vio != 0)
-    MYODBCDbgReturn(set_conn_error(hdbc,MYERR_08002,NULL,0));
+    if (dbc->mysql.net.vio != 0)
+        MYODBCDbgReturn(set_conn_error(hdbc,MYERR_08002,NULL,0));
 
-  /* Reset error state */
-  CLEAR_DBC_ERROR(dbc);
+    /* Reset error state */
+    CLEAR_DBC_ERROR(dbc);
 
-  dsn_ptr= fix_str(dsn, (char*) szDSN, cbDSN);
-  if (dsn_ptr && !dsn_ptr[0])
-    MYODBCDbgReturn(set_conn_error(hdbc, MYERR_S1000, "Invalid Connection
Parameters",0));
+    dsn_ptr= fix_str(dsn, (char*) szDSN, cbDSN);
+    if (dsn_ptr && !dsn_ptr[0])
+        MYODBCDbgReturn(set_conn_error(hdbc, MYERR_S1000, "Invalid Connection
Parameters",0));
 
-  SQLGetPrivateProfileString(dsn_ptr,"user","", user, sizeof(user),
MYODBCUtilGetIniFileName( TRUE ) );
-  SQLGetPrivateProfileString(dsn_ptr,"password","", passwd, sizeof(passwd),
MYODBCUtilGetIniFileName( TRUE ) );
-  SQLGetPrivateProfileString(dsn_ptr,"server","localhost", host, sizeof(host),
MYODBCUtilGetIniFileName( TRUE ) );
-  SQLGetPrivateProfileString(dsn_ptr,"database",dsn_ptr, database, sizeof(database),
MYODBCUtilGetIniFileName( TRUE ) );
-  SQLGetPrivateProfileString(dsn_ptr,"port","0", port, sizeof(port),
MYODBCUtilGetIniFileName( TRUE ) );
-  port_nr= (uint) atoi(port);
-  SQLGetPrivateProfileString(dsn_ptr,"option","0", flag, sizeof(flag),
MYODBCUtilGetIniFileName( TRUE ) );
-  flag_nr= (ulong) atol(flag);
+    SQLGetPrivateProfileString(dsn_ptr,"user","", user, sizeof(user),
MYODBCUtilGetIniFileName( TRUE ) );
+    SQLGetPrivateProfileString(dsn_ptr,"password","", passwd, sizeof(passwd),
MYODBCUtilGetIniFileName( TRUE ) );
+    SQLGetPrivateProfileString(dsn_ptr,"server","localhost", host, sizeof(host),
MYODBCUtilGetIniFileName( TRUE ) );
+    SQLGetPrivateProfileString(dsn_ptr,"database",dsn_ptr, database, sizeof(database),
MYODBCUtilGetIniFileName( TRUE ) );
+    SQLGetPrivateProfileString(dsn_ptr,"port","0", port, sizeof(port),
MYODBCUtilGetIniFileName( TRUE ) );
+    port_nr= (uint) atoi(port);
+    SQLGetPrivateProfileString(dsn_ptr,"option","0", flag, sizeof(flag),
MYODBCUtilGetIniFileName( TRUE ) );
+    flag_nr= (ulong) atol(flag);
 
 #ifdef _UNIX_
-  SQLGetPrivateProfileString(dsn_ptr,"socket", "", socket, sizeof(socket),
MYODBCUtilGetIniFileName( TRUE ) );
+    SQLGetPrivateProfileString(dsn_ptr,"socket", "", socket, sizeof(socket),
MYODBCUtilGetIniFileName( TRUE ) );
 #endif
 
-  SQLGetPrivateProfileString(dsn_ptr,"stmt", "", init_stmt, sizeof(init_stmt),
MYODBCUtilGetIniFileName( TRUE ) );
-  SQLGetPrivateProfileString(dsn_ptr, "TRACE", "", szTRACE, sizeof(szTRACE), 
MYODBCUtilGetIniFileName( TRUE ) );
-  if (szTRACE[0] == '0' || szTRACE[0] == 'N' || szTRACE[0] == 'n' ||
-      ((szTRACE[0] == 'O' || szTRACE[0] == 'o') &&
-       (szTRACE[1] == 'N' || szTRACE[1] == 'n')))
-  {
-    char  szTRACEFILE[FILENAME_MAX+1]= "";
-    char  szMYODBC_LOG[FILENAME_MAX+20]= "";
-    SQLGetPrivateProfileString(dsn_ptr, "TRACEFILE", "", szTRACEFILE,
sizeof(szTRACEFILE), MYODBCUtilGetIniFileName( TRUE ) );
-    if (*szTRACEFILE)
+    SQLGetPrivateProfileString(dsn_ptr,"stmt", "", init_stmt, sizeof(init_stmt),
MYODBCUtilGetIniFileName( TRUE ) );
+
+#ifndef DBUG_OFF
+    if ( flag_nr & FLAG_DEBUG )
     {
-      sprintf(szMYODBC_LOG, "d:t:F:L:S:A,%s", szTRACEFILE);
-      MYODBCDbgSetFile(szMYODBC_LOG);
+        MYODBCDbgSetFile( "1" );
+
+        SQLGetPrivateProfileString(dsn_ptr, "TRACE", "", szTRACE, sizeof(szTRACE), 
MYODBCUtilGetIniFileName( TRUE ) );
+        if ( (szTRACE[0] == 'O' || szTRACE[0] == 'o') && (szTRACE[1] == 'N' ||
szTRACE[1] == 'n')))
+        {
+            char  szTRACEFILE[FILENAME_MAX+1]= "";
+            char  szMYODBC_LOG[FILENAME_MAX+20]= "";
+            SQLGetPrivateProfileString(dsn_ptr, "TRACEFILE", "", szTRACEFILE,
sizeof(szTRACEFILE), MYODBCUtilGetIniFileName( TRUE ) );
+            if (*szTRACEFILE)
+            {
+                sprintf(szMYODBC_LOG, "d:t:F:L:S:A,%s", szTRACEFILE);
+                MYODBCDbgSetFile( szMYODBC_LOG );
+            }
+        }
     }
-  }
-#ifndef DBUG_OFF
-  if (flag_nr & FLAG_DEBUG && ! _db_on_)
-    MYODBCDbgInit();  
 #endif
-  client_flag= get_client_flag(&dbc->mysql,flag_nr,(uint) dbc->login_timeout,
-			       init_stmt);
+    client_flag= get_client_flag(&dbc->mysql,flag_nr,(uint) dbc->login_timeout,
+                                 init_stmt);
 
-  copy_if_not_empty(passwd,sizeof(passwd), (char FAR*) szAuthStr,cbAuthStr);
-  copy_if_not_empty(user, sizeof(user), (char FAR *) szUID, cbUID);
+    copy_if_not_empty(passwd,sizeof(passwd), (char FAR*) szAuthStr,cbAuthStr);
+    copy_if_not_empty(user, sizeof(user), (char FAR *) szUID, cbUID);
 
-  /* socket[0] is always 0 if you are not under UNIX */
-  if (!mysql_real_connect(&dbc->mysql,
-                          host,
-                          user,
-                          passwd[0] ? passwd : 0,
-                          database, 
-                          port_nr,
-                          socket[0] ? socket: NullS,
-                          (uint)client_flag))
-  {
-    set_dbc_error(dbc, "HY000", mysql_error(&dbc->mysql),
-		  mysql_errno(&dbc->mysql));
-    translate_error(dbc->error.sqlstate,
-		    MYERR_S1000,mysql_errno(&dbc->mysql));
-    MYODBCDbgReturn(SQL_ERROR);
-  }
-  dbc->dsn= my_strdup(dsn_ptr ? dsn_ptr : database ,MYF(MY_WME));
-  dbc->database= my_strdup(database,MYF(MY_WME));
-  dbc->server= my_strdup(host,MYF(MY_WME));
-  dbc->user= my_strdup(user,MYF(MY_WME));
-  dbc->password= my_strdup(passwd,MYF(MY_WME));
-  dbc->port= port_nr;
-  dbc->flag= flag_nr;
+    /* socket[0] is always 0 if you are not under UNIX */
+    if (!mysql_real_connect(&dbc->mysql,
+                            host,
+                            user,
+                            passwd[0] ? passwd : 0,
+                            database, 
+                            port_nr,
+                            socket[0] ? socket: NullS,
+                            (uint)client_flag))
+    {
+        set_dbc_error(dbc, "HY000", mysql_error(&dbc->mysql),
+                      mysql_errno(&dbc->mysql));
+        translate_error(dbc->error.sqlstate,
+                        MYERR_S1000,mysql_errno(&dbc->mysql));
+        MYODBCDbgReturn(SQL_ERROR);
+    }
+    dbc->dsn= my_strdup(dsn_ptr ? dsn_ptr : database ,MYF(MY_WME));
+    dbc->database= my_strdup(database,MYF(MY_WME));
+    dbc->server= my_strdup(host,MYF(MY_WME));
+    dbc->user= my_strdup(user,MYF(MY_WME));
+    dbc->password= my_strdup(passwd,MYF(MY_WME));
+    dbc->port= port_nr;
+    dbc->flag= flag_nr;
 
-  MYODBCDbgReturn(set_connect_defaults(dbc));
+    MYODBCDbgReturn(set_connect_defaults(dbc));
 }
 
 
@@ -287,30 +289,30 @@
 
 static char *my_strtok(char *s1, pchar separator, char **save)
 {
-  reg1 char *rtnval,*end;
+    reg1 char *rtnval,*end;
 
-  rtnval= NULL;
-  if (s1 != NULL)
-    end= s1;
-  else
-    end= *save;
-  if (end != NULL && *end != 0)
-  {
-    rtnval= end;
-    do
+    rtnval= NULL;
+    if (s1 != NULL)
+        end= s1;
+    else
+        end= *save;
+    if (end != NULL && *end != 0)
     {
-      if (*end++ == separator)
-      {
-	if (separator)
-	  end[-1]= 0;
-	else
-	  end--;      /* \0 as separator */
-	break;
-      }
-    } while (*end != 0);
-    *save= end;
-  }
-  return (rtnval);
+        rtnval= end;
+        do
+        {
+            if (*end++ == separator)
+            {
+                if (separator)
+                    end[-1]= 0;
+                else
+                    end--;      /* \0 as separator */
+                break;
+            }
+        } while (*end != 0);
+        *save= end;
+    }
+    return(rtnval);
 }
 
 /*
@@ -324,7 +326,7 @@
                              pDataSource->pszOPTION ? atoi(pDataSource->pszOPTION)
: 0, 
                              (uint)dbc->login_timeout, 
                              pDataSource->pszSTMT ? pDataSource->pszSTMT : "" );
-    
+
     if ( !mysql_real_connect( &dbc->mysql,
                               pDataSource->pszSERVER, 
                               pDataSource->pszUSER,
@@ -392,7 +394,7 @@
 
         \note
                 This also allows us to get pszDRIVER (if not already given).
-    */    
+    */
     if ( pDataSource->pszDSN )
     {
         if ( !MYODBCUtilReadDataSource( pDataSource, pDataSource->pszDSN ) )
@@ -416,7 +418,7 @@
 
 #ifndef DBUG_OFF
     if ( atol( pDataSource->pszOPTION ) & FLAG_DEBUG && ! _db_on_ )
-      MYODBCDbgInit();
+        MYODBCDbgInit();
     MYODBCDbgPrint( "enter",( "fDriverCompletion: %d", fDriverCompletion ) );
 #endif
 
@@ -453,7 +455,7 @@
         server and password - particularly password. These can work with defaults/blank
but 
         many callers expect prompting when these are blank. So we compromise; we try to 
         connect and if it works we say its ok otherwise we go to a prompt.
-    */    
+    */
     switch ( fDriverCompletion )
     {
         case SQL_DRIVER_PROMPT:
@@ -521,7 +523,7 @@
             nReturn = SQL_ERROR;
             goto exitDriverConnect;
         }
-    
+
         /* 
            At this point we should have a driver name (friendly name) either loaded
            from DSN or provided in connection string. So lets determine the setup
@@ -611,17 +613,17 @@
     {
         if (!pDataSource->bSaveFileDSN)
         {
-          nReturn = SQL_ERROR;
-          goto exitDriverConnect0;
+            nReturn = SQL_ERROR;
+            goto exitDriverConnect0;
         }
         else
         {
-          set_dbc_error( hdbc, "08001", "Client unable to establish connection.", 0 );
-          nReturn = SQL_SUCCESS_WITH_INFO;
+            set_dbc_error( hdbc, "08001", "Client unable to establish connection.", 0 );
+            nReturn = SQL_SUCCESS_WITH_INFO;
         }
     }
 
-exitDriverConnect1:
+    exitDriverConnect1:
     /*! todo: handle error from this without losing memory */
     set_connect_defaults( dbc );
 
@@ -669,7 +671,7 @@
             *pcbConnStrOut = strlen( szConnStrOut );
     }
 
-exitDriverConnect0:
+    exitDriverConnect0:
 #ifdef WIN32
     if ( hModule )
         FreeLibrary( hModule );
@@ -678,7 +680,7 @@
         lt_dlclose( hModule );
 #endif
 
-exitDriverConnect:
+    exitDriverConnect:
     MYODBCUtilFreeDriver( pDriver );
     MYODBCUtilFreeDataSource( pDataSource );
 
@@ -697,16 +699,16 @@
 
 SQLRETURN SQL_API
 SQLDriverConnect(SQLHDBC hdbc,SQLHWND hwnd,
-		 SQLCHAR FAR *szConnStrIn,
-		 SQLSMALLINT cbConnStrIn,
-		 SQLCHAR FAR *szConnStrOut,
-		 SQLSMALLINT cbConnStrOutMax,
-		 SQLSMALLINT FAR *pcbConnStrOut,
-		 SQLUSMALLINT fDriverCompletion)
+                 SQLCHAR FAR *szConnStrIn,
+                 SQLSMALLINT cbConnStrIn,
+                 SQLCHAR FAR *szConnStrOut,
+                 SQLSMALLINT cbConnStrOutMax,
+                 SQLSMALLINT FAR *pcbConnStrOut,
+                 SQLUSMALLINT fDriverCompletion)
 {
-  return my_SQLDriverConnect(hdbc,hwnd,szConnStrIn,cbConnStrIn,
-			     szConnStrOut,cbConnStrOutMax,
-			     pcbConnStrOut,fDriverCompletion);
+    return my_SQLDriverConnect(hdbc,hwnd,szConnStrIn,cbConnStrIn,
+                               szConnStrOut,cbConnStrOutMax,
+                               pcbConnStrOut,fDriverCompletion);
 }
 
 
@@ -719,15 +721,15 @@
 
 SQLRETURN SQL_API
 SQLBrowseConnect(SQLHDBC hdbc,
-		 SQLCHAR FAR *szConnStrIn __attribute__((unused)),
-		 SQLSMALLINT cbConnStrIn __attribute__((unused)),
-		 SQLCHAR FAR *szConnStrOut __attribute__((unused)),
-		 SQLSMALLINT cbConnStrOutMax __attribute__((unused)),
-		 SQLSMALLINT FAR *pcbConnStrOut __attribute__((unused)))
+                 SQLCHAR FAR *szConnStrIn __attribute__((unused)),
+                 SQLSMALLINT cbConnStrIn __attribute__((unused)),
+                 SQLCHAR FAR *szConnStrOut __attribute__((unused)),
+                 SQLSMALLINT cbConnStrOutMax __attribute__((unused)),
+                 SQLSMALLINT FAR *pcbConnStrOut __attribute__((unused)))
 {
-  MYODBCDbgEnter("SQLBrowseConnect");
-  MYODBCDbgReturn(set_conn_error(hdbc,MYERR_S1000,
-				    "Driver Does not support this API",0));
+    MYODBCDbgEnter("SQLBrowseConnect");
+    MYODBCDbgReturn(set_conn_error(hdbc,MYERR_S1000,
+                                   "Driver Does not support this API",0));
 }
 
 
@@ -738,28 +740,28 @@
 
 SQLRETURN SQL_API my_SQLDisconnect(SQLHDBC hdbc)
 {
-  LIST *list_element,*next_element;
-  DBC FAR *dbc= (DBC FAR*) hdbc;
-  MYODBCDbgEnter("my_SQLDisconnect");
+    LIST *list_element,*next_element;
+    DBC FAR *dbc= (DBC FAR*) hdbc;
+    MYODBCDbgEnter("my_SQLDisconnect");
 
-  for (list_element= dbc->statements ; list_element ;
-       list_element= next_element)
-  {
-    next_element= list_element->next;
-    my_SQLFreeStmt((SQLHSTMT) list_element->data, SQL_DROP);
-  }
-  mysql_close(&dbc->mysql);
-  my_free(dbc->dsn,MYF(0));
-  my_free(dbc->database,MYF(0));
-  my_free(dbc->server,MYF(0));
-  my_free(dbc->user,MYF(0));
-  my_free(dbc->password,MYF(0));
-  dbc->dsn= dbc->database= dbc->server= dbc->user= dbc->password= 0;
+    for (list_element= dbc->statements ; list_element ;
+        list_element= next_element)
+    {
+        next_element= list_element->next;
+        my_SQLFreeStmt((SQLHSTMT) list_element->data, SQL_DROP);
+    }
+    mysql_close(&dbc->mysql);
+    my_free(dbc->dsn,MYF(0));
+    my_free(dbc->database,MYF(0));
+    my_free(dbc->server,MYF(0));
+    my_free(dbc->user,MYF(0));
+    my_free(dbc->password,MYF(0));
+    dbc->dsn= dbc->database= dbc->server= dbc->user= dbc->password= 0;
 #ifndef DBUG_OFF
-  if (dbc->flag & FLAG_LOG_QUERY)
-    end_query_log(dbc->query_log);
+    if (dbc->flag & FLAG_LOG_QUERY)
+        end_query_log(dbc->query_log);
 #endif
-  MYODBCDbgReturn(SQL_SUCCESS);
+    MYODBCDbgReturn(SQL_SUCCESS);
 }
 
 
@@ -770,5 +772,5 @@
 
 SQLRETURN SQL_API SQLDisconnect(SQLHDBC hdbc)
 {
-  return my_SQLDisconnect(hdbc);
+    return my_SQLDisconnect(hdbc);
 }

Thread
Connector/ODBC 3.51 commit: r43 - / MYODBCDbg/MYODBCDbgLib MYODBCDbg/include myodbc3pharvey6 Mar