* Check for module initialization failure (extremely rare)

* The MySQL FIELD_TYPE converter can now be a sequence of 2-tuples.
   Item 0 is a bit mask (using FLAG.*) which must be matched. This should
   be an integer. Item 1 is the conversion function. If item 0 is not an
   integer, then this function is considered the default converter for
   this FIELD_TYPE. Note that these tuples are considered when the query
   has been executed and the result is available, so it doesn't add a
   per-row overhead.

 * As a result of the above, BINARY BLOB fields are now returned as
   character arrays using the array.array class. Non-BINARY BLOB fields
   (i.e. TEXT) are returned as strings. If unicode is enabled, they are
   returned as unicode strings.

 * Bump version to 0.9.3b3.
This commit is contained in:
adustman
2003-12-30 01:30:36 +00:00
parent 37481774b1
commit 59913d32f4
5 changed files with 46 additions and 9 deletions

View File

@ -20,7 +20,7 @@ version_info = (
9, 9,
3, 3,
"beta", "beta",
2) 3)
if version_info[3] == "final": __version__ = "%d.%d.%d" % version_info[:3] if version_info[3] == "final": __version__ = "%d.%d.%d" % version_info[:3]
else: __version__ = "%d.%d.%d%1.1s%d" % version_info[:5] else: __version__ = "%d.%d.%d%1.1s%d" % version_info[:5]

View File

@ -112,6 +112,7 @@ class Connection(ConnectionBase):
u = unicode u = unicode
conv[FIELD_TYPE.STRING] = u conv[FIELD_TYPE.STRING] = u
conv[FIELD_TYPE.VAR_STRING] = u conv[FIELD_TYPE.VAR_STRING] = u
conv[FIELD_TYPE.BLOB].insert(-1, (None, u))
self._make_connection(args, kwargs2) self._make_connection(args, kwargs2)
self.converter[types.StringType] = self.string_literal self.converter[types.StringType] = self.string_literal
if hasattr(types, 'UnicodeType'): if hasattr(types, 'UnicodeType'):

View File

@ -26,7 +26,7 @@ MySQL.connect().
""" """
from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL
from constants import FIELD_TYPE from constants import FIELD_TYPE, FLAG
from sets import * from sets import *
from times import * from times import *
from string import split from string import split
@ -132,6 +132,10 @@ conversions = {
FIELD_TYPE.DATETIME: DateTime_or_None, FIELD_TYPE.DATETIME: DateTime_or_None,
FIELD_TYPE.TIME: Time_or_None, FIELD_TYPE.TIME: Time_or_None,
FIELD_TYPE.DATE: Date_or_None, FIELD_TYPE.DATE: Date_or_None,
FIELD_TYPE.BLOB: [
(FLAG.BINARY, char_array),
(None, None),
],
} }

View File

@ -1,4 +1,4 @@
#define version_info "(0,9,3,'beta',2)" #define version_info "(0,9,3,'beta',3)"
#define __version__ "0.9.3" #define __version__ "0.9.3"
/* /*
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@ -362,6 +362,38 @@ _mysql_ResultObject_Initialize(
fun = Py_None; fun = Py_None;
Py_INCREF(Py_None); Py_INCREF(Py_None);
} }
if (PySequence_Check(fun)) {
int j, n2=PySequence_Size(fun);
PyObject *fun2=NULL;
for (j=0; j<n2; j++) {
PyObject *t = PySequence_GetItem(fun, j);
if (!t) continue;
if (!PyTuple_Check(t)) goto cleanup;
if (PyTuple_GET_SIZE(t) == 2) {
long mask;
PyObject *pmask=NULL;
pmask = PyTuple_GET_ITEM(t, 0);
fun2 = PyTuple_GET_ITEM(t, 1);
if (PyInt_Check(pmask)) {
mask = PyInt_AS_LONG(pmask);
if (mask & fields[i].flags) {
break;
}
else {
continue;
}
} else {
break;
}
}
cleanup:
Py_DECREF(t);
}
if (!fun2) fun2 = Py_None;
Py_INCREF(fun2);
Py_DECREF(fun);
fun = fun2;
}
PyTuple_SET_ITEM(self->converter, i, fun); PyTuple_SET_ITEM(self->converter, i, fun);
} }
return 0; return 0;
@ -2370,7 +2402,7 @@ init_mysql(void)
PyObject *dict, *module, *emod, *edict; PyObject *dict, *module, *emod, *edict;
module = Py_InitModule4("_mysql", _mysql_methods, _mysql___doc__, module = Py_InitModule4("_mysql", _mysql_methods, _mysql___doc__,
(PyObject *)NULL, PYTHON_API_VERSION); (PyObject *)NULL, PYTHON_API_VERSION);
if (!module) return; /* this really should never happen */
_mysql_ConnectionObject_Type.ob_type = &PyType_Type; _mysql_ConnectionObject_Type.ob_type = &PyType_Type;
_mysql_ResultObject_Type.ob_type = &PyType_Type; _mysql_ResultObject_Type.ob_type = &PyType_Type;
#if PY_VERSION_HEX >= 0x02020000 #if PY_VERSION_HEX >= 0x02020000

View File

@ -18,7 +18,7 @@ embedded_server = (mysqlclient == 'mysqld')
name = "MySQL-%s" % os.path.basename(sys.executable) name = "MySQL-%s" % os.path.basename(sys.executable)
if embedded_server: if embedded_server:
name = name + "-embedded" name = name + "-embedded"
version = "0.9.3b2" version = "0.9.3b3"
# include files and library locations should cover most platforms # include files and library locations should cover most platforms
include_dirs = [ include_dirs = [