diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2021-07-31 12:55:21 +0530 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-09-15 08:55:34 +0200 |
commit | ea06c67a49cf6f4b8daa7287454faba6b7cae874 (patch) | |
tree | 5ca3baa1ed755803a16c43d36b10fe2896b22fbe /sql/sql_class.h | |
parent | 50e08f3da00bbc800de7eec278ad98cf0acd0845 (diff) | |
download | mariadb-git-ea06c67a49cf6f4b8daa7287454faba6b7cae874.tar.gz |
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.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index e569fcd32d6..791e67b4f59 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5502,6 +5502,29 @@ public: { lex= backup_lex; } + + /* + Stores the the processed record during INSERT/REPLACE. Used for assigning + value of error_index in case of warning or error. + */ + ulonglong current_insert_index; + + /* + Error may take place in prepare phase and it might not be because of + rows/values we are inserting into the table, it could be because of say + something like wrong field name. In such case we want to return 0 + for error index. + */ + ulonglong correct_error_index(uint error_no) + { + if (error_no == ER_FIELD_SPECIFIED_TWICE || + error_no == ER_BAD_FIELD_ERROR || + error_no == ER_VIEW_NO_INSERT_FIELD_LIST || + error_no == ER_VIEW_MULTIUPDATE) + return 0; + + return current_insert_index; + } }; |