Problem with SQLx
Hello. I have a problem. I writing a plugin for CS 1.6, which check messages and nicknames for advertising (regular expressions). RegEx patterns contains in the database and updating one time in the function plugin_cfg ().
There are about 10 tables.
7 contains patterns.
1 log table
2 ban tables
Most SQL read/write requests executes on log and ban tables (if plugin has found advertising at chat message).
Problem: This plugin makes random server's crash only after changelevel.
I tried various versions of amxmodx & server's builds, but it didn't help.
Code (reduced):
Code:
new Handle:SQL_Tuple
new Handle:SQL_Connection
public plugin_init()
{
register_cvar("ar_sql_host", "127.0.0.1")
// ...
}
public plugin_end()
{
SQL_FreeHandle(SQL_Connection)
SQL_FreeHandle(SQL_Tuple)
}
public plugin_cfg()
{
get_cvar_string("ar_sql_host",host,30)
// ...
// SQL CONNECTION ========================================================================================
SQL_Tuple = SQL_MakeDbTuple(host,user,pass,dbase)
new err, error[256]
SQL_Connection = SQL_Connect(SQL_Tuple, err, error, charsmax(error))
if(SQL_Connection != Empty_Handle)
{
log_amx("[SQLx connect ok]")
}
else
{
log_amx("[SQLX sql error] %s ",error)
pause("a")
}
// ========================================================================================================
// loading regex pattenrs form tables (one time)
}
// sql function example
public sql_get_ucp_table_id(ucpid[9])
{
if(SQL_Connection == Empty_Handle) return -1
new Handle:query = SQL_PrepareQuery(SQL_Connection,"SELECT id FROM `%s` WHERE ucp = '%s'", ucps_table, ucpid)
SQL_Execute(query)
if (SQL_NumResults(query) > 0)
{
new result = SQL_ReadResult(query, 0)
SQL_FreeHandle(query)
return result
}
SQL_FreeHandle(query)
return -1
}
|