20.04.2013, 19:53
[Include] SQLite Improved
27.06.2013, 23:09
having a similar problem to ReVo I think:
after it restarted, it wouldn't even properly open the database:
the code:
for now, I just won't use prepared statements.
Works on windows, doesn't work on Linux, www.hostspree.org
Код:
[10:25:27] [debug] Server crashed while executing attdef.amx [10:25:27] [debug] AMX backtrace: [10:25:27] [debug] #0 00005554 in bool:stmt_fetch_row (&DBStatement:stStatement=@0x001f1170) at C:\Users\Dracule\Dropbox\AADeathZone\pawno\include\sqlitei.inc:1724 [10:25:27] [debug] #1 0004a9e4 in public S@@_OnDialogResponse (playerid=0, dialogid=21, response=1, listitem=-1, inputtext[]=@0x001eddf8 "REMOVED PASSWORD") at C:\Users\Dracule\Dropbox\AADeathZone\gamemodes\attdef.pwn:2420 [10:25:27] [debug] Native backtrace: [10:25:27] [debug] #0 f7dbf60b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so [10:25:27] [debug] #1 f7db6e92 in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so [10:25:27] [debug] #2 f7db88d9 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so [10:25:27] [debug] #3 f7dbf2a0 in ?? () from plugins/crashdetect.so [10:25:27] [debug] #4 ffffe600 in ?? () [10:25:27] [debug] #5 f7dc1a27 in amx_Exec () from plugins/crashdetect.so [10:25:27] [debug] #6 f7db8abb in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so [10:25:27] [debug] #7 f7dbb100 in ?? () from plugins/crashdetect.so [10:25:27] [debug] #8 080ae33f in ?? () from /home/tcagame/MaiwandM/148/samp03svr [10:25:27] [debug] #9 080b97da in ?? () from /home/tcagame/MaiwandM/148/samp03svr [10:25:27] [debug] #10 08071ae8 in ?? () from /home/tcagame/MaiwandM/148/samp03svr [10:25:27] [debug] #11 08071be2 in ?? () from /home/tcagame/MaiwandM/148/samp03svr [10:25:27] [debug] #12 0807ba00 in ?? () from /home/tcagame/MaiwandM/148/samp03svr [10:25:27] [debug] #13 080b59ad in ?? () from /home/tcagame/MaiwandM/148/samp03svr [10:25:27] [debug] #14 080b5b42 in ?? () from /home/tcagame/MaiwandM/148/samp03svr [10:25:27] [debug] #15 080b1453 in ?? () from /home/tcagame/MaiwandM/148/samp03svr [10:25:27] [debug] #16 00272ebc in __libc_start_main () from /lib/libc.so.6 [10:25:27] [debug] #17 0804b521 in ?? () from /home/tcagame/MaiwandM/148/samp03svr
Код:
[10:25:29] SQLitei Error: (db_query) Invalid persistent database given (F71EB748). [10:25:29] SQLitei Notice: (db_free_result_hook) Invalid result given. [10:25:29] Server Config Loaded. [10:25:29] SQLitei Error: (db_query) Invalid persistent database given (F71EB748). [10:25:29] SQLitei Notice: (db_free_result_hook) Invalid result given. [10:25:29] Bases Loaded: 0 [10:25:29] SQLitei Error: (db_query) Invalid persistent database given (F71EB748). [10:25:29] Arenas Loaded: 0 [10:25:29] SQLitei Error: (db_query) Invalid persistent database given (F71EB748). [10:25:29] DMs Loaded: 0 [10:25:29] SQLitei Error: (db_query) Invalid persistent database given (F71EB748). [10:25:29] Duels Loaded: 0 [10:25:29] SQLitei Error: (db_query) Invalid persistent database given (F71EB748). [10:25:29] SQLitei Notice: (db_free_result_hook) Invalid result given. [10:25:29] Bases Loaded: 0
pawn Код:
new Query[256];
format(Query, sizeof(Query), "SELECT * FROM `Players` WHERE `Name` = '%s' AND `Password` = '%s'", Player[playerid][Name], HashPass);
new DBStatement:stmt = db_prepare(sqliteconnection, Query);
new level, weather, time, chatchannel, netcheck;
stmt_bind_result_field(stmt, 1, DB::TYPE_STRING, CurrentPassword, sizeof(CurrentPassword));
stmt_bind_result_field(stmt, 2, DB::TYPE_INT, level);
stmt_bind_result_field(stmt, 3, DB::TYPE_INT, weather);
stmt_bind_result_field(stmt, 4, DB::TYPE_INT, time);
stmt_bind_result_field(stmt, 5, DB::TYPE_INT, chatchannel);
stmt_bind_result_field(stmt, 6, DB::TYPE_INT, netcheck);
if(stmt_execute(stmt)) {
if(stmt_fetch_row(stmt)) {
Player[playerid][Level] = level;
Player[playerid][Weather] = weather;
Player[playerid][Time] = time;
Player[playerid][ChatChannel] = chatchannel;
Player[playerid][NetCheck] = netcheck;
Player[playerid][Logged] = true;
SendClientMessage(playerid,-1, "You have successfully logged in.");
format(Query, sizeof(Query), "Level: %d | Weather: %d | Time: %d | Chat Channel: %d | Net Check: %d", level, weather, time, chatchannel, netcheck);
SendClientMessage(playerid, -1, Query);
} else {
SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}Wrong Password. Please try again.");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"{FFFFFF}Login Dialog","{FFFFFF}Type your password below to log in:","Login","Leave");
}
}
stmt_close(stmt);
Works on windows, doesn't work on Linux, www.hostspree.org
28.06.2013, 07:00
Did you use db_open_persistent or just db_open?
I suspect there's a bug when using db_open, which can be worked around by using db_open_persistent.
I suspect there's a bug when using db_open, which can be worked around by using db_open_persistent.
28.06.2013, 07:37
Hmmm nice improvement
12.07.2013, 16:25
What's better? This or BUD?
12.07.2013, 17:33
14.07.2013, 02:39
Awesome slice great
17.07.2013, 13:45
Anyone have tested it using Linux?
Last time i used Linux this include wasn't compatible (cause crash, see my post above).
Last time i used Linux this include wasn't compatible (cause crash, see my post above).
17.07.2013, 13:53
Worked fine when I tested it. Which Linux dist?
17.07.2013, 13:58
Time ago i was with centos (i dont remember if was 5 or 6, but 6 maybe.)
17.08.2013, 04:07
pawn Код:
stock Float:db_get_field_float(DBResult:dbrResult, iField = 0) {
if (dbrResult == DB::INVALID_RESULT) {
DB::Notice("(db_get_field_float) Invalid result given.");
return 0.0;
}
if (!db_num_rows(dbrResult)) {
DB::Notice("(db_get_field_int) Empty result given.");
return 0.0;
}
if (iField < 0 || db_num_fields(dbrResult) <= iField) {
DB::Notice("(db_get_field_int) Given field index doesn't exist in the result.");
return 0.0;
}
db_get_field(dbrResult, iField, gs_szBuffer, sizeof(gs_szBuffer) - 1);
return floatstr(gs_szBuffer);
}
07.10.2013, 08:09
Update!
I finally managed to get error messages from db_query!
To use this, you must download amx_assembly (.zip) and put it with your include files.
After that, define DB_QUERY_ERRORS like this:
It might seem like a simple thing, but here's what I had to do to get it working: https://github.com/oscar-broman/sqli...b7fa2d8658b3b1
I finally managed to get error messages from db_query!
pawn Код:
new DB:db = db_open("test.db");
// no such table: some_table
db_query(db, "SELECT * FROM some_table;");
// No error (or "table test already exists" if you run it again)
db_query(db, "CREATE TABLE test (a, b, c)");
// no such column name: name
db_query(db, "SELECT name FROM test");
// near "bla": syntax error
db_query(db, "SELECT test FRMO bla");
db_close(db);
After that, define DB_QUERY_ERRORS like this:
pawn Код:
#define DB_QUERY_ERRORS true
// automatically print errors (it's true by default)
#define DB_PRINT_ERRORS true
#include <sqlitei>
18.12.2013, 00:40
Excellent include, especially love the prepared statements feature.
18.12.2013, 13:54
good job
22.12.2013, 09:09
So as I understand I don't need to use SQL injection anymore. Correct me if I'm wrong.
Do you have any example of updating data?
Do you have any example of updating data?
16.02.2014, 19:39
Could you add the question marks to db_exec?
Also want to say: Great work Saved me lot of code I was using previously.
Also want to say: Great work Saved me lot of code I was using previously.
03.03.2014, 14:11
Hi there. I'm working on someone's script, and I used sqlitei to get better debug info for now. Well, I started and got something like
Is that because the original writer never freed stuff? No idea yet where from it's coming, but what should I look for?
Quote:
[16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! [16:04:58] SQLitei Warning: (db_autofree_result) The autofree pool is full! |
04.03.2014, 04:27
Quote:
Hi there. I'm working on someone's script, and I used sqlitei to get better debug info for now. Well, I started and got something like
Is that because the original writer never freed stuff? No idea yet where from it's coming, but what should I look for? |
Look for queries executed inside loops.
The easiest way, however, is if you have crashdetect.inc. You could modify sqlitei.inc to print a backtrace here.
04.03.2014, 10:09
I just enabled DB_DEBUG, and yeah, awesome code firing 2k+ queries in a row without freeing them. I wanted to use DB_QUERY_ERRORS, but amx_assembly crashes on my PC (I disabled DEP, but still crash on SysreqD). Still, I'm really grateful for this library, I'll use it always when dealing with sqlite! Thank you
04.03.2014, 11:41
DB_QUERY_ERRORS should work without crashdetect - I think I need to use SysreqC instead.
« Next Oldest | Next Newest »
Users browsing this thread: 8 Guest(s)