Mercurial > p > mysql-python > mysqldb-2
annotate src/results.c @ 85:c16ae20b964d default tip
Add a README, with a map to the known repositories...
author | Andy Dustman <adustman@uga.edu> |
---|---|
date | Mon, 24 Sep 2012 15:39:03 -0400 |
parents | 3b03cb566032 |
children |
rev | line source |
---|---|
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
1 /* -*- mode: C; indent-tabs-mode: t; c-basic-offset: 8; -*- */ |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
2 |
55
e606fd52e866
make things a little cleaner by moving to a src directory for the C code
kylev
parents:
53
diff
changeset
|
3 #include "mysqlmod.h" |
0 | 4 |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
5 static PyObject * |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
6 _mysql_ResultObject_get_fields( |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
7 _mysql_ResultObject *self, |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
8 PyObject *unused) |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
9 { |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
10 PyObject *arglist=NULL, *kwarglist=NULL; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
11 PyObject *fields=NULL; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
12 _mysql_FieldObject *field=NULL; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
13 unsigned int i, n; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
14 |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
15 check_result_connection(self); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
16 kwarglist = PyDict_New(); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
17 if (!kwarglist) goto error; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
18 n = mysql_num_fields(self->result); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
19 if (!(fields = PyTuple_New(n))) return NULL; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
20 for (i=0; i<n; i++) { |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
21 arglist = Py_BuildValue("(Oi)", self, i); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
22 if (!arglist) goto error; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
23 field = MyAlloc(_mysql_FieldObject, _mysql_FieldObject_Type); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
24 if (!field) goto error; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
25 if (_mysql_FieldObject_Initialize(field, arglist, kwarglist)) |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
26 goto error; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
27 Py_DECREF(arglist); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
28 PyTuple_SET_ITEM(fields, i, (PyObject *) field); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
29 } |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
30 Py_DECREF(kwarglist); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
31 return fields; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
32 error: |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
33 Py_XDECREF(arglist); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
34 Py_XDECREF(kwarglist); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
35 Py_XDECREF(fields); |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
36 return NULL; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
37 } |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
38 |
0 | 39 static char _mysql_ResultObject__doc__[] = |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
40 "result(connection, use=0) -- Result set from a query.\n\ |
0 | 41 \n\ |
42 Creating instances of this class directly is an excellent way to\n\ | |
43 shoot yourself in the foot. If using _mysql.connection directly,\n\ | |
44 use connection.store_result() or connection.use_result() instead.\n\ | |
45 If using MySQLdb.Connection, this is done by the cursor class.\n\ | |
46 Just forget you ever saw this. Forget... FOR-GET..."; | |
47 | |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
48 int |
0 | 49 _mysql_ResultObject_Initialize( |
50 _mysql_ResultObject *self, | |
51 PyObject *args, | |
52 PyObject *kwargs) | |
53 { | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
54 static char *kwlist[] = {"connection", "use", NULL}; |
45 | 55 MYSQL_RES *result; |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
56 _mysql_ConnectionObject *conn = NULL; |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
57 int use = 0; |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
58 int n; |
0 | 59 |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
60 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i", kwlist, |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
61 &conn, &use)) |
0 | 62 return -1; |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
63 |
0 | 64 self->conn = (PyObject *) conn; |
65 Py_INCREF(conn); | |
66 self->use = use; | |
67 Py_BEGIN_ALLOW_THREADS ; | |
68 if (use) | |
69 result = mysql_use_result(&(conn->connection)); | |
70 else | |
71 result = mysql_store_result(&(conn->connection)); | |
72 self->result = result; | |
73 Py_END_ALLOW_THREADS ; | |
74 if (!result) { | |
75 return 0; | |
76 } | |
77 n = mysql_num_fields(result); | |
78 self->nfields = n; | |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
79 self->fields = _mysql_ResultObject_get_fields(self, NULL); |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
80 |
0 | 81 return 0; |
82 } | |
83 | |
45 | 84 static int |
85 _mysql_ResultObject_traverse( | |
0 | 86 _mysql_ResultObject *self, |
87 visitproc visit, | |
88 void *arg) | |
89 { | |
90 int r; | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
91 if (self->fields) { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
92 if (!(r = visit(self->fields, arg))) return r; |
0 | 93 } |
94 if (self->conn) | |
95 return visit(self->conn, arg); | |
96 return 0; | |
97 } | |
98 | |
99 static char _mysql_ResultObject_describe__doc__[] = | |
100 "Returns the sequence of 7-tuples required by the DB-API for\n\ | |
101 the Cursor.description attribute.\n\ | |
102 "; | |
103 | |
104 static PyObject * | |
105 _mysql_ResultObject_describe( | |
106 _mysql_ResultObject *self, | |
26 | 107 PyObject *unused) |
0 | 108 { |
109 PyObject *d; | |
110 MYSQL_FIELD *fields; | |
111 unsigned int i, n; | |
26 | 112 |
0 | 113 check_result_connection(self); |
114 n = mysql_num_fields(self->result); | |
115 fields = mysql_fetch_fields(self->result); | |
116 if (!(d = PyTuple_New(n))) return NULL; | |
117 for (i=0; i<n; i++) { | |
118 PyObject *t; | |
119 t = Py_BuildValue("(siiiiii)", | |
120 fields[i].name, | |
121 (long) fields[i].type, | |
122 (long) fields[i].max_length, | |
123 (long) fields[i].length, | |
124 (long) fields[i].length, | |
125 (long) fields[i].decimals, | |
126 (long) !(IS_NOT_NULL(fields[i].flags))); | |
127 if (!t) goto error; | |
128 PyTuple_SET_ITEM(d, i, t); | |
129 } | |
130 return d; | |
131 error: | |
132 Py_XDECREF(d); | |
133 return NULL; | |
134 } | |
18
d55bfb1a4701
Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents:
2
diff
changeset
|
135 |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
136 static char _mysql_ResultObject_fetch_row__doc__[] = |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
137 "fetchrow()\n\ |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
138 Fetches one row as a tuple of strings.\n\ |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
139 NULL is returned as None.\n\ |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
140 A single None indicates the end of the result set.\n\ |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
141 "; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
142 |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
143 static PyObject * |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
144 _mysql_ResultObject_fetch_row( |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
145 _mysql_ResultObject *self, |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
146 PyObject *unused) |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
147 { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
148 unsigned int n, i; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
149 unsigned long *length; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
150 PyObject *r=NULL; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
151 MYSQL_ROW row; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
152 |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
153 check_result_connection(self); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
154 |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
155 if (!self->use) |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
156 row = mysql_fetch_row(self->result); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
157 else { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
158 Py_BEGIN_ALLOW_THREADS; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
159 row = mysql_fetch_row(self->result); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
160 Py_END_ALLOW_THREADS; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
161 } |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
162 if (!row && mysql_errno(&(((_mysql_ConnectionObject *)(self->conn))->connection))) { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
163 _mysql_Exception((_mysql_ConnectionObject *)self->conn); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
164 goto error; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
165 } |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
166 if (!row) { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
167 Py_INCREF(Py_None); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
168 return Py_None; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
169 } |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
170 |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
171 n = mysql_num_fields(self->result); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
172 if (!(r = PyTuple_New(n))) return NULL; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
173 length = mysql_fetch_lengths(self->result); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
174 for (i=0; i<n; i++) { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
175 PyObject *v; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
176 if (row[i]) { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
177 v = PyString_FromStringAndSize(row[i], length[i]); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
178 if (!v) goto error; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
179 } else /* NULL */ { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
180 v = Py_None; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
181 Py_INCREF(v); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
182 } |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
183 PyTuple_SET_ITEM(r, i, v); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
184 } |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
185 return r; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
186 error: |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
187 Py_XDECREF(r); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
188 return NULL; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
189 } |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
190 |
0 | 191 static char _mysql_ResultObject_field_flags__doc__[] = |
192 "Returns a tuple of field flags, one for each column in the result.\n\ | |
193 " ; | |
194 | |
195 static PyObject * | |
196 _mysql_ResultObject_field_flags( | |
197 _mysql_ResultObject *self, | |
26 | 198 PyObject *unused) |
0 | 199 { |
200 PyObject *d; | |
201 MYSQL_FIELD *fields; | |
202 unsigned int i, n; | |
26 | 203 |
0 | 204 check_result_connection(self); |
205 n = mysql_num_fields(self->result); | |
206 fields = mysql_fetch_fields(self->result); | |
207 if (!(d = PyTuple_New(n))) return NULL; | |
208 for (i=0; i<n; i++) { | |
209 PyObject *f; | |
210 if (!(f = PyInt_FromLong((long)fields[i].flags))) goto error; | |
211 PyTuple_SET_ITEM(d, i, f); | |
212 } | |
213 return d; | |
214 error: | |
215 Py_XDECREF(d); | |
216 return NULL; | |
217 } | |
218 | |
219 typedef PyObject *_PYFUNC(_mysql_ResultObject *, MYSQL_ROW); | |
220 | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
221 static char _mysql_ResultObject_clear__doc__[] = |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
222 "clear()\n\ |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
223 Reads to the end of the result set, discarding all the rows.\n\ |
0 | 224 "; |
225 | |
226 static PyObject * | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
227 _mysql_ResultObject_clear( |
73
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
228 _mysql_ResultObject *self, |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
229 PyObject *unused) |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
230 { |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
231 if (self->result) { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
232 if (self->use) { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
233 Py_BEGIN_ALLOW_THREADS; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
234 while (mysql_fetch_row(self->result)); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
235 Py_END_ALLOW_THREADS; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
236 |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
237 if (mysql_errno(&(((_mysql_ConnectionObject *)(self->conn))->connection))) { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
238 _mysql_Exception((_mysql_ConnectionObject *)self->conn); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
239 return NULL; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
240 } |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
241 } |
73
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
242 } |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
243 Py_XDECREF(self->fields); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
244 self->fields = NULL; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
245 Py_XDECREF(self->conn); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
246 self->conn = NULL; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
247 if (self->result) { |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
248 mysql_free_result(self->result); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
249 self->result = NULL; |
73
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
250 } |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
251 Py_INCREF(Py_None); |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
252 return Py_None; |
73
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
253 } |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
254 |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
255 static PyObject * |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
256 _mysql_ResultObject__iter__( |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
257 _mysql_ResultObject *self, |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
258 PyObject *unused) |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
259 { |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
260 check_result_connection(self); |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
261 Py_INCREF(self); |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
262 return (PyObject *)self; |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
263 } |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
264 |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
265 static PyObject * |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
266 _mysql_ResultObject_next( |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
267 _mysql_ResultObject *self, |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
268 PyObject *unused) |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
269 { |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
270 PyObject *row; |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
271 check_result_connection(self); |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
272 row = _mysql_ResultObject_fetch_row(self, NULL); |
73
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
273 if (row == Py_None) { |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
274 Py_DECREF(row); |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
275 PyErr_SetString(PyExc_StopIteration, ""); |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
276 return NULL; |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
277 } |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
278 return row; |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
279 } |
0 | 280 |
281 static char _mysql_ResultObject_num_fields__doc__[] = | |
282 "Returns the number of fields (column) in the result." ; | |
283 | |
284 static PyObject * | |
285 _mysql_ResultObject_num_fields( | |
286 _mysql_ResultObject *self, | |
26 | 287 PyObject *unused) |
0 | 288 { |
289 check_result_connection(self); | |
290 return PyInt_FromLong((long)mysql_num_fields(self->result)); | |
26 | 291 } |
0 | 292 |
293 static char _mysql_ResultObject_num_rows__doc__[] = | |
294 "Returns the number of rows in the result set. Note that if\n\ | |
295 use=1, this will not return a valid value until the entire result\n\ | |
296 set has been read.\n\ | |
297 "; | |
298 | |
299 static PyObject * | |
300 _mysql_ResultObject_num_rows( | |
301 _mysql_ResultObject *self, | |
26 | 302 PyObject *unused) |
0 | 303 { |
304 check_result_connection(self); | |
305 return PyLong_FromUnsignedLongLong(mysql_num_rows(self->result)); | |
26 | 306 } |
0 | 307 |
308 | |
309 static char _mysql_ResultObject_data_seek__doc__[] = | |
310 "data_seek(n) -- seek to row n of result set"; | |
311 static PyObject * | |
312 _mysql_ResultObject_data_seek( | |
313 _mysql_ResultObject *self, | |
314 PyObject *args) | |
315 { | |
316 unsigned int row; | |
317 if (!PyArg_ParseTuple(args, "i:data_seek", &row)) return NULL; | |
318 check_result_connection(self); | |
319 mysql_data_seek(self->result, row); | |
320 Py_INCREF(Py_None); | |
321 return Py_None; | |
322 } | |
323 | |
324 static char _mysql_ResultObject_row_seek__doc__[] = | |
325 "row_seek(n) -- seek by offset n rows of result set"; | |
326 static PyObject * | |
327 _mysql_ResultObject_row_seek( | |
328 _mysql_ResultObject *self, | |
329 PyObject *args) | |
330 { | |
331 int offset; | |
332 MYSQL_ROW_OFFSET r; | |
333 if (!PyArg_ParseTuple(args, "i:row_seek", &offset)) return NULL; | |
334 check_result_connection(self); | |
335 if (self->use) { | |
336 PyErr_SetString(_mysql_ProgrammingError, | |
337 "cannot be used with connection.use_result()"); | |
338 return NULL; | |
339 } | |
340 r = mysql_row_tell(self->result); | |
341 mysql_row_seek(self->result, r+offset); | |
342 Py_INCREF(Py_None); | |
343 return Py_None; | |
344 } | |
345 | |
346 static char _mysql_ResultObject_row_tell__doc__[] = | |
347 "row_tell() -- return the current row number of the result set."; | |
348 static PyObject * | |
349 _mysql_ResultObject_row_tell( | |
350 _mysql_ResultObject *self, | |
26 | 351 PyObject *unused) |
0 | 352 { |
353 MYSQL_ROW_OFFSET r; | |
26 | 354 |
0 | 355 check_result_connection(self); |
356 if (self->use) { | |
357 PyErr_SetString(_mysql_ProgrammingError, | |
358 "cannot be used with connection.use_result()"); | |
359 return NULL; | |
360 } | |
361 r = mysql_row_tell(self->result); | |
362 return PyInt_FromLong(r-self->result->data->data); | |
363 } | |
364 | |
365 static void | |
366 _mysql_ResultObject_dealloc( | |
367 _mysql_ResultObject *self) | |
368 { | |
369 PyObject_GC_UnTrack((PyObject *)self); | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
370 _mysql_ResultObject_clear(self, NULL); |
0 | 371 mysql_free_result(self->result); |
372 MyFree(self); | |
373 } | |
374 | |
375 static PyObject * | |
376 _mysql_ResultObject_repr( | |
377 _mysql_ResultObject *self) | |
378 { | |
379 char buf[300]; | |
380 sprintf(buf, "<_mysql.result object at %lx>", | |
381 (long)self); | |
382 return PyString_FromString(buf); | |
383 } | |
384 | |
385 static PyMethodDef _mysql_ResultObject_methods[] = { | |
386 { | |
387 "data_seek", | |
388 (PyCFunction)_mysql_ResultObject_data_seek, | |
389 METH_VARARGS, | |
390 _mysql_ResultObject_data_seek__doc__ | |
391 }, | |
392 { | |
393 "row_seek", | |
394 (PyCFunction)_mysql_ResultObject_row_seek, | |
395 METH_VARARGS, | |
396 _mysql_ResultObject_row_seek__doc__ | |
397 }, | |
398 { | |
399 "row_tell", | |
400 (PyCFunction)_mysql_ResultObject_row_tell, | |
26 | 401 METH_NOARGS, |
0 | 402 _mysql_ResultObject_row_tell__doc__ |
403 }, | |
404 { | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
405 "clear", |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
406 (PyCFunction)_mysql_ResultObject_clear, |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
407 METH_NOARGS, |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
408 _mysql_ResultObject_clear__doc__ |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
409 }, |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
73
diff
changeset
|
410 { |
0 | 411 "describe", |
412 (PyCFunction)_mysql_ResultObject_describe, | |
26 | 413 METH_NOARGS, |
0 | 414 _mysql_ResultObject_describe__doc__ |
415 }, | |
416 { | |
417 "fetch_row", | |
418 (PyCFunction)_mysql_ResultObject_fetch_row, | |
419 METH_VARARGS | METH_KEYWORDS, | |
420 _mysql_ResultObject_fetch_row__doc__ | |
421 }, | |
73
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
422 |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
423 { |
0 | 424 "field_flags", |
425 (PyCFunction)_mysql_ResultObject_field_flags, | |
26 | 426 METH_NOARGS, |
0 | 427 _mysql_ResultObject_field_flags__doc__ |
428 }, | |
429 { | |
430 "num_fields", | |
431 (PyCFunction)_mysql_ResultObject_num_fields, | |
26 | 432 METH_NOARGS, |
0 | 433 _mysql_ResultObject_num_fields__doc__ |
434 }, | |
435 { | |
436 "num_rows", | |
437 (PyCFunction)_mysql_ResultObject_num_rows, | |
26 | 438 METH_NOARGS, |
0 | 439 _mysql_ResultObject_num_rows__doc__ |
440 }, | |
441 {NULL, NULL} /* sentinel */ | |
442 }; | |
443 | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
444 static struct PyMemberDef _mysql_ResultObject_memberlist[] = { |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
445 { |
66
5a7c30cd9de2
By exposing connection on result, decoders can be simplified: Only the field object is needed. Turned on leak testing and found a leak writing BLOBs. removed one of the old stubs in Cursor.
adustman
parents:
55
diff
changeset
|
446 "connection", |
5a7c30cd9de2
By exposing connection on result, decoders can be simplified: Only the field object is needed. Turned on leak testing and found a leak writing BLOBs. removed one of the old stubs in Cursor.
adustman
parents:
55
diff
changeset
|
447 T_OBJECT, |
5a7c30cd9de2
By exposing connection on result, decoders can be simplified: Only the field object is needed. Turned on leak testing and found a leak writing BLOBs. removed one of the old stubs in Cursor.
adustman
parents:
55
diff
changeset
|
448 offsetof(_mysql_ConnectionObject, connection), |
5a7c30cd9de2
By exposing connection on result, decoders can be simplified: Only the field object is needed. Turned on leak testing and found a leak writing BLOBs. removed one of the old stubs in Cursor.
adustman
parents:
55
diff
changeset
|
449 RO, |
5a7c30cd9de2
By exposing connection on result, decoders can be simplified: Only the field object is needed. Turned on leak testing and found a leak writing BLOBs. removed one of the old stubs in Cursor.
adustman
parents:
55
diff
changeset
|
450 "Connection associated with result" |
5a7c30cd9de2
By exposing connection on result, decoders can be simplified: Only the field object is needed. Turned on leak testing and found a leak writing BLOBs. removed one of the old stubs in Cursor.
adustman
parents:
55
diff
changeset
|
451 }, |
5a7c30cd9de2
By exposing connection on result, decoders can be simplified: Only the field object is needed. Turned on leak testing and found a leak writing BLOBs. removed one of the old stubs in Cursor.
adustman
parents:
55
diff
changeset
|
452 { |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
453 "fields", |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
454 T_OBJECT, |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
455 offsetof(_mysql_ResultObject, fields), |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
456 RO, |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
66
diff
changeset
|
457 "Field metadata for result set" |
73
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
458 }, |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
459 { |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
460 "use", |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
461 T_INT, |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
462 offsetof(_mysql_ResultObject, use), |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
463 RO, |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
464 "True if mysql_use_result() was used; False if mysql_store_result() was used" |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
465 }, |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
466 {NULL} /* Sentinel */ |
0 | 467 }; |
468 | |
469 static PyObject * | |
470 _mysql_ResultObject_getattr( | |
471 _mysql_ResultObject *self, | |
472 char *name) | |
473 { | |
474 PyObject *res; | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
475 struct PyMemberDef *l; |
0 | 476 |
477 res = Py_FindMethod(_mysql_ResultObject_methods, (PyObject *)self, name); | |
478 if (res != NULL) | |
479 return res; | |
480 PyErr_Clear(); | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
481 |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
482 for (l = _mysql_ResultObject_memberlist; l->name != NULL; l++) { |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
483 if (strcmp(l->name, name) == 0) |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
484 return PyMember_GetOne((char *)self, l); |
0 | 485 } |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
486 |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
487 PyErr_SetString(PyExc_AttributeError, name); |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
488 return NULL; |
0 | 489 } |
490 | |
491 static int | |
492 _mysql_ResultObject_setattr( | |
493 _mysql_ResultObject *self, | |
494 char *name, | |
495 PyObject *v) | |
496 { | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
497 struct PyMemberDef *l; |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
498 |
0 | 499 if (v == NULL) { |
500 PyErr_SetString(PyExc_AttributeError, | |
501 "can't delete connection attributes"); | |
502 return -1; | |
503 } | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
504 |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
505 for (l = _mysql_ResultObject_memberlist; l->name != NULL; l++) |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
506 if (strcmp(l->name, name) == 0) |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
507 return PyMember_SetOne((char *)self, l, v); |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
508 |
0 | 509 PyErr_SetString(PyExc_AttributeError, name); |
510 return -1; | |
511 } | |
512 | |
513 PyTypeObject _mysql_ResultObject_Type = { | |
514 PyObject_HEAD_INIT(NULL) | |
515 0, | |
516 "_mysql.result", | |
517 sizeof(_mysql_ResultObject), | |
518 0, | |
519 (destructor)_mysql_ResultObject_dealloc, /* tp_dealloc */ | |
520 0, /*tp_print*/ | |
521 (getattrfunc)_mysql_ResultObject_getattr, /* tp_getattr */ | |
522 (setattrfunc)_mysql_ResultObject_setattr, /* tp_setattr */ | |
523 0, /*tp_compare*/ | |
524 (reprfunc)_mysql_ResultObject_repr, /* tp_repr */ | |
45 | 525 |
0 | 526 /* Method suites for standard classes */ |
45 | 527 |
0 | 528 0, /* (PyNumberMethods *) tp_as_number */ |
529 0, /* (PySequenceMethods *) tp_as_sequence */ | |
530 0, /* (PyMappingMethods *) tp_as_mapping */ | |
45 | 531 |
0 | 532 /* More standard operations (here for binary compatibility) */ |
45 | 533 |
0 | 534 0, /* (hashfunc) tp_hash */ |
535 0, /* (ternaryfunc) tp_call */ | |
536 0, /* (reprfunc) tp_str */ | |
537 0, /* (getattrofunc) tp_getattro */ | |
538 0, /* (setattrofunc) tp_setattro */ | |
45 | 539 |
0 | 540 /* Functions to access object as input/output buffer */ |
541 0, /* (PyBufferProcs *) tp_as_buffer */ | |
45 | 542 |
0 | 543 /* Flags to define presence of optional/expanded features */ |
45 | 544 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* (long) tp_flags */ |
545 | |
0 | 546 _mysql_ResultObject__doc__, /* (char *) tp_doc Documentation string */ |
547 /* call function for all accessible objects */ | |
45 | 548 (traverseproc)_mysql_ResultObject_traverse, /* tp_traverse */ |
0 | 549 /* delete references to contained objects */ |
45 | 550 (inquiry)_mysql_ResultObject_clear, /* tp_clear */ |
551 | |
0 | 552 /* rich comparisons */ |
553 0, /* (richcmpfunc) tp_richcompare */ | |
45 | 554 |
0 | 555 /* weak reference enabler */ |
556 0, /* (long) tp_weaklistoffset */ | |
45 | 557 |
0 | 558 /* Iterators */ |
73
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
559 (getiterfunc) _mysql_ResultObject__iter__, /* (getiterfunc) tp_iter */ |
24fa6a40c706
Added a simple_fetch_row() to the result object that simply returns one row
adustman
parents:
67
diff
changeset
|
560 (iternextfunc) _mysql_ResultObject_next, /* (iternextfunc) tp_iternext */ |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
561 |
0 | 562 /* Attribute descriptor and subclassing stuff */ |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
563 (struct PyMethodDef *)_mysql_ResultObject_methods, /* tp_methods */ |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
564 (struct PyMemberDef *)_mysql_ResultObject_memberlist, /*tp_members */ |
0 | 565 0, /* (struct getsetlist *) tp_getset; */ |
566 0, /* (struct _typeobject *) tp_base; */ | |
567 0, /* (PyObject *) tp_dict */ | |
568 0, /* (descrgetfunc) tp_descr_get */ | |
569 0, /* (descrsetfunc) tp_descr_set */ | |
570 0, /* (long) tp_dictoffset */ | |
571 (initproc)_mysql_ResultObject_Initialize, /* tp_init */ | |
572 NULL, /* tp_alloc */ | |
573 NULL, /* tp_new */ | |
574 NULL, /* tp_free Low-level free-memory routine */ | |
575 0, /* (PyObject *) tp_bases */ | |
576 0, /* (PyObject *) tp_mro method resolution order */ | |
577 0, /* (PyObject *) tp_defined */ | |
578 }; |