Commit graph

65894 commits

Author SHA1 Message Date
Konstantin Osipov
7c63481249 Fix the cmake rule that builds heap tests, added
to cmake build with the patch for WL#5419.
Add missing libraries.
2010-06-12 00:50:41 +04:00
Alexey Kopytov
e69c738fe1 Automerge. 2010-06-12 00:40:02 +04:00
Alexey Kopytov
61aaf4edbb Fixed ha_ndbcluster_binlog.cc to use Parser_state::init(). 2010-06-12 00:35:28 +04:00
Alexey Kopytov
08f3b0ab92 Automerge. 2010-06-11 23:44:01 +04:00
Ramil Kalimullin
20e0a9ab8f Automerge. 2010-06-11 19:36:57 +04:00
Konstantin Osipov
b140456601 WL#5419 "LOCK_open scalability: make tdc_refresh_version
an atomic counter"

Split the large LOCK_open section in open_table(). 
Do not call open_table_from_share() under LOCK_open.
Remove thd->version.

This fixes
Bug#50589 "Server hang on a query evaluated using a temporary 
table"
Bug#51557 "LOCK_open and kernel_mutex are not happy together"
Bug#49463 "LOCK_table and innodb are not nice when handler 
instances are created".

This patch has effect on storage engines that rely on
ha_open() PSEA method being called under LOCK_open.
In particular:

1) NDB is broken and left unfixed. NDB relies on LOCK_open
being kept as part of ha_open(), since it uses auto-discovery.
While previously the NDB open code was race-prone, now
it simply fails on asserts.

2) HEAP engine had a race in ha_heap::open() when
a share for the same table could be added twice
to the list of shares, or a dangling reference to a share
stored in HEAP handler. This patch aims to address this
problem by 'pinning' the newly created share in the 
internal HEAP engine share list until at least one
handler instance is created using that share.
2010-06-11 19:28:18 +04:00
Ramil Kalimullin
d4746b8e84 Automerge. 2010-06-11 18:43:36 +04:00
Alexey Kopytov
1ab6c34341 Null merge. 2010-06-11 17:54:39 +04:00
Alexey Kopytov
eae3b4fe76 Manual merge from mysql-5.1-bugteam to mysql-trunk-merge.
conflicts:
   conflict      mysys/safemalloc.c
   conflict      sql/mysqld.cc
   conflict      sql/sp.cc
   conflict      sql/sql_lex.cc
   conflict      sql/sql_lex.h
   conflict      sql/sql_parse.cc
   conflict      sql/sql_prepare.cc
2010-06-11 17:48:24 +04:00
Dmitry Lenev
218bf86cd9 Fix for bug #46785 "main.truncate_coverage fails
sporadically".

Races in truncate_coverage.test have caused its sporadical 
failures.

In the test case we have tried to kill truncate statement 
being executed in the first connection which was waiting 
for X metadata lock on table being locked by the second
connection. Since we have released metadata lock held by 
the second connection right after issuing KILL statement 
sometimes TRUNCATE TABLE managed to acquire X lock before 
it has noticed that it was killed. In this case TRUNCATE
TABLE was successfully executed till its end and this fact
has caused test failure since this statement didn't return 
expected error in such case.

This patch addresses the problem by not releasing metadata
locks in the second connections prematurely.
2010-06-11 17:32:12 +04:00
Alexey Kopytov
162e426238 Manual merge from the bugfix tree.
conflicts:
   conflict      sql/sql_parse.cc
2010-06-11 16:52:06 +04:00
Alexey Kopytov
b497e2c6b2 Manual merge from the bugfix tree.
conflicts:
   conflict      sql/sql_parse.cc
2010-06-11 14:51:21 +04:00
Martin Hansson
6d38a625c1 Merge of fix for bug#53859. 2010-06-11 10:15:55 +02:00
Jon Olav Hauglid
2b0c42f808 This patch backports test coverage for:
Bug #22909 Using CREATE ... LIKE is possible to create
           field with invalid default value
Bug #35935 CREATE TABLE under LOCK TABLES ignores FLUSH
           TABLES WITH READ LOCK
Bug #37371 CREATE TABLE LIKE merge loses UNION parameter

