Fix GetDbTables

This commit is contained in:
Changhua 2022-10-16 22:08:05 +08:00
parent eb7ace08c1
commit f757c95e0d

View File

@ -73,8 +73,8 @@ typedef int(__cdecl *Sqlite3_finalize)(DWORD *);
static int cbGetTables(void *ret, int argc, char **argv, char **azColName) static int cbGetTables(void *ret, int argc, char **argv, char **azColName)
{ {
wcf::DbTables *tbls = (wcf::DbTables *)ret; wcf::DbTables *tbls = (wcf::DbTables *)ret;
for (int i = 0; i < argc; i++) {
wcf::DbTable *tbl = tbls->add_tables(); wcf::DbTable *tbl = tbls->add_tables();
for (int i = 0; i < argc; i++) {
if (strcmp(azColName[i], "name") == 0) { if (strcmp(azColName[i], "name") == 0) {
tbl->set_name(argv[i] ? argv[i] : ""); tbl->set_name(argv[i] ? argv[i] : "");
} else if (strcmp(azColName[i], "sql") == 0) { } else if (strcmp(azColName[i], "sql") == 0) {
@ -106,7 +106,6 @@ dbMap_t GetDbHandles()
return dbMap; return dbMap;
} }
void GetDbNames(wcf::DbNames *names) void GetDbNames(wcf::DbNames *names)
{ {
if (dbMap.empty()) { if (dbMap.empty()) {
@ -130,7 +129,7 @@ void GetDbTables(const string db, wcf::DbTables* tables)
return; // DB not found return; // DB not found
} }
const char *sql = "select * from sqlite_master where type=\"table\";"; const char *sql = "select name, sql from sqlite_master where type=\"table\";";
Sqlite3_exec p_Sqlite3_exec = (Sqlite3_exec)(g_WeChatWinDllAddr + g_WxCalls.sql.exec); Sqlite3_exec p_Sqlite3_exec = (Sqlite3_exec)(g_WeChatWinDllAddr + g_WxCalls.sql.exec);
p_Sqlite3_exec(it->second, sql, (sqlite3_callback)cbGetTables, tables, 0); p_Sqlite3_exec(it->second, sql, (sqlite3_callback)cbGetTables, tables, 0);