diff options
| author | 2006-07-22 13:30:34 +0000 | |
|---|---|---|
| committer | 2006-07-22 13:30:34 +0000 | |
| commit | fcc4355c4b80e6598aa93dc7f8f40f80e979582c (patch) | |
| tree | a247141de94522b1eb1a3f8b3cd02b188cda364c /src/modules/extra/m_mysql.cpp | |
| parent | Allocate id properly (diff) | |
I hate the fucking mysql devs. Craq smoking bastards.
Upon Insert, number of rows is the number of rows effected but the number of columns is 0?????
Add check to MySQLreply::Rows() to ensure the user doesnt see N rows and 0 columns!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4510 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra/m_mysql.cpp')
| -rw-r--r-- | src/modules/extra/m_mysql.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index acfdf8214..38c3b4c93 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -254,16 +254,14 @@ class MySQLresult : public SQLresult } rows++; } - cols = field_count; mysql_free_result(res); } - log(DEBUG, "Created new MySQL result; %d rows, %d columns", rows, cols); + log(DEBUG, "Created new MySQL result; %d rows, %d columns", rows, colnames.size()); } MySQLresult(Module* self, Module* to, SQLerror e, unsigned int id) : SQLresult(self, to, id), currentrow(0) { rows = 0; - cols = 0; error = e; log(DEBUG,"Created new MySQLresult of error type"); } @@ -274,12 +272,18 @@ class MySQLresult : public SQLresult virtual int Rows() { - return rows; + /* An INSERT can return 0 columns, but N rows. This is unsafe to + * allow the user to 'see'. Go figure. I hate you, MySQL devs. + */ + if (colnames.size()) + return rows; + else + return 0; } virtual int Cols() { - return cols; + return colnames.size(); } virtual std::string ColName(int column) @@ -308,7 +312,7 @@ class MySQLresult : public SQLresult virtual SQLfield GetValue(int row, int column) { - if ((row >= 0) && (row < rows) && (column >= 0) && (column < cols)) + if ((row >= 0) && (row < rows) && (column >= 0) && (column < Cols())) { return fieldlists[row][column]; } |
