[Plugin] [REL] MySQL Plugin (Now on github!)

  • easier to iterate
  • most efficient way to access them within the plugin
  • consistent with the data retrieval (row indices also start at 0, see previous point why)
This was also like that since R7, that means BlueG made that decision in the end (I'm responsible for this plugin since R8 or so).
Reply

awesome thanks
Reply

Great plugins, works flawlessly.
Reply

is there a way to use OnQueryFinish here?
Reply

Quote:
Originally Posted by DeathKing
Посмотреть сообщение
is there a way to use OnQueryFinish here?
You don't need it anymore. You can add a callback to mysql_tquery which will pass the parameter and works same as like that callback.

pawn Код:
mysql_tquery(DB, "SELECT..........", "ExampleQuery", "s", "example");
forward ExampleQuery(p_name[]);
public ExampleQuery(p_name[])
{
    printf("%s", p_name);
    // prints 'example'
}
Reply

Код:
[16:35:06] [debug] Server crashed due to an unknown error
[16:35:06] [debug] Native backtrace:
[16:35:06] [debug] #0 004c531b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[16:35:06] [debug] #1 004bf7c2 in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[16:35:06] [debug] #2 004c03ac in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[16:35:06] [debug] #3 004c0856 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[16:35:06] [debug] #4 004c4f6c in ?? () from plugins/crashdetect.so
[16:35:06] [debug] #5 00e4a410 in ?? ()
[16:35:06] [debug] #6 003177d6 in ?? () from /lib/libc.so.6
[16:35:06] [debug] #7 00b81be4 in _ZN11CMySQLQuery11StoreResultEP8st_mysqlP12st_mysql_res () from plugins/mysql_static.so
[16:35:06] [debug] #8 00b81fe7 in _ZN11CMySQLQuery7ExecuteEP8st_mysql () from plugins/mysql_static.so
[16:35:06] [debug] #9 00b79384 in _ZN16CMySQLConnection14ProcessQueriesEv () from plugins/mysql_static.so
[16:35:06] [debug] #10 00b79c87 in _ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0Iv16CMySQLConnectionEENS2_5list1INS2_5valueIPS6_EEEEEEE3runEv () from plugins/mysql_static.so
[16:35:06] [debug] #11 00c24b78 in ?? () from plugins/mysql_static.so
[16:35:06] [debug] #12 009dfb39 in ?? () from /lib/libpthread.so.0
[16:35:06] [debug] #13 002c2d6e in clone () from /lib/libc.so.6
What's wrong in my server?
Reply

Quote:
Originally Posted by Aliassassin123456
Посмотреть сообщение
Код:
[16:35:06] [debug] Server crashed due to an unknown error
[16:35:06] [debug] Native backtrace:
[16:35:06] [debug] #0 004c531b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[16:35:06] [debug] #1 004bf7c2 in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[16:35:06] [debug] #2 004c03ac in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[16:35:06] [debug] #3 004c0856 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[16:35:06] [debug] #4 004c4f6c in ?? () from plugins/crashdetect.so
[16:35:06] [debug] #5 00e4a410 in ?? ()
[16:35:06] [debug] #6 003177d6 in ?? () from /lib/libc.so.6
[16:35:06] [debug] #7 00b81be4 in _ZN11CMySQLQuery11StoreResultEP8st_mysqlP12st_mysql_res () from plugins/mysql_static.so
[16:35:06] [debug] #8 00b81fe7 in _ZN11CMySQLQuery7ExecuteEP8st_mysql () from plugins/mysql_static.so
[16:35:06] [debug] #9 00b79384 in _ZN16CMySQLConnection14ProcessQueriesEv () from plugins/mysql_static.so
[16:35:06] [debug] #10 00b79c87 in _ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0Iv16CMySQLConnectionEENS2_5list1INS2_5valueIPS6_EEEEEEE3runEv () from plugins/mysql_static.so
[16:35:06] [debug] #11 00c24b78 in ?? () from plugins/mysql_static.so
[16:35:06] [debug] #12 009dfb39 in ?? () from /lib/libpthread.so.0
[16:35:06] [debug] #13 002c2d6e in clone () from /lib/libc.so.6
What's wrong in my server?
Are you having latest crashdetect plugin, and also this also happens when something is wrong with the query, try using OnQueryError to detect any problem or just enable MySQL debug.
Reply

Quote:
Originally Posted by Aliassassin123456
Посмотреть сообщение
Код:
[16:35:06] [debug] Server crashed due to an unknown error
[16:35:06] [debug] Native backtrace:
[16:35:06] [debug] #0 004c531b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[16:35:06] [debug] #1 004bf7c2 in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[16:35:06] [debug] #2 004c03ac in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[16:35:06] [debug] #3 004c0856 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[16:35:06] [debug] #4 004c4f6c in ?? () from plugins/crashdetect.so
[16:35:06] [debug] #5 00e4a410 in ?? ()
[16:35:06] [debug] #6 003177d6 in ?? () from /lib/libc.so.6
[16:35:06] [debug] #7 00b81be4 in _ZN11CMySQLQuery11StoreResultEP8st_mysqlP12st_mysql_res () from plugins/mysql_static.so
[16:35:06] [debug] #8 00b81fe7 in _ZN11CMySQLQuery7ExecuteEP8st_mysql () from plugins/mysql_static.so
[16:35:06] [debug] #9 00b79384 in _ZN16CMySQLConnection14ProcessQueriesEv () from plugins/mysql_static.so
[16:35:06] [debug] #10 00b79c87 in _ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0Iv16CMySQLConnectionEENS2_5list1INS2_5valueIPS6_EEEEEEE3runEv () from plugins/mysql_static.so
[16:35:06] [debug] #11 00c24b78 in ?? () from plugins/mysql_static.so
[16:35:06] [debug] #12 009dfb39 in ?? () from /lib/libpthread.so.0
[16:35:06] [debug] #13 002c2d6e in clone () from /lib/libc.so.6
What's wrong in my server?
Can you reproduce that issue?

Quote:
Originally Posted by iZN
Посмотреть сообщение
[...]and also this also happens when something is wrong with the query, try using OnQueryError to detect any problem or just enable MySQL debug.
The plugin should NEVER crash, EVERY crash is likely caused by a bug within the plugin, even if the MySQL query is malformed.
Reply

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
The plugin should NEVER crash, EVERY crash is likely caused by a bug within the plugin, even if the MySQL query is malformed.
It crashed for me like 2-3 times because of my mistake related to query. I don't know why. Also, it crashes only on Linux, not on Windows.
Reply

I think i know why the plugin crash, i am always using from mysql_tquery, i call some queries per second for every player and i have +70 players, when i remove some of them, my server crashed again but, before this update server was crash very fast... my server was works perfectly i check everything and i found why plugin crashed, THE PROBLEM IS FROM PLUGIN, when i want to call a simple query: UPDATE `users` SET pCash='x' WHERE pName='x'; sometimes server crash... i hope anyone help me before i lost all of my players
Reply

Quote:
Originally Posted by dusk
Посмотреть сообщение
Speaking of parallel queries. Could you give me a scenario where they might be useful?
You could speed up the data fetching in the gamemode initialization stage with parallel queries, like
Код:
public OnGameModeInit
{
	[...]
	mysql_pquery(g_SQL, "SELECT * FROM vehicles", "OnVehiclesLoad");
	mysql_pquery(g_SQL, "SELECT * FROM houses", "OnHousesLoad");
	//other systems
	[...]
	return 1;
}
or you can speed up updating many rows, e. g. saving all player data before a server restart (maybe MySQL transactions are even faster in that case, I should check this when I'll have the time).

Parallel queries are mainly there for faster query execution.
Reply

But when someone has something like a UCP, the player must quit the game or he must wait for crash to he see his informations? I think plugin must not crash when we entered some query, server was work perfectly for 2 weeks, but after 2 week, without ANY UPDATE Server crashed, i test mysql R37 and this is crashed too ... i am using mysql_static, My server crashed, crashed, crashed ....
Edit: I think the problem should be for mysql_static.so and i think mysql.so hasen't any problem because server was work with mysql.so but now mysql.so gave me this:
Код:
[13:36:01]  Loading plugin: mysql.so
[13:36:01]   Failed (plugins/mysql.so: symbol __cxa_pure_virtual, version libmysqlclient_16 not defined in file libmysqlclient_r.so.16 with link time reference)
Reply

Downgrading to R34 should stop the crashes, but that's only a temporary solution.
There's also no big difference between the static and dynamic version of the plugin, both should crash for the same reason.
Reply

r34? guy r34 crashes way more than r38

I have figured out the problem anyway

The program is a memory leak issue (in either streamer (sampgdk) or MySQL plugin, apparently if you have both of them it's going to hurt but using 1 only isn't so bad). Also the sa-mp server has a few memory issues with some delete[] / delete function but that isn't hurting.
Reply

If you used the experimental streamer plugin 2.7.1, then switch back to 2.7 because its unusable. Crashes very often..

Anyway, I had crashdetect installed (4.13), and the server in windows on start sometimes crashed. I removed it, then worked without problem. IDK that bug still present in lastest version.
Reply

Quote:
Originally Posted by kurta999
Посмотреть сообщение
Anyway, I had crashdetect installed (4.13), and the server in windows on start sometimes crashed. I removed it, then worked without problem.
Try using 4.13.1 which was released few days ago. I've got mysql R38, streamer v2.7 and crashdetect 4.13.1 and I haven't come across with any crashes so far (while testing alone).
Reply

You can't test alone, you need players to do stuff.

streamer 2.7 is not that good because it uses sampgdk 3.0.2 which has alot of memory leaks and the amx crash (READ the sampgdk changelog), streamer 2.7.1 has these fixes.

If you used the experimental streamer plugin 2.7.1, then switch back to 2.7 because its unusable. Crashes very often.. < other way around for me.

IDK but I too myself agree that while having crashdetect on, things are worse SOMETIMES, but it's helpful
Reply

I haven't coded sa-mp awhile, is there a replacement for
pawn Код:
mysql_ping()
If not, how can you see if the connection is active?

Edit nevermind, i'm just gonna have to redo my whole script to use the latest plugin, shit has change a lot over the years
Reply

I deleted my crashdetect from plugins and i start the server, the server was crashed again ... I test my server for so many times on windows, on windows it's work perfectly without any problem, i downgrade my server to R34 with all of my players, No crash for +10 hours ... and crashdetect V4.13, streamer V2.7 are running with it, if the problem is for R+35 from the plugin, my server must crash in -24 hours, but if my server never crashed in 24 hours the problem is for R+35 plugin.
Edit: The problem is for mysql plugin R+35 versions... My server is still running without any problem.
Quote:
Originally Posted by ihatetn931
Посмотреть сообщение
I haven't coded sa-mp awhile, is there a replacement for
pawn Код:
mysql_ping()
If not, how can you see if the connection is active?

Edit nevermind, i'm just gonna have to redo my whole script to use the latest plugin, shit has change a lot over the years
Click
Reply

How would I go about handling transactions? I have one instance where I need, or rather want to perform inserts in a loop. Do I simply execute Start->queries->Commit?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)