SA-MP Forums Archive
MySQL instantly releases result? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL instantly releases result? (/showthread.php?tid=389662)



[solved]MySQL instantly releases result? - 13th - 03.11.2012

Hi, it seems like MySQL releases the results right after it stores it. I'm using BlueG's MySQL plugin R7. What am I doing wrong?

Код:
[02:41:14] >> mysql_connect(127.0.0.1, root, ****, ******) on port 3306
[02:41:14] CMySQLHandler::Connect() - Connection was successful.
[02:41:14] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[02:41:14] >> mysql_query_callback( Connection handle: 2 )
[02:41:14] Passing query SELECT * FROM users WHERE NAME = 'Name_Name' LIMIT 0,1 | i
[02:41:14] ProcessQueryThread(AnotherFunction) - Query was successful. (SELECT * FROM users WHERE NAME = 'Name_Name' LIMIT 0,1)
[02:41:14] ProcessQueryThread(AnotherFunction) - Data caching enabled.
[02:41:14] CMySQLHandler::StoreResult() - Result was stored.
[02:41:14] CMySQLHandler::FreeResult() - Result was successfully free'd.
[02:41:14] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[02:41:14] AnotherFunction(i) - Threaded function called.
[02:41:14] >> cache_get_data( Connection handle: 1 )
[02:41:14] ProcessTick() - The cache has been cleared.
Код:
forward Function(playerid);
public Function(playerid){
	new sqlQuery[128], name[MAX_NAME_LENGHT];
	GetPlayerName(playerid, name, sizeof(name));
	format(sqlQuery, sizeof(sqlQuery), "SELECT * FROM users WHERE NAME = '%s' LIMIT 0,1", name);
	mysql_function_query(mysql, sqlQuery, true, "AnotherFunction", "i", playerid);
	return 1;
}

forward AnotherFunction(playerid);
public AnotherFunction(playerid){
	new rows, fields;
	cache_get_data(rows, fields);
	printf("rows: %i, fields: %i", rows, fields);
	return 1;
}



Re: MySQL instantly releases result? - Vince - 03.11.2012

Connection handle 2 seems odd. Especially since you're fetching a result on handle 1.


Re: MySQL instantly releases result? - 13th - 03.11.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
Connection handle 2 seems odd. Especially since you're fetching a result on handle 1.
You're right. But why would it do that?

mysql = mysql_connect() @ OnGameModeInit


Re: MySQL instantly releases result? - ReneG - 03.11.2012

I'm not sure about why the connection handle is 2, but the result isn't being freed right after being stored. The code between storing and freeing is just executing in less than a millisecond, which is the smallest unit of time you can use in the pawn API.


Re: MySQL instantly releases result? - 13th - 03.11.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
I'm not sure about why the connection handle is 2, but the result isn't being freed right after being stored. The code between storing and freeing is just executing in less than a millisecond, which is the smallest unit of time you can use in the pawn API.
Yeah, but it's frees the result before calling the AnotherFunction..


Re: MySQL instantly releases result? - ReneG - 03.11.2012

Quote:
Originally Posted by 13th
Посмотреть сообщение
Yeah, but it's frees the result before calling the AnotherFunction..
I see what you mean, but It's nothing to worry about. AFAIK, the result is stored in the cache, the result is freed, and then the cache functions are self explanatory.

I pulled this straight out of my logs
Код:
[07:28:08] Passing query SELECT * FROM `settings` LIMIT 1 | iii
[07:28:08] ProcessQueryThread(OnServerQueryFinish) - Query was successful. (SELECT * FROM `settings` LIMIT 1)
[07:28:08] ProcessQueryThread(OnServerQueryFinish) - Data caching enabled.
[07:28:08] CMySQLHandler::StoreResult() - Result was stored.
[07:28:08] CMySQLHandler::FreeResult() - Result was successfully free'd.
[07:28:08] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[07:28:08] OnServerQueryFinish(iii) - Threaded function called.
[07:28:08] >> cache_get_data( Connection handle: 1 )
[07:28:08] ProcessTick() - The cache has been cleared.
and I can assure you all the data was loaded correctly.


Re: MySQL instantly releases result? - 13th - 03.11.2012

Uh... I'm sorry. I don't know why this happened, but I just the server and it fixed itself This time the connection handle is consistent..
But thanks for the help! Appreciate it.