These bugs were originally fixed in the 6.1-fk tree and the fixes
were backported as part of the fix for Bug #42546 "Backup: RESTORE
fails, thinking it finds an existing table". This patch backports
test coverage missing in the original backport. The patch contains
no code changes.
2010-06-11 10:14:38 +02:00
Martin Hansson
5bace3f049 Bug#53859: Valgrind: opt_sum_query(TABLE_LIST*, List<Item>&,
Item*) at opt_sum.cc:305
      
Queries applying MIN/MAX functions to indexed columns are
optimized to read directly from the index if all key parts
of the index preceding the aggregated key part are bound to
constants by the WHERE clause. A prefix length is also
produced, equal to the total length of the bound key
parts. If the aggregated column itself is bound to a
constant, however, it is also included in the prefix.

Such full search keys are read as closed intervals for
reasons beyond the scope of this bug. However, the procedure
missed one case where a key part meant for use as range
endpoint was being overwritten with a NULL value destined
for equality checking. In this case the key part was
overwritten but the range flag remained, causing open
interval reading to be performed.

Bug was fixed by adding more stringent checking to the
search key building procedure (matching_cond) and never
allow overwrites of range predicates with non-range
predicates.

An assertion was added to make sure open intervals are never
used with full search keys.
2010-06-11 09:38:29 +02:00
Davi Arnaut
d6e003545a Merge of mysql-5.1-bugteam into mysql-trunk-merge. 2010-06-10 22:30:49 -03:00
Davi Arnaut
53b8829682 Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.

One somewhat major source of strict-aliasing violations and
related warnings is the SQL_LIST structure. For example,
consider its member function `link_in_list` which takes
a pointer to pointer of type T (any type) as a pointer to
pointer to unsigned char. Dereferencing this pointer, which
is done to reset the next field, violates strict-aliasing
rules and might cause problems for surrounding code that
uses the next field of the object being added to the list.

The solution is to use templates to parametrize the SQL_LIST
structure in order to deference the pointers with compatible
types. As a side bonus, it becomes possible to remove quite
a few casts related to acessing data members of SQL_LIST.
2010-06-10 17:45:22 -03:00
Davi Arnaut
bb036c93b4 Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.

Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.

As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.

The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
2010-06-10 17:16:43 -03:00
Alexander Nozdrin
222076528d Auto-merge from mysql-trunk-bugfixing. 2010-06-10 18:00:32 +04:00
Alexander Nozdrin
b985f88460 Revert a patch for Bug#54334 (Double initialization of mysys mutexes).
Revision ID of the patch: marc.alff@oracle.com-20100608124148-lr1ult7lwo75niev
2010-06-10 17:44:19 +04:00
Konstantin Osipov
41d95c5049 A pre-requisite for WL#5419 "LOCK_open scalability:
make tdc_refresh_version an 
atomic counter".
Backport the trivial changes from mysql-trunk-iplus.
2010-06-10 15:43:32 +04:00
Konstantin Osipov
df9ab0ffea A pre-requisite patch for WL#5419 "LOCK_open scalability:
make tdc_refresh_version an atomic counter".

To avoid orphaned TABLE_SHARE objects left in the
cache, make sure that wherever we set table->s->version
we take care of removing all unused table share objects
from the table cache. 

Always set table->s->version under LOCK_open, to make sure
that no other connection sees an old value of the
version and adds the table to unused_tables list.

Add an assert to table_def_unuse_table() that we never
'unuse' a talbe of a share that has an old version.

With this patch, only three places are left in the code
that manipulate with table->s->version:
- tdc_remove_table(). In most cases we have an X mdl lock
in tdc_remove_table(), the two remaining cases when we
don't are 'FLUSH TABLE' and mysql_admin_table().
- sql_view.cc - a crude hack that needs a separate fix
- initial assignment from refresh_version in table.cc.
2010-06-10 15:31:19 +04:00
Tor Didriksen
5fcfeb0817 Merge fix for Bug#53303 from 5.1-bugteam
text conflict: unittest/examples/Makefile.am
2010-06-10 13:21:35 +02:00
Tor Didriksen
e3b4d33187 Backport of Bug#53303 mytap tests should always have a plan()
The bug was caused by buffered output. Flushing resolved it.
We still recommend to allways call plan().
  
