mysql_real_query returning error... 1 ??
Posted by: Curt Hartung
Date: March 15, 2010 09:21AM

If I let the mysql connection get stale (no queries for at least an hour or so) I get the 'mysql has gone away' error, of course. So I added some code to reconnect it in this case.

	int ret = mysql_real_query( &m_sql, szSQLQueryString, len );
	if ( ret )
	{
		if ( m_reconnect && (ret == CR_SERVER_GONE_ERROR || ret == CR_SERVER_LOST) )
		{
			if ( !connect() )
			{
				log( "<1> MySQL err: went away[%s] query not not executed[%s]", mysql_error(&m_sql), szSQLQueryString );
				g_cSqlLock.unlock();
				return false;
			}
			else
			{
				ret = mysql_real_query( &m_sql, szSQLQueryString, len );
				if ( ret )
				{
					log( "<2> MySQL err[%s] query not executed[%s]", mysql_error(&m_sql), szSQLQueryString );
					g_cSqlLock.unlock();
					return false;
				}
			}
		}
		else
		{
			log( "<3> MySQL err[%d:%s] query not executed[%s]", ret, mysql_error(&m_sql), szSQLQueryString );
			g_cSqlLock.unlock();
			return false;
		}
	}

produces the output:

15 10:33:37.590> <3> MySQL err[1:MySQL server has gone away] query not executed[SELECT players.player_id,players.user_id,user_accounts.priv_level,players.name FROM players, user_accounts WHERE players.user_id=user_accounts.user_id AND user_accounts.user_name='jolly roger' AND user_accounts.password='testpass' AND players.universe_id=1]

A perfectly regular, well-formed query that routinely succeeds, returns error 200-what? no. 1. m_reconnect is 'true', and 'len' is correct.

I have checked this return value several times in several ways, and it is indeed a '1'. Of course I can work around this but was hoping for maybe some guidance and/or bug-reporting love?

-Curt



Edited 2 time(s). Last edit at 03/15/2010 09:24AM by Curt Hartung.

Options: ReplyQuote


Subject
Views
Written By
Posted
mysql_real_query returning error... 1 ??
1330
March 15, 2010 09:21AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.