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

Function env_create_db

python/src/python.cc:233–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231construct_cursor(PyObject *self, PyObject *args);
232
233static PyObject *
234env_create_db(UpsEnvironment *self, PyObject *args)
235{
236 ups_status_t st;
237 int name = 0;
238 uint32_t flags = 0;
239 PyObject *extargs = 0;
240 std::vector<ups_parameter_t> params;
241
242 if (!PyArg_ParseTuple(args, "i|iO!:create_db", &name, &flags,
243 &PyTuple_Type, &extargs))
244 return (0);
245
246 if (extargs) {
247 if (!parse_parameters(extargs, params))
248 return (0);
249 }
250
251 UpsDatabase *db = (UpsDatabase *)construct_db(0, 0);
252 if (!db)
253 return (0);
254
255 st = ups_env_create_db(self->env, &db->db, (uint16_t)name, flags,
256 extargs ? &params[0] : 0);
257 if (st) {
258 db_dealloc(db);
259 THROW(st);
260 }
261
262 db->flags = flags;
263 ups_set_context_data(db->db, db);
264
265 /* add the new database to the environment */
266 if (!self->dblist) {
267 self->dblist = PyList_New(10);
268 if (!self->dblist)
269 return (0);
270 }
271 if (PyList_Append(self->dblist, (PyObject *)db))
272 return (0);
273 Py_INCREF(db);
274
275 return ((PyObject *)db);
276}
277
278static PyObject *
279env_open_db(UpsEnvironment *self, PyObject *args)

Callers

nothing calls this directly

Calls 3

parse_parametersFunction · 0.85
construct_dbFunction · 0.85
db_deallocFunction · 0.85

Tested by

no test coverage detected