SOURCES: freetds-cvs-fixes.patch (NEW) - few fixes from freetds CVS, helps ...

hawk hawk at pld-linux.org
Wed Jun 18 13:05:46 CEST 2008


Author: hawk                         Date: Wed Jun 18 11:05:46 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- few fixes from freetds CVS, helps with building some tds related packages

---- Files affected:
SOURCES:
   freetds-cvs-fixes.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/freetds-cvs-fixes.patch
diff -u /dev/null SOURCES/freetds-cvs-fixes.patch:1.1
--- /dev/null	Wed Jun 18 13:05:47 2008
+++ SOURCES/freetds-cvs-fixes.patch	Wed Jun 18 13:05:41 2008
@@ -0,0 +1,863 @@
+diff -urN freetds/configure.ac freetds.current/configure.ac
+--- freetds/configure.ac	2008-05-08 00:57:52.000000000 +0200
++++ freetds.current/configure.ac	2008-05-28 15:40:28.000000000 +0200
+@@ -1,7 +1,7 @@
+ dnl Process this file with autoconf to produce a configure script.
+ 
+ dnl ------------------------------------------------------------
+-dnl $Id$
++dnl $Id$
+ dnl If you're trying to create a new configure test, try
+ dnl
+ dnl 	http://autogen.sourceforge.net/conftest.html
+@@ -240,7 +240,7 @@
+ ])
+ AC_CHECK_HEADERS([unistd.h errno.h wchar.h sys/time.h sys/types.h \
+ sys/param.h sys/stat.h sys/wait.h limits.h locale.h odbcss.h readpassphrase.h \
+-signal.h libgen.h poll.h])
++signal.h libgen.h poll.h getopt.h])
+ if test $tds_mingw = no; then
+ 	AC_CHECK_HEADERS([sys/socket.h arpa/inet.h netdb.h netinet/in.h \
+ netinet/tcp.h paths.h sys/ioctl.h langinfo.h])
+@@ -347,6 +347,16 @@
+ 
+ TYPE_SOCKLEN_T
+ 
++AC_MSG_CHECKING([whether getopt has optreset support])
++AC_TRY_LINK([#ifdef HAVE_GETOPT_H
++#include <getopt.h>
++#endif], [extern int optreset; optreset = 0;],
++[AC_MSG_RESULT(yes)
++AC_DEFINE(HAVE_GETOPT_OPTRESET, 1, [Define if your getopt(3) defines and uses optreset])],
++[AC_MSG_RESULT(no)]
++)
++
++
+ # ------------------------------------------------------------
+ # Checks for compiler characteristics.
+ # ------------------------------------------------------------
+diff -urN freetds/include/cspublic.h freetds.current/include/cspublic.h
+--- freetds/include/cspublic.h	2007-06-25 11:48:20.000000000 +0200
++++ freetds.current/include/cspublic.h	2008-05-19 16:23:52.000000000 +0200
+@@ -34,7 +34,7 @@
+ #define TDS_STATIC_CAST(type, a) ((type)(a))
+ #endif
+ 
+-static const char rcsid_cspublic_h[] = "$Id$";
++static const char rcsid_cspublic_h[] = "$Id$";
+ static const void *const no_unused_cspublic_h_warn[] = { rcsid_cspublic_h, no_unused_cspublic_h_warn };
+ 
+ #define CS_PUBLIC
+@@ -447,6 +447,9 @@
+ 
+ #define BLK_VERSION_100 CS_VERSION_100
+ #define BLK_VERSION_110 CS_VERSION_100
++#define BLK_VERSION_120 CS_VERSION_120
++#define BLK_VERSION_125 CS_VERSION_125
++#define BLK_VERSION_150 CS_VERSION_150
+ 
+ #define CS_FORCE_EXIT	300
+ #define CS_FORCE_CLOSE  301
+diff -urN freetds/include/tdsbytes.h freetds.current/include/tdsbytes.h
+--- freetds/include/tdsbytes.h	2005-08-10 14:06:03.000000000 +0200
++++ freetds.current/include/tdsbytes.h	2008-05-26 14:49:56.000000000 +0200
+@@ -20,7 +20,7 @@
+ #ifndef _tdsbytes_h_
+ #define _tdsbytes_h_
+ 
+-/* $Id$ */
++/* $Id$ */
+ 
+ #ifndef _tds_h_
+ #error tds.h must be included before tdsbytes.h
+@@ -61,9 +61,9 @@
+ #define TDS_GET_A2BE(ptr) TDS_GET_UA2BE(ptr)
+ 
+ #define TDS_PUT_UA2LE(ptr,val) do {\
+- ((TDS_UCHAR*)(ptr))[1] = (val)>>8; ((TDS_UCHAR*)(ptr))[0] = (val); } while(0)
++ ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)(val); } while(0)
+ #define TDS_PUT_UA2BE(ptr,val) do {\
+- ((TDS_UCHAR*)(ptr))[0] = (val)>>8; ((TDS_UCHAR*)(ptr))[1] = (val); } while(0)
++ ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)(val); } while(0)
+ #define TDS_PUT_A2LE(ptr,val) TDS_PUT_UA2LE(ptr,val)
+ #define TDS_PUT_A2BE(ptr,val) TDS_PUT_UA2BE(ptr,val)
+ 
+@@ -78,11 +78,11 @@
+ #define TDS_GET_A4BE(ptr) TDS_GET_UA4BE(ptr)
+ 
+ #define TDS_PUT_UA4LE(ptr,val) do {\
+- ((TDS_UCHAR*)(ptr))[3] = (val)>>24; ((TDS_UCHAR*)(ptr))[2] = (val)>>16;\
+- ((TDS_UCHAR*)(ptr))[1] = (val)>>8; ((TDS_UCHAR*)(ptr))[0] = (val); } while(0)
++ ((TDS_UCHAR*)(ptr))[3] = (TDS_UCHAR)((val)>>24); ((TDS_UCHAR*)(ptr))[2] = (TDS_UCHAR)((val)>>16);\
++ ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)(val); } while(0)
+ #define TDS_PUT_UA4BE(ptr,val) do {\
+- ((TDS_UCHAR*)(ptr))[0] = (val)>>24; ((TDS_UCHAR*)(ptr))[1] = (val)>>16;\
+- ((TDS_UCHAR*)(ptr))[2] = (val)>>8; ((TDS_UCHAR*)(ptr))[3] = (val); } while(0)
++ ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)((val)>>24); ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)((val)>>16);\
++ ((TDS_UCHAR*)(ptr))[2] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[3] = (TDS_UCHAR)(val); } while(0)
+ #define TDS_PUT_A4LE(ptr,val) TDS_PUT_UA4LE(ptr,val)
+ #define TDS_PUT_A4BE(ptr,val) TDS_PUT_UA4BE(ptr,val)
+ 
+diff -urN freetds/include/tds.h freetds.current/include/tds.h
+--- freetds/include/tds.h	2007-12-27 14:45:22.000000000 +0100
++++ freetds.current/include/tds.h	2008-05-28 00:48:50.000000000 +0200
+@@ -20,12 +20,16 @@
+ #ifndef _tds_h_
+ #define _tds_h_
+ 
+-/* $Id$ */
++/* $Id$ */
+ 
+ #include <stdarg.h>
+ #include <stdio.h>
+ #include <time.h>
+ 
++#if HAVE_ARPA_INET_H
++#include <arpa/inet.h>
++#endif /* HAVE_ARPA_INET_H */
++
+ /* forward declaration */
+ typedef struct tdsiconvinfo TDSICONV;
+ typedef struct tds_socket TDSSOCKET;
+@@ -747,7 +751,7 @@
+ 
+ 
+ #define TDS_MAX_CAPABILITY	22
+-#define MAXPRECISION 		80
++#define MAXPRECISION 		77
+ #define TDS_MAX_CONN		4096
+ #define TDS_MAX_DYNID_LEN	30
+ 
+diff -urN freetds/src/apps/freebcp.c freetds.current/src/apps/freebcp.c
+--- freetds/src/apps/freebcp.c	2006-12-01 22:51:11.000000000 +0100
++++ freetds.current/src/apps/freebcp.c	2008-05-28 22:07:55.000000000 +0200
+@@ -45,7 +45,7 @@
+ #include <sybdb.h>
+ #include "freebcp.h"
+ 
+-static char software_version[] = "$Id$";
++static char software_version[] = "$Id$";
+ static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };
+ 
+ void pusage(void);
+@@ -351,6 +351,8 @@
+ 	 */
+ 
+ 	login = dblogin();
++	if (!login)
++		return FALSE;
+ 
+ 	DBSETLUSER(login, pdata->user);
+ 	DBSETLPWD(login, pdata->pass);
+@@ -372,8 +374,11 @@
+ 
+ 	if ((*pdbproc = dbopen(login, pdata->server)) == NULL) {
+ 		fprintf(stderr, "Can't connect to server \"%s\".\n", pdata->server);
++		dbloginfree(login);
+ 		return (FALSE);
+ 	}
++	dbloginfree(login);
++	login = NULL;
+ 
+ 	/* set hint if any */
+ 	if (pdata->hint) {
+diff -urN freetds/src/apps/tsql.c freetds.current/src/apps/tsql.c
+--- freetds/src/apps/tsql.c	2008-01-11 13:46:52.000000000 +0100
++++ freetds.current/src/apps/tsql.c	2008-05-31 10:53:39.000000000 +0200
+@@ -85,7 +85,9 @@
+ #include "tdsconvert.h"
+ #include "replacements.h"
+ 
+-TDS_RCSID(var, "$Id$");
++TDS_RCSID(var, "$Id$");
++
++#define TDS_ISSPACE(c) isspace((unsigned char) (c))
+ 
+ enum
+ {
+@@ -301,6 +303,15 @@
+ 		progname, progname);
+ }
+ 
++static void
++reset_getopt(void)
++{
++#ifdef HAVE_GETOPT_OPTRESET
++	optreset = 1;
++#endif
++	optind = 1;
++}
++
+ /*
+  * The 'GO' command may be followed by options that apply to the batch.
+  * If they don't appear to be right, assume the letters "go" are part of the
+@@ -324,7 +335,7 @@
+ 		s = NULL;
+ 
+ 	*opt_flags = 0;
+-	optind = 0;		/* reset getopt */
++	reset_getopt();
+ 	opterr = 0;		/* suppress error messages */
+ 	while ((opt = getopt(argc, argv, "fhqtv")) != -1) {
+ 		switch (opt) {
+@@ -396,24 +407,24 @@
+ 			opt_flags_str = optarg;
+ 			break;
+ 		case 'H':
+-			hostname = (char *) malloc(strlen(optarg) + 1);
+-			strcpy(hostname, optarg);
++			free(hostname);
++			hostname = strdup(optarg);
+ 			break;
+ 		case 'S':
+-			servername = (char *) malloc(strlen(optarg) + 1);
+-			strcpy(servername, optarg);
++			free(servername);
++			servername = strdup(optarg);
+ 			break;
+ 		case 'U':
+-			username = (char *) malloc(strlen(optarg) + 1);
+-			strcpy(username, optarg);
++			free(username);
++			username = strdup(optarg);
+ 			break;
+ 		case 'P':
+-			password = (char *) malloc(strlen(optarg) + 1);
+-			strcpy(password, optarg);
++			free(password);
++			password = strdup(optarg);
+ 			break;
+ 		case 'I':
+-			confile = (char *) malloc(strlen(optarg) + 1);
+-			strcpy(confile, optarg);
++			free(confile);
++			confile = strdup(optarg);
+ 			break;
+ 		case 'p':
+ 			port = atoi(optarg);
+@@ -524,6 +535,7 @@
+ 	}
+ 
+ 	/* free up all the memory */
++	free(confile);
+ 	free(hostname);
+ 	free(username);
+ 	free(password);
+@@ -572,6 +584,7 @@
+ 		tsql_add_history(s);
+ 		(*line)++;
+ 	}
++	fclose(fp);
+ }
+ 
+ extern const char STD_DATETIME_FMT[];
+@@ -709,7 +722,7 @@
+ 		 *  The rest of the line may include options that apply to the batch, 
+ 		 *  and perhaps whitespace.  
+ 		 */
+-		if (0 == strncasecmp(s, "go", 2) && (strlen(s) == 2 || isspace(s[2]))) {
++		if (0 == strncasecmp(s, "go", 2) && (strlen(s) == 2 || TDS_ISSPACE(s[2]))) {
+ 			char *go_line = strdup(s);
+ 			assert(go_line);
+ 			line = 0;
+diff -urN freetds/src/dblib/bcp.c freetds.current/src/dblib/bcp.c
+--- freetds/src/dblib/bcp.c	2008-01-08 16:38:31.000000000 +0100
++++ freetds.current/src/dblib/bcp.c	2008-05-26 14:49:56.000000000 +0200
+@@ -71,7 +71,7 @@
+ }
+ TDS_PBCB;
+ 
+-TDS_RCSID(var, "$Id$");
++TDS_RCSID(var, "$Id$");
+ 
+ #ifdef HAVE_FSEEKO
+ typedef off_t offset_type;
+@@ -799,11 +799,13 @@
+ 
+ 	if (dbproc->bcpinfo->direction == DB_QUERYOUT ) {
+ 		if (tds_submit_query(tds, dbproc->bcpinfo->tablename) == TDS_FAIL) {
++			fclose(hostfile);
+ 			return FAIL;
+ 		}
+ 	} else {
+ 		/* TODO quote if needed */
+ 		if (tds_submit_queryf(tds, "select * from %s", dbproc->bcpinfo->tablename) == TDS_FAIL) {
++			fclose(hostfile);
+ 			return FAIL;
+ 		}
+ 	}
+@@ -1061,6 +1063,7 @@
+ 					break;
+ 				}
+ 				if( plen != 0 && written != 1 ) {
++					fclose(hostfile);
+ 					dbperror(dbproc, SYBEBCWE, errno);
+ 					return FAIL;
+ 				}
+@@ -1073,6 +1076,7 @@
+ 				if (buflen > 0) {
+ 					written = fwrite(hostcol->bcp_column_data->data, buflen, 1, hostfile);
+ 					if (written < 1) {
++						fclose(hostfile);
+ 						dbperror(dbproc, SYBEBCWE, errno);
+ 						return FAIL;
+ 					}
+@@ -1082,6 +1086,7 @@
+ 				if (hostcol->terminator && hostcol->term_len > 0) {
+ 					written = fwrite(hostcol->terminator, hostcol->term_len, 1, hostfile);
+ 					if (written < 1) {
++						fclose(hostfile);
+ 						dbperror(dbproc, SYBEBCWE, errno);
+ 						return FAIL;
+ 					}
+@@ -1094,6 +1099,7 @@
+ 		dbperror(dbproc, SYBEBCUC, errno);
+ 		return (FAIL);
+ 	}
++	hostfile = NULL;
+ 
+ 	if (dbproc->hostfileinfo->firstrow > 0 && row_of_query < dbproc->hostfileinfo->firstrow) {
+ 		/* 
+@@ -1896,8 +1902,10 @@
+ 		return FAIL;
+ 	}
+ 
+-	if (_bcp_start_copy_in(dbproc) == FAIL)
++	if (_bcp_start_copy_in(dbproc) == FAIL) {
++		fclose(hostfile);
+ 		return FAIL;
++	}
+ 
+ 	tds->out_flag = TDS_BULK;
+ 	tds_set_state(tds, TDS_QUERYING);
+@@ -1922,6 +1930,7 @@
+ 
+ 			if (errfile == NULL && dbproc->hostfileinfo->errorfile) {
+ 				if (!(errfile = fopen(dbproc->hostfileinfo->errorfile, "w"))) {
++					fclose(hostfile);
+ 					dbperror(dbproc, SYBEBUOE, 0);
+ 					return FAIL;
+ 				}
+@@ -2003,6 +2012,7 @@
+ 						if (tds_process_simple_query(tds) != TDS_SUCCEED) {
+ 							if (errfile)
+ 								fclose(errfile);
++							fclose(hostfile);
+ 							return FAIL;
+ 						}
+ 							
+diff -urN freetds/src/dblib/dblib.c freetds.current/src/dblib/dblib.c
+--- freetds/src/dblib/dblib.c	2008-01-02 00:09:46.000000000 +0100
++++ freetds.current/src/dblib/dblib.c	2008-05-26 14:49:56.000000000 +0200
+@@ -76,7 +76,7 @@
+ #include <dmalloc.h>
+ #endif
+ 
+-TDS_RCSID(var, "$Id$");
++TDS_RCSID(var, "$Id$");
+ 
+ static RETCODE _dbresults(DBPROCESS * dbproc);
+ static int _db_get_server_type(int bindtype);
+@@ -3325,8 +3325,10 @@
+ 			computeid = status;
+ 
+ 			for (i = 0;; ++i) {
+-				if (i >= tds->num_comp_info)
++				if (i >= tds->num_comp_info) {
++					free(col_printlens);
+ 					return FAIL;
++				}
+ 				resinfo = tds->comp_info[i];
+ 				if (resinfo->computeid == computeid)
+ 					break;
+diff -urN freetds/src/odbc/odbc.c freetds.current/src/odbc/odbc.c
+--- freetds/src/odbc/odbc.c	2008-04-30 16:59:32.000000000 +0200
++++ freetds.current/src/odbc/odbc.c	2008-06-18 06:11:39.000000000 +0200
+@@ -60,7 +60,7 @@
+ #include <dmalloc.h>
+ #endif
+ 
+-TDS_RCSID(var, "$Id$");
++TDS_RCSID(var, "$Id$");
+ 
+ static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc);
+ static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv);
+@@ -3608,10 +3608,6 @@
+ 					truncated = 1;
+ 					stmt->errs.lastrc = SQL_SUCCESS_WITH_INFO;
+ 				}
+-			} else {
+-				/* TODO change when we code cursors support... */
+-				/* stop looping, forward cursor support only one row */
+-				num_rows = 1;
+ 			}
+ 			if (drec_ard->sql_desc_octet_length_ptr)
+ 				*AT_ROW(drec_ard->sql_desc_octet_length_ptr, SQLLEN) = len;
+@@ -3648,11 +3644,33 @@
+ SQLRETURN ODBC_API
+ SQLFetch(SQLHSTMT hstmt)
+ {
++	SQLRETURN ret;
++	SQLULEN  save_sql_desc_array_size;
++	SQLULEN *save_sql_desc_rows_processed_ptr;
++	SQLUSMALLINT *save_sql_desc_array_status_ptr;
++
+ 	INIT_HSTMT;
+ 
+ 	tdsdump_log(TDS_DBG_FUNC, "SQLFetch(%p)\n", hstmt);
+ 
+-	ODBC_RETURN(stmt, _SQLFetch(stmt, SQL_FETCH_NEXT, 0));
++	if (stmt->dbc->env->attr.odbc_version != SQL_OV_ODBC3) {
++		save_sql_desc_array_size = stmt->ard->header.sql_desc_array_size;
++		stmt->ard->header.sql_desc_array_size = 1;
++		save_sql_desc_rows_processed_ptr = stmt->ird->header.sql_desc_rows_processed_ptr;
++		stmt->ird->header.sql_desc_rows_processed_ptr = NULL;
++		save_sql_desc_array_status_ptr = stmt->ird->header.sql_desc_array_status_ptr;
++		stmt->ird->header.sql_desc_array_status_ptr = NULL;
++	}
++
++	ret = _SQLFetch(stmt, SQL_FETCH_NEXT, 0);
++
++	if (stmt->dbc->env->attr.odbc_version != SQL_OV_ODBC3) {
++		stmt->ard->header.sql_desc_array_size = save_sql_desc_array_size;
++		stmt->ird->header.sql_desc_rows_processed_ptr = save_sql_desc_rows_processed_ptr;
++		stmt->ird->header.sql_desc_array_status_ptr = save_sql_desc_array_status_ptr;
++	}
++
++	ODBC_RETURN(stmt, ret);
+ }
+ 
+ #if (ODBCVER >= 0x0300)
+@@ -4564,6 +4582,8 @@
+ 	SQLLEN dummy_cb;
+ 	int nSybType;
+ 
++	int extra_bytes = 0;
++
+ 	INIT_HSTMT;
+ 
+ 	tdsdump_log(TDS_DBG_FUNC, "SQLGetData(%p, %u, %d, %p, %d, %p)\n", 
+@@ -4601,42 +4621,140 @@
+ 	if (colinfo->column_cur_size < 0) {
+ 		*pcbValue = SQL_NULL_DATA;
+ 	} else {
++		nSybType = tds_get_conversion_type(colinfo->column_type, colinfo->column_size);
++		if (fCType == SQL_C_DEFAULT)
++			fCType = odbc_sql_to_c_type_default(stmt->ird->records[icol - 1].sql_desc_concise_type);
++		if (fCType == SQL_ARD_TYPE) {
++			if (icol > stmt->ard->header.sql_desc_count) {
++				odbc_errs_add(&stmt->errs, "07009", NULL);
++				ODBC_RETURN(stmt, SQL_ERROR);
++			}
++			fCType = stmt->ard->records[icol - 1].sql_desc_concise_type;
++		}
++		assert(fCType);
++
+ 		src = (TDS_CHAR *) colinfo->column_data;
+ 		if (is_variable_type(colinfo->column_type)) {
+-			if (colinfo->column_text_sqlgetdatapos > 0
+-			    && colinfo->column_text_sqlgetdatapos >= colinfo->column_cur_size)
+-				ODBC_RETURN(stmt, SQL_NO_DATA);
+-
++			int nread = 0;
++			
+ 			/* 2003-8-29 check for an old bug -- freddy77 */
+ 			assert(colinfo->column_text_sqlgetdatapos >= 0);
+ 			if (is_blob_type(colinfo->column_type))
+ 				src = ((TDSBLOB *) src)->textvalue;
+-			src += colinfo->column_text_sqlgetdatapos;
+-			srclen = colinfo->column_cur_size - colinfo->column_text_sqlgetdatapos;
++
++			if (fCType == SQL_C_CHAR && colinfo->column_text_sqlgetdatapos) {
++				TDS_CHAR buf[3];
++				SQLLEN len;
++
++				switch (nSybType) {
++				case SYBLONGBINARY:
++				case SYBBINARY:
++				case SYBVARBINARY:
++				case SYBIMAGE:
++				case XSYBBINARY:
++				case XSYBVARBINARY:
++				case TDS_CONVERT_BINARY:
++					if (colinfo->column_text_sqlgetdatapos % 2) {
++						nread = (colinfo->column_text_sqlgetdatapos - 1) / 2;
++						if (nread >= colinfo->column_cur_size)
++							ODBC_RETURN(stmt, SQL_NO_DATA);
++						
++						if (cbValueMax > 2) {
++							len = convert_tds2sql(context, nSybType, src + nread, 1, fCType, buf, sizeof(buf), NULL);
++							if (len < 2) {
++								if (len < 0) 
++									odbc_convert_err_set(&stmt->errs, len);
++								ODBC_RETURN(stmt, SQL_ERROR);
++							}
++							*(TDS_CHAR *) rgbValue = buf[1];
++							*((TDS_CHAR *) rgbValue + 1) = 0;
++						
++							rgbValue++;
++							cbValueMax--;
++						
++							extra_bytes = 1;
++							nread++;
++
++							if (nread >= colinfo->column_cur_size)
++								ODBC_RETURN_(stmt);
++						} else {
++							if (cbValueMax) 
++								*(TDS_CHAR *) rgbValue = 0;
++							odbc_errs_add(&stmt->errs, "01004", "String data, right truncated");
++							ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO);
++						}
++					} else {
++						nread = colinfo->column_text_sqlgetdatapos / 2;
++						if (nread >= colinfo->column_cur_size)
++							ODBC_RETURN(stmt, SQL_NO_DATA);
++					}
++					
++					src += nread;
++					srclen = colinfo->column_cur_size - nread;
++					break;
++				default:
++					if (colinfo->column_text_sqlgetdatapos >= colinfo->column_cur_size)
++						ODBC_RETURN(stmt, SQL_NO_DATA);
++						
++					src += colinfo->column_text_sqlgetdatapos;
++					srclen = colinfo->column_cur_size - colinfo->column_text_sqlgetdatapos;
++
++				}
++			} else if (fCType == SQL_C_BINARY) {
++				switch (nSybType) {
++				case SYBCHAR:
++				case SYBVARCHAR:
++				case SYBTEXT:
++				case XSYBCHAR:
++				case XSYBVARCHAR:
++					nread = (src[0] == '0' && toupper(src[1]) == 'X')? 2 : 0;
++						
++					while ((nread < colinfo->column_cur_size) && (src[nread] == ' ' || src[nread] == '\0')) 
++						nread++;
++
++					nread += colinfo->column_text_sqlgetdatapos * 2;
++					
++					if (nread && nread >= colinfo->column_cur_size)
++						ODBC_RETURN(stmt, SQL_NO_DATA);
++
++					src += nread;
++					srclen = colinfo->column_cur_size - nread;
++					break;
++				default:
++					if (colinfo->column_text_sqlgetdatapos > 0
++					&&  colinfo->column_text_sqlgetdatapos >= colinfo->column_cur_size)
++						ODBC_RETURN(stmt, SQL_NO_DATA);
++						
++					src += colinfo->column_text_sqlgetdatapos;
++					srclen = colinfo->column_cur_size - colinfo->column_text_sqlgetdatapos;
++				}
++			} else {
++				if (colinfo->column_text_sqlgetdatapos > 0
++				&&  colinfo->column_text_sqlgetdatapos >= colinfo->column_cur_size)
++					ODBC_RETURN(stmt, SQL_NO_DATA);
++
++				src += colinfo->column_text_sqlgetdatapos;
++				srclen = colinfo->column_cur_size - colinfo->column_text_sqlgetdatapos;
++			}
+ 		} else {
+ 			if (colinfo->column_text_sqlgetdatapos > 0
+-			    && colinfo->column_text_sqlgetdatapos >= colinfo->column_cur_size)
++			&&  colinfo->column_text_sqlgetdatapos >= colinfo->column_cur_size)
+ 				ODBC_RETURN(stmt, SQL_NO_DATA);
+ 
+ 			srclen = colinfo->column_cur_size;
+ 		}
+-		nSybType = tds_get_conversion_type(colinfo->column_type, colinfo->column_size);
+-		if (fCType == SQL_C_DEFAULT)
+-			fCType = odbc_sql_to_c_type_default(stmt->ird->records[icol - 1].sql_desc_concise_type);
+-		if (fCType == SQL_ARD_TYPE) {
+-			if (icol > stmt->ard->header.sql_desc_count) {
+-				odbc_errs_add(&stmt->errs, "07009", NULL);
+-				ODBC_RETURN(stmt, SQL_ERROR);
+-			}
+-			fCType = stmt->ard->records[icol - 1].sql_desc_concise_type;
+-		}
+-		assert(fCType);
++
+ 		*pcbValue = convert_tds2sql(context, nSybType, src, srclen, fCType, (TDS_CHAR *) rgbValue, cbValueMax, NULL);
+ 		if (*pcbValue < 0) {
+ 			odbc_convert_err_set(&stmt->errs, *pcbValue);
+ 			ODBC_RETURN(stmt, SQL_ERROR);
+ 		}
+-
++		
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list