1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-30366 Permit bulk implementation to return ALL individual results

COM_STMT_BULK_STMT new flag to server to returns all unitary results
This commit is contained in:
Sergei Golubchik
2023-12-04 18:49:39 +01:00
parent 73ed0a23eb
commit ea6975b1f1
10 changed files with 231 additions and 38 deletions

View File

@ -470,6 +470,7 @@ void upgrade_lock_type(THD *thd, thr_lock_type *lock_type,
the statement indirectly via a stored function or trigger:
if it is used, that will lead to a deadlock between the
client connection and the delayed thread.
- client explicitly ask to retrieve unitary changes
*/
if (specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE) ||
thd->variables.max_insert_delayed_threads == 0 ||
@ -480,6 +481,14 @@ void upgrade_lock_type(THD *thd, thr_lock_type *lock_type,
*lock_type= TL_WRITE;
return;
}
/* client explicitly asked to retrieved each affected rows and insert ids */
if (thd->need_report_unit_results())
{
*lock_type= TL_WRITE;
return;
}
if (thd->slave_thread)
{
/* Try concurrent insert */
@ -717,6 +726,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
uint value_count;
/* counter of iteration in bulk PS operation*/
ulonglong iteration= 0;
ulonglong last_affected_rows= 0;
ulonglong id;
COPY_INFO info;
TABLE *table= 0;
@ -931,7 +941,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
functions or invokes triggers since they may access
to the same table and therefore should not see its
inconsistent state created by this optimization.
So we call start_bulk_insert to perform nesessary checks on
So we call start_bulk_insert to perform necessary checks on
values_list.elements, and - if nothing else - to initialize
the code to make the call of end_bulk_insert() below safe.
*/
@ -1159,6 +1169,17 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
}
its.rewind();
iteration++;
/*
Save affected rows and insert id when collecting using results
*/
ulonglong new_affected_rows= info.copied + info.deleted +
((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
info.touched : info.updated);
thd->collect_unit_results(
table->file->insert_id_for_cur_row,
new_affected_rows - last_affected_rows);
last_affected_rows = new_affected_rows;
} while (bulk_parameters_iterations(thd));
values_loop_end:
@ -1342,7 +1363,7 @@ values_loop_end:
Client expects an EOF/OK packet if result set metadata was sent. If
LEX::has_returning and the statement returns result set
we send EOF which is the indicator of the end of the row stream.
Oherwise we send an OK packet i.e when the statement returns only the
Otherwise we send an OK packet i.e when the statement returns only the
status information
*/
if (returning)