summaryrefslogtreecommitdiffstats
path: root/dev-db/freetds/files/SQLGetData_cvs.patch
blob: 5631c22ac2c172b9852ed6e1665ab4a98a1c83c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
diff -dPNur freetds-0.82-ds1/src/odbc/odbc.c freetds-0.82-ds2/src/odbc/odbc.c
--- freetds-0.82-ds1/src/odbc/odbc.c	2008-07-01 19:19:14.000000000 +0200
+++ freetds-0.82-ds2/src/odbc/odbc.c	2008-07-01 19:19:25.000000000 +0200
@@ -4564,6 +4564,7 @@
 	SQLLEN dummy_cb;
 	int nSybType;
 
+	TDS_INT converted_column_cur_size;
 	int extra_bytes = 0;
 
 	INIT_HSTMT;
@@ -4599,6 +4600,7 @@
 		ODBC_RETURN(stmt, SQL_ERROR);
 	}
 	colinfo = resinfo->columns[icol - 1];
+	converted_column_cur_size = colinfo->column_cur_size;
 
 	if (colinfo->column_cur_size < 0) {
 		*pcbValue = SQL_NULL_DATA;
@@ -4624,7 +4626,7 @@
 			if (is_blob_type(colinfo->column_type))
 				src = ((TDSBLOB *) src)->textvalue;
 
-			if (fCType == SQL_C_CHAR && colinfo->column_text_sqlgetdatapos) {
+			if (fCType == SQL_C_CHAR) {
 				TDS_CHAR buf[3];
 				SQLLEN len;
 
@@ -4667,12 +4669,15 @@
 						}
 					} else {
 						nread = colinfo->column_text_sqlgetdatapos / 2;
-						if (nread >= colinfo->column_cur_size)
+						
+						if (colinfo->column_text_sqlgetdatapos > 0
+						    && nread >= colinfo->column_cur_size)
 							ODBC_RETURN(stmt, SQL_NO_DATA);
 					}
 					
 					src += nread;
 					srclen = colinfo->column_cur_size - nread;
+					converted_column_cur_size *= 2;
 					break;
 				default:
 					if (colinfo->column_text_sqlgetdatapos >= colinfo->column_cur_size)
@@ -4701,6 +4706,12 @@
 
 					src += nread;
 					srclen = colinfo->column_cur_size - nread;
+					
+					if (converted_column_cur_size%2)
+						converted_column_cur_size = (converted_column_cur_size + 1) / 2;
+					else
+						converted_column_cur_size /= 2;
+					
 					break;
 				default:
 					if (colinfo->column_text_sqlgetdatapos > 0
@@ -4751,7 +4762,7 @@
 			if (colinfo->column_text_sqlgetdatapos == 0 && cbValueMax > 0)
 				++colinfo->column_text_sqlgetdatapos;
 			/* not all readed ?? */
-			if (colinfo->column_text_sqlgetdatapos < colinfo->column_cur_size) {
+			if (colinfo->column_text_sqlgetdatapos < converted_column_cur_size) {
 				odbc_errs_add(&stmt->errs, "01004", "String data, right truncated");
 				ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO);
 			}