Also fix some compile warnings (formal parameter different from declaration)
2010-06-10 13:15:35 +02:00
Alexander Nozdrin
ad92ee1204 Auto-merge from mysql-trunk-bugfixing. 2010-06-10 14:38:32 +04:00
Davi Arnaut
d348f1219f Merge of mysql-5.1-bugteam into mysql-trunk-merge. 2010-06-09 21:41:40 -03:00
Davi Arnaut
2c8fd5fae8 Merge of mysql-5.0-bugteam into mysql-5.1-bugteam. 2010-06-09 21:36:20 -03:00
Davi Arnaut
b564aa92ab Bug#34236: Various possibly related SSL crashes
Addendum: Work around a compilation failure on Windows due to
          windows.h not being added to the global namespace.
2010-06-09 21:30:41 -03:00
Ramil Kalimullin
3058f4a136 Fix for bug #54007: assert in ha_myisam::index_next, HANDLER
Problem: the server missed the fact that one can read from 
2 indexes alternately using HANDLER interface.

Fix: check if the same (initialized) index is involved
reading next/prev values from the index.
2010-06-09 14:45:04 +04:00
Magne Mahre
fdd7c28bd8 Post-commit fixes after the push for Bug#20837 et. al. 2010-06-09 10:46:24 +02:00
Georgi Kodinov
fdbef84347 merge 2010-06-09 11:41:24 +03:00
Konstantin Osipov
b976fb1444 A review comment for WL#4441 " LOCK_open: Remove requirement of
mutex protecting thd->open_tables".

We should not manipulate with table->s->version outside the 
table definition cache code, but use the TDC API
to achieve the desired result.

Fix one violation: close_all_tables_for_name().
2010-06-09 12:39:09 +04:00
Georgi Kodinov
5932330839 Merge 2010-06-09 11:29:27 +03:00
Davi Arnaut
43316c794a Merge of mysql-5.1-bugteam into mysql-trunk-merge. 2010-06-08 20:44:25 -03:00
Davi Arnaut
1de997d849 Merge of mysql-5.0-bugteam into mysql-5.1-bugteam. 2010-06-08 18:14:18 -03:00
Davi Arnaut
514e407c44 Bug#53906: Stray semicolon in my_sys.h corrupts macro function definition of MY_INIT 2010-06-08 16:20:54 -03:00
Magne Mahre
0cb90edfe5 Bug#20837 Apparent change of isolation level during transaction
Bug#46527 COMMIT AND CHAIN RELEASE does not make sense
Bug#53343 completion_type=1, COMMIT/ROLLBACK AND CHAIN don't 
          preserve the isolation level
Bug#53346 completion_type has strange effect in a stored 
          procedure/prepared statement

Added test cases to verify the expected behaviour of :
 SET SESSION TRANSACTION ISOLATION LEVEL, 
 SET TRANSACTION ISOLATION LEVEL,
 @@completion_type,
 COMMIT AND CHAIN,
 ROLLBACK AND CHAIN
 ..and some combinations of the above
2010-06-08 19:47:10 +02:00
Davi Arnaut
f63046319b Bug#34236: Various possibly related SSL crashes
The problem was that the bundled yaSSL library was being built
without thread safety support regardless of the thread safeness
of the compoments linked with it.

The solution is to enable yaSSL thread safety support if any
component (server or client) is to be built with thread support.

Also, generate new certificates for yaSSL's test suite.
2010-06-08 10:36:47 -03:00
Marc Alff
ddf6a66504 Bug#54334 Double initialization of mysys mutexes
Prior to this fix, mysys mutexes such as THR_LOCK_lock could be initialized
twice by a call to my_init().
The root cause was out of place initialization in my_basic_init(),
calling my_thread_global_init().

