Mercurial > cpython-lru_cache-weakref
annotate Modules/_sqlite/connection.c @ 87690:66c1c9f32567 default tip
Add use_weakref option to functools.lru_cache
The use_weakref option makes lru_cache create weak references to the function
arguments when creating the cache key, which prevents them from staying in the
memory forever even after all other references to them are gone.
This is a proof of concept for http://bugs.python.org/issue19859
| author | Radomir Dopieralski <devel@sheep.art.pl> |
|---|---|
| date | Tue, 03 Dec 2013 16:02:48 +0100 |
| parents | 0f7f1f2121a1 |
| children |
| 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 /* connection.c - the connection 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 * |
|
64423
e9cd15d539e1
Welcome to the UTF-8 world.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
62009
diff
changeset
|
3 * Copyright (C) 2004-2010 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. |
|
61720
7ba851d1b46e
Issue #6697: Check that _PyUnicode_AsString() result is not NULL in _sqlite
Victor Stinner <victor.stinner@haypocalc.com>
parents:
60845
diff
changeset
|
6 * |
|
37879
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 "cache.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 "module.h" |
|
62009
62ca540d8b6e
#8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents:
61720
diff
changeset
|
26 #include "structmember.h" |
|
37879
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 "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
|
28 #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
|
29 #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
|
30 #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
|
31 #include "util.h" |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
32 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
33 #include "pythread.h" |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
34 |
|
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:
46161
diff
changeset
|
35 #define ACTION_FINALIZE 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:
46161
diff
changeset
|
36 #define ACTION_RESET 2 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
37 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
38 #if SQLITE_VERSION_NUMBER >= 3003008 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
39 #ifndef SQLITE_OMIT_LOAD_EXTENSION |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
40 #define HAVE_LOAD_EXTENSION |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
41 #endif |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
42 #endif |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
43 |
|
86994
4a09cc62419b
Issue #19514: Deduplicate some _Py_IDENTIFIER declarations.
Martin v. Löwis <martin@v.loewis.de>
parents:
86945
diff
changeset
|
44 _Py_IDENTIFIER(cursor); |
|
4a09cc62419b
Issue #19514: Deduplicate some _Py_IDENTIFIER declarations.
Martin v. Löwis <martin@v.loewis.de>
parents:
86945
diff
changeset
|
45 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
46 static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* isolation_level); |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
47 static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* 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
|
48 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
49 |
|
49178
8f886acaa142
Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
48660
diff
changeset
|
50 static void _sqlite3_result_error(sqlite3_context* ctx, const char* errmsg, int len) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
51 { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
52 /* in older SQLite versions, calling sqlite3_result_error in callbacks |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
53 * triggers a bug in SQLite that leads either to irritating results or |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
54 * segfaults, depending on the SQLite version */ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
55 #if SQLITE_VERSION_NUMBER >= 3003003 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
56 sqlite3_result_error(ctx, errmsg, len); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
57 #else |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
58 PyErr_SetString(pysqlite_OperationalError, errmsg); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
59 #endif |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
60 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
61 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
62 int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
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 { |
|
82113
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
64 static char *kwlist[] = { |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
65 "database", "timeout", "detect_types", "isolation_level", |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
66 "check_same_thread", "factory", "cached_statements", "uri", |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
67 NULL |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
68 }; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
69 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
70 char* database; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
71 int detect_types = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
72 PyObject* isolation_level = NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
73 PyObject* factory = NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
74 int check_same_thread = 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 int cached_statements = 100; |
|
82113
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
76 int uri = 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
|
77 double timeout = 5.0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
78 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
|
79 |
|
82113
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
80 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOip", kwlist, |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
81 &database, &timeout, &detect_types, |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
82 &isolation_level, &check_same_thread, |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
83 &factory, &cached_statements, &uri)) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
84 { |
|
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:
46161
diff
changeset
|
85 return -1; |
|
37879
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 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
88 self->initialized = 1; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
89 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
90 self->begin_statement = NULL; |
|
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 self->statement_cache = NULL; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
93 self->statements = NULL; |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
94 self->cursors = 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
|
95 |
|
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_INCREF(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
|
97 self->row_factory = 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
|
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 Py_INCREF(&PyUnicode_Type); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
100 self->text_factory = (PyObject*)&PyUnicode_Type; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
101 |
|
82113
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
102 #ifdef SQLITE_OPEN_URI |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
103 Py_BEGIN_ALLOW_THREADS |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
104 rc = sqlite3_open_v2(database, &self->db, |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
105 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
106 (uri ? SQLITE_OPEN_URI : 0), NULL); |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
107 #else |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
108 if (uri) { |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
109 PyErr_SetString(pysqlite_NotSupportedError, "URIs not supported"); |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
110 return -1; |
|
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
111 } |
|
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 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
|
113 rc = sqlite3_open(database, &self->db); |
|
82113
f13bb1e40fbc
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82056
diff
changeset
|
114 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
115 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
|
116 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
117 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:
46161
diff
changeset
|
118 _pysqlite_seterror(self->db, 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
|
119 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
|
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 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
122 if (!isolation_level) { |
|
43694
b102b8361d5e
Use unicode in more places. Fixes a problem with str8 + str in test.
Neal Norwitz <nnorwitz@gmail.com>
parents:
43490
diff
changeset
|
123 isolation_level = PyUnicode_FromString(""); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
124 if (!isolation_level) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
125 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
126 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
127 } else { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
128 Py_INCREF(isolation_level); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
129 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
130 self->isolation_level = NULL; |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
131 pysqlite_connection_set_isolation_level(self, isolation_level); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
132 Py_DECREF(isolation_level); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
133 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
134 self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "Oi", self, cached_statements); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
135 if (PyErr_Occurred()) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
136 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
|
137 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
138 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
139 self->created_statements = 0; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
140 self->created_cursors = 0; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
141 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
142 /* Create lists of weak references to statements/cursors */ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
143 self->statements = PyList_New(0); |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
144 self->cursors = PyList_New(0); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
145 if (!self->statements || !self->cursors) { |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
146 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
147 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
148 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
149 /* By default, the Cache class INCREFs the factory in its initializer, and |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
150 * decrefs it in its deallocator method. Since this would create a circular |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
151 * reference here, we're breaking it by decrementing self, and telling the |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
152 * cache class to not decref the factory (self) in its deallocator. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
153 */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
154 self->statement_cache->decref_factory = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
155 Py_DECREF(self); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
156 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
157 self->inTransaction = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
158 self->detect_types = detect_types; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
159 self->timeout = timeout; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
160 (void)sqlite3_busy_timeout(self->db, (int)(timeout*1000)); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
161 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
162 self->thread_ident = PyThread_get_thread_ident(); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
163 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
164 self->check_same_thread = check_same_thread; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
165 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
166 self->function_pinboard = PyDict_New(); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
167 if (!self->function_pinboard) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
168 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
|
169 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
170 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
171 self->collations = PyDict_New(); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
172 if (!self->collations) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
173 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
|
174 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
175 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
176 self->Warning = pysqlite_Warning; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
177 self->Error = pysqlite_Error; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
178 self->InterfaceError = pysqlite_InterfaceError; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
179 self->DatabaseError = pysqlite_DatabaseError; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
180 self->DataError = pysqlite_DataError; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
181 self->OperationalError = pysqlite_OperationalError; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
182 self->IntegrityError = pysqlite_IntegrityError; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
183 self->InternalError = pysqlite_InternalError; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
184 self->ProgrammingError = pysqlite_ProgrammingError; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
185 self->NotSupportedError = pysqlite_NotSupportedError; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
186 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
187 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
|
188 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
189 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
190 /* Empty the entire statement cache of this connection */ |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
191 void pysqlite_flush_statement_cache(pysqlite_Connection* 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
|
192 { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
193 pysqlite_Node* node; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
194 pysqlite_Statement* statement; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
195 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
196 node = self->statement_cache->first; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
197 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
198 while (node) { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
199 statement = (pysqlite_Statement*)(node->data); |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
200 (void)pysqlite_statement_finalize(statement); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
201 node = node->next; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
202 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
203 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
204 Py_DECREF(self->statement_cache); |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
205 self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "O", 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
|
206 Py_DECREF(self); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
207 self->statement_cache->decref_factory = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
208 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
209 |
|
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:
46161
diff
changeset
|
210 /* action in (ACTION_RESET, ACTION_FINALIZE) */ |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
211 void pysqlite_do_all_statements(pysqlite_Connection* self, int action, int reset_cursors) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
212 { |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
213 int i; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
214 PyObject* weakref; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
215 PyObject* statement; |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
216 pysqlite_Cursor* cursor; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
217 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
218 for (i = 0; i < PyList_Size(self->statements); i++) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
219 weakref = PyList_GetItem(self->statements, i); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
220 statement = PyWeakref_GetObject(weakref); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
221 if (statement != Py_None) { |
|
70569
a856be6688a6
be extra careful with a borrowed reference when the GIL could be released (closes #8578)
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
222 Py_INCREF(statement); |
|
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:
46161
diff
changeset
|
223 if (action == ACTION_RESET) { |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
224 (void)pysqlite_statement_reset((pysqlite_Statement*)statement); |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
225 } 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:
46161
diff
changeset
|
226 (void)pysqlite_statement_finalize((pysqlite_Statement*)statement); |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
227 } |
|
70569
a856be6688a6
be extra careful with a borrowed reference when the GIL could be released (closes #8578)
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
228 Py_DECREF(statement); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
229 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
230 } |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
231 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
232 if (reset_cursors) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
233 for (i = 0; i < PyList_Size(self->cursors); i++) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
234 weakref = PyList_GetItem(self->cursors, i); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
235 cursor = (pysqlite_Cursor*)PyWeakref_GetObject(weakref); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
236 if ((PyObject*)cursor != Py_None) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
237 cursor->reset = 1; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
238 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
239 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
240 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
241 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
242 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
243 void pysqlite_connection_dealloc(pysqlite_Connection* 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
|
244 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
245 Py_XDECREF(self->statement_cache); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
246 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
247 /* Clean up if user has not called .close() explicitly. */ |
|
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 (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
|
249 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
|
250 sqlite3_close(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
|
251 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
|
252 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
253 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
254 if (self->begin_statement) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
255 PyMem_Free(self->begin_statement); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
256 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
257 Py_XDECREF(self->isolation_level); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
258 Py_XDECREF(self->function_pinboard); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
259 Py_XDECREF(self->row_factory); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
260 Py_XDECREF(self->text_factory); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
261 Py_XDECREF(self->collations); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
262 Py_XDECREF(self->statements); |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
263 Py_XDECREF(self->cursors); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
264 |
|
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:
44099
diff
changeset
|
265 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
|
266 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
267 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
268 /* |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
269 * Registers a cursor with the connection. |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
270 * |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
271 * 0 => error; 1 => ok |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
272 */ |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
273 int pysqlite_connection_register_cursor(pysqlite_Connection* connection, PyObject* cursor) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
274 { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
275 PyObject* weakref; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
276 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
277 weakref = PyWeakref_NewRef((PyObject*)cursor, NULL); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
278 if (!weakref) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
279 goto error; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
280 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
281 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
282 if (PyList_Append(connection->cursors, weakref) != 0) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
283 Py_CLEAR(weakref); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
284 goto error; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
285 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
286 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
287 Py_DECREF(weakref); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
288 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
289 return 1; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
290 error: |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
291 return 0; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
292 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
293 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
294 PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
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 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
296 static char *kwlist[] = {"factory", NULL, NULL}; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
297 PyObject* factory = NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
298 PyObject* cursor; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
299 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
300 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist, |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
301 &factory)) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
302 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
303 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
304 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
305 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(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
|
306 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
307 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
308 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
309 if (factory == NULL) { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
310 factory = (PyObject*)&pysqlite_CursorType; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
311 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
312 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
313 cursor = PyObject_CallFunction(factory, "O", self); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
314 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
315 _pysqlite_drop_unused_cursor_references(self); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
316 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
317 if (cursor && self->row_factory != Py_None) { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
318 Py_XDECREF(((pysqlite_Cursor*)cursor)->row_factory); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
319 Py_INCREF(self->row_factory); |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
320 ((pysqlite_Cursor*)cursor)->row_factory = self->row_factory; |
|
37879
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 cursor; |
|
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:
39442
diff
changeset
|
326 PyObject* pysqlite_connection_close(pysqlite_Connection* self, PyObject* args) |
|
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 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
330 if (!pysqlite_check_thread(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
|
331 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
332 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
333 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
334 pysqlite_do_all_statements(self, ACTION_FINALIZE, 1); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
335 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
336 if (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
|
337 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
|
338 rc = sqlite3_close(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
|
339 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
|
340 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
341 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:
46161
diff
changeset
|
342 _pysqlite_seterror(self->db, 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
|
343 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
344 } else { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
345 self->db = NULL; |
|
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 } |
|
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 Py_INCREF(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
|
350 return 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
|
351 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
352 |
|
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 * Checks if a connection object is usable (i. e. not closed). |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
355 * |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
356 * 0 => error; 1 => ok |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
357 */ |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
358 int pysqlite_check_connection(pysqlite_Connection* con) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
359 { |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
360 if (!con->initialized) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
361 PyErr_SetString(pysqlite_ProgrammingError, "Base Connection.__init__ not called."); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
362 return 0; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
363 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
364 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
365 if (!con->db) { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
366 PyErr_SetString(pysqlite_ProgrammingError, "Cannot operate on a closed database."); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
367 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
|
368 } else { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
369 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
|
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 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
372 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
373 PyObject* _pysqlite_connection_begin(pysqlite_Connection* 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
|
374 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
375 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
|
376 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
|
377 sqlite3_stmt* statement; |
|
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_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
|
380 rc = sqlite3_prepare(self->db, self->begin_statement, -1, &statement, &tail); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
381 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
|
382 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
383 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:
46161
diff
changeset
|
384 _pysqlite_seterror(self->db, statement); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
385 goto error; |
|
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 |
|
49178
8f886acaa142
Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
48660
diff
changeset
|
388 rc = pysqlite_step(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
|
389 if (rc == SQLITE_DONE) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
390 self->inTransaction = 1; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
391 } 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:
46161
diff
changeset
|
392 _pysqlite_seterror(self->db, statement); |
|
37879
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 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
395 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
|
396 rc = sqlite3_finalize(statement); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
397 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
|
398 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
399 if (rc != SQLITE_OK && !PyErr_Occurred()) { |
|
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:
46161
diff
changeset
|
400 _pysqlite_seterror(self->db, 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
|
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 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
403 error: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
404 if (PyErr_Occurred()) { |
|
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 NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
406 } else { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
407 Py_INCREF(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
|
408 return 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
|
409 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
410 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
411 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
412 PyObject* pysqlite_connection_commit(pysqlite_Connection* self, PyObject* args) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
413 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
414 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
|
415 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
|
416 sqlite3_stmt* statement; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
417 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
418 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(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
|
419 return NULL; |
|
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 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
422 if (self->inTransaction) { |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
423 pysqlite_do_all_statements(self, ACTION_RESET, 0); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
424 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
425 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
|
426 rc = sqlite3_prepare(self->db, "COMMIT", -1, &statement, &tail); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
427 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
|
428 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:
46161
diff
changeset
|
429 _pysqlite_seterror(self->db, 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
|
430 goto error; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
431 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
432 |
|
49178
8f886acaa142
Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
48660
diff
changeset
|
433 rc = pysqlite_step(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
|
434 if (rc == SQLITE_DONE) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
435 self->inTransaction = 0; |
|
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 { |
|
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:
46161
diff
changeset
|
437 _pysqlite_seterror(self->db, statement); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
438 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
439 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
440 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
|
441 rc = sqlite3_finalize(statement); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
442 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
|
443 if (rc != SQLITE_OK && !PyErr_Occurred()) { |
|
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:
46161
diff
changeset
|
444 _pysqlite_seterror(self->db, 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
|
445 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
446 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
447 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
448 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
449 error: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
450 if (PyErr_Occurred()) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
451 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
452 } else { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
453 Py_INCREF(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
|
454 return 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
|
455 } |
|
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:
39442
diff
changeset
|
458 PyObject* pysqlite_connection_rollback(pysqlite_Connection* self, PyObject* args) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
459 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
460 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
|
461 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
|
462 sqlite3_stmt* statement; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
463 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
464 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(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
|
465 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
466 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
467 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
468 if (self->inTransaction) { |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
469 pysqlite_do_all_statements(self, ACTION_RESET, 1); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
470 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
471 Py_BEGIN_ALLOW_THREADS |
|
42543
a44c564026b8
Fix automatic replacing mistake.
Georg Brandl <georg@python.org>
parents:
42541
diff
changeset
|
472 rc = sqlite3_prepare(self->db, "ROLLBACK", -1, &statement, &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
|
473 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
|
474 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:
46161
diff
changeset
|
475 _pysqlite_seterror(self->db, 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
|
476 goto error; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
477 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
478 |
|
49178
8f886acaa142
Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
48660
diff
changeset
|
479 rc = pysqlite_step(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
|
480 if (rc == SQLITE_DONE) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
481 self->inTransaction = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
482 } 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:
46161
diff
changeset
|
483 _pysqlite_seterror(self->db, statement); |
|
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 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
485 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
486 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
|
487 rc = sqlite3_finalize(statement); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
488 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
|
489 if (rc != SQLITE_OK && !PyErr_Occurred()) { |
|
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:
46161
diff
changeset
|
490 _pysqlite_seterror(self->db, 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
|
491 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
492 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
493 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
494 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
495 error: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
496 if (PyErr_Occurred()) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
497 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
498 } else { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
499 Py_INCREF(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
|
500 return 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
|
501 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
502 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
503 |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
504 static int |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
505 _pysqlite_set_result(sqlite3_context* context, PyObject* py_val) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
506 { |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
507 if (py_val == Py_None) { |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
508 sqlite3_result_null(context); |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
44018
diff
changeset
|
509 } else if (PyLong_Check(py_val)) { |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
510 sqlite_int64 value = _pysqlite_long_as_int64(py_val); |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
511 if (value == -1 && PyErr_Occurred()) |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
512 return -1; |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
513 sqlite3_result_int64(context, value); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
514 } else if (PyFloat_Check(py_val)) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
515 sqlite3_result_double(context, PyFloat_AsDouble(py_val)); |
|
43487
8c10aac37037
Breaking ground for PEP 3137 implementation:
Guido van Rossum <guido@python.org>
parents:
42543
diff
changeset
|
516 } else if (PyUnicode_Check(py_val)) { |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
517 const char *str = _PyUnicode_AsString(py_val); |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
518 if (str == NULL) |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
519 return -1; |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
520 sqlite3_result_text(context, str, -1, SQLITE_TRANSIENT); |
|
43487
8c10aac37037
Breaking ground for PEP 3137 implementation:
Guido van Rossum <guido@python.org>
parents:
42543
diff
changeset
|
521 } else if (PyObject_CheckBuffer(py_val)) { |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
522 const char* buffer; |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
523 Py_ssize_t buflen; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
524 if (PyObject_AsCharBuffer(py_val, &buffer, &buflen) != 0) { |
|
87232
0f7f1f2121a1
sqlite: raise an OverflowError if the result is longer than INT_MAX bytes
Victor Stinner <victor.stinner@gmail.com>
parents:
86994
diff
changeset
|
525 PyErr_SetString(PyExc_ValueError, |
|
0f7f1f2121a1
sqlite: raise an OverflowError if the result is longer than INT_MAX bytes
Victor Stinner <victor.stinner@gmail.com>
parents:
86994
diff
changeset
|
526 "could not convert BLOB to buffer"); |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
527 return -1; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
528 } |
|
87232
0f7f1f2121a1
sqlite: raise an OverflowError if the result is longer than INT_MAX bytes
Victor Stinner <victor.stinner@gmail.com>
parents:
86994
diff
changeset
|
529 if (buflen > INT_MAX) { |
|
0f7f1f2121a1
sqlite: raise an OverflowError if the result is longer than INT_MAX bytes
Victor Stinner <victor.stinner@gmail.com>
parents:
86994
diff
changeset
|
530 PyErr_SetString(PyExc_OverflowError, |
|
0f7f1f2121a1
sqlite: raise an OverflowError if the result is longer than INT_MAX bytes
Victor Stinner <victor.stinner@gmail.com>
parents:
86994
diff
changeset
|
531 "BLOB longer than INT_MAX bytes"); |
|
0f7f1f2121a1
sqlite: raise an OverflowError if the result is longer than INT_MAX bytes
Victor Stinner <victor.stinner@gmail.com>
parents:
86994
diff
changeset
|
532 return -1; |
|
0f7f1f2121a1
sqlite: raise an OverflowError if the result is longer than INT_MAX bytes
Victor Stinner <victor.stinner@gmail.com>
parents:
86994
diff
changeset
|
533 } |
|
0f7f1f2121a1
sqlite: raise an OverflowError if the result is longer than INT_MAX bytes
Victor Stinner <victor.stinner@gmail.com>
parents:
86994
diff
changeset
|
534 sqlite3_result_blob(context, buffer, (int)buflen, SQLITE_TRANSIENT); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
535 } else { |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
536 return -1; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
537 } |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
538 return 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
|
539 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
540 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
541 PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_value** argv) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
542 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
543 PyObject* args; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
544 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
|
545 sqlite3_value* cur_value; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
546 PyObject* cur_py_value; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
547 const char* val_str; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
548 Py_ssize_t buflen; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
549 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
550 args = PyTuple_New(argc); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
551 if (!args) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
552 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
553 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
554 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
555 for (i = 0; i < argc; i++) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
556 cur_value = argv[i]; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
557 switch (sqlite3_value_type(argv[i])) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
558 case SQLITE_INTEGER: |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
559 cur_py_value = _pysqlite_long_from_int64(sqlite3_value_int64(cur_value)); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
560 break; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
561 case SQLITE_FLOAT: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
562 cur_py_value = PyFloat_FromDouble(sqlite3_value_double(cur_value)); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
563 break; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
564 case SQLITE_TEXT: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
565 val_str = (const char*)sqlite3_value_text(cur_value); |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43694
diff
changeset
|
566 cur_py_value = PyUnicode_FromString(val_str); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
567 /* TODO: have a way to show errors here */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
568 if (!cur_py_value) { |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
569 PyErr_Clear(); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
570 Py_INCREF(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
|
571 cur_py_value = 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
|
572 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
573 break; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
574 case SQLITE_BLOB: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
575 buflen = sqlite3_value_bytes(cur_value); |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46178
diff
changeset
|
576 cur_py_value = PyBytes_FromStringAndSize( |
|
43487
8c10aac37037
Breaking ground for PEP 3137 implementation:
Guido van Rossum <guido@python.org>
parents:
42543
diff
changeset
|
577 sqlite3_value_blob(cur_value), buflen); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
578 break; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
579 case SQLITE_NULL: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
580 default: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
581 Py_INCREF(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
|
582 cur_py_value = 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
|
583 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
584 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
585 if (!cur_py_value) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
586 Py_DECREF(args); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
587 return NULL; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
588 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
589 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
590 PyTuple_SetItem(args, i, cur_py_value); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
591 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
592 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
593 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
594 return args; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
595 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
596 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
597 void _pysqlite_func_callback(sqlite3_context* context, int argc, sqlite3_value** argv) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
598 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
599 PyObject* args; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
600 PyObject* py_func; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
601 PyObject* py_retval = NULL; |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
602 int ok; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
603 |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
604 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
605 PyGILState_STATE threadstate; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
606 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
607 threadstate = PyGILState_Ensure(); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
608 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
609 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
610 py_func = (PyObject*)sqlite3_user_data(context); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
611 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
612 args = _pysqlite_build_py_params(context, argc, argv); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
613 if (args) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
614 py_retval = PyObject_CallObject(py_func, args); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
615 Py_DECREF(args); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
616 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
617 |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
618 ok = 0; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
619 if (py_retval) { |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
620 ok = _pysqlite_set_result(context, py_retval) == 0; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
621 Py_DECREF(py_retval); |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
622 } |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
623 if (!ok) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
624 if (_enable_callback_tracebacks) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
625 PyErr_Print(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
626 } else { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
627 PyErr_Clear(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
628 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
629 _sqlite3_result_error(context, "user-defined function raised exception", -1); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
630 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
631 |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
632 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
633 PyGILState_Release(threadstate); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
634 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
635 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
636 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
637 static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_value** 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
|
638 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
639 PyObject* args; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
640 PyObject* function_result = 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
|
641 PyObject* aggregate_class; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
642 PyObject** aggregate_instance; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
643 PyObject* stepmethod = 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
|
644 |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
645 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
646 PyGILState_STATE threadstate; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
647 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
648 threadstate = PyGILState_Ensure(); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
649 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
650 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
651 aggregate_class = (PyObject*)sqlite3_user_data(context); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
652 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
653 aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*)); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
654 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
655 if (*aggregate_instance == 0) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
656 *aggregate_instance = PyObject_CallFunction(aggregate_class, ""); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
657 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
658 if (PyErr_Occurred()) { |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
659 *aggregate_instance = 0; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
660 if (_enable_callback_tracebacks) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
661 PyErr_Print(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
662 } else { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
663 PyErr_Clear(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
664 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
665 _sqlite3_result_error(context, "user-defined aggregate's '__init__' method raised error", -1); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
666 goto error; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
667 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
668 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
669 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
670 stepmethod = PyObject_GetAttrString(*aggregate_instance, "step"); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
671 if (!stepmethod) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
672 goto error; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
673 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
674 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
675 args = _pysqlite_build_py_params(context, argc, params); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
676 if (!args) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
677 goto error; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
678 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
679 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
680 function_result = PyObject_CallObject(stepmethod, args); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
681 Py_DECREF(args); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
682 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
683 if (!function_result) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
684 if (_enable_callback_tracebacks) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
685 PyErr_Print(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
686 } else { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
687 PyErr_Clear(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
688 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
689 _sqlite3_result_error(context, "user-defined aggregate's 'step' method raised error", -1); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
690 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
691 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
692 error: |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
693 Py_XDECREF(stepmethod); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
694 Py_XDECREF(function_result); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
695 |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
696 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
697 PyGILState_Release(threadstate); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
698 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
699 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
700 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
701 void _pysqlite_final_callback(sqlite3_context* context) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
702 { |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
703 PyObject* function_result; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
704 PyObject** aggregate_instance; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72835
diff
changeset
|
705 _Py_IDENTIFIER(finalize); |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
706 int ok; |
|
84703
a2214ab0812e
Issue #18488: _pysqlite_final_callback() should not clear the exception set by
Victor Stinner <victor.stinner@gmail.com>
parents:
82113
diff
changeset
|
707 PyObject *exception, *value, *tb; |
|
84965
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
708 int restore; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
709 |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
710 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
711 PyGILState_STATE threadstate; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
712 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
713 threadstate = PyGILState_Ensure(); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
714 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
715 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
716 aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*)); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
717 if (!*aggregate_instance) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
718 /* this branch is executed if there was an exception in the aggregate's |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
719 * __init__ */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
720 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
721 goto error; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
722 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
723 |
|
84703
a2214ab0812e
Issue #18488: _pysqlite_final_callback() should not clear the exception set by
Victor Stinner <victor.stinner@gmail.com>
parents:
82113
diff
changeset
|
724 /* Keep the exception (if any) of the last call to step() */ |
|
a2214ab0812e
Issue #18488: _pysqlite_final_callback() should not clear the exception set by
Victor Stinner <victor.stinner@gmail.com>
parents:
82113
diff
changeset
|
725 PyErr_Fetch(&exception, &value, &tb); |
|
84965
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
726 restore = 1; |
|
84703
a2214ab0812e
Issue #18488: _pysqlite_final_callback() should not clear the exception set by
Victor Stinner <victor.stinner@gmail.com>
parents:
82113
diff
changeset
|
727 |
|
72835
5e33219492bc
Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents:
72475
diff
changeset
|
728 function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, ""); |
|
84703
a2214ab0812e
Issue #18488: _pysqlite_final_callback() should not clear the exception set by
Victor Stinner <victor.stinner@gmail.com>
parents:
82113
diff
changeset
|
729 |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
730 Py_DECREF(*aggregate_instance); |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
731 |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
732 ok = 0; |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
733 if (function_result) { |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
734 ok = _pysqlite_set_result(context, function_result) == 0; |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
735 Py_DECREF(function_result); |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
736 } |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
737 if (!ok) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
738 if (_enable_callback_tracebacks) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
739 PyErr_Print(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
740 } else { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
741 PyErr_Clear(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
742 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
743 _sqlite3_result_error(context, "user-defined aggregate's 'finalize' method raised error", -1); |
|
84965
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
744 #if SQLITE_VERSION_NUMBER < 3003003 |
|
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
745 /* with old SQLite versions, _sqlite3_result_error() sets a new Python |
|
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
746 exception, so don't restore the previous exception */ |
|
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
747 restore = 0; |
|
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
748 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
749 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
750 |
|
84965
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
751 if (restore) { |
|
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
752 /* Restore the exception (if any) of the last call to step(), |
|
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
753 but clear also the current exception if finalize() failed */ |
|
c73f4dced6aa
Issue #18519: Fix test_sqlite on old versions of libsqlite3
Victor Stinner <victor.stinner@gmail.com>
parents:
84843
diff
changeset
|
754 PyErr_Restore(exception, value, tb); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
755 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
756 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
757 error: |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
758 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
759 PyGILState_Release(threadstate); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
760 #endif |
|
85421
65a83a5cf77e
Fix compilation of the _sqlite module if threads are disabled
Victor Stinner <victor.stinner@gmail.com>
parents:
82056
diff
changeset
|
761 /* explicit return to avoid a compilation error if WITH_THREAD |
|
65a83a5cf77e
Fix compilation of the _sqlite module if threads are disabled
Victor Stinner <victor.stinner@gmail.com>
parents:
82056
diff
changeset
|
762 is not defined */ |
|
65a83a5cf77e
Fix compilation of the _sqlite module if threads are disabled
Victor Stinner <victor.stinner@gmail.com>
parents:
82056
diff
changeset
|
763 return; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
764 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
765 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
766 static void _pysqlite_drop_unused_statement_references(pysqlite_Connection* self) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
767 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
768 PyObject* new_list; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
769 PyObject* weakref; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
770 int i; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
771 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
772 /* we only need to do this once in a while */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
773 if (self->created_statements++ < 200) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
774 return; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
775 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
776 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
777 self->created_statements = 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
778 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
779 new_list = PyList_New(0); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
780 if (!new_list) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
781 return; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
782 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
783 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
784 for (i = 0; i < PyList_Size(self->statements); i++) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
785 weakref = PyList_GetItem(self->statements, i); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
786 if (PyWeakref_GetObject(weakref) != Py_None) { |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
787 if (PyList_Append(new_list, weakref) != 0) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
788 Py_DECREF(new_list); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
789 return; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
790 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
791 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
792 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
793 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
794 Py_DECREF(self->statements); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
795 self->statements = new_list; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
796 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
797 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
798 static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
799 { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
800 PyObject* new_list; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
801 PyObject* weakref; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
802 int i; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
803 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
804 /* we only need to do this once in a while */ |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
805 if (self->created_cursors++ < 200) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
806 return; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
807 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
808 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
809 self->created_cursors = 0; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
810 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
811 new_list = PyList_New(0); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
812 if (!new_list) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
813 return; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
814 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
815 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
816 for (i = 0; i < PyList_Size(self->cursors); i++) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
817 weakref = PyList_GetItem(self->cursors, i); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
818 if (PyWeakref_GetObject(weakref) != Py_None) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
819 if (PyList_Append(new_list, weakref) != 0) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
820 Py_DECREF(new_list); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
821 return; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
822 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
823 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
824 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
825 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
826 Py_DECREF(self->cursors); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
827 self->cursors = new_list; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
828 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
829 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
830 PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
831 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
832 static char *kwlist[] = {"name", "narg", "func", NULL, NULL}; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
833 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
834 PyObject* func; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
835 char* name; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
836 int narg; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
837 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
|
838 |
|
59374
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
839 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
840 return NULL; |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
841 } |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
842 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
843 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO", kwlist, |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
844 &name, &narg, &func)) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
845 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
846 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
847 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
848 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
849 rc = sqlite3_create_function(self->db, name, narg, SQLITE_UTF8, (void*)func, _pysqlite_func_callback, NULL, 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
|
850 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
851 if (rc != SQLITE_OK) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
852 /* Workaround for SQLite bug: no error code or string is available here */ |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
853 PyErr_SetString(pysqlite_OperationalError, "Error creating function"); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
854 return NULL; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
855 } else { |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
856 if (PyDict_SetItem(self->function_pinboard, func, Py_None) == -1) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
857 return 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
|
858 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
859 Py_INCREF(Py_None); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
860 return Py_None; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
861 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
862 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
863 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
864 PyObject* pysqlite_connection_create_aggregate(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
865 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
866 PyObject* aggregate_class; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
867 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
868 int n_arg; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
869 char* name; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
870 static char *kwlist[] = { "name", "n_arg", "aggregate_class", NULL }; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
871 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
|
872 |
|
59374
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
873 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
874 return NULL; |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
875 } |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
876 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
877 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO:create_aggregate", |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
878 kwlist, &name, &n_arg, &aggregate_class)) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
879 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
880 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
881 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
882 rc = sqlite3_create_function(self->db, name, n_arg, SQLITE_UTF8, (void*)aggregate_class, 0, &_pysqlite_step_callback, &_pysqlite_final_callback); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
883 if (rc != SQLITE_OK) { |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
884 /* Workaround for SQLite bug: no error code or string is available here */ |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
885 PyErr_SetString(pysqlite_OperationalError, "Error creating aggregate"); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
886 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
887 } else { |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
888 if (PyDict_SetItem(self->function_pinboard, aggregate_class, Py_None) == -1) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
889 return 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
|
890 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
891 Py_INCREF(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
|
892 return 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
|
893 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
894 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
895 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
896 static int _authorizer_callback(void* user_arg, int action, const char* arg1, const char* arg2 , const char* dbname, const char* access_attempt_source) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
897 { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
898 PyObject *ret; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
899 int rc; |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
900 #ifdef WITH_THREAD |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
901 PyGILState_STATE gilstate; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
902 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
903 gilstate = PyGILState_Ensure(); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
904 #endif |
|
84760
026593cbc006
Issue #18519, #18408: Fix sqlite authorizer callback
Victor Stinner <victor.stinner@gmail.com>
parents:
84703
diff
changeset
|
905 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
906 ret = PyObject_CallFunction((PyObject*)user_arg, "issss", action, arg1, arg2, dbname, access_attempt_source); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
907 |
|
84843
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
908 if (ret == NULL) { |
|
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
909 if (_enable_callback_tracebacks) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
910 PyErr_Print(); |
|
84843
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
911 else |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
912 PyErr_Clear(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
913 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
914 rc = SQLITE_DENY; |
|
84843
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
915 } |
|
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
916 else { |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
44018
diff
changeset
|
917 if (PyLong_Check(ret)) { |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
918 rc = _PyLong_AsInt(ret); |
|
84843
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
919 if (rc == -1 && PyErr_Occurred()) { |
|
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
920 if (_enable_callback_tracebacks) |
|
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
921 PyErr_Print(); |
|
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
922 else |
|
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
923 PyErr_Clear(); |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
924 rc = SQLITE_DENY; |
|
84760
026593cbc006
Issue #18519, #18408: Fix sqlite authorizer callback
Victor Stinner <victor.stinner@gmail.com>
parents:
84703
diff
changeset
|
925 } |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
926 } |
|
84843
f7a0a4e0ada4
Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions
Victor Stinner <victor.stinner@gmail.com>
parents:
84780
diff
changeset
|
927 else { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
928 rc = SQLITE_DENY; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
929 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
930 Py_DECREF(ret); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
931 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
932 |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
933 #ifdef WITH_THREAD |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
934 PyGILState_Release(gilstate); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
935 #endif |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
936 return rc; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
937 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
938 |
|
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:
46161
diff
changeset
|
939 static int _progress_handler(void* user_arg) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
940 { |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
941 int rc; |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
942 PyObject *ret; |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
943 #ifdef WITH_THREAD |
|
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:
46161
diff
changeset
|
944 PyGILState_STATE gilstate; |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
945 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
946 gilstate = PyGILState_Ensure(); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
947 #endif |
|
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:
46161
diff
changeset
|
948 ret = PyObject_CallFunction((PyObject*)user_arg, ""); |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
949 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
950 if (!ret) { |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
951 if (_enable_callback_tracebacks) { |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
952 PyErr_Print(); |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
953 } 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:
46161
diff
changeset
|
954 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:
46161
diff
changeset
|
955 } |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
956 |
|
51776
d06a3ebf306f
Merged revisions 69846 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
51271
diff
changeset
|
957 /* abort query if error occurred */ |
|
61720
7ba851d1b46e
Issue #6697: Check that _PyUnicode_AsString() result is not NULL in _sqlite
Victor Stinner <victor.stinner@haypocalc.com>
parents:
60845
diff
changeset
|
958 rc = 1; |
|
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:
46161
diff
changeset
|
959 } 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:
46161
diff
changeset
|
960 rc = (int)PyObject_IsTrue(ret); |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
961 Py_DECREF(ret); |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
962 } |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
963 |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
964 #ifdef WITH_THREAD |
|
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:
46161
diff
changeset
|
965 PyGILState_Release(gilstate); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
966 #endif |
|
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:
46161
diff
changeset
|
967 return rc; |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
968 } |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
969 |
|
69120
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
970 static void _trace_callback(void* user_arg, const char* statement_string) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
971 { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
972 PyObject *py_statement = NULL; |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
973 PyObject *ret = NULL; |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
974 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
975 #ifdef WITH_THREAD |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
976 PyGILState_STATE gilstate; |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
977 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
978 gilstate = PyGILState_Ensure(); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
979 #endif |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
980 py_statement = PyUnicode_DecodeUTF8(statement_string, |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
981 strlen(statement_string), "replace"); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
982 if (py_statement) { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
983 ret = PyObject_CallFunctionObjArgs((PyObject*)user_arg, py_statement, NULL); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
984 Py_DECREF(py_statement); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
985 } |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
986 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
987 if (ret) { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
988 Py_DECREF(ret); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
989 } else { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
990 if (_enable_callback_tracebacks) { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
991 PyErr_Print(); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
992 } else { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
993 PyErr_Clear(); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
994 } |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
995 } |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
996 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
997 #ifdef WITH_THREAD |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
998 PyGILState_Release(gilstate); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
999 #endif |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1000 } |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1001 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1002 static PyObject* pysqlite_connection_set_authorizer(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1003 { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1004 PyObject* authorizer_cb; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1005 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1006 static char *kwlist[] = { "authorizer_callback", NULL }; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1007 int rc; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1008 |
|
59374
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1009 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1010 return NULL; |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1011 } |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1012 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1013 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:set_authorizer", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1014 kwlist, &authorizer_cb)) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1015 return NULL; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1016 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1017 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1018 rc = sqlite3_set_authorizer(self->db, _authorizer_callback, (void*)authorizer_cb); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1019 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1020 if (rc != SQLITE_OK) { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1021 PyErr_SetString(pysqlite_OperationalError, "Error setting authorizer callback"); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1022 return NULL; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1023 } else { |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1024 if (PyDict_SetItem(self->function_pinboard, authorizer_cb, Py_None) == -1) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1025 return NULL; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1026 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1027 Py_INCREF(Py_None); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1028 return Py_None; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1029 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1030 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1031 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1032 static PyObject* pysqlite_connection_set_progress_handler(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
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:
46161
diff
changeset
|
1033 { |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1034 PyObject* progress_handler; |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1035 int n; |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1036 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1037 static char *kwlist[] = { "progress_handler", "n", NULL }; |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1038 |
|
59374
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1039 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1040 return NULL; |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1041 } |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1042 |
|
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:
46161
diff
changeset
|
1043 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi:set_progress_handler", |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1044 kwlist, &progress_handler, &n)) { |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1045 return NULL; |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1046 } |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1047 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1048 if (progress_handler == Py_None) { |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1049 /* None clears the progress handler previously 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:
46161
diff
changeset
|
1050 sqlite3_progress_handler(self->db, 0, 0, (void*)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:
46161
diff
changeset
|
1051 } 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:
46161
diff
changeset
|
1052 sqlite3_progress_handler(self->db, n, _progress_handler, progress_handler); |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1053 if (PyDict_SetItem(self->function_pinboard, progress_handler, Py_None) == -1) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1054 return 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:
46161
diff
changeset
|
1055 } |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1056 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1057 Py_INCREF(Py_None); |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1058 return Py_None; |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1059 } |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1060 |
|
69120
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1061 static PyObject* pysqlite_connection_set_trace_callback(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1062 { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1063 PyObject* trace_callback; |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1064 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1065 static char *kwlist[] = { "trace_callback", NULL }; |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1066 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1067 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1068 return NULL; |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1069 } |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1070 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1071 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:set_trace_callback", |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1072 kwlist, &trace_callback)) { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1073 return NULL; |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1074 } |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1075 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1076 if (trace_callback == Py_None) { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1077 /* None clears the trace callback previously set */ |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1078 sqlite3_trace(self->db, 0, (void*)0); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1079 } else { |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1080 if (PyDict_SetItem(self->function_pinboard, trace_callback, Py_None) == -1) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1081 return NULL; |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1082 sqlite3_trace(self->db, _trace_callback, trace_callback); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1083 } |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1084 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1085 Py_INCREF(Py_None); |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1086 return Py_None; |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1087 } |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1088 |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1089 #ifdef HAVE_LOAD_EXTENSION |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1090 static PyObject* pysqlite_enable_load_extension(pysqlite_Connection* self, PyObject* args) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1091 { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1092 int rc; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1093 int onoff; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1094 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1095 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1096 return NULL; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1097 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1098 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1099 if (!PyArg_ParseTuple(args, "i", &onoff)) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1100 return NULL; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1101 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1102 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1103 rc = sqlite3_enable_load_extension(self->db, onoff); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1104 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1105 if (rc != SQLITE_OK) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1106 PyErr_SetString(pysqlite_OperationalError, "Error enabling load extension"); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1107 return NULL; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1108 } else { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1109 Py_INCREF(Py_None); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1110 return Py_None; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1111 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1112 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1113 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1114 static PyObject* pysqlite_load_extension(pysqlite_Connection* self, PyObject* args) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1115 { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1116 int rc; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1117 char* extension_name; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1118 char* errmsg; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1119 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1120 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1121 return NULL; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1122 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1123 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1124 if (!PyArg_ParseTuple(args, "s", &extension_name)) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1125 return NULL; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1126 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1127 |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1128 rc = sqlite3_load_extension(self->db, extension_name, 0, &errmsg); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1129 if (rc != 0) { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1130 PyErr_SetString(pysqlite_OperationalError, errmsg); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1131 return NULL; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1132 } else { |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1133 Py_INCREF(Py_None); |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1134 return Py_None; |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1135 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1136 } |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1137 #endif |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1138 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1139 int pysqlite_check_thread(pysqlite_Connection* 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
|
1140 { |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
1141 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1142 if (self->check_same_thread) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1143 if (PyThread_get_thread_ident() != self->thread_ident) { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1144 PyErr_Format(pysqlite_ProgrammingError, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1145 "SQLite objects created in a thread can only be used in that same thread." |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1146 "The object was created in thread id %ld and this is thread id %ld", |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1147 self->thread_ident, PyThread_get_thread_ident()); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1148 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
|
1149 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1150 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1151 } |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
1152 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1153 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
|
1154 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1155 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1156 static PyObject* pysqlite_connection_get_isolation_level(pysqlite_Connection* self, void* unused) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1157 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1158 Py_INCREF(self->isolation_level); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1159 return self->isolation_level; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1160 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1161 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1162 static PyObject* pysqlite_connection_get_total_changes(pysqlite_Connection* self, void* unused) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1163 { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1164 if (!pysqlite_check_connection(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
|
1165 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1166 } else { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1167 return Py_BuildValue("i", sqlite3_total_changes(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
|
1168 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1169 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1170 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1171 static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* isolation_level) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1172 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1173 PyObject* res; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1174 PyObject* begin_statement; |
|
44018
a7c18b924236
#1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents:
43777
diff
changeset
|
1175 static PyObject* begin_word; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1176 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1177 Py_XDECREF(self->isolation_level); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1178 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1179 if (self->begin_statement) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1180 PyMem_Free(self->begin_statement); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1181 self->begin_statement = NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1182 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1183 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1184 if (isolation_level == 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
|
1185 Py_INCREF(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
|
1186 self->isolation_level = 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
|
1187 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1188 res = pysqlite_connection_commit(self, 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
|
1189 if (!res) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1190 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
|
1191 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1192 Py_DECREF(res); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1193 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1194 self->inTransaction = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1195 } else { |
|
43694
b102b8361d5e
Use unicode in more places. Fixes a problem with str8 + str in test.
Neal Norwitz <nnorwitz@gmail.com>
parents:
43490
diff
changeset
|
1196 const char *statement; |
|
b102b8361d5e
Use unicode in more places. Fixes a problem with str8 + str in test.
Neal Norwitz <nnorwitz@gmail.com>
parents:
43490
diff
changeset
|
1197 Py_ssize_t size; |
|
b102b8361d5e
Use unicode in more places. Fixes a problem with str8 + str in test.
Neal Norwitz <nnorwitz@gmail.com>
parents:
43490
diff
changeset
|
1198 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1199 Py_INCREF(isolation_level); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1200 self->isolation_level = isolation_level; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1201 |
|
44018
a7c18b924236
#1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents:
43777
diff
changeset
|
1202 if (!begin_word) { |
|
a7c18b924236
#1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents:
43777
diff
changeset
|
1203 begin_word = PyUnicode_FromString("BEGIN "); |
|
a7c18b924236
#1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents:
43777
diff
changeset
|
1204 if (!begin_word) return -1; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1205 } |
|
44018
a7c18b924236
#1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents:
43777
diff
changeset
|
1206 begin_statement = PyUnicode_Concat(begin_word, isolation_level); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1207 if (!begin_statement) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1208 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
|
1209 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1210 |
|
48660
85b67fb5672b
Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents:
48563
diff
changeset
|
1211 statement = _PyUnicode_AsStringAndSize(begin_statement, &size); |
|
48563
b51cd5d3795c
Merged revisions 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from
Georg Brandl <georg@python.org>
parents:
48463
diff
changeset
|
1212 if (!statement) { |
|
59852
92f256174154
Merged revisions 78894 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59374
diff
changeset
|
1213 Py_DECREF(begin_statement); |
|
48563
b51cd5d3795c
Merged revisions 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from
Georg Brandl <georg@python.org>
parents:
48463
diff
changeset
|
1214 return -1; |
|
b51cd5d3795c
Merged revisions 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from
Georg Brandl <georg@python.org>
parents:
48463
diff
changeset
|
1215 } |
|
43694
b102b8361d5e
Use unicode in more places. Fixes a problem with str8 + str in test.
Neal Norwitz <nnorwitz@gmail.com>
parents:
43490
diff
changeset
|
1216 self->begin_statement = PyMem_Malloc(size + 2); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1217 if (!self->begin_statement) { |
|
48563
b51cd5d3795c
Merged revisions 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from
Georg Brandl <georg@python.org>
parents:
48463
diff
changeset
|
1218 Py_DECREF(begin_statement); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1219 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
|
1220 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1221 |
|
43694
b102b8361d5e
Use unicode in more places. Fixes a problem with str8 + str in test.
Neal Norwitz <nnorwitz@gmail.com>
parents:
43490
diff
changeset
|
1222 strcpy(self->begin_statement, statement); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1223 Py_DECREF(begin_statement); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1224 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1225 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1226 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
|
1227 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1228 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1229 PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1230 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1231 PyObject* sql; |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1232 pysqlite_Statement* statement; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
1233 PyObject* weakref; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1234 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
|
1235 |
|
59374
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1236 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1237 return NULL; |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1238 } |
|
ecca703bc0df
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1239 |
|
86945
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1240 if (!PyArg_ParseTuple(args, "O", &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
|
1241 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1242 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1243 _pysqlite_drop_unused_statement_references(self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
1244 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1245 statement = PyObject_New(pysqlite_Statement, &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
|
1246 if (!statement) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1247 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1248 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1249 |
|
59854
c073f3c3276e
Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59852
diff
changeset
|
1250 statement->db = NULL; |
|
c073f3c3276e
Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59852
diff
changeset
|
1251 statement->st = NULL; |
|
c073f3c3276e
Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59852
diff
changeset
|
1252 statement->sql = NULL; |
|
c073f3c3276e
Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59852
diff
changeset
|
1253 statement->in_use = 0; |
|
c073f3c3276e
Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59852
diff
changeset
|
1254 statement->in_weakreflist = NULL; |
|
c073f3c3276e
Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59852
diff
changeset
|
1255 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1256 rc = pysqlite_statement_create(statement, self, 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
|
1257 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
|
1258 if (rc == PYSQLITE_TOO_MUCH_SQL) { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1259 PyErr_SetString(pysqlite_Warning, "You can only execute one statement at a time."); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1260 } else if (rc == PYSQLITE_SQL_WRONG_TYPE) { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1261 PyErr_SetString(pysqlite_Warning, "SQL is of wrong type. Must be string or 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
|
1262 } 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:
46161
diff
changeset
|
1263 (void)pysqlite_statement_reset(statement); |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1264 _pysqlite_seterror(self->db, 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
|
1265 } |
|
86945
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1266 goto error; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1267 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1268 |
|
86945
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1269 weakref = PyWeakref_NewRef((PyObject*)statement, NULL); |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1270 if (weakref == NULL) |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1271 goto error; |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1272 if (PyList_Append(self->statements, weakref) != 0) { |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1273 Py_DECREF(weakref); |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1274 goto error; |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1275 } |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1276 Py_DECREF(weakref); |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1277 |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1278 return (PyObject*)statement; |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1279 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
1280 error: |
|
86945
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1281 Py_DECREF(statement); |
|
00ee08fac522
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
Victor Stinner <victor.stinner@gmail.com>
parents:
85422
diff
changeset
|
1282 return 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
|
1283 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1284 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1285 PyObject* pysqlite_connection_execute(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1286 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1287 PyObject* cursor = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1288 PyObject* result = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1289 PyObject* method = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1290 |
|
72835
5e33219492bc
Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents:
72475
diff
changeset
|
1291 cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, ""); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1292 if (!cursor) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1293 goto error; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1294 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1295 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1296 method = PyObject_GetAttrString(cursor, "execute"); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1297 if (!method) { |
|
48463
81e34d7e4ba0
Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
47301
diff
changeset
|
1298 Py_CLEAR(cursor); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1299 goto error; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1300 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1301 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1302 result = PyObject_CallObject(method, args); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1303 if (!result) { |
|
48463
81e34d7e4ba0
Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
47301
diff
changeset
|
1304 Py_CLEAR(cursor); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1305 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1306 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1307 error: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1308 Py_XDECREF(result); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1309 Py_XDECREF(method); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1310 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1311 return cursor; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1312 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1313 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1314 PyObject* pysqlite_connection_executemany(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1315 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1316 PyObject* cursor = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1317 PyObject* result = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1318 PyObject* method = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1319 |
|
72835
5e33219492bc
Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents:
72475
diff
changeset
|
1320 cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, ""); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1321 if (!cursor) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1322 goto error; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1323 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1324 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1325 method = PyObject_GetAttrString(cursor, "executemany"); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1326 if (!method) { |
|
48463
81e34d7e4ba0
Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
47301
diff
changeset
|
1327 Py_CLEAR(cursor); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1328 goto error; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1329 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1330 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1331 result = PyObject_CallObject(method, args); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1332 if (!result) { |
|
48463
81e34d7e4ba0
Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
47301
diff
changeset
|
1333 Py_CLEAR(cursor); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1334 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1335 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1336 error: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1337 Py_XDECREF(result); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1338 Py_XDECREF(method); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1339 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1340 return cursor; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1341 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1342 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1343 PyObject* pysqlite_connection_executescript(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1344 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1345 PyObject* cursor = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1346 PyObject* result = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1347 PyObject* method = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1348 |
|
72835
5e33219492bc
Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents:
72475
diff
changeset
|
1349 cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, ""); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1350 if (!cursor) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1351 goto error; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1352 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1353 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1354 method = PyObject_GetAttrString(cursor, "executescript"); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1355 if (!method) { |
|
48463
81e34d7e4ba0
Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
47301
diff
changeset
|
1356 Py_CLEAR(cursor); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1357 goto error; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1358 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1359 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1360 result = PyObject_CallObject(method, args); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1361 if (!result) { |
|
48463
81e34d7e4ba0
Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
47301
diff
changeset
|
1362 Py_CLEAR(cursor); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1363 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1364 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1365 error: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1366 Py_XDECREF(result); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1367 Py_XDECREF(method); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1368 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1369 return cursor; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1370 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1371 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1372 /* ------------------------- COLLATION CODE ------------------------ */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1373 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1374 static int |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1375 pysqlite_collation_callback( |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1376 void* context, |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1377 int text1_length, const void* text1_data, |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1378 int text2_length, const void* text2_data) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1379 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1380 PyObject* callback = (PyObject*)context; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1381 PyObject* string1 = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1382 PyObject* string2 = 0; |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
1383 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1384 PyGILState_STATE gilstate; |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
1385 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1386 PyObject* retval = NULL; |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1387 long longval; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1388 int result = 0; |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
1389 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1390 gilstate = PyGILState_Ensure(); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
1391 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1392 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1393 if (PyErr_Occurred()) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1394 goto finally; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1395 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1396 |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43694
diff
changeset
|
1397 string1 = PyUnicode_FromStringAndSize((const char*)text1_data, text1_length); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43694
diff
changeset
|
1398 string2 = PyUnicode_FromStringAndSize((const char*)text2_data, text2_length); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1399 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1400 if (!string1 || !string2) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1401 goto finally; /* failed to allocate strings */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1402 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1403 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1404 retval = PyObject_CallFunctionObjArgs(callback, string1, string2, NULL); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1405 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1406 if (!retval) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1407 /* execution failed */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1408 goto finally; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1409 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1410 |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1411 longval = PyLong_AsLongAndOverflow(retval, &result); |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1412 if (longval == -1 && PyErr_Occurred()) { |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1413 PyErr_Clear(); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1414 result = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1415 } |
|
82055
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1416 else if (!result) { |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1417 if (longval > 0) |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1418 result = 1; |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1419 else if (longval < 0) |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1420 result = -1; |
|
55a89352e220
Issue #17073: Fix some integer overflows in sqlite3 module.
Serhiy Storchaka <storchaka@gmail.com>
parents:
75119
diff
changeset
|
1421 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1422 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1423 finally: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1424 Py_XDECREF(string1); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1425 Py_XDECREF(string2); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1426 Py_XDECREF(retval); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
1427 #ifdef WITH_THREAD |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1428 PyGILState_Release(gilstate); |
|
52870
98f42392835b
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Georg Brandl <georg@python.org>
parents:
51776
diff
changeset
|
1429 #endif |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1430 return result; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1431 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1432 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1433 static PyObject * |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1434 pysqlite_connection_interrupt(pysqlite_Connection* self, PyObject* args) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1435 { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1436 PyObject* retval = NULL; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1437 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1438 if (!pysqlite_check_connection(self)) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1439 goto finally; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1440 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1441 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1442 sqlite3_interrupt(self->db); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1443 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1444 Py_INCREF(Py_None); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1445 retval = Py_None; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1446 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1447 finally: |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1448 return retval; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1449 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1450 |
|
46161
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1451 /* Function author: Paul Kippes <kippesp@gmail.com> |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1452 * Class method of Connection to call the Python function _iterdump |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1453 * of the sqlite3 module. |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1454 */ |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1455 static PyObject * |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1456 pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args) |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1457 { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1458 PyObject* retval = NULL; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1459 PyObject* module = NULL; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1460 PyObject* module_dict; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1461 PyObject* pyfn_iterdump; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1462 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1463 if (!pysqlite_check_connection(self)) { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1464 goto finally; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1465 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1466 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1467 module = PyImport_ImportModule(MODULE_NAME ".dump"); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1468 if (!module) { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1469 goto finally; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1470 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1471 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1472 module_dict = PyModule_GetDict(module); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1473 if (!module_dict) { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1474 goto finally; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1475 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1476 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1477 pyfn_iterdump = PyDict_GetItemString(module_dict, "_iterdump"); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1478 if (!pyfn_iterdump) { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1479 PyErr_SetString(pysqlite_OperationalError, "Failed to obtain _iterdump() reference"); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1480 goto finally; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1481 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1482 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1483 args = PyTuple_New(1); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1484 if (!args) { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1485 goto finally; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1486 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1487 Py_INCREF(self); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1488 PyTuple_SetItem(args, 0, (PyObject*)self); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1489 retval = PyObject_CallObject(pyfn_iterdump, args); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1490 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1491 finally: |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1492 Py_XDECREF(args); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1493 Py_XDECREF(module); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1494 return retval; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1495 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1496 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1497 static PyObject * |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1498 pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1499 { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1500 PyObject* callable; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1501 PyObject* uppercase_name = 0; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1502 PyObject* name; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1503 PyObject* retval; |
|
60847
8c0517f50c4e
Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59854
diff
changeset
|
1504 Py_ssize_t i, len; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72835
diff
changeset
|
1505 _Py_IDENTIFIER(upper); |
|
60847
8c0517f50c4e
Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59854
diff
changeset
|
1506 char *uppercase_name_str; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1507 int rc; |
| 72475 | 1508 unsigned int kind; |
| 1509 void *data; | |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1510 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1511 if (!pysqlite_check_thread(self) || !pysqlite_check_connection(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
|
1512 goto finally; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1513 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1514 |
|
42525
e64286053b25
Make the sqlite tests pass.
Gerhard Häring <gh@ghaering.de>
parents:
42334
diff
changeset
|
1515 if (!PyArg_ParseTuple(args, "O!O:create_collation(name, callback)", &PyUnicode_Type, &name, &callable)) { |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1516 goto finally; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1517 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1518 |
|
72835
5e33219492bc
Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents:
72475
diff
changeset
|
1519 uppercase_name = _PyObject_CallMethodId(name, &PyId_upper, ""); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1520 if (!uppercase_name) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1521 goto finally; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1522 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1523 |
| 72475 | 1524 if (PyUnicode_READY(uppercase_name)) |
| 1525 goto finally; | |
| 1526 len = PyUnicode_GET_LENGTH(uppercase_name); | |
| 1527 kind = PyUnicode_KIND(uppercase_name); | |
| 1528 data = PyUnicode_DATA(uppercase_name); | |
| 1529 for (i=0; i<len; i++) { | |
| 1530 Py_UCS4 ch = PyUnicode_READ(kind, data, i); | |
| 1531 if ((ch >= '0' && ch <= '9') | |
| 1532 || (ch >= 'A' && ch <= 'Z') | |
| 1533 || (ch == '_')) | |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1534 { |
|
60847
8c0517f50c4e
Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59854
diff
changeset
|
1535 continue; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1536 } else { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1537 PyErr_SetString(pysqlite_ProgrammingError, "invalid character in collation name"); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1538 goto finally; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1539 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1540 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1541 |
|
60847
8c0517f50c4e
Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59854
diff
changeset
|
1542 uppercase_name_str = _PyUnicode_AsString(uppercase_name); |
|
8c0517f50c4e
Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59854
diff
changeset
|
1543 if (!uppercase_name_str) |
|
8c0517f50c4e
Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59854
diff
changeset
|
1544 goto finally; |
|
8c0517f50c4e
Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59854
diff
changeset
|
1545 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1546 if (callable != Py_None && !PyCallable_Check(callable)) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1547 PyErr_SetString(PyExc_TypeError, "parameter must be callable"); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1548 goto finally; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1549 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1550 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1551 if (callable != Py_None) { |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1552 if (PyDict_SetItem(self->collations, uppercase_name, callable) == -1) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1553 goto finally; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1554 } else { |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1555 if (PyDict_DelItem(self->collations, uppercase_name) == -1) |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1556 goto finally; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1557 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1558 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1559 rc = sqlite3_create_collation(self->db, |
|
60847
8c0517f50c4e
Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59854
diff
changeset
|
1560 uppercase_name_str, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1561 SQLITE_UTF8, |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1562 (callable != Py_None) ? callable : NULL, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1563 (callable != Py_None) ? pysqlite_collation_callback : 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
|
1564 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
|
1565 PyDict_DelItem(self->collations, uppercase_name); |
|
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:
46161
diff
changeset
|
1566 _pysqlite_seterror(self->db, 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
|
1567 goto finally; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1568 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1569 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1570 finally: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1571 Py_XDECREF(uppercase_name); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1572 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1573 if (PyErr_Occurred()) { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1574 retval = NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1575 } else { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1576 Py_INCREF(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
|
1577 retval = 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
|
1578 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1579 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1580 return retval; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1581 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1582 |
|
46161
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1583 /* Called when the connection is used as a context manager. Returns itself as a |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1584 * convenience to the caller. */ |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1585 static PyObject * |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1586 pysqlite_connection_enter(pysqlite_Connection* self, PyObject* args) |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1587 { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1588 Py_INCREF(self); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1589 return (PyObject*)self; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1590 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1591 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1592 /** Called when the connection is used as a context manager. If there was any |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1593 * exception, a rollback takes place; otherwise we commit. */ |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1594 static PyObject * |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1595 pysqlite_connection_exit(pysqlite_Connection* self, PyObject* args) |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1596 { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1597 PyObject* exc_type, *exc_value, *exc_tb; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1598 char* method_name; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1599 PyObject* result; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1600 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1601 if (!PyArg_ParseTuple(args, "OOO", &exc_type, &exc_value, &exc_tb)) { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1602 return NULL; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1603 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1604 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1605 if (exc_type == Py_None && exc_value == Py_None && exc_tb == Py_None) { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1606 method_name = "commit"; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1607 } else { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1608 method_name = "rollback"; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1609 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1610 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1611 result = PyObject_CallMethod((PyObject*)self, method_name, ""); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1612 if (!result) { |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1613 return NULL; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1614 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1615 Py_DECREF(result); |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1616 |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1617 Py_RETURN_FALSE; |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1618 } |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1619 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1620 static char connection_doc[] = |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
1621 PyDoc_STR("SQLite database connection object."); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1622 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1623 static PyGetSetDef connection_getset[] = { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1624 {"isolation_level", (getter)pysqlite_connection_get_isolation_level, (setter)pysqlite_connection_set_isolation_level}, |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1625 {"total_changes", (getter)pysqlite_connection_get_total_changes, (setter)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
|
1626 {NULL} |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1627 }; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1628 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1629 static PyMethodDef connection_methods[] = { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1630 {"cursor", (PyCFunction)pysqlite_connection_cursor, METH_VARARGS|METH_KEYWORDS, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1631 PyDoc_STR("Return a cursor for the connection.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1632 {"close", (PyCFunction)pysqlite_connection_close, METH_NOARGS, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1633 PyDoc_STR("Closes the connection.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1634 {"commit", (PyCFunction)pysqlite_connection_commit, METH_NOARGS, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1635 PyDoc_STR("Commit the current transaction.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1636 {"rollback", (PyCFunction)pysqlite_connection_rollback, METH_NOARGS, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1637 PyDoc_STR("Roll back the current transaction.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1638 {"create_function", (PyCFunction)pysqlite_connection_create_function, METH_VARARGS|METH_KEYWORDS, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1639 PyDoc_STR("Creates a new function. Non-standard.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1640 {"create_aggregate", (PyCFunction)pysqlite_connection_create_aggregate, METH_VARARGS|METH_KEYWORDS, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1641 PyDoc_STR("Creates a new aggregate. Non-standard.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1642 {"set_authorizer", (PyCFunction)pysqlite_connection_set_authorizer, METH_VARARGS|METH_KEYWORDS, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1643 PyDoc_STR("Sets authorizer callback. Non-standard.")}, |
|
59372
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1644 #ifdef HAVE_LOAD_EXTENSION |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1645 {"enable_load_extension", (PyCFunction)pysqlite_enable_load_extension, METH_VARARGS, |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1646 PyDoc_STR("Enable dynamic loading of SQLite extension modules. Non-standard.")}, |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1647 {"load_extension", (PyCFunction)pysqlite_load_extension, METH_VARARGS, |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1648 PyDoc_STR("Load SQLite extension module. Non-standard.")}, |
|
3003c1656e2a
Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents:
52870
diff
changeset
|
1649 #endif |
|
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:
46161
diff
changeset
|
1650 {"set_progress_handler", (PyCFunction)pysqlite_connection_set_progress_handler, METH_VARARGS|METH_KEYWORDS, |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
46161
diff
changeset
|
1651 PyDoc_STR("Sets progress handler callback. Non-standard.")}, |
|
69120
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1652 {"set_trace_callback", (PyCFunction)pysqlite_connection_set_trace_callback, METH_VARARGS|METH_KEYWORDS, |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68258
diff
changeset
|
1653 PyDoc_STR("Sets a trace callback called for each SQL statement (passed as unicode). Non-standard.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1654 {"execute", (PyCFunction)pysqlite_connection_execute, METH_VARARGS, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1655 PyDoc_STR("Executes a SQL statement. Non-standard.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1656 {"executemany", (PyCFunction)pysqlite_connection_executemany, METH_VARARGS, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1657 PyDoc_STR("Repeatedly executes a SQL statement. Non-standard.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1658 {"executescript", (PyCFunction)pysqlite_connection_executescript, METH_VARARGS, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1659 PyDoc_STR("Executes a multiple SQL statements at once. Non-standard.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1660 {"create_collation", (PyCFunction)pysqlite_connection_create_collation, METH_VARARGS, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
1661 PyDoc_STR("Creates a collation function. Non-standard.")}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1662 {"interrupt", (PyCFunction)pysqlite_connection_interrupt, METH_NOARGS, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1663 PyDoc_STR("Abort any pending database operation. Non-standard.")}, |
|
46161
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1664 {"iterdump", (PyCFunction)pysqlite_connection_iterdump, METH_NOARGS, |
|
49178
8f886acaa142
Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
48660
diff
changeset
|
1665 PyDoc_STR("Returns iterator to the dump of the database in an SQL text format. Non-standard.")}, |
|
46161
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1666 {"__enter__", (PyCFunction)pysqlite_connection_enter, METH_NOARGS, |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1667 PyDoc_STR("For context manager. Non-standard.")}, |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1668 {"__exit__", (PyCFunction)pysqlite_connection_exit, METH_VARARGS, |
|
848160d10780
Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
1669 PyDoc_STR("For context manager. Non-standard.")}, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1670 {NULL, NULL} |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1671 }; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1672 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1673 static struct PyMemberDef connection_members[] = |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1674 { |
|
42541
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1675 {"Warning", T_OBJECT, offsetof(pysqlite_Connection, Warning), READONLY}, |
|
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1676 {"Error", T_OBJECT, offsetof(pysqlite_Connection, Error), READONLY}, |
|
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1677 {"InterfaceError", T_OBJECT, offsetof(pysqlite_Connection, InterfaceError), READONLY}, |
|
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1678 {"DatabaseError", T_OBJECT, offsetof(pysqlite_Connection, DatabaseError), READONLY}, |
|
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1679 {"DataError", T_OBJECT, offsetof(pysqlite_Connection, DataError), READONLY}, |
|
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1680 {"OperationalError", T_OBJECT, offsetof(pysqlite_Connection, OperationalError), READONLY}, |
|
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1681 {"IntegrityError", T_OBJECT, offsetof(pysqlite_Connection, IntegrityError), READONLY}, |
|
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1682 {"InternalError", T_OBJECT, offsetof(pysqlite_Connection, InternalError), READONLY}, |
|
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1683 {"ProgrammingError", T_OBJECT, offsetof(pysqlite_Connection, ProgrammingError), READONLY}, |
|
d1855d0e4e03
A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents:
42526
diff
changeset
|
1684 {"NotSupportedError", T_OBJECT, offsetof(pysqlite_Connection, NotSupportedError), READONLY}, |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1685 {"row_factory", T_OBJECT, offsetof(pysqlite_Connection, row_factory)}, |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1686 {"text_factory", T_OBJECT, offsetof(pysqlite_Connection, text_factory)}, |
|
62009
62ca540d8b6e
#8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents:
61720
diff
changeset
|
1687 {"in_transaction", T_BOOL, offsetof(pysqlite_Connection, inTransaction), READONLY}, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1688 {NULL} |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1689 }; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1690 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1691 PyTypeObject pysqlite_ConnectionType = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
40643
diff
changeset
|
1692 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
|
1693 MODULE_NAME ".Connection", /* tp_name */ |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1694 sizeof(pysqlite_Connection), /* 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
|
1695 0, /* tp_itemsize */ |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1696 (destructor)pysqlite_connection_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
|
1697 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
|
1698 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
|
1699 0, /* tp_setattr */ |
|
51271
87fbbf22adf3
Merged revisions 69214 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
49178
diff
changeset
|
1700 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
|
1701 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
|
1702 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
|
1703 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
|
1704 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
|
1705 0, /* tp_hash */ |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1706 (ternaryfunc)pysqlite_connection_call, /* tp_call */ |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1707 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
|
1708 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
|
1709 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
|
1710 0, /* tp_as_buffer */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1711 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1712 connection_doc, /* 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
|
1713 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
|
1714 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
|
1715 0, /* tp_richcompare */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1716 0, /* tp_weaklistoffset */ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1717 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
|
1718 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
|
1719 connection_methods, /* 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
|
1720 connection_members, /* 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
|
1721 connection_getset, /* 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
|
1722 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
|
1723 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
|
1724 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
|
1725 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
|
1726 0, /* tp_dictoffset */ |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1727 (initproc)pysqlite_connection_init, /* tp_init */ |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1728 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
|
1729 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
|
1730 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
|
1731 }; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1732 |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1733 extern int pysqlite_connection_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
|
1734 { |
|
40643
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1735 pysqlite_ConnectionType.tp_new = PyType_GenericNew; |
|
47f9efdc0855
Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1736 return PyType_Ready(&pysqlite_ConnectionType); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1737 } |
