Update of /cvsroot/ruby-dbi/subprojects/ruby-db2/ext/db2
In directory sc8-pr-cvs1:/tmp/cvs-serv19572
Modified Files:
db2cli.c
Log Message:
fixes bug in SQLGetData that occurs for SQL_BIGINTs
Index: db2cli.c
===================================================================
RCS file: /cvsroot/ruby-dbi/subprojects/ruby-db2/ext/db2/db2cli.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- db2cli.c 11 Sep 2003 15:47:07 -0000 1.3
+++ db2cli.c 22 Nov 2003 16:56:46 -0000 1.4
@@ -885,8 +885,21 @@
/* TODO: How large can a BIGINT be? ==> expect 200 bytes, should be enought? */
ptr = (SQLPOINTER) ALLOC_N(SQLCHAR, MAX(bl,200));
CALL_SQL_GET_DATA(ptr, SQL_C_CHAR, bl);
- RETVAL( rb_str_new(ptr, MIN(bl, strlen_or_indptr)) );
- rc = rb_funcall(rc, rb_intern("to_i"), 0);
+
+ if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
+ if (strlen_or_indptr == SQL_NULL_DATA) {
+ retval = objNull;
+ }
+ else {
+ /* convert string to integer */
+ retval = rb_str_new(ptr, MIN(bl, strlen_or_indptr));
+ retval = rb_funcall(retval, rb_intern("to_i"), 0);
+ }
+ }
+ else {
+ retval = Qnil;
+ }
+
free((void*)ptr);
break;
|