MCPcopy Create free account
hub / github.com/cuberite/cuberite / db_progress_handler

Function db_progress_handler

lib/sqlite/lsqlite3.c:1473–1504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1471}
1472
1473static int db_progress_handler(lua_State *L) {
1474 sdb *db = lsqlite_checkdb(L, 1);
1475
1476 if (lua_gettop(L) < 2 || lua_isnil(L, 2)) {
1477 luaL_unref(L, LUA_REGISTRYINDEX, db->progress_cb);
1478 luaL_unref(L, LUA_REGISTRYINDEX, db->progress_udata);
1479
1480 db->progress_cb =
1481 db->progress_udata = LUA_NOREF;
1482
1483 /* clear busy handler */
1484 sqlite3_progress_handler(db->db, 0, NULL, NULL);
1485 }
1486 else {
1487 int nop = luaL_checkint(L, 2); /* number of opcodes */
1488 luaL_checktype(L, 3, LUA_TFUNCTION);
1489
1490 /* make sure we have an userdata field (even if nil) */
1491 lua_settop(L, 4);
1492
1493 luaL_unref(L, LUA_REGISTRYINDEX, db->progress_cb);
1494 luaL_unref(L, LUA_REGISTRYINDEX, db->progress_udata);
1495
1496 db->progress_udata = luaL_ref(L, LUA_REGISTRYINDEX);
1497 db->progress_cb = luaL_ref(L, LUA_REGISTRYINDEX);
1498
1499 /* set progress callback */
1500 sqlite3_progress_handler(db->db, nop, db_progress_callback, db);
1501 }
1502
1503 return 0;
1504}
1505
1506#else /* #if !defined(SQLITE_OMIT_PROGRESS_CALLBACK) || !SQLITE_OMIT_PROGRESS_CALLBACK */
1507

Callers

nothing calls this directly

Calls 7

lsqlite_checkdbFunction · 0.85
lua_gettopFunction · 0.85
luaL_unrefFunction · 0.85
luaL_checktypeFunction · 0.85
lua_settopFunction · 0.85
luaL_refFunction · 0.85
lua_errorFunction · 0.85

Tested by

no test coverage detected