sqlite_open_v2 requires sqlite3_close_v2 (I think, not really clear).
This commit is contained in:
parent
446cf2eb05
commit
f492f9bf6e
1 changed files with 4 additions and 8 deletions
|
@ -21,7 +21,7 @@ static naGhostType StmtType = { (void(*)(void*))stmtDestroy, "sqlite_statement"
|
||||||
|
|
||||||
static void dbDestroy(struct DBGhost* g)
|
static void dbDestroy(struct DBGhost* g)
|
||||||
{
|
{
|
||||||
if(g->db) sqlite3_close(g->db);
|
if(g->db) sqlite3_close_v2(g->db);
|
||||||
g->db = 0;
|
g->db = 0;
|
||||||
free(g);
|
free(g);
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,7 @@ static naRef f_open(naContext c, naRef me, int argc, naRef* args)
|
||||||
g = (DBGhost*)malloc(sizeof(struct DBGhost));
|
g = (DBGhost*)malloc(sizeof(struct DBGhost));
|
||||||
|
|
||||||
const auto path = SGPath::fromUtf8(naStr_data(args[0]));
|
const auto path = SGPath::fromUtf8(naStr_data(args[0]));
|
||||||
if (!path.exists()) {
|
const SGPath filename = SGPath(path).validate(true);
|
||||||
return naNil();
|
|
||||||
}
|
|
||||||
|
|
||||||
const SGPath filename = SGPath(path).validate(false);
|
|
||||||
if (filename.isNull()) {
|
if (filename.isNull()) {
|
||||||
SG_LOG(SG_NASAL, SG_ALERT, "stat(): reading '" <<
|
SG_LOG(SG_NASAL, SG_ALERT, "stat(): reading '" <<
|
||||||
naStr_data(args[0]) << "' denied (unauthorized directory - authorization"
|
naStr_data(args[0]) << "' denied (unauthorized directory - authorization"
|
||||||
|
@ -60,7 +56,7 @@ static naRef f_open(naContext c, naRef me, int argc, naRef* args)
|
||||||
if(sqlite3_open_v2(pathUtf8.c_str(), &g->db, openFlags, NULL))
|
if(sqlite3_open_v2(pathUtf8.c_str(), &g->db, openFlags, NULL))
|
||||||
{
|
{
|
||||||
const char* msg = sqlite3_errmsg(g->db);
|
const char* msg = sqlite3_errmsg(g->db);
|
||||||
sqlite3_close(g->db);
|
sqlite3_close_v2(g->db);
|
||||||
free(g);
|
free(g);
|
||||||
naRuntimeError(c, "sqlite open error: %s", msg);
|
naRuntimeError(c, "sqlite open error: %s", msg);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +68,7 @@ static naRef f_close(naContext c, naRef me, int argc, naRef* args)
|
||||||
{
|
{
|
||||||
struct DBGhost* g = argc > 0 ? DBG(args[0]) : 0;
|
struct DBGhost* g = argc > 0 ? DBG(args[0]) : 0;
|
||||||
if(!g) naRuntimeError(c, "bad/missing argument to sqlite.close");
|
if(!g) naRuntimeError(c, "bad/missing argument to sqlite.close");
|
||||||
sqlite3_close(g->db);
|
sqlite3_close_v2(g->db);
|
||||||
g->db = 0;
|
g->db = 0;
|
||||||
return naNil();
|
return naNil();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue