mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
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.
This commit is contained in:
@@ -1005,10 +1005,10 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
if (values_list.elements == 1 && (!(thd->variables.option_bits & OPTION_WARNINGS) ||
|
||||
!thd->cuted_fields))
|
||||
{
|
||||
thd->row_count_func= info.copied + info.deleted +
|
||||
((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
|
||||
info.touched : info.updated);
|
||||
my_ok(thd, (ulong) thd->row_count_func, id);
|
||||
my_ok(thd, info.copied + info.deleted +
|
||||
((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
|
||||
info.touched : info.updated),
|
||||
id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1024,8 +1024,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
|
||||
(ulong) (info.deleted + updated),
|
||||
(ulong) thd->warning_info->statement_warn_count());
|
||||
thd->row_count_func= info.copied + info.deleted + updated;
|
||||
::my_ok(thd, (ulong) thd->row_count_func, id, buff);
|
||||
::my_ok(thd, info.copied + info.deleted + updated, id, buff);
|
||||
}
|
||||
thd->abort_on_warning= 0;
|
||||
DBUG_RETURN(FALSE);
|
||||
@@ -3337,7 +3336,7 @@ bool select_insert::send_eof()
|
||||
{
|
||||
int error;
|
||||
bool const trans_table= table->file->has_transactions();
|
||||
ulonglong id;
|
||||
ulonglong id, row_count;
|
||||
bool changed;
|
||||
THD::killed_state killed_status= thd->killed;
|
||||
DBUG_ENTER("select_insert::send_eof");
|
||||
@@ -3403,16 +3402,15 @@ bool select_insert::send_eof()
|
||||
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
|
||||
(ulong) (info.deleted+info.updated),
|
||||
(ulong) thd->warning_info->statement_warn_count());
|
||||
thd->row_count_func= info.copied + info.deleted +
|
||||
((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
|
||||
info.touched : info.updated);
|
||||
|
||||
row_count= info.copied + info.deleted +
|
||||
((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
|
||||
info.touched : info.updated);
|
||||
id= (thd->first_successful_insert_id_in_cur_stmt > 0) ?
|
||||
thd->first_successful_insert_id_in_cur_stmt :
|
||||
(thd->arg_of_last_insert_id_function ?
|
||||
thd->first_successful_insert_id_in_prev_stmt :
|
||||
(info.copied ? autoinc_value_of_last_inserted_row : 0));
|
||||
::my_ok(thd, (ulong) thd->row_count_func, id, buff);
|
||||
::my_ok(thd, row_count, id, buff);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user