[freetds] ODBC transaction unit test

John Anderson panic at semiosix.com
Sun Oct 19 12:12:10 EDT 2003


As requested, I've added a unit test (in transaction.c) to
odbc/unittests to expose the ODBC transaction error. Also, I added a
function to common.c - in the diff along with Makefile.am additions.

bye
John

-------------- next part --------------
? transaction
? transaction.c
Index: Makefile.am
===================================================================
RCS file: /cvsroot/freetds/freetds/src/odbc/unittests/Makefile.am,v
retrieving revision 1.22
diff -u -u -r1.22 Makefile.am
--- Makefile.am	30 Sep 2003 19:06:45 -0000	1.22
+++ Makefile.am	19 Oct 2003 11:08:48 -0000
@@ -1,8 +1,11 @@
-TESTS		=	t0001 t0002 t0003 t0004 connect print date \
+TESTS		=	\
+			t0001 t0002 t0003 t0004 connect print date \
 			norowset funccall lang_error tables \
 			binary_test moreandcount earlybind \
 			putdata params raiseerror getdata \
+			transaction \
 			type
+
 check_PROGRAMS	=	$(TESTS)
 
 t0001_SOURCES	=	t0001.c common.c common.h
@@ -24,6 +27,7 @@
 raiseerror_SOURCES	= raiseerror.c common.c common.h
 getdata_SOURCES	= getdata.c common.c common.h
 type_SOURCES	= type.c common.c common.h
+transaction_SOURCES = transaction.c common.c common.h
 
 LIBS		=	-lodbc @NETWORK_LIBS@
 INCLUDES	=	-I$(top_srcdir)/include $(ODBC_INC)
Index: common.c
===================================================================
RCS file: /cvsroot/freetds/freetds/src/odbc/unittests/common.c,v
retrieving revision 1.17
diff -u -u -r1.17 common.c
--- common.c	1 Apr 2003 12:01:34 -0000	1.17
+++ common.c	19 Oct 2003 11:08:48 -0000
@@ -68,7 +68,6 @@
 	exit(1);
 }
 
-
 int
 Connect(void)
 {
@@ -139,14 +138,22 @@
 	return 0;
 }
 
-void
+void 
 Command(HSTMT stmt, const char *command)
 {
+	int result = 0;
 	printf("%s\n", command);
-	if (SQLExecDirect(stmt, (SQLCHAR *) command, SQL_NTS)
-	    != SQL_SUCCESS) {
+	result = SQLExecDirect(stmt, (SQLCHAR *) command, SQL_NTS);
+	if ( result != SQL_SUCCESS) {
 		printf("Unable to execute statement\n");
 		CheckReturn();
 		exit(1);
 	}
+}
+
+SQLRETURN
+CommandWithResult(HSTMT stmt, const char *command)
+{
+	printf("%s\n", command);
+	return SQLExecDirect(stmt, (SQLCHAR *) command, SQL_NTS);
 }
Index: common.h
===================================================================
RCS file: /cvsroot/freetds/freetds/src/odbc/unittests/common.h,v
retrieving revision 1.7
diff -u -u -r1.7 common.h
--- common.h	1 Apr 2003 12:01:35 -0000	1.7
+++ common.h	19 Oct 2003 11:08:49 -0000
@@ -33,3 +33,4 @@
 int Connect(void);
 int Disconnect(void);
 void Command(HSTMT stmt, const char *command);
+SQLRETURN CommandWithResult(HSTMT stmt, const char *command);


More information about the FreeTDS mailing list