Merged changes from standalone version 2.3.3. This should probably all be
merged into the 2.5 maintenance branch:

- self->statement was not checked while fetching data, which could
  lead to crashes if you used the pysqlite API in unusual ways.
  Closing the cursor and continuing to fetch data was enough.

- Converters are stored in a converters dictionary. The converter name
  is uppercased first. The old upper-casing algorithm was wrong and
  was replaced by a simple call to the Python string's upper() method
  instead.

-Applied patch by Glyph Lefkowitz that fixes the problem with
 subsequent SQLITE_SCHEMA errors.

- Improvement to the row type: rows can now be iterated over and have a keys()
  method. This improves compatibility with both tuple and dict a lot.

- A bugfix for the subsecond resolution in timestamps.

- Corrected the way the flags PARSE_DECLTYPES and PARSE_COLNAMES are
  checked for. Now they work as documented.

- gcc on Linux sucks. It exports all symbols by default in shared
  libraries, so if symbols are not unique it can lead to problems with
  symbol lookup.  pysqlite used to crash under Apache when mod_cache
  was enabled because both modules had the symbol cache_init. I fixed
  this by applying the prefix pysqlite_ almost everywhere. Sigh.
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index 80b6135..7cfcfc3 100644
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -25,7 +25,7 @@
 #include "cursor.h"
 #include "sqlitecompat.h"
 
-void row_dealloc(Row* self)
+void pysqlite_row_dealloc(pysqlite_Row* self)
 {
     Py_XDECREF(self->data);
     Py_XDECREF(self->description);
@@ -33,10 +33,10 @@
     self->ob_type->tp_free((PyObject*)self);
 }
 
-int row_init(Row* self, PyObject* args, PyObject* kwargs)
+int pysqlite_row_init(pysqlite_Row* self, PyObject* args, PyObject* kwargs)
 {
     PyObject* data;
-    Cursor* cursor;
+    pysqlite_Cursor* cursor;
 
     self->data = 0;
     self->description = 0;
@@ -45,7 +45,7 @@
         return -1;
     }
 
-    if (!PyObject_IsInstance((PyObject*)cursor, (PyObject*)&CursorType)) {
+    if (!PyObject_IsInstance((PyObject*)cursor, (PyObject*)&pysqlite_CursorType)) {
         PyErr_SetString(PyExc_TypeError, "instance of cursor required for first argument");
         return -1;
     }
@@ -64,7 +64,7 @@
     return 0;
 }
 
-PyObject* row_subscript(Row* self, PyObject* idx)
+PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
 {
     long _idx;
     char* key;
@@ -133,32 +133,63 @@
     }
 }
 
-Py_ssize_t row_length(Row* self, PyObject* args, PyObject* kwargs)
+Py_ssize_t pysqlite_row_length(pysqlite_Row* self, PyObject* args, PyObject* kwargs)
 {
     return PyTuple_GET_SIZE(self->data);
 }
 
-static int row_print(Row* self, FILE *fp, int flags)
+PyObject* pysqlite_row_keys(pysqlite_Row* self, PyObject* args, PyObject* kwargs)
+{
+    PyObject* list;
+    int nitems, i;
+
+    list = PyList_New(0);
+    if (!list) {
+        return NULL;
+    }
+    nitems = PyTuple_Size(self->description);
+
+    for (i = 0; i < nitems; i++) {
+        if (PyList_Append(list, PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0)) != 0) {
+            Py_DECREF(list);
+            return NULL;
+        }
+    }
+
+    return list;
+}
+
+static int pysqlite_row_print(pysqlite_Row* self, FILE *fp, int flags)
 {
     return (&PyTuple_Type)->tp_print(self->data, fp, flags);
 }
 
+static PyObject* pysqlite_iter(pysqlite_Row* self)
+{
+    return PyObject_GetIter(self->data);
+}
 
-PyMappingMethods row_as_mapping = {
-    /* mp_length        */ (lenfunc)row_length,
-    /* mp_subscript     */ (binaryfunc)row_subscript,
+PyMappingMethods pysqlite_row_as_mapping = {
+    /* mp_length        */ (lenfunc)pysqlite_row_length,
+    /* mp_subscript     */ (binaryfunc)pysqlite_row_subscript,
     /* mp_ass_subscript */ (objobjargproc)0,
 };
 
+static PyMethodDef pysqlite_row_methods[] = {
+    {"keys", (PyCFunction)pysqlite_row_keys, METH_NOARGS,
+        PyDoc_STR("Returns the keys of the row.")},
+    {NULL, NULL}
+};
 
-PyTypeObject RowType = {
+
+PyTypeObject pysqlite_RowType = {
         PyObject_HEAD_INIT(NULL)
         0,                                              /* ob_size */
         MODULE_NAME ".Row",                             /* tp_name */
-        sizeof(Row),                                    /* tp_basicsize */
+        sizeof(pysqlite_Row),                           /* tp_basicsize */
         0,                                              /* tp_itemsize */
-        (destructor)row_dealloc,                        /* tp_dealloc */
-        (printfunc)row_print,                           /* tp_print */
+        (destructor)pysqlite_row_dealloc,               /* tp_dealloc */
+        (printfunc)pysqlite_row_print,                  /* tp_print */
         0,                                              /* tp_getattr */
         0,                                              /* tp_setattr */
         0,                                              /* tp_compare */
@@ -174,13 +205,13 @@
         0,                                              /* tp_as_buffer */
         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,         /* tp_flags */
         0,                                              /* tp_doc */
-        0,                                              /* tp_traverse */
+        (traverseproc)0,                                /* tp_traverse */
         0,                                              /* tp_clear */
         0,                                              /* tp_richcompare */
         0,                                              /* tp_weaklistoffset */
-        0,                                              /* tp_iter */
+        (getiterfunc)pysqlite_iter,                     /* tp_iter */
         0,                                              /* tp_iternext */
-        0,                                              /* tp_methods */
+        pysqlite_row_methods,                           /* tp_methods */
         0,                                              /* tp_members */
         0,                                              /* tp_getset */
         0,                                              /* tp_base */
@@ -188,15 +219,15 @@
         0,                                              /* tp_descr_get */
         0,                                              /* tp_descr_set */
         0,                                              /* tp_dictoffset */
-        (initproc)row_init,                             /* tp_init */
+        (initproc)pysqlite_row_init,                    /* tp_init */
         0,                                              /* tp_alloc */
         0,                                              /* tp_new */
         0                                               /* tp_free */
 };
 
-extern int row_setup_types(void)
+extern int pysqlite_row_setup_types(void)
 {
-    RowType.tp_new = PyType_GenericNew;
-    RowType.tp_as_mapping = &row_as_mapping;
-    return PyType_Ready(&RowType);
+    pysqlite_RowType.tp_new = PyType_GenericNew;
+    pysqlite_RowType.tp_as_mapping = &pysqlite_row_as_mapping;
+    return PyType_Ready(&pysqlite_RowType);
 }