MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.
Find a file
unknown 0e4dd85d67 Fix for bug#20670 "UPDATE using key and invoking trigger that modifies
this key does not stop" (version for 5.0 only).

UPDATE statement which WHERE clause used key and which invoked trigger
that modified field in this key worked indefinetely.

This problem occured because in cases when UPDATE statement was
executed in update-on-the-fly mode (in which row is updated right
during evaluation of select for WHERE clause) the new version of
the row became visible to select representing WHERE clause and was
updated again and again.
We already solve this problem for UPDATE statements which does not
invoke triggers by detecting the fact that we are going to update
field in key used for scanning and performing update in two steps,
during the first step we gather information about the rows to be
updated and then doing actual updates. We also do this for
MULTI-UPDATE and in its case we even detect situation when such
fields are updated in triggers (actually we simply assume that
we always update fields used in key if we have before update
trigger).

The fix simply extends this check which is done in check_if_key_used()/
QUICK_SELECT_I::check_if_keys_used() routine/method in such way that
it also detects cases when field used in key is updated in trigger.
As nice side-effect we have more precise and thus more optimal
perfomance-wise check for the MULTI-UPDATE.
Also check_if_key_used()/QUICK_SELECT_I::check_if_keys_used() were
renamed to is_key_used()/QUICK_SELECT_I::is_keys_used() in order to
better reflect that boolean predicate.

Note that this check is implemented in much more elegant way in 5.1 


mysql-test/r/trigger.result:
  Added test case for bug#20670 "UPDATE using key and invoking trigger that
  modifies this key does not stop".
mysql-test/t/trigger.test:
  Added test case for bug#20670 "UPDATE using key and invoking trigger that
  modifies this key does not stop".
sql/key.cc:
  Renamed check_if_key_used() to is_key_used(). Also this routine checks if
  key uses field which can be updated by before update trigger defined on the
  table. As result we avoid using update-on-the-fly method in cases when trigger
  updates part of key which is used by select which filters rows to be updated
  and thus avoid infinite updates. By doing such check here we cover both UPDATE
  and MULTI-UPDATE cases.
sql/mysql_priv.h:
  Renamed check_if_key_used() to is_key_used().
sql/opt_range.cc:
  Renamed check_if_key_used()/QUICK_SELECT_I::check_if_keys_used() to
  is_key_used()/QUICK_SELECT_I::is_keys_used().
sql/opt_range.h:
  Renamed QUICK_SELECT_I::check_if_keys_used() method to is_keys_used(),
  also updated comment describing it to reflect its extended semantics
  (this change was caused by change in check_if_key_used()/is_key_used()
   routine semantics).
sql/sql_trigger.cc:
  Introduced Table_triggers_list::is_updated_in_before_update_triggers()
  method which is needed for checking if field of subject table can be
  changed in before update trigger.
sql/sql_trigger.h:
  Table_triggers_list:
    Removed has_before_update_triggers() method which is not used any longer.
    Added declaration of is_updated_in_before_update_triggers() which is
    needed for checking if field of subject table can be changed by before
    update trigger.
sql/sql_update.cc:
  safe_update_on_fly():
    check_if_key_used() routine and check_if_keys_used() method were
    renamed to is_key_used()/is_keys_used(). 
    Now cases when trigger updates fields which are part of key used for
    filtering rows for update are caught directly in is_key_used().
    This also allows to cover both UPDATE and MULTI-UPDATE cases.
