Mercurial > p > mysql-python > mysqldb-2
annotate src/results.c @ 72:c0c00294239b MySQLdb
Check in some old changes
author | adustman |
---|---|
date | Thu, 18 Feb 2010 23:47:51 +0000 |
parents | 98d968f5af11 |
children | 24fa6a40c706 |
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__[] = |
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
|
40 "result(connection, use=0, decoder_stack=[]) -- 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 { | |
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
|
54 static char *kwlist[] = {"connection", "use", "decoder_stack", 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; |
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
|
58 PyObject *decoder_stack = 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
|
59 int n, ns, i, j; |
0 | 60 |
61 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|iO", kwlist, | |
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
|
62 &conn, &use, &decoder_stack)) |
0 | 63 return -1; |
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
|
64 if (!decoder_stack) decoder_stack = PyList_New(0); |
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
|
65 if (!decoder_stack) return -1; |
0 | 66 self->conn = (PyObject *) conn; |
67 Py_INCREF(conn); | |
68 self->use = use; | |
69 Py_BEGIN_ALLOW_THREADS ; | |
70 if (use) | |
71 result = mysql_use_result(&(conn->connection)); | |
72 else | |
73 result = mysql_store_result(&(conn->connection)); | |
74 self->result = result; | |
75 Py_END_ALLOW_THREADS ; | |
76 if (!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
|
77 self->decoders = PyTuple_New(0); |
0 | 78 return 0; |
79 } | |
80 n = mysql_num_fields(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
|
81 ns = PySequence_Length(decoder_stack); |
0 | 82 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
|
83 if (!(self->decoders = PyTuple_New(n))) return -1; |
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
|
84 self->fields = _mysql_ResultObject_get_fields(self, NULL); |
0 | 85 for (i=0; i<n; i++) { |
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
|
86 PyObject *field = PyTuple_GET_ITEM(self->fields, 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
|
87 for (j=0; j<ns; j++) { |
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
|
88 PyObject *df = PySequence_GetItem(decoder_stack, j); |
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
|
89 if (!df) 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
|
90 PyObject *f = PyObject_CallFunctionObjArgs(df, 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
|
91 Py_DECREF(df); |
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
|
92 if (!f) 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
|
93 if (f != Py_None) { |
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
|
94 PyTuple_SET_ITEM(self->decoders, i, f); |
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
|
95 break; |
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
|
96 } |
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
|
97 Py_DECREF(f); |
0 | 98 } |
99 } | |
100 return 0; | |
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
|
101 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
|
102 return -1; |
0 | 103 } |
104 | |
45 | 105 static int |
106 _mysql_ResultObject_traverse( | |
0 | 107 _mysql_ResultObject *self, |
108 visitproc visit, | |
109 void *arg) | |
110 { | |
111 int r; | |
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
|
112 if (self->decoders) { |
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
|
113 if (!(r = visit(self->decoders, arg))) return r; |
0 | 114 } |
115 if (self->conn) | |
116 return visit(self->conn, arg); | |
117 return 0; | |
118 } | |
119 | |
45 | 120 static int |
121 _mysql_ResultObject_clear( | |
0 | 122 _mysql_ResultObject *self) |
123 { | |
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
|
124 Py_XDECREF(self->decoders); |
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
|
125 self->decoders = NULL; |
0 | 126 Py_XDECREF(self->conn); |
127 self->conn = NULL; | |
128 return 0; | |
129 } | |
26 | 130 |
0 | 131 static char _mysql_ResultObject_describe__doc__[] = |
132 "Returns the sequence of 7-tuples required by the DB-API for\n\ | |
133 the Cursor.description attribute.\n\ | |
134 "; | |
135 | |
136 static PyObject * | |
137 _mysql_ResultObject_describe( | |
138 _mysql_ResultObject *self, | |
26 | 139 PyObject *unused) |
0 | 140 { |
141 PyObject *d; | |
142 MYSQL_FIELD *fields; | |
143 unsigned int i, n; | |
26 | 144 |
0 | 145 check_result_connection(self); |
146 n = mysql_num_fields(self->result); | |
147 fields = mysql_fetch_fields(self->result); | |
148 if (!(d = PyTuple_New(n))) return NULL; | |
149 for (i=0; i<n; i++) { | |
150 PyObject *t; | |
151 t = Py_BuildValue("(siiiiii)", | |
152 fields[i].name, | |
153 (long) fields[i].type, | |
154 (long) fields[i].max_length, | |
155 (long) fields[i].length, | |
156 (long) fields[i].length, | |
157 (long) fields[i].decimals, | |
158 (long) !(IS_NOT_NULL(fields[i].flags))); | |
159 if (!t) goto error; | |
160 PyTuple_SET_ITEM(d, i, t); | |
161 } | |
162 return d; | |
163 error: | |
164 Py_XDECREF(d); | |
165 return NULL; | |
166 } | |
18
d55bfb1a4701
Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents:
2
diff
changeset
|
167 |
0 | 168 static char _mysql_ResultObject_field_flags__doc__[] = |
169 "Returns a tuple of field flags, one for each column in the result.\n\ | |
170 " ; | |
171 | |
172 static PyObject * | |
173 _mysql_ResultObject_field_flags( | |
174 _mysql_ResultObject *self, | |
26 | 175 PyObject *unused) |
0 | 176 { |
177 PyObject *d; | |
178 MYSQL_FIELD *fields; | |
179 unsigned int i, n; | |
26 | 180 |
0 | 181 check_result_connection(self); |
182 n = mysql_num_fields(self->result); | |
183 fields = mysql_fetch_fields(self->result); | |
184 if (!(d = PyTuple_New(n))) return NULL; | |
185 for (i=0; i<n; i++) { | |
186 PyObject *f; | |
187 if (!(f = PyInt_FromLong((long)fields[i].flags))) goto error; | |
188 PyTuple_SET_ITEM(d, i, f); | |
189 } | |
190 return d; | |
191 error: | |
192 Py_XDECREF(d); | |
193 return NULL; | |
194 } | |
195 | |
196 static PyObject * | |
197 _mysql_field_to_python( | |
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
|
198 PyObject *decoder, |
0 | 199 char *rowitem, |
200 unsigned long length) | |
201 { | |
202 PyObject *v; | |
203 if (rowitem) { | |
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
|
204 if (decoder != Py_None) |
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
|
205 v = PyObject_CallFunction(decoder, |
0 | 206 "s#", |
207 rowitem, | |
208 (int)length); | |
209 else | |
210 v = PyString_FromStringAndSize(rowitem, | |
211 (int)length); | |
212 if (!v) | |
213 return NULL; | |
214 } else { | |
215 Py_INCREF(Py_None); | |
216 v = Py_None; | |
217 } | |
218 return v; | |
219 } | |
220 | |
221 static PyObject * | |
222 _mysql_row_to_tuple( | |
223 _mysql_ResultObject *self, | |
224 MYSQL_ROW row) | |
225 { | |
226 unsigned int n, i; | |
227 unsigned long *length; | |
228 PyObject *r, *c; | |
229 | |
230 n = mysql_num_fields(self->result); | |
231 if (!(r = PyTuple_New(n))) return NULL; | |
232 length = mysql_fetch_lengths(self->result); | |
233 for (i=0; i<n; i++) { | |
234 PyObject *v; | |
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
|
235 c = PyTuple_GET_ITEM(self->decoders, i); |
0 | 236 v = _mysql_field_to_python(c, row[i], length[i]); |
237 if (!v) goto error; | |
238 PyTuple_SET_ITEM(r, i, v); | |
239 } | |
240 return r; | |
241 error: | |
242 Py_XDECREF(r); | |
243 return NULL; | |
244 } | |
245 | |
246 static PyObject * | |
247 _mysql_row_to_dict( | |
248 _mysql_ResultObject *self, | |
249 MYSQL_ROW row) | |
250 { | |
251 unsigned int n, i; | |
252 unsigned long *length; | |
253 PyObject *r, *c; | |
254 MYSQL_FIELD *fields; | |
255 | |
256 n = mysql_num_fields(self->result); | |
257 if (!(r = PyDict_New())) return NULL; | |
258 length = mysql_fetch_lengths(self->result); | |
259 fields = mysql_fetch_fields(self->result); | |
260 for (i=0; i<n; i++) { | |
261 PyObject *v; | |
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
|
262 c = PyTuple_GET_ITEM(self->decoders, i); |
0 | 263 v = _mysql_field_to_python(c, row[i], length[i]); |
264 if (!v) goto error; | |
265 if (!PyMapping_HasKeyString(r, fields[i].name)) { | |
266 PyMapping_SetItemString(r, fields[i].name, v); | |
267 } else { | |
268 int len; | |
269 char buf[256]; | |
270 strncpy(buf, fields[i].table, 256); | |
271 len = strlen(buf); | |
272 strncat(buf, ".", 256-len); | |
273 len = strlen(buf); | |
274 strncat(buf, fields[i].name, 256-len); | |
275 PyMapping_SetItemString(r, buf, v); | |
276 } | |
277 Py_DECREF(v); | |
278 } | |
279 return r; | |
280 error: | |
281 Py_XDECREF(r); | |
282 return NULL; | |
283 } | |
284 | |
285 static PyObject * | |
286 _mysql_row_to_dict_old( | |
287 _mysql_ResultObject *self, | |
288 MYSQL_ROW row) | |
289 { | |
290 unsigned int n, i; | |
291 unsigned long *length; | |
292 PyObject *r, *c; | |
293 MYSQL_FIELD *fields; | |
294 | |
295 n = mysql_num_fields(self->result); | |
296 if (!(r = PyDict_New())) return NULL; | |
297 length = mysql_fetch_lengths(self->result); | |
298 fields = mysql_fetch_fields(self->result); | |
299 for (i=0; i<n; i++) { | |
300 PyObject *v; | |
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
|
301 c = PyTuple_GET_ITEM(self->decoders, i); |
0 | 302 v = _mysql_field_to_python(c, row[i], length[i]); |
303 if (!v) goto error; | |
304 { | |
305 int len=0; | |
306 char buf[256]=""; | |
307 if (strlen(fields[i].table)) { | |
308 strncpy(buf, fields[i].table, 256); | |
309 len = strlen(buf); | |
310 strncat(buf, ".", 256-len); | |
311 len = strlen(buf); | |
312 } | |
313 strncat(buf, fields[i].name, 256-len); | |
314 PyMapping_SetItemString(r, buf, v); | |
315 } | |
316 Py_DECREF(v); | |
317 } | |
318 return r; | |
319 error: | |
320 Py_XDECREF(r); | |
321 return NULL; | |
322 } | |
323 | |
324 typedef PyObject *_PYFUNC(_mysql_ResultObject *, MYSQL_ROW); | |
325 | |
326 int | |
327 _mysql__fetch_row( | |
328 _mysql_ResultObject *self, | |
329 PyObject **r, | |
330 int skiprows, | |
331 int maxrows, | |
332 _PYFUNC *convert_row) | |
333 { | |
334 unsigned int i; | |
335 MYSQL_ROW row; | |
336 | |
337 for (i = skiprows; i<(skiprows+maxrows); i++) { | |
338 PyObject *v; | |
339 if (!self->use) | |
340 row = mysql_fetch_row(self->result); | |
341 else { | |
342 Py_BEGIN_ALLOW_THREADS; | |
343 row = mysql_fetch_row(self->result); | |
344 Py_END_ALLOW_THREADS; | |
345 } | |
346 if (!row && mysql_errno(&(((_mysql_ConnectionObject *)(self->conn))->connection))) { | |
347 _mysql_Exception((_mysql_ConnectionObject *)self->conn); | |
348 goto error; | |
349 } | |
350 if (!row) { | |
44
2b9a9814daab
_PyTuple_Resize is stable since 2.2, so we don't need the macro MyTuple_Resize
kylev
parents:
42
diff
changeset
|
351 if (_PyTuple_Resize(r, i) == -1) goto error; |
0 | 352 break; |
353 } | |
354 v = convert_row(self, row); | |
355 if (!v) goto error; | |
356 PyTuple_SET_ITEM(*r, i, v); | |
357 } | |
358 return i-skiprows; | |
359 error: | |
360 return -1; | |
361 } | |
362 | |
363 static char _mysql_ResultObject_fetch_row__doc__[] = | |
364 "fetch_row([maxrows, how]) -- Fetches up to maxrows as a tuple.\n\ | |
365 The rows are formatted according to how:\n\ | |
366 \n\ | |
367 0 -- tuples (default)\n\ | |
368 1 -- dictionaries, key=column or table.column if duplicated\n\ | |
369 2 -- dictionaries, key=table.column\n\ | |
370 "; | |
371 | |
372 static PyObject * | |
373 _mysql_ResultObject_fetch_row( | |
374 _mysql_ResultObject *self, | |
375 PyObject *args, | |
376 PyObject *kwargs) | |
377 { | |
378 typedef PyObject *_PYFUNC(_mysql_ResultObject *, MYSQL_ROW); | |
379 static char *kwlist[] = { "maxrows", "how", NULL }; | |
380 static _PYFUNC *row_converters[] = | |
381 { | |
382 _mysql_row_to_tuple, | |
383 _mysql_row_to_dict, | |
384 _mysql_row_to_dict_old | |
385 }; | |
386 _PYFUNC *convert_row; | |
387 unsigned int maxrows=1, how=0, skiprows=0, rowsadded; | |
388 PyObject *r=NULL; | |
389 | |
390 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii:fetch_row", kwlist, | |
391 &maxrows, &how)) | |
392 return NULL; | |
393 check_result_connection(self); | |
394 if (how < 0 || how >= sizeof(row_converters)) { | |
395 PyErr_SetString(PyExc_ValueError, "how out of range"); | |
396 return NULL; | |
397 } | |
398 convert_row = row_converters[how]; | |
399 if (maxrows) { | |
400 if (!(r = PyTuple_New(maxrows))) goto error; | |
44
2b9a9814daab
_PyTuple_Resize is stable since 2.2, so we don't need the macro MyTuple_Resize
kylev
parents:
42
diff
changeset
|
401 rowsadded = _mysql__fetch_row(self, &r, skiprows, maxrows, |
0 | 402 convert_row); |
403 if (rowsadded == -1) goto error; | |
404 } else { | |
405 if (self->use) { | |
406 maxrows = 1000; | |
407 if (!(r = PyTuple_New(maxrows))) goto error; | |
408 while (1) { | |
409 rowsadded = _mysql__fetch_row(self, &r, skiprows, | |
410 maxrows, convert_row); | |
411 if (rowsadded == -1) goto error; | |
412 skiprows += rowsadded; | |
413 if (rowsadded < maxrows) break; | |
44
2b9a9814daab
_PyTuple_Resize is stable since 2.2, so we don't need the macro MyTuple_Resize
kylev
parents:
42
diff
changeset
|
414 if (_PyTuple_Resize(&r, skiprows + maxrows) == -1) |
0 | 415 goto error; |
416 } | |
417 } else { | |
418 /* XXX if overflow, maxrows<0? */ | |
419 maxrows = (int) mysql_num_rows(self->result); | |
420 if (!(r = PyTuple_New(maxrows))) goto error; | |
421 rowsadded = _mysql__fetch_row(self, &r, 0, | |
422 maxrows, convert_row); | |
423 if (rowsadded == -1) goto error; | |
424 } | |
425 } | |
426 return r; | |
427 error: | |
428 Py_XDECREF(r); | |
429 return NULL; | |
430 } | |
431 | |
432 | |
433 static char _mysql_ResultObject_num_fields__doc__[] = | |
434 "Returns the number of fields (column) in the result." ; | |
435 | |
436 static PyObject * | |
437 _mysql_ResultObject_num_fields( | |
438 _mysql_ResultObject *self, | |
26 | 439 PyObject *unused) |
0 | 440 { |
441 check_result_connection(self); | |
442 return PyInt_FromLong((long)mysql_num_fields(self->result)); | |
26 | 443 } |
0 | 444 |
445 static char _mysql_ResultObject_num_rows__doc__[] = | |
446 "Returns the number of rows in the result set. Note that if\n\ | |
447 use=1, this will not return a valid value until the entire result\n\ | |
448 set has been read.\n\ | |
449 "; | |
450 | |
451 static PyObject * | |
452 _mysql_ResultObject_num_rows( | |
453 _mysql_ResultObject *self, | |
26 | 454 PyObject *unused) |
0 | 455 { |
456 check_result_connection(self); | |
457 return PyLong_FromUnsignedLongLong(mysql_num_rows(self->result)); | |
26 | 458 } |
0 | 459 |
460 | |
461 static char _mysql_ResultObject_data_seek__doc__[] = | |
462 "data_seek(n) -- seek to row n of result set"; | |
463 static PyObject * | |
464 _mysql_ResultObject_data_seek( | |
465 _mysql_ResultObject *self, | |
466 PyObject *args) | |
467 { | |
468 unsigned int row; | |
469 if (!PyArg_ParseTuple(args, "i:data_seek", &row)) return NULL; | |
470 check_result_connection(self); | |
471 mysql_data_seek(self->result, row); | |
472 Py_INCREF(Py_None); | |
473 return Py_None; | |
474 } | |
475 | |
476 static char _mysql_ResultObject_row_seek__doc__[] = | |
477 "row_seek(n) -- seek by offset n rows of result set"; | |
478 static PyObject * | |
479 _mysql_ResultObject_row_seek( | |
480 _mysql_ResultObject *self, | |
481 PyObject *args) | |
482 { | |
483 int offset; | |
484 MYSQL_ROW_OFFSET r; | |
485 if (!PyArg_ParseTuple(args, "i:row_seek", &offset)) return NULL; | |
486 check_result_connection(self); | |
487 if (self->use) { | |
488 PyErr_SetString(_mysql_ProgrammingError, | |
489 "cannot be used with connection.use_result()"); | |
490 return NULL; | |
491 } | |
492 r = mysql_row_tell(self->result); | |
493 mysql_row_seek(self->result, r+offset); | |
494 Py_INCREF(Py_None); | |
495 return Py_None; | |
496 } | |
497 | |
498 static char _mysql_ResultObject_row_tell__doc__[] = | |
499 "row_tell() -- return the current row number of the result set."; | |
500 static PyObject * | |
501 _mysql_ResultObject_row_tell( | |
502 _mysql_ResultObject *self, | |
26 | 503 PyObject *unused) |
0 | 504 { |
505 MYSQL_ROW_OFFSET r; | |
26 | 506 |
0 | 507 check_result_connection(self); |
508 if (self->use) { | |
509 PyErr_SetString(_mysql_ProgrammingError, | |
510 "cannot be used with connection.use_result()"); | |
511 return NULL; | |
512 } | |
513 r = mysql_row_tell(self->result); | |
514 return PyInt_FromLong(r-self->result->data->data); | |
515 } | |
516 | |
517 static void | |
518 _mysql_ResultObject_dealloc( | |
519 _mysql_ResultObject *self) | |
520 { | |
521 PyObject_GC_UnTrack((PyObject *)self); | |
522 mysql_free_result(self->result); | |
523 _mysql_ResultObject_clear(self); | |
524 MyFree(self); | |
525 } | |
526 | |
527 static PyObject * | |
528 _mysql_ResultObject_repr( | |
529 _mysql_ResultObject *self) | |
530 { | |
531 char buf[300]; | |
532 sprintf(buf, "<_mysql.result object at %lx>", | |
533 (long)self); | |
534 return PyString_FromString(buf); | |
535 } | |
536 | |
537 static PyMethodDef _mysql_ResultObject_methods[] = { | |
538 { | |
539 "data_seek", | |
540 (PyCFunction)_mysql_ResultObject_data_seek, | |
541 METH_VARARGS, | |
542 _mysql_ResultObject_data_seek__doc__ | |
543 }, | |
544 { | |
545 "row_seek", | |
546 (PyCFunction)_mysql_ResultObject_row_seek, | |
547 METH_VARARGS, | |
548 _mysql_ResultObject_row_seek__doc__ | |
549 }, | |
550 { | |
551 "row_tell", | |
552 (PyCFunction)_mysql_ResultObject_row_tell, | |
26 | 553 METH_NOARGS, |
0 | 554 _mysql_ResultObject_row_tell__doc__ |
555 }, | |
556 { | |
557 "describe", | |
558 (PyCFunction)_mysql_ResultObject_describe, | |
26 | 559 METH_NOARGS, |
0 | 560 _mysql_ResultObject_describe__doc__ |
561 }, | |
562 { | |
563 "fetch_row", | |
564 (PyCFunction)_mysql_ResultObject_fetch_row, | |
565 METH_VARARGS | METH_KEYWORDS, | |
566 _mysql_ResultObject_fetch_row__doc__ | |
567 }, | |
568 { | |
569 "field_flags", | |
570 (PyCFunction)_mysql_ResultObject_field_flags, | |
26 | 571 METH_NOARGS, |
0 | 572 _mysql_ResultObject_field_flags__doc__ |
573 }, | |
574 { | |
575 "num_fields", | |
576 (PyCFunction)_mysql_ResultObject_num_fields, | |
26 | 577 METH_NOARGS, |
0 | 578 _mysql_ResultObject_num_fields__doc__ |
579 }, | |
580 { | |
581 "num_rows", | |
582 (PyCFunction)_mysql_ResultObject_num_rows, | |
26 | 583 METH_NOARGS, |
0 | 584 _mysql_ResultObject_num_rows__doc__ |
585 }, | |
586 {NULL, NULL} /* sentinel */ | |
587 }; | |
588 | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
589 static struct PyMemberDef _mysql_ResultObject_memberlist[] = { |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
590 { |
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
|
591 "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
|
592 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
|
593 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
|
594 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
|
595 "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
|
596 }, |
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
|
597 { |
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
|
598 "decoders", |
0 | 599 T_OBJECT, |
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
|
600 offsetof(_mysql_ResultObject, decoders), |
0 | 601 RO, |
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
|
602 "Field decoders for result set" |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
603 }, |
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
|
604 { |
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
|
605 "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
|
606 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
|
607 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
|
608 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
|
609 "Field metadata for result set" |
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
|
610 }, {NULL} /* Sentinel */ |
0 | 611 }; |
612 | |
613 static PyObject * | |
614 _mysql_ResultObject_getattr( | |
615 _mysql_ResultObject *self, | |
616 char *name) | |
617 { | |
618 PyObject *res; | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
619 struct PyMemberDef *l; |
0 | 620 |
621 res = Py_FindMethod(_mysql_ResultObject_methods, (PyObject *)self, name); | |
622 if (res != NULL) | |
623 return res; | |
624 PyErr_Clear(); | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
625 |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
626 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
|
627 if (strcmp(l->name, name) == 0) |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
628 return PyMember_GetOne((char *)self, l); |
0 | 629 } |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
630 |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
631 PyErr_SetString(PyExc_AttributeError, name); |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
632 return NULL; |
0 | 633 } |
634 | |
635 static int | |
636 _mysql_ResultObject_setattr( | |
637 _mysql_ResultObject *self, | |
638 char *name, | |
639 PyObject *v) | |
640 { | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
641 struct PyMemberDef *l; |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
642 |
0 | 643 if (v == NULL) { |
644 PyErr_SetString(PyExc_AttributeError, | |
645 "can't delete connection attributes"); | |
646 return -1; | |
647 } | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
648 |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
649 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
|
650 if (strcmp(l->name, name) == 0) |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
651 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
|
652 |
0 | 653 PyErr_SetString(PyExc_AttributeError, name); |
654 return -1; | |
655 } | |
656 | |
657 PyTypeObject _mysql_ResultObject_Type = { | |
658 PyObject_HEAD_INIT(NULL) | |
659 0, | |
660 "_mysql.result", | |
661 sizeof(_mysql_ResultObject), | |
662 0, | |
663 (destructor)_mysql_ResultObject_dealloc, /* tp_dealloc */ | |
664 0, /*tp_print*/ | |
665 (getattrfunc)_mysql_ResultObject_getattr, /* tp_getattr */ | |
666 (setattrfunc)_mysql_ResultObject_setattr, /* tp_setattr */ | |
667 0, /*tp_compare*/ | |
668 (reprfunc)_mysql_ResultObject_repr, /* tp_repr */ | |
45 | 669 |
0 | 670 /* Method suites for standard classes */ |
45 | 671 |
0 | 672 0, /* (PyNumberMethods *) tp_as_number */ |
673 0, /* (PySequenceMethods *) tp_as_sequence */ | |
674 0, /* (PyMappingMethods *) tp_as_mapping */ | |
45 | 675 |
0 | 676 /* More standard operations (here for binary compatibility) */ |
45 | 677 |
0 | 678 0, /* (hashfunc) tp_hash */ |
679 0, /* (ternaryfunc) tp_call */ | |
680 0, /* (reprfunc) tp_str */ | |
681 0, /* (getattrofunc) tp_getattro */ | |
682 0, /* (setattrofunc) tp_setattro */ | |
45 | 683 |
0 | 684 /* Functions to access object as input/output buffer */ |
685 0, /* (PyBufferProcs *) tp_as_buffer */ | |
45 | 686 |
0 | 687 /* Flags to define presence of optional/expanded features */ |
45 | 688 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* (long) tp_flags */ |
689 | |
0 | 690 _mysql_ResultObject__doc__, /* (char *) tp_doc Documentation string */ |
691 /* call function for all accessible objects */ | |
45 | 692 (traverseproc)_mysql_ResultObject_traverse, /* tp_traverse */ |
0 | 693 /* delete references to contained objects */ |
45 | 694 (inquiry)_mysql_ResultObject_clear, /* tp_clear */ |
695 | |
0 | 696 /* rich comparisons */ |
697 0, /* (richcmpfunc) tp_richcompare */ | |
45 | 698 |
0 | 699 /* weak reference enabler */ |
700 0, /* (long) tp_weaklistoffset */ | |
45 | 701 |
0 | 702 /* Iterators */ |
703 0, /* (getiterfunc) tp_iter */ | |
704 0, /* (iternextfunc) tp_iternext */ | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
705 |
0 | 706 /* Attribute descriptor and subclassing stuff */ |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
26
diff
changeset
|
707 (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
|
708 (struct PyMemberDef *)_mysql_ResultObject_memberlist, /*tp_members */ |
0 | 709 0, /* (struct getsetlist *) tp_getset; */ |
710 0, /* (struct _typeobject *) tp_base; */ | |
711 0, /* (PyObject *) tp_dict */ | |
712 0, /* (descrgetfunc) tp_descr_get */ | |
713 0, /* (descrsetfunc) tp_descr_set */ | |
714 0, /* (long) tp_dictoffset */ | |
715 (initproc)_mysql_ResultObject_Initialize, /* tp_init */ | |
716 NULL, /* tp_alloc */ | |
717 NULL, /* tp_new */ | |
718 NULL, /* tp_free Low-level free-memory routine */ | |
719 0, /* (PyObject *) tp_bases */ | |
720 0, /* (PyObject *) tp_mro method resolution order */ | |
721 0, /* (PyObject *) tp_defined */ | |
722 }; |