| 1 | Index: setup.py |
| 2 | =================================================================== |
| 3 | --- setup.py.orig |
| 4 | +++ setup.py |
| 5 | @@ -782,7 +782,7 @@ class PyBuildExt(build_ext): |
| 6 | # a release. Most open source OSes come with one or more |
| 7 | # versions of BerkeleyDB already installed. |
| 8 | |
| 9 | - max_db_ver = (4, 7) |
| 10 | + max_db_ver = (4, 8) |
| 11 | min_db_ver = (3, 3) |
| 12 | db_setup_debug = False # verbose debug prints from this script? |
| 13 | |
| 14 | Index: Modules/_bsddb.c |
| 15 | =================================================================== |
| 16 | --- Modules/_bsddb.c.orig |
| 17 | +++ Modules/_bsddb.c |
| 18 | @@ -1417,6 +1417,62 @@ _db_associateCallback(DB* db, const DBT* |
| 19 | PyErr_Print(); |
| 20 | } |
| 21 | } |
| 22 | +#if (DBVER >= 46) |
| 23 | + else if (PyList_Check(result)) |
| 24 | + { |
| 25 | + char* data; |
| 26 | + Py_ssize_t size; |
| 27 | + int i, listlen; |
| 28 | + DBT* dbts; |
| 29 | + |
| 30 | + listlen = PyList_Size(result); |
| 31 | + |
| 32 | + dbts = (DBT *)malloc(sizeof(DBT) * listlen); |
| 33 | + |
| 34 | + for (i=0; i<listlen; i++) |
| 35 | + { |
| 36 | + if (!PyBytes_Check(PyList_GetItem(result, i))) |
| 37 | + { |
| 38 | + PyErr_SetString( |
| 39 | + PyExc_TypeError, |
| 40 | +#if (PY_VERSION_HEX < 0x03000000) |
| 41 | +"The list returned by DB->associate callback should be a list of strings."); |
| 42 | +#else |
| 43 | +"The list returned by DB->associate callback should be a list of bytes."); |
| 44 | +#endif |
| 45 | + PyErr_Print(); |
| 46 | + } |
| 47 | + |
| 48 | + PyBytes_AsStringAndSize( |
| 49 | + PyList_GetItem(result, i), |
| 50 | + &data, &size); |
| 51 | + |
| 52 | + CLEAR_DBT(dbts[i]); |
| 53 | + dbts[i].data = malloc(size); /* TODO, check this */ |
| 54 | + |
| 55 | + if (dbts[i].data) |
| 56 | + { |
| 57 | + memcpy(dbts[i].data, data, size); |
| 58 | + dbts[i].size = size; |
| 59 | + dbts[i].ulen = dbts[i].size; |
| 60 | + dbts[i].flags = DB_DBT_APPMALLOC; /* DB will free */ |
| 61 | + } |
| 62 | + else |
| 63 | + { |
| 64 | + PyErr_SetString(PyExc_MemoryError, |
| 65 | + "malloc failed in _db_associateCallback (list)"); |
| 66 | + PyErr_Print(); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + CLEAR_DBT(*secKey); |
| 71 | + |
| 72 | + secKey->data = dbts; |
| 73 | + secKey->size = listlen; |
| 74 | + secKey->flags = DB_DBT_APPMALLOC | DB_DBT_MULTIPLE; |
| 75 | + retval = 0; |
| 76 | + } |
| 77 | +#endif |
| 78 | else { |
| 79 | PyErr_SetString( |
| 80 | PyExc_TypeError, |
| 81 | @@ -4501,7 +4557,11 @@ DBEnv_txn_recover(DBEnvObject* self) |
| 82 | DBTxnObject *txn; |
| 83 | #define PREPLIST_LEN 16 |
| 84 | DB_PREPLIST preplist[PREPLIST_LEN]; |
| 85 | +#if (DBVER < 48) || (DBVER >= 52) |
| 86 | long retp; |
| 87 | +#else |
| 88 | + u_int32_t retp; |
| 89 | +#endif |
| 90 | |
| 91 | CHECK_ENV_NOT_CLOSED(self); |
| 92 | |
| 93 | @@ -4522,7 +4582,7 @@ DBEnv_txn_recover(DBEnvObject* self) |
| 94 | flags=DB_NEXT; /* Prepare for next loop pass */ |
| 95 | for (i=0; i<retp; i++) { |
| 96 | gid=PyBytes_FromStringAndSize((char *)(preplist[i].gid), |
| 97 | - DB_XIDDATASIZE); |
| 98 | + DB_GID_SIZE); |
| 99 | if (!gid) { |
| 100 | Py_DECREF(list); |
| 101 | return NULL; |
| 102 | @@ -5046,7 +5106,7 @@ DBEnv_set_private(DBEnvObject* self, PyO |
| 103 | RETURN_NONE(); |
| 104 | } |
| 105 | |
| 106 | - |
| 107 | +#if (DBVER < 48) |
| 108 | static PyObject* |
| 109 | DBEnv_set_rpc_server(DBEnvObject* self, PyObject* args, PyObject* kwargs) |
| 110 | { |
| 111 | @@ -5068,6 +5128,7 @@ DBEnv_set_rpc_server(DBEnvObject* self, |
| 112 | RETURN_IF_ERR(); |
| 113 | RETURN_NONE(); |
| 114 | } |
| 115 | +#endif |
| 116 | |
| 117 | static PyObject* |
| 118 | DBEnv_set_verbose(DBEnvObject* self, PyObject* args) |
| 119 | @@ -5949,9 +6010,9 @@ DBTxn_prepare(DBTxnObject* self, PyObjec |
| 120 | if (!PyArg_ParseTuple(args, "s#:prepare", &gid, &gid_size)) |
| 121 | return NULL; |
| 122 | |
| 123 | - if (gid_size != DB_XIDDATASIZE) { |
| 124 | + if (gid_size != DB_GID_SIZE) { |
| 125 | PyErr_SetString(PyExc_TypeError, |
| 126 | - "gid must be DB_XIDDATASIZE bytes long"); |
| 127 | + "gid must be DB_GID_SIZE bytes long"); |
| 128 | return NULL; |
| 129 | } |
| 130 | |
| 131 | @@ -6541,8 +6602,10 @@ static PyMethodDef DBEnv_methods[] = { |
| 132 | #endif |
| 133 | {"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS}, |
| 134 | {"txn_recover", (PyCFunction)DBEnv_txn_recover, METH_NOARGS}, |
| 135 | +#if (DBVER < 48) |
| 136 | {"set_rpc_server", (PyCFunction)DBEnv_set_rpc_server, |
| 137 | - METH_VARARGS||METH_KEYWORDS}, |
| 138 | + METH_VARARGS|METH_KEYWORDS}, |
| 139 | +#endif |
| 140 | {"set_verbose", (PyCFunction)DBEnv_set_verbose, METH_VARARGS}, |
| 141 | #if (DBVER >= 42) |
| 142 | {"get_verbose", (PyCFunction)DBEnv_get_verbose, METH_VARARGS}, |
| 143 | @@ -7091,14 +7154,17 @@ PyMODINIT_FUNC PyInit__bsddb(void) / |
| 144 | ADD_INT(d, DB_MAX_PAGES); |
| 145 | ADD_INT(d, DB_MAX_RECORDS); |
| 146 | |
| 147 | -#if (DBVER >= 42) |
| 148 | +#if (DBVER >= 42) && (DBVER < 48) |
| 149 | ADD_INT(d, DB_RPCCLIENT); |
| 150 | -#else |
| 151 | +#elif (DBVER < 42) |
| 152 | ADD_INT(d, DB_CLIENT); |
| 153 | /* allow apps to be written using DB_RPCCLIENT on older Berkeley DB */ |
| 154 | _addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT); |
| 155 | #endif |
| 156 | + |
| 157 | +#if (DBVER < 48) |
| 158 | ADD_INT(d, DB_XA_CREATE); |
| 159 | +#endif |
| 160 | |
| 161 | ADD_INT(d, DB_CREATE); |
| 162 | ADD_INT(d, DB_NOMMAP); |
| 163 | @@ -7115,7 +7181,13 @@ PyMODINIT_FUNC PyInit__bsddb(void) / |
| 164 | ADD_INT(d, DB_INIT_TXN); |
| 165 | ADD_INT(d, DB_JOINENV); |
| 166 | |
| 167 | +#if (DBVER >= 48) |
| 168 | + ADD_INT(d, DB_GID_SIZE); |
| 169 | +#else |
| 170 | ADD_INT(d, DB_XIDDATASIZE); |
| 171 | + /* Allow new code to work in old BDB releases */ |
| 172 | + _addIntToDict(d, "DB_GID_SIZE", DB_XIDDATASIZE); |
| 173 | +#endif |
| 174 | |
| 175 | ADD_INT(d, DB_RECOVER); |
| 176 | ADD_INT(d, DB_RECOVER_FATAL); |