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

Quote:
Originally Posted by wups
Посмотреть сообщение
Anyway, is anyone using the latest version in a LIVE server?
Yes, but unfortunately with some room for error. My server has started getting occasional lockups/freezes once again. Currently (I hope the author doesn't mind as long the code is for personal use only) I have finished stripping down most parts of the plugin to maintain only cache compatibility and later in the evening will try it out on Linux (CentOS) as well.

A lot of people were getting those heap underflow errors in this topic. I tried, once again, compiling the Windows build with maximal optimization /Ox, but apparently this is what generates this awkward behavior.

Quote:
Originally Posted by ombre
Посмотреть сообщение
What's the difference between threaded and unthreaded (query)? I don't understand this word (bad english)
Unthreaded queries do not work anymore in the new version of this plugin (R7). In previous versions, there were a lot of issues with using threaded and unthreaded queries together.
Threaded queries, if they take a long time to execute internally, don't interfere with other things going on in the server.
For example, if I have a huge database and it is unoptimized, and some UPDATE query takes 2 seconds, then with threaded queries the players wont notice it. With unthreaded queries, the whole server will halt for the time of query execution.
Reply

ok thanks, but I can see the difference in a code between Threaded queries and Unthreaded queries? Because I understand but I don't see the structure.
Reply

Good work GStylezzz (BlueG)
and yay threaded queries!
Reply

How to use UPDATE and INSERT in OnQueryFinish?

mysql_query(UPDATE...,THREAD_SAVE,playerid,SQL);

OnQueryFinish
{
case THREAD_SAVE:
{

}
}
Reply

Just put return 1 if you won't do something after the query is executed.
Reply

mysql_query(UPDATE...,THREAD_SAVE,playerid,SQL);

OnQueryFinish
{
case THREAD_SAVE:
{
return 1;
}
return 1
}

Work's?
Reply

anyone got a working version for volt?
Reply

I have a long query for save the player account so I share it in 2 parts: mysql_query(UPDATE...,THREAD_SAVE,playerid,SQL);
mysql_query(UPDATE...,THREAD_SAVE,playerid,SQL);

I can to use THREAD_SAVE 2 times? or i need to use THREAD_SAVE THREAD_SAVE1 ...?
Reply

I think you can use two tames , because when you execute the first thread, the second will wait the first finish. :b
Reply

ok but the threaded queries is not more Unstable? because I modified to unthreaded => threaded and the server crash sometimes, I reboot without no change the script and work fine...

mysql_ping() is Useful in OnQueryFinish?
Reply

Quote:
Originally Posted by AndreT
Посмотреть сообщение
Yes, but unfortunately with some room for error. My server has started getting occasional lockups/freezes once again. Currently (I hope the author doesn't mind as long the code is for personal use only) I have finished stripping down most parts of the plugin to maintain only cache compatibility and later in the evening will try it out on Linux (CentOS) as well.

A lot of people were getting those heap underflow errors in this topic. I tried, once again, compiling the Windows build with maximal optimization /Ox, but apparently this is what generates this awkward behavior.


Unthreaded queries do not work anymore in the new version of this plugin (R7). In previous versions, there were a lot of issues with using threaded and unthreaded queries together.
Threaded queries, if they take a long time to execute internally, don't interfere with other things going on in the server.
For example, if I have a huge database and it is unoptimized, and some UPDATE query takes 2 seconds, then with threaded queries the players wont notice it. With unthreaded queries, the whole server will halt for the time of query execution.
Oh, ok. I'll have to wait for something more stable then.
Reply

mysql_ping() is useless currently with threads.

This is the crash reason.
Reply

Quote:
Originally Posted by ombre
Посмотреть сообщение
ok but the threaded queries is not more Unstable? because I modified to unthreaded => threaded and the server crash sometimes, I reboot without no change the script and work fine...

mysql_ping() is Useful in OnQueryFinish?
Yeah, I'm using threaded queries and no problems at all.



Do not use mysql_ping, it's not necessary:

Quote:
Originally Posted by SA-MP Wiki
Important Note: Connection state check (and reconnect if needed) happens automatically incase you are using threaded callback, so you don't need to perform any manual checks.
Reply

Is there something wrong with mysql_format? I thought it is a replacement for mysql_escape_string, but it doesn't escape the string at all. What's the purpose of that function?
Reply

You have to use %e to escape the string.

https://sampwiki.blast.hk/wiki/MySQL#mysql_format
Reply

thank for your help. Last question. I have a problem with a command.

/command ( playerid giveplayerid)

==> check sql name {return1}
==> check sql number {return1}
If isn't in the sql so Activate [giveplayerid] = 1;

Before with UNTHREAD query is directly, but with THREAD query is slow so sometimes the Activate [giveplayerid] is read before the check SQL. When there is only "playerid" I write the continuation in the OnQueryFinish but here I need playerid and giveplayerid.

Thank for the help.
Reply

You can do this:

pawn Код:
new cmd_giveplayerid;

CMD:yourcmd(playerid, params[])
{
    new giveplayerid;
    // something to do before the query
    cmd_giveplayerid = giveplayerid;
    mysql_query("query, blabla", THREADID, playerid);
    return 1;
}

public OnQueryFinish(...)
{
    if(resultid == THREADID)
    {
        // code to execute after query
    }
    return 1;
}
Now in OnQueryFinish use extraid instead of playerid, and cmd_giveplayerid instead of giveplayerid.


EDIT: In R7, you can create your own functions with your custom parameters, so you haven't to use OnQueryFinish with only 1 parameter (extraid).
Reply

Can someone explain me what this cache system does? I use it, works well, but what are pros/cons?
Reply

Quote:

An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)

Version: R6-2

I dont use threaded querys.

The line:
Код:
mysql_query("SELECT ID FROM chat WHERE Done = '0'",-1,-1,Connection_Chat);
Is this a problem whit the multiple connection?
When I use the same query at the first db (Connection = 1, Connection_Chat = 2) I dont have any errors or problems. The dbґs are at the same mysql server, but different dbґs.

Anyone has a idea to fix this? Or anyone can explain what the exectly problem is?

Thx for any help.
Reply

Check if you're passing the right connection parameter to mysql_free_result(). Commands get out of synchronization if you have forgotten to free a result.

Codes like this are a source of problems as well, if there are 0 rows!
pawn Код:
// query
mysql_store_result();
if(!mysql_num_rows())
{
    // send a message, blabla, whateva
    return true;
}
mysql_free_result();
Also, why not update your plugin to the newest version?
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)