diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-22 16:02:17 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-22 16:02:17 +0000 |
commit | c9408c6c43e5ea2be81fe070c3e96f84f8c6d5dc (patch) | |
tree | 2c09cf246e7f5d20662d66a994836fc3aa852aba /src | |
parent | acb8786c19bc26a95ae68817cf5f8ec932e67b88 (diff) |
Alter for Rows() == X, Cols() == 0 for 'X rows affected' queries
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4515 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/extra/m_mysql.cpp | 8 | ||||
-rw-r--r-- | src/modules/extra/m_sqllog.cpp | 6 | ||||
-rw-r--r-- | src/modules/extra/m_sqlv2.h | 13 |
3 files changed, 12 insertions, 15 deletions
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 38c3b4c93..daf59a5d9 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -272,13 +272,7 @@ class MySQLresult : public SQLresult virtual int 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; + return rows; } virtual int Cols() diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp index add188c8c..4ce24822d 100644 --- a/src/modules/extra/m_sqllog.cpp +++ b/src/modules/extra/m_sqllog.cpp @@ -86,7 +86,7 @@ class QueryInfo case FIND_SOURCE: // "SELECT id,actor FROM ircd_log_actors WHERE actor='"+nick+"'" // If we find it, advance to FIND_NICK state, otherwise go to INSERT_SOURCE - if (res->Rows()) + if (res->Cols()) { if (sourceid == -1) { @@ -136,7 +136,7 @@ class QueryInfo case FIND_NICK: // "SELECT id,actor FROM ircd_log_actors WHERE actor='"+nick+"'" // If we find it, advance to FIND_HOST state, otherwise go to INSERT_NICK - if (res->Rows()) + if (res->Cols()) { if (nickid == -1) { @@ -183,7 +183,7 @@ class QueryInfo case FIND_HOST: // "SELECT id,hostname FROM ircd_log_hosts WHERE hostname='"+host+"'" // If we find it, advance to INSERT_LOGENTRY state, otherwise go to INSERT_HOST - if (res->Rows()) + if (res->Cols()) { if (hostid == -1) { diff --git a/src/modules/extra/m_sqlv2.h b/src/modules/extra/m_sqlv2.h index 336fc8903..3272efec5 100644 --- a/src/modules/extra/m_sqlv2.h +++ b/src/modules/extra/m_sqlv2.h @@ -315,16 +315,19 @@ public: * Return the number of rows in the result * Note that if you have perfomed an INSERT * or UPDATE query or other query which will - * not return rows, this value will NOT be - * the number of affected rows, as this would - * then indicate there are rows in the set, - * which there are not. + * not return rows, this will return the + * number of affected rows, and SQLresult::Cols() + * will contain 0. In this case you SHOULD NEVER + * access any of the result set rows, as there arent any! * @returns Number of rows in the result set. */ virtual int Rows() = 0; /** - * Return the number of columns in the result + * Return the number of columns in the result. + * If you performed an UPDATE or INSERT which + * does not return a dataset, this value will + * be 0. * @returns Number of columns in the result set. */ virtual int Cols() = 0; |