diff options
author | Alexander Nozdrin <alik@sun.com> | 2010-05-14 09:28:51 +0400 |
---|---|---|
committer | Alexander Nozdrin <alik@sun.com> | 2010-05-14 09:28:51 +0400 |
commit | 4333980a493e7062e108899b34cc809b03862c34 (patch) | |
tree | f19fd6d634984242eb5cb0583cf805e7ec43ebc9 /sql/sql_delete.cc | |
parent | f9101d98b73f8353bc1de0959c6a1a35a91a9f7b (diff) | |
download | mariadb-git-4333980a493e7062e108899b34cc809b03862c34.tar.gz |
Patch for Bug#21818 (Return value of ROW_COUNT() is incorrect
for ALTER TABLE, LOAD DATA).
ROW_COUNT is now assigned according to the following rules:
- In my_ok():
- for DML statements: to the number of affected rows;
- for DDL statements: to 0.
- In my_eof(): to -1 to indicate that there was a result set.
We derive this semantics from the JDBC specification, where int
java.sql.Statement.getUpdateCount() is defined to (sic) "return the
current result as an update count; if the result is a ResultSet
object or there are no more results, -1 is returned".
- In my_error(): to -1 to be compatible with the MySQL C API and
MySQL ODBC driver.
- For SIGNAL statements: to 0 per WL#2110 specification. Zero is used
since that's the "default" value of ROW_COUNT in the diagnostics area.
sql/protocol.cc:
Fix a typo.
sql/sql_class.h:
- Introduce THD::get_row_count_func() / THD::set_row_count_func();
- Remove the CF_HAS_ROW_COUNT define
sql/sql_parse.cc:
CF_HAS_ROW_COUNT was eliminated.
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r-- | sql/sql_delete.cc | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 2a8503077aa..10bdb8a22a6 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -187,8 +187,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (prune_partitions(thd, table, conds)) { free_underlaid_joins(thd, select_lex); - thd->row_count_func= 0; - my_ok(thd, (ha_rows) thd->row_count_func); // No matching records + // No matching record + my_ok(thd, 0); DBUG_RETURN(0); } #endif @@ -204,7 +204,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { delete select; free_underlaid_joins(thd, select_lex); - thd->row_count_func= 0; /* Error was already created by quick select evaluation (check_quick()). TODO: Add error code output parameter to Item::val_xxx() methods. @@ -213,7 +212,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, */ if (thd->is_error()) DBUG_RETURN(TRUE); - my_ok(thd, (ha_rows) thd->row_count_func); + my_ok(thd, 0); /* We don't need to call reset_auto_increment in this case, because mysql_truncate always gives a NULL conds argument, hence we never @@ -460,8 +459,7 @@ cleanup: If a TRUNCATE TABLE was issued, the number of rows should be reported as zero since the exact number is unknown. */ - thd->row_count_func= reset_auto_increment ? 0 : deleted; - my_ok(thd, (ha_rows) thd->row_count_func); + my_ok(thd, reset_auto_increment ? 0 : deleted); DBUG_PRINT("info",("%ld records deleted",(long) deleted)); } DBUG_RETURN(error >= 0 || thd->is_error()); @@ -1058,8 +1056,7 @@ bool multi_delete::send_eof() if (!local_error) { - thd->row_count_func= deleted; - ::my_ok(thd, (ha_rows) thd->row_count_func); + ::my_ok(thd, deleted); } return 0; } |