2006-09-21 11:35:38 +04:00
bdb BUG#15734: Fix undefined awk behaviour breaking compilation on Debian. 2005-12-14 13:09:37 +01:00
BitKeeper Preliminary patch for the following bugs: 2006-08-29 15:46:40 +04:00
BUILD Merge mysql.com:/Users/kent/mysql/bk/mysql-4.1-new 2006-06-17 15:42:24 +02:00
client Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2006-08-02 21:54:10 +04:00
cmd-line-utils Merge neptunus.(none):/home/msvensson/mysql/bug16557/my50-bug16557 2006-02-21 08:58:19 +01:00
config/ac-macros Merge xiphis.org:/home/antony/work2/p4-bug12096.2 2006-06-28 09:54:40 -07:00
dbug Fix two Valgrind memory leak warnings. 2006-05-15 18:07:18 +02:00
Docs Merge mysql.com:/home/tomash/src/mysql_ab/tmp_merge 2006-05-06 11:18:42 +04:00
extra sql_select.cc: 2006-07-28 21:26:46 +02:00
heap Merge mysql.com:/home/my/mysql-4.1 2006-06-30 19:15:18 +03:00
include Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0 2006-08-22 12:21:37 +04:00
innobase Applied innodb-5.0-ss677 snapshot. 2006-08-01 21:59:58 +02:00
libmysql Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2006-08-02 14:13:01 +04:00
libmysql_r Bug#19575 MySQL-shared-5.0.21-0.glibc23 causes segfault in SSL_library_init 2006-05-31 16:19:06 +02:00
libmysqld Merge mysql.com:/home/hf/work/mysql-4.1.mrg 2006-07-25 13:50:17 +05:00
man Makefile.am, configure.in: 2006-07-28 23:12:40 +02:00
myisam Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2006-07-08 21:45:02 +04:00
myisammrg BUG#17314: Can't use index_merge/intersection for MERGE tables 2006-02-11 21:51:43 +03:00
mysql-test Fix for bug#20670 "UPDATE using key and invoking trigger that modifies 2006-09-21 11:35:38 +04:00
mysys Bug #21396: Wrong error number generated for a missing table 2006-08-02 10:00:28 +02:00
ndb Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0 2006-07-18 23:45:17 +04:00
netware Merge mysql.com:/Users/kent/mysql/bk/mysql-4.0 2006-07-24 10:59:51 +02:00
os2 Merge 2005-09-29 03:20:31 +02:00
pstack Makefile.am, configure.in: 2005-09-24 15:51:45 +02:00
regex Bug#19407 Test 'func_regexp' fails on Windows x64 2006-06-19 22:19:05 -04:00
scripts Merge moonbone.local:/work/tmp_merge-4.1-opt-mysql 2006-08-02 16:46:55 +04:00
server-tools mysqlmanager.vcproj: 2006-07-22 02:00:33 +02:00
sql Fix for bug#20670 "UPDATE using key and invoking trigger that modifies 2006-09-21 11:35:38 +04:00
sql-bench Set thread_stack after return from end_thread() 2005-12-03 18:13:06 +02:00
sql-common Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2006-08-02 14:13:01 +04:00
SSL Remove client-req-pem and server-req.pem 2006-05-03 11:53:16 +02:00
strings Merge trift2.:/M41/push-1-4.1 2006-07-24 16:04:40 +02:00
support-files Merge moonlight.intranet:/home/tomash/src/mysql_ab/tmp_merge 2006-07-29 13:43:34 +04:00
tests Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2006-08-02 14:13:01 +04:00
tools Bug#19575 MySQL-shared-5.0.21-0.glibc23 causes segfault in SSL_library_init 2006-05-31 16:19:06 +02:00
VC++Files Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-release 2006-07-27 13:47:36 +04:00
vio Bug#19575 MySQL-shared-5.0.21-0.glibc23 causes segfault in SSL_library_init 2006-05-31 16:19:06 +02:00
zlib Changes after initial patch to #15787 2006-01-23 21:35:11 +03:00
.bzrignore Merge bodhi.local:/opt/local/work/tmp_merge 2006-07-08 02:30:07 +04:00
.cvsignore Import changeset 2000-07-31 21:29:14 +02:00
configure.in WL#3432 (Compile the Parser with a --debug --verbose option) 2006-08-18 19:16:07 -07:00
COPYING - manual.texi will be replaced with a manual written in DocBook/XML. This ChangeSet removes all 2005-04-13 11:51:38 +02:00
Makefile.am Merge 2005-11-04 02:17:11 +01:00
README README: 2006-04-01 04:13:33 +02:00

This is a release of MySQL, a dual-license SQL database server.
MySQL is brought to you by the MySQL team at MySQL AB.

License information can be found in these files:
- For GPL (free) distributions, see the COPYING file.
- For commercial distributions, see the MySQLEULA.txt file.


For further information about MySQL or additional documentation, see:
- The latest information about MySQL: http://www.mysql.com
- The current MySQL documentation: http://dev.mysql.com/doc

Some manual sections of special interest:

- If you are migrating from an older version of MySQL, please read the
  "Upgrading from..." section first!
- To see what MySQL can do, take a look at the features section.
- For installation instructions, see the Installation chapter.
- For future plans, see the TODO appendix.
- For the new features/bugfix history, see the News appendix.
- For the currently known bugs/misfeatures (known errors) see the problems
  appendix.
- For a list of developers and other contributors, see the Credits
  appendix.

A local copy of the MySQL Reference Manual can be found in the Docs
directory in GNU Info format.  You can also browse the manual online or
download it in any of several formats at the URL given earlier in this
file.

************************************************************

IMPORTANT:

Bug or error reports should be sent to http://bugs.mysql.com.