annotate Modules/_sqlite/statement.c @ 58664:993f703a61ba

Merged revisions 77484,77487,77561,77570,77593,77603,77608,77667,77702-77703,77739,77858,77887,77889 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r77484 | skip.montanaro | 2010-01-13 19:12:34 -0600 (Wed, 13 Jan 2010) | 4 lines Update PyEval_EvalFrame to PyEval_EvalFrameEx. This looks to have been done partially before. Also add a comment describing how this might have to work with different versions of the interpreter. ........ r77487 | ezio.melotti | 2010-01-14 05:34:10 -0600 (Thu, 14 Jan 2010) | 1 line Fixed typo ........ r77561 | georg.brandl | 2010-01-17 02:42:30 -0600 (Sun, 17 Jan 2010) | 1 line #7699: improve datetime docs: straightforward linking to strftime/strptime section, mark classmethods as such. ........ r77570 | georg.brandl | 2010-01-17 06:14:42 -0600 (Sun, 17 Jan 2010) | 1 line Add note about usage of STRINGLIB_EMPTY. ........ r77593 | georg.brandl | 2010-01-17 17:33:53 -0600 (Sun, 17 Jan 2010) | 1 line Fix internal reference. ........ r77603 | benjamin.peterson | 2010-01-18 17:07:56 -0600 (Mon, 18 Jan 2010) | 8 lines data descriptors do not override the class dictionary if __get__ is not defined Adjust documentation and add a test to verify this behavior. See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for discussion. ........ r77608 | gregory.p.smith | 2010-01-19 02:19:03 -0600 (Tue, 19 Jan 2010) | 6 lines Do not compile stubs for the sha2 series hashes in the openssl hashlib module when the openssl version is too old to support them. That leads both compiled code bloat and to unittests attempting to test implementations that don't exist for comparison purposes on such platforms. ........ r77667 | mark.dickinson | 2010-01-21 12:32:27 -0600 (Thu, 21 Jan 2010) | 1 line Add two more test_strtod test values. ........ r77702 | georg.brandl | 2010-01-23 02:43:31 -0600 (Sat, 23 Jan 2010) | 1 line #7762: fix refcount annotation of PyUnicode_Tailmatch(). ........ r77703 | georg.brandl | 2010-01-23 02:47:54 -0600 (Sat, 23 Jan 2010) | 1 line #7725: fix referencing issue. ........ r77739 | benjamin.peterson | 2010-01-24 21:52:52 -0600 (Sun, 24 Jan 2010) | 1 line mention from_float() in error message ........ r77858 | georg.brandl | 2010-01-30 11:57:48 -0600 (Sat, 30 Jan 2010) | 1 line #7802: fix invalid example (heh). ........ r77887 | georg.brandl | 2010-01-31 12:51:49 -0600 (Sun, 31 Jan 2010) | 5 lines Fix-up ftplib documentation: move exception descriptions to toplevel, not inside a class remove attribution in "versionadded" spell and grammar check docstring of FTP_TLS ........ r77889 | michael.foord | 2010-01-31 13:59:26 -0600 (Sun, 31 Jan 2010) | 1 line Minor modification to unittest documentation. ........
author Benjamin Peterson <benjamin@python.org>
date Wed, 03 Feb 2010 02:35:45 +0000
parents 87fbbf22adf3
children 3003c1656e2a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1 /* statement.c - the statement type
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2 *
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
3 * Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
4 *
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
5 * This file is part of pysqlite.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
6 *
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
7 * This software is provided 'as-is', without any express or implied
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
8 * warranty. In no event will the authors be held liable for any damages
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
9 * arising from the use of this software.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
10 *
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
11 * Permission is granted to anyone to use this software for any purpose,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
12 * including commercial applications, and to alter it and redistribute it
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
13 * freely, subject to the following restrictions:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
14 *
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
15 * 1. The origin of this software must not be misrepresented; you must not
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
16 * claim that you wrote the original software. If you use this software
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
17 * in a product, an acknowledgment in the product documentation would be
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
18 * appreciated but is not required.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
19 * 2. Altered source versions must be plainly marked as such, and must not be
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
20 * misrepresented as being the original software.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
21 * 3. This notice may not be removed or altered from any source distribution.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
22 */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
23
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
24 #include "statement.h"
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
25 #include "cursor.h"
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
26 #include "connection.h"
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
27 #include "microprotocols.h"
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
28 #include "prepare_protocol.h"
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
29 #include "sqlitecompat.h"
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
30
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
31 /* prototypes */
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
32 static int pysqlite_check_remaining_sql(const char* tail);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
33
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
34 typedef enum {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
35 LINECOMMENT_1,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
36 IN_LINECOMMENT,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
37 COMMENTSTART_1,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
38 IN_COMMENT,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
39 COMMENTEND_1,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
40 NORMAL
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
41 } parse_remaining_sql_state;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
42
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
43 typedef enum {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
44 TYPE_LONG,
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
45 TYPE_FLOAT,
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
46 TYPE_UNICODE,
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
47 TYPE_BUFFER,
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
48 TYPE_UNKNOWN
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
49 } parameter_type;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
50
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
51 int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* connection, PyObject* sql)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
52 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
53 const char* tail;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
54 int rc;
41669
d12811decf94 Use AsCharBuffer to get C strings out of Python strings.
Guido van Rossum <guido@python.org>
parents: 40643
diff changeset
55 const char* sql_cstr;
d12811decf94 Use AsCharBuffer to get C strings out of Python strings.
Guido van Rossum <guido@python.org>
parents: 40643
diff changeset
56 Py_ssize_t sql_cstr_len;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
57
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
58 self->st = NULL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
59 self->in_use = 0;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
60
48660
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 47301
diff changeset
61 sql_cstr = _PyUnicode_AsStringAndSize(sql, &sql_cstr_len);
42970
cb5ae020a060 "Fix" a few places that were using PyObject_AsCharBuffer() to convert a string
Guido van Rossum <guido@python.org>
parents: 42525
diff changeset
62 if (sql_cstr == NULL) {
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
63 rc = PYSQLITE_SQL_WRONG_TYPE;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
64 return rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
65 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
66
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
67 self->in_weakreflist = NULL;
41669
d12811decf94 Use AsCharBuffer to get C strings out of Python strings.
Guido van Rossum <guido@python.org>
parents: 40643
diff changeset
68 Py_INCREF(sql);
d12811decf94 Use AsCharBuffer to get C strings out of Python strings.
Guido van Rossum <guido@python.org>
parents: 40643
diff changeset
69 self->sql = sql;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
70
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
71 Py_BEGIN_ALLOW_THREADS
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
72 rc = sqlite3_prepare(connection->db,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
73 sql_cstr,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
74 -1,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
75 &self->st,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
76 &tail);
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
77 Py_END_ALLOW_THREADS
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
78
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
79 self->db = connection->db;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
80
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
81 if (rc == SQLITE_OK && pysqlite_check_remaining_sql(tail)) {
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
82 (void)sqlite3_finalize(self->st);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
83 self->st = NULL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
84 rc = PYSQLITE_TOO_MUCH_SQL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
85 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
86
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
87 return rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
88 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
89
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
90 int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter, int allow_8bit_chars)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
91 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
92 int rc = SQLITE_OK;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
93 PY_LONG_LONG longlongval;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
94 const char* buffer;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
95 char* string;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
96 Py_ssize_t buflen;
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
97 parameter_type paramtype;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
98
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
99 if (parameter == Py_None) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
100 rc = sqlite3_bind_null(self->st, pos);
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
101 goto final;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
102 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
103
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
104 if (PyLong_CheckExact(parameter)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
105 paramtype = TYPE_LONG;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
106 } else if (PyFloat_CheckExact(parameter)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
107 paramtype = TYPE_FLOAT;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
108 } else if (PyUnicode_CheckExact(parameter)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
109 paramtype = TYPE_UNICODE;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
110 } else if (PyLong_Check(parameter)) {
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
111 paramtype = TYPE_LONG;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
112 } else if (PyFloat_Check(parameter)) {
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
113 paramtype = TYPE_FLOAT;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
114 } else if (PyUnicode_Check(parameter)) {
49264
54613ba1dcad Issue #3659: Values of string subclasses were not handled correctly when used
Gerhard Häring <gh@ghaering.de>
parents: 49178
diff changeset
115 paramtype = TYPE_UNICODE;
43487
8c10aac37037 Breaking ground for PEP 3137 implementation:
Guido van Rossum <guido@python.org>
parents: 42984
diff changeset
116 } else if (PyObject_CheckBuffer(parameter)) {
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
117 paramtype = TYPE_BUFFER;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
118 } else {
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
119 paramtype = TYPE_UNKNOWN;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
120 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
121
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
122 switch (paramtype) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
123 case TYPE_LONG:
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
124 /* in the overflow error case, longval/longlongval is -1, and an exception is set */
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
125 longlongval = PyLong_AsLongLong(parameter);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
126 rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longlongval);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
127 break;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
128 case TYPE_FLOAT:
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
129 rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter));
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
130 break;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
131 case TYPE_UNICODE:
48660
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 47301
diff changeset
132 string = _PyUnicode_AsString(parameter);
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
133 rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
134 break;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
135 case TYPE_BUFFER:
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
136 if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
137 rc = sqlite3_bind_blob(self->st, pos, buffer, buflen, SQLITE_TRANSIENT);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
138 } else {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
139 PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
140 rc = -1;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
141 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
142 break;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
143 case TYPE_UNKNOWN:
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
144 rc = -1;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
145 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
146
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
147 final:
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
148 return rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
149 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
150
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
151 /* returns 0 if the object is one of Python's internal ones that don't need to be adapted */
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
152 static int _need_adapt(PyObject* obj)
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
153 {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
154 if (pysqlite_BaseTypeAdapted) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
155 return 1;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
156 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
157
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
158 if (PyLong_CheckExact(obj) || PyFloat_CheckExact(obj)
47300
96b34263e448 Renamed PyBytes to PyByteArray
Christian Heimes <christian@cheimes.de>
parents: 46664
diff changeset
159 || PyUnicode_CheckExact(obj) || PyByteArray_CheckExact(obj)) {
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
160 return 0;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
161 } else {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
162 return 1;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
163 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
164 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
165
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
166 void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* parameters, int allow_8bit_chars)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
167 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
168 PyObject* current_param;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
169 PyObject* adapted;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
170 const char* binding_name;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
171 int i;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
172 int rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
173 int num_params_needed;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
174 int num_params;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
175
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
176 Py_BEGIN_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
177 num_params_needed = sqlite3_bind_parameter_count(self->st);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
178 Py_END_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
179
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
180 if (PyTuple_CheckExact(parameters) || PyList_CheckExact(parameters) || (!PyDict_Check(parameters) && PySequence_Check(parameters))) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
181 /* parameters passed as sequence */
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
182 if (PyTuple_CheckExact(parameters)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
183 num_params = PyTuple_GET_SIZE(parameters);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
184 } else if (PyList_CheckExact(parameters)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
185 num_params = PyList_GET_SIZE(parameters);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
186 } else {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
187 num_params = PySequence_Size(parameters);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
188 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
189 if (num_params != num_params_needed) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
190 PyErr_Format(pysqlite_ProgrammingError, "Incorrect number of bindings supplied. The current statement uses %d, and there are %d supplied.",
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
191 num_params_needed, num_params);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
192 return;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
193 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
194 for (i = 0; i < num_params; i++) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
195 if (PyTuple_CheckExact(parameters)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
196 current_param = PyTuple_GET_ITEM(parameters, i);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
197 Py_XINCREF(current_param);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
198 } else if (PyList_CheckExact(parameters)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
199 current_param = PyList_GET_ITEM(parameters, i);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
200 Py_XINCREF(current_param);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
201 } else {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
202 current_param = PySequence_GetItem(parameters, i);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
203 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
204 if (!current_param) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
205 return;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
206 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
207
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
208 if (!_need_adapt(current_param)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
209 adapted = current_param;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
210 } else {
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
211 adapted = pysqlite_microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL);
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
212 if (adapted) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
213 Py_DECREF(current_param);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
214 } else {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
215 PyErr_Clear();
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
216 adapted = current_param;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
217 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
218 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
219
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
220 rc = pysqlite_statement_bind_parameter(self, i + 1, adapted, allow_8bit_chars);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
221 Py_DECREF(adapted);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
222
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
223 if (rc != SQLITE_OK) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
224 if (!PyErr_Occurred()) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
225 PyErr_Format(pysqlite_InterfaceError, "Error binding parameter %d - probably unsupported type.", i);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
226 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
227 return;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
228 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
229 }
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
230 } else if (PyDict_Check(parameters)) {
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
231 /* parameters passed as dictionary */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
232 for (i = 1; i <= num_params_needed; i++) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
233 Py_BEGIN_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
234 binding_name = sqlite3_bind_parameter_name(self->st, i);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
235 Py_END_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
236 if (!binding_name) {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
237 PyErr_Format(pysqlite_ProgrammingError, "Binding %d has no name, but you supplied a dictionary (which has only names).", i);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
238 return;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
239 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
240
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
241 binding_name++; /* skip first char (the colon) */
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
242 if (PyDict_CheckExact(parameters)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
243 current_param = PyDict_GetItemString(parameters, binding_name);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
244 Py_XINCREF(current_param);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
245 } else {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
246 current_param = PyMapping_GetItemString(parameters, (char*)binding_name);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
247 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
248 if (!current_param) {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
249 PyErr_Format(pysqlite_ProgrammingError, "You did not supply a value for binding %d.", i);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
250 return;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
251 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
252
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
253 if (!_need_adapt(current_param)) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
254 adapted = current_param;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
255 } else {
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
256 adapted = pysqlite_microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL);
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
257 if (adapted) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
258 Py_DECREF(current_param);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
259 } else {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
260 PyErr_Clear();
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
261 adapted = current_param;
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
262 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
263 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
264
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
265 rc = pysqlite_statement_bind_parameter(self, i, adapted, allow_8bit_chars);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
266 Py_DECREF(adapted);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
267
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
268 if (rc != SQLITE_OK) {
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
269 if (!PyErr_Occurred()) {
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
270 PyErr_Format(pysqlite_InterfaceError, "Error binding parameter :%s - probably unsupported type.", binding_name);
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
271 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
272 return;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
273 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
274 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
275 } else {
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
276 PyErr_SetString(PyExc_ValueError, "parameters are of unsupported type");
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
277 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
278 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
279
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
280 int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
281 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
282 const char* tail;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
283 int rc;
41669
d12811decf94 Use AsCharBuffer to get C strings out of Python strings.
Guido van Rossum <guido@python.org>
parents: 40643
diff changeset
284 const char* sql_cstr;
d12811decf94 Use AsCharBuffer to get C strings out of Python strings.
Guido van Rossum <guido@python.org>
parents: 40643
diff changeset
285 Py_ssize_t sql_len;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
286 sqlite3_stmt* new_st;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
287
48660
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 47301
diff changeset
288 sql_cstr = _PyUnicode_AsStringAndSize(self->sql, &sql_len);
42970
cb5ae020a060 "Fix" a few places that were using PyObject_AsCharBuffer() to convert a string
Guido van Rossum <guido@python.org>
parents: 42525
diff changeset
289 if (sql_cstr == NULL) {
41669
d12811decf94 Use AsCharBuffer to get C strings out of Python strings.
Guido van Rossum <guido@python.org>
parents: 40643
diff changeset
290 rc = PYSQLITE_SQL_WRONG_TYPE;
d12811decf94 Use AsCharBuffer to get C strings out of Python strings.
Guido van Rossum <guido@python.org>
parents: 40643
diff changeset
291 return rc;
d12811decf94 Use AsCharBuffer to get C strings out of Python strings.
Guido van Rossum <guido@python.org>
parents: 40643
diff changeset
292 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
293
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
294 Py_BEGIN_ALLOW_THREADS
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
295 rc = sqlite3_prepare(self->db,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
296 sql_cstr,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
297 -1,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
298 &new_st,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
299 &tail);
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
300 Py_END_ALLOW_THREADS
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
301
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
302 if (rc == SQLITE_OK) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
303 /* The efficient sqlite3_transfer_bindings is only available in SQLite
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
304 * version 3.2.2 or later. For older SQLite releases, that might not
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
305 * even define SQLITE_VERSION_NUMBER, we do it the manual way.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
306 */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
307 #ifdef SQLITE_VERSION_NUMBER
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
308 #if SQLITE_VERSION_NUMBER >= 3002002
44291
71623878057b Merged revisions 59465-59487 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43778
diff changeset
309 /* The check for the number of parameters is necessary to not trigger a
71623878057b Merged revisions 59465-59487 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43778
diff changeset
310 * bug in certain SQLite versions (experienced in 3.2.8 and 3.3.4). */
71623878057b Merged revisions 59465-59487 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43778
diff changeset
311 if (sqlite3_bind_parameter_count(self->st) > 0) {
71623878057b Merged revisions 59465-59487 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43778
diff changeset
312 (void)sqlite3_transfer_bindings(self->st, new_st);
71623878057b Merged revisions 59465-59487 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43778
diff changeset
313 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
314 #endif
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
315 #else
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
316 statement_bind_parameters(self, params);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
317 #endif
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
318
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
319 (void)sqlite3_finalize(self->st);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
320 self->st = new_st;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
321 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
322
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
323 return rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
324 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
325
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
326 int pysqlite_statement_finalize(pysqlite_Statement* self)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
327 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
328 int rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
329
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
330 rc = SQLITE_OK;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
331 if (self->st) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
332 Py_BEGIN_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
333 rc = sqlite3_finalize(self->st);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
334 Py_END_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
335 self->st = NULL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
336 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
337
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
338 self->in_use = 0;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
339
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
340 return rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
341 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
342
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
343 int pysqlite_statement_reset(pysqlite_Statement* self)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
344 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
345 int rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
346
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
347 rc = SQLITE_OK;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
348
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
349 if (self->in_use && self->st) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
350 Py_BEGIN_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
351 rc = sqlite3_reset(self->st);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
352 Py_END_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
353
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
354 if (rc == SQLITE_OK) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
355 self->in_use = 0;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
356 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
357 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
358
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
359 return rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
360 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
361
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
362 void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
363 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
364 self->in_use = 1;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
365 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
366
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
367 void pysqlite_statement_dealloc(pysqlite_Statement* self)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
368 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
369 int rc;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
370
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
371 if (self->st) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
372 Py_BEGIN_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
373 rc = sqlite3_finalize(self->st);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
374 Py_END_ALLOW_THREADS
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
375 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
376
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
377 self->st = NULL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
378
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
379 Py_XDECREF(self->sql);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
380
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
381 if (self->in_weakreflist != NULL) {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
382 PyObject_ClearWeakRefs((PyObject*)self);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
383 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
384
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 44291
diff changeset
385 Py_TYPE(self)->tp_free((PyObject*)self);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
386 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
387
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
388 /*
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
389 * Checks if there is anything left in an SQL string after SQLite compiled it.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
390 * This is used to check if somebody tried to execute more than one SQL command
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
391 * with one execute()/executemany() command, which the DB-API and we don't
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
392 * allow.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
393 *
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
394 * Returns 1 if there is more left than should be. 0 if ok.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
395 */
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
396 static int pysqlite_check_remaining_sql(const char* tail)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
397 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
398 const char* pos = tail;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
399
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
400 parse_remaining_sql_state state = NORMAL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
401
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
402 for (;;) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
403 switch (*pos) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
404 case 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
405 return 0;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
406 case '-':
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
407 if (state == NORMAL) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
408 state = LINECOMMENT_1;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
409 } else if (state == LINECOMMENT_1) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
410 state = IN_LINECOMMENT;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
411 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
412 break;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
413 case ' ':
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
414 case '\t':
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
415 break;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
416 case '\n':
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
417 case 13:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
418 if (state == IN_LINECOMMENT) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
419 state = NORMAL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
420 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
421 break;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
422 case '/':
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
423 if (state == NORMAL) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
424 state = COMMENTSTART_1;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
425 } else if (state == COMMENTEND_1) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
426 state = NORMAL;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
427 } else if (state == COMMENTSTART_1) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
428 return 1;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
429 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
430 break;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
431 case '*':
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
432 if (state == NORMAL) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
433 return 1;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
434 } else if (state == LINECOMMENT_1) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
435 return 1;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
436 } else if (state == COMMENTSTART_1) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
437 state = IN_COMMENT;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
438 } else if (state == IN_COMMENT) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
439 state = COMMENTEND_1;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
440 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
441 break;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
442 default:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
443 if (state == COMMENTEND_1) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
444 state = IN_COMMENT;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
445 } else if (state == IN_LINECOMMENT) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
446 } else if (state == IN_COMMENT) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
447 } else {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
448 return 1;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
449 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
450 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
451
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
452 pos++;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
453 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
454
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
455 return 0;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
456 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
457
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
458 PyTypeObject pysqlite_StatementType = {
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 41669
diff changeset
459 PyVarObject_HEAD_INIT(NULL, 0)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
460 MODULE_NAME ".Statement", /* tp_name */
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
461 sizeof(pysqlite_Statement), /* tp_basicsize */
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
462 0, /* tp_itemsize */
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
463 (destructor)pysqlite_statement_dealloc, /* tp_dealloc */
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
464 0, /* tp_print */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
465 0, /* tp_getattr */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
466 0, /* tp_setattr */
51271
87fbbf22adf3 Merged revisions 69214 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 49264
diff changeset
467 0, /* tp_reserved */
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
468 0, /* tp_repr */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
469 0, /* tp_as_number */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
470 0, /* tp_as_sequence */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
471 0, /* tp_as_mapping */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
472 0, /* tp_hash */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
473 0, /* tp_call */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
474 0, /* tp_str */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
475 0, /* tp_getattro */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
476 0, /* tp_setattro */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
477 0, /* tp_as_buffer */
46178
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 44351
diff changeset
478 Py_TPFLAGS_DEFAULT, /* tp_flags */
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
479 0, /* tp_doc */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
480 0, /* tp_traverse */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
481 0, /* tp_clear */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
482 0, /* tp_richcompare */
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
483 offsetof(pysqlite_Statement, in_weakreflist), /* tp_weaklistoffset */
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
484 0, /* tp_iter */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
485 0, /* tp_iternext */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
486 0, /* tp_methods */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
487 0, /* tp_members */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
488 0, /* tp_getset */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
489 0, /* tp_base */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
490 0, /* tp_dict */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
491 0, /* tp_descr_get */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
492 0, /* tp_descr_set */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
493 0, /* tp_dictoffset */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
494 (initproc)0, /* tp_init */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
495 0, /* tp_alloc */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
496 0, /* tp_new */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
497 0 /* tp_free */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
498 };
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
499
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
500 extern int pysqlite_statement_setup_types(void)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
501 {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
502 pysqlite_StatementType.tp_new = PyType_GenericNew;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40641
diff changeset
503 return PyType_Ready(&pysqlite_StatementType);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
504 }