annotate Modules/_sqlite/connection.c @ 74006:88198b93ff2f

Issue #13560: Add PyUnicode_EncodeLocale() * Use PyUnicode_EncodeLocale() in time.strftime() if wcsftime() is not available * Document my last changes in Misc/NEWS
author Victor Stinner <victor.stinner@haypocalc.com>
date Sat, 17 Dec 2011 04:13:41 +0100
parents 7109f31300fb
children cf12fe9ce2b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1 /* 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 #include "sqlitecompat.h"
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
33
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
34 #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
35
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
36 #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
37 #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
38
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
39 #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
40 #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
41 #define HAVE_LOAD_EXTENSION
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 #endif
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
44
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
45 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
46 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
47
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
48
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
49 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
50 {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
51 /* 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
52 * 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
53 * segfaults, depending on the SQLite version */
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
54 #if SQLITE_VERSION_NUMBER >= 3003003
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
55 sqlite3_result_error(ctx, errmsg, len);
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
56 #else
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
57 PyErr_SetString(pysqlite_OperationalError, errmsg);
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
58 #endif
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
59 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
60
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
61 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
62 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
63 static char *kwlist[] = {"database", "timeout", "detect_types", "isolation_level", "check_same_thread", "factory", "cached_statements", 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
64
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
65 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
66 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
67 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
68 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
69 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
70 int cached_statements = 100;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
71 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
72 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
73
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
74 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOi", kwlist,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
75 &database, &timeout, &detect_types, &isolation_level, &check_same_thread, &factory, &cached_statements))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
76 {
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
77 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
78 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
79
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
80 self->initialized = 1;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
81
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
82 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
83
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
84 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
85 self->statements = NULL;
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
86 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
87
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
88 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
89 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
90
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
91 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
92 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
93
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
94 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
95 rc = sqlite3_open(database, &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
96 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
97
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
98 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
99 _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
100 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
101 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
102
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
103 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
104 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
105 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
106 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
107 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
108 } else {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
109 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
110 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
111 self->isolation_level = NULL;
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
112 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
113 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
114
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
115 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
116 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
117 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
118 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
119
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
120 self->created_statements = 0;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
121 self->created_cursors = 0;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
122
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
123 /* 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
124 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
125 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
126 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
127 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
128 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
129
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
130 /* 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
131 * 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
132 * 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
133 * 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
134 */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
135 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
136 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
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 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
139 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
140 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
141 (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
142 #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
143 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
144 #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
145 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
146
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
147 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
148 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
149 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
150 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
151
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
152 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
153 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
154 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
155 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
156
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
157 self->Warning = pysqlite_Warning;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
158 self->Error = pysqlite_Error;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
159 self->InterfaceError = pysqlite_InterfaceError;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
160 self->DatabaseError = pysqlite_DatabaseError;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
161 self->DataError = pysqlite_DataError;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
162 self->OperationalError = pysqlite_OperationalError;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
163 self->IntegrityError = pysqlite_IntegrityError;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
164 self->InternalError = pysqlite_InternalError;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
165 self->ProgrammingError = pysqlite_ProgrammingError;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
166 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
167
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
168 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
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
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
171 /* 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
172 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
173 {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
174 pysqlite_Node* node;
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
175 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
176
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
177 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
178
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
179 while (node) {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
180 statement = (pysqlite_Statement*)(node->data);
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
181 (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
182 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
183 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
184
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
185 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
186 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
187 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
188 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
189 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
190
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
191 /* 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
192 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
193 {
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
194 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
195 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
196 PyObject* statement;
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
197 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
198
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
199 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
200 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
201 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
202 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
203 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
204 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
205 (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
206 } 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
207 (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
208 }
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
209 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
210 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
211 }
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
212
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
213 if (reset_cursors) {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
214 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
215 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
216 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
217 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
218 cursor->reset = 1;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
219 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
220 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
221 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
222 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
223
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
224 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
225 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
226 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
227
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
228 /* 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
229 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
230 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
231 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
232 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
233 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
234
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
235 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
236 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
237 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245
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
246 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
247 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
248
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
249 /*
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
250 * 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
251 *
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
252 * 0 => error; 1 => ok
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
253 */
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
254 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
255 {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
256 PyObject* weakref;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
257
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
258 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
259 if (!weakref) {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
260 goto error;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
261 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
262
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
263 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
264 Py_CLEAR(weakref);
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
265 goto error;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
266 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
267
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
268 Py_DECREF(weakref);
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
269
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
270 return 1;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
271 error:
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
272 return 0;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
273 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
274
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
275 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
276 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
277 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
278 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
279 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
280
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
281 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
282 &factory)) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
283 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
284 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
285
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
286 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
287 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
288 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
289
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
290 if (factory == NULL) {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
291 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
292 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
293
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
294 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
295
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
296 _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
297
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
298 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
299 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
300 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
301 ((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
302 }
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 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
305 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
306
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
307 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
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 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
310
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
311 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
312 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
313 }
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_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
316
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 (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
318 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
319 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
320 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
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 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
323 _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
324 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
325 } else {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
326 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
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 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
329
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
330 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
331 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
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
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
334 /*
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
335 * 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
336 *
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
337 * 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
338 */
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
339 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
340 {
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
341 if (!con->initialized) {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
342 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
343 return 0;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
344 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
345
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
346 if (!con->db) {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
347 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
348 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
349 } else {
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 1;
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
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
354 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
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 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
357 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
358 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
359
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
360 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
361 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
362 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
363
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
364 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
365 _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
366 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
367 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
368
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
369 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
370 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
371 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
372 } 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
373 _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
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
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
376 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
377 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
378 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
379
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
380 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
381 _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
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
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
384 error:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
385 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
386 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
387 } else {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
388 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
389 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
390 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
391 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
392
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
393 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
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 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
396 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
397 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
398
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
399 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
400 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
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 if (self->inTransaction) {
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
404 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
405
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
406 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
407 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
408 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
409 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
410 _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
411 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
412 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
413
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
414 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
415 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
416 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
417 } 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
418 _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
419 }
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 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
422 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
423 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
424 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
425 _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
426 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
427
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
428 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
429
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
430 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 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
432 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
433 } else {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
434 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
435 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
436 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
437 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
438
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
439 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
440 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
441 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
442 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
443 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
444
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
445 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
446 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
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 if (self->inTransaction) {
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
450 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
451
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
452 Py_BEGIN_ALLOW_THREADS
42543
a44c564026b8 Fix automatic replacing mistake.
Georg Brandl <georg@python.org>
parents: 42541
diff changeset
453 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
454 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
455 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
456 _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
457 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
458 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
459
49178
8f886acaa142 Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48660
diff changeset
460 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
461 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
462 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
463 } 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
464 _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
465 }
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 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
468 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
469 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
470 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
471 _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
472 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
473
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
474 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
475
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
476 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 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
478 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
479 } else {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
480 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
481 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
482 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
483 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
484
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
485 void _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
486 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
487 long longval;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
488 const char* buffer;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
489 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
490
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
491 if ((!py_val) || 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
492 sqlite3_result_null(context);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
493 } else if (py_val == 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
494 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
495 } else if (PyLong_Check(py_val)) {
f324631462a2 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents: 44018
diff changeset
496 longval = PyLong_AsLong(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
497 sqlite3_result_int64(context, (PY_LONG_LONG)longval);
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 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
499 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
500 } else if (PyUnicode_Check(py_val)) {
61720
7ba851d1b46e Issue #6697: Check that _PyUnicode_AsString() result is not NULL in _sqlite
Victor Stinner <victor.stinner@haypocalc.com>
parents: 60845
diff changeset
501 char *str = _PyUnicode_AsString(py_val);
7ba851d1b46e Issue #6697: Check that _PyUnicode_AsString() result is not NULL in _sqlite
Victor Stinner <victor.stinner@haypocalc.com>
parents: 60845
diff changeset
502 if (str != NULL)
7ba851d1b46e Issue #6697: Check that _PyUnicode_AsString() result is not NULL in _sqlite
Victor Stinner <victor.stinner@haypocalc.com>
parents: 60845
diff changeset
503 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
504 } else if (PyObject_CheckBuffer(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
505 if (PyObject_AsCharBuffer(py_val, &buffer, &buflen) != 0) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
506 PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
507 } else {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
508 sqlite3_result_blob(context, buffer, 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
509 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
510 } else {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
511 /* TODO: raise error */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
512 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
513 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
514
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
515 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
516 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
517 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
518 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
519 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
520 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
521 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
522 PY_LONG_LONG val_int;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
523 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
524
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
525 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
526 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
527 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
528 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
529
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
530 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
531 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
532 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
533 case SQLITE_INTEGER:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
534 val_int = sqlite3_value_int64(cur_value);
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
535 cur_py_value = PyLong_FromLong((long)val_int);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
536 break;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
537 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
538 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
539 break;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
540 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
541 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
542 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
543 /* 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
544 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
545 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
546 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
547 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
548 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
549 break;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
550 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
551 buflen = sqlite3_value_bytes(cur_value);
47301
23ab586c427a Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents: 46178
diff changeset
552 cur_py_value = PyBytes_FromStringAndSize(
43487
8c10aac37037 Breaking ground for PEP 3137 implementation:
Guido van Rossum <guido@python.org>
parents: 42543
diff changeset
553 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
554 break;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
555 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
556 default:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
557 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
558 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
559 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
560
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
561 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
562 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
563 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
564 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
565
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
566 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
567
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
568 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
569
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
570 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
571 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
572
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
573 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
574 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
575 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
576 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
577 PyObject* py_retval = 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
578
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
579 #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
580 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
581
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
582 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
583 #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
584
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
585 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
586
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
587 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
588 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
589 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
590 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
591 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
592
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
593 if (py_retval) {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
594 _pysqlite_set_result(context, py_retval);
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
595 Py_DECREF(py_retval);
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
596 } else {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
597 if (_enable_callback_tracebacks) {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
598 PyErr_Print();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
599 } else {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
600 PyErr_Clear();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
601 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
602 _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
603 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
604
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
605 #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
606 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
607 #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
608 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
609
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
610 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
611 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
612 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
613 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
614 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
615 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
616 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
617
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
618 #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
619 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
620
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
621 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
622 #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
623
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
624 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
625
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
626 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
627
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
628 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
629 *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
630
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
631 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
632 *aggregate_instance = 0;
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
633 if (_enable_callback_tracebacks) {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
634 PyErr_Print();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
635 } else {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
636 PyErr_Clear();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
637 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
638 _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
639 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
640 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
641 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
642
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
643 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
644 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
645 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
646 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
647
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
648 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
649 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
650 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
651 }
37879
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 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
654 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
655
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
656 if (!function_result) {
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
657 if (_enable_callback_tracebacks) {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
658 PyErr_Print();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
659 } else {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
660 PyErr_Clear();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
661 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
662 _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
663 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
664
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
665 error:
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
666 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
667 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
668
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
669 #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
670 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
671 #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
672 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
673
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
674 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
675 {
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 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
677 PyObject** aggregate_instance;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72835
diff changeset
678 _Py_IDENTIFIER(finalize);
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
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
680 #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
681 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
682
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
683 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
684 #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
685
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
686 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
687 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
688 /* 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
689 * __init__ */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
690
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
691 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
692 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
693
72835
5e33219492bc Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents: 72475
diff changeset
694 function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, "");
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
695 if (!function_result) {
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
696 if (_enable_callback_tracebacks) {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
697 PyErr_Print();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
698 } else {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
699 PyErr_Clear();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
700 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
701 _sqlite3_result_error(context, "user-defined aggregate's 'finalize' method raised error", -1);
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
702 } else {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
703 _pysqlite_set_result(context, 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 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
705
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
706 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
707 Py_XDECREF(*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
708 Py_XDECREF(function_result);
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_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
712 #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
713 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
714
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
715 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
716 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
717 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
718 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
719 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
720
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
721 /* 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
722 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
723 return;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
724 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
725
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
726 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
727
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
728 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
729 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
730 return;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
731 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
732
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
733 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
734 weakref = PyList_GetItem(self->statements, i);
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
735 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
736 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
737 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
738 return;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
739 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
740 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
741 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
742
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
743 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
744 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
745 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
746
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
747 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
748 {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
749 PyObject* new_list;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
750 PyObject* weakref;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
751 int i;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
752
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
753 /* 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
754 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
755 return;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
756 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
757
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
758 self->created_cursors = 0;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
759
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
760 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
761 if (!new_list) {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
762 return;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
763 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
764
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
765 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
766 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
767 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
768 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
769 Py_DECREF(new_list);
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
770 return;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
771 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
772 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
773 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
774
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
775 Py_DECREF(self->cursors);
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
776 self->cursors = new_list;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
777 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
778
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
779 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
780 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
781 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
782
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
783 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
784 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
785 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
786 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
787
59374
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
788 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
789 return NULL;
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
790 }
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
791
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
792 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
793 &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
794 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
795 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
796 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
797
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
798 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
799
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
800 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
801 /* 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
802 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
803 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
804 } else {
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
805 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
806 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
807
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
808 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
809 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
810 }
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
811 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
812
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
813 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
814 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
815 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
816
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
817 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
818 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
819 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
820 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
821
59374
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
822 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
823 return NULL;
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
824 }
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
825
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
826 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
827 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
828 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
829 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
830
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
831 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
832 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
833 /* 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
834 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
835 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
836 } else {
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
837 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
838 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
839
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
840 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
841 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
842 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
843 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
844
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
845 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
846 {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
847 PyObject *ret;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
848 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
849 #ifdef WITH_THREAD
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
850 PyGILState_STATE gilstate;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
851
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
852 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
853 #endif
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
854 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
855
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
856 if (!ret) {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
857 if (_enable_callback_tracebacks) {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
858 PyErr_Print();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
859 } else {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
860 PyErr_Clear();
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
861 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
862
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
863 rc = SQLITE_DENY;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
864 } 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
865 if (PyLong_Check(ret)) {
f324631462a2 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents: 44018
diff changeset
866 rc = (int)PyLong_AsLong(ret);
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
867 } else {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
868 rc = SQLITE_DENY;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
869 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
870 Py_DECREF(ret);
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
871 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
872
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
873 #ifdef WITH_THREAD
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
874 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
875 #endif
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
876 return rc;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
877 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
878
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
879 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
880 {
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
881 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
882 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
883 #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
884 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
885
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
886 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
887 #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
888 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
889
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
890 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
891 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
892 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
893 } 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
894 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
895 }
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
896
51776
d06a3ebf306f Merged revisions 69846 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 51271
diff changeset
897 /* 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
898 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
899 } 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
900 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
901 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
902 }
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
903
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 #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
905 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
906 #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
907 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
908 }
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
909
69120
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
910 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
911 {
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
912 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
913 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
914
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
915 #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
916 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
917
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
918 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
919 #endif
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
920 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
921 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
922 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
923 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
924 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
925 }
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
926
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
927 if (ret) {
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
928 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
929 } else {
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
930 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
931 PyErr_Print();
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
932 } else {
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
933 PyErr_Clear();
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
934 }
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
935 }
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
936
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
937 #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
938 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
939 #endif
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
940 }
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
941
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
942 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
943 {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
944 PyObject* authorizer_cb;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
945
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
946 static char *kwlist[] = { "authorizer_callback", NULL };
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
947 int rc;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
948
59374
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
949 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
950 return NULL;
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
951 }
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
952
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
953 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
954 kwlist, &authorizer_cb)) {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
955 return NULL;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
956 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
957
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
958 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
959
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
960 if (rc != SQLITE_OK) {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
961 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
962 return NULL;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
963 } else {
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
964 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
965 return NULL;
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
966
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
967 Py_INCREF(Py_None);
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
968 return Py_None;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
969 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
970 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
971
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
972 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
973 {
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
974 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
975 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
976
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
977 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
978
59374
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
979 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
980 return NULL;
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
981 }
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
982
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
983 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
984 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
985 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
986 }
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
987
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
988 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
989 /* 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
990 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
991 } 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
992 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
993 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
994 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
995 }
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
996
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
997 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
998 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
999 }
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
1000
69120
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1001 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
1002 {
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1003 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
1004
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1005 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
1006
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1007 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
1008 return NULL;
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1009 }
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1010
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1011 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
1012 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
1013 return NULL;
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1014 }
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1015
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1016 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
1017 /* 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
1018 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
1019 } else {
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1020 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
1021 return NULL;
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1022 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
1023 }
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1024
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1025 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
1026 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
1027 }
575ee55081dc Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents: 68258
diff changeset
1028
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1029 #ifdef HAVE_LOAD_EXTENSION
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1030 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
1031 {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1032 int rc;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1033 int onoff;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1034
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1035 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
1036 return NULL;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1037 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1038
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1039 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
1040 return NULL;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1041 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1042
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1043 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
1044
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1045 if (rc != SQLITE_OK) {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1046 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
1047 return NULL;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1048 } else {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1049 Py_INCREF(Py_None);
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1050 return Py_None;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1051 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1052 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1053
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1054 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
1055 {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1056 int rc;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1057 char* extension_name;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1058 char* errmsg;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1059
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1060 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
1061 return NULL;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1062 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1063
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1064 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
1065 return NULL;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1066 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1067
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1068 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
1069 if (rc != 0) {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1070 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
1071 return NULL;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1072 } else {
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1073 Py_INCREF(Py_None);
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1074 return Py_None;
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1075 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1076 }
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1077 #endif
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1078
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1079 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
1080 {
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
1081 #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
1082 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
1083 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
1084 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
1085 "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
1086 "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
1087 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
1088 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
1089 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1090
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1091 }
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
1092 #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
1093 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
1094 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1095
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1096 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
1097 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1098 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
1099 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
1100 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1101
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1102 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
1103 {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1104 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
1105 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
1106 } else {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1107 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
1108 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1109 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1110
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1111 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
1112 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1113 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
1114 PyObject* begin_statement;
44018
a7c18b924236 #1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents: 43777
diff changeset
1115 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
1116
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1117 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
1118
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1119 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
1120 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
1121 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
1122 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1123
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1124 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
1125 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
1126 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
1127
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1128 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
1129 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
1130 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
1131 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1132 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
1133
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1134 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
1135 } 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
1136 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
1137 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
1138
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1139 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
1140 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
1141
44018
a7c18b924236 #1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents: 43777
diff changeset
1142 if (!begin_word) {
a7c18b924236 #1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents: 43777
diff changeset
1143 begin_word = PyUnicode_FromString("BEGIN ");
a7c18b924236 #1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents: 43777
diff changeset
1144 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
1145 }
44018
a7c18b924236 #1480: fix refleak in the sqlite module.
Georg Brandl <georg@python.org>
parents: 43777
diff changeset
1146 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
1147 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
1148 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
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
48660
85b67fb5672b Rename PyUnicode_AsString -> _PyUnicode_AsString and
Marc-André Lemburg <mal@egenix.com>
parents: 48563
diff changeset
1151 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
1152 if (!statement) {
59852
92f256174154 Merged revisions 78894 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59374
diff changeset
1153 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
1154 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
1155 }
43694
b102b8361d5e Use unicode in more places. Fixes a problem with str8 + str in test.
Neal Norwitz <nnorwitz@gmail.com>
parents: 43490
diff changeset
1156 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
1157 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
1158 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
1159 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
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
43694
b102b8361d5e Use unicode in more places. Fixes a problem with str8 + str in test.
Neal Norwitz <nnorwitz@gmail.com>
parents: 43490
diff changeset
1162 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
1163 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
1164 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1165
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1166 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
1167 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1168
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1169 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
1170 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1171 PyObject* sql;
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1172 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
1173 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
1174 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
1175
59374
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1176 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
1177 return NULL;
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1178 }
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1179
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1180 if (!PyArg_ParseTuple(args, "O", &sql)) {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1181 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
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
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1184 _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
1185
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1186 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
1187 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
1188 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
1189 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1190
59854
c073f3c3276e Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59852
diff changeset
1191 statement->db = NULL;
c073f3c3276e Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59852
diff changeset
1192 statement->st = NULL;
c073f3c3276e Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59852
diff changeset
1193 statement->sql = NULL;
c073f3c3276e Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59852
diff changeset
1194 statement->in_use = 0;
c073f3c3276e Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59852
diff changeset
1195 statement->in_weakreflist = NULL;
c073f3c3276e Merged revisions 78899 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59852
diff changeset
1196
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1197 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
1198
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1199 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
1200 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
1201 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
1202 } 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
1203 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
1204 } 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
1205 (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
1206 _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
1207 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1208
48463
81e34d7e4ba0 Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 47301
diff changeset
1209 Py_CLEAR(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
1210 } else {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1211 weakref = PyWeakref_NewRef((PyObject*)statement, NULL);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1212 if (!weakref) {
48463
81e34d7e4ba0 Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 47301
diff changeset
1213 Py_CLEAR(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
1214 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
1215 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1216
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1217 if (PyList_Append(self->statements, weakref) != 0) {
48463
81e34d7e4ba0 Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 47301
diff changeset
1218 Py_CLEAR(weakref);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1219 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
1220 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1221
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1222 Py_DECREF(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
1223 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1224
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1225 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
1226 return (PyObject*)statement;
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_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
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* 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
1232 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
1233 PyObject* method = 0;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72835
diff changeset
1234 _Py_IDENTIFIER(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
1235
72835
5e33219492bc Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents: 72475
diff changeset
1236 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
1237 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
1238 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
1239 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1240
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1241 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
1242 if (!method) {
48463
81e34d7e4ba0 Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 47301
diff changeset
1243 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
1244 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
1245 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1246
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1247 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
1248 if (!result) {
48463
81e34d7e4ba0 Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 47301
diff changeset
1249 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
1250 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1251
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1252 error:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1253 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
1254 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
1255
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1256 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
1257 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1258
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1259 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
1260 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1261 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
1262 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
1263 PyObject* method = 0;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72835
diff changeset
1264 _Py_IDENTIFIER(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
1265
72835
5e33219492bc Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents: 72475
diff changeset
1266 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
1267 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
1268 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
1269 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1270
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1271 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
1272 if (!method) {
48463
81e34d7e4ba0 Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 47301
diff changeset
1273 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
1274 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
1275 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1276
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1277 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
1278 if (!result) {
48463
81e34d7e4ba0 Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 47301
diff changeset
1279 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
1280 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1281
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1282 error:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1283 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
1284 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
1285
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1286 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
1287 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1288
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1289 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
1290 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1291 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
1292 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
1293 PyObject* method = 0;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72835
diff changeset
1294 _Py_IDENTIFIER(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
1295
72835
5e33219492bc Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents: 72475
diff changeset
1296 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
1297 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
1298 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
1299 }
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 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
1302 if (!method) {
48463
81e34d7e4ba0 Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 47301
diff changeset
1303 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
1304 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
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 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
1308 if (!result) {
48463
81e34d7e4ba0 Forward port r64930.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 47301
diff changeset
1309 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
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
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1312 error:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1313 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
1314 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
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 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
1317 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1318
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1319 /* ------------------------- 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
1320
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1321 static int
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1322 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
1323 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
1324 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
1325 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
1326 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1327 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
1328 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
1329 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
1330 #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
1331 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
1332 #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
1333 PyObject* 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
1334 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
1335 #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
1336 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
1337 #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
1338
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1339 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
1340 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
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
43777
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43694
diff changeset
1343 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
1344 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
1345
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1346 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
1347 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
1348 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1349
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1350 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
1351
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1352 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
1353 /* 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
1354 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
1355 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1356
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
1357 result = PyLong_AsLong(retval);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1358 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
1359 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
1360 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1361
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1362 finally:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1363 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
1364 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
1365 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
1366 #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
1367 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
1368 #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
1369 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
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 static PyObject *
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1373 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
1374 {
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1375 PyObject* retval = NULL;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1376
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1377 if (!pysqlite_check_connection(self)) {
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1378 goto finally;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1379 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1380
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1381 sqlite3_interrupt(self->db);
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1382
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1383 Py_INCREF(Py_None);
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1384 retval = Py_None;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1385
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1386 finally:
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1387 return retval;
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1388 }
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1389
46161
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1390 /* 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
1391 * 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
1392 * 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
1393 */
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1394 static PyObject *
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1395 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
1396 {
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1397 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
1398 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
1399 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
1400 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
1401
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1402 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
1403 goto finally;
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1404 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1405
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1406 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
1407 if (!module) {
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1408 goto finally;
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1409 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1410
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1411 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
1412 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
1413 goto finally;
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1414 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1415
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1416 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
1417 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
1418 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
1419 goto finally;
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1420 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1421
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1422 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
1423 if (!args) {
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1424 goto finally;
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1425 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1426 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
1427 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
1428 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
1429
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1430 finally:
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1431 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
1432 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
1433 return retval;
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1434 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1435
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1436 static PyObject *
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1437 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
1438 {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1439 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
1440 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
1441 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
1442 PyObject* retval;
60847
8c0517f50c4e Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59854
diff changeset
1443 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
1444 _Py_IDENTIFIER(upper);
60847
8c0517f50c4e Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59854
diff changeset
1445 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
1446 int rc;
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1447 unsigned int kind;
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1448 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
1449
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1450 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
1451 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
1452 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1453
42525
e64286053b25 Make the sqlite tests pass.
Gerhard Häring <gh@ghaering.de>
parents: 42334
diff changeset
1454 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
1455 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
1456 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1457
72835
5e33219492bc Add API for static strings, primarily good for identifiers.
Martin v. Löwis <martin@v.loewis.de>
parents: 72475
diff changeset
1458 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
1459 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
1460 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
1461 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1462
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1463 if (PyUnicode_READY(uppercase_name))
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1464 goto finally;
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1465 len = PyUnicode_GET_LENGTH(uppercase_name);
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1466 kind = PyUnicode_KIND(uppercase_name);
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1467 data = PyUnicode_DATA(uppercase_name);
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1468 for (i=0; i<len; i++) {
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1469 Py_UCS4 ch = PyUnicode_READ(kind, data, i);
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1470 if ((ch >= '0' && ch <= '9')
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1471 || (ch >= 'A' && ch <= 'Z')
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70570
diff changeset
1472 || (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
1473 {
60847
8c0517f50c4e Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59854
diff changeset
1474 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
1475 } else {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1476 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
1477 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
1478 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1479 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1480
60847
8c0517f50c4e Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59854
diff changeset
1481 uppercase_name_str = _PyUnicode_AsString(uppercase_name);
8c0517f50c4e Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59854
diff changeset
1482 if (!uppercase_name_str)
8c0517f50c4e Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59854
diff changeset
1483 goto finally;
8c0517f50c4e Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59854
diff changeset
1484
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1485 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
1486 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
1487 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
1488 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1489
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1490 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
1491 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
1492 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
1493 } else {
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1494 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
1495 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
1496 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1497
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1498 rc = sqlite3_create_collation(self->db,
60847
8c0517f50c4e Merged revisions 80349 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59854
diff changeset
1499 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
1500 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
1501 (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
1502 (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
1503 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
1504 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
1505 _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
1506 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
1507 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1508
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1509 finally:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1510 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
1511
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1512 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
1513 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
1514 } else {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1515 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
1516 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
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
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1519 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
1520 }
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1521
46161
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1522 /* 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
1523 * 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
1524 static PyObject *
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1525 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
1526 {
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1527 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
1528 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
1529 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1530
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1531 /** 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
1532 * 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
1533 static PyObject *
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1534 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
1535 {
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1536 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
1537 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
1538 PyObject* result;
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1539
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1540 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
1541 return NULL;
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1542 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1543
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1544 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
1545 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
1546 } else {
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1547 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
1548 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1549
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1550 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
1551 if (!result) {
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1552 return NULL;
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1553 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1554 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
1555
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1556 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
1557 }
848160d10780 Merged revisions 61981,61984-61987,61992-61993,61997-62000 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
1558
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1559 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
1560 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
1561
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1562 static PyGetSetDef connection_getset[] = {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1563 {"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
1564 {"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
1565 {NULL}
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1566 };
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1567
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1568 static PyMethodDef connection_methods[] = {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1569 {"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
1570 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
1571 {"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
1572 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
1573 {"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
1574 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
1575 {"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
1576 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
1577 {"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
1578 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
1579 {"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
1580 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
1581 {"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
1582 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
1583 #ifdef HAVE_LOAD_EXTENSION
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 52870
diff changeset
1584 {"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
1585 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
1586 {"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
1587 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
1588 #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
1589 {"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
1590 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
1591 {"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
1592 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
1593 {"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
1594 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
1595 {"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
1596 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
1597 {"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
1598 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
1599 {"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
1600 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
1601 {"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
1602 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
1603 {"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
1604 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
1605 {"__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
1606 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
1607 {"__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
1608 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
1609 {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
1610 };
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1611
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1612 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
1613 {
42541
d1855d0e4e03 A few sqlite files were still using RO instead of READONLY.
Guido van Rossum <guido@python.org>
parents: 42526
diff changeset
1614 {"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
1615 {"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
1616 {"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
1617 {"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
1618 {"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
1619 {"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
1620 {"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
1621 {"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
1622 {"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
1623 {"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
1624 {"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
1625 {"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
1626 {"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
1627 {NULL}
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
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1630 PyTypeObject pysqlite_ConnectionType = {
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 40643
diff changeset
1631 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
1632 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
1633 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
1634 0, /* tp_itemsize */
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1635 (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
1636 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
1637 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
1638 0, /* tp_setattr */
51271
87fbbf22adf3 Merged revisions 69214 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 49178
diff changeset
1639 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
1640 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
1641 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
1642 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
1643 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
1644 0, /* tp_hash */
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1645 (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
1646 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
1647 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
1648 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
1649 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
1650 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
1651 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
1652 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
1653 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
1654 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
1655 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
1656 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
1657 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
1658 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
1659 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
1660 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
1661 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
1662 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
1663 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
1664 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
1665 0, /* tp_dictoffset */
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1666 (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
1667 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
1668 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
1669 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
1670 };
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1671
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1672 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
1673 {
40643
47f9efdc0855 Merged revisions 53304-53433,53435-53450 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
1674 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
1675 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
1676 }