diff options
-rw-r--r-- | mysql-test/r/sp.result | 5 | ||||
-rw-r--r-- | mysql-test/t/sp.test | 2 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 20 |
4 files changed, 28 insertions, 1 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 631e640366d..cd5c2aa67c1 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -823,6 +823,11 @@ delete from t1| select row_count()| row_count() 0 +select * from t1| +id data +select row_count()| +row_count() +-1 drop procedure rc| create procedure bug822(a_id char(16), a_data int) begin diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index f2bbf8d939c..abd3901f234 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -947,6 +947,8 @@ delete from t1| select row_count()| delete from t1| select row_count()| +select * from t1| +select row_count()| drop procedure rc| diff --git a/sql/sql_class.h b/sql/sql_class.h index 14e4ce0044b..3f1236851b3 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -829,7 +829,7 @@ public: bool charset_is_system_charset, charset_is_collation_connection; bool slow_command; - ulong row_count_func; /* For the ROW_COUNT() function */ + longlong row_count_func; /* For the ROW_COUNT() function */ sp_rcontext *spcont; // SP runtime context sp_cache *sp_proc_cache; sp_cache *sp_func_cache; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 63873bcb6b1..4ea1fcf3301 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3727,6 +3727,26 @@ unsent_create_error: } thd->proc_info="query end"; // QQ + /* + The return value for ROW_COUNT() is "implementation dependent" if + the statement is not DELETE, INSERT or UPDATE (or a CALL executing + such a statement), but -1 is what JDBC and ODBC wants. + */ + switch (lex->sql_command) { + case SQLCOM_UPDATE: + case SQLCOM_UPDATE_MULTI: + case SQLCOM_REPLACE: + case SQLCOM_INSERT: + case SQLCOM_REPLACE_SELECT: + case SQLCOM_INSERT_SELECT: + case SQLCOM_DELETE: + case SQLCOM_DELETE_MULTI: + case SQLCOM_CALL: + break; + default: + thd->row_count_func= -1; + } + // We end up here if res == 0 and send_ok() has been done, // or res != 0 and no send_error() has yet been done. if (res < 0) |