Oha, da ist aber die Kacke am dampfen:
Der Problemverursacher waren folgende Zeilen im Filterscript:
mysql_function_query(cH,"CALL TestProz(25);","OnTest","");
//woanders
forward OnTest();
public OnTest()
{
new rows=cache_get_row_count();
new name[25];
cache_get_row(0,0,name);
printf("Name: %s",name);
return 1;
}
Der Serverlog sieht wiefolgt aus:
[22:28:14] Name: TestEvent2 // Das ist die Debugnachricht bei OnTest!
[22:28:14] ---------------- MYSQL ERROR ------------------ // Alle SELECT-Querys dannach, egal ob Filterscript oder Gamemode, können nicht ausgeführt werden.
[22:28:14] Error #2014 im MySQL-Syntax:
[22:28:14] Commands out of sync; you can't run this command now
[22:28:14] Callback: 'EM_OnLoadFS'
[22:28:14] Query: 'SELECT Name FROM EM_E'
DerMySQL-Log:
[22:28:14] [DEBUG] mysql_tquery - connection: 1, query: "CALL TestProz(25);", callback: "OnTest", format: "(null)"
[22:28:14] [DEBUG] mysql_tquery - connection: 1, query: "SELECT Name FROM EM_E", callback: "EM_OnLoadFS", format: "(null)"
[22:28:14] [DEBUG] CMySQLQuery::Execute[OnTest] - starting query execution
[22:28:14] [DEBUG] CMySQLQuery::Execute[OnTest] - query was successfully executed within 0.271 milliseconds
[22:28:14] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[22:28:14] [DEBUG] CMySQLQuery::Execute[EM_OnLoadFS] - starting query execution
[22:28:14] [ERROR] CMySQLQuery::Execute[EM_OnLoadFS] - (error #2014) Commands out of sync; you can't run this command now
[22:28:14] [DEBUG] CMySQLQuery::Execute[EM_OnLoadFS] - error will be triggered in OnQueryError
So sieht meine Prozedor aus (die man mit MySQL erstellt und mit CALL aufruft:
CREATE DEFINER=`root`@`localhost` PROCEDURE `TestProz`(IN `eID` SMALLINT(4))
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
SELECT Name FROM EM_E WHERE ID=eID
Wenn ich den Query mit dem CALL auskommentiere, funktionieren alle SELECT-Querys.
Ist das ein Fehler im Plugin oder verwende ich die PROCEDURE-Funktion falsch?
Hier nochmal ein ausführlicher Test:
Folgendes Script wurde als Gamemode geladen (ohne jegliche Filterscripts!)
#include <a_samp>
#include <a_mysql>
public OnGameModeInit()
{
cH=mysql_connect("127.0.0.1","root","samp","1234");
if(!cH)
{
printf("Verbindung fehlgeschlagen!");
SendRconCommand("exit");
}
mysql_log(LOG_ALL);
mysql_function_query(cH,"CALL TestProz(10);","OnCall","");
return 1;
}
forward OnCall();
public OnCall()
{
printf("Da sind wir.");
printf("Endergebnis: Spieler-ID 10 hat Level %i. ",cache_get_row_int(0,0));
mysql_function_query(cH,"SELECT 1","OnCall2","");
print("Query!");
return 1;
}
forward OnCall2();
public OnCall2()
{
printf("Nummer %i",cache_get_row_int(0,0));
return 1;
}
public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
{
print("---------------- MYSQL ERROR ------------------");
printf("Error #%02d im MySQL-Syntax:",errorid);
printf(error);
printf("Callback: '%s'",callback);
printf("Query: '%s'",query);
print("-----------------------------------------------");
return 1;
}
----------Loaded log file: "server_log.txt".----------SA-MP Dedicated Server----------------------v0.3z-R2, (C)2005-2014 SA-MP Team[22:58:57] filterscripts = "" (string)[22:58:57] [22:58:57] Server Plugins[22:58:57] --------------[22:58:57] Loading plugin: mysql[22:58:57] >> plugin.mysql: R39-2 successfully loaded.[22:58:57] Loaded.[22:58:57] Loading plugin: crashdetect[22:58:57] CrashDetect v4.10 is OK.[22:58:57] Loaded.[22:58:57] Loaded 2 plugins.[22:58:57] [22:58:57] Ban list[22:58:57] --------[22:58:57] Loaded: samp.ban[22:58:57] [22:58:57] [22:58:57] Filterscripts[22:58:57] ---------------[22:58:57] Loaded 0 filterscripts.[22:58:57] Number of vehicle models: 0[22:58:57] Da sind wir.[22:58:57] Endergebnis: Spieler-ID 10 hat Level 22. [22:58:57] Query![22:58:57] ---------------- MYSQL ERROR ------------------[22:58:57] Error #2014 im MySQL-Syntax:[22:58:57] Commands out of sync; you can't run this command now[22:58:57] Callback: 'OnCall2'[22:58:57] Query: 'SELECT 1'[22:58:57] -----------------------------------------------
[22:58:57] [DEBUG] mysql_tquery - connection: 1, query: "CALL TestProz(10);", callback: "OnCall", format: "(null)"[22:58:57] [DEBUG] CMySQLConnection::Connect - establishing connection to database...[22:58:57] [DEBUG] CMySQLConnection::Connect - establishing connection to database...[22:58:57] [DEBUG] CMySQLConnection::Connect - connection was successful[22:58:57] [DEBUG] CMySQLConnection::Connect - connection was successful[22:58:57] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled[22:58:57] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled[22:58:57] [DEBUG] CMySQLQuery::Execute[OnCall] - starting query execution[22:58:57] [DEBUG] CMySQLQuery::Execute[OnCall] - query was successfully executed within 0.241 milliseconds[22:58:57] [DEBUG] CMySQLResult::CMySQLResult() - constructor called[22:58:57] [DEBUG] Calling callback "OnCall"..[22:58:57] [DEBUG] cache_get_row_int - row: 0, field_idx: 0, connection: 1[22:58:57] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "22"[22:58:57] [DEBUG] mysql_tquery - connection: 1, query: "SELECT 1", callback: "OnCall2", format: "(null)"[22:58:57] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called[22:58:57] [DEBUG] CMySQLQuery::Execute[OnCall2] - starting query execution[22:58:57] [ERROR] CMySQLQuery::Execute[OnCall2] - (error #2014) Commands out of sync; you can't run this command now[22:58:57] [DEBUG] CMySQLQuery::Execute[OnCall2] - error will be triggered in OnQueryError[22:58:57] [DEBUG] Calling callback "OnQueryError"..
Create-Code der Procedure:
CREATE DEFINER=`root`@`localhost` PROCEDURE `TestProz`(IN `Num` SMALLINT(4)) LANGUAGE SQL NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER COMMENT ''SELECT Level FROM Accounts WHERE Nummer=Num
Was mir sehr komisch vorkommt ist, dass zuerst der CALL-Query ausgesand wird, und dann die Verbindung aufgebaut wird zum MySQL-Server.
Oder wurde sie vielleicht aufgebaut, aber nicht geloggt? Und dann wurde sie wieder verloren?
Jeffry: