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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
41 \n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
42 Creating instances of this class directly is an excellent way to\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
43 shoot yourself in the foot. If using _mysql.connection directly,\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
44 use connection.store_result() or connection.use_result() instead.\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
45 If using MySQLdb.Connection, this is done by the cursor class.\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
46 Just forget you ever saw this. Forget... FOR-GET...";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
47
2
c0d1fc0429ce Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents: 1
diff changeset
48 int
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
49 _mysql_ResultObject_Initialize(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
50 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
51 PyObject *args,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
52 PyObject *kwargs)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
62 return -1;
75
3b03cb566032 More serious restructuring and cleaning, especially in the handling
adustman
parents: 73
diff changeset
63
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
64 self->conn = (PyObject *) conn;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
65 Py_INCREF(conn);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
66 self->use = use;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
67 Py_BEGIN_ALLOW_THREADS ;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
68 if (use)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
69 result = mysql_use_result(&(conn->connection));
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
70 else
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
71 result = mysql_store_result(&(conn->connection));
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
72 self->result = result;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
73 Py_END_ALLOW_THREADS ;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
74 if (!result) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
75 return 0;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
76 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
77 n = mysql_num_fields(result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
81 return 0;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
82 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
83
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
84 static int
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
85 _mysql_ResultObject_traverse(
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
86 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
87 visitproc visit,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
88 void *arg)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
89 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
93 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
94 if (self->conn)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
95 return visit(self->conn, arg);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
96 return 0;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
97 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
98
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
99 static char _mysql_ResultObject_describe__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
100 "Returns the sequence of 7-tuples required by the DB-API for\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
101 the Cursor.description attribute.\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
102 ";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
103
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
104 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
105 _mysql_ResultObject_describe(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
106 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
107 PyObject *unused)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
108 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
109 PyObject *d;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
110 MYSQL_FIELD *fields;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
111 unsigned int i, n;
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
112
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
113 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
114 n = mysql_num_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
115 fields = mysql_fetch_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
116 if (!(d = PyTuple_New(n))) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
117 for (i=0; i<n; i++) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
118 PyObject *t;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
119 t = Py_BuildValue("(siiiiii)",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
120 fields[i].name,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
121 (long) fields[i].type,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
122 (long) fields[i].max_length,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
123 (long) fields[i].length,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
124 (long) fields[i].length,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
125 (long) fields[i].decimals,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
126 (long) !(IS_NOT_NULL(fields[i].flags)));
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
127 if (!t) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
128 PyTuple_SET_ITEM(d, i, t);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
129 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
130 return d;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
131 error:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
132 Py_XDECREF(d);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
133 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
191 static char _mysql_ResultObject_field_flags__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
192 "Returns a tuple of field flags, one for each column in the result.\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
193 " ;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
194
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
195 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
196 _mysql_ResultObject_field_flags(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
197 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
198 PyObject *unused)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
199 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
200 PyObject *d;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
201 MYSQL_FIELD *fields;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
202 unsigned int i, n;
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
203
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
204 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
205 n = mysql_num_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
206 fields = mysql_fetch_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
207 if (!(d = PyTuple_New(n))) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
208 for (i=0; i<n; i++) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
209 PyObject *f;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
210 if (!(f = PyInt_FromLong((long)fields[i].flags))) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
211 PyTuple_SET_ITEM(d, i, f);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
212 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
213 return d;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
214 error:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
215 Py_XDECREF(d);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
216 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
217 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
218
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
219 typedef PyObject *_PYFUNC(_mysql_ResultObject *, MYSQL_ROW);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
224 ";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
225
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
280
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
281 static char _mysql_ResultObject_num_fields__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
282 "Returns the number of fields (column) in the result." ;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
283
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
284 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
285 _mysql_ResultObject_num_fields(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
286 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
287 PyObject *unused)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
288 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
289 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
290 return PyInt_FromLong((long)mysql_num_fields(self->result));
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
291 }
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
292
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
293 static char _mysql_ResultObject_num_rows__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
294 "Returns the number of rows in the result set. Note that if\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
295 use=1, this will not return a valid value until the entire result\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
296 set has been read.\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
297 ";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
298
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
299 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
300 _mysql_ResultObject_num_rows(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
301 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
302 PyObject *unused)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
303 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
304 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
305 return PyLong_FromUnsignedLongLong(mysql_num_rows(self->result));
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
306 }
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
307
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
308
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
309 static char _mysql_ResultObject_data_seek__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
310 "data_seek(n) -- seek to row n of result set";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
311 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
312 _mysql_ResultObject_data_seek(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
313 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
314 PyObject *args)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
315 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
316 unsigned int row;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
317 if (!PyArg_ParseTuple(args, "i:data_seek", &row)) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
318 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
319 mysql_data_seek(self->result, row);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
320 Py_INCREF(Py_None);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
321 return Py_None;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
322 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
323
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
324 static char _mysql_ResultObject_row_seek__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
325 "row_seek(n) -- seek by offset n rows of result set";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
326 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
327 _mysql_ResultObject_row_seek(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
328 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
329 PyObject *args)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
330 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
331 int offset;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
332 MYSQL_ROW_OFFSET r;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
333 if (!PyArg_ParseTuple(args, "i:row_seek", &offset)) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
334 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
335 if (self->use) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
336 PyErr_SetString(_mysql_ProgrammingError,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
337 "cannot be used with connection.use_result()");
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
338 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
339 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
340 r = mysql_row_tell(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
341 mysql_row_seek(self->result, r+offset);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
342 Py_INCREF(Py_None);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
343 return Py_None;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
344 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
345
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
346 static char _mysql_ResultObject_row_tell__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
347 "row_tell() -- return the current row number of the result set.";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
348 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
349 _mysql_ResultObject_row_tell(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
350 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
351 PyObject *unused)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
352 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
353 MYSQL_ROW_OFFSET r;
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
354
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
355 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
356 if (self->use) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
357 PyErr_SetString(_mysql_ProgrammingError,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
358 "cannot be used with connection.use_result()");
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
359 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
360 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
361 r = mysql_row_tell(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
362 return PyInt_FromLong(r-self->result->data->data);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
363 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
364
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
365 static void
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
366 _mysql_ResultObject_dealloc(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
367 _mysql_ResultObject *self)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
368 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
371 mysql_free_result(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
372 MyFree(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
373 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
374
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
375 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
376 _mysql_ResultObject_repr(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
377 _mysql_ResultObject *self)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
378 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
379 char buf[300];
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
380 sprintf(buf, "<_mysql.result object at %lx>",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
381 (long)self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
382 return PyString_FromString(buf);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
383 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
384
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
385 static PyMethodDef _mysql_ResultObject_methods[] = {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
386 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
387 "data_seek",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
388 (PyCFunction)_mysql_ResultObject_data_seek,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
389 METH_VARARGS,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
390 _mysql_ResultObject_data_seek__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
391 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
392 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
393 "row_seek",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
394 (PyCFunction)_mysql_ResultObject_row_seek,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
395 METH_VARARGS,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
396 _mysql_ResultObject_row_seek__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
397 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
398 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
399 "row_tell",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
400 (PyCFunction)_mysql_ResultObject_row_tell,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
401 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
402 _mysql_ResultObject_row_tell__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
403 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
411 "describe",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
412 (PyCFunction)_mysql_ResultObject_describe,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
413 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
414 _mysql_ResultObject_describe__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
415 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
416 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
417 "fetch_row",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
418 (PyCFunction)_mysql_ResultObject_fetch_row,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
419 METH_VARARGS | METH_KEYWORDS,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
420 _mysql_ResultObject_fetch_row__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
424 "field_flags",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
425 (PyCFunction)_mysql_ResultObject_field_flags,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
426 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
427 _mysql_ResultObject_field_flags__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
428 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
429 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
430 "num_fields",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
431 (PyCFunction)_mysql_ResultObject_num_fields,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
432 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
433 _mysql_ResultObject_num_fields__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
434 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
435 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
436 "num_rows",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
437 (PyCFunction)_mysql_ResultObject_num_rows,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
438 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
439 _mysql_ResultObject_num_rows__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
440 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
441 {NULL, NULL} /* sentinel */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
442 };
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
467 };
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
468
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
469 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
470 _mysql_ResultObject_getattr(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
471 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
472 char *name)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
473 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
476
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
477 res = Py_FindMethod(_mysql_ResultObject_methods, (PyObject *)self, name);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
478 if (res != NULL)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
479 return res;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
489 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
490
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
491 static int
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
492 _mysql_ResultObject_setattr(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
493 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
494 char *name,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
495 PyObject *v)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
499 if (v == NULL) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
500 PyErr_SetString(PyExc_AttributeError,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
501 "can't delete connection attributes");
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
502 return -1;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
509 PyErr_SetString(PyExc_AttributeError, name);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
510 return -1;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
511 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
512
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
513 PyTypeObject _mysql_ResultObject_Type = {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
514 PyObject_HEAD_INIT(NULL)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
515 0,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
516 "_mysql.result",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
517 sizeof(_mysql_ResultObject),
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
518 0,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
519 (destructor)_mysql_ResultObject_dealloc, /* tp_dealloc */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
520 0, /*tp_print*/
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
521 (getattrfunc)_mysql_ResultObject_getattr, /* tp_getattr */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
522 (setattrfunc)_mysql_ResultObject_setattr, /* tp_setattr */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
523 0, /*tp_compare*/
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
524 (reprfunc)_mysql_ResultObject_repr, /* tp_repr */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
525
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
526 /* Method suites for standard classes */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
527
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
528 0, /* (PyNumberMethods *) tp_as_number */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
529 0, /* (PySequenceMethods *) tp_as_sequence */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
530 0, /* (PyMappingMethods *) tp_as_mapping */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
531
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
532 /* More standard operations (here for binary compatibility) */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
533
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
534 0, /* (hashfunc) tp_hash */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
535 0, /* (ternaryfunc) tp_call */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
536 0, /* (reprfunc) tp_str */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
537 0, /* (getattrofunc) tp_getattro */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
538 0, /* (setattrofunc) tp_setattro */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
539
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
540 /* Functions to access object as input/output buffer */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
541 0, /* (PyBufferProcs *) tp_as_buffer */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
542
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
543 /* Flags to define presence of optional/expanded features */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
544 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* (long) tp_flags */
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
545
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
546 _mysql_ResultObject__doc__, /* (char *) tp_doc Documentation string */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
547 /* call function for all accessible objects */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
548 (traverseproc)_mysql_ResultObject_traverse, /* tp_traverse */
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
549 /* delete references to contained objects */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
550 (inquiry)_mysql_ResultObject_clear, /* tp_clear */
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
551
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
552 /* rich comparisons */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
553 0, /* (richcmpfunc) tp_richcompare */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
554
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
555 /* weak reference enabler */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
556 0, /* (long) tp_weaklistoffset */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
557
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
565 0, /* (struct getsetlist *) tp_getset; */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
566 0, /* (struct _typeobject *) tp_base; */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
567 0, /* (PyObject *) tp_dict */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
568 0, /* (descrgetfunc) tp_descr_get */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
569 0, /* (descrsetfunc) tp_descr_set */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
570 0, /* (long) tp_dictoffset */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
571 (initproc)_mysql_ResultObject_Initialize, /* tp_init */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
572 NULL, /* tp_alloc */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
573 NULL, /* tp_new */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
574 NULL, /* tp_free Low-level free-memory routine */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
575 0, /* (PyObject *) tp_bases */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
576 0, /* (PyObject *) tp_mro method resolution order */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
577 0, /* (PyObject *) tp_defined */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
578 };