annotate Modules/_sqlite/statement.c @ 58765:2ba7677bfa95 legacy-trunk

testCopysign was defined twice in test_math; combine the definitions
author Mark Dickinson <dickinsm@gmail.com>
date Sat, 06 Feb 2010 23:11:25 +0000
parents 76bc75772736
children 787b969d37f0 04d3ae52ff73
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
1 /* statement.c - the statement type
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
2 *
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
3 * Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
4 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
5 * This file is part of pysqlite.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
6 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
7 * This software is provided 'as-is', without any express or implied
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
8 * warranty. In no event will the authors be held liable for any damages
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
9 * arising from the use of this software.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
10 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
11 * Permission is granted to anyone to use this software for any purpose,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
12 * including commercial applications, and to alter it and redistribute it
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
13 * freely, subject to the following restrictions:
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
14 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
15 * 1. The origin of this software must not be misrepresented; you must not
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
16 * claim that you wrote the original software. If you use this software
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
17 * in a product, an acknowledgment in the product documentation would be
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
18 * appreciated but is not required.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
19 * 2. Altered source versions must be plainly marked as such, and must not be
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
20 * misrepresented as being the original software.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
21 * 3. This notice may not be removed or altered from any source distribution.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
22 */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
23
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
24 #include "statement.h"
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
25 #include "cursor.h"
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
26 #include "connection.h"
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
27 #include "microprotocols.h"
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
28 #include "prepare_protocol.h"
37458
d27058c409df Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37387
diff changeset
29 #include "sqlitecompat.h"
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
30
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
31 /* prototypes */
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
32 static int pysqlite_check_remaining_sql(const char* tail);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
33
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
34 typedef enum {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
35 LINECOMMENT_1,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
36 IN_LINECOMMENT,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
37 COMMENTSTART_1,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
38 IN_COMMENT,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
39 COMMENTEND_1,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
40 NORMAL
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
41 } parse_remaining_sql_state;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
42
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
43 typedef enum {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
44 TYPE_INT,
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
45 TYPE_LONG,
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
46 TYPE_FLOAT,
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
47 TYPE_STRING,
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
48 TYPE_UNICODE,
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
49 TYPE_BUFFER,
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
50 TYPE_UNKNOWN
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
51 } parameter_type;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
52
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
53 int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* connection, PyObject* sql)
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
54 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
55 const char* tail;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
56 int rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
57 PyObject* sql_str;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
58 char* sql_cstr;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
59
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
60 self->st = NULL;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
61 self->in_use = 0;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
62
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
63 if (PyString_Check(sql)) {
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
64 sql_str = sql;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
65 Py_INCREF(sql_str);
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
66 } else if (PyUnicode_Check(sql)) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
67 sql_str = PyUnicode_AsUTF8String(sql);
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
68 if (!sql_str) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
69 rc = PYSQLITE_SQL_WRONG_TYPE;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
70 return rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
71 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
72 } else {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
73 rc = PYSQLITE_SQL_WRONG_TYPE;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
74 return rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
75 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
76
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37764
diff changeset
77 self->in_weakreflist = NULL;
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
78 self->sql = sql_str;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
79
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
80 sql_cstr = PyString_AsString(sql_str);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
81
49155
76bc75772736 Issue #3846: Release GIL during calls to sqlite3_prepare. This improves concurrent access to the same database file from multiple threads/processes.
Gerhard Häring <gh@ghaering.de>
parents: 49154
diff changeset
82 Py_BEGIN_ALLOW_THREADS
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
83 rc = sqlite3_prepare(connection->db,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
84 sql_cstr,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
85 -1,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
86 &self->st,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
87 &tail);
49155
76bc75772736 Issue #3846: Release GIL during calls to sqlite3_prepare. This improves concurrent access to the same database file from multiple threads/processes.
Gerhard Häring <gh@ghaering.de>
parents: 49154
diff changeset
88 Py_END_ALLOW_THREADS
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
89
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
90 self->db = connection->db;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
91
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
92 if (rc == SQLITE_OK && pysqlite_check_remaining_sql(tail)) {
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
93 (void)sqlite3_finalize(self->st);
37764
96addaa25869 Fix valgrind problem with invalid memory read
Neal Norwitz <nnorwitz@gmail.com>
parents: 37495
diff changeset
94 self->st = NULL;
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
95 rc = PYSQLITE_TOO_MUCH_SQL;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
96 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
97
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
98 return rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
99 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
100
46166
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
101 int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter, int allow_8bit_chars)
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
102 {
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
103 int rc = SQLITE_OK;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
104 long longval;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
105 PY_LONG_LONG longlongval;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
106 const char* buffer;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
107 char* string;
37387
4ab8ec9e59df Make ssize_t clean
Neal Norwitz <nnorwitz@gmail.com>
parents: 37381
diff changeset
108 Py_ssize_t buflen;
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
109 PyObject* stringval;
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
110 parameter_type paramtype;
46166
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
111 char* c;
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
112
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
113 if (parameter == Py_None) {
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
114 rc = sqlite3_bind_null(self->st, pos);
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
115 goto final;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
116 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
117
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
118 if (PyInt_CheckExact(parameter)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
119 paramtype = TYPE_INT;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
120 } else if (PyLong_CheckExact(parameter)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
121 paramtype = TYPE_LONG;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
122 } else if (PyFloat_CheckExact(parameter)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
123 paramtype = TYPE_FLOAT;
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
124 } else if (PyString_CheckExact(parameter)) {
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
125 paramtype = TYPE_STRING;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
126 } else if (PyUnicode_CheckExact(parameter)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
127 paramtype = TYPE_UNICODE;
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
128 } else if (PyBuffer_Check(parameter)) {
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
129 paramtype = TYPE_BUFFER;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
130 } else if (PyInt_Check(parameter)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
131 paramtype = TYPE_INT;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
132 } else if (PyLong_Check(parameter)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
133 paramtype = TYPE_LONG;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
134 } else if (PyFloat_Check(parameter)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
135 paramtype = TYPE_FLOAT;
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
136 } else if (PyString_Check(parameter)) {
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
137 paramtype = TYPE_STRING;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
138 } else if (PyUnicode_Check(parameter)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
139 paramtype = TYPE_UNICODE;
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
140 } else {
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
141 paramtype = TYPE_UNKNOWN;
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
142 }
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
143
46166
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
144 if (paramtype == TYPE_STRING && !allow_8bit_chars) {
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
145 string = PyString_AS_STRING(parameter);
46166
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
146 for (c = string; *c != 0; c++) {
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
147 if (*c & 0x80) {
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
148 PyErr_SetString(pysqlite_ProgrammingError, "You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.");
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
149 rc = -1;
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
150 goto final;
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
151 }
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
152 }
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
153 }
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
154
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
155 switch (paramtype) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
156 case TYPE_INT:
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
157 longval = PyInt_AsLong(parameter);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
158 rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longval);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
159 break;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
160 case TYPE_LONG:
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
161 longlongval = PyLong_AsLongLong(parameter);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
162 /* in the overflow error case, longlongval is -1, and an exception is set */
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
163 rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longlongval);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
164 break;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
165 case TYPE_FLOAT:
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
166 rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter));
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
167 break;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
168 case TYPE_STRING:
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
169 string = PyString_AS_STRING(parameter);
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
170 rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
171 break;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
172 case TYPE_UNICODE:
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
173 stringval = PyUnicode_AsUTF8String(parameter);
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
174 string = PyString_AsString(stringval);
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
175 rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
176 Py_DECREF(stringval);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
177 break;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
178 case TYPE_BUFFER:
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
179 if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
180 rc = sqlite3_bind_blob(self->st, pos, buffer, buflen, SQLITE_TRANSIENT);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
181 } else {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
182 PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
183 rc = -1;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
184 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
185 break;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
186 case TYPE_UNKNOWN:
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
187 rc = -1;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
188 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
189
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
190 final:
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
191 return rc;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
192 }
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
193
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
194 /* returns 0 if the object is one of Python's internal ones that don't need to be adapted */
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
195 static int _need_adapt(PyObject* obj)
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
196 {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
197 if (pysqlite_BaseTypeAdapted) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
198 return 1;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
199 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
200
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
201 if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj)
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
202 || PyFloat_CheckExact(obj) || PyString_CheckExact(obj)
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
203 || PyUnicode_CheckExact(obj) || PyBuffer_Check(obj)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
204 return 0;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
205 } else {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
206 return 1;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
207 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
208 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
209
46166
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
210 void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* parameters, int allow_8bit_chars)
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
211 {
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
212 PyObject* current_param;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
213 PyObject* adapted;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
214 const char* binding_name;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
215 int i;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
216 int rc;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
217 int num_params_needed;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
218 int num_params;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
219
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
220 Py_BEGIN_ALLOW_THREADS
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
221 num_params_needed = sqlite3_bind_parameter_count(self->st);
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
222 Py_END_ALLOW_THREADS
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
223
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
224 if (PyTuple_CheckExact(parameters) || PyList_CheckExact(parameters) || (!PyDict_Check(parameters) && PySequence_Check(parameters))) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
225 /* parameters passed as sequence */
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
226 if (PyTuple_CheckExact(parameters)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
227 num_params = PyTuple_GET_SIZE(parameters);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
228 } else if (PyList_CheckExact(parameters)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
229 num_params = PyList_GET_SIZE(parameters);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
230 } else {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
231 num_params = PySequence_Size(parameters);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
232 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
233 if (num_params != num_params_needed) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
234 PyErr_Format(pysqlite_ProgrammingError, "Incorrect number of bindings supplied. The current statement uses %d, and there are %d supplied.",
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
235 num_params_needed, num_params);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
236 return;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
237 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
238 for (i = 0; i < num_params; i++) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
239 if (PyTuple_CheckExact(parameters)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
240 current_param = PyTuple_GET_ITEM(parameters, i);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
241 Py_XINCREF(current_param);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
242 } else if (PyList_CheckExact(parameters)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
243 current_param = PyList_GET_ITEM(parameters, i);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
244 Py_XINCREF(current_param);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
245 } else {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
246 current_param = PySequence_GetItem(parameters, i);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
247 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
248 if (!current_param) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
249 return;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
250 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
251
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
252 if (!_need_adapt(current_param)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
253 adapted = current_param;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
254 } else {
49154
4c77d1016f60 Fixes issue #3103. In the sqlite3 module, made one more function static. All renaming public symbos now have the pysqlite prefix to avoid name clashes. This at least once created problems where the same symbol name appeared somewhere in Apache and the sqlite3 module was used from mod_python.
Gerhard Häring <gh@ghaering.de>
parents: 47527
diff changeset
255 adapted = pysqlite_microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL);
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
256 if (adapted) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
257 Py_DECREF(current_param);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
258 } else {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
259 PyErr_Clear();
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
260 adapted = current_param;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
261 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
262 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
263
46166
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
264 rc = pysqlite_statement_bind_parameter(self, i + 1, adapted, allow_8bit_chars);
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
265 Py_DECREF(adapted);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
266
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
267 if (rc != SQLITE_OK) {
46166
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
268 if (!PyErr_Occurred()) {
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
269 PyErr_Format(pysqlite_InterfaceError, "Error binding parameter %d - probably unsupported type.", i);
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
270 }
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
271 return;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
272 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
273 }
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
274 } else if (PyDict_Check(parameters)) {
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
275 /* parameters passed as dictionary */
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
276 for (i = 1; i <= num_params_needed; i++) {
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
277 Py_BEGIN_ALLOW_THREADS
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
278 binding_name = sqlite3_bind_parameter_name(self->st, i);
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
279 Py_END_ALLOW_THREADS
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
280 if (!binding_name) {
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
281 PyErr_Format(pysqlite_ProgrammingError, "Binding %d has no name, but you supplied a dictionary (which has only names).", i);
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
282 return;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
283 }
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
284
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
285 binding_name++; /* skip first char (the colon) */
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
286 if (PyDict_CheckExact(parameters)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
287 current_param = PyDict_GetItemString(parameters, binding_name);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
288 Py_XINCREF(current_param);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
289 } else {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
290 current_param = PyMapping_GetItemString(parameters, (char*)binding_name);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
291 }
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
292 if (!current_param) {
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
293 PyErr_Format(pysqlite_ProgrammingError, "You did not supply a value for binding %d.", i);
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
294 return;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
295 }
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
296
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
297 if (!_need_adapt(current_param)) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
298 adapted = current_param;
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
299 } else {
49154
4c77d1016f60 Fixes issue #3103. In the sqlite3 module, made one more function static. All renaming public symbos now have the pysqlite prefix to avoid name clashes. This at least once created problems where the same symbol name appeared somewhere in Apache and the sqlite3 module was used from mod_python.
Gerhard Häring <gh@ghaering.de>
parents: 47527
diff changeset
300 adapted = pysqlite_microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL);
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
301 if (adapted) {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
302 Py_DECREF(current_param);
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
303 } else {
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
304 PyErr_Clear();
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
305 adapted = current_param;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
306 }
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
307 }
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
308
46166
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
309 rc = pysqlite_statement_bind_parameter(self, i, adapted, allow_8bit_chars);
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
310 Py_DECREF(adapted);
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
311
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
312 if (rc != SQLITE_OK) {
46166
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
313 if (!PyErr_Occurred()) {
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
314 PyErr_Format(pysqlite_InterfaceError, "Error binding parameter :%s - probably unsupported type.", binding_name);
a21854e510b4 Update sqlite3 module to match current version of pysqlite.
Gerhard Häring <gh@ghaering.de>
parents: 45580
diff changeset
315 }
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
316 return;
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
317 }
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
318 }
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
319 } else {
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 44350
diff changeset
320 PyErr_SetString(PyExc_ValueError, "parameters are of unsupported type");
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
321 }
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
322 }
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
323
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
324 int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
325 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
326 const char* tail;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
327 int rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
328 char* sql_cstr;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
329 sqlite3_stmt* new_st;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
330
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
331 sql_cstr = PyString_AsString(self->sql);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
332
49155
76bc75772736 Issue #3846: Release GIL during calls to sqlite3_prepare. This improves concurrent access to the same database file from multiple threads/processes.
Gerhard Häring <gh@ghaering.de>
parents: 49154
diff changeset
333 Py_BEGIN_ALLOW_THREADS
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
334 rc = sqlite3_prepare(self->db,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
335 sql_cstr,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
336 -1,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
337 &new_st,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
338 &tail);
49155
76bc75772736 Issue #3846: Release GIL during calls to sqlite3_prepare. This improves concurrent access to the same database file from multiple threads/processes.
Gerhard Häring <gh@ghaering.de>
parents: 49154
diff changeset
339 Py_END_ALLOW_THREADS
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
340
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
341 if (rc == SQLITE_OK) {
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
342 /* The efficient sqlite3_transfer_bindings is only available in SQLite
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
343 * version 3.2.2 or later. For older SQLite releases, that might not
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
344 * even define SQLITE_VERSION_NUMBER, we do it the manual way.
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
345 */
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
346 #ifdef SQLITE_VERSION_NUMBER
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
347 #if SQLITE_VERSION_NUMBER >= 3002002
44274
a6d1059f22e2 Forward-port of commit 59184.
Gerhard Häring <gh@ghaering.de>
parents: 42333
diff changeset
348 /* The check for the number of parameters is necessary to not trigger a
a6d1059f22e2 Forward-port of commit 59184.
Gerhard Häring <gh@ghaering.de>
parents: 42333
diff changeset
349 * bug in certain SQLite versions (experienced in 3.2.8 and 3.3.4). */
a6d1059f22e2 Forward-port of commit 59184.
Gerhard Häring <gh@ghaering.de>
parents: 42333
diff changeset
350 if (sqlite3_bind_parameter_count(self->st) > 0) {
a6d1059f22e2 Forward-port of commit 59184.
Gerhard Häring <gh@ghaering.de>
parents: 42333
diff changeset
351 (void)sqlite3_transfer_bindings(self->st, new_st);
a6d1059f22e2 Forward-port of commit 59184.
Gerhard Häring <gh@ghaering.de>
parents: 42333
diff changeset
352 }
37381
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
353 #endif
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
354 #else
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
355 statement_bind_parameters(self, params);
91e9fb5cfe14 backport r243 from the pysqlite2 svn repository - lowers the required version
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
356 #endif
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
357
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
358 (void)sqlite3_finalize(self->st);
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
359 self->st = new_st;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
360 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
361
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
362 return rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
363 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
364
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
365 int pysqlite_statement_finalize(pysqlite_Statement* self)
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
366 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
367 int rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
368
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
369 rc = SQLITE_OK;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
370 if (self->st) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
371 Py_BEGIN_ALLOW_THREADS
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
372 rc = sqlite3_finalize(self->st);
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
373 Py_END_ALLOW_THREADS
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
374 self->st = NULL;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
375 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
376
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
377 self->in_use = 0;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
378
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
379 return rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
380 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
381
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
382 int pysqlite_statement_reset(pysqlite_Statement* self)
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
383 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
384 int rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
385
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
386 rc = SQLITE_OK;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
387
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
388 if (self->in_use && self->st) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
389 Py_BEGIN_ALLOW_THREADS
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
390 rc = sqlite3_reset(self->st);
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
391 Py_END_ALLOW_THREADS
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
392
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
393 if (rc == SQLITE_OK) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
394 self->in_use = 0;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
395 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
396 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
397
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
398 return rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
399 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
400
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
401 void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
402 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
403 self->in_use = 1;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
404 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
405
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
406 void pysqlite_statement_dealloc(pysqlite_Statement* self)
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
407 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
408 int rc;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
409
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
410 if (self->st) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
411 Py_BEGIN_ALLOW_THREADS
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
412 rc = sqlite3_finalize(self->st);
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
413 Py_END_ALLOW_THREADS
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
414 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
415
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
416 self->st = NULL;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
417
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
418 Py_XDECREF(self->sql);
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
419
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37764
diff changeset
420 if (self->in_weakreflist != NULL) {
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37764
diff changeset
421 PyObject_ClearWeakRefs((PyObject*)self);
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37764
diff changeset
422 }
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37764
diff changeset
423
44350
26384b8180c7 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents: 44274
diff changeset
424 Py_TYPE(self)->tp_free((PyObject*)self);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
425 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
426
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
427 /*
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
428 * Checks if there is anything left in an SQL string after SQLite compiled it.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
429 * This is used to check if somebody tried to execute more than one SQL command
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
430 * with one execute()/executemany() command, which the DB-API and we don't
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
431 * allow.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
432 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
433 * Returns 1 if there is more left than should be. 0 if ok.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
434 */
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
435 static int pysqlite_check_remaining_sql(const char* tail)
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
436 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
437 const char* pos = tail;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
438
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
439 parse_remaining_sql_state state = NORMAL;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
440
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
441 for (;;) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
442 switch (*pos) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
443 case 0:
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
444 return 0;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
445 case '-':
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
446 if (state == NORMAL) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
447 state = LINECOMMENT_1;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
448 } else if (state == LINECOMMENT_1) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
449 state = IN_LINECOMMENT;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
450 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
451 break;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
452 case ' ':
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
453 case '\t':
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
454 break;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
455 case '\n':
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
456 case 13:
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
457 if (state == IN_LINECOMMENT) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
458 state = NORMAL;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
459 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
460 break;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
461 case '/':
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
462 if (state == NORMAL) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
463 state = COMMENTSTART_1;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
464 } else if (state == COMMENTEND_1) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
465 state = NORMAL;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
466 } else if (state == COMMENTSTART_1) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
467 return 1;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
468 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
469 break;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
470 case '*':
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
471 if (state == NORMAL) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
472 return 1;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
473 } else if (state == LINECOMMENT_1) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
474 return 1;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
475 } else if (state == COMMENTSTART_1) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
476 state = IN_COMMENT;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
477 } else if (state == IN_COMMENT) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
478 state = COMMENTEND_1;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
479 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
480 break;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
481 default:
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
482 if (state == COMMENTEND_1) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
483 state = IN_COMMENT;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
484 } else if (state == IN_LINECOMMENT) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
485 } else if (state == IN_COMMENT) {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
486 } else {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
487 return 1;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
488 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
489 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
490
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
491 pos++;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
492 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
493
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
494 return 0;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
495 }
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
496
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
497 PyTypeObject pysqlite_StatementType = {
42333
6620a510e9a9 PEP 3123: Provide forward compatibility with Python 3.0, while keeping
Martin v. Löwis <martin@v.loewis.de>
parents: 40625
diff changeset
498 PyVarObject_HEAD_INIT(NULL, 0)
37495
d3969aeba777 upgrade to final version of pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37458
diff changeset
499 MODULE_NAME ".Statement", /* tp_name */
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
500 sizeof(pysqlite_Statement), /* tp_basicsize */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
501 0, /* tp_itemsize */
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
502 (destructor)pysqlite_statement_dealloc, /* tp_dealloc */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
503 0, /* tp_print */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
504 0, /* tp_getattr */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
505 0, /* tp_setattr */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
506 0, /* tp_compare */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
507 0, /* tp_repr */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
508 0, /* tp_as_number */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
509 0, /* tp_as_sequence */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
510 0, /* tp_as_mapping */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
511 0, /* tp_hash */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
512 0, /* tp_call */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
513 0, /* tp_str */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
514 0, /* tp_getattro */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
515 0, /* tp_setattro */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
516 0, /* tp_as_buffer */
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37764
diff changeset
517 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
518 0, /* tp_doc */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
519 0, /* tp_traverse */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
520 0, /* tp_clear */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
521 0, /* tp_richcompare */
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
522 offsetof(pysqlite_Statement, in_weakreflist), /* tp_weaklistoffset */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
523 0, /* tp_iter */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
524 0, /* tp_iternext */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
525 0, /* tp_methods */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
526 0, /* tp_members */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
527 0, /* tp_getset */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
528 0, /* tp_base */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
529 0, /* tp_dict */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
530 0, /* tp_descr_get */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
531 0, /* tp_descr_set */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
532 0, /* tp_dictoffset */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
533 (initproc)0, /* tp_init */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
534 0, /* tp_alloc */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
535 0, /* tp_new */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
536 0 /* tp_free */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
537 };
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
538
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
539 extern int pysqlite_statement_setup_types(void)
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
540 {
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
541 pysqlite_StatementType.tp_new = PyType_GenericNew;
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
542 return PyType_Ready(&pysqlite_StatementType);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
543 }