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
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__[] =
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
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 {
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
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;
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
60
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
66 self->conn = (PyObject *) conn;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
67 Py_INCREF(conn);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
68 self->use = use;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
69 Py_BEGIN_ALLOW_THREADS ;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
70 if (use)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
71 result = mysql_use_result(&(conn->connection));
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
72 else
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
73 result = mysql_store_result(&(conn->connection));
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
74 self->result = result;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
75 Py_END_ALLOW_THREADS ;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
78 return 0;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
79 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
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 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
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
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
105 static int
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
106 _mysql_ResultObject_traverse(
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
107 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
108 visitproc visit,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
109 void *arg)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
110 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
114 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
115 if (self->conn)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
116 return visit(self->conn, arg);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
117 return 0;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
118 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
119
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
120 static int
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
121 _mysql_ResultObject_clear(
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
122 _mysql_ResultObject *self)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
126 Py_XDECREF(self->conn);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
127 self->conn = NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
128 return 0;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
129 }
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
130
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
131 static char _mysql_ResultObject_describe__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
132 "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
133 the Cursor.description attribute.\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
134 ";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
135
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
136 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
137 _mysql_ResultObject_describe(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
138 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
139 PyObject *unused)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
140 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
141 PyObject *d;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
142 MYSQL_FIELD *fields;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
143 unsigned int i, n;
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
144
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
145 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
146 n = mysql_num_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
147 fields = mysql_fetch_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
148 if (!(d = PyTuple_New(n))) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
149 for (i=0; i<n; i++) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
150 PyObject *t;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
151 t = Py_BuildValue("(siiiiii)",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
152 fields[i].name,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
153 (long) fields[i].type,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
154 (long) fields[i].max_length,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
155 (long) fields[i].length,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
156 (long) fields[i].length,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
157 (long) fields[i].decimals,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
158 (long) !(IS_NOT_NULL(fields[i].flags)));
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
159 if (!t) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
160 PyTuple_SET_ITEM(d, i, t);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
161 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
162 return d;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
163 error:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
164 Py_XDECREF(d);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
165 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
166 }
18
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 2
diff changeset
167
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
168 static char _mysql_ResultObject_field_flags__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
169 "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
170 " ;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
171
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
172 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
173 _mysql_ResultObject_field_flags(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
174 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
175 PyObject *unused)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
176 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
177 PyObject *d;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
178 MYSQL_FIELD *fields;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
179 unsigned int i, n;
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
180
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
181 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
182 n = mysql_num_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
183 fields = mysql_fetch_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
184 if (!(d = PyTuple_New(n))) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
185 for (i=0; i<n; i++) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
186 PyObject *f;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
187 if (!(f = PyInt_FromLong((long)fields[i].flags))) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
188 PyTuple_SET_ITEM(d, i, f);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
189 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
190 return d;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
191 error:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
192 Py_XDECREF(d);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
193 return NULL;
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
196 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
199 char *rowitem,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
200 unsigned long length)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
201 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
202 PyObject *v;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
206 "s#",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
207 rowitem,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
208 (int)length);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
209 else
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
210 v = PyString_FromStringAndSize(rowitem,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
211 (int)length);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
212 if (!v)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
213 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
214 } else {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
215 Py_INCREF(Py_None);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
216 v = Py_None;
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 return v;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
219 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
220
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
221 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
222 _mysql_row_to_tuple(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
223 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
224 MYSQL_ROW row)
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 unsigned int n, i;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
227 unsigned long *length;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
228 PyObject *r, *c;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
229
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
230 n = mysql_num_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
231 if (!(r = PyTuple_New(n))) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
232 length = mysql_fetch_lengths(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
233 for (i=0; i<n; i++) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
236 v = _mysql_field_to_python(c, row[i], length[i]);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
237 if (!v) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
238 PyTuple_SET_ITEM(r, i, v);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
239 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
240 return r;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
241 error:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
242 Py_XDECREF(r);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
243 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
244 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
245
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
246 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
247 _mysql_row_to_dict(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
248 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
249 MYSQL_ROW row)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
250 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
251 unsigned int n, i;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
252 unsigned long *length;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
253 PyObject *r, *c;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
254 MYSQL_FIELD *fields;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
255
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
256 n = mysql_num_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
257 if (!(r = PyDict_New())) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
258 length = mysql_fetch_lengths(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
259 fields = mysql_fetch_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
260 for (i=0; i<n; i++) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
263 v = _mysql_field_to_python(c, row[i], length[i]);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
264 if (!v) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
265 if (!PyMapping_HasKeyString(r, fields[i].name)) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
266 PyMapping_SetItemString(r, fields[i].name, v);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
267 } else {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
268 int len;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
269 char buf[256];
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
270 strncpy(buf, fields[i].table, 256);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
271 len = strlen(buf);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
272 strncat(buf, ".", 256-len);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
273 len = strlen(buf);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
274 strncat(buf, fields[i].name, 256-len);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
275 PyMapping_SetItemString(r, buf, v);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
276 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
277 Py_DECREF(v);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
278 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
279 return r;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
280 error:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
281 Py_XDECREF(r);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
282 return NULL;
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
285 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
286 _mysql_row_to_dict_old(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
287 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
288 MYSQL_ROW row)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
289 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
290 unsigned int n, i;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
291 unsigned long *length;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
292 PyObject *r, *c;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
293 MYSQL_FIELD *fields;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
294
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
295 n = mysql_num_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
296 if (!(r = PyDict_New())) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
297 length = mysql_fetch_lengths(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
298 fields = mysql_fetch_fields(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
299 for (i=0; i<n; i++) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
302 v = _mysql_field_to_python(c, row[i], length[i]);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
303 if (!v) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
304 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
305 int len=0;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
306 char buf[256]="";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
307 if (strlen(fields[i].table)) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
308 strncpy(buf, fields[i].table, 256);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
309 len = strlen(buf);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
310 strncat(buf, ".", 256-len);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
311 len = strlen(buf);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
312 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
313 strncat(buf, fields[i].name, 256-len);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
314 PyMapping_SetItemString(r, buf, v);
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 Py_DECREF(v);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
317 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
318 return r;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
319 error:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
320 Py_XDECREF(r);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
321 return NULL;
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 typedef PyObject *_PYFUNC(_mysql_ResultObject *, MYSQL_ROW);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
325
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
326 int
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
327 _mysql__fetch_row(
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 **r,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
330 int skiprows,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
331 int maxrows,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
332 _PYFUNC *convert_row)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
333 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
334 unsigned int i;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
335 MYSQL_ROW row;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
336
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
337 for (i = skiprows; i<(skiprows+maxrows); i++) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
338 PyObject *v;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
339 if (!self->use)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
340 row = mysql_fetch_row(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
341 else {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
342 Py_BEGIN_ALLOW_THREADS;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
343 row = mysql_fetch_row(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
344 Py_END_ALLOW_THREADS;
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 if (!row && mysql_errno(&(((_mysql_ConnectionObject *)(self->conn))->connection))) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
347 _mysql_Exception((_mysql_ConnectionObject *)self->conn);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
348 goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
349 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
352 break;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
353 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
354 v = convert_row(self, row);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
355 if (!v) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
356 PyTuple_SET_ITEM(*r, i, v);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
357 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
358 return i-skiprows;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
359 error:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
360 return -1;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
361 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
362
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
363 static char _mysql_ResultObject_fetch_row__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
364 "fetch_row([maxrows, how]) -- Fetches up to maxrows as a tuple.\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
365 The rows are formatted according to how:\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
366 \n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
367 0 -- tuples (default)\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
368 1 -- dictionaries, key=column or table.column if duplicated\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
369 2 -- dictionaries, key=table.column\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
370 ";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
371
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
372 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
373 _mysql_ResultObject_fetch_row(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
374 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
375 PyObject *args,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
376 PyObject *kwargs)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
377 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
378 typedef PyObject *_PYFUNC(_mysql_ResultObject *, MYSQL_ROW);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
379 static char *kwlist[] = { "maxrows", "how", NULL };
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
380 static _PYFUNC *row_converters[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
381 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
382 _mysql_row_to_tuple,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
383 _mysql_row_to_dict,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
384 _mysql_row_to_dict_old
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
385 };
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
386 _PYFUNC *convert_row;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
387 unsigned int maxrows=1, how=0, skiprows=0, rowsadded;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
388 PyObject *r=NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
389
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
390 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii:fetch_row", kwlist,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
391 &maxrows, &how))
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
392 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
393 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
394 if (how < 0 || how >= sizeof(row_converters)) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
395 PyErr_SetString(PyExc_ValueError, "how out of range");
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
396 return NULL;
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 convert_row = row_converters[how];
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
399 if (maxrows) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
402 convert_row);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
403 if (rowsadded == -1) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
404 } else {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
405 if (self->use) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
406 maxrows = 1000;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
407 if (!(r = PyTuple_New(maxrows))) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
408 while (1) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
409 rowsadded = _mysql__fetch_row(self, &r, skiprows,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
410 maxrows, convert_row);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
411 if (rowsadded == -1) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
412 skiprows += rowsadded;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
415 goto error;
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 } else {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
418 /* XXX if overflow, maxrows<0? */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
419 maxrows = (int) mysql_num_rows(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
420 if (!(r = PyTuple_New(maxrows))) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
421 rowsadded = _mysql__fetch_row(self, &r, 0,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
422 maxrows, convert_row);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
423 if (rowsadded == -1) goto error;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
424 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
425 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
426 return r;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
427 error:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
428 Py_XDECREF(r);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
429 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
430 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
431
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
432
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
433 static char _mysql_ResultObject_num_fields__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
434 "Returns the number of fields (column) in the result." ;
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 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
437 _mysql_ResultObject_num_fields(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
438 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
439 PyObject *unused)
0
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 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
442 return PyInt_FromLong((long)mysql_num_fields(self->result));
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
443 }
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
444
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
445 static char _mysql_ResultObject_num_rows__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
446 "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
447 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
448 set has been read.\n\
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
449 ";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
450
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
451 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
452 _mysql_ResultObject_num_rows(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
453 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
454 PyObject *unused)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
455 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
456 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
457 return PyLong_FromUnsignedLongLong(mysql_num_rows(self->result));
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
458 }
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
459
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
460
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
461 static char _mysql_ResultObject_data_seek__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
462 "data_seek(n) -- seek to row n of result set";
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
463 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
464 _mysql_ResultObject_data_seek(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
465 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
466 PyObject *args)
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 unsigned int row;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
469 if (!PyArg_ParseTuple(args, "i:data_seek", &row)) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
470 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
471 mysql_data_seek(self->result, row);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
472 Py_INCREF(Py_None);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
473 return Py_None;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
474 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
475
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
476 static char _mysql_ResultObject_row_seek__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
477 "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
478 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
479 _mysql_ResultObject_row_seek(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
480 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
481 PyObject *args)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
482 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
483 int offset;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
484 MYSQL_ROW_OFFSET r;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
485 if (!PyArg_ParseTuple(args, "i:row_seek", &offset)) return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
486 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
487 if (self->use) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
488 PyErr_SetString(_mysql_ProgrammingError,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
489 "cannot be used with connection.use_result()");
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
490 return NULL;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
491 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
492 r = mysql_row_tell(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
493 mysql_row_seek(self->result, r+offset);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
494 Py_INCREF(Py_None);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
495 return Py_None;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
496 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
497
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
498 static char _mysql_ResultObject_row_tell__doc__[] =
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
499 "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
500 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
501 _mysql_ResultObject_row_tell(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
502 _mysql_ResultObject *self,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
503 PyObject *unused)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
504 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
505 MYSQL_ROW_OFFSET r;
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
506
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
507 check_result_connection(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
508 if (self->use) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
509 PyErr_SetString(_mysql_ProgrammingError,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
510 "cannot be used with connection.use_result()");
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
511 return NULL;
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 r = mysql_row_tell(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
514 return PyInt_FromLong(r-self->result->data->data);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
515 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
516
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
517 static void
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
518 _mysql_ResultObject_dealloc(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
519 _mysql_ResultObject *self)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
520 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
521 PyObject_GC_UnTrack((PyObject *)self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
522 mysql_free_result(self->result);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
523 _mysql_ResultObject_clear(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
524 MyFree(self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
525 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
526
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
527 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
528 _mysql_ResultObject_repr(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
529 _mysql_ResultObject *self)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
530 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
531 char buf[300];
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
532 sprintf(buf, "<_mysql.result object at %lx>",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
533 (long)self);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
534 return PyString_FromString(buf);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
535 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
536
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
537 static PyMethodDef _mysql_ResultObject_methods[] = {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
538 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
539 "data_seek",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
540 (PyCFunction)_mysql_ResultObject_data_seek,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
541 METH_VARARGS,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
542 _mysql_ResultObject_data_seek__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
543 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
544 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
545 "row_seek",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
546 (PyCFunction)_mysql_ResultObject_row_seek,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
547 METH_VARARGS,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
548 _mysql_ResultObject_row_seek__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
549 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
550 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
551 "row_tell",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
552 (PyCFunction)_mysql_ResultObject_row_tell,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
553 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
554 _mysql_ResultObject_row_tell__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
555 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
556 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
557 "describe",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
558 (PyCFunction)_mysql_ResultObject_describe,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
559 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
560 _mysql_ResultObject_describe__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
561 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
562 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
563 "fetch_row",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
564 (PyCFunction)_mysql_ResultObject_fetch_row,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
565 METH_VARARGS | METH_KEYWORDS,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
566 _mysql_ResultObject_fetch_row__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
567 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
568 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
569 "field_flags",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
570 (PyCFunction)_mysql_ResultObject_field_flags,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
571 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
572 _mysql_ResultObject_field_flags__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
573 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
574 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
575 "num_fields",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
576 (PyCFunction)_mysql_ResultObject_num_fields,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
577 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
578 _mysql_ResultObject_num_fields__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
579 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
580 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
581 "num_rows",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
582 (PyCFunction)_mysql_ResultObject_num_rows,
26
9863f08a337c Last of the METH_NOARGS conversions.
kylev
parents: 18
diff changeset
583 METH_NOARGS,
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
584 _mysql_ResultObject_num_rows__doc__
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
585 },
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
586 {NULL, NULL} /* sentinel */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
587 };
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
611 };
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
612
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
613 static PyObject *
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
614 _mysql_ResultObject_getattr(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
615 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
616 char *name)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
617 {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
620
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
621 res = Py_FindMethod(_mysql_ResultObject_methods, (PyObject *)self, name);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
622 if (res != NULL)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
623 return res;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
633 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
634
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
635 static int
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
636 _mysql_ResultObject_setattr(
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
637 _mysql_ResultObject *self,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
638 char *name,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
639 PyObject *v)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
643 if (v == NULL) {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
644 PyErr_SetString(PyExc_AttributeError,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
645 "can't delete connection attributes");
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
646 return -1;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
653 PyErr_SetString(PyExc_AttributeError, name);
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
654 return -1;
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
655 }
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
656
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
657 PyTypeObject _mysql_ResultObject_Type = {
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
658 PyObject_HEAD_INIT(NULL)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
659 0,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
660 "_mysql.result",
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
661 sizeof(_mysql_ResultObject),
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
662 0,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
663 (destructor)_mysql_ResultObject_dealloc, /* tp_dealloc */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
664 0, /*tp_print*/
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
665 (getattrfunc)_mysql_ResultObject_getattr, /* tp_getattr */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
666 (setattrfunc)_mysql_ResultObject_setattr, /* tp_setattr */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
667 0, /*tp_compare*/
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
668 (reprfunc)_mysql_ResultObject_repr, /* tp_repr */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
669
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
670 /* Method suites for standard classes */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
671
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
672 0, /* (PyNumberMethods *) tp_as_number */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
673 0, /* (PySequenceMethods *) tp_as_sequence */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
674 0, /* (PyMappingMethods *) tp_as_mapping */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
675
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
676 /* More standard operations (here for binary compatibility) */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
677
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
678 0, /* (hashfunc) tp_hash */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
679 0, /* (ternaryfunc) tp_call */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
680 0, /* (reprfunc) tp_str */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
681 0, /* (getattrofunc) tp_getattro */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
682 0, /* (setattrofunc) tp_setattro */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
683
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
684 /* Functions to access object as input/output buffer */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
685 0, /* (PyBufferProcs *) tp_as_buffer */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
686
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
687 /* Flags to define presence of optional/expanded features */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
688 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
689
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
690 _mysql_ResultObject__doc__, /* (char *) tp_doc Documentation string */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
691 /* call function for all accessible objects */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
692 (traverseproc)_mysql_ResultObject_traverse, /* tp_traverse */
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
693 /* delete references to contained objects */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
694 (inquiry)_mysql_ResultObject_clear, /* tp_clear */
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
695
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
696 /* rich comparisons */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
697 0, /* (richcmpfunc) tp_richcompare */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
698
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
699 /* weak reference enabler */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
700 0, /* (long) tp_weaklistoffset */
45
28e9be1ca559 Remove more pre-py2.3 ifdef workarounds
kylev
parents: 44
diff changeset
701
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
702 /* Iterators */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
703 0, /* (getiterfunc) tp_iter */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
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
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
709 0, /* (struct getsetlist *) tp_getset; */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
710 0, /* (struct _typeobject *) tp_base; */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
711 0, /* (PyObject *) tp_dict */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
712 0, /* (descrgetfunc) tp_descr_get */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
713 0, /* (descrsetfunc) tp_descr_set */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
714 0, /* (long) tp_dictoffset */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
715 (initproc)_mysql_ResultObject_Initialize, /* tp_init */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
716 NULL, /* tp_alloc */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
717 NULL, /* tp_new */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
718 NULL, /* tp_free Low-level free-memory routine */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
719 0, /* (PyObject *) tp_bases */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
720 0, /* (PyObject *) tp_mro method resolution order */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
721 0, /* (PyObject *) tp_defined */
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
722 };