33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
static const char schema[]=
"BEGIN;"
"PRAGMA APPLICATION_ID(1296388936);"
"PRAGMA RECURSIVE_TRIGGERS(1);"
"CREATE TABLE IF NOT EXISTS `USERCACHEINDEX`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `TIME` INT);"
"CREATE TABLE IF NOT EXISTS `USERCACHEDATA`(`ID` INTEGER PRIMARY KEY, `FILE` INT, `LEVEL` INT, `NAME` TEXT COLLATE NOCASE, `OFFSET` INT, `DATA` BLOB, `USERSTATE` BLOB);"
"CREATE UNIQUE INDEX IF NOT EXISTS `USERCACHEDATA_I1` ON `USERCACHEDATA`(`FILE`, `LEVEL`);"
"CREATE TEMPORARY TABLE `PICTURES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT COLLATE NOCASE, `OFFSET` INT, `DEPENDENT` INT);"
"CREATE TEMPORARY TABLE `VARIABLES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT);"
"COMMIT;"
;
sqlite3*userdb;
xrm_db*resourcedb;
|
>
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
static const char schema[]=
"BEGIN;"
"PRAGMA APPLICATION_ID(1296388936);"
"PRAGMA RECURSIVE_TRIGGERS(1);"
"CREATE TABLE IF NOT EXISTS `USERCACHEINDEX`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `TIME` INT);"
"CREATE TABLE IF NOT EXISTS `USERCACHEDATA`(`ID` INTEGER PRIMARY KEY, `FILE` INT, `LEVEL` INT, `NAME` TEXT COLLATE NOCASE, `OFFSET` INT, `DATA` BLOB, `USERSTATE` BLOB);"
"CREATE UNIQUE INDEX IF NOT EXISTS `USERCACHEDATA_I1` ON `USERCACHEDATA`(`FILE`, `LEVEL`);"
"CREATE TRIGGER IF NOT EXISTS `USERCACHEINDEX_DELETION` AFTER DELETE ON `USERCACHEINDEX` BEGIN DELETE FROM `USERCACHEDATA` WHERE `FILE` = OLD.`ID`; END;"
"CREATE TEMPORARY TABLE `PICTURES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT COLLATE NOCASE, `OFFSET` INT, `DEPENDENT` INT);"
"CREATE TEMPORARY TABLE `VARIABLES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT);"
"COMMIT;"
;
sqlite3*userdb;
xrm_db*resourcedb;
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
static char*hpath;
static sqlite3_int64 reset_usercache(FILE*fp,const char*nam,struct stat*stats,const char*suffix) {
sqlite3_stmt*st;
sqlite3_int64 t,id;
char buf[128];
int i,z;
if(z=sqlite3_prepare_v2(userdb,"DELETE FROM `USERCACHEDATA` WHERE `FILE` = (SELECT `ID` FROM `USERCACHEINDEX` WHERE `NAME` = ?1);",-1,&st,0)) {
fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb));
}
sqlite3_bind_text(st,1,nam,-1,0);
while((z=sqlite3_step(st))==SQLITE_ROW);
if(z!=SQLITE_DONE) fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb));
sqlite3_finalize(st);
if(z=sqlite3_prepare_v2(userdb,"DELETE FROM `USERCACHEINDEX` WHERE `NAME` = ?1;",-1,&st,0)) fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb));
sqlite3_bind_text(st,1,nam,-1,0);
while((z=sqlite3_step(st))==SQLITE_ROW);
if(z!=SQLITE_DONE) fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb));
sqlite3_finalize(st);
t=stats->st_mtime;
if(stats->st_ctime>t) t=stats->st_ctime;
|
<
<
<
<
<
<
<
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
static char*hpath;
static sqlite3_int64 reset_usercache(FILE*fp,const char*nam,struct stat*stats,const char*suffix) {
sqlite3_stmt*st;
sqlite3_int64 t,id;
char buf[128];
int i,z;
if(z=sqlite3_prepare_v2(userdb,"DELETE FROM `USERCACHEINDEX` WHERE `NAME` = ?1;",-1,&st,0)) fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb));
sqlite3_bind_text(st,1,nam,-1,0);
while((z=sqlite3_step(st))==SQLITE_ROW);
if(z!=SQLITE_DONE) fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb));
sqlite3_finalize(st);
t=stats->st_mtime;
if(stats->st_ctime>t) t=stats->st_ctime;
|