summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2021-07-31 12:55:21 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2021-09-09 14:39:03 +0530
commit9295921e8740335e12b2697ffa8e444cc942b0a2 (patch)
tree7a5642d5c8b4ae1d56c245355f6d868a04fc938b /sql/sql_class.cc
parent76149650764ea9660ae05d4987ea6c91534851ab (diff)
downloadmariadb-git-bb-10.7-MDEV-10075.tar.gz
MDEV-10075: Provide index of error causing error in array INSERTbb-10.7-MDEV-10075
Extended the parser for GET DIAGNOSTICS to use ERROR_INDEX to get warning/error index. Error information is stored in Sql_condition. So it can be used to store the index of warning/error too. THD::current_insert_index keeps a track of count for each row that is processed or going to be inserted in the table (or first row in case of prepare phase). When an error occurs, first we need to fetch corrected error index (using correct_error_index()) for an error number. This is needed because in prepare phase, the error may not be because of rows/values. In such case, correct value of error_index should be 0. Once correct value if fetched, assign it to Sql_condition::error_index when the object is created during error/warning. This error_index variable is returned when ERROR_INDEX is used in GET DIAGNOSTICS.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index c88bfc4c484..34d220aa27e 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -908,6 +908,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
org_charset= 0;
/* Restore THR_THD */
set_current_thd(old_THR_THD);
+ current_insert_index= 0;
}
@@ -1055,6 +1056,8 @@ Sql_condition* THD::raise_condition(uint sql_errno,
{
Diagnostics_area *da= get_stmt_da();
Sql_condition *cond= NULL;
+ ulonglong saved_error_index;
+
DBUG_ENTER("THD::raise_condition");
DBUG_ASSERT(level < Sql_condition::WARN_LEVEL_END);
@@ -1149,7 +1152,10 @@ Sql_condition* THD::raise_condition(uint sql_errno,
if (likely(!(is_fatal_error && (sql_errno == EE_OUTOFMEMORY ||
sql_errno == ER_OUTOFMEMORY))))
{
+ saved_error_index= this->current_insert_index;
+ this->current_insert_index= this->correct_error_index(sql_errno);
cond= da->push_warning(this, sql_errno, sqlstate, level, ucid, msg);
+ this->current_insert_index= saved_error_index;
}
DBUG_RETURN(cond);
}