Changeset 391 for python/trunk/Modules/_sqlite/statement.c
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Modules/_sqlite/statement.c
r2 r391 1 1 /* statement.c - the statement type 2 2 * 3 * Copyright (C) 2005-20 07Gerhard Häring <gh@ghaering.de>3 * Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> 4 4 * 5 5 * This file is part of pysqlite. … … 27 27 #include "microprotocols.h" 28 28 #include "prepare_protocol.h" 29 #include "util.h" 29 30 #include "sqlitecompat.h" 30 31 … … 102 103 { 103 104 int rc = SQLITE_OK; 104 long longval;105 PY_LONG_LONG longlongval;106 105 const char* buffer; 107 106 char* string; … … 154 153 155 154 switch (paramtype) { 156 case TYPE_INT: 157 long val = PyInt_AsLong(parameter);158 rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longval);155 case TYPE_INT: { 156 long longval = PyInt_AsLong(parameter); 157 rc = sqlite3_bind_int64(self->st, pos, longval); 159 158 break; 160 case TYPE_LONG: 161 longlongval = PyLong_AsLongLong(parameter); 162 /* in the overflow error case, longlongval is -1, and an exception is set */ 163 rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longlongval); 159 } 160 case TYPE_LONG: { 161 sqlite_int64 value = _pysqlite_long_as_int64(parameter); 162 if (value == -1 && PyErr_Occurred()) 163 rc = -1; 164 else 165 rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)value); 164 166 break; 167 } 165 168 case TYPE_FLOAT: 166 169 rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter)); 167 170 break; 168 171 case TYPE_STRING: 169 string = PyString_AS_STRING(parameter);170 rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);172 PyString_AsStringAndSize(parameter, &string, &buflen); 173 rc = sqlite3_bind_text(self->st, pos, string, buflen, SQLITE_TRANSIENT); 171 174 break; 172 175 case TYPE_UNICODE: 173 176 stringval = PyUnicode_AsUTF8String(parameter); 174 string = PyString_AsString(stringval);175 rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);177 PyString_AsStringAndSize(stringval, &string, &buflen); 178 rc = sqlite3_bind_text(self->st, pos, string, buflen, SQLITE_TRANSIENT); 176 179 Py_DECREF(stringval); 177 180 break; … … 199 202 } 200 203 201 if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj) 204 if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj) 202 205 || PyFloat_CheckExact(obj) || PyString_CheckExact(obj) 203 206 || PyUnicode_CheckExact(obj) || PyBuffer_Check(obj)) {
Note:
See TracChangeset
for help on using the changeset viewer.