Lines 1-73
Link Here
|
1 |
--- src/modules/Odbc/odbc_result.c.old Wed Nov 16 10:55:43 2005 |
|
|
2 |
+++ src/modules/Odbc/odbc_result.c Wed Nov 16 10:55:48 2005 |
3 |
@@ -2,7 +2,7 @@ |
4 |
|| This file is part of Pike. For copyright information see COPYRIGHT. |
5 |
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING |
6 |
|| for more information. |
7 |
-|| $Id: odbc_result.c,v 1.37 2003/05/02 12:54:37 grubba Exp $ |
8 |
+|| $Id: odbc_result.c,v 1.38 2005/11/09 13:12:35 grubba Exp $ |
9 |
*/ |
10 |
|
11 |
/* |
12 |
@@ -21,7 +21,7 @@ |
13 |
#include "config.h" |
14 |
#endif /* HAVE_CONFIG_H */ |
15 |
|
16 |
-RCSID("$Id: odbc_result.c,v 1.37 2003/05/02 12:54:37 grubba Exp $"); |
17 |
+RCSID("$Id: odbc_result.c,v 1.38 2005/11/09 13:12:35 grubba Exp $"); |
18 |
|
19 |
#include "interpret.h" |
20 |
#include "object.h" |
21 |
@@ -442,6 +442,18 @@ |
22 |
push_int(0); |
23 |
} |
24 |
break; |
25 |
+ } else if (code == SQL_SUCCESS_WITH_INFO) { |
26 |
+ /* Data truncated. */ |
27 |
+ num_strings++; |
28 |
+#ifdef ODBC_DEBUG |
29 |
+ fprintf(stderr, "[%d] ", num_strings); |
30 |
+#endif /* ODBC_DEBUG */ |
31 |
+ if (PIKE_ODBC_RES->field_info[i].type == SQL_C_BINARY) { |
32 |
+ push_string(make_shared_binary_string(blob_buf, BLOB_BUFSIZ)); |
33 |
+ } else { |
34 |
+ /* SQL_C_CHAR's are NUL-terminated... */ |
35 |
+ push_string(make_shared_binary_string(blob_buf, BLOB_BUFSIZ - 1)); |
36 |
+ } |
37 |
} else { |
38 |
num_strings++; |
39 |
#ifdef ODBC_DEBUG |
40 |
@@ -453,15 +465,27 @@ |
41 |
#endif /* SQL_NO_TOTAL */ |
42 |
) { |
43 |
push_string(make_shared_binary_string(blob_buf, len)); |
44 |
- break; |
45 |
} else { |
46 |
- if (PIKE_ODBC_RES->field_info[i].type == SQL_C_BINARY) { |
47 |
- push_string(make_shared_binary_string(blob_buf, BLOB_BUFSIZ)); |
48 |
- } else { |
49 |
- /* SQL_C_CHAR's are NUL-terminated... */ |
50 |
- push_string(make_shared_binary_string(blob_buf, BLOB_BUFSIZ - 1)); |
51 |
+ /* Truncated, but no support for chained SQLGetData calls. */ |
52 |
+ char *buf = xalloc(len+2); |
53 |
+ SQLLEN newlen = 0; |
54 |
+ code = SQLGetData(PIKE_ODBC_RES->hstmt, (SQLUSMALLINT)(i+1), |
55 |
+ PIKE_ODBC_RES->field_info[i].type, |
56 |
+ buf, len+1, &newlen); |
57 |
+ if (code != SQL_SUCCESS) { |
58 |
+ Pike_error("odbc->fetch_row(): " |
59 |
+ "Unexpected code from SQLGetData(): %d\n", |
60 |
+ code); |
61 |
} |
62 |
+ if (len != newlen) { |
63 |
+ Pike_error("odbc->fetch_row(): " |
64 |
+ "Unexpected length from SQLGetData(): " |
65 |
+ "%d (expected %d)\n", newlen, len); |
66 |
+ } |
67 |
+ push_string(make_shared_binary_string(buf, len)); |
68 |
+ free(buf); |
69 |
} |
70 |
+ break; |
71 |
} |
72 |
} |
73 |
if (num_strings > 1) { |