annotate Modules/_sqlite/connection.h @ 58765:2ba7677bfa95 legacy-trunk

testCopysign was defined twice in test_math; combine the definitions
author Mark Dickinson <dickinsm@gmail.com>
date Sat, 06 Feb 2010 23:11:25 +0000
parents 52294af4b663
children 04d3ae52ff73
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
1 /* connection.h - definitions for the connection type
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
2 *
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 40625
diff changeset
3 * Copyright (C) 2004-2007 Gerhard Häring <gh@ghaering.de>
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
4 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
5 * This file is part of pysqlite.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
6 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
7 * This software is provided 'as-is', without any express or implied
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
8 * warranty. In no event will the authors be held liable for any damages
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
9 * arising from the use of this software.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
10 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
11 * Permission is granted to anyone to use this software for any purpose,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
12 * including commercial applications, and to alter it and redistribute it
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
13 * freely, subject to the following restrictions:
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
14 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
15 * 1. The origin of this software must not be misrepresented; you must not
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
16 * claim that you wrote the original software. If you use this software
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
17 * in a product, an acknowledgment in the product documentation would be
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
18 * appreciated but is not required.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
19 * 2. Altered source versions must be plainly marked as such, and must not be
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
20 * misrepresented as being the original software.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
21 * 3. This notice may not be removed or altered from any source distribution.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
22 */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
23
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
24 #ifndef PYSQLITE_CONNECTION_H
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
25 #define PYSQLITE_CONNECTION_H
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
26 #include "Python.h"
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
27 #include "pythread.h"
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
28 #include "structmember.h"
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
29
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
30 #include "cache.h"
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
31 #include "module.h"
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
32
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
33 #include "sqlite3.h"
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
34
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
35 typedef struct
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
36 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
37 PyObject_HEAD
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
38 sqlite3* db;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
39
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
40 /* 1 if we are currently within a transaction, i. e. if a BEGIN has been
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
41 * issued */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
42 int inTransaction;
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
43
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
44 /* the type detection mode. Only 0, PARSE_DECLTYPES, PARSE_COLNAMES or a
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
45 * bitwise combination thereof makes sense */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
46 int detect_types;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
47
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
48 /* the timeout value in seconds for database locks */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
49 double timeout;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
50
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
51 /* for internal use in the timeout handler: when did the timeout handler
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
52 * first get called with count=0? */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
53 double timeout_started;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
54
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
55 /* None for autocommit, otherwise a PyString with the isolation level */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
56 PyObject* isolation_level;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
57
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
58 /* NULL for autocommit, otherwise a string with the BEGIN statment; will be
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
59 * freed in connection destructor */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
60 char* begin_statement;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
61
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
62 /* 1 if a check should be performed for each API call if the connection is
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
63 * used from the same thread it was created in */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
64 int check_same_thread;
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
65
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
66 /* thread identification of the thread the connection was created in */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
67 long thread_ident;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
68
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
69 pysqlite_Cache* statement_cache;
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
70
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
71 /* A list of weak references to statements used within this connection */
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
72 PyObject* statements;
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
73
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
74 /* a counter for how many statements were created in the connection. May be
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
75 * reset to 0 at certain intervals */
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
76 int created_statements;
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
77
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
78 PyObject* row_factory;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
79
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
80 /* Determines how bytestrings from SQLite are converted to Python objects:
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
81 * - PyUnicode_Type: Python Unicode objects are constructed from UTF-8 bytestrings
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
82 * - OptimizedUnicode: Like before, but for ASCII data, only PyStrings are created.
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
83 * - PyString_Type: PyStrings are created as-is.
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
84 * - Any custom callable: Any object returned from the callable called with the bytestring
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
85 * as single parameter.
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37458
diff changeset
86 */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
87 PyObject* text_factory;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
88
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
89 /* remember references to functions/classes used in
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
90 * create_function/create/aggregate, use these as dictionary keys, so we
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
91 * can keep the total system refcount constant by clearing that dictionary
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
92 * in connection_dealloc */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
93 PyObject* function_pinboard;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
94
37458
d27058c409df Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
95 /* a dictionary of registered collation name => collation callable mappings */
d27058c409df Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
96 PyObject* collations;
d27058c409df Update to pysqlite 2.2.0
Anthony Baxter <anthonybaxter@gmail.com>
parents: 37362
diff changeset
97
45580
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 40625
diff changeset
98 /* if our connection was created from a APSW connection, we keep a
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 40625
diff changeset
99 * reference to the APSW connection around and get rid of it in our
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 40625
diff changeset
100 * destructor */
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 40625
diff changeset
101 PyObject* apsw_connection;
b7ee9074ca0e Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents: 40625
diff changeset
102
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
103 /* Exception objects */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
104 PyObject* Warning;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
105 PyObject* Error;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
106 PyObject* InterfaceError;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
107 PyObject* DatabaseError;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
108 PyObject* DataError;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
109 PyObject* OperationalError;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
110 PyObject* IntegrityError;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
111 PyObject* InternalError;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
112 PyObject* ProgrammingError;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
113 PyObject* NotSupportedError;
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
114 } pysqlite_Connection;
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
115
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
116 extern PyTypeObject pysqlite_ConnectionType;
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
117
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
118 PyObject* pysqlite_connection_alloc(PyTypeObject* type, int aware);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
119 void pysqlite_connection_dealloc(pysqlite_Connection* self);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
120 PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
121 PyObject* pysqlite_connection_close(pysqlite_Connection* self, PyObject* args);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
122 PyObject* _pysqlite_connection_begin(pysqlite_Connection* self);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
123 PyObject* pysqlite_connection_commit(pysqlite_Connection* self, PyObject* args);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
124 PyObject* pysqlite_connection_rollback(pysqlite_Connection* self, PyObject* args);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
125 PyObject* pysqlite_connection_new(PyTypeObject* type, PyObject* args, PyObject* kw);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
126 int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject* kwargs);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
127
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
128 int pysqlite_check_thread(pysqlite_Connection* self);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
129 int pysqlite_check_connection(pysqlite_Connection* con);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
130
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
131 int pysqlite_connection_setup_types(void);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
132
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
133 #endif