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

What?
Reply

version debian 7 static ?, thanks.
Reply

Use the default "linux" download.
Reply

I've updated mysql server to 5.7.11 and since then I've got few problems. I fixed the issue with ONLY_FULL_GROUP_BY sql mode and the one left is very odd.

My query:
Code:
"INSERT INTO player_vehicles VALUES (NULL,%i,%i,%i,%i,%i,%i) ON DUPLICATE KEY UPDATE modelid=%i,color1=%i,color2=%i,paintjob=%i"
The problem is that it doesn't insert a new row when it should.

I print the query and everything seems fine. I copy the output and run it through phpmyAdmin and it inserts a new row. I execute the same query after connecting the mysql in OnGameModeInit and it still inserts a new row.

However when I use it in the command, it does not insert a new row. Extra info:
- it retrieves the ID generated for an AUTO_INCREMENT column by the sent query correctly
- debug with LOG_ALL and it says "query was successfully executed within X milliseconds"

Any help would be appreciated.

EDIT: After more analysis it seems the cache is the problem.
I tried running a non-threaded query for the INSERT and it worked. Switching cache back to true didn't work though.
Reply

Nice!
Reply

I finally updated my gamemode from R5 to R39-5. Was not that easy. I am still having hard time understanding how the latest version works. But there is one thing that I do not understand. When the server starts loading house data from the mysql server it takes ~10 seconds to load up the data and after that the server fully starts. Could there be something wrong with the code? This is an idea of what the code looks like:

Code:
forward LoadHouseInfo();

OnGameModeInit
{
	for(new i; i<27; i++)
	{
		mysql_format(...); // format the query
		mysql_tquery(...); // send the query to a forwarded function
		for(new j; j<20; j++)
		{
			mysql_format(...); // format the query
			mysql_tquery(...); // send the query to a forwarded function
		}
	}
}

public LoadHouseInfo()
{
	// Load house data here
	if(rows==27)
	{
	    HouseCreationFunction(0,...);
	    HouseCreationFunction(1,...);
	    HouseCreationFunction(2,...);
	    HouseCreationFunction(3,...);
		// ...
	}
}

HouseCreationFunction()
{
}
EDIT: Nevermind. Everything is working perfectly now. A BIG tip: don't log everything
Reply

Never use debug logging if you need speed or/and are on a live server. Same thing goes for compiling with debug symbols (PAWN parameter '-d2' or '-d3').
Reply

Guys a few questions, since im moving from old R7 to these now.

pawn Код:
stock pName(playerid)
{
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    return PlayerName;
}

orm_addvar_string(playerid, pName(playerid), MAX_PLAYER_NAME, "UserName");
Can i use orm_addvar like that? Will it try to access invalid memory and fuck up my server?

Is it possible to create my own query, and still be able to use ORM?
pawn Код:
mysql_tquery(mysqlThread, "SELECT * FROM `Vehicles`", "OnVehicleLoading");
And now just use ORM in the OnVehicleLoading public? (If i can, than example is more than welcome)

[EDIT] Dont mind second question, just found answer myself.
If someone is interested here is example from wiki:
pawn Код:
new query[128];
format(query, sizeof(query), "SELECT * FROM `players` WHERE `id` = '%d'", Player[playerid][ID]);
mysql_tquery(MySQL, query, "OnStuffSelected", "d", playerid);
 
public OnStuffSelected(playerid)
{
    orm_apply_cache(Player[playerid][ORM_ID], 0);
    printf("Player %s has %d Money and is on PosX with %f.", Player[playerid][Name], Player[playerid][Money], Player[playerid][PosX]);
    return 1;
}
Reply

Memory leak bug on R39-5 and previous version

Test code

Код:
forward PubTestmysql();
public PubTestmysql()
{
	return 1;
}

new sdkfsd = 0;

forward testsampmV();
public testsampmV()
{
	if (sdkfsd < 500)
	{
		for(new i = 0; i < 1000; i++)
		{
			format(query, 256, "SELECT * FROM `mybase` WHERE id > 0 LIMIT 1");
			mysql_tquery(SQL, query, "PubTestmysql", "");
		}
		sdkfsd++;
	}
}

SetTimer("testsampmV",100,true);
if change query on
Код:
format(query, 256, "update `mybase` set cash = 545642  where id = 1");
Memory leak not detect
Reply

Where is new query[256]? And why you use 256 array when you can use less than 256(86 will be good).
Reply

Quote:
Originally Posted by vannesenn
Посмотреть сообщение
Where is new query[256]? And why you use 256 array when you can use less than 256(86 will be good).
What does that have to do with a plugin memory leak? wtf lol?
Reply

Quote:
Originally Posted by cm666
Посмотреть сообщение
Memory leak bug on R39-5 and previous version

Test code

Код:
forward PubTestmysql();
public PubTestmysql()
{
	return 1;
}

new sdkfsd = 0;

forward testsampmV();
public testsampmV()
{
	if (sdkfsd < 500)
	{
		for(new i = 0; i < 1000; i++)
		{
			format(query, 256, "SELECT * FROM `mybase` WHERE id > 0 LIMIT 1");
			mysql_tquery(SQL, query, "PubTestmysql", "");
		}
		sdkfsd++;
	}
}

SetTimer("testsampmV",100,true);
if change query on
Код:
format(query, 256, "update `mybase` set cash = 545642  where id = 1");
Memory leak not detect
How exactly did you detect a memory leak there?
Reply

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
How exactly did you detect a memory leak there?
When the server is running, let's say 50 mb The use, after starting to run this code memory usage increases. After the termination of the code memory is not reduced and not increased.
Reply

Hello everybody.

Could you help me to compile this plugin, please.

1. I installed all what i need from this instraction - https://github.com/pBlueG/SA-MP-MySQL
2. I use Centos 6 OS (VDS).
3. I also install Development Tools (GCC compiler latest version - 4.4.7)

And i got this error:


What should i do? Different C++ compiler (Why?) and how?
Reply

You need GCC 4.8 or higher for C++11 support.
Reply

Quote:
Originally Posted by DarkSlyder
Посмотреть сообщение
You need GCC 4.8 or higher for C++11 support.
Do you know how can i install it on centos?
Command <yum groupinstall 'Development Tools'> will install 4.4
Reply

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
How exactly did you detect a memory leak there?
If use ORM memory leak not detect.
Code above and ORM used in free mode (new.pwn) and used only plugin mysql
Tested mysql_pquery memory leak not detect.
Reply

Quote:
Originally Posted by wharlos
Посмотреть сообщение
Any solution? I have windows xp sp3

Capture

and I have installed these visual

Capture
Try to recompile the plugin on Windows XP. [LE: I guess this won't work]
Or you can also install a low-spec Linux distribution like Lubuntu inside a virtual machine.
Reply

If you select "UNIX_TIMESTAMP(`Time`)" then the column in the result will inevitably also be called "UNIX_TIMESTAMP(`Time`)". The column "Time" does not exist in that result set. Use an alias (SELECT ... AS `Time`).
Reply

Quick question: does the plugin support multiple caches? For example if in one tquery/pquery callback I send a unthreded query?

Sample code
pawn Код:
for(new i = 0; i < cache_get_row_count(); i++)
{
     new Cache:result = mysql_query("...");
     if(cache_get_row_count())
        // stuff
     cache_delete(result);
}
It works well on the first iteration but on the second I get a "no active cache" warning. If so, I guess I could save the cache from first query, but since the second query is actually in a different module of mine, it doesn't look like a good solution.

P.S. I'm on 39-3. Will the dreaded HTML log color will ever change?
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)