With this fix,
- my_basic_init() properly initializes the mutex implementation itself,
for SAFE or FAST mutexes, and for platform dependent initializations,
before initialiazing a mutex.
- my_init() properly initializes mysys mutexes once,
when making the first call to my_thread_global_init().
2010-06-08 06:41:48 -06:00
Marko Mäkelä
fe0037b996 Merge a change from mysql-5.1-innodb:
------------------------------------------------------------
revno: 3503
revision-id: marko.makela@oracle.com-20100608121041-l7t9r6lrpx6lh361
parent: marko.makela@oracle.com-20100608114055-7b04ytuqz0lde6v1
committer: Marko Mäkelä <marko.makela@oracle.com>
branch nick: 5.1-innodb
timestamp: Tue 2010-06-08 15:10:41 +0300
message:
  Bug#54009: Server crashes when data is selected from non backed up table
  for InnoDB plugin

  dict_load_table(): Pass the correct tablespace flags to
  fil_open_single_table_tablespace(). For ROW_FORMAT=COMPACT and REDUNDANT,
  the tablespace flags are 0. The table flags would be 0 or DICT_TF_COMPACT.
2010-06-08 15:26:45 +03:00
Konstantin Osipov
85391c90ea Merge with trunk-runtime. 2010-06-08 16:20:15 +04:00
Kristofer Pettersson
8f4a33732a automerge 2010-06-08 13:50:54 +02:00
Marko Mäkelä
570a4ae8fe Merge a change from mysql-5.1-innodb:
------------------------------------------------------------
revno: 3502
revision-id: marko.makela@oracle.com-20100608114055-7b04ytuqz0lde6v1
parent: jimmy.yang@oracle.com-20100603134448-itzduhwgbw0b8nlh
committer: Marko Mäkelä <marko.makela@oracle.com>
branch nick: 5.1-innodb
timestamp: Tue 2010-06-08 14:40:55 +0300
message:
  buf_page_get_gen(): Pass file,line to rw_lock_x_lock().
2010-06-08 14:47:34 +03:00
Kristofer Pettersson
f813fbbb28 Automerge 2010-06-08 12:19:20 +02:00
Georgi Kodinov
a54aa69d8f Addendum to merge of Bug#52315 to mysql-trunk-merge :
Fixed the failing sys_vars.timestamp_basic.test by 
not re-calculating the value of the system variable at
check time.
2010-06-08 13:17:46 +03:00
Kristofer Pettersson
59dea5e7f8 merge 5.1-bugteam => trunk-merge 2010-06-08 12:17:07 +02:00
Kristofer Pettersson
5a570b0f54 Bug#53191 Lock_time in slow log is negative when logging stored routines
Logging slow stored procedures caused the slow log to write 
very large lock times. The lock times was a result of a 
negative number being cast to an unsigned integer.
The reason the lock time appeard negative was because 
one of the measurements points was reset after execution
causing it to change order with the start time of the 
statement.
      
This bug is related to bug 47905 which in turn was 
introduced because of a joint fix for 12480,12481,12482 and 11587.

The fix is to only reset the start_time before any statement
execution in a SP while not resetting start_utime or
utime_after_lock which are used for measuring the 
performance of the SP. Start_time is used to set the
timestamp on the replication event which controlls how
the slave interprets time functions like NOW().
2010-06-08 10:58:19 +02:00
Konstantin Osipov
4b6b69d22e WL#4441 "LOCK_open: Remove requirement of mutex protecting
thd->open_tables"

thd->open_tables list is not normally accessed concurrently
except for one case: when the connection has open SQL
HANDLER tables, and we want to perform a DDL on the table,
we want to abort waits on MyISAM thr_lock of those connections
that prevent the DDL from proceeding, and iterate
over thd->open_tables list to find out the tables on which
the thread is waiting.

In 5.5 we mostly use deadlock detection and soft deadlock 
prevention, as opposed to "hard" deadlock prevention
of 5.1, which would abort any transaction that
may cause a deadlock. The only remaining case when
neither deadlock detection nor deadlock prevention
is implemented in 5.5 is HANDLER SQL, where we use
old good thr_lock_abort() technique form 5.1. 

Thus, replace use of LOCK_open to protect thd->open_tables
with thd->LOCK_ha_data (a lock protecting various session
private data).

This is a port of the work done for 5.5.4 for review
and inclusion into 5.5.5.
2010-06-08 12:08:46 +04:00
Sergey Glukhov
482a40e149 5.1-bugteam->trunk-merge merge 2010-06-08 10:47:23 +04:00
Sergey Glukhov
39065d5105 5.0-bugteam->5.1-bugteam merge 2010-06-08 10:28:30 +04:00