summaryrefslogtreecommitdiff
path: root/sql/sql_error.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2020-06-22 18:21:21 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2020-10-12 17:07:33 +0200
commit1df5a92df899d033841d77c34e1512e2b118b2ec (patch)
treeff7879dbeb9f0afd8ef95cfa4aad0b5ba741ea20 /sql/sql_error.cc
parent861cd4ce286e7b41cc38facfc86c358e15161a74 (diff)
downloadmariadb-git-bb-10.5-MDEV-21916.tar.gz
MDEV-21916: COM_STMT_BULK_EXECUTE with RETURNING insert wrong valuesbb-10.5-MDEV-21916
To allocate new net buffer to avoid changing bufer we are reading.
Diffstat (limited to 'sql/sql_error.cc')
-rw-r--r--sql/sql_error.cc37
1 files changed, 27 insertions, 10 deletions
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index b3ef0d89a98..a753af2b34d 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -372,7 +372,7 @@ Diagnostics_area::set_eof_status(THD *thd)
{
DBUG_ENTER("set_eof_status");
/* Only allowed to report eof if has not yet reported an error */
- DBUG_ASSERT(! is_set());
+ DBUG_ASSERT(!is_set() || (m_status == DA_EOF_BULK && is_bulk_op()));
/*
In production, refuse to overwrite an error or a custom response
with an EOF packet.
@@ -380,16 +380,33 @@ Diagnostics_area::set_eof_status(THD *thd)
if (unlikely(is_error() || is_disabled()))
return;
- /*
- If inside a stored procedure, do not return the total
- number of warnings, since they are not available to the client
- anyway.
- */
- m_statement_warn_count= (thd->spcont ?
- 0 :
- current_statement_warn_count());
+ if (m_status == DA_EOF_BULK)
+ {
+ /*
+ If inside a stored procedure, do not return the total
+ number of warnings, since they are not available to the client
+ anyway.
+ */
+ if (!thd->spcont)
+ m_statement_warn_count+= current_statement_warn_count();
+ }
+ else
+ {
+ /*
+ If inside a stored procedure, do not return the total
+ number of warnings, since they are not available to the client
+ anyway.
+ */
+ if (thd->spcont)
+ {
+ m_statement_warn_count= 0;
+ m_affected_rows= 0;
+ }
+ else
+ m_statement_warn_count= current_statement_warn_count();
+ m_status= (is_bulk_op() ? DA_EOF_BULK : DA_EOF);
+ }
- m_status= DA_EOF;
DBUG_VOID_RETURN;
}