MCPcopy Create free account
hub / github.com/cruppstahl/upscaledb / env_open_db

Function env_open_db

python/src/python.cc:278–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278static PyObject *
279env_open_db(UpsEnvironment *self, PyObject *args)
280{
281 ups_status_t st;
282 int name = 0;
283 uint32_t flags = 0;
284 PyObject *extargs = 0;
285 std::vector<ups_parameter_t> params; /* should be enough */
286
287 if (!PyArg_ParseTuple(args, "i|iO!:open_db", &name, &flags,
288 &PyTuple_Type, &extargs))
289 return (0);
290
291 if (extargs) {
292 if (!parse_parameters(extargs, params))
293 return (0);
294 }
295
296 UpsDatabase *db = (UpsDatabase *)construct_db(0, 0);
297 if (!db)
298 return (0);
299
300 ups_set_context_data(db->db, db);
301
302 st = ups_env_open_db(self->env, &db->db, (uint16_t)name, flags,
303 extargs ? &params[0] : 0);
304 if (st) {
305 db_dealloc(db);
306 THROW(st);
307 }
308
309 ups_parameter_t flag_params[] = {
310 {UPS_PARAM_FLAGS, 0},
311 {0, 0}
312 };
313 ups_db_get_parameters(db->db, &flag_params[0]);
314 db->flags = (uint32_t)flag_params[0].value;
315
316 /* add the new database to the environment */
317 if (!self->dblist) {
318 self->dblist = PyList_New(10);
319 if (!self->dblist)
320 return (0);
321 }
322 if (PyList_Append(self->dblist, (PyObject *)db))
323 return (0);
324 Py_INCREF(db);
325
326 return ((PyObject *)db);
327}
328
329static PyObject *
330env_rename_db(UpsEnvironment *self, PyObject *args)

Callers

nothing calls this directly

Calls 4

parse_parametersFunction · 0.85
construct_dbFunction · 0.85
db_deallocFunction · 0.85
ups_db_get_parametersFunction · 0.85

Tested by

no test coverage detected