01.02.2010, 19:09
Hi there again, Ethan ![Wink](images/smilies/wink.png)
Simply a great update, it's a huge progress from 1.0.x. Nice to see you using C++'s operators now, but I still could find a few mistakes![Smiley](images/smilies/smile.png)
There's one thing I mentioned after G-Stylezz's R3 release. You both decided to return a constant number in mysql_query. Your version at least returns 1 instead of 0.
I've modified this function. First of all, you still didn't make it free the allocated *query after an error from mysql_real_query(). I also allowed myself to adjust returned values a little. I hope you're okay with that![Wink](images/smilies/wink.png)
I don't like going through all 20 possible mysql connections (even in a separate thread), while most of plugin's uses won't require more than just one connetion open at a time. I actually think you could reduce it to just three - if anyone needs a bigger one, they can simply modify and recompile the plugin. You didn't choose std::vector to store them - was it because of it's overhead?
And there's also the thing Mike has already mentioned - use ProcessTick() and another queue to call OnMysqlQuery().
![Wink](images/smilies/wink.png)
Simply a great update, it's a huge progress from 1.0.x. Nice to see you using C++'s operators now, but I still could find a few mistakes
![Smiley](images/smilies/smile.png)
There's one thing I mentioned after G-Stylezz's R3 release. You both decided to return a constant number in mysql_query. Your version at least returns 1 instead of 0.
I've modified this function. First of all, you still didn't make it free the allocated *query after an error from mysql_real_query(). I also allowed myself to adjust returned values a little. I hope you're okay with that
![Wink](images/smilies/wink.png)
I don't like going through all 20 possible mysql connections (even in a separate thread), while most of plugin's uses won't require more than just one connetion open at a time. I actually think you could reduce it to just three - if anyone needs a bigger one, they can simply modify and recompile the plugin. You didn't choose std::vector to store them - was it because of it's overhead?
And there's also the thing Mike has already mentioned - use ProcessTick() and another queue to call OnMysqlQuery().
Quote:
// native mysql_query(const query[]); PLUGIN_FUNCTION n_mysql_query( AMX* amx, cell* params ) { int h = MY_HANDLE(3); if (!PARAM_COUNT(3)) { GenerateError(h, "'mysql_query' called with incorrect param count", P_ERROR_INCPARAMCNT); return 0; } if (!my[h].connected) { GenerateError(h, "'mysql_reload' called when not connected to any database", P_ERROR_DBNOCONN); return 0; } if (my[h].result) { mysql_free_result(my[h].result); my[h].result = NULL; } if (params[2] != -1) { queryInfo mysqlQueue; mysqlQueue.query = GetParam(amx, params[1]); mysqlQueue.resultId = params[2]; my[h].queueInfo.push(mysqlQueue); return -1; } else { const char *query = GetParam(amx, params[1]); my[h].state = mysql_real_query(my[h].mysql, query, strlen(query)+1); if (my[h].state != NULL) { GenerateError(h, "Could not execute query", mysql_errno(my[h].mysql)); delete query; return 0; } if (my[h].logging == LOG_ALL) mysql_log("'mysql_query' executed: \"%s\" with result: \"%d\".", query, my[h].state); delete query; return 1; } //no constant return here } |