mariadb/tests
Dmitry Shulga ba5482ffc2 MDEV-34718: Trigger doesn't work correctly with bulk update
Running an UPDATE statement in PS mode and having positional
parameter(s) bound with an array of actual values (that is
prepared to be run in bulk mode) results in incorrect behaviour
in presence of on update trigger that also executes an UPDATE
statement. The same is true for handling a DELETE statement in
presence of on delete trigger. Typically, the visible effect of
such incorrect behaviour is expressed in a wrong number of
updated/deleted rows of a target table. Additionally, in case UPDATE
statement, a number of modified rows and a state message returned
by a statement contains wrong information about a number of modified rows.

The reason for incorrect number of updated/deleted rows is that
a data structure used for binding positional argument with its
actual values is stored in THD (this is thd->bulk_param) and reused
on processing every INSERT/UPDATE/DELETE statement. It leads to
consuming actual values bound with top-level UPDATE/DELETE statement
by other DML statements used by triggers' body.

To fix the issue, reset the thd->bulk_param temporary to the value
nullptr before invoking triggers and restore its value on finishing
its execution.

The second part of the problem relating with wrong value of affected
rows reported by Connector/C API is caused by the fact that diagnostics
area is reused by an original DML statement and a statement invoked
by a trigger. This fact should be take into account on finalizing a
state of diagnostics area on completion running of a statement.

Important remark: in case the macros DBUG_OFF is on, call of the method
  Diagnostics_area::reset_diagnostics_area()
results in reset of the data members
  m_affected_rows, m_statement_warn_count.
Values of these data members of the class Diagnostics_area are used on
sending OK and EOF messages. In case DML statement is executed in PS bulk
mode such resetting results in sending wrong result values to a client
for affected rows in case the DML statement fires a triggers. So, reset
these data members only in case the current statement being processed
is not run in bulk mode.
2024-08-19 12:13:43 +07:00
..
code_quality Refactor GitLab cppcheck and update SAST ignorelists 2024-07-08 10:51:48 +01:00
async_queries.c Merge commit '10.4' into 10.5 2023-07-20 11:54:52 +02:00
auto_increment.res
auto_increment.tst
big_record.pl Merge 10.4 into 10.5 2020-07-02 09:41:44 +03:00
bug25714.c Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
check_async_queries.pl Switch Perl DBI scripts from DBD::mysql to DBD::MariaDB driver 2019-07-19 13:39:20 +03:00
CMakeLists.txt MDEV-21303 Make executables MariaDB named 2020-03-21 20:20:29 +01:00
connect_test.c Update FSF Address 2019-05-11 21:29:06 +03:00
consistent_snapshot.pl Switch Perl DBI scripts from DBD::mysql to DBD::MariaDB driver 2019-07-19 13:39:20 +03:00
deadlock_test.c Update FSF Address 2019-05-11 21:29:06 +03:00
drop_test.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30
export.pl mtr: use env for perl 2020-06-23 03:24:46 +02:00
fork2_test.pl MDEV-23697: perl -w -> perl 2020-09-24 08:09:56 +10:00
fork_big.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30
fork_big2.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30
function.res
function.tst
grant.res
index_corrupt.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30
insert_and_repair.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30
insert_test.c Update FSF Address 2019-05-11 21:29:06 +03:00
list_test.c Update FSF Address 2019-05-11 21:29:06 +03:00
lock_test.pl mtr: use env for perl 2020-06-23 03:24:46 +02:00
lock_test.res
mail_to_db.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30
myisam-big-rows.tst
mysql_client_fw.c Merge branch '10.4' into 10.5 2023-12-02 01:02:50 +01:00
mysql_client_test.c MDEV-34718: Trigger doesn't work correctly with bulk update 2024-08-19 12:13:43 +07:00
nonblock-wrappers.h After-review changes 2016-09-12 17:51:50 +02:00
pmail.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30
rename_test.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30
restore-lock.smack
select_test.c Update FSF Address 2019-05-11 21:29:06 +03:00
showdb_test.c Update FSF Address 2019-05-11 21:29:06 +03:00
ssl_test.c Update FSF Address 2019-05-11 21:29:06 +03:00
table_types.pl mtr: use env for perl 2020-06-23 03:24:46 +02:00
test_delayed_insert.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30
thread_test.c MDEV-31461 mariadb SIGSEGV when built with -DCLIENT_PLUGIN_DIALOG=STATIC 2023-06-19 12:12:21 +02:00
truncate.pl Merge branch '10.4' into 10.5 2020-09-29 16:59:36 +05:30