mirror of
				https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
				synced 2025-10-31 02:27:56 +00:00 
			
		
		
		
	another attempt at #1187: retry mysql_stmt_prepare if server has gone away
This commit is contained in:
		| @@ -55,8 +55,17 @@ void StatementExecutor::prepare(const std::string& query) | |||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	if (mysql_stmt_prepare(_pHandle, query.c_str(), static_cast<unsigned int>(query.length())) != 0) | 	int rc = mysql_stmt_prepare(_pHandle, query.c_str(), static_cast<unsigned int>(query.length())); | ||||||
| 		throw StatementException("mysql_stmt_prepare error", _pHandle, query); | 	if (rc != 0) | ||||||
|  | 	{ | ||||||
|  | 		// retry if connection lost | ||||||
|  | 		int err = mysql_errno(_pSessionHandle); | ||||||
|  | 		if (err == 2006 /* CR_SERVER_GONE_ERROR */ || err == 2013 /* CR_SERVER_LOST */) | ||||||
|  | 		{ | ||||||
|  | 			rc = mysql_stmt_prepare(_pHandle, query.c_str(), static_cast<unsigned int>(query.length())); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	if (rc != 0) throw StatementException("mysql_stmt_prepare error", _pHandle, query); | ||||||
|  |  | ||||||
| 	_query = query; | 	_query = query; | ||||||
| 	_state = STMT_COMPILED; | 	_state = STMT_COMPILED; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Guenter Obiltschnig
					Guenter Obiltschnig