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

Documentation is one thing, but to be honest, I'd oppose the 5th parameter of cache_get_row anyways.
1) Scripters should know what they're doing. This addition is going to stop a runtime error from occurring, but wouldn't the warning/error/undefined behavior itself a good sign to the scripter that they're trying to fit a lot more into something smaller.
2) This breaks far too much backwards compatibility. Faaaaar to much to handle without proper documentation.

Although, got to admit, this is somewhat related to our own lazyness. It is a common expectation that sizeof on an enumeration member should return its size, but nope - this is not what the actual PAWN docs say as far as I know.
Reply

R17
  • added function 'mysql_log':
    this function replaces 'mysql_debug' (alltough it's still available for backwards compability). Now you can control which things get logged, i.e. you can call 'mysql_log(LOG_ERROR | LOG_DEBUG)' to log only errors and debug informations. The default log setting is 'LOG_ERROR | LOG_WARNING', thus will log only errors and warnings. Available log types are 'LOG_ERROR', 'LOG_WARNING', 'LOG_DEBUG' and 'LOG_NONE'.
  • added prefixes to log lines which indicate if that log is an error, warning or debug information (i.e. '[14:32:29] [ERROR] CMySQLHandler...' instead of '[14:32:29] CMySQLHandler...')
  • fixed bug with mutex deadlock on Linux
  • fixed bug: not calling mysql_store and _free will cause the a 'commands out of sync' error when mysql_ping gets called in the internal mysql-thread. (alltough have no clue how I fixed that and how that bug happened)
  • when a query-error occured in the internal mysql-thread, the error will now be printed in the mysql-log AND forwarded to the error-callback (the error was only forwarded to the callback before)
Download Windows .dll and include (download button is the small one below the download counter)
Download source code (download button is the small one below the download counter)
Download Linux .so and static.so
Reply

Quote:
Originally Posted by Pain123
Посмотреть сообщение
R17
  • added function 'mysql_log':
    this function replaces 'mysql_debug' (alltough it's still available for backwards compability). Now you can control which things get logged, i.e. you can call 'mysql_log(LOG_ERROR | LOG_DEBUG)' to log only errors and debug informations. The default log setting is 'LOG_ERROR | LOG_WARNING', thus will log only errors and warnings. Available log types are 'LOG_ERROR', 'LOG_WARNING', 'LOG_DEBUG' and 'LOG_NONE'.
  • added prefixes to log lines which indicate if that log is an error, warning or debug information (i.e. '[14:32:29] [ERROR] CMySQLHandler...' instead of '[14:32:29] CMySQLHandler...')
  • fixed bug with mutex deadlock on Linux
  • fixed bug: not calling mysql_store and _free will cause the a 'commands out of sync' error when mysql_ping gets called in the internal mysql-thread. (alltough have no clue how I fixed that and how that bug happened)
  • when a query-error occured in the internal mysql-thread, the error will now be printed in the mysql-log AND forwarded to the error-callback (the error was only forwarded to the callback before)
Download Windows .dll and include (download button is the small one below the download counter)
Download source code (download button is the small one below the download counter)
The Linux version will be available later.
Very nice, well done.
Reply

How can I compile the source code in linux?

root@km35001-02:/home/src# make
make: *** No targets specified and no makefile found. Stop.
Reply

Just switched from an old R7 to R17. Server now crashes when tries to perform an insert query on a non-existing table.

I don't know if it's a bug or made by design to prevent data loss (which I doubt is the case), but I'm here to report it doesn't give me any notice about an error. Logging is set to log only errors and warnings and the log file is empty. Also OnQueryError doesn't get triggered.
I saw the problem when I enabled debug logging, the last line in the log was "Executing query INSERT INTO ..." so I realized what was the problem.

server_log.txt says the following:
Code:
[28/04/2013 - 16:53:00] [debug] Server crashed due to an unknown error
[28/04/2013 - 16:53:00] [debug] System backtrace:
[28/04/2013 - 16:53:00] [debug] #0 7164732f in ?? () from C:\Windows\system32\MSVCR100.dll
[28/04/2013 - 16:53:00] [debug] #1 71647368 in ?? () from C:\Windows\system32\MSVCR100.dll
[28/04/2013 - 16:53:00] [debug] #2 71d9888f in ?? () from E:\...\plugins\mysql-r17.DLL
[28/04/2013 - 16:53:00] [debug] #3 71d9b7bb in ?? () from E:\...\plugins\mysql-r17.DLL
[28/04/2013 - 16:53:00] [debug] #4 75dd33aa in ?? () from C:\Windows\syswow64\kernel32.dll
[28/04/2013 - 16:53:00] [debug] #5 77489ef2 in ?? () from C:\Windows\SysWOW64\ntdll.dll
[28/04/2013 - 16:53:00] [debug] #6 77489ec5 in ?? () from C:\Windows\SysWOW64\ntdll.dll
Reply

Why would you insert in a non-existing table ?
Reply

The point here is that the server crashes without reporting an error, not why would I insert in a non-existing table. Might be just that I recently made a lot of changes and made a typo while writing a query.
Reply

Thanks for reporting, was a stupid mistake.
Here is the new source and the new download for Windows.
The links in my other post are now also up2date.

Update:
Linux version now available! Thanks to Mellnik
Reply

Hello there, i got the following situation, sometimes mysql don't run properly my function and i have the following

code:
Code:
connectData = mysql_connect(myHost, myUser, myData, myPass);
	
	if(mysql_ping(connectData) == 1)
	{
		mysql_debug(1);
                printf("[MYSQL] Coneccao com a base de dados: SUCESSO!");
		mysql_function_query(connectData, "SELECT nome FROM contas WHERE nome = 'Mishima_Kazuma'", false, "", "");
		mysql_store_result(connectData);
		new linhas = mysql_num_rows(connectData);
		mysql_free_result(connectData);
		
	}
	else
	{
 		printf("[MYSQL] Coneccao com a base de dados: ERRO!");
	}
Then i gonna see my logs and sometimes i get this:

Code:
[22:16:05] [WARNING] 'mysql_debug' is deprecated, use 'mysql_log' instead.
[22:16:05] [DEBUG] >> mysql_query_callback(Connection handle: 1)
[22:16:05] [DEBUG] ProcessQueryThread() - Executing query SELECT nome FROM contas WHERE nome = 'Mishima_Kazuma'...
[22:16:06] [DEBUG] ProcessQueryThread() - Query was successful.
[22:16:06] [DEBUG] ProcessQueryThread() - Data being passed to ProcessTick().
[22:16:06] [DEBUG] >> mysql_store_result(Connection handle: 1)
[22:16:06] [DEBUG] CMySQLHandler::StoreResult() - Result was stored.
[22:16:06] [DEBUG] >> mysql_num_rows(Connection handle: 1)
[22:16:06] [DEBUG] CMySQLHandler::NumRows() - Returned 2 row(s).
[22:16:06] [DEBUG] >> mysql_free_result(Connection handle: 1)
[22:16:06] [DEBUG] CMySQLHandler::FreeResult() - Result was successfully freed.
Other times, i get this:

Code:
[22:16:42] [WARNING] 'mysql_debug' is deprecated, use 'mysql_log' instead.
[22:16:42] [DEBUG] >> mysql_query_callback(Connection handle: 1)
[22:16:42] [DEBUG] >> mysql_store_result(Connection handle: 1)
[22:16:42] [WARNING] CMySQLHandler::StoreResult() - No data to store.
[22:16:42] [DEBUG] ProcessQueryThread() - Executing query SELECT nome FROM contas WHERE nome = 'Mishima_Kazuma'...
[22:16:42] [DEBUG] ProcessQueryThread() - Query was successful.
[22:16:42] [DEBUG] ProcessQueryThread() - Data being passed to ProcessTick().
[22:16:42] [DEBUG] >> mysql_num_rows(Connection handle: 1)
[22:16:42] [ERROR] CMySQLHandler::NumRows() - You cannot call this function now (no result).
[22:16:42] [DEBUG] >> mysql_free_result(Connection handle: 1)
[22:16:42] [WARNING] CMySQLHandler::FreeResult() - The result is already empty.
What could be happening here?
Reply

Thanks. Now my server can run now, all the crashes seems to be fixed. You did a great job, also allowing us to not get overly massive mysql_logs, thanks! Now the server starts without lagging, no massive writes have to be done
Reply

I figured it out and got fixed.
Reply

You'll have to store the result before retrieving the number of rows the result has.
Reply

I figured it out and got fixed.
Reply

Typhome u have the same problem as me, sometimes get 2 and other times get -1. Are u testing with xamp or other similar program?
Reply

I've been getting this issue today, no clue why:

Код:
[20:05:17] [INFO] Now logging: errors
[20:05:54] [ERROR] ProcessTick() - The result wasn't freed!
[20:06:19] [ERROR] ProcessTick() - The result wasn't freed!
Reply

Well after each mysql_store_result there has to be a mysql_free_result
Reply

Quote:
Originally Posted by Pain123
Посмотреть сообщение
Well after each mysql_store_result there has to be a mysql_free_result
I have that, but I figured out the issue had to do with something else, crashdetect pointed out.
Reply

@Memoryz, is your issue now solved?

I wonder how many people are using the newest version?
And does anyone misses unthreaded queries, thus queries without using callbacks (public's)?
Reply

Quote:
Originally Posted by Pain123
Посмотреть сообщение
@Memoryz, is your issue now solved?

I wonder how many people are using the newest version?
And does anyone misses unthreaded queries, thus queries without using callbacks (public's)?
Me, honestly r20 fixed all crashes. I'm thankful. It's the best.

I've taken a liking to threaded queries, they work fine. I don't really miss them o.0
Reply

Hm, r20 is stable? Most interesting stability on Linux,Ubuntu 13.04
Reply


Forum Jump:


Users browsing this thread: 28 Guest(s)