[svn-commits] r45 - in drivers/python/trunk: . dbi hdr
crogr01 at ingres.com
crogr01 at ingres.com
Thu Jun 5 10:33:36 PDT 2008
Author: crogr01
Date: 2008-06-05 10:33:36 -0700 (Thu, 05 Jun 2008)
New Revision: 45
Modified:
drivers/python/trunk/CHANGELOG
drivers/python/trunk/dbi/iidbiutil.c
drivers/python/trunk/dbi/ingresdbi.c
drivers/python/trunk/hdr/iidbi.h
drivers/python/trunk/hdr/iidbiutil.h
Log:
Raise IOError if the trace file cannot be opened
Modified: drivers/python/trunk/CHANGELOG
===================================================================
--- drivers/python/trunk/CHANGELOG 2008-04-28 17:36:44 UTC (rev 44)
+++ drivers/python/trunk/CHANGELOG 2008-06-05 17:33:36 UTC (rev 45)
@@ -1,5 +1,9 @@
IngresDBI CHANGELOG
+SVN - Last updated $Date$
+ Raise IOError if the trace file cannot be opened - [grant - 28-Apr-2008]
+ Extend search for odbcinst.ini - [grant - 28-Apr-2008]
+
09-May-2006 - 2.0.0
Incremented version to 2.0.0.
Fixed a number of memory leaks and negative reference counts.
Modified: drivers/python/trunk/dbi/iidbiutil.c
===================================================================
--- drivers/python/trunk/dbi/iidbiutil.c 2008-04-28 17:36:44 UTC (rev 44)
+++ drivers/python/trunk/dbi/iidbiutil.c 2008-06-05 17:33:36 UTC (rev 45)
@@ -81,11 +81,12 @@
** Save the filename of the file that is opened.
** Keep a reference of open requests.
}*/
-void
+short int
dbi_trace( int dbglevel, char* trcfile )
{
FILE* fd;
time_t ltime;
+ short int ret_val;
time( <ime );
@@ -103,6 +104,12 @@
dbi_dbgfd = fd;
dbi_tracerefs += 1;
}
+ else
+ {
+ ret_val = FALSE;
+ goto dbi_trace_end;
+ }
+
}
else
{
@@ -112,8 +119,12 @@
}
dbi_tracerefs += 1;
}
- dbi_format( "Ingres DBI trace - started %s%s\n",
- ctime( <ime ), (dbi_tracerefs == 1) ? "{{{" : "");
+ if (!dbi_format( "Ingres DBI trace - started %s%s\n",
+ ctime( <ime ), (dbi_tracerefs == 1) ? "{{{" : ""))
+ {
+ ret_val = FALSE;
+ goto dbi_trace_end;
+ }
}
else
{
@@ -135,7 +146,8 @@
}
}
}
- return;
+dbi_trace_end:
+ return ret_val;
}
/*{
@@ -307,18 +319,24 @@
** 16-Jul-2004 (raymond.fan at ca.com)
** Add close on each trace message.
}*/
-void
+short int
dbi_format( char* fmt, ... )
{
va_list p;
+ short int ret_val;
va_start( p, fmt );
+ ret_val = TRUE;
if ((dbi_dbgfd != NULL) || (dbi_trcfile != NULL))
{
if (dbi_dbgfd == NULL)
{
- dbi_dbgfd = fopen( dbi_trcfile, "a" );
+ if ((dbi_dbgfd = fopen( dbi_trcfile, "a" )) == NULL);
+ {
+ ret_val = FALSE;
+ goto dbi_format_end;
+ }
}
vfprintf( dbi_dbgfd, fmt, p );
fflush( dbi_dbgfd );
@@ -329,5 +347,6 @@
}
}
- return;
+dbi_format_end:
+ return ret_val;
}
Modified: drivers/python/trunk/dbi/ingresdbi.c
===================================================================
--- drivers/python/trunk/dbi/ingresdbi.c 2008-04-28 17:36:44 UTC (rev 44)
+++ drivers/python/trunk/dbi/ingresdbi.c 2008-06-05 17:33:36 UTC (rev 45)
@@ -195,6 +195,7 @@
static PyObject *IIDBI_InternalError;
static PyObject *IIDBI_ProgrammingError;
static PyObject *IIDBI_NotSupportedError;
+static PyObject *IIDBI_IOError;
static PyObject * IIDBI_connect(PyObject *self, PyObject *args,
PyObject *keywords);
@@ -1150,7 +1151,11 @@
PyErr_SetString(IIDBI_InterfaceError, "format of trace is (traceLevel,[traceFile])");
goto errorExit;
}
- dbi_trace(trace, traceFile);
+ if (!dbi_trace(trace, traceFile))
+ {
+ PyErr_SetFromErrnoWithFilename(IIDBI_IOError, traceFile);
+ goto errorExit;
+ }
}
DBPRINTF(DBI_TRC_RET)("IIDBI_connect {{{1\n");
@@ -1400,6 +1405,9 @@
conn->NotSupportedError = IIDBI_NotSupportedError;
Py_INCREF(conn->NotSupportedError);
+
+ conn->IOError = IIDBI_IOError;
+ Py_INCREF(conn->IOError);
}
DBPRINTF(DBI_TRC_RET)("IIDBI_connConstructor }}}1\n");
@@ -2131,6 +2139,15 @@
Py_INCREF(IIDBI_ProgrammingError);
PyModule_AddObject(IIDBI_module, "ProgrammingError", IIDBI_ProgrammingError);
+
+ if (!(IIDBI_IOError = PyErr_NewException("ingresdbi.IOError",
+ IIDBI_IOError, NULL)))
+ Py_FatalError("Creation of ingresdbi.IOError exception failed");
+ else
+ Py_INCREF(IIDBI_IOError);
+
+ PyModule_AddObject(IIDBI_module, "IOError", IIDBI_IOError);
+
PyDateTime_IMPORT;
decimalmod = PyImport_ImportModule("decimal");
Modified: drivers/python/trunk/hdr/iidbi.h
===================================================================
--- drivers/python/trunk/hdr/iidbi.h 2008-04-28 17:36:44 UTC (rev 44)
+++ drivers/python/trunk/hdr/iidbi.h 2008-06-05 17:33:36 UTC (rev 45)
@@ -349,6 +349,7 @@
PyObject *ProgrammingError;
PyObject *NotSupportedError;
PyObject *errorhandler;
+ PyObject *IOError;
int pooled;
} IIDBI_CONNECTION;
Modified: drivers/python/trunk/hdr/iidbiutil.h
===================================================================
--- drivers/python/trunk/hdr/iidbiutil.h 2008-04-28 17:36:44 UTC (rev 44)
+++ drivers/python/trunk/hdr/iidbiutil.h 2008-06-05 17:33:36 UTC (rev 45)
@@ -45,14 +45,14 @@
void
print_err(RETCODE rc, HENV henv, HDBC hdbc, SQLHSTMT hstmt);
-void
+short int
dbi_format( char* fmt, ... );
RETCODE
dbi_error_withtext( RETCODE status, HENV henv, HDBC hdbc, SQLHSTMT hstmt, IIDBI_ERROR* err, char *err_str );
#define IIDBI_ERROR( status, henv, hdbc, hstmt, err) dbi_error_withtext( status, henv, hdbc, hstmt, err, NULL )
-void
+short int
dbi_trace( int dbglevel, char* trcfile );
# endif /* __IIDBI_UTIL_H_INCLUDED */
More information about the svn-commits
mailing list