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

Nice work!
Reply

Hi, I am a Pole, I'm sorry for my English.
I have a table `gangs` that consists of these fields: `gid` (index), `leader`, `name`, `shortname`, `created`
The table is empty. Then send query:
Код:
SELECT * FROM gangs WHERE name='Grove Street' OR shortname='GS'
Next is the code to mysql_num_rows, but before he performs, the database already crashes, then the server shuts down.

Here is the log
Код:
[14:44:37] CMySQLHandler::Query(SELECT * FROM gangs WHERE name='Grove Street' OR shortname='GS') - Successfully executed.

[14:44:37] >> mysql_num_rows( Connection handle: 1 )

[14:44:37] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[14:44:37] >> mysql_ping( Connection handle: 1 )
Edit: The problem of obsolete. I added the before mysql_num_rows function mysql_store_result and now it works.
Reply

Quote:
Originally Posted by PawnNewCommer
Посмотреть сообщение
Tell me how can I get this code of such a request. What would it take some data from the database.
Код:
format(query,sizeof(query),"SELECT date1, date2, date3, date4, ..., datan FROM players WHERE id=%d AND Password='%s' LIMIT 1",id,password);
But the fact is that I have a lot of data. About 40 DATA. (Date1 - date40). But if I do as posted above then get an error that the string is very long.
How can this be done?
Just do not say do SELECT * ....
Because in addition to the required fields, I have a lot of extra fields. Including text and they are only needed for the site.
You could select * and ignore extra fields or create a stored procedure with the syntax that you need and call that procedure each time you need to get data from table.
Reply

Quote:
Originally Posted by kuba707
Посмотреть сообщение
Hi, I am a Pole, I'm sorry for my English.
I have a table `gangs` that consists of these fields: `gid` (index), `leader`, `name`, `shortname`, `created`
The table is empty. Then send query:
Код:
SELECT * FROM gangs WHERE name='Grove Street' OR shortname='GS'
Next is the code to mysql_num_rows, but before he performs, the database already crashes, then the server shuts down.

Here is the log
Код:
[14:44:37] CMySQLHandler::Query(SELECT * FROM gangs WHERE name='Grove Street' OR shortname='GS') - Successfully executed.

[14:44:37] >> mysql_num_rows( Connection handle: 1 )

[14:44:37] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[14:44:37] >> mysql_ping( Connection handle: 1 )
Edit: The problem of obsolete. I added the before mysql_num_rows function mysql_store_result and now it works.
Remember to free the result once you used the data stored.
Reply

I tried the current version of that plugin.
Sending queries to the MySQL-Server works. But reading the field data sends my server to death.

That is my test code:
Код:
new query[256];
format(query, sizeof(query), "SELECT * FROM `positions` WHERE `Name` = '%s'", name);
mysql_query(query);
mysql_store_result();
if (mysql_retrieve_row())
{
	printf("num fields: %d", mysql_num_fields());
	new value[256];
	mysql_fetch_field(1, value);
	printf("field 1: %s", value);
}
The server crashs where it should execute mysql_fetch_field(). I can see "num fields: 5" but not "field 1: ...".

Debug output of the MySQL plugin:
Код:
[21:24:10] >> mysql_query( Connection handle: 1 )
[21:24:10] CMySQLHandler::Query(SELECT * FROM `positions` WHERE `Name` = 'test') - Successfully executed.
[21:24:10] >> mysql_store_result( Connection handle: 1 )
[21:24:10] CMySQLHandler::StoreResult() - Result was stored.
[21:24:10] >> mysql_retrieve_row( Connection handle: 1 )
[21:24:10] >> mysql_num_fields( Connection handle: 1 )
[21:24:10] CMySQLHandler::NumFields() - Returned 5 field(s)
[21:24:10] >> mysql_fetch_field( Connection handle: 1 )
Are there any solutions for that problem?
Reply

Any NULL fields?
Reply

That is the content of the table:


Type of the fields:
Name: VARCHAR(100)
Playername: VARCHAR(24)
PosX: FLOAT
PosY: FLOAT
PosZ: FLOAT

btw. I'm using Debian 6 x86 and plugin R6 x86 for Debian 5.
Reply

DL links are dead. Maybe your sever is having some issues. Do someone has a mirror for the pawn sample script?
Reply

Quote:
Originally Posted by Johnson_boy
Посмотреть сообщение
I have problem with this plugin. The server keeps freezing randomly, not crashing, freezing. People only see connected to server, and nothing after it. Server responds to nothing, and has to be forced to restart.
This isn't caused by some specific query or function, every function works, randomly server just freezes. Sometimes server stays up for week without freezes, sometimes just for day. I am using threaded mysql, code is written in OnQueryFinish.

Server is running on linux, players usually from 50 to 80, latest SA-MP server, latest plugin.

Do you have any idea what could cause these freezes? could it be incorrectly written script, if so, what is wrong, or too many queries at the same time?

Help appreciated.
Same problem as him, I'm using Vortex 2 No edit, I'm getting the error
"An error has occured. (Error ID: 2013, Lost connection to MySQL server during query)"
at the end of my mysql_debug

also vortex 2 uses threaded queries
Reply

I've:
if(mysql_ping() == -1) mysql_reconnect();
in my OnPlayerConnect and it sometimes crashes the server.. Why?
Reply

By the way (topic, lol) Is there a similar function to StrickenKid's mysql_data_seek? Otherwise, I'd have to limit the row I want and DESC it. :\
Reply

In this post >>Klick<< is a Link (http://forum.sa-mp.com/showpost.php?...&postcount=553) ther is Down ! i cann not connect to this link.

someone has the files ?
or someone has a new link?

sry for my English
Reply

Could logging actually make the server lag(mysql_debug)? I think it's in a different thread, so it shouldn't bother the server. Anyway, still waiting for a reply.
Reply

I doubt the log writing happens in a different thread and apparently the log file is opened and closed every time some MySQL function is called. But I doubt it is the cause of any notable lag and I think you'll rather benefit from the logging function.
Reply

Quote:
Originally Posted by AndreT
Посмотреть сообщение
I doubt the log writing happens in a different thread and apparently the log file is opened and closed every time some MySQL function is called. But I doubt it is the cause of any notable lag and I think you'll rather benefit from the logging function.
Well, in a big server, where it's main core is MySQL, there are some notable lag moments. Well, logging could be an option of the cause.
Reply

And now what can the people do not get away with the error?
the link is not a question of can you download anything

if someone has the files he can help us / send me to say please and where I need to insert them.

sry for my english is coming from Germany ^ ^
Reply

I am using R6 and noticed problem that I never had. When I use mysql_close ( on OnGameModeExit ) server doesn't turn off, but it becomes unreachable. What can cause this? If I don't use mysql_close nothing changes. Seems like plugin doesn't unload at all.
Reply

Should it matter what version of mysql server I'm running? I'm currently running 5.1 and using VXRP2 which uses threaded queries, and it likes to crash every once in a while, could be 5 mins, could be 2hours.
Reply

If a person know my Mysql Table or the database structure, it's dangerous? Exploit possible?
Reply

Quote:
Originally Posted by ombre
Посмотреть сообщение
If a person know my Mysql Table or the database structure, it's dangerous? Exploit possible?
using mysql_real_escape_string he can't do exploit (SQL Injection)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)