From ea06c67a49cf6f4b8daa7287454faba6b7cae874 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Sat, 31 Jul 2021 12:55:21 +0530 Subject: MDEV-10075: Provide index of error causing error in array INSERT 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. --- sql/sql_get_diagnostics.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/sql_get_diagnostics.h') diff --git a/sql/sql_get_diagnostics.h b/sql/sql_get_diagnostics.h index f283aa5b2c6..69432f9cf86 100644 --- a/sql/sql_get_diagnostics.h +++ b/sql/sql_get_diagnostics.h @@ -254,7 +254,8 @@ public: CURSOR_NAME, MESSAGE_TEXT, MYSQL_ERRNO, - RETURNED_SQLSTATE + RETURNED_SQLSTATE, + ERROR_INDEX }; /** -- cgit v1.2.1