mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-08 02:40:28 +00:00
Add database readonly check to redbean sqlite
This commit is contained in:
parent
6cc9fc32d6
commit
b7a4c89fc8
1 changed files with 10 additions and 0 deletions
|
@ -920,6 +920,15 @@ static int pusherrstr(lua_State *L, char *str) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int db_readonly(lua_State *L) {
|
||||||
|
sdb *db = lsqlite_checkdb(L, 1);
|
||||||
|
const char *zDb = luaL_optstring(L, 2, "main");
|
||||||
|
int res = sqlite3_db_readonly(db->db, zDb);
|
||||||
|
if (res == -1) return pusherrstr(L, "unknown (not attached) database name");
|
||||||
|
lua_pushboolean(L, res);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int db_wal_checkpoint(lua_State *L) {
|
static int db_wal_checkpoint(lua_State *L) {
|
||||||
sdb *db = lsqlite_checkdb(L, 1);
|
sdb *db = lsqlite_checkdb(L, 1);
|
||||||
int eMode = luaL_optinteger(L, 2, SQLITE_CHECKPOINT_PASSIVE);
|
int eMode = luaL_optinteger(L, 2, SQLITE_CHECKPOINT_PASSIVE);
|
||||||
|
@ -2612,6 +2621,7 @@ static const struct {
|
||||||
|
|
||||||
static const luaL_Reg dblib[] = {
|
static const luaL_Reg dblib[] = {
|
||||||
{"isopen", db_isopen },
|
{"isopen", db_isopen },
|
||||||
|
{"readonly", db_readonly },
|
||||||
{"last_insert_rowid", db_last_insert_rowid },
|
{"last_insert_rowid", db_last_insert_rowid },
|
||||||
{"changes", db_changes },
|
{"changes", db_changes },
|
||||||
{"total_changes", db_total_changes },
|
{"total_changes", db_total_changes },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue