04.08.2011, 15:02
Good Job G-sTyLeZzZ.
+1 Rep for you.
+1 Rep for you.
Is it possible to connect 2 databases ( in the GM)? database 1 = accounts, database 2 = bans.
mysql_connect("123.456.789", "DB1", "AA"); mysql_connect("123.456.789", "DB2", "BB"); With the php I believe it's possible. Thx. |
//this example demonstrates how to use more connections new SQLPtr[2]; //global var ... Function() { SQLPtr[0] = mysql_connect(...); SQLPtr[1] = mysql_connect(...); mysql_query("SELECT a FROM table WHERE foo = 'bar'",(-1),(-1),SQLPtr[0]); //select query in the first DB mysql_query("UPDATE b SET bar = 'foo'",(-1),(-1),SQLPtr[1]); //update query in the second DB mysql_close(SQLPtr[1]); //close the 2nd DB connection, the other connection still exists
[20:34:59] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)
[05:18:28] CMySQLHandler::ProcessQueryThread(SELECT * FROM Drug_Plants WHERE Owner = 'Harry') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)
[16:02:06] CMySQLHandler::Query("OnUserLogin") - Custom callback query with index 102 started (ExtraID: -1)
[13:41:55] >> mysql_real_escape_string( Connection handle: 1 )
[13:41:55] CMySQLHandler::EscapeString(Galamonkey); - Escaped 10 characters to Galamonkey.
[13:41:55] >> mysql_query( Connection handle: 1 )
[13:41:55] CMySQLHandler::Query(resultID) - Threaded query with id 3 started. (Extra ID: 8)
[13:41:55] >> mysql_real_escape_string( Connection handle: 1 )
[13:41:55] CMySQLHandler::EscapeString(Peter_Toman); - Escaped 11 characters to Peter_Toman.
[13:41:55] >> mysql_query( Connection handle: 1 )
[13:41:55] CMySQLHandler::ProcessQueryThread(SELECT * FROM Drug_Plants WHERE Owner = 'Galamonkey') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)
[13:41:55] CMySQLHandler::Query(UPDATE `Accounts` SET `WantedLevel` = 3 WHERE `Username` = 'Peter_Toman') - An error has occured. (Error ID: 2013, Lost connection to MySQL server during query)
[13:41:55] OnQueryError() - Called.
[13:41:55] >> mysql_reconnect( Connection handle: 1 )
[13:41:55] CMySQLHandler::Disconnect() - Connection was closed.
[13:41:55] CMySQLHandler::Connect() - Connection was successful.
[13:41:55] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[13:41:55] OnQueryFinish(3,"SELECT * FROM Drug_Plants WHERE Owner = 'Galamonkey'") - Called.
[13:41:55] >> mysql_store_result( Connection handle: 1 )
[13:41:55] CMySQLHandler::StoreResult() - No data to store.
[13:41:55] >> mysql_num_rows( Connection handle: 1 )
[13:41:55] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)
[13:41:55] >> mysql_retrieve_row( Connection handle: 1 )
[13:41:55] CMySQLHandler::RetrieveRow() - You cannot call this function now. (Reason: Empty Result)
[13:41:55] >> mysql_free_result( Connection handle: 1 )
[13:41:55] CMySQLHandler::FreeResult() - The result is already empty.
Nice plugin
I wanted to know, since i've threaded some queries my server freezes sometimes. By checking in the logs i can find "Data is getting passed to OnQueryFinish() - (Threadsafe: No)". What does that "Threadsafe: No" mean ? I think it has something to do with the MySQL server's configuration, the threaded queries cannot execute in the specified thread, but i am not sure. If it has an importance, how could i activate it ? Thanks in advance. |
The plugin has been updated after almost one year once again due to a threading bug which was discovered by xxmitsu. I have added mutexes to make sure shared variables don't get accessed twice by different threads at the same time. (which causes random crashes) Besides that I have made some code improvements and fixed some small bugs.
I advice everyone who uses the threading capabilities to update to R6, the files are as usual in the first post. Great thanks for this release goes to xxmitsu for testing and compiling the plugin on Debian5 and CentOS. |
Hey, was just searching the forums for a solution and this guy had the same problem..
The bug is back! |
[13:41:55] OnQueryError() - Called.
another small problem.. R6
my server kinda like.. disconnects from the mysql server around 27 - 35 seconds after connection.. this only happens when I gmx |
public OnQueryError(errorid, error[], resultid, extraid, callback[], query[], connectionHandle)
{
switch(errorid)
{
case CR_COMMAND_OUT_OF_SYNC: {
mysql_free_result();
printf("[Mysql Error] - Commands Out Of Sync For Thread ID: %d", resultid);
}
case ER_UNKNOWN_TABLE: printf("[Mysql Error] - Unknown table '%s' in %s", error, query);
case ER_SYNTAX_ERROR: printf("[Mysql Error] - Something is wrong in your syntax, query: %s", query);
case CR_SERVER_GONE_ERROR: mysql_reconnect();
case CR_SERVER_LOST: mysql_reconnect();
case CR_SERVER_LOST_EXTENDED: mysql_reconnect();
}
if(errorid == CR_SERVER_LOST && resultid == THREAD_INITIATE_GROUPS) mysql_query("SELECT * FROM Groups", THREAD_INITIATE_GROUPS);
printf("EID: %d | Error: %s | Query: %s", errorid, error, query);
return 1;
}
Are you using threded queries mixed with standard queries ?(if yes, it could be the problem) are you freeing the results after storing them ?
[...] EDIT: I've just read that this problem only appears on gmx. Well, I can't tell you for sure because I NEVER gmx. I always prefer killing/restarting the server process. |
I can't pronounce myself regarding the gmx issue because I'm not using gmx. But perhaps using threaded with non-treaded queries can lead to unexpected results (I don't know this either because all my queries are threded).
|
Thanks AndreT,
i tested with Debian-mysqlR6-normal.tar.gz and the error is gone. I have ia32-libs already installed. But now i get this error: Failed (libmysqlclient_r.so.16: cannot open shared object file: No such file or directory) In startpost is only the libmysqlclient.so.15. libmysqlclient16 is installed in the newest version. Now starts my server, and if a player join i get this message in console: ./samp03svr: symbol lookup error: plugins/mysql.so: undefined symbol: compress greetings |