Commit graph

27376 commits

Author SHA1 Message Date
Konstantin Osipov
ec2c3bf2c1 A pre-requisite patch for the fix for Bug#52044.
This patch also fixes Bug#55452 "SET PASSWORD is
replicated twice in RBR mode".

The goal of this patch is to remove the release of 
metadata locks from close_thread_tables().
This is necessary to not mistakenly release
the locks in the course of a multi-step
operation that involves multiple close_thread_tables()
or close_tables_for_reopen().

On the same token, move statement commit outside 
close_thread_tables().

Other cleanups:
Cleanup COM_FIELD_LIST.
Don't call close_thread_tables() in COM_SHUTDOWN -- there
are no open tables there that can be closed (we leave
the locked tables mode in THD destructor, and this
close_thread_tables() won't leave it anyway).

Make open_and_lock_tables() and open_and_lock_tables_derived()
call close_thread_tables() upon failure.
Remove the calls to close_thread_tables() that are now
unnecessary.

Simplify the back off condition in Open_table_context.

Streamline metadata lock handling in LOCK TABLES 
implementation.

Add asserts to ensure correct life cycle of 
statement transaction in a session.

Remove a piece of dead code that has also become redundant
after the fix for Bug 37521.
2010-07-27 14:25:53 +04:00
Jon Olav Hauglid
97bfd559f1 Bug #55498 SHOW CREATE TRIGGER takes wrong type of metadata lock
The first problem was that SHOW CREATE TRIGGER took a stronger metadata
lock than required. This caused the statement to be blocked when it was
not needed. For example, LOCK TABLE WRITE in one connection would block
SHOW CREATE TRIGGER in another connection.

Another problem was that a SHOW CREATE TRIGGER statement issued inside
a transaction did not release its metadata locks at the end of the
statement execution. This happened even if SHOW CREATE TRIGGER is an
information statement. The consequence was that SHOW CREATE TRIGGER
was able to block other connections from accessing the table
(e.g. using ALTER TABLE).

This patch fixes the problem by changing SHOW CREATE TRIGGER to take
a MDL_SHARED_HIGH_PRIO metadata lock similar to what is already done
for SHOW CREATE TABLE. The patch also changes SHOW CREATE TRIGGER to
explicitly release any metadata locks taken by the statement after
it completes.

Test case added to show_check.test.
2010-07-23 10:44:55 +02:00
Jon Olav Hauglid
e814e9ac1e Bug #54905 Connection with WRITE lock cannot ALTER table due to
concurrent SHOW CREATE

The problem was that a SHOW CREATE TABLE statement issued inside
a transaction did not release its metadata locks at the end of the
statement execution. This happened even if SHOW CREATE TABLE is an
information statement. 

The consequence was that SHOW CREATE TABLE was able to block other
connections from accessing the table (e.g. using ALTER TABLE).

This patch fixes the problem by explicitly releasing any metadata
locks taken by SHOW CREATE TABLE after the statement completes.

Test case added to show_check.test.
2010-07-22 11:10:35 +02:00
Jon Olav Hauglid
131095149f Bug #55223 assert in Protocol::end_statement during CREATE DATABASE
The problem was that a statement could cause an assert if it was aborted by
KILL QUERY while it waited on a metadata lock. This assert checks that a
statement either sends OK or an error to the client. If the bug was triggered
on release builds, it caused OK to be sent to the client instead of
ER_QUERY_INTERRUPTED.

The root cause of the problem was that there are two separate ways to tell if a
statement is killed: thd->killed and mysys_var->abort. KILL QUERY causes both
to be set, thd->killed before mysys_var->abort. Also, both values are reset
at the end of statement execution. This means that it is possible for
KILL QUERY to first set thd->killed, then have the killed statement reset
both thd->killed and mysys_var->abort and finally have KILL QUERY set
mysys_var->abort. This means that the connection with the killed statement
will start executing the next statement with the two values out of sync - i.e.
thd->killed not set but mysys_var->abort set.

Since mysys_var->abort is used to check if a wait for a metadata lock should
be aborted, the next statement would immediately abort any such waiting.
When waiting is aborted, no OK message is sent and thd->killed is checked to
see if ER_QUERY_INTERRUPTED should be sent to the client. But since
the->killed had been reset, neither OK nor an error message was sent to the
client. This then triggered the assert.

This patch fixes the problem by changing the metadata lock waiting code to
check thd->killed.

No test case added as reproducing the assert is dependent on very exact timing
of two (or more) threads. The patch has been checked using RQG and the grammar
posted on the bug report.
2010-07-22 10:00:32 +02:00
Jon Olav Hauglid
52b1e11ee1 merge from mysql-trunk-bugfixing 2010-07-19 10:27:53 +02:00
Davi Arnaut
4d532f6ea6 Merge of mysql-trunk-merge into mysql-trunk-bugfixing. 2010-07-16 17:02:40 -03:00
Marc Alff
9247f2252b Bug#54467 performance schema complains of wrong structure in bootstrap mode
Backport from mysql-next-mr (5.6) to mysql-trunk (5.5)
2010-07-16 08:01:47 -06:00
Marc Alff
ae127ed601 Bug#54782 Performance schema per thread accounting and thread cache
Backport from mysql-next-mr (5.6) to mysql-trunk (5.5)
2010-07-16 07:50:50 -06:00
Davi Arnaut
55958d6dac Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations.
Silence bogus aliasing warning through a pointer indirection. Also,
no need to check the return of a placement new.
2010-07-15 16:29:25 -03:00
Davi Arnaut
0e6fcb393c Bug#45288: pb2 returns a lot of compilation warnings on linux
Fix compiler warnings due to: a mismatch in the prototypes for
check_access and implicit conversions from double to ulonglong
and vice-versa.
2010-07-15 14:45:08 -03:00
Georgi Kodinov
aaf5f8d5c4 merge 2010-07-15 18:46:41 +03:00
Davi Arnaut
649390ac81 Merge of mysql-trunk-bugfixing into mysql-trunk-merge. 2010-07-15 10:47:50 -03:00
Alexey Kopytov
06b8897e8e Automerge. 2010-07-15 17:09:38 +04:00
Alexey Kopytov
0860015560 Manual merge. 2010-07-15 17:01:44 +04:00
Davi Arnaut
f54a118249 WL#5486: Remove code for unsupported platforms
Remove Netware specific code.
2010-07-15 08:13:30 -03:00
Alexey Kopytov
a42108c291 Backport of the fix for bug#25421 to 5.0.
Calculating the estimated number of records for a range scan
may take a significant time, and it was impossible for a user
to interrupt that process by killing the connection or the
query.

Fixed by checking the thread's 'killed' status in
check_quick_keys() and interrupting the calculation process if
it is set to a non-zero value.
2010-07-15 10:10:16 +04:00
Davi Arnaut
d5e8508f90 Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.

Post-merge fix: include my_compiler.h before my_attribute.h
as the latter will undef __attribute__ if the compiler is not
GCC. Based on the compiler version, in my_compiler.h we know
for sure whether the aligned attribute is supported. Furthermore,
undefining attribute might cause bugs if some system header
uses it.
2010-07-14 16:39:40 -03:00
Davi Arnaut
e29211c366 Merge of mysql-5.1-bugteam into mysql-trunk-merge. 2010-07-14 11:12:26 -03:00
Davi Arnaut
21f63caf8e Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.

Another rather noisy violation of strict aliasing rules
is the spatial code which makes use of stack-based memory
(of type Geometry_buffer) to provide placement for Geometry
objects. Although a placement new is allowed to dynamically
change the type of a object, the object returned by the
new placement was being ignored and the original stack-based
object was being casted to the new type, thus violating strict
aliasing rules.

The solution is to reorganize the code so that the object
returned by the new placement is used instead of casting the
original object. Also, to ensure that the stack-based object
is properly aligned with respect to the objects it provides
placement for, a set of compiler-dependent macros and types
are introduced so that the alignment of objects can be inquired
and specified.
2010-07-14 09:27:13 -03:00
Georgi Kodinov
a1414d519f merge 2010-07-14 15:05:20 +03:00
Georgi Kodinov
b4766fc36a Bug #51876: crash/memory underrun when loading data with ucs2
and reverse() function
      
3 problems fixed : 
1. The reported problem : caused by incorrect parsing of 
the file as ucs data resulting in wrong length of the parsed
string. Fixed by truncating the invalid trailing bytes 
(non-complete multibyte characters) when reading from the file
2. LOAD DATA when reading from a proper UCS2 file wasn't 
recognizing the new line characters. Fixed by first looking 
if a byte is a new line (or any other special) character before
reading it as a part of a multibyte character.
3. When using user variables to hold the column data in LOAD
DATA the character set of the user variable was set incorrectly
to the database charset. Fixed by setting it to the charset
specified by LOAD DATA (if any).
2010-07-14 14:54:51 +03:00
Georgi Kodinov
9952c560cb merge 2010-07-14 14:09:00 +03:00
Georgi Kodinov
16a7308825 Bug #53493 : add_to_status does not handle the longlong fields in STATUS_VAR
bytes_received/bytes_sent are ulonglong so they cannot be handled by the 
ulong handling code in add_to_status/add_diff_to_status().

Fixed by adding code to handle these two variables in 
add_to_status()/add_diff_to_status() and making sure they are not a subject
to the ulong handling code.
2010-07-14 11:50:17 +03:00
Dmitry Lenev
cf93bc7181 A pre-requisite for patch fixing bug #52044 "FLUSH TABLES
WITH READ LOCK and FLUSH TABLES <list> WITH READ LOCK are
incompatible", which adds information about waits caused by 
FLUSH TABLES statement to deadlock detector in MDL subsystem.

Remove API supporting caching of pointers to TABLE_SHARE 
object in MDL subsystem and all code related to it. 

The problem was that locking requirements of code 
implementing this API conflicted with locking requirements 
of code which adds information about waits caused by flushes 
to deadlock detector in MDL subsystem (the former needed to
lock LOCK_open or its future equivalent while having 
write-lock on MDL_lock's rwlock, and the latter needs to be 
able to read-lock MDL_lock rwlock while owning LOCK_open or 
its future equivalent).

Since caching of pointers to TABLE_SHARE objects in MDL 
subsystem didn't bring expected performance benefits we 
decided to remove caching API rather than try to come up 
with some complex solution for this problem.
2010-07-13 22:01:54 +04:00
Sven Sandberg
7c3670294b BUG#54729: sleep() capped to 5 seconds when executed in the sql thread or in an event
Symptom:
When the sql function SLEEP() was executed in the slave SQL thread or from an event (as in
CREATE EVENT, not binlog event), then the timeout was capped to 5 seconds.

Background:
This bug was introduced in the fix of BUG#10374, in the function interruptible_wait() in
item_func.cc.
The function interruptible_wait(), called from item_func_sleep::val_int(), splits the
sleep into 5 seconds units. After each unit, it checks if thd->is_connected() is true: if
not, it stops sleeping. The purpose is to not use system resources to sleep when a client
disconnects.
However, thd->is_connected() returns false for the slave SQL thread and for the event
worker thread, because they don't connect to the server the same way as client threads
do.

Fix:
Make thd->is_connected() return true for all system threads.
2010-07-13 11:13:06 +02:00
Jon Olav Hauglid
a5d72c498c merge from mysql-trunk-bugfixing 2010-07-13 10:39:24 +02:00
Mattias Jonsson
a0752a9eaf merge 2010-07-09 15:02:27 +02:00
Mattias Jonsson
6433a55356 merge 2010-07-09 15:00:33 +02:00
Mattias Jonsson
70e490430f merge 2010-07-09 14:59:40 +02:00
Davi Arnaut
e1f748c0bd Merge of mysql-5.1-bugteam into mysql-trunk-merge. 2010-07-09 09:28:51 -03:00
Davi Arnaut
ed9ffc6b09 Bug#45288: pb2 returns a lot of compilation warnings on linux
Although the C standard mandates that sprintf return the number
of bytes written, some very ancient systems (i.e. SunOS 4)
returned a pointer to the buffer instead. Since these systems
are not supported anymore and are hopefully long dead by now,
simply remove the portability wrapper that dealt with this
discrepancy. The autoconf check was causing trouble with GCC.
2010-07-09 09:00:17 -03:00
Mattias Jonsson
9414aee225 Bug#52517: Regression in ROW level replication performance with partitions
In bug-28430 HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
was disabled in the partitioning engine in the first patch,
That bug was later fixed a second time, but that flag
was not removed.

No need to disable this flag, as it leads to bad
choise in row replication.
2010-07-09 13:15:26 +02:00
Sergey Glukhov
80935b8659 5.1-bugteam->trunk-merge merge 2010-07-09 14:46:46 +04:00
Sergey Glukhov
3c39a56208 Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set
The problem there is that HAVING condition evaluates const
parts of condition despite the condition has references
on aggregate functions. Table t1 became const tables
after make_join_statistics and table1.pk = 1, HAVING is
transformed into MAX(1) < 7 and taken away from HAVING.
The fix is to skip evaluation of HAVING conts parts if
HAVING condition has references on aggregate functions.
2010-07-09 14:39:47 +04:00
Alexander Barkov
63777287b8 Bug#54668 User variable assignments get wrong type
Problem: Item_str_ascii_func::val_str() did not set
charset of the returned value properly.
  
  mysql-test/include/ctype_numconv.inc
  mysql-test/r/ctype_binary.result
  mysql-test/r/ctype_cp1251.result
  mysql-test/r/ctype_latin1.result
  mysql-test/r/ctype_ucs.result
  - Adding tests
  
  sql/item_strfunc.cc
  - Adding initialization of charset
2010-07-09 09:39:41 +04:00
Davi Arnaut
dbf76b0deb Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Post-merge fix: cast argument and correct type in assignment.
2010-07-08 22:19:57 -03:00
Mattias Jonsson
e13405a79f Bug#52455: Subpar INSERT ON DUPLICATE KEY UPDATE performance with many partitions
The handler function for reading one row from a specific index
was not optimized in the partitioning handler since it
used the default implementation.

No test case since it is performance only, verified by hand.
2010-07-09 01:09:31 +02:00
Davi Arnaut
a10ae35328 Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.

Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.

Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost. 

The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.

Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
2010-07-08 18:20:08 -03:00
Olav Sandstaa
b7166f33d0 Backporting of jorgen.loland@sun.com-20100618093212-lifp1psig3hbj6jj
from mysql-next-mr-opt-backporting.

Bug#54515: Crash in opt_range.cc::get_best_group_min_max on 
           SELECT from VIEW with GROUP BY
      
When handling the grouping items in get_best_group_min_max, the
items need to be of type Item_field. In this bug, an ASSERT 
triggered because the item used for grouping was an 
Item_direct_view_ref (i.e., the group column is from a view). 
The fix is to get the real_item since Item_ref* pointing to 
Item_field is ok.
2010-07-08 15:19:05 +02:00
Guilhem Bichot
65bdafda29 backport of guilhem@mysql.com-20100628140739-i9vy8ugxp1v5aspb
from next-mr-bugfixing:
BUG#54682 "set sql_select_limit=0 does not work"; let SQL_SELECT_LIMIT=0
work like it does in 5.1.
2010-07-08 14:36:10 +02:00
Luis Soares
e8ee471447 BUG 54925: automerged bzr bundle from bug report. 2010-07-08 10:02:43 +01:00
Luis Soares
43f6b7b4d5 BUG 54509: automerged bzr bundle from bug report. 2010-07-08 10:01:12 +01:00
38876dc9af Auto merge 2010-07-08 10:49:22 +08:00
b440125f1c Postfix bug#48321
Fix the memory leak
2010-07-08 10:44:26 +08:00
Luis Soares
8794236100 BUG 54842: automerged bzr bundle in mysql-trunk-bugfixing. 2010-07-07 23:27:52 +01:00
Jon Olav Hauglid
5050cd7c89 Bug #37521 Row inserted through view not always visible in base
table immediately after

The problem was that rows inserted in a table by one connection was
not immediately visible if another connection queried the table,
even if the insert had committed.

The reason for the problem was that the server sent a status reply
to the client before it actually did the commit. Therefore it was
possible to get an OK from the server before the changes were made
permanent and visible to other connections.

This patch fixes the problem by not sending status messages to the
server until any changes made have been committed. No test case added
as reproducing the error requires very specific timing betweeen the
server and two or more clients.

This patch also fixes the following (duplicate) bugs:
Bug #29334 pseudo-finished SHOW GLOBAL STATUS
Bug #36618 myisam insert not immediately visible to select from another client
Bug #45864 insert on one connection, immediate query on another produces no result
Bug #51329 Inserts from one connection not immediately visible in second
           connection
Bug #41516 Assertion fails when error returned from
           handler::external_lock(thd, F_UNLCK)
2010-07-07 15:20:07 +02:00
Georgi Kodinov
15a95344d0 merge 2010-07-07 13:05:08 +03:00
Georgi Kodinov
28004bd592 Addendum to the fix for bug #53095 (failing information_schema.test on windows)
Since the original fix for this bug lowercases the search pattern it's not a 
good idea to copy the search pattern to the output instead of the real table 
name found (since, depending on the case mode these two names may differ in 
case).
Fixed the infrmation_schema.test failure by making sure the actual table 
name of an inoformation schema table is passed instead of the lookup pattern
even when the pattern doesn't contain wildcards.
2010-07-07 12:15:58 +03:00
Alexander Barkov
a1a16aaa66 Bug#54661 sha2() returns BINARY result
Problem: sha2() reported its result as BINARY

Fix:
- Inheriting Item_func_sha2 from Item_str_ascii_func
- Setting max_length via fix_length_and_charset() 
  instead of direct assignment.
- Adding tests
2010-07-07 10:38:11 +04:00
Alexander Barkov
8a603a16d3 Bug#52159 returning time type from function and empty left join causes debug assertion
Problem: Item_copy did not set "fixed", which resulted in DBUG_ASSERT in some cases.
Fix: adding  initialization of the "fixed" member

Adding tests:
  mysql-test/include/ctype_numconv.inc
  mysql-test/r/ctype_binary.result
  mysql-test/r/ctype_cp1251.result
  mysql-test/r/ctype_latin1.result
  mysql-test/r/ctype_ucs.result

Adding initialization of the "fixed" member:
  sql/item.h
2010-07-07 10:00:46 +04:00