Date: Monday, January 16, 2006 @ 20:01:33
Author: marc
Path: /cvsroot/carob/odbsequoia/src
Modified: simpletest.c (1.6 -> 1.7)
Now testing SQLGetDiagField()
--------------+
simpletest.c | 51 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 41 insertions(+), 10 deletions(-)
Index: odbsequoia/src/simpletest.c
diff -u odbsequoia/src/simpletest.c:1.6 odbsequoia/src/simpletest.c:1.7
--- odbsequoia/src/simpletest.c:1.6 Fri Jan 13 17:28:14 2006
+++ odbsequoia/src/simpletest.c Mon Jan 16 20:01:33 2006
@@ -3,6 +3,7 @@
#include <sqlucode.h>
#include <stdio.h>
+#include <string.h>
#include <wchar.h>
// !log_info.log_flag && !ODBCSharedTraceFlag
@@ -12,22 +13,52 @@
void print_diags(int pc, SQLSMALLINT hdletype, SQLHANDLE hdle)
{
- SQLINTEGER recnum = 1;
- SQLSMALLINT msgsize;
- SQLCHAR state[6];
+ SQLINTEGER irec, recmax;
+ SQLSMALLINT statesize, msgsize;
+ SQLCHAR state[12]; // twice what needed because of this under-estimating
bug:
+ //
<http://permalink.gmane.org/gmane.comp.db.unixodbc.devel/1760>
SQLINTEGER nativecode;
- SQLCHAR msg[100];
+ SQLCHAR msg[201];
+
+ SQLSMALLINT ignoredBufLen = 0; // should be zero because of "2nd bug"
linked to above
+ SQLSMALLINT * ignoredLenPtr = (SQLSMALLINT *) 0;
+ SQLSMALLINT ignoredRecNum = 5243;
+
+ SQLGetDiagField(hdletype, hdle, ignoredRecNum, SQL_DIAG_NUMBER, &recmax,
+ ignoredBufLen, ignoredLenPtr);
+
+ for (irec = 1; irec <= recmax; irec++) {
+
+ SQLGetDiagRec(hdletype, hdle,
+ irec, state, &nativecode, msg, 200, &msgsize);
- while (SQL_NO_DATA !=
- SQLGetDiagRec(hdletype, hdle,
- recnum, state, &nativecode, msg, 100, &msgsize)) {
-
printf ("step %d: sqlstate: %s, ", pc, state);
printf ("native errr: %ld, ", nativecode);
printf ("%s, ", msg);
printf ("msgsize: %d\n", msgsize);
-
- recnum++;
+
+ // cleanup
+ strcpy ((char *)state, "nop"); statesize = -1000; nativecode = -1000;
+ strcpy((char *)msg, "nop"); msgsize = -1000 ;
+
+ // get the same thing through SQLGetDiagField thrice
+ SQLGetDiagField(hdletype, hdle, irec, SQL_DIAG_SQLSTATE,
+ state, 12*sizeof(SQLCHAR), &statesize);
+
+ SQLGetDiagField(hdletype, hdle, irec, SQL_DIAG_NATIVE,
+ &nativecode, ignoredBufLen, ignoredLenPtr );
+
+ SQLGetDiagField(hdletype, hdle, irec, SQL_DIAG_MESSAGE_TEXT,
+ msg, 201, &msgsize);
+
+
+ printf ("same diags but through SQLGetDiagField:\n");
+ printf ("step %d: sqlstate: %s, ", pc, state);
+ printf ("statesize: %d\n", statesize);
+ printf ("native errr: %ld, ", nativecode);
+ printf ("%s, ", msg);
+ printf ("msgsize: %d\n", msgsize);
+
}
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits