SA-MP Forums Archive
[Plugin] [REL] MySQL Plugin (Now on github!) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] [REL] MySQL Plugin (Now on github!) (/showthread.php?tid=56564)



Re: [REL] MySQL Plugin (R7 source available) - AndreT - 18.02.2012

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.


Re : [REL] MySQL Plugin (R7 source available) - ombre - 18.02.2012

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.


Re: [REL] MySQL Plugin (R7 source available) - iZN - 18.02.2012

Good work GStylezzz (BlueG)
and yay threaded queries!


Re : [REL] MySQL Plugin (R7 source available) - ombre - 18.02.2012

How to use UPDATE and INSERT in OnQueryFinish?

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

OnQueryFinish
{
case THREAD_SAVE:
{

}
}


Re: [REL] MySQL Plugin (R7 source available) - Pooh7 - 18.02.2012

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


Re : [REL] MySQL Plugin (R7 source available) - ombre - 18.02.2012

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

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

Work's?


Re: [REL] MySQL Plugin (R7 source available) - Kar - 18.02.2012

anyone got a working version for volt?


Re : [REL] MySQL Plugin (R7 source available) - ombre - 18.02.2012

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 ...?


Re: [REL] MySQL Plugin (R7 source available) - Ricop522 - 18.02.2012

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


Re : [REL] MySQL Plugin (R7 source available) - ombre - 19.02.2012

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?


Re: [REL] MySQL Plugin (R7 source available) - wups - 19.02.2012

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.


Re: [REL] MySQL Plugin (R7 source available) - kurta999 - 19.02.2012

mysql_ping() is useless currently with threads.

This is the crash reason.


Re: Re : [REL] MySQL Plugin (R7 source available) - Pooh7 - 19.02.2012

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.



Re: [REL] MySQL Plugin (R7 source available) - Luka P. - 19.02.2012

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?


Re: [REL] MySQL Plugin (R7 source available) - Pooh7 - 19.02.2012

You have to use %e to escape the string.

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


Re : [REL] MySQL Plugin (R7 source available) - ombre - 19.02.2012

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.


Re: [REL] MySQL Plugin (R7 source available) - Pooh7 - 19.02.2012

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).


Re: [REL] MySQL Plugin (R7 source available) - Luka P. - 19.02.2012

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


AW: [REL] MySQL Plugin (R7 source available) - Dandimite - 20.02.2012

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.


Re: [REL] MySQL Plugin (R7 source available) - AndreT - 20.02.2012

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?