When innodb detects a deadlock it calls ha_rollback_trans() to rollback the
main transaction. But such action isn't allowed from inside of triggers and
functions. When it happen the 'Explicit or implicit commit' error is thrown
even if there is no commit/rollback statements in the trigger/function. This
leads to the user confusion.
Now the convert_error_code_to_mysql() function doesn't call the
ha_rollback_trans() function directly but rather calls the
mark_transaction_to_rollback function and returns an error.
The sp_rcontext::find_handler() now doesn't allow errors to be caught by the
trigger/function error handlers when the thd->is_fatal_sub_stmt_error flag
is set. Procedures are still allowed to catch such errors.
The sp_rcontext::find_handler function now accepts a THD handle as a parameter.
The transaction_rollback_request and the is_fatal_sub_stmt_error flags are
added to the THD class. The are initialized by the THD class constructor.
Now the ha_autocommit_or_rollback function rolls back main transaction
when not in a sub statement and the thd->transaction_rollback_request
is set.
The THD::restore_sub_statement_state function now resets the
thd->is_fatal_sub_stmt_error flag on exit from a sub-statement.
sql/ha_innodb.cc:
Bug#24989: The DEADLOCK error is improperly handled by InnoDB.
Now the convert_error_code_to_mysql() function doesn't call the
ha_rollback_trans() function directly but rather calls the
mark_transaction_to_rollback function and returns an error.
sql/handler.cc:
Bug#24989: The DEADLOCK error is improperly handled by InnoDB.
Now the ha_autocommit_or_rollback function rolls back main transaction
when not in a sub statement and the thd->transaction_rollback_request
is set.
mysql-test/r/innodb-big.result:
Added a test case for the bug#24989: The DEADLOCK error is improperly handled by
InnoDB.
mysql-test/t/innodb-big.test:
Added a test case for the bug#24989: The DEADLOCK error is improperly handled by
InnoDB.
sql/sql_class.h:
Bug#24989: The DEADLOCK error is improperly handled by InnoDB.
The transaction_rollback_request and the is_fatal_sub_stmt_error flags are
added to the THD class.
sql/sql_class.cc:
Bug#24989: The DEADLOCK error is improperly handled by InnoDB.
Initialization of the transaction_rollback_request and the
is_fatal_sub_stmt_error flags are added to the THD class constructor.
The mark_transaction_to_rollback function is added.
The THD::restore_sub_statement_state function now resets the
thd->is_fatal_sub_stmt_error flag on exit from a sub-statement.
sql/sp_rcontext.h:
Bug#24989: The DEADLOCK error is improperly handled by InnoDB.
The sp_rcontext::find_handler function now accepts a THD handle as a parameter.
The in_sub_stmt flag is added to the sp_rcontext class.
sql/sp_rcontext.cc:
Bug#24989: The DEADLOCK error is improperly handled by InnoDB.
The sp_rcontext::find_handler() now doesn't allow errors to be caught by the
trigger/function error handlers when the thd->is_fatal_sub_stmt_error flag
is set. Instead it tries to find a most inner procedure that isn't called
directly or indirectly from any function/trigger.
Procedures are still allowed to catch such errors.
The sp_rcontext::find_handler function now accepts a THD handle as a parameter.
SP with local variables with non-ASCII names crashed the server.
The server replaces SP local variable names with NAME_CONST calls
when putting statements into the binary log. It used UTF8-encoded
item names as variable names for the replacement inside NAME_CONST
calls. However, statement string may be encoded by any
known character set by the SET NAMES statement.
The server used byte length of UTF8-encoded names to increment
the position in the query string that led to array index overrun.
sql/item.cc:
Fixed bug #30120.
The Item_splocal class constructor has been modified to
accept new parameter `len_in_q': the byte length of
variable name in the query string.
sql/item.h:
Fixed bug #30120.
The Item_splocal class has been modified to keep new
field `len_in_query': the byte length of variable name in
the query string.
sql/sp_head.cc:
Fixed bug #30120.
The subst_spvars function has been modified to increment
position in the query string by the lengths of not
encoded variable names instead of byte length of names
encoded to UTF-8.
sql/sql_yacc.yy:
Fixed bug #30120.
The simple_ident rule action has been modified to
pass the byte length of the local variable name token
to the Item_splocal object constructor.
mysql-test/t/sp.test:
Updated test case for bug #30120.
mysql-test/r/sp.result:
Updated test case for bug #30120.
into gleb.loc:/home/uchum/work/bk/5.0-opt
sql/sql_base.cc:
Auto merged
mysql-test/r/sp.result:
Merge with local tree.
mysql-test/t/sp.test:
Merge with local tree.
Using view columns by their names during an execution of
a prepared SELECT statement or a SELECT statement inside
a SP caused a memory leak.
sql/sql_base.cc:
Fixed bug #29834.
The find_field_in_view function has been modified to
use the execution memory root for the Item_direct_view_ref
objects allocation at non-first executions of
a PS/SP instead of the statement memory.
mysql-test/t/sp.test:
Updated test case for bug #29834.
mysql-test/r/sp.result:
Updated test case for bug #29834.
information schema table.
The get_schema_views_record() function fills records in the view table of
the informations schema with data about given views. Among other info
the is_updatable flag is set. But the check whether the view is updatable or
not wasn't covering all cases thus sometimes providing wrong info.
This might led to a user confusion.
Now the get_schema_views_record function additionally calls to the
view->can_be_merge() function to find out whether the view can be updated or
not.
mysql-test/t/view.test:
Added a test case for the bug#30020: Insufficient check led to a wrong info
provided by the information schema table.
mysql-test/r/view.result:
Added a test case for the bug#30020: Insufficient check led to a wrong info
provided by the information schema table.
sql/sql_show.cc:
Bug#30020: Insufficient check led to a wrong info provided by the
information schema table.
Now the get_schema_views_record function additionally calls to the
view->can_be_merge() function to find out whether the view can be updated or
not.
The subst_spvars function is used to create query string with SP variables
substituted with their values. This string is used later for the binary log
and for the query cache. The problem is that the
query_cache_send_result_to_client function requires some additional space
after the query to store database name and query cache flags. This
space wasn't reserved by the subst_spvars function which led to a memory
corruption and crash.
Now the subst_spvars function reserves additional space for the query cache.
mysql-test/t/query_cache.test:
Added a test case for the bug#29856: Insufficient buffer space led to a server crash.
mysql-test/r/query_cache.result:
Added a test case for the bug#29856: Insufficient buffer space led to a server crash.
sql/sp_head.cc:
Bug#29856: Insufficient buffer space led to a server crash.
Now the subst_spvars function reserves additional space for the query cache.
Moved CERT files to where they are used, avoids conflict
between two make files trying to install the same CERTs
SSL/*.pem,
Move: SSL/*.pem -> mysql-test/std_data/
mysql-test/std_data/cacert.pem:
Rename: SSL/cacert.pem -> mysql-test/std_data/cacert.pem
mysql-test/std_data/client-cert.pem:
Rename: SSL/client-cert.pem -> mysql-test/std_data/client-cert.pem
mysql-test/std_data/client-key.pem:
Rename: SSL/client-key.pem -> mysql-test/std_data/client-key.pem
mysql-test/std_data/server-cert.pem:
Rename: SSL/server-cert.pem -> mysql-test/std_data/server-cert.pem
mysql-test/std_data/server-key.pem:
Rename: SSL/server-key.pem -> mysql-test/std_data/server-key.pem
SSL/Makefile.am:
Moved CERT files to where they are used, avoids conflict
between two make files trying to install the same CERTs
When a table was explicitly locked with LOCK TABLES no associated
tables from any related trigger on the subject table were locked.
As a result of this the user could experience unexpected locking
behavior and statement failures similar to "failed: 1100: Table'xx'
was not locked with LOCK TABLES".
This patch fixes this problem by making sure triggers are
pre-loaded on any statement if the subject table was explicitly
locked with LOCK TABLES.
mysql-test/r/sp-prelocking.result:
Added test case
mysql-test/t/sp-prelocking.test:
Added test case
sql/sql_lex.cc:
- Moved some conditional logic out of the table iteration.
- Added event map values for LOCK TABLE command.
sql/table.cc:
- Refactored set_trg_event_tpye into the two simpler functions set_trg_event_map
and set_trg_event_map as methods for manipulating the table event map.
The original function was only called from st_lex::set_trg_event_type_for_tables
so it was possible to move the event map creation logic to this function as
a loop optimization.
sql/table.h:
- Refactored set_trg_event_tpye into the two simpler functions set_trg_event_map
and set_trg_event_map as methods for manipulating the table event map.
The original function was only called from st_lex::set_trg_event_type_for_tables
so it was possible to move the event map creation logic to this function as
a loop optimization.
Item_func_user doesn't calculate anything in it's val_str() method,
just returns saved str_value.
Though Item::save_in_field method can destroy str_value, relying on
val_str() return. As a result we get the garbage stored in field.
We cannot use Item::save_in_field implementation for Item_func_user,
reimplement it in simpler way.
mysql-test/r/rpl_session_var.result:
Bug #29878 Garbage data generation when executing SESSION_USER() on a slave.
test result
mysql-test/t/rpl_session_var.test:
Bug #29878 Garbage data generation when executing SESSION_USER() on a slave.
test case
sql/item.cc:
Bug #29878 Garbage data generation when executing SESSION_USER() on a slave.
duplicating code moved to Item::save_str_in_field
sql/item.h:
Bug #29878 Garbage data generation when executing SESSION_USER() on a slave.
duplicating code moved to Item::save_str_in_field
sql/item_strfunc.h:
Bug #29878 Garbage data generation when executing SESSION_USER() on a slave.
Item_func_user::save_in_field implemented as simple storing str_value
- make the 'dist-hook' from top-level Makefile work again.
- we can find my_print_defaults from --basedir by parsing command
line arguments prior to running my_print_defaults.
- take advantage of additional command line parsing and allow the
--no-defaults etc arguments to work anywhere rather than having
to be the first argument.
- find SQL files either from binary archive or source install.
- consolidate and tidy code and error messages.
scripts/mysql_install_db.sh:
Consolidate error messages.
between perm and temp tables. Review fixes.
The original bug report complains that if we locked a temporary table
with LOCK TABLES statement, we would not leave LOCK TABLES mode
when this temporary table is dropped.
Additionally, the bug was escalated when it was discovered than
when a temporary transactional table that was previously
locked with LOCK TABLES statement was dropped, futher actions with
this table, such as UNLOCK TABLES, would lead to a crash.
The problem originates from incomplete support of transactional temporary
tables. When we added calls to handler::store_lock()/handler::external_lock()
to operations that work with such tables, we only covered the normal
server code flow and did not cover LOCK TABLES mode.
In LOCK TABLES mode, ::external_lock(LOCK) would sometimes be called without
matching ::external_lock(UNLOCK), e.g. when a transactional temporary table
was dropped. Additionally, this table would be left in the list of LOCKed
TABLES.
The patch aims to address this inadequacy. Now, whenever an instance
of 'handler' is destroyed, we assert that it was priorly
external_lock(UNLOCK)-ed. All the places that violate this assert
were fixed.
This patch introduces no changes in behavior -- the discrepancy in
behavior will be fixed when we start calling ::store_lock()/::external_lock()
for all tables, regardless whether they are transactional or not,
temporary or not.
mysql-test/r/innodb_mysql.result:
Update test results (Bug#24918)
mysql-test/t/innodb_mysql.test:
Add a test case for Bug#24918
sql/handler.h:
Make handler::external_lock() a protected method. Backport from 5.1 its
public wrapper handler::ha_external_lock().
Assert that the handler is not closed if it is still locked.
sql/lock.cc:
In mysql_lock_tables only call lock_external() for the list of tables that
we called store_lock() for.
E.g. get_lock_data() does not add non-transactional temporary tables to the
lock list, so lock_external() should not be called for them.
Use handler::ha_external_lock() instead of handler::external_lock().
Add comments for mysql_lock_remove(), parameterize one strange
side effect that it has. At least in one place where mysql_lock_remove
is used, this side effect is not desired (DROP TABLE). The parameter
will be dropped in 5.1, along with the side effect.
sql/mysql_priv.h:
Update declaration of mysql_lock_remove().
sql/opt_range.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
sql/sql_base.cc:
When closing a temporary table, remove the table from the list of LOCKed
TABLES of this thread, in case it's there.
It's there if it is a transactional temporary table.
Use a new declaration of mysql_lock_remove().
sql/sql_class.h:
Extend the comment for THD::temporary_tables.
sql/sql_table.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
INSERT/DELETE/UPDATE followed by ALTER TABLE within LOCK TABLES
may cause table corruption on Windows.
That happens because ALTER TABLE writes outdated shared state
info into index file.
Fixed by removing obsolete workaround.
Affects MyISAM tables on Windows only.
myisam/mi_extra.c:
On windows when mi_extra(HA_EXTRA_PREPARE_FOR_DELETE) is called,
we release external lock and close index file. If we're in LOCK
TABLES, MyISAM state info doesn't get updated until UNLOCK TABLES.
That means when we release external lock and we're in LOCK TABLES,
we may write outdated state info.
As SQL layer closes all table instances, we do not need this
workaround anymore.
mysql-test/r/alter_table.result:
A test case for BUG#29957.
mysql-test/t/alter_table.test:
A test case for BUG#29957.
- make ha_berkeley::cmp_ref() take into account that auto-generated PKs
are stored in LSB-first order.
- Remove the temporary code that made the bugfix work for innodb only
mysql-test/r/bdb.result:
Adjust test-results.
sql/ha_berkeley.cc:
BUG#28591: make the fix work for BDB tables too:
- make ha_berkeley::cmp_ref() take into account that auto-generated PKs
are stored in LSB-first order.
sql/sql_select.cc:
BUG#28591: Remove "innodb only" clause as the fix now works for BDB too
sql/table.cc:
BUG#28591: Remove "innodb only" clause as the fix now works for BDB too
available and reduce the chance of failure. This should fix bug#28585
which is caused by the script being quite random in how it finds files it
requires and not giving very good feedback to the user about what went
wrong.
Also update make_binary_distribution so that it provides the correct path
to the required SQL scripts when generating mysql_install_db. The script
only previously worked because of the permissive behaviour which looked
around the current working directory before the "correct" location. This
could lead to severe problems if the user happened to run the script from
a location which contained older or even broken copies of the SQL scripts.
We now require either a complete binary release (and the mysql_install_db
script ran from inside the extracted archive), or an installed compiled
tree, as this is the only way we can be sure everything that we need is
available and ready to run.
While working on this fix, also clean up the mysql_install_db script a lot
to make it simpler, easier to read, and hopefully less prone to bugs in
the future.
scripts/make_binary_distribution.sh:
SQL files live in ./share not ./support-files in binary distribution.
scripts/mysql_install_db.sh:
Use a consistent shell indentation style.
to 150 or 107 characters for those messages which are generated
by the embedded server during release builds.
This fixes bug#16635:
Error messages wrong: absolute path names, "%s" format code
See the bug report or the changelog for "sql/share/english/errmsg.txt"
for instructions how to do that with other languages,
even at the customer site, and for the restrictions to keep.
sql/share/english/errmsg.txt:
The embedded server uses absolute path names in its error messages,
in the release build environment these exceed the 64 character limit
which the format strings for the error messages impose (bug#16635).
But when the messages are output, the server does the "printf()"
internally in a 256 character buffer; the constant text and the
expanded variables (strings, error number) must fit into this.
(If the buffer would overflow, a format specification will not be
expanded but just copied with its code, and the message output
will just contain '%s' or '%d' where a value is expected.)
So the string lengths are increased to 150 characters in those messages
which are issued by the embedded server during release tests
and contain 1 (one) path name,
but only to 107 in the "rename" message which contains 2 (two).
This solves bug#16635 for the release builds.
For other languages used by OEM customers, similar fixes may be needed,
but we cannot test them.
These fixes can be done even in a binary installation at the customer site
by following these steps:
cd <<install-root>>/share
$EDITOR <<lang>>/errmsg.txt
../../bin/comp_err -C./charsets/ <<lang>>/errmsg.txt <<lang>>/errmsg.sys
and then restarting the server.
If ::exteral_lock hadn't been called, we'd have no NDB object,
so need to check/get one here.
It looks like sql_show.cc is the only place that does this....
or at least the other places will be well hidden.
Index: ndb-work/sql/ha_ndbcluster.cc
===================================================================
sql/ha_ndbcluster.cc:
Bug#26793 I_S query crashes in NDB
Reduce case and formalise into something we should be
able to use in mysql-test-run.
Index: ndb-work/mysql-test/t/ndb_bug26793.test
===================================================================
mysql-test/r/ndb_bug26793.result:
BUG#26793 test: mysqld crashes in NDB on I_S query
mysql-test/t/ndb_bug26793.test:
BUG#26793 test: mysqld crashes in NDB on I_S query