[Include] SQLite Improved
#21

Whoop whoop! Minor, yet awesome update: db_get_field/db_get_field_assoc will no longer crash on NULL values!
Reply
#22

Woah, great work. I'll start learning SQLite from now. Keep up the good work and updates.
Reply
#23

awesomnees slice
Reply
#24

Amazing as always, thanks!
Mirror: http://www.lpupak.com/dl/get/sqlitei.inc
Reply
#25

Update!

SQLitei has now taken a big step towards stability!

Highlights:
  • Improved stability on freeing results:
    • Freeing results twice will not crash the server anymore - it will just generate a warning.
    • Freeing a result that will be autoreleased will remove it from the autorelease pool.
  • Added db_query_int and db_query_float.
  • Added db_get_struct_info and db_set_struct_info; used mainly internally.
  • Added db_exec and db_insert.
  • Performance improvements!
Now these things are possible (with very little code):
pawn Код:
new uid = db_insert(db, "INSERT INTO blabla VALUES blabla");

if (uid) {
    // uid is now the index for whatever we just inserted
}
pawn Код:
printf("%d", db_query_int(db, "SELECT COUNT(*) FROM something"));
Reply
#26

Why don't you improve MySQL?
Reply
#27

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
Why don't you improve MySQL?
The MySQL plugins are open-source, anyone can modify them where they should be - within the source code. This is not the case for SQLite, which is why I've decided to do my best in improving it.

@Steven82: Let me know if you run into problems or have any requests. Also, expect a few more updates with new features.
Reply
#28

Quote:
Originally Posted by Slice
Посмотреть сообщение
The MySQL plugins are open-source, anyone can modify them where they should be - within the source code. This is not the case for SQLite, which is why I've decided to do my best in improving it.
For sure you need to have C++ knowlage, isn't it?
Reply
#29

Useful For Sever +rep
Reply
#30

Quote:
Originally Posted by Slice
Посмотреть сообщение
Your script should behave exactly the same way when you include SQLite, and there won't be any significant performance changes.
What are the reasons you need this?
I use this because of the null-crash fix, and my problem was that my script was spamming auto-release when I always release manually.
"The result being freed was inside the autorelease pool"
I disabled it now though.
Reply
#31

Ah, ok, well you could add "false" at the end of your db_query calls to disable autofreeing.
Reply
#32

Is there any tutorial on Login & Register using this include?
Reply
#33

Yeah, there's a demo somewhere in this topic.
Reply
#34

Not bad, might update the LV-RP SQLite GM to this.
Reply
#35

Slice, how can I do this:

pawn Код:
new uid, DBStatement:stmt = db_prepare(trpdb, "SELECT uid FROM users WHERE name=? LIMIT 1");
And then num_rows this? Since it's a prepared statement and I can't see that it would work with "db_num_rows(DBResult:dbresult)" since there is no result in stmt_execute?

So how can I check the number of rows after a prepared statement?
Reply
#36

Use stmt_rows_left.
Reply
#37

pawn Код:
db_last_insert_rowid(DB:db)
]

Crashes the server after doing prepared statement:

pawn Код:
"INSERT INTO staticphones (x,y,z,rz,int,vw,type) VALUES(?,?,?,?,?,?,1)"
Reply
#38

Hm.. Linux or Windows? As a temporary solution, use db_query_int(db, "SELECT last_insert_rowid()").
Reply
#39

Your test code cause a crash on linux

Quote:

[07:24:18] [debug] Server crashed while executing timertest.amx
[07:24:18] [debug] AMX backtrace:
[07:24:18] [debug] #0 00005530 in booltmt_fetch_row (&DBStatementtStatement=@0x00056c90) at [...]\include\sqlitei.inc:1724
[07:24:18] [debug] #1 0000a29c in public OnGameModeInit () at [...]\timertest.pwn:88
[07:24:18] [debug] System backtrace:
[07:24:18] [debug] #0 f71dbecb in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[07:24:18] [debug] #1 f71d3c69 in _ZN11CrashDetect20PrintSystemBacktraceEPv () from plugins/crashdetect.so
[07:24:18] [debug] #2 f71d5c99 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[07:24:18] [debug] #3 f71db9d8 in ?? () from plugins/crashdetect.so
[07:24:18] [debug] #4 ffffe600 in ?? ()
[07:24:18] [debug] #5 f71df3b6 in amx_Exec () from plugins/crashdetect.so
[07:24:18] [debug] #6 f71d5e1e in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so
[07:24:18] [debug] #7 f71d82de in ?? () from plugins/crashdetect.so
[07:24:18] [debug] #8 080acc4b in ?? () from ./samp03svr
[07:24:18] [debug] #9 080b2b3d in ?? () from ./samp03svr
[07:24:18] [debug] #10 080b1407 in ?? () from ./samp03svr
[07:24:18] [debug] #11 004d6ebc in __libc_start_main () from /lib/libc.so.6
[07:24:18] [debug] #12 0804b521 in ?? () from ./samp03svr

Reply
#40

Which test code?
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)