MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / init_db_funcs

Function init_db_funcs

lua/sp.c:5046–5081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5044};
5045
5046static void init_db_funcs(Lua L)
5047{
5048 db_t *db = lua_newuserdata(L, sizeof(db_t));
5049 init_new_t(db, DBTYPES_DB);
5050
5051 luaL_newmetatable(L, dbtypes.db);
5052
5053 lua_pushinteger(L, CDB2__ERROR_CODE__DUP_OLD);
5054 lua_setfield(L, -2, "err_dup");
5055
5056 lua_pushinteger(L, CDB2ERR_VERIFY_ERROR);
5057 lua_setfield(L, -2, "err_verify");
5058
5059 lua_pushinteger(L, CDB2ERR_FKEY_VIOLATION);
5060 lua_setfield(L, -2, "err_fkey");
5061
5062 lua_pushinteger(L, CDB2ERR_NULL_CONSTRAINT);
5063 lua_setfield(L, -2, "err_null_constraint");
5064
5065 lua_pushinteger(L, CDB2ERR_CONSTRAINTS);
5066 lua_setfield(L, -2, "err_selectv");
5067
5068 lua_pushinteger(L, CDB2ERR_CONV_FAIL);
5069 lua_setfield(L, -2, "err_conv");
5070
5071 lua_pushinteger(L, CDB2ERR_CHECK_CONSTRAINT);
5072 lua_setfield(L, -2, "err_check_constraint");
5073
5074 lua_pushstring(L, "__index");
5075 lua_pushvalue(L, -2);
5076 lua_settable(L, -3); // db.metatable.__index = db.metatable
5077 luaL_openlib(L, NULL, db_funcs, 0);
5078
5079 lua_setmetatable(L, -2);
5080 lua_setglobal(L, "db");
5081}
5082
5083static void init_dbtable_funcs(Lua L)
5084{

Callers 1

create_sp_intFunction · 0.85

Calls 8

lua_newuserdataFunction · 0.85
luaL_newmetatableFunction · 0.85
lua_pushintegerFunction · 0.85
lua_setfieldFunction · 0.85
lua_pushstringFunction · 0.85
lua_pushvalueFunction · 0.85
lua_settableFunction · 0.85
lua_setmetatableFunction · 0.85

Tested by

no test coverage detected