My favorites
▼
|
Sign in
pyodbc
Python ODBC library
Project Home
Downloads
Wiki
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
269
attachment: pyodbc-bind-param-varchar-max.diff
(1.9 KB)
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
diff --git a/src/params.cpp b/src/params.cpp
index f7ef29f..4ffb6f8 100644
--- a/src/params.cpp
+++ b/src/params.cpp
@@ -157,10 +157,10 @@ static bool GetBytesInfo(Cursor* cur, Py_ssize_t index, PyObject* param, ParamIn
#else
info.ValueType = SQL_C_CHAR;
- info.ColumnSize = (SQLUINTEGER)max(len, 1);
if (len <= cur->cnxn->varchar_maxlength)
{
+ info.ColumnSize = (SQLUINTEGER)cur->cnxn->varchar_maxlength;
info.ParameterType = SQL_VARCHAR;
info.StrLen_or_Ind = len;
info.ParameterValuePtr = PyBytes_AS_STRING(param);
@@ -168,6 +168,7 @@ static bool GetBytesInfo(Cursor* cur, Py_ssize_t index, PyObject* param, ParamIn
else
{
// Too long to pass all at once, so we'll provide the data at execute.
+ info.ColumnSize = (SQLUINTEGER)len;
info.ParameterType = SQL_LONGVARCHAR;
info.StrLen_or_Ind = SQL_LEN_DATA_AT_EXEC((SQLLEN)len);
info.ParameterValuePtr = param;
@@ -183,10 +184,10 @@ static bool GetUnicodeInfo(Cursor* cur, Py_ssize_t index, PyObject* param, Param
Py_ssize_t len = PyUnicode_GET_SIZE(param);
info.ValueType = SQL_C_WCHAR;
- info.ColumnSize = (SQLUINTEGER)max(len, 1);
if (len <= cur->cnxn->wvarchar_maxlength)
{
+ info.ColumnSize = (SQLUINTEGER)cur->cnxn->wvarchar_maxlength;
if (SQLWCHAR_SIZE == Py_UNICODE_SIZE)
{
info.ParameterValuePtr = pch;
@@ -213,7 +214,7 @@ static bool GetUnicodeInfo(Cursor* cur, Py_ssize_t index, PyObject* param, Param
else
{
// Too long to pass all at once, so we'll provide the data at execute.
-
+ info.ColumnSize = (SQLUINTEGER)len;
info.ParameterType = SQL_WLONGVARCHAR;
info.StrLen_or_Ind = SQL_LEN_DATA_AT_EXEC((SQLLEN)(len * sizeof(SQLWCHAR)));
info.ParameterValuePtr = param;
Powered by
Google Project Hosting