Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 1 | /* statement.c - the statement type |
| 2 | * |
| 3 | * Copyright (C) 2005-2006 Gerhard Häring <gh@ghaering.de> |
| 4 | * |
| 5 | * This file is part of pysqlite. |
| 6 | * |
| 7 | * This software is provided 'as-is', without any express or implied |
| 8 | * warranty. In no event will the authors be held liable for any damages |
| 9 | * arising from the use of this software. |
| 10 | * |
| 11 | * Permission is granted to anyone to use this software for any purpose, |
| 12 | * including commercial applications, and to alter it and redistribute it |
| 13 | * freely, subject to the following restrictions: |
| 14 | * |
| 15 | * 1. The origin of this software must not be misrepresented; you must not |
| 16 | * claim that you wrote the original software. If you use this software |
| 17 | * in a product, an acknowledgment in the product documentation would be |
| 18 | * appreciated but is not required. |
| 19 | * 2. Altered source versions must be plainly marked as such, and must not be |
| 20 | * misrepresented as being the original software. |
| 21 | * 3. This notice may not be removed or altered from any source distribution. |
| 22 | */ |
| 23 | |
| 24 | #include "statement.h" |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 25 | #include "cursor.h" |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 26 | #include "connection.h" |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 27 | #include "microprotocols.h" |
| 28 | #include "prepare_protocol.h" |
Anthony Baxter | 72289a6 | 2006-04-04 06:29:05 +0000 | [diff] [blame] | 29 | #include "sqlitecompat.h" |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 30 | |
| 31 | /* prototypes */ |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 32 | static int pysqlite_check_remaining_sql(const char* tail); |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 33 | |
| 34 | typedef enum { |
| 35 | LINECOMMENT_1, |
| 36 | IN_LINECOMMENT, |
| 37 | COMMENTSTART_1, |
| 38 | IN_COMMENT, |
| 39 | COMMENTEND_1, |
| 40 | NORMAL |
| 41 | } parse_remaining_sql_state; |
| 42 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 43 | int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* connection, PyObject* sql) |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 44 | { |
| 45 | const char* tail; |
| 46 | int rc; |
| 47 | PyObject* sql_str; |
| 48 | char* sql_cstr; |
| 49 | |
| 50 | self->st = NULL; |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 51 | self->in_use = 0; |
| 52 | |
| 53 | if (PyString_Check(sql)) { |
| 54 | sql_str = sql; |
| 55 | Py_INCREF(sql_str); |
| 56 | } else if (PyUnicode_Check(sql)) { |
| 57 | sql_str = PyUnicode_AsUTF8String(sql); |
| 58 | if (!sql_str) { |
| 59 | rc = PYSQLITE_SQL_WRONG_TYPE; |
| 60 | return rc; |
| 61 | } |
| 62 | } else { |
| 63 | rc = PYSQLITE_SQL_WRONG_TYPE; |
| 64 | return rc; |
| 65 | } |
| 66 | |
Gerhard Häring | 3e99c0a | 2006-04-23 15:24:26 +0000 | [diff] [blame] | 67 | self->in_weakreflist = NULL; |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 68 | self->sql = sql_str; |
| 69 | |
| 70 | sql_cstr = PyString_AsString(sql_str); |
| 71 | |
| 72 | rc = sqlite3_prepare(connection->db, |
| 73 | sql_cstr, |
| 74 | -1, |
| 75 | &self->st, |
| 76 | &tail); |
| 77 | |
| 78 | self->db = connection->db; |
| 79 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 80 | if (rc == SQLITE_OK && pysqlite_check_remaining_sql(tail)) { |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 81 | (void)sqlite3_finalize(self->st); |
Neal Norwitz | 195e4e6 | 2006-04-16 03:37:19 +0000 | [diff] [blame] | 82 | self->st = NULL; |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 83 | rc = PYSQLITE_TOO_MUCH_SQL; |
| 84 | } |
| 85 | |
| 86 | return rc; |
| 87 | } |
| 88 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 89 | int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter) |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 90 | { |
| 91 | int rc = SQLITE_OK; |
| 92 | long longval; |
| 93 | #ifdef HAVE_LONG_LONG |
| 94 | PY_LONG_LONG longlongval; |
| 95 | #endif |
| 96 | const char* buffer; |
| 97 | char* string; |
Neal Norwitz | 95f0e4c | 2006-04-01 09:08:06 +0000 | [diff] [blame] | 98 | Py_ssize_t buflen; |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 99 | PyObject* stringval; |
| 100 | |
| 101 | if (parameter == Py_None) { |
| 102 | rc = sqlite3_bind_null(self->st, pos); |
| 103 | } else if (PyInt_Check(parameter)) { |
| 104 | longval = PyInt_AsLong(parameter); |
| 105 | rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longval); |
| 106 | #ifdef HAVE_LONG_LONG |
| 107 | } else if (PyLong_Check(parameter)) { |
| 108 | longlongval = PyLong_AsLongLong(parameter); |
| 109 | /* in the overflow error case, longlongval is -1, and an exception is set */ |
| 110 | rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longlongval); |
| 111 | #endif |
| 112 | } else if (PyFloat_Check(parameter)) { |
| 113 | rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter)); |
| 114 | } else if (PyBuffer_Check(parameter)) { |
| 115 | if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) { |
| 116 | rc = sqlite3_bind_blob(self->st, pos, buffer, buflen, SQLITE_TRANSIENT); |
| 117 | } else { |
| 118 | PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer"); |
| 119 | rc = -1; |
| 120 | } |
| 121 | } else if PyString_Check(parameter) { |
| 122 | string = PyString_AsString(parameter); |
| 123 | rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT); |
| 124 | } else if PyUnicode_Check(parameter) { |
| 125 | stringval = PyUnicode_AsUTF8String(parameter); |
| 126 | string = PyString_AsString(stringval); |
| 127 | rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT); |
| 128 | Py_DECREF(stringval); |
| 129 | } else { |
| 130 | rc = -1; |
| 131 | } |
| 132 | |
| 133 | return rc; |
| 134 | } |
| 135 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 136 | void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* parameters) |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 137 | { |
| 138 | PyObject* current_param; |
| 139 | PyObject* adapted; |
| 140 | const char* binding_name; |
| 141 | int i; |
| 142 | int rc; |
| 143 | int num_params_needed; |
| 144 | int num_params; |
| 145 | |
| 146 | Py_BEGIN_ALLOW_THREADS |
| 147 | num_params_needed = sqlite3_bind_parameter_count(self->st); |
| 148 | Py_END_ALLOW_THREADS |
| 149 | |
| 150 | if (PyDict_Check(parameters)) { |
| 151 | /* parameters passed as dictionary */ |
| 152 | for (i = 1; i <= num_params_needed; i++) { |
| 153 | Py_BEGIN_ALLOW_THREADS |
| 154 | binding_name = sqlite3_bind_parameter_name(self->st, i); |
| 155 | Py_END_ALLOW_THREADS |
| 156 | if (!binding_name) { |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 157 | PyErr_Format(pysqlite_ProgrammingError, "Binding %d has no name, but you supplied a dictionary (which has only names).", i); |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 158 | return; |
| 159 | } |
| 160 | |
| 161 | binding_name++; /* skip first char (the colon) */ |
| 162 | current_param = PyDict_GetItemString(parameters, binding_name); |
| 163 | if (!current_param) { |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 164 | PyErr_Format(pysqlite_ProgrammingError, "You did not supply a value for binding %d.", i); |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 165 | return; |
| 166 | } |
| 167 | |
| 168 | Py_INCREF(current_param); |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 169 | adapted = microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL); |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 170 | if (adapted) { |
| 171 | Py_DECREF(current_param); |
| 172 | } else { |
| 173 | PyErr_Clear(); |
| 174 | adapted = current_param; |
| 175 | } |
| 176 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 177 | rc = pysqlite_statement_bind_parameter(self, i, adapted); |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 178 | Py_DECREF(adapted); |
| 179 | |
| 180 | if (rc != SQLITE_OK) { |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 181 | PyErr_Format(pysqlite_InterfaceError, "Error binding parameter :%s - probably unsupported type.", binding_name); |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 182 | return; |
| 183 | } |
| 184 | } |
| 185 | } else { |
| 186 | /* parameters passed as sequence */ |
| 187 | num_params = PySequence_Length(parameters); |
| 188 | if (num_params != num_params_needed) { |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 189 | PyErr_Format(pysqlite_ProgrammingError, "Incorrect number of bindings supplied. The current statement uses %d, and there are %d supplied.", |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 190 | num_params_needed, num_params); |
| 191 | return; |
| 192 | } |
| 193 | for (i = 0; i < num_params; i++) { |
| 194 | current_param = PySequence_GetItem(parameters, i); |
| 195 | if (!current_param) { |
| 196 | return; |
| 197 | } |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 198 | adapted = microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL); |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 199 | |
| 200 | if (adapted) { |
| 201 | Py_DECREF(current_param); |
| 202 | } else { |
| 203 | PyErr_Clear(); |
| 204 | adapted = current_param; |
| 205 | } |
| 206 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 207 | rc = pysqlite_statement_bind_parameter(self, i + 1, adapted); |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 208 | Py_DECREF(adapted); |
| 209 | |
| 210 | if (rc != SQLITE_OK) { |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 211 | PyErr_Format(pysqlite_InterfaceError, "Error binding parameter %d - probably unsupported type.", i); |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 212 | return; |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 218 | int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params) |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 219 | { |
| 220 | const char* tail; |
| 221 | int rc; |
| 222 | char* sql_cstr; |
| 223 | sqlite3_stmt* new_st; |
| 224 | |
| 225 | sql_cstr = PyString_AsString(self->sql); |
| 226 | |
| 227 | rc = sqlite3_prepare(self->db, |
| 228 | sql_cstr, |
| 229 | -1, |
| 230 | &new_st, |
| 231 | &tail); |
| 232 | |
| 233 | if (rc == SQLITE_OK) { |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 234 | /* The efficient sqlite3_transfer_bindings is only available in SQLite |
| 235 | * version 3.2.2 or later. For older SQLite releases, that might not |
| 236 | * even define SQLITE_VERSION_NUMBER, we do it the manual way. |
| 237 | */ |
| 238 | #ifdef SQLITE_VERSION_NUMBER |
| 239 | #if SQLITE_VERSION_NUMBER >= 3002002 |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 240 | (void)sqlite3_transfer_bindings(self->st, new_st); |
Anthony Baxter | 07f5b35 | 2006-04-01 08:36:27 +0000 | [diff] [blame] | 241 | #endif |
| 242 | #else |
| 243 | statement_bind_parameters(self, params); |
| 244 | #endif |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 245 | |
| 246 | (void)sqlite3_finalize(self->st); |
| 247 | self->st = new_st; |
| 248 | } |
| 249 | |
| 250 | return rc; |
| 251 | } |
| 252 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 253 | int pysqlite_statement_finalize(pysqlite_Statement* self) |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 254 | { |
| 255 | int rc; |
| 256 | |
| 257 | rc = SQLITE_OK; |
| 258 | if (self->st) { |
| 259 | Py_BEGIN_ALLOW_THREADS |
| 260 | rc = sqlite3_finalize(self->st); |
| 261 | Py_END_ALLOW_THREADS |
| 262 | self->st = NULL; |
| 263 | } |
| 264 | |
| 265 | self->in_use = 0; |
| 266 | |
| 267 | return rc; |
| 268 | } |
| 269 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 270 | int pysqlite_statement_reset(pysqlite_Statement* self) |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 271 | { |
| 272 | int rc; |
| 273 | |
| 274 | rc = SQLITE_OK; |
| 275 | |
| 276 | if (self->in_use && self->st) { |
| 277 | Py_BEGIN_ALLOW_THREADS |
| 278 | rc = sqlite3_reset(self->st); |
| 279 | Py_END_ALLOW_THREADS |
| 280 | |
| 281 | if (rc == SQLITE_OK) { |
| 282 | self->in_use = 0; |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | return rc; |
| 287 | } |
| 288 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 289 | void pysqlite_statement_mark_dirty(pysqlite_Statement* self) |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 290 | { |
| 291 | self->in_use = 1; |
| 292 | } |
| 293 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 294 | void pysqlite_statement_dealloc(pysqlite_Statement* self) |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 295 | { |
| 296 | int rc; |
| 297 | |
| 298 | if (self->st) { |
| 299 | Py_BEGIN_ALLOW_THREADS |
| 300 | rc = sqlite3_finalize(self->st); |
| 301 | Py_END_ALLOW_THREADS |
| 302 | } |
| 303 | |
| 304 | self->st = NULL; |
| 305 | |
| 306 | Py_XDECREF(self->sql); |
| 307 | |
Gerhard Häring | 3e99c0a | 2006-04-23 15:24:26 +0000 | [diff] [blame] | 308 | if (self->in_weakreflist != NULL) { |
| 309 | PyObject_ClearWeakRefs((PyObject*)self); |
| 310 | } |
| 311 | |
Martin v. Löwis | 6819210 | 2007-07-21 06:55:02 +0000 | [diff] [blame^] | 312 | Py_Type(self)->tp_free((PyObject*)self); |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /* |
| 316 | * Checks if there is anything left in an SQL string after SQLite compiled it. |
| 317 | * This is used to check if somebody tried to execute more than one SQL command |
| 318 | * with one execute()/executemany() command, which the DB-API and we don't |
| 319 | * allow. |
| 320 | * |
| 321 | * Returns 1 if there is more left than should be. 0 if ok. |
| 322 | */ |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 323 | static int pysqlite_check_remaining_sql(const char* tail) |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 324 | { |
| 325 | const char* pos = tail; |
| 326 | |
| 327 | parse_remaining_sql_state state = NORMAL; |
| 328 | |
| 329 | for (;;) { |
| 330 | switch (*pos) { |
| 331 | case 0: |
| 332 | return 0; |
| 333 | case '-': |
| 334 | if (state == NORMAL) { |
| 335 | state = LINECOMMENT_1; |
| 336 | } else if (state == LINECOMMENT_1) { |
| 337 | state = IN_LINECOMMENT; |
| 338 | } |
| 339 | break; |
| 340 | case ' ': |
| 341 | case '\t': |
| 342 | break; |
| 343 | case '\n': |
| 344 | case 13: |
| 345 | if (state == IN_LINECOMMENT) { |
| 346 | state = NORMAL; |
| 347 | } |
| 348 | break; |
| 349 | case '/': |
| 350 | if (state == NORMAL) { |
| 351 | state = COMMENTSTART_1; |
| 352 | } else if (state == COMMENTEND_1) { |
| 353 | state = NORMAL; |
| 354 | } else if (state == COMMENTSTART_1) { |
| 355 | return 1; |
| 356 | } |
| 357 | break; |
| 358 | case '*': |
| 359 | if (state == NORMAL) { |
| 360 | return 1; |
| 361 | } else if (state == LINECOMMENT_1) { |
| 362 | return 1; |
| 363 | } else if (state == COMMENTSTART_1) { |
| 364 | state = IN_COMMENT; |
| 365 | } else if (state == IN_COMMENT) { |
| 366 | state = COMMENTEND_1; |
| 367 | } |
| 368 | break; |
| 369 | default: |
| 370 | if (state == COMMENTEND_1) { |
| 371 | state = IN_COMMENT; |
| 372 | } else if (state == IN_LINECOMMENT) { |
| 373 | } else if (state == IN_COMMENT) { |
| 374 | } else { |
| 375 | return 1; |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | pos++; |
| 380 | } |
| 381 | |
| 382 | return 0; |
| 383 | } |
| 384 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 385 | PyTypeObject pysqlite_StatementType = { |
Martin v. Löwis | 6819210 | 2007-07-21 06:55:02 +0000 | [diff] [blame^] | 386 | PyVarObject_HEAD_INIT(NULL, 0) |
Anthony Baxter | 8e7b490 | 2006-04-05 18:25:33 +0000 | [diff] [blame] | 387 | MODULE_NAME ".Statement", /* tp_name */ |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 388 | sizeof(pysqlite_Statement), /* tp_basicsize */ |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 389 | 0, /* tp_itemsize */ |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 390 | (destructor)pysqlite_statement_dealloc, /* tp_dealloc */ |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 391 | 0, /* tp_print */ |
| 392 | 0, /* tp_getattr */ |
| 393 | 0, /* tp_setattr */ |
| 394 | 0, /* tp_compare */ |
| 395 | 0, /* tp_repr */ |
| 396 | 0, /* tp_as_number */ |
| 397 | 0, /* tp_as_sequence */ |
| 398 | 0, /* tp_as_mapping */ |
| 399 | 0, /* tp_hash */ |
| 400 | 0, /* tp_call */ |
| 401 | 0, /* tp_str */ |
| 402 | 0, /* tp_getattro */ |
| 403 | 0, /* tp_setattro */ |
| 404 | 0, /* tp_as_buffer */ |
Gerhard Häring | 3e99c0a | 2006-04-23 15:24:26 +0000 | [diff] [blame] | 405 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 406 | 0, /* tp_doc */ |
| 407 | 0, /* tp_traverse */ |
| 408 | 0, /* tp_clear */ |
| 409 | 0, /* tp_richcompare */ |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 410 | offsetof(pysqlite_Statement, in_weakreflist), /* tp_weaklistoffset */ |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 411 | 0, /* tp_iter */ |
| 412 | 0, /* tp_iternext */ |
| 413 | 0, /* tp_methods */ |
| 414 | 0, /* tp_members */ |
| 415 | 0, /* tp_getset */ |
| 416 | 0, /* tp_base */ |
| 417 | 0, /* tp_dict */ |
| 418 | 0, /* tp_descr_get */ |
| 419 | 0, /* tp_descr_set */ |
| 420 | 0, /* tp_dictoffset */ |
| 421 | (initproc)0, /* tp_init */ |
| 422 | 0, /* tp_alloc */ |
| 423 | 0, /* tp_new */ |
| 424 | 0 /* tp_free */ |
| 425 | }; |
| 426 | |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 427 | extern int pysqlite_statement_setup_types(void) |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 428 | { |
Gerhard Häring | 0741a60 | 2007-01-14 01:43:50 +0000 | [diff] [blame] | 429 | pysqlite_StatementType.tp_new = PyType_GenericNew; |
| 430 | return PyType_Ready(&pysqlite_StatementType); |
Anthony Baxter | c51ee69 | 2006-04-01 00:57:31 +0000 | [diff] [blame] | 431 | } |