SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 15/02/2012, 02:50 PM   #2061
Jeroen52
Gangsta
 
Jeroen52's Avatar
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 531
Reputation: 28
Default Re: [REL] MySQL Plugin (R7 source available)

Quote:
Originally Posted by WackoX View Post
Code:
Failed (/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by plugins/mysql.so))
Anyone?

EDIT: I downloaded the Debian version, now it works.
I get that error when I run my server on CentOS 5.5 64Bit, what is your OS?
__________________
Jeroen52 is offline   Reply With Quote
Old 15/02/2012, 03:05 PM   #2062
kirk
Big Clucker
 
Join Date: Oct 2010
Posts: 193
Reputation: 59
Default Respuesta: Re: [REL] MySQL Plugin (R7 source available)

Quote:
Originally Posted by Gamer_Z View Post
eee what is the cache? O_O and using it is as simple as doing cache = true? No need to edit my queries or callbacks or whatever?
I guess it stores the fetched data on the cache memory of the core, thats why it runs so fast.
kirk is offline   Reply With Quote
Old 15/02/2012, 03:46 PM   #2063
JernejL
Beta Tester
 
JernejL's Avatar
 
Join Date: Jan 2006
Location: Slovenia
Posts: 565
Reputation: 366
Default Re: [REL] MySQL Plugin (R7 source available)

Quote:
Originally Posted by Kar View Post
Yes, I am switching, JernejL just told me that using cache and non-cache will have crashes and weird stuff. so yea ignore the above^^^
Cached and non-cached works fine.. it's threaded Vs non-threaded which had problem in past.

I still use mix of cache and noncached and am transferring to cache fully (had done experiments.. loading data for 1300 cars went from 6 seconds to 60 ms).
__________________


8.2.121.99:7777 - Partyserver - TurtleServer (now with extra turtles)!

SA-MP map editor: Not a in-game script but a proper windows application!
http://forum.sa-mp.com/showthread.php?t=282801
JernejL is offline   Reply With Quote
Old 15/02/2012, 03:53 PM   #2064
AndreT
High-roller
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 1,021
Reputation: 397
Default Re: [REL] MySQL Plugin (R7 source available)

Simply setting the cache to true in mysql_function_query won't do the trick, you need to use the cache functions in the returning callback as well.

cache_get_data returns stores the amount of rows and fields in the given parameters. This is useful for checking validity of what a SELECT query outputs and looping through the results as well.
cache_get_row stores the field data in the destination string. It is as simple as that:
pawn Code:
// Example query: SELECT name,kills FROM players WHERE id = %d LIMIT 0,1
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
    new PlayerName[MAX_PLAYER_NAME], kills, storage[12];
    cache_get_row(0, 0, PlayerName);
    cache_get_row(0, 1, storage), kills = strval(storage);
    printf("Player %s has %d kills!", PlayerName, kills);
}

I haven't tested cache_get_field, but according to the source, it is supposed to return the name of the given field.
There's also cache_get_field_content which will get the data by the field's name, for example:
pawn Code:
cache_get_field_content(0, "name", PlayerName);
cache_get_field_content(0, "kills", storage), kills = strval(storage);
I have avoided using this function for the same reason people avoid mysql_fetch_field_row. It loops through the cached array of field names and compares the strings, but in case of cached results, the difference won't of course be as bad as for mysql_fetch_row_format and mysql_fetch_field_row (although the functions are not designed to do the same thing, one is just faster to use when it comes to a large number of fields).

I have a house loading/parsing function which runs on startup only. When using the regular method (store the result, put mysql_fetch_row_format in a loop, etc), it took around 2.5 seconds to execute. I converted that function to use the cache method and the differences are slightly astonishing!

For the sake of it, I searched them out in my outbox (sent to xxmitsu previously), and for the old method, all mysql_fetch_row calls took ~3000ms, sscanf parsing took ~30ms and other parts of code in the loop ~130ms. After converting, the whole execution time is ~300ms, cache functions take around 160ms of it. I didn't run very many tests, but when starting the server up on Windows, I can clearly tell that the gain in startup is literally seconds!
AndreT is offline   Reply With Quote
Old 18/02/2012, 05:08 PM   #2065
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,369
Reputation: 132
Default Re: [REL] MySQL Plugin (R7 source available)

Quote:
Originally Posted by AndreT View Post
Simply setting the cache to true in mysql_function_query won't do the trick, you need to use the cache functions in the returning callback as well.

cache_get_data returns stores the amount of rows and fields in the given parameters. This is useful for checking validity of what a SELECT query outputs and looping through the results as well.
cache_get_row stores the field data in the destination string. It is as simple as that:
pawn Code:
// Example query: SELECT name,kills FROM players WHERE id = %d LIMIT 0,1
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
    new PlayerName[MAX_PLAYER_NAME], kills, storage[12];
    cache_get_row(0, 0, PlayerName);
    cache_get_row(0, 1, storage), kills = strval(storage);
    printf("Player %s has %d kills!", PlayerName, kills);
}

I haven't tested cache_get_field, but according to the source, it is supposed to return the name of the given field.
There's also cache_get_field_content which will get the data by the field's name, for example:
pawn Code:
cache_get_field_content(0, "name", PlayerName);
cache_get_field_content(0, "kills", storage), kills = strval(storage);
I have avoided using this function for the same reason people avoid mysql_fetch_field_row. It loops through the cached array of field names and compares the strings, but in case of cached results, the difference won't of course be as bad as for mysql_fetch_row_format and mysql_fetch_field_row (although the functions are not designed to do the same thing, one is just faster to use when it comes to a large number of fields).

I have a house loading/parsing function which runs on startup only. When using the regular method (store the result, put mysql_fetch_row_format in a loop, etc), it took around 2.5 seconds to execute. I converted that function to use the cache method and the differences are slightly astonishing!

For the sake of it, I searched them out in my outbox (sent to xxmitsu previously), and for the old method, all mysql_fetch_row calls took ~3000ms, sscanf parsing took ~30ms and other parts of code in the loop ~130ms. After converting, the whole execution time is ~300ms, cache functions take around 160ms of it. I didn't run very many tests, but when starting the server up on Windows, I can clearly tell that the gain in startup is literally seconds!
That's some nice experience.

Anyway, is anyone using the latest version in a LIVE server?
wups is offline   Reply With Quote
Old 18/02/2012, 05:46 PM   #2066
ombre
Huge Clucker
 
Join Date: Jul 2010
Posts: 277
Reputation: 6
Default Re : [REL] MySQL Plugin (R7 source available)

hi,

What's the difference between threaded and unthreaded (query)? I don't understand this word (bad english)

thx.
ombre is offline   Reply With Quote
Old 18/02/2012, 06:08 PM   #2067
AndreT
High-roller
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 1,021
Reputation: 397
Default Re: [REL] MySQL Plugin (R7 source available)

Quote:
Originally Posted by wups View Post
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 View Post
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.
AndreT is offline   Reply With Quote
Old 18/02/2012, 06:30 PM   #2068
ombre
Huge Clucker
 
Join Date: Jul 2010
Posts: 277
Reputation: 6
Default Re : [REL] MySQL Plugin (R7 source available)

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.
ombre is offline   Reply With Quote
Old 18/02/2012, 06:45 PM   #2069
iZN
High-roller
 
iZN's Avatar
 
Join Date: Jun 2010
Location: Japan
Posts: 2,094
Reputation: 351
Default Re: [REL] MySQL Plugin (R7 source available)

Good work GStylezzz (BlueG)
and yay threaded queries!
iZN is offline   Reply With Quote
Old 18/02/2012, 09:33 PM   #2070
ombre
Huge Clucker
 
Join Date: Jul 2010
Posts: 277
Reputation: 6
Default Re : [REL] MySQL Plugin (R7 source available)

How to use UPDATE and INSERT in OnQueryFinish?

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

OnQueryFinish
{
case THREAD_SAVE:
{

}
}

Last edited by ombre; 18/02/2012 at 10:08 PM.
ombre is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Project: Glass int3s0 Everything and Nothing 99 26/02/2013 05:22 PM
MySQL Plugin R5 plugin problem dud Scripting Help 12 05/12/2011 07:28 PM
Strikens Mysql vs BlueG's Mysql plugin PrawkC Scripting Help 4 30/09/2011 10:30 AM
[help][plugin] Can't load mysql plugin mariomako Help Archive 8 16/07/2011 02:37 PM
mysql plugin. loading plugin failed ikkentim Help Archive 2 10/02/2011 03:32 PM


All times are GMT. The time now is 02:50 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.