[PATCH] to improve DBD::Sybase 'make test' when using freetds

David Dick <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
This patch redirects some logging statements from stderr to the tdsdump 
file and tries to improve the results of running 'make test' from 
DBD::Sybase when using the freetds libraries.  It allows every 
DBD::Sybase test to pass except for t/xblob.t.

_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
freetds_dbd_sybase.patch (text/plain, 2.7 KB)
diff -Naur old/locales.conf new/locales.conf
--- old/locales.conf	2008-02-29 09:30:19.000000000 +1100
+++ new/locales.conf	2010-04-11 20:22:08.000000000 +1000
@@ -1,5 +1,5 @@
 [default]
-	date format = %b %e %Y %I:%M:%S:%z%p
+	date format = %b %e %Y %I:%M
 
 [en_US]
 	date format = %b %e %Y %I:%M:%S:%z%p
diff -Naur old/src/ctlib/cs.c new/src/ctlib/cs.c
--- old/src/ctlib/cs.c	2007-12-24 08:12:02.000000000 +1100
+++ new/src/ctlib/cs.c	2010-04-11 20:22:08.000000000 +1000
@@ -471,7 +471,14 @@
 		    src_type, src_len, desttype, destlen);
 
 	if (!is_fixed_type(desttype) && (destlen <= 0)) {
-		return CS_FAIL;
+		destlen = srcfmt ? srcfmt->maxlength : 0;
+		if (destlen <= 0) {
+			tdsdump_log(TDS_DBG_FUNC, "cs_convert() could not determine the maxlength for the destination field\n");
+			return CS_FAIL;
+		}
+	}
+	if ((is_numeric_type(src_type)) && (desttype == SYBCHAR)) {
+		destlen += 1; /* maxlength does not take into account the decimal point in the resulting string */
 	}
 
 	dest = (unsigned char *) destdata;
@@ -668,7 +675,7 @@
 
 		if (len > destlen) {
 			free(cres.ib);
-			fprintf(stderr, "error_handler: Data-conversion resulted in overflow.\n");
+			tdsdump_log(TDS_DBG_FUNC, "error_handler: Data-conversion resulted in overflow\n");
 			ret = CS_FAIL;
 		} else {
 			memcpy(dest, cres.ib, len);
@@ -757,7 +764,10 @@
 	case SYBVARCHAR:
 	case SYBTEXT:
 		if (len > destlen) {
-			fprintf(stderr, "error_handler: Data-conversion resulted in overflow.\n");
+			tdsdump_log(TDS_DBG_FUNC, "Data-conversion resulted in overflow\n");
+			len = destlen; 
+		}
+		if (len > destlen) {
 			ret = CS_FAIL;
 		} else {
 			switch (destfmt->format) {
diff -Naur old/src/ctlib/ct.c new/src/ctlib/ct.c
--- old/src/ctlib/ct.c	2008-05-06 13:23:45.000000000 +1000
+++ new/src/ctlib/ct.c	2010-04-11 20:22:08.000000000 +1000
@@ -2335,6 +2335,14 @@
 		datafmt->status |= CS_CANBENULL;
 	if (curcol->column_identity)
 		datafmt->status |= CS_IDENTITY;
+	if (curcol->column_writeable)
+		datafmt->status |= CS_UPDATABLE;
+	if (curcol->column_key)
+		datafmt->status |= CS_KEY;
+	if (curcol->column_hidden)
+		datafmt->status |= CS_HIDDEN;
+	if (curcol->column_timestamp)
+		datafmt->status |= CS_TIMESTAMP;
 	if (strcmp(datafmt->name, "txts") == 0)
 		datafmt->status |= CS_TIMESTAMP;
 
diff -Naur old/src/tds/convert.c new/src/tds/convert.c
--- old/src/tds/convert.c	2008-02-04 18:55:39.000000000 +1100
+++ new/src/tds/convert.c	2010-04-11 20:22:08.000000000 +1000
@@ -2070,6 +2070,7 @@
 			old_digits_left = digits_left;
 			digits_left = cr->n.scale;
 			places = 1;
+		} else if (*pstr == 0) {
 		} else if (*pstr == ' ') {
 			for (; pstr != pend && *pstr == ' '; ++pstr) ; /* skip contiguous blanks */
 			if (pstr == pend)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.