Commit graph

28050 commits

Author SHA1 Message Date
Jon Olav Hauglid
936bec8e2c Merge from mysql-5.5-bugteam to mysql-5.5-runtime
Text conflict in mysql-test/suite/perfschema/r/dml_setup_instruments.result
Text conflict in mysql-test/suite/perfschema/r/global_read_lock.result
Text conflict in mysql-test/suite/perfschema/r/server_init.result
Text conflict in mysql-test/suite/perfschema/t/global_read_lock.test
Text conflict in mysql-test/suite/perfschema/t/server_init.test
2010-11-12 12:23:17 +01:00
Alexander Barkov
efe8743bd8 Merging from mysql-5.1-security 2010-11-12 13:20:58 +03:00
Alexander Barkov
0e1c167e16 Bug#58005 utf8 + get_format causes failed assertion: !str || str != Ptr'
Problem: When GET_FORMAT() is called two times from the upper
level function (e.g. LEAST in the bug report), on the second
call "res= args[0]->val_str(...)" and str point to the same
String object.

1. Fix: changing the order from
- get val_str into tmp_value then convert to str
to
- get val_str into str then convert to tmp_value

The new order is more correct: the purpose of "str" parameter
is exactly to call val_str() for arguments.
The purpose of String class members (like tmp_value) is to do further
actions on the result.
Doing it in the other way around give unexpected surprises.

2. Using str_value instead of str to do padding, for the same reason.
2010-11-12 13:12:15 +03:00
Marc Alff
80589ada50 Bug#58052 Binary log IO not being accounted for properly
Before this fix, file io for the binary log file was not accounted properly,
and showed no io at all.

This bug was due to the following issues:

1) file io for the binlog was instrumented:
- sometime as "wait/io/file/sql/binlog"
- sometime as "wait/io/file/sql/MYSQL_LOG"
leading to inconsistent event_names.

2) the binlog file itself was using an IO_CACHE,
but the IO_CACHE implementation in mysys/mf_iocache.c was
not instrumented to make performance schema calls to record file io.

3) The "wait/io/file/sql/MYSQL_LOG" instrumentation was used
for several log files, such as:
- the binary log
- the slow log
- the query log
which caused file io in these different log files to be accounted
against the same instrument.
The instrumentation needs to have a finer grain and report io
in different event_names, because each file really serves a different purpose.

With this fix:
- the IO_CACHE implementation is now instrumented
- the "wait/io/file/sql/MYSQL_LOG" instrument has been removed
- binlog io is now always instrumented with "wait/io/file/sql/binlog"
- the slow log is instrumented with a new name, "wait/io/file/sql/slow_log"
- the query log is instrumented with a new name, "wait/io/file/sql/query_log"
2010-11-12 07:23:26 +01:00
Dmitry Lenev
378cdc58c1 Patch that refactors global read lock implementation and fixes
bug #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ
LOCK" and bug #54673 "It takes too long to get readlock for
'FLUSH TABLES WITH READ LOCK'".

The first bug manifested itself as a deadlock which occurred
when a connection, which had some table open through HANDLER
statement, tried to update some data through DML statement
while another connection tried to execute FLUSH TABLES WITH
READ LOCK concurrently.

What happened was that FTWRL in the second connection managed
to perform first step of GRL acquisition and thus blocked all
upcoming DML. After that it started to wait for table open
through HANDLER statement to be flushed. When the first connection
tried to execute DML it has started to wait for GRL/the second
connection creating deadlock.

The second bug manifested itself as starvation of FLUSH TABLES
WITH READ LOCK statements in cases when there was a constant
stream of concurrent DML statements (in two or more
connections).

This has happened because requests for protection against GRL
which were acquired by DML statements were ignoring presence of
pending GRL and thus the latter was starved.

This patch solves both these problems by re-implementing GRL
using metadata locks.

Similar to the old implementation acquisition of GRL in new
implementation is two-step. During the first step we block
all concurrent DML and DDL statements by acquiring global S
metadata lock (each DML and DDL statement acquires global IX
lock for its duration). During the second step we block commits
by acquiring global S lock in COMMIT namespace (commit code
acquires global IX lock in this namespace).

Note that unlike in old implementation acquisition of
protection against GRL in DML and DDL is semi-automatic.
We assume that any statement which should be blocked by GRL
will either open and acquires write-lock on tables or acquires
metadata locks on objects it is going to modify. For any such
statement global IX metadata lock is automatically acquired
for its duration.

The first problem is solved because waits for GRL become
visible to deadlock detector in metadata locking subsystem
and thus deadlocks like one in the first bug become impossible.

The second problem is solved because global S locks which
are used for GRL implementation are given preference over
IX locks which are acquired by concurrent DML (and we can
switch to fair scheduling in future if needed).

Important change:
FTWRL/GRL no longer blocks DML and DDL on temporary tables.
Before this patch behavior was not consistent in this respect:
in some cases DML/DDL statements on temporary tables were
blocked while in others they were not. Since the main use cases
for FTWRL are various forms of backups and temporary tables are
not preserved during backups we have opted for consistently
allowing DML/DDL on temporary tables during FTWRL/GRL.

Important change:
This patch changes thread state names which are used when
DML/DDL of FTWRL is waiting for global read lock. It is now
either "Waiting for global read lock" or "Waiting for commit
lock" depending on the stage on which FTWRL is.

Incompatible change:
To solve deadlock in events code which was exposed by this
patch we have to replace LOCK_event_metadata mutex with
metadata locks on events. As result we have to prohibit
DDL on events under LOCK TABLES.

This patch also adds extensive test coverage for interaction
of DML/DDL and FTWRL.

Performance of new and old global read lock implementations
in sysbench tests were compared. There were no significant
difference between new and old implementations.
2010-11-11 20:11:05 +03:00
Tatiana A. Nurnberg
58f5b9c0cc Bug#43233: Some server variables are clipped during "update," not "check" stage
Bug#55794: ulonglong options of mysqld show wrong values.

Port the few remaining system variables to the correct mechanism --
range-check in check-stage (and throw error or warning at that point
as needed and depending on STRICTness), update in update stage.
Fix some signedness errors when retrieving sysvar values for display.
2010-11-11 11:35:48 +00:00
Mattias Jonsson
a58527deec Bug#57890: Assertion failed: next_insert_id == 0
with on duplicate key update

There was a missed corner case in the partitioning
handler, which caused the next_insert_id to be changed
in the second level handlers (i.e the hander of a partition),
which caused this debug assertion.

The solution was to always ensure that only the partitioning
level generates auto_increment values, since if it was done
within a partition, it may fail to match the partition
function.
2010-11-11 11:34:55 +01:00
Alexander Barkov
324cb45899 Merging from mysql-5.1-security 2010-11-11 13:31:17 +03:00
Alexander Barkov
771137b50e Bug#57257 Replace(ExtractValue(...)) causes MySQL crash
Bug#57820 extractvalue crashes

Problem: ExtractValue and Replace crashed in some cases
due to invalid handling of empty and NULL arguments.

Per file comments:

  @mysql-test/r/ctype_ujis.result
  @mysql-test/r/xml.result
  @mysql-test/t/ctype_ujis.test
  @mysql-test/t/xml.test
  Adding tests

  @sql/item_strfunc.cc
  Make sure Item_func_replace::val_str safely handles empty strings.

  @sql/item_xmlfunc.cc
  set null_value if nodeset_func returned NULL,
  which is possible when the second argument is an
  unset user variable.
2010-11-11 13:25:23 +03:00
Alexander Barkov
0c4e115c95 Bug#57687 crash when reporting duplicate group_key error and utf8
Fixing DoS regression problem.

Using "key_part->fieldnr - 1" to access the desired field
is only correct in real INSERT queries.
In case of inserting records into a temporary table
when performing GROUP BY queries this expression does not work.

Fix: Instead of accessing field_length and comparing it
to key_part->length, there is an easier way to check if
we're dealing with a prefix key: check key_part_flag against
HA_PART_KEY_SEG flag.
2010-11-11 11:08:53 +03:00
Tatiana A. Nurnberg
b56f1d8283 Bug #49752: 2469.126.2 unintentionally breaks authentication against
MySQL 5.1 server

Server used to clip overly long user-names. This was presumably lost
when code was made UTF8-clean.

Now we emulate the behaviour for backward compatibility, but UTF8-ly
correct.
2010-11-11 07:34:14 +00:00
Dmitry Shulga
0fa20fa441 Auto-merge from mysql-5.1-bugteam for bug#54375. 2010-11-11 11:06:16 +06:00
Dmitry Shulga
0fc49ccf9a Fixed bug#54375 - Error in stored procedure leaves connection
in different default schema.

In strict mode, when data truncation or conversion happens,
THD::killed is set to THD::KILL_BAD_DATA.

This is abuse of KILL mechanism to guarantee that execution
of statement is aborted.

The stored procedures execution, on the other hand,
upon detection that a connection was killed, would
terminate immediately, without trying to restore the caller's
context, in particular, restore the caller's current schema.

The fix is, when terminating a stored procedure execution,
to only bypass cleanup if the entire connection was killed,
not in case of other forms of KILL.
2010-11-11 10:52:51 +06:00
Davi Arnaut
80246ac8b8 Bug#58057: 5.1 libmysql/libmysql.c unused variable/compile failure
Bug#57995: Compiler flag change build error on OSX 10.4: my_getncpus.c
Bug#57996: Compiler flag change build error on OSX 10.5 : bind.c
Bug#57994: Compiler flag change build error : my_redel.c
Bug#57993: Compiler flag change build error on FreeBsd 7.0 : regexec.c
Bug#57992: Compiler flag change build error on FreeBsd : mf_keycache.c
Bug#57997: Compiler flag change build error on OSX 10.6: debug_sync.cc

Fix assorted compiler generated warnings.
2010-11-10 19:14:47 -02:00
Oystein Grovlen
117c19c262 Bug#57704 Cleanup code dies with void TABLE::set_keyread(bool): Assertion `file' failed.
This bug was introduced in this revision: 
kostja@sun.com-20100727102553-b4n2ojcyfj79l2x7
("A pre-requisite patch for the fix for Bug#52044.")

It happens because close_thread_tables() is now called in
open_and_lock_tables upon failure.  Hence, table is no longer
open when optimizer tries to do cleanup.

Fix: Make sure to do cleanup in st_select_lex_unit::prepare()
upon failure. This way, cleanup() is called before tables are
released.
2010-11-10 15:48:29 +01:00
Dmitry Shulga
ce3a7f4b01 Fixed bug#56619 - Assertion failed during
ALTER TABLE RENAME, DISABLE KEYS.

The code of ALTER TABLE RENAME, DISABLE KEYS could
issue a commit while holding LOCK_open mutex.
This is a regression introduced by the fix for
Bug 54453.
This failed an assert guarding us against a potential
deadlock with connections trying to execute
FLUSH TABLES WITH READ LOCK.

The fix is to move acquisition of LOCK_open outside
the section that issues ha_autocommit_or_rollback().
LOCK_open is taken to protect against concurrent
operations with .frms and the table definition
cache, and doesn't need to cover the call to commit.

A test case added to innodb_mysql.test.

The patch is to be null-merged to 5.5, which
already has 54453 null-merged to it.
2010-11-10 14:32:42 +06:00
Dmitry Shulga
64b897b0ce Auto-merge from 5.1-bugteam for bug#57386. 2010-11-10 11:58:50 +06:00
Dmitry Shulga
5b3e668af8 Fixed Bug#57386 - main.execution_constants segfault on MIPS64EL. 2010-11-10 11:49:37 +06:00
Davi Arnaut
5d7d1a42d8 Bug#58080: Crash on failure to create a thread to handle a user connection
The problem was that the scheduler function used to handle a
new user connection could use the ER() macro without having a
THD object bound to the current thread. The crash would happen
whenever the function failed to create a new thread to handle a
user connection. Thread creation can fail due to lack or limit
of available resources.

The solution is to simply use the ER_THD() macro instead and pass
to it the THD object which would be bound to the connection.

Fix was tested manually. In a test case, it is too cumbersome to
inject a error in this context.
2010-11-09 13:59:33 -02:00
Davi Arnaut
b963c7b14d Bug#57210: remove pstack
Quoting from the bug report:

The pstack library has been included in MySQL since version
4.0.0. It's useless and should be removed.

Details: According to its own documentation, pstack only works
on Linux on x86 in 32 bit mode and requires LinuxThreads and a
statically linked binary. It doesn't really support any Linux
from 2003 or later and doesn't work on any other OS.

The --enable-pstack option is thus deprecated and has no effect.
2010-11-09 12:45:13 -02:00
Jon Olav Hauglid
aee8fce233 Merge from mysql-5.5-bugteam to mysql-5.5-runtime
No conflicts
2010-11-08 15:37:04 +01:00
Sergey Glukhov
b318882949 Bug#52711 Segfault when doing EXPLAIN SELECT with union...order by (select... where...)
backport from 5.1
2010-11-08 13:51:39 +03:00
Sergey Glukhov
ff24facf81 Fix for bug #54575: crash when joining tables with unique set column(backport from 5.1)
Problem: a flaw (derefencing a NULL pointer) in the LIKE optimization
code may lead to a server crash in some rare cases.

Fix: check the pointer before its dereferencing.
2010-11-08 13:34:27 +03:00
Dmitry Shulga
1f79894087 Auto-merge from mysql-5.1-bugteam for bug#47924. 2010-11-08 00:06:22 +06:00
Dmitry Shulga
9c45600dac A fix and a test case for Bug#47924 -main.log_tables times out
sporadically.

The cause of the sporadic time out was a leaking protection
against the global read lock, taken by the RENAME statement,
and not released in case of an error occurred during RENAME.
The leaking protection counter would lead to the value of
protect_against_global_read never dropping to 0.
Consequently FLUSH TABLES in all connections, including the
one that leaked the protection, could not proceed.
 
The fix is to ensure that all branchesin RENAME code properly
release GRL protection.
2010-11-07 23:42:54 +06:00
Alfranio Correia
bf2c66d4a7 BUG#57275 binlog_cache_size affects trx- and stmt-cache and gets twice the expected memory
After the WL#2687, the binlog_cache_size and max_binlog_cache_size affect both the
stmt-cache and the trx-cache. This means that the resource used is twice the amount
expected/defined by the user.
      
The binlog_cache_use is incremented when the stmt-cache or the trx-cache is used
and binlog_cache_disk_use is incremented when the disk space from the stmt-cache or the
trx-cache is used. This behavior does not allow to distinguish which cache may be harming
performance due to the extra disk accesses and needs to have its in-memory cache
increased.
      
To fix the problem, we introduced two new options and status variables related to the
stmt-cache:
      
  Options:
      
    . binlog_stmt_cache_size
    . max_binlog_stmt_cache_size
      
    Status Variables:
      
    . binlog_stmt_cache_use
    . binlog_stmt_cache_disk_use

So there are

  . binlog_cache_size that defines the size of the transactional cache for
  updates to transactional engines for the binary log.

  . binlog_stmt_cache_size that defines the size of the statement cache for
  updates to non-transactional engines for the binary log.

  . max_binlog_cache_size that sets the total size of the transactional
  cache.

  . max_binlog_stmt_cache_size that sets the total size of the statement
  cache.

  . binlog_cache_use that identifies the number of transactions that used the
  temporary transactional binary log cache.

  . binlog_cache_disk_use that identifies the number of transactions that used
  the temporary transactional binary log cache but that exceeded the value of
  binlog_cache_size.

  . binlog_stmt_cache_use that identifies the number of statements that used the
  temporary non-transactional binary log cache.

  . binlog_stmt_cache_disk_use that identifies the number of statements that used
  the temporary non-transactional binary log cache but that exceeded the value of
  binlog_stmt_cache_size.
2010-11-05 17:42:37 +00:00
Mats Kindahl
f24edae3ab Merging patch for BUG#57108 with mysql-5.5-bugteam 2010-11-05 15:50:11 +01:00
Jon Olav Hauglid
355ff93fbc Merge from mysql-5.5-bugteam to mysql-5.5-runtime
No conflicts
2010-11-05 15:24:16 +01:00
Alfranio Correia
c26c9b805e BUG#56343 binlog_cache_use status is bigger than expected
The binlog_cache_use is incremented twice when changes to a transactional table
are committed, i.e. TC_LOG_BINLOG::log_xid calls is called. The problem happens
because log_xid calls both binlog_flush_stmt_cache and binlog_flush_trx_cache
without checking if such caches are empty thus unintentionally increasing the
binlog_cache_use value twice.

Although not explicitly mentioned in the bug, the binlog_cache_disk_use presents
the same problem.

The binlog_cache_use and binlog_cache_disk_use are status variables that are
incremented when transactional (i.e. trx-cache) or non-transactional (i.e.
stmt-cache) changes are committed. They are used to compute the ratio between
the use of disk and memory while gathering updates for a transaction.

The problem reported is fixed by avoiding incrementing the binlog_cache_use
and binlog_cache_disk_use if a cache is empty. We also have decided to increment
both variables when a cache is truncated as the cache is used although its
content is discarded and is not written to the binary log.

In this patch, we take the opportunity to re-organize the code around the
function binlog_flush_trx_cache and binlog_flush_stmt_cache.
2010-11-05 13:58:05 +00:00
Guilhem Bichot
f80d13e530 Fix for BUG#57316 "It is not clear how to disable autocommit"
add boolean command-line option --autocommit.
2010-11-05 14:16:27 +01:00
Mattias Jonsson
6c2c6118b3 Bug#57778: failed primary key add to partitioned innodb table inconsistent and crashes
It was possible to issue an ALTER TABLE ADD PRIMARY KEY on
an partitioned InnoDB table that failed and crashed the server.

The problem was that it succeeded to create the PK on at least
one partition, and then failed on a subsequent partition, due to
duplicate key violation. Since the partitions that already had added
the PK was not reverted all partitions was not consistent with the
table definition, which caused the crash.

The solution was to add a revert step to ha_partition::add_index()
that dropped the index for the already succeeded partitions, on failure.
2010-11-05 12:01:10 +01:00
Luis Soares
682014526c BUG 57899: merged bzr bundle #1 from bug report into latest
mysql-5.5-bugteam.
2010-11-05 08:30:10 +00:00
Evgeny Potemkin
a7a1cf0d33 Auto-merged. 2010-11-04 23:38:45 +03:00
Evgeny Potemkin
ccbf81d5ff Bug#57278: Crash on min/max + with date out of range.
MySQL officially supports DATE values starting from 1000-01-01. This is
enforced for int values, but not for string values, thus one
could easily insert '0001-01-01' value. Int values are checked by
number_to_datetime function and Item_cache_datetime::val_str uses it
to fill MYSQL_TIME struct out of cached int value. This leads to the
scenario where Item_cache_datetime caches a non-null datetime value and when
it tries to convert it from int to string number_to_datetime function
treats the value as out-of-range and returns an error and
Item_cache_datetime::val_str returns NULL for a non-null value. Due to this
inconsistency server crashes.

Now number_to_datetime allows DATE values below 1000-01-01 if the
TIME_FUZZY_DATE flag is set. Better NULL handling for Item_cache_datetime.
Added the Item_cache_datetime::store function to reset str_value_cached flag
when an item is stored.
2010-11-04 16:18:27 +03:00
Mats Kindahl
d817b7cb8a BUG#57108: mysqld crashes when I attempt to install plugin
If a relative path is supplied to option --defaults-file or
--defaults-extra-file, the server will crash when executing
an INSTALL PLUGIN command. The reason is that the defaults
file is initially read relative the current working directory
when the server is started, but when INSTALL PLUGIN is executed,
the server has changed working directory to the data directory.
Since there is no check that the call to my_load_defaults()
inside mysql_install_plugin(), the subsequence call to
free_defaults() will crash the server.

This patch fixes the problem by:

- Prepending the current working directory to the file name when
  a relative path is given to the --defaults-file or --defaults-
  extra-file option the first time my_load_defaults() is called,
  which is just after the server has started in main().

- Adding a check of the return value of my_load_defaults() inside
  mysql_install_plugin() and aborting command (with an error) if
  an error is returned.

- It also adds a check of the return value for load_defaults in
  lib_sql.cc for the embedded server since that was missing.

To test that the relative files for the options --defaults-file and
--defaults-extra-file is handled properly, mysql-test-run.pl is also
changed to not add a --defaults-file option if one is provided in the
tests *.opt file.
2010-11-04 11:00:59 +01:00
Jorgen Loland
eeb8bce911 Bug#57882 - Item_func_conv_charset::val_str(String*):
Assertion `fixed == 1' failed

(also fixes duplicate bug 57515)

agg_item_set_converter() (item.cc) handles conversion of 
character sets by creating a new Item. fix_fields() is then 
called on this newly created item. Prior to this patch, it was
not checked whether fix_fields() was successful or not. Thus, 
agg_item_set_converter() would return success even when an 
error occured. This patch makes it return error (TRUE) if 
fix_fields() fails.
2010-11-04 09:36:04 +01:00
He Zhenxing
04673ee770 BUG#47027 delegates_init() failure is not user friendly (usability issue)
Function delegetas_init() did not report proper error messages
when there are failures, which made it hard to know where the problem
occurred.

Fixed the problem by adding specific error message for every possible
place that can fail. And since these failures are supposed to never
happen, ask the user to report a bug if they happened.
2010-11-04 13:29:16 +08:00
Jon Olav Hauglid
0fb0d9a9a2 Bug #57130 crash in Item_field::print during SHOW CREATE TABLE or VIEW
This crash could happen if SHOW CREATE VIEW indirectly failed to open a
view due to failures to open underlying tables (or functions). Several
such errors were hidden and converted to ER_VIEW_INVALID warnings to
prevent exposing details of underlying tables for which the user have
no privileges.

However, with the changes introduced by the patch for Bug#52044,
failing to open a view will cause opened tables, views and functions
to be closed. Since the errors causing these failures were converted
to warnings, SHOW CREATE VIEW would try to continue. This made it
possible to try to access memory that had been freed, causing a crash.

This patch fixes the problem by not closing opened tables, views and
functions in these cases. This allows SHOW CREATE VIEW to continue
and also prevents it from accessing freed memory.

Test case added to lock_sync.test.
2010-11-03 16:47:32 +01:00
Luis Soares
9d102947e8 BUG#57899: Certain reserved words should not be reserved
In MySQL 5.5 the new reserved words include:
SLOW                    as in FLUSH SLOW LOGS
GENERAL                 as in FLUSH GENERAL LOGS
IGNORE_SERVER_IDS       as in CHANGE MASTER ... IGNORE_SERVER_IDS
MASTER_HEARTBEAT_PERIOD as in CHANGE MASTER ... MASTER_HEARTBEAT_PERIOD

These are not reserved words in standard SQL, or in Oracle 11g,
and as such, may affect existing applications.

We fix this by adding the new words to the list of 
keywords that are allowed for labels in SPs.
2010-11-03 14:51:52 +00:00
Georgi Kodinov
7e2fa49edf merge 2010-11-03 16:09:17 +02:00
Georgi Kodinov
b69f9b397a Bug #57916: Fix the naming of the proxy_priv table
1. Fixed the name of the table to proxies_priv
2. Fixed the column names to be of the form Capitalized_lowecarse instead of
Capitalized_Capitalized
3. Added Timestamp and Grantor columns
4. Added tests to plugin_auth to check the table structure
5. Updated the existing tests
2010-11-02 17:45:26 +02:00
Georgi Kodinov
3202c98c92 merge 2010-11-02 16:02:16 +02:00
Georgi Kodinov
4e78acd35c Bug #51208: Extra string allocation from thd->mem_root
in sql_show.cc, find_files()

Removed the extra allocation.
2010-11-02 15:20:02 +02:00
Jon Olav Hauglid
9d16003a00 Merge from mysql-5.5-bugteam to mysql-5.5-runtime
No conflicts
2010-11-01 12:10:04 +01:00
Gleb Shchepa
89f9f6a40d manual merge 5.1-bugteam --> 5.5-bugteam (bug 52160) 2010-11-01 02:23:37 +03:00
Gleb Shchepa
0389c6aac0 Bug #52160: crash and inconsistent results when grouping
by a function and column

The bugreport reveals two different bugs about grouping
on a function:

1) grouping by the TIME_TO_SEC function result caused
   a server crash or wrong results and
2) grouping by the function returning a blob caused
   an unexpected "Duplicate entry" error and wrong
   result.

Details for the 1st bug:

TIME_TO_SEC() returns NULL if its argument is invalid (empty
string for example). Thus its nullability depends not only
on the nullability of its arguments but also on their values.
Fixed by (overoptimistically) setting TIME_TO_SEC() to be
nullable despite the nullability of its arguments.

Details for the 2nd bug:

The server is unable to create indices on blobs without
explicit blob key part length. However, this fact was
ignored for blob function result fields of GROUP BY
intermediate tables.
Fixed by disabling GROUP BY index creation for blob
function result fields like regular blob fields.
2010-10-31 19:04:38 +03:00
Jon Olav Hauglid
97e295cc22 Bug #57659 Segfault in Query_cache::invalidate_data for TRUNCATE TABLE
This crash could happen if TRUNCATE TABLE indirectly failed to open a
merge table due to failures to open underlying tables. Even if opening
failed, the TRUNCATE TABLE code would try to invalidate the table in
the query cache. Since this table had been closed and memory released,
this could lead to a crash.

This bug was introduced by a combination of the changes introduced by
the patch for Bug#52044, where failing to open a table will cause opened
tables to be closed. And the changes in patch for Bug#49938, where
TRUNCATE TABLE uses the standard open tables function.

This patch fixes the problem by setting the TABLE pointer to NULL before 
invalidating the query cache.

Test case added to truncate_coverage.test.
2010-10-29 16:10:53 +02:00
Georgi Kodinov
97a06e4d9a merge 2010-10-29 15:25:18 +03:00
Georgi Kodinov
860c9d9c35 merge to 5.1-security 2010-10-29 14:02:49 +03:00
Jon Olav Hauglid
37efd0e1ef Merge from mysql-5.5-bugteam to mysql-5.5-runtime
No conflicts
2010-10-29 11:46:18 +02:00
Tor Didriksen
ea61d74328 Bug #52131: SET and ENUM stored endian-dependent in binary log
Post-Push fix, DBUG build broken on freebsd7

sql/field.cc:8456: warning: control reaches end of non-void function
2010-10-29 11:35:07 +02:00
Sergey Glukhov
88e82a892b 5.1-security->5.5-security merge 2010-10-29 12:31:28 +04:00
Sergey Glukhov
e3917c3d43 Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field
Lines below which were added in the patch for Bug#56814 cause this crash:

+      if (table->table)
+        table->table->maybe_null= FALSE;

Consider following test case:
--
CREATE TABLE t1(f1 INT NOT NULL);
INSERT INTO t1 VALUES (16777214),(0);

SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2
ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1;

DROP TABLE t1;
--

We set TABLE::maybe_null to FALSE for t2 table
and in create_tmp_field() we create appropriate tmp table field
using create_tmp_field_from_item() function instead of
create_tmp_field_from_field. As a result we have
LONGLONG field. As we have GROUP BY clause we calculate
group buffer length, see calc_group_buffer().
Item from group list which is used for calculation
refer to the field from real tables and have LONG type.
So group buffer length become insufficient for storing of
LONGLONG value. It leads to overwriting of wrong memory
area in do_field_int() function which is called from
end_update().
After some investigation I found out that
create_tmp_field_from_item() is used only for OLAP
grouping and can not be used for common grouping
as it could be an incompatibility between tmp
table fields and group buffer length.
We can not remove create_tmp_field_from_item() call from
create_tmp_field as OLAP needs it and we can not use this
function for common grouping. So we should remove setting
TABLE::maybe_null to FALSE from simplify_joins().
In this case we'll get wrong behaviour of
list_contains_unique_index() back. To fix it we
could use Field::real_maybe_null() check instead of
Field::maybe_null() and add addition check of
TABLE_LIST::outer_join.
2010-10-29 12:23:06 +04:00
Sergey Glukhov
bfa29d10e0 5.1-security->5.5-security 2010-10-29 11:59:36 +04:00
Sergey Glukhov
3a61843a1f Bug#57194 group_concat cause crash and/or invalid memory reads with type errors
The problem is caused by bug49487 fix and became visible
after after bug56679 fix.
Items are cleaned up and set to unfixed state after filling derived table.
So we can not rely on item::fixed state in Item_func_group_concat::print
and we can not use 'args' array as items there may be cleaned up.
The fix is always to use orig_args array of items as it
always should contain the correct data.
2010-10-29 11:44:32 +04:00
Konstantin Osipov
09b07bfae1 Remove a dead declaration. 2010-10-27 22:57:44 +04:00
Mattias Jonsson
02f1a6cbaa post merge fix 2010-10-28 12:08:09 +02:00
Mats Kindahl
9368f11b69 Merging patch for BUG#52131 with mysql-5.5-bugteam. 2010-10-27 23:12:45 +02:00
Sergey Glukhov
5bf148fccd Bug#57477 SIGFPE when dividing a huge number a negative number
The problem is dividing by const value when
the result is out of supported range.
The fix:
-return LONGLONG_MIN if the result is out of supported range for DIV operator.
-return 0 if divisor is -1 for MOD operator.
2010-10-27 18:12:10 +04:00
Georgi Kodinov
777ad2dd98 Bug #57689: mysql_change_user() breaks user connection on older clients
COM_CHANGE_USER was always handled like an implicit request to change the
client plugin, so that the client can re-use the same code path for both normal 
login and COM_CHANGE_USER. However this doesn't really work well with old 
clients because they don't understand the request to change a client plugin.

Fixed by implementing a special state in the code (and old client issuing 
COM_CHANGE_USER). In this state the server parses the COM_CHANGE_USER 
package and pushes back the password hash, the user name and the database 
to the input stream in the same order that the native password server side plugin 
expects. As a result it replies with an OK/FAIL just like the old server does thus
making the new server compatible with older clients.

No test case added, since it would requre an old client binary. Tested using 
accounts with and without passwords. Tested with a correct and incorrect 
password.
2010-10-25 18:11:58 +03:00
Georgi Kodinov
cfa413bf4e merge 2010-10-27 09:32:26 +02:00
Alexander Nozdrin
1ed6c86396 Patch for Bug#55850 (Trigger warnings not cleared).
The problem was that the warnings risen by a trigger were not cleared upon
successful completion. The warnings should be cleared if the trigger completes
successfully.

The fix is to skip merging warnings into caller's Warning Info for triggers.
2010-10-26 15:48:08 +04:00
Tor Didriksen
e6ae473bca Bug#45288: pb2 returns a lot of compilation warnings
sql/sql_lex.h:1437: warning: control reaches end of non-void function
2010-10-25 17:08:27 +02:00
Jon Olav Hauglid
a12de3d00d Merge from mysql-5.5-bugteam to mysql-5.5-runtime
No conflicts
2010-10-25 14:26:21 +02:00
f11fc60281 Manual merge 2010-10-23 21:09:27 +08:00
180e74bd49 Bug#27606 GRANT statement should be replicated with DEFINER information
"Grantor" columns' data is lost when replicating mysql.tables_priv.
Slave SQL thread used its default user ''@'' as the grantor of GRANT|REVOKE
statements executing on it.

In this patch, current user is put in query log event for all GRANT and REVOKE
statement, SQL thread uses the user in query log event as grantor.
2010-10-23 20:55:44 +08:00
Davi Arnaut
ae6801eb23 Bug#37780: Make KILL reliable (main.kill fails randomly)
- A prerequisite cleanup patch for making KILL reliable.

The test case main.kill did not work reliably.

The following problems have been identified:

1. A kill signal could go lost if it came in, short before a
thread went reading on the client connection.

2. A kill signal could go lost if it came in, short before a
thread went waiting on a condition variable.

These problems have been solved as follows. Please see also
added code comments for more details.

1. There is no safe way to detect, when a thread enters the
blocking state of a read(2) or recv(2) system call, where it
can be interrupted by a signal. Hence it is not possible to
wait for the right moment to send a kill signal. It has been
decided, not to fix it in the code.  Instead, the test case
repeats the KILL statement until the connection terminates.

2. Before waiting on a condition variable, we register it
together with a synchronizating mutex in THD::mysys_var. After
this, we need to test THD::killed again. At some places we did
only test it in a loop condition before the registration. When
THD::killed had been set between this test and the registration,
we entered waiting without noticing the killed flag. Additional
checks ahve been introduced where required.

In addition to the above, a re-write of the main.kill test
case has been done. All sleeps have been replaced by Debug
Sync Facility synchronization. A couple of sync points have
been added to the server code.

To avoid further problems, if the test case fails in spite of
the fixes, the test case has been added to the "experimental"
list for now.

- Most of the work on this patch is authored by Ingo Struewing
2010-10-22 09:58:09 -02:00
Jon Olav Hauglid
26e7ee2fa5 Merge from mysql-5.5-bugteam to mysql-5.5-runtime
No conflicts
2010-10-21 16:28:29 +02:00
Dmitry Shulga
3d9cddabf8 Fixed bug#45445 - cannot execute procedures with thread_stack
set to 128k.
2010-10-21 15:41:13 +07:00
9c2c464805 Manual Merge 2010-10-21 13:49:19 +08:00
aa235b1b15 Bug#55478 Row events wrongly apply on the temporary table of the same name
Rows events were applied wrongly on the temporary table with the same name.
But rows events are generated only for base tables. As temporary
table's data never be binlogged on row mode. Normally, base table of the
same name cannot be updated if a temporary table has the same name.
But there are two cases which can generate rows events on 
the base table of same name.
      
Case1: 'CREATE TABLE ... SELECT' statement.
In mixed format, it will generate rows events if it is unsafe.
      
Case2: Drop a transactional temporary table in a transaction
       (happens only on 5.5+).
BEGIN;
DROP TEMPORARY TABLE t1;       # t1 is a InnoDB table
INSERT INTO t1 VALUES(rand()); # t1 is a MyISAM table
COMMIT;
'DROP TEMPORARY TABLE' will be put in the transaction cache and
binlogged after the rows events generated by the 'INSERT' statement.
      
After this patch, slave opens only base table when applying a rows event.
2010-10-21 13:43:19 +08:00
Davi Arnaut
1e1985eba7 Merge of mysql-5.1-bugteam into mysql-5.5-bugteam. 2010-10-20 17:02:59 -02:00
Davi Arnaut
560ee2158d Bug#45288: pb2 returns a lot of compilation warnings
Fix assorted warnings that are generated in optimized builds.
Most of it is silencing variables that are set but unused.

This patch also introduces the MY_ASSERT_UNREACHABLE macro
which helps the compiler to deduce that a certain piece of
code is unreachable.
2010-10-20 16:21:40 -02:00
Magnus Blåudd
95ee8f4cf6 Bug#57604 Reserve bit in option_bits for slave_allow_batching feature
- Add  define to reserve bit number 36 for slave_allow_batching feature
2010-10-20 15:54:58 +02:00
Oystein Grovlen
07fd5d6f99 Bug#57512 str_to_date crash...
str_to_date function should only try to generate a warning for
invalid input strings, not when input value is NULL. In latter
case, val_str() of input argument will return a nil pointer.
Trying to generate a warning using this pointer lead to a
segmentation fault. Solution: Only generate warning when pointer
to input string is non-nil.
2010-10-20 15:17:29 +02:00
Jon Olav Hauglid
5ea471bde5 Merge from mysql-5.5-bugteam to mysql-5.5-runtime
No conflicts
2010-10-20 10:41:32 +02:00
Davi Arnaut
69aea87d5f Merge of mysql-5.1-bugteam into mysql-5.5-bugteam. 2010-10-19 20:51:34 -02:00
Davi Arnaut
39e9bde2c0 Bug#45288: pb2 returns a lot of compilation warnings
Tag or remove unused arguments and variables.
2010-10-19 20:36:59 -02:00
Konstantin Osipov
192ee935aa Merge 5.5-bugteam -> 5.5-runtime. 2010-10-19 19:20:25 +04:00
Magne Mahre
1c68d2efe7 Bug #46941 crash with lower_case_table_names=2 and foreign key
data dictionary confusion

On file systems with case insensitive file names, and
lower_case_table_names set to '2', the server could crash
due to a table definition cache inconsistency.  This is 
the default setting on MacOSX, but may also be set and
used on MS Windows.

The bug is caused by using two different strategies for
creating the hash key for the table definition cache, resulting
in failure to look up an entry which is present in the cache,
or failure to delete an existing entry.  One strategy was to
use the real table name (with case preserved), and the other
to use a normalized table name (i.e a lower case version).

This is manifested in two cases.  One is  during 'DROP DATABASE', 
where all known files are removed.  The removal from
the table definition cache is done via a generated list of
TABLE_LIST with keys (wrongly) created using the case preserved 
name.  The other is during CREATE TABLE, where the cache lookup
is also (wrongly) based on the case preserved name.
   
The fix was to use only the normalized table name when
creating hash keys.
2010-10-19 12:27:09 +02:00
Jon Olav Hauglid
1bb2c68bfa Merge from mysql-5.5-bugteam to mysql-5.5-runtime
No conflicts
2010-10-19 11:26:45 +02:00
Tor Didriksen
acaede7334 Bug #57203 Assertion `field_length <= 255' failed.
After the fix for
Bug #55077 Assertion failed: width > 0 && to != ((void *)0), file .\dtoa.c
we no longer try to allocate a string of length 'field_length'
so the asserts are relevant only for ZEROFILL columns.
2010-10-19 08:45:18 +02:00
Sergey Glukhov
3e876844a7 5.1-security->5.5-security merge 2010-10-18 16:22:02 +04:00
Sergey Glukhov
e6472e8fed Bug#56814 Explain + subselect + fulltext crashes server
create_sort_index() function overwrites original JOIN_TAB::type field.
At re-execution of subquery overwritten JOIN_TAB::type(JT_ALL) is
used instead of JT_FT. It misleads test_if_skip_sort_order() and
the function tries to find suitable key for the order that should
not be allowed for FULLTEXT(JT_FT) table.
The fix is to restore JOIN_TAB strucures for subselect on re-execution
for EXPLAIN.
Additional fix:
Update TABLE::maybe_null field which
affects list_contains_unique_index() behaviour as it
could have the value(maybe_null==TRUE) based on the
assumption that this join is outer
(see setup_table_map() func).
2010-10-18 16:12:27 +04:00
Tor Didriksen
367549ab2b Bug#52172 test binlog.binlog_index needs --skip-core-file to avoid leaving core files
For crash testing: kill the server without generating core file.

include/my_dbug.h
  Use kill(getpid(), SIGKILL) which cannot be caught by signal handlers.
  All DBUG_XXX macros should be no-ops in optimized mode, do that for DBUG_ABORT as well.
sql/handler.cc
  Kill server without generating core.
sql/log.cc
  Kill server without generating core.
2010-10-18 13:27:52 +02:00
Tor Didriksen
0853153346 Bug#52172 test binlog.binlog_index needs --skip-core-file to avoid leaving core files
For crash testing: kill the server without generating core file.

include/my_dbug.h
  Use kill(getpid(), SIGKILL) which cannot be caught by signal handlers.
  All DBUG_XXX macros should be no-ops in optimized mode, do that for DBUG_ABORT as well.
sql/handler.cc
  Kill server without generating core.
sql/log.cc
  Kill server without generating core.
2010-10-18 13:24:34 +02:00
Sergey Glukhov
c77992cd5f 5.1-security->5.5-security merge 2010-10-18 15:06:15 +04:00
Sergey Glukhov
9a8f22fa2d Bug#54484 explain + prepared statement: crash and Got error -1 from storage engine
Subquery executes twice, at top level JOIN::optimize and ::execute stages.
At first execution create_sort_index() function is called and
FT_SELECT object is created and destroyed. HANDLER::ft_handler is cleaned up
in the object destructor and at second execution FT_SELECT::get_next() method
returns error.
The fix is to reinit HANDLER::ft_handler field before re-execution of subquery.
2010-10-18 14:47:26 +04:00
b1b7e534ef Manual merge 2010-10-16 22:20:35 +08:00
131e3e38fd Bug#56118 STOP SLAVE does not wait till trx with CREATE TMP TABLE ends,
replication aborts

When recieving a 'SLAVE STOP' command, slave SQL thread will roll back the
transaction and stop immidiately if there is only transactional table updated,
even through 'CREATE|DROP TEMPOARY TABLE' statement are in it. But These
statements can never be rolled back. Because the temporary tables to the user
session mapping remain until 'RESET SLAVE', Therefore it will abort SQL thread
with an error that the table already exists or doesn't exist, when it restarts
and executes the whole transaction again.

After this patch, SQL thread always waits till the transaction ends and then stops,
if 'CREATE|DROP TEMPOARY TABLE' statement are in it.
2010-10-16 20:03:44 +08:00
Alexey Botchkov
c8adfa3366 merging. 2010-10-15 20:44:55 +05:00
Alexey Botchkov
5f06f44f8b merging. 2010-10-15 20:13:35 +05:00
Mattias Jonsson
50fcba46f4 Manual merge 2010-10-15 10:06:22 +02:00
Mattias Jonsson
2246f67f7a merge 2010-10-15 09:27:28 +02:00
Konstantin Osipov
efcb38e71e A fix and a test case for Bug#56540 "Exception (crash) in
sql_show.cc during rqg_info_schema test on Windows".

Ensure we do not access freed memory when filling
information_schema.views when one of the views
could not be properly opened.
2010-10-14 20:56:56 +04:00
Jon Olav Hauglid
7774a0048a Follow-up for Bug #55930 Assertion `thd->transaction.stmt.is_empty()
|| thd->in_sub_stmt || (thd->state..

Don't rollback statement transactions if we are in a sub-statement.
This could for example happen for open_ltable() when opening the
general log during execution of a stored procedure.
2010-10-14 11:02:37 +02:00
Davi Arnaut
7d64c36486 Bug#56096: STOP SLAVE hangs if executed in parallel with user sleep
The root of the problem is that to interrupt a slave SQL thread
wait, the STOP SLAVE implementation uses thd->awake(THD::NOT_KILLED).
This appears as a spurious wakeup (e.g. from a sleep on a
condition variable) to the code that the slave SQL thread is
executing at the time of the STOP. If the code is not written
to be spurious-wakeup safe, unexpected behavior can occur. For
the reported case, this problem led to an infinite loop around
the interruptible_wait() function in item_func.cc (SLEEP()
function implementation).  The loop was not being properly
restarted and, consequently, would not come to an end. Since the
SLEEP function sleeps on a timed event in order to be killable
and to perform periodic checks until the requested time has
elapsed, the spurious wake up was causing the requested sleep
time to be reset every two seconds.

The solution is to calculate the requested absolute time only
once and to ensure that the thread only sleeps until this
time is elapsed. In case of a spurious wake up, the sleep is
restarted using the previously calculated absolute time. This
restores the behavior present in previous releases. If a slave
thread is executing a SLEEP function, a STOP SLAVE statement
will wait until the time requested in the sleep function
has elapsed.
2010-10-13 22:54:07 -03:00
Jon Olav Hauglid
4eb324693f Bug #55930 Assertion `thd->transaction.stmt.is_empty() ||
thd->in_sub_stmt || (thd->state..

OPTIMIZE TABLE is not directly supported by InnoDB. Instead,
recreate and analyze of the table is done. After recreate,
the table is closed and locks are released before the table
is reopened and locks re-acquired for the analyze phase.

This assertion was triggered if OPTIMIZE TABLE failed to
acquire thr_lock locks before starting the analyze phase.
The assertion tests (among other things) that there no
active statement transaction. However, as part of acquiring
the thr_lock lock, external_lock() is called for InnoDB
tables and this causes a statement transaction to be started.
If thr_multi_lock() later fails (e.g. due to timeout),
the failure handling code causes this assert to be triggered.

This patch fixes the problem by doing rollback of the
current statement transaction in case open_ltable (used by
OPTIMIZE TABLE) fails to acquire thr_lock locks.

Test case added to lock_sync.test.
2010-10-13 16:15:28 +02:00
Luis Soares
a7dc817904 Automerge from mysql-5.1-bugteam into mysql-5.5-bugteam. 2010-10-13 11:08:39 +01:00
Alexander Nozdrin
46f2610b26 Reverting a patch for Bug#45445 (cannot execute procedures with thread_stack set to 128k).
Some platforms don't work with 4 * STACK_MIN_SIZE.
Thus, reverting back to 8 * STACK_MIN_SIZE and waiting for another fix.
2010-10-13 13:34:02 +04:00
Alexander Nozdrin
79626ba4ab Reverting a patch for Bug#45445 (cannot execute procedures with thread_stack set to 128k).
Some platforms don't work with 4 * STACK_MIN_SIZE.
Thus, reverting back to 8 * STACK_MIN_SIZE and waiting for another fix.
2010-10-13 13:29:34 +04:00
Konstantin Osipov
148260044e Fix Bug#56443 remove last 'mysqld_show_column_type' remains 2010-10-13 12:48:08 +04:00
Luis Soares
5f31581fff BUG 55263: automerged bzr bundle from bug report into
latest mysql-5.1-bugteam.
2010-10-13 08:26:50 +01:00
Luis Soares
0e5d43cd81 BUG 38718: automerged bzr bundle from bug report into
latest mysql-5.1-bugteam.
2010-10-13 08:25:43 +01:00
Dmitry Shulga
32658e4512 Auto-merge from mysql-5.1-bugteam for bug#36742. 2010-10-13 13:27:03 +07:00
Dmitry Shulga
fea55c7ff5 Fixed bug#36742 - GRANT hostname case handling inconsistent. 2010-10-13 12:28:58 +07:00
Ramil Kalimullin
a9ac3cde49 Merge. 2010-10-13 08:51:37 +04:00
Alexander Nozdrin
bde1955104 Auto-merge from mysql-5.5-bugteam. 2010-10-13 01:17:22 +04:00
Ramil Kalimullin
9ef7eac2c0 Fix for bug#57283: inet_ntoa() crashes
Problem: some call of INET_NTOA() function may lead 
to a crash due to missing its character set initialization.

Fix: explicitly set the character set.
2010-10-12 23:28:03 +04:00
Ramil Kalimullin
5a2a6c2c0d Fix for bug#57272: crash in rpad() when using utf8
Problem: if multibyte and binary string arguments passed to 
RPAD(), LPAD() or INSERT() functions, they might return 
wrong results or even lead to a server crash due to missed
character set convertion.

Fix: perform the convertion if necessary.
2010-10-12 23:25:40 +04:00
Jon Olav Hauglid
ea7acdefbc Merge from mysql-5.5-bugteam to mysql-5.5-runtime
No conflicts
2010-10-12 15:26:35 +02:00
Dmitry Shulga
b79f67eaf4 A follow up for the patch for Bug#45445, increase stack size
to fix an sp-error.test failure on Sun Sparc system.
2010-10-12 19:19:33 +07:00
Alexander Nozdrin
26e12a11bb Fix compilation warnings. 2010-10-12 14:07:13 +04:00
Luis Soares
f2dabc49e1 Fix for crash in mysqld --verbose --help while initializing option
for --init-rpl-role.

Problem: There are two variables involved in this issue,
rpl_status and rpl_role_type. The former is an array containing
the description of the possible values for the latter.

rpl_status is declared as an enumeration and is stored in a 4
bytes integer. On the other hand, my_getopt, reads enum values
into a ulong:

  *(ulong*)value= arg;

This is overwriting the memory used for rpl_role_type, 
corrupting the first entry in the array.

Fix: We fix this by re-declaring rpl_status as a ulong, so that it
has space to accommodate the value "parsed" in my_getopt .
2010-10-11 15:50:14 +01:00
d7767d4ab6 Bug#56226 Table map set to 0 after altering MyISAM table
After ALTER TABLE which changed only table's metadata, row-based
binlog sometimes got corrupted since the tablemap was unexpectedly
set to 0 for subsequent updates to the same table.

ALTER TABLE which changed only table's metadata always reset
table_map_id for the table share to 0. Despite the fact that
0 is a valid value for table_map_id, this step caused problems
as it could have created situation in which we had more than
one table share with table_map_id equal 0. If more than one
table with table_map_id are 0 were updated in the same statement,
updates to these different tables were written into the same
rows event. This caused slave server to crash.

This bug happens only on 5.1. It doesn't affect 5.5+.

This patch solves this problem by ensuring that ALTER TABLE
statements which change metadata only never reset table_map_id
to 0. To do this it changes reopen_table() to correctly use
refreshed table_map_id value instead of using the old one/
resetting it.
2010-10-11 11:08:49 +08:00
Alfranio Correia
d0435b5267 merge mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2010-10-10 20:13:25 +01:00
a667ce8e27 Manual merge 2010-10-09 18:18:16 +08:00
b66825912a Bug#55375 Transaction bigger than max_binlog_cache_size crashes slave
When slave executes a transaction bigger than slave's max_binlog_cache_size,
slave will crash. It is caused by the assert that server should only roll back
the statement but not the whole transaction if the error ER_TRANS_CACHE_FULL 
happens. But slave sql thread always rollbacks the whole transaction when
an error happens.
            
Ather this patch, we always clear any error set in sql thread(it is different
from the error in 'SHOW SLAVE STATUS') and it is cleared before rolling back
the transaction.
2010-10-09 15:05:43 +08:00
Dmitry Lenev
d471e7ca70 Merged recent changes from mysql-5.5-bugteam into
mysql-5.5-runtime tree.
2010-10-08 20:33:46 +04:00
Davi Arnaut
31e1b12eb0 Bug#45288: pb2 returns a lot of compilation warnings on linux
Fix assorted compiler warnings.
2010-10-08 11:52:39 -03:00
Alexander Barkov
c57244fb17 The fix for
Bug#55744 GROUP_CONCAT + CASE + ucs return garbage
revealed problems in how character set aggregation
code works with prepared statements.

This patch fixes (hopefully) the problems.
2010-10-08 18:06:31 +04:00
Mats Kindahl
16182cd791 Merging with mysql-5.5-bugteam. 2010-10-08 14:46:18 +02:00
Mats Kindahl
fa4a4b7a64 WL#5363: Thread Pool Service Interface
Adding a comment to scheduler_types on
the default values used.
2010-10-08 14:44:57 +02:00
Mats Kindahl
5d014b8319 Bug #57338: Extreneous server variable thread_pool_size
The server contained code for the server variable and
option thread_pool_size, but this server variable where
not used anywhere.

The variable is probably remains from backporting too
much from 6.0 (specifically, the thread pool
implementation was not backported from 6.0, which this
variable is associated with).

This patch eliminates the variable from the server.
2010-10-08 14:22:22 +02:00
Davi Arnaut
657b157511 Bug#56822: Add a thread state for sessions waiting on the query cache lock
Only wait for a single debug signal at a time as the signal state
is global. Also, do not activate the query cache debug sync points
if the thread has no associated THD session.
2010-10-08 09:16:20 -03:00
Tor Didriksen
921fd52975 Bug#57209 valgrind + Assertion failed: dst > buf
Buffer overrun when trying to format DBL_MAX
2010-10-08 11:52:09 +02:00
Alexey Botchkov
a398378776 Bug#30025 Mysqld prints out warnings/errors being run with --no-defaults --help
now do no initializations for the --help.
        Do it for --verbose --help though.

per-file comments:
  sql/mysqld.cc
Bug#30025 Mysqld prints out warnings/errors being run with --no-defaults --help
        quit with the help message at once as --help was given
2010-10-08 12:12:18 +05:00
Davi Arnaut
96c99602d4 Bug#45288: pb2 returns a lot of compilation warnings on linux
Fix warnings related to the use of the deprecated gets() function
and passing NULL to non-pointer argument of the sys_var constructor.
2010-10-07 21:53:00 -03:00
Davi Arnaut
ea4c11f923 Bug#56822: Add a thread state for sessions waiting on the query cache lock
Move Query_cache_wait_state declaration out of a debug block.
2010-10-07 21:05:23 -03:00
Luis Soares
e514a7a644 BUG#54144: manual merged bzr bundle from bug report. 2010-10-08 00:34:59 +01:00
Davi Arnaut
76643a469a Bug#56822: Add a thread state for sessions waiting on the query cache lock
The problem was that threads waiting on the query cache lock
are not easily seen due to the lack of a state indicating that
the thread is waiting on the said lock. This made it difficult
for users to quickly spot (for example, via SHOW PROCESSLIST)
a query cache contention problem.

The solution is to update the thread state when the query cache
lock needs to be acquired. Whenever the lock is to be acquired,
the thread state is updated to "Waiting for query cache lock"
and is reset once the lock is granted or the wait is interrupted.
The intention is to make query cache related hangs more evident.

To further investigate query cache related locking problems, one
may use PERFORMANCE_SCHEMA to track the overhead associated with
the locking bits and determine which particular lock is being a
contention point.
2010-10-07 19:51:37 -03:00
Evgeny Potemkin
8fceaa387d Auto-merged. 2010-10-07 20:39:24 +04:00
Evgeny Potemkin
2fd0bc63bb Bug#57095: Wrongly chosen expression cache type led to a wrong result.
The coalesce function returned DATETIME type due to a DATETIME argument, but
since it's not a date/time function it can't return correct int value for
it. Nevertheless Item_datetime_cache was chosen to cache coalesce's result
and that led to a wrong result.

Now Item_datetime_cache is used only for those function that could return
correct int representation of DATETIME values.
2010-10-07 20:16:30 +04:00
Dmitry Lenev
51ff281efe Fix for bug#57061 "User without privilege on routine can
discover its existence".

The problem was that user without any privileges on 
routine was able to find out whether it existed or not.
DROP FUNCTION and DROP PROCEDURE statements were 
checking if routine being dropped existed and reported 
ER_SP_DOES_NOT_EXIST error/warning before checking 
if user had enough privileges to drop it.

This patch solves this problem by changing code not to 
check if routine exists before checking if user has enough 
privileges to drop it. Moreover we no longer perform this 
check using a separate call instead we rely on 
sp_drop_routine() returning SP_KEY_NOT_FOUND if routine 
doesn't exist.

This change also simplifies one of upcoming patches
refactoring global read lock implementation.
2010-10-07 20:01:17 +04:00
Sergey Vojtovich
818e848dcf Merge WL#5496 and WL#5341 to 5.5-bugteam. 2010-10-07 19:52:34 +04:00
Luis Soares
cc15d2462c BUG#54144: ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE is hard coded
The error message for ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE was
hard coded. Additionally, the same error was used in three
separate error symptoms: 1. when heartbeat period exceeds the
value of slave_net_timeout, 2. when it is smaller than 1
milisecond and 3. when it was not in range, ie, either negative
or greater than the maximum allowed.
      
We fix this by splitting into three distinct errors and by
removing the message from the source code and moving it to the
errmsg-utf8.txt file.
2010-10-07 16:38:23 +01:00
Jon Olav Hauglid
ee1ea44569 Merge from mysql-5.5-runtime to mysql-5.5-bugteam
No conflicts
2010-10-07 14:12:33 +02:00
Dmitry Shulga
eec581e07f Fixed bug#45445 - cannot execute procedures with thread_stack
set to 128k.
2010-10-07 18:57:12 +07:00
Martin Hansson
d6ee2ecf90 Bug#56423: Different count with SELECT and CREATE SELECT queries
This is the 5.5 version of the fix. The 5.1 version was too complicated to
merge and was null merged.

This is a regression from the fix for bug no 38999. A storage engine capable
of reading only a subset of a table's columns updates corresponding bits in
the read buffer to signal that it has read NULL values for the corresponding
columns. It cannot, and should not, update any other bits. Bug no 38999
occurred because the implementation of UPDATE statements compare the NULL bits
using memcmp, inadvertently comparing bits that were never requested from the
storage engine. The regression was caused by the storage engine trying to
alleviate the situation by writing to all NULL bits, even those that it had no
knowledge of. This has devastating effects for the index merge algorithm,
which relies on all NULL bits, except those explicitly requested, being left
unchanged.

The fix reverts the fix for bug no 38999 in both InnoDB and InnoDB plugin and
changes the server's method of comparing records. For engines that always read
entire rows, we proceed as usual. For engines capable of reading only select
columns, the record buffers are now compared on a column by column basis. An
assertion was also added so that non comparable buffers are never read. Some
relevant copy-pasted code was also consolidated in a new function.
2010-10-07 12:01:51 +02:00
Evgeny Potemkin
28af216cb5 Auto-merged. 2010-10-07 12:17:08 +04:00
Martin Hansson
9c82ecec37 Bug#56423: Different count with SELECT and CREATE SELECT queries
This is a regression from the fix for bug no 38999. A storage engine capable
of reading only a subset of a table's columns updates corresponding bits in
the read buffer to signal that it has read NULL values for the corresponding
columns. It cannot, and should not, update any other bits. Bug no 38999
occurred because the implementation of UPDATE statements compare the NULL bits
using memcmp, inadvertently comparing bits that were never requested from the
storage engine. The regression was caused by the storage engine trying to
alleviate the situation by writing to all NULL bits, even those that it had no
knowledge of. This has devastating effects for the index merge algorithm,
which relies on all NULL bits, except those explicitly requested, being left
unchanged.

The fix reverts the fix for bug no 38999 in both InnoDB and InnoDB plugin and
changes the server's method of comparing records. For engines that always read
entire rows, we proceed as usual. For engines capable of reading only select
columns, the record buffers are now compared on a column by column basis. An
assertion was also added so that non comparable buffers are never read. Some
relevant copy-pasted code was also consolidated in a new function.
2010-10-07 10:13:11 +02:00
Evgeny Potemkin
4bfec5733d Bug#57039: constant subtime expression returns incorrect result.
The subtime function wasn't able to produce correct int representation of
its result. For constant expressions the Item_datetime_cache is used to
speedup evaluation and Item_datetime_cache expects underlying item to return
correct int representation of DATETIME value. These two factors combined led
to a wrong query result.

Now the Item_func_add_time has function val_datetime which performs the
calculation and saves result into given MYSQL_TIME struct, it also sets
null_value to appropriate value. val_int and val_str member functions
convert the result obtained from val_datetime to int or string respectively
and returns it.
2010-10-07 11:07:56 +04:00
Mats Kindahl
9d249079a8 Bug #52131: SET and ENUM stored endian-dependent in binary log
Replication SET and ENUM fields from a big-endian to a little-
endian machine (or the opposite) that are represented using
more than 1 byte (SET fields with more than 8 members or ENUM
fields with more than 256 constants) will fail to replicate
correctly when using row-based replication.

The reason is that there are no pack() or unpack() functions
for Field_set or Field_enum, which make them rely on Field::pack
and Field::unpack. These functions pack data as strings, but
since Field_set and Field_enum use integral types for
representation, the fields are stored incorrectly on big-endian
machines.

This patch adds Field_enum::pack and Field_enum::unpack
functions that store the integral value correctly in the binary
log even on big-endian machines. Since Field_set inherits from
Field_enum, it will use the same functions for packing and
unpacking the field.
2010-10-06 19:20:18 +02:00
Alexander Nozdrin
f79f6e0c34 Fix for Bug#57094 (Copyright notice incorrect?).
The fix is to:
  - introduce ORACLE_WELCOME_COPYRIGHT_NOTICE define to have a single place
    to specify copyright notice;
  - replace custom copyright notices with ORACLE_WELCOME_COPYRIGHT_NOTICE
    in programs.
2010-10-06 19:06:13 +04:00
Davi Arnaut
5f911fa874 Bug#49938: Failing assertion: inode or deadlock in fsp/fsp0fsp.c
Bug#54678: InnoDB, TRUNCATE, ALTER, I_S SELECT, crash or deadlock

- Incompatible change: truncate no longer resorts to a row by
row delete if the storage engine does not support the truncate
method. Consequently, the count of affected rows does not, in
any case, reflect the actual number of rows.

- Incompatible change: it is no longer possible to truncate a
table that participates as a parent in a foreign key constraint,
unless it is a self-referencing constraint (both parent and child
are in the same table). To work around this incompatible change
and still be able to truncate such tables, disable foreign checks
with SET foreign_key_checks=0 before truncate. Alternatively, if
foreign key checks are necessary, please use a DELETE statement
without a WHERE condition.

Problem description:

The problem was that for storage engines that do not support
truncate table via a external drop and recreate, such as InnoDB
which implements truncate via a internal drop and recreate, the
delete_all_rows method could be invoked with a shared metadata
lock, causing problems if the engine needed exclusive access
to some internal metadata. This problem originated with the
fact that there is no truncate specific handler method, which
ended up leading to a abuse of the delete_all_rows method that
is primarily used for delete operations without a condition.

Solution:

The solution is to introduce a truncate handler method that is
invoked when the engine does not support truncation via a table
drop and recreate. This method is invoked under a exclusive
metadata lock, so that there is only a single instance of the
table when the method is invoked.

Also, the method is not invoked and a error is thrown if
the table is a parent in a non-self-referencing foreign key
relationship. This was necessary to avoid inconsistency as
some integrity checks are bypassed. This is inline with the
fact that truncate is primarily a DDL operation that was
designed to quickly remove all data from a table.
2010-10-06 11:34:28 -03:00
Alexander Barkov
ab15833ac2 Bug#55744 GROUP_CONCAT + CASE + ucs return garbage
Problem: CASE didn't work with a mixture of different character
sets in THEN/ELSE in some cases.
This happened because after character set aggregation
newly created Item_func_conv_charset items corresponding
to THEN/ELSE arguments were not put back to args[] array.

Fix:
put all Item_func_conv_charset back to args[].


  @ mysql-test/include/ctype_numconv.inc
  @ mysql-test/r/ctype_ucs.result
  Adding tests

  @ sql/item_cmpfunc.cc
  Put "agg" back to args[] after character set aggregation.
2010-10-06 16:15:59 +04:00
Luis Soares
5109d5401e BUG#38718: slave sql thread crashes when reading relay log
Suprisingly, a Slave_log_event would show up in the binary
log. This event is never used and should not appear in the
logs. As such, when the slave (or the mysqlbinlog tool) reads the
event, it will hit an invalid pointer (reference to the
descriptor event when deserializing the Slave_log_event was
purposodely set to NULL).
      
The presence of the Slave_log_event denotes a corrupted log, but
we cannot tell how the log got corrupted in the first
place. However, we can make the server cope with such events when
it reads them - in case of log corruption - and fail gracefully.
     
This patch makes the server/mysqlbinlog to report that it has
found an invalid log event when Slave_log_event is read.
2010-10-06 12:23:46 +01:00
Alfranio Correia
361833796f BUG#57098 RBR breaks on changing user password on 5.1 master -> 5.5 slave
Backported the patch for BUG#55452.
2010-10-06 11:19:51 +01:00
Georgi Kodinov
fd7cbdc48d merge 2010-10-06 13:02:11 +03:00
Jon Olav Hauglid
38194bf7a5 Merge from mysql-5.5-bugteam to mysql-5.5-runtime. 2010-10-06 11:29:44 +02:00
Georgi Kodinov
86d35d20c1 merge 5.5-bugteam -> 5.5-security 2010-10-06 12:17:22 +03:00
Magne Mahre
623ed19462 Bug#56452 Assertion failed: thd->transaction.stmt.is_empty() ||
thd->in_sub_stmt
      
In a precursor patch for Bug#52044 
(revid:bzr/kostja@stripped), a
number of reorganizations of code was made. In addition some
assertions were added to ensure the correct transactional state.
      
The reorganization had a small glitch so statements that was
active in the query cache was not followed by a
statement commit/rollback (this code was removed). A section
in the trans_commit_stmt/trans_rollback_stmt code is to
clear the thd->transaction.stmt list of affected storage
engines.  When a new statement is initiated, an assert
introduced by the 523044 patch checks if this list is cleared.
When the query cache is accessed, this list may be populated,
and since it's not committed it will not be cleared.
      
This fix adds explicit statement commit or rollback for
statements that is contained in the query cache.
2010-10-06 11:01:24 +02:00
Georgi Kodinov
5a9b624aab merge of 5.1-bugteam into 5.1-security 2010-10-06 11:58:31 +03:00
Alfranio Correia
0be27d8f1c BUG#56343 binlog_cache_use status is bigger than expected
The binlog_cache_use is incremented twice when changes to a transactional table
are committed, i.e. TC_LOG_BINLOG::log_xid calls is called. The problem happens
because log_xid calls both binlog_flush_stmt_cache and binlog_flush_trx_cache
without checking if such caches are empty thus unintentionally increasing the
binlog_cache_use value twice.

To fix the problem we avoided incrementing the binlog_cache_use if the cache is
empty. We also decided to increment binlog_cache_use when the cache is truncated
as the cache is used although its content is discarded and is not written to the
binary log.

Note that binlog_cache_use is incremented for both types of cache, transactional
and non-transactional and that the behavior presented in this patch also applies
to the binlog_cache_disk_use.

Finally, we re-organized the code around the functions binlog_flush_trx_cache and
binlog_flush_stmt_cache.
2010-10-06 09:34:49 +01:00
Georgi Kodinov
2a7ea14f5f WL#1054: fixed a compilation warning 2010-10-05 17:22:30 +03:00
Mattias Jonsson
f3e2b3df18 Bug#55091: Server crashes on ADD PARTITION after a failed attempt
In case of failure in ALTER ... PARTITION under LOCK TABLE
the server could crash, due to it had modified the locked
table object, which was not reverted in case of failure,
resulting in a bad table definition used after the failed
command.

Solved by always closing the LOCKED TABLE, even in case
of error.

Note: this is a 5.1-only fix, bug#56172 fixed it in 5.5+
2010-10-05 14:57:51 +02:00
Georgi Kodinov
539291cde9 merged mysql-5.1 into mysql-5.1-bugteam 2010-10-05 11:11:56 +03:00
Jon Olav Hauglid
72cc5173b2 Merge from mysql-5.5-bugteam to mysql-5.5-runtime. 2010-10-04 16:19:11 +02:00
Georgi Kodinov
dd2e3db48f merge 2010-10-04 15:42:16 +03:00
Davi Arnaut
774a5778d5 Bug#57210: remove pstack
Quoting from the bug report:

The pstack library has been included in MySQL since version
4.0.0. It's useless and should be removed.

Details: According to its own documentation, pstack only works
on Linux on x86 in 32 bit mode and requires LinuxThreads and a
statically linked binary. It doesn't really support any Linux
from 2003 or later and doesn't work on any other OS.
2010-10-04 08:52:59 -03:00
Jon Olav Hauglid
c4a18b6af3 Bug #51099 Assertion in mysql_multi_delete_prepare()
This assert was triggered if DELETE was done on a view that
referenced another view which in turn (directly or indirectly)
referenced more than one table.

Delete from a view referencing more than one table (a join view)
is not supported and is supposed to give ER_VIEW_DELETE_MERGE_VIEW
error. Before this error was reported from the multi table 
delete code, an assert verified that the view from the DELETE statement
had more than one underlying table. However, this assert did not take
into account that the view could refer to another view which in turn
referenced the actual tables.

This patch fixes the problem by adjusting the assert to take this
possibility into account. This problem was only noticeable on debug
builds of the server. On release builds, ER_VIEW_DELETE_MERGE_VIEW
was correctly reported.

Test case added to delete.test.
2010-10-04 10:25:04 +02:00
Alexander Nozdrin
228b127d2e Auto-merge from mysql-5.5-bugteam. 2010-10-02 22:21:41 +04:00
Alexey Kopytov
49e715258f Manual merge from mysql-5.1-bugteam into mysql-5.5-bugteam.
conflicts:
   conflict      dbug/dbug.c
   conflict      sql/sql_load.cc
2010-10-02 00:12:27 +04:00
Alexey Kopytov
e1e838169a Automerge. 2010-10-01 23:56:55 +04:00
Mattias Jonsson
a37418bc45 merge 2010-10-01 16:06:10 +02:00
Mattias Jonsson
199fb36567 Manual merge into mysql-5.5-bugteam 2010-10-01 15:59:07 +02:00
Mattias Jonsson
cddd0d685f merge 2010-10-01 15:41:27 +02:00
Mattias Jonsson
141d83127d merge 2010-10-01 15:32:03 +02:00
Mattias Jonsson
7ecc107757 removed a comment according to the review 2010-10-01 15:30:16 +02:00
Mattias Jonsson
0ac0817348 Manual merge of bug#51851 from mysql-5.1-bugteam into mysql-5.5-bugteam 2010-10-01 14:16:00 +02:00
Mattias Jonsson
460fcf7c5e merge 2010-10-01 13:39:49 +02:00
Mattias Jonsson
a01773dbee Bug#51851: Server with SBR locks mutex twice on
LOAD DATA into partitioned MyISAM table

Problem was that both partitioning and myisam
used the same table_share->mutex for different protections
(auto inc and repair).

Solved by adding a specific mutex for the partitioning
auto_increment.

Also adding destroying the ha_data structure in
free_table_share (which is to be propagated
into 5.5).

This is a 5.1 ONLY patch, already fixed in 5.5+.
2010-10-01 13:39:04 +02:00
Mattias Jonsson
2a67a3a7f5 Bug#56172: Server crashes in ha_partition::reset on
REBUILD PARTITION under LOCK TABLE

Collapsed patch including updates from the reviews.

In case of failure in ALTER ... PARTITION under LOCK TABLE
the server could crash, due to it had modified the locked
table object, which was not reverted in case of failure,
resulting in a bad table definition used after the failed
command.

Solved by instead of altering the locked table object and
its partition_info struct, creating an internal temporary
intermediate table object used for altering,
just like the non partitioned mysql_alter_table.
So if an error occur before the alter operation is complete,
the original table is not modified at all.
But if the alter operation have succeeded so far that it
must be completed as whole,
the table is properly closed and reopened.
(The completion on failure is done by the ddl_log.)
2010-10-01 13:22:11 +02:00
Sergey Glukhov
86ef233232 Bug#54488 crash when using explain and prepared statements with subqueries
The crash happens because original join table is replaced with temporary table
at execution stage and later we attempt to use this temporary table in
select_describe. It might happen that
Item_subselect::update_used_tables() method which sets const_item flag
is not called by some reasons (no where/having conditon in subquery for example).
It prevents JOIN::join_tmp creation and breaks original join.
The fix is to call ::update_used_tables() before ::const_item() check.
2010-10-01 14:08:38 +04:00
Jon Olav Hauglid
fbfbc7ee9b Merge from mysql-5.5-runtime to mysql-5.5-bugteam. 2010-10-01 11:23:43 +02:00
Mattias Jonsson
d7bfd59a5a Bug#55458: Partitioned MyISAM table gets crashed by multi-table update
Bug#57113: ha_partition::extra(ha_extra_function):
            Assertion `m_extra_cache' failed

Fix for bug#55458 included DBUG_ASSERTS causing
debug builds of the server to crash on
another multi-table update.

Removed the asserts since they where wrong.
(updated after testing the patch in 5.5).
2010-09-30 15:57:33 +02:00
Dmitry Lenev
8322cad015 Reverted a temporary workaround for bug #56405 "Deadlock
in the MDL deadlock detector".

It is no longer needed as a better fix for this bug has
been pushed.
2010-09-30 17:29:12 +04:00
Georgi Kodinov
b2437d07e6 merge 2010-09-30 14:06:50 +03:00
Jon Olav Hauglid
a53f61e6e8 Merge from mysql-5.5-bugteam to mysql-5.5-runtime 2010-09-30 12:43:43 +02:00
Georgi Kodinov
216418e7b2 merge 2010-09-29 17:26:32 +03:00
Georgi Kodinov
9d8098e0c6 merge 2010-09-29 14:48:57 +03:00
Alexander Nozdrin
a79093cd94 Auto-merge from mysql-5.5-merge. 2010-09-28 19:15:58 +04:00
Sergey Vojtovich
19463ba418 WL#5496 - Plugin LOAD_OPTION in INFORMATION_SCHEMA.PLUGINS
This patch implements I_S.PLUGINS.LOAD_OPTION column
as specified by WL#5496.
2010-09-27 17:03:27 +04:00
Sergey Vojtovich
42d46376af WL#5341 - Sticky plugins
This patch implements "permanent" load option for
plugins as specified by WL#5341.
2010-09-27 16:55:09 +04:00
Dmitry Lenev
afa568c24b Fix compile warning about passing NULL to non-pointer
argument of inline_mysql_mutex_init in sql_base.cc.

When initializing LOCK_dd_owns_lock_open mutex pass
correct PSI key instead of NULL value.
2010-09-24 20:26:24 +04:00
Konstantin Osipov
5b06699029 Merge 5.5 -> 5.5-merge. 2010-09-24 17:18:45 +04:00
Dmitry Shulga
e1b299ed02 Merged changes from 5.1-bugteam for bug#42503. 2010-09-24 19:12:09 +07:00
Dmitry Shulga
f14d8c2896 Follow-up for Bug#42503: fix a compilation warning. 2010-09-24 19:03:28 +07:00
Luis Soares
f17cc60413 BUG#55263: assert in check_binlog_magic
The procedure for setting up a fake binary log, by changing the
relay log files manually, is run twice when we issue mtr with
--repeat=2. However, when setting it up for the second time,
neither the sql thread is reset nor the server is restarted. This
means that previous stale relay log IO_CACHE metadata - from 
first run - is left around. As a consequence, when the test is 
run for the second time, the IO_CACHE for the relay log has 
position in file different than zero, triggering the assertion.
            
We fix this by deploying a call to my_b_seek before calling
check_binlog_magic in next_event. This prevents the server 
from asserting, in the cases that the SQL thread was reads
from a hot log (relay.NNNNN), then is stopped, then is restarted 
from a previous cold log (relay.MMMMM), and then it reaches 
the hot log relay.NNNNN again, in which case, the read 
coordinates are not set to zero, but to the old values.

Additionally, some comments to the source code were added.
2010-09-24 10:44:53 +01:00
Jon Olav Hauglid
71affc142d Bug #56678 Valgrind warnings from binlog.binlog_unsafe
After the patch for Bug#54579, multi inserts done with INSERT DELAYED
are binlogged as normal INSERT. During processing of the statement,
a new query string without the DELAYED keyword is made. The problem
was that this new string was incorrectly made when the INSERT DELAYED
was part of a prepared statement - data was read outside the allocated
buffer.

The reason for this bug was that a pointer to the position of the
DELAYED keyword inside the query string was stored when parsing the
statement. This pointer was then later (at runtime) used (via pointer
subtraction) to find the number of characters to skip when making a
new query string without DELAYED. But when the statement was re-executed
as part of a prepared statement, the original pointer would be invalid
and the pointer subtraction would give a wrong/random result.

This patch fixes the problem by instead storing the offsets from the
beginning of the query string to the start and end of the DELAYED 
keyword. These values will not depend on the memory position
of the query string at runtime and therefore not give wrong results
when the statement is executed in a prepared statement.

This bug was a regression introduced by the patch for Bug#54579.

No test case added as this bug is already covered by the existing
binlog.binlog_unsafe test case when running with valgrind.
2010-09-24 10:44:09 +02:00
Jon Olav Hauglid
11c4d8ba1f Bug #54920 Stored functions are allowed in HANDLER statements,
but broken.

Before this patch, it was allowed to use stored functions in
HANDLER ... READ statements. The problem was that this functionality
was not really supported by the code. Proper locking would for example
not be performed, and it was also possible to break replication by
having stored functions that performed updates.

This patch disallows the use of stored functions in HANDLER ... READ.
Any such statement will now give an ER_NOT_SUPPORTED_YET error.
This is an incompatible change and should be reflected in the
documentation.

Test case added to handler_myisam/handler_innodb.test.
2010-09-24 09:18:16 +02:00
Jon Olav Hauglid
4ecf1d32ac Merge from mysql-5.5-bugfixing to mysql-5.5-runtime. 2010-09-24 08:46:43 +02:00
Mats Kindahl
246b7b0b7d Merging into mysql-5.5-bugfixing. 2010-09-23 14:38:24 +02:00
Sergey Glukhov
5539072560 Bug#54494 crash with explain extended and prepared statements
In case of outer join and emtpy WHERE conditon
'always true' condition is created for WHERE clasue.
Later in mysql_select() original SELECT_LEX WHERE
condition is overwritten with created cond.
However SELECT_LEX condition is also used as inital
condition in mysql_select()->JOIN::prepare().
On second execution of PS modified SELECT_LEX condition
is taken and it leads to crash.
The fix is to restore original SELECT_LEX condition
(set to NULL if original cond is NULL) in
 reinit_stmt_before_use().
HAVING clause is fixed too for safety reason
(no test case as I did not manage to think out
 appropriate example).
2010-09-23 10:43:51 +04:00
Alexey Kopytov
a1f1e77c38 Bug #56709: Memory leaks at running the 5.1 test suite
Fixed a number of memory leaks discovered by valgrind.
2010-09-22 23:33:18 +04:00
Dmitry Shulga
7cc604561c Auto-merge from mysql-5.1-bugteam for bug#56821. 2010-09-22 20:11:40 +07:00
Dmitry Shulga
c7ccc7265e Fixed bug#56821 - failure to start the MySQL Service. 2010-09-22 19:53:06 +07:00
Jon Olav Hauglid
5d06dddff3 Bug #56494 Segfault in upgrade_shared_lock_to_exclusive() for
REPAIR of merge table
Bug #56422 CHECK TABLE run when the table is locked reports
           corruption along with timeout

The crash happened if a table maintenance statement (ANALYZE TABLE,
REPAIR TABLE, etc.) was executed on a MERGE table and opening and 
locking a child table failed. This could for example happen if a child
table did not exist or if a lock timeout happened while waiting for
a conflicting metadata lock to disappear.

Since opening and locking the MERGE table and its children failed,
the tables would be closed and the metadata locks released.
However, TABLE_LIST::table for the MERGE table would still be set,
with its value invalid since the tables had been closed.
This caused the table maintenance statement to try to continue
and upgrade the metadata lock on the MERGE table. But since the lock
already had been released, this caused a segfault.

This patch fixes the problem by setting TABLE_LIST::table to NULL 
if open_and_lock_tables() fails. This prevents maintenance
statements from continuing and trying to upgrade the metadata lock.

The patch includes a 5.5 version of the fix for
Bug #46339 crash on REPAIR TABLE merge table USE_FRM.
This bug caused REPAIR TABLE ... USE_FRM to give an assert 
when used on merge tables.

The patch also enables the CHECK TABLE statement for log tables.
Before, CHECK TABLE for log tables gave ER_CANT_LOCK_LOG_TABLE,
yet still counted the statement as successfully executed.
With the changes to table maintenance statement error handling
in this patch, CHECK TABLE would no longer be considered as
successful in this case. This would have caused upgrade scripts
to mistakenly think that the general and slow logs are corrupted
and have to be repaired. Enabling CHECK TABLES for log tables
prevents this from happening.

Finally, the patch changes the error message from "Corrupt" to
"Operation failed" for a number of issues not related to table
corruption. For example "Lock wait timeout exceeded" and 
"Deadlock found trying to get lock".

Test cases added to merge.test and check.test.
2010-09-22 10:15:41 +02:00
Mats Kindahl
48ac52a861 Merging into mysql-5.5-bugfixing. 2010-09-21 23:24:29 +02:00
Ingo Struewing
386d50478c Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
Merge from saved bundle.
2010-09-21 16:37:18 +02:00
Georgi Kodinov
99039957fe WL#1054: code style remarks fixed. 2010-09-20 19:38:27 +03:00
Georgi Kodinov
dc0b8f7ada merge of mysql-5.5 into mysql-5.5-wl1054 2010-09-20 17:17:32 +03:00
Georgi Kodinov
702d559fd5 Bug #56798 : Wrong credentials assigned when using a proxy user.
Fixed incorrect handling of user credentials when authenticating
via proxy user. Now the server will use the proxies user's 
access mask and host to update the security context runtime 
structure when logging in.

Fixed a compilation warning with the embedded library.

Fixed a crash when doing a second GRANT PROXY on ''@'' due to 
incomplete equality check logic.
2010-09-20 16:51:42 +03:00
Alfranio Correia
c316b68146 merge mysql-5.1-bugteam --> mysql-5.5-merge 2010-09-17 21:22:34 +01:00
Alfranio Correia
6baf9d5a61 merge mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2010-09-17 14:55:23 +01:00
Alfranio Correia
77dcf9bec7 merge mysql-5.5-bugfixing (local) --> mysql-5.5-bugfixing 2010-09-17 12:58:27 +01:00
Jon Olav Hauglid
1818165cdb Merge from mysql-5.5-bugfixing to mysql-5.5-runtime. 2010-09-16 16:16:29 +02:00
Sergey Glukhov
dcad3feb1c 5.1-bugteam->5.5-merge 2010-09-16 16:20:35 +04:00
Sergey Glukhov
86d7cbd450 Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB
Subselect executes twice, at JOIN::optimize stage
and at JOIN::execute stage. At optimize stage
Innodb prebuilt struct which is used for the
retrieval of column values is initialized in.
ha_innobase::index_read(), prebuilt->sql_stat_start is true.
After QUICK_ROR_INTERSECT_SELECT finished his job it
restores read_set/write_set bitmaps with initial values
and deactivates one of the handlers used by
QUICK_ROR_INTERSECT_SELECT in JOIN::cleanup
(it's the case when we reuse original handler as one of
 handlers required by QUICK_ROR_INTERSECT_SELECT object).
On second subselect execution inactive handler is activated
in  QUICK_RANGE_SELECT::reset, file->ha_index_init().
In ha_index_init Innodb prebuilt struct is reinitialized
with inappropriate read_set/write_set bitmaps. Further
reinitialization in ha_innobase::index_read() does not
happen as prebuilt->sql_stat_start is false.
It leads to partial retrieval of required field values
and we get a mix of field values from different records
in the record buffer.
The fix is to reset
read_set/write_set bitmaps as these values
are required for proper intialization of
internal InnoDB struct which is used for
the retrieval of column values
(see build_template(), ha_innodb.cc)
2010-09-16 16:13:53 +04:00
Magne Mahre
327eb7b680 Merge from 5.1-bugteam 2010-09-16 13:00:53 +02:00
Magne Mahre
f43d6c2b73 Bug #54606 innodb fast alter table + pack_keys=0 prevents
adding new indexes

A fast alter table requires that the existing (old) table
and indices are unchanged (i.e only new indices can be
added).  To verify this, the layout and flags of the old
table/indices are compared for equality with the new.

The PACK_KEYS option is a no-op in InnoDB, but the flag
exists, and is used in the table compare.  We need to
check this (table) option flag before deciding whether an 
index should be packed or not.  If the table has
explicitly set PACK_KEYS to 0, the created indices should
not be marked as packed/packable.
2010-09-16 12:51:08 +02:00
Dmitry Shulga
a684f8df20 Auto-merge from mysql-5.1-bugteam for bug#42503. 2010-09-16 17:38:13 +07:00
Dmitry Shulga
be794bc5eb Fixed bug#42503 - "Lost connection" errors when using
compression protocol.

The loss of connection was caused by a malformed packet
sent by the server in case when query cache was in use.
When storing data in the query cache, the query  cache
memory allocation algorithm had a tendency to reduce
the amount of memory block necessary to store a result
set, up to finally storing the entire result set in a single
block. With a significant result set, this memory block
could turn out to be quite large - 30, 40 MB and on.
When such a result set was sent to the client, the entire
memory block was compressed and written to network as a
single network packet. However, the length of the
network packet is limited by 0xFFFFFF (16MB), since
the packet format only allows 3 bytes for packet length.
As a result, a malformed, overly large packet
with truncated length would be sent to the client
and break the client/server protocol.

The solution is, when sending result sets from the query
cache, to ensure that the data is chopped into
network packets of size <= 16MB, so that there
is no corruption of packet length. This solution,
however, has a shortcoming: since the result set
is still stored in the query cache as a single block,
at the time of sending, we've lost boundaries of individual
logical packets (one logical packet = one row of the result
set) and thus can end up sending a truncated logical
packet in a compressed network packet.

As a result, on the client we may require more memory than 
max_allowed_packet to keep, both, the truncated
last logical packet, and the compressed next packet.
This never (or in practice never) happens without compression,
since without compression it's very unlikely that
a) a truncated logical packet would remain on the client
when it's time to read the next packet
b) a subsequent logical packet that is being read would be
so large that size-of-new-packet + size-of-old-packet-tail >
max_allowed_packet.
To remedy this issue, we send data in 1MB sized packets,
that's below the current client default of 16MB for
max_allowed_packet, but large enough to ensure there is no
unnecessary overhead from too many syscalls per result set.
2010-09-16 17:24:27 +07:00
Jon Olav Hauglid
f14d947c98 Bug #56595 RENAME TABLE causes assert on OS X
The problem was that RENAME TABLE caused an assert if the system variable
lower_case_table_names was 2 (default on Mac OS X) and the old table name
was given in upper case. This caused lowercase_table2.test to fail.

The assert checks that an exclusive metadata lock is held by the connection
trying to do RENAME TABLE - specificially during updates of table triggers.
The assert was triggered since the check is case sensitive and the lock
was held on the normalized (lower case) version of the table name.

This patch fixes the problem by making sure a normalized version of the
table name is used for the metadata lock check, while using a non-normalized
version of the table name for the rename of trigger files. The same is done
for ALTER TABLE ... RENAME.

Regression testing for the bug itself is already covered by
lowercase_table2.test. Additional coverage added to lowercase_fs_off.test.
2010-09-16 11:11:13 +02:00
Mattias Jonsson
1387f38969 Bug#56287: mysql5.1.50 crash when using Partition datetime in sub in query
When having a sub query in partitioned innodb one could
make the partitioning engine to search for a 'index_next_same'
on a partition that had not been initialized.

Problem was that the subselect function looks at table->status
which was not set in the partitioning handler when it skipped
scanning due to no matching partitions found.

Fixed by setting table->status = STATUS_NOT_FOUND when
there was no partitions to scan. (If there are partitions to
scan, it will be set in the partitions handler.)
2010-09-16 11:01:06 +02:00
Dmitry Lenev
6d5065a9f4 Fix for bug #56251 "Deadlock with INSERT DELAYED and MERGE
tables".

Attempting to issue an INSERT DELAYED statement for a MERGE
table might have caused a deadlock if it happened as part of
a transaction or under LOCK TABLES, and there was a concurrent
DDL or LOCK TABLES ... WRITE statement which tried to lock one
of its underlying tables.

The problem occurred when a delayed insert handler thread tried
to open a MERGE table and discovered that to do this it had also
to open all underlying tables and hence acquire metadata
locks on them. Since metadata locks on the underlying tables were
not pre-acquired by the connection thread executing INSERT DELAYED,
attempts to do so might lead to waiting. In this case the
connection thread had to wait for the delayed insert thread.
If the thread which was preventing the lock on the underlying table
from being acquired had to wait for the connection thread (due to
this or other metadata locks), a deadlock occurred. 
This deadlock was not detected by the MDL deadlock detector since 
waiting for the handler thread by the connection thread is not
represented in the wait-for graph.

This patch solves the problem by ensuring that the delayed
insert handler thread never tries to open underlying tables 
of a MERGE table. Instead open_tables() is aborted right after
the parent table is opened and a ER_DELAYED_NOT_SUPPORTED 
error is emitted (which is passed to the connection thread and
ultimately to the user).
2010-09-15 18:15:31 +04:00
Marc Alff
3e70a34f30 Local merge 2010-09-14 15:40:50 -06:00
Mattias Jonsson
061769d7b6 merge 2010-09-13 16:07:50 +02:00
Mattias Jonsson
640454b373 merge 2010-09-13 15:56:56 +02:00
Mattias Jonsson
99e507e8a4 merge 2010-09-13 15:14:17 +02:00
Martin Hansson
c09489ebb2 Merge of fix for Bug#50394. 2010-09-13 14:46:55 +02:00
Martin Hansson
20bdf7636b Bug #50394: Regression in EXPLAIN with index scan, LIMIT, GROUP BY and
ORDER BY computed col
      
GROUP BY implies ORDER BY in the MySQL dialect of SQL. Therefore, when an
index on the first table in the query is used, and that index satisfies
ordering according to the GROUP BY clause, the query optimizer estimates the
number of tuples that need to be read from this index. If there is a LIMIT
clause, table statistics on tables following this 'sort table' are employed.

There may be a separate ORDER BY clause however, which mandates reading the
whole 'sort table' anyway. But the previous estimate was left untouched.

Fixed by removing the estimate from EXPLAIN output if GROUP BY is used in
conjunction with an ORDER BY clause that mandates using a temporary table.
2010-09-13 13:33:19 +02:00
Jon Olav Hauglid
20b7be9263 Bug #56448 Assertion failed: ! is_set() with second xa end
The problem was that issuing XA END when the XA transaction was
already ended, caused an assertion. This assertion tests that 
the server does not try to send OK to the client if there has
already been an error reported. The bug was only noticeable on
debug versions of the server.

The reason for the problem was that the trans_xa_end() function
reported success if the transaction was at XA_IDLE state at the
end regardless of any errors occured during processing of
trans_xa_end(). So if the transaction state was XA_IDLE already,
reported errors would be ignored.

This patch fixes the problem by having trans_xa_end() take into
consideration any reported errors. The patch also fixes a similar
bug with XA PREPARE.

Test case added to xa.test.
2010-09-13 13:31:22 +02:00
Gleb Shchepa
83c5552b4f manual merge 5.1-bugteam --> 5.5-merge (bug 55779) 2010-09-13 11:30:10 +04:00
Gleb Shchepa
79c1faa05e Bug #55779: select does not work properly in mysql server
Version "5.1.42 SUSE MySQL RPM"

When a query was using a DATE or DATETIME value formatted
using different formatting than "yyyy-mm-dd HH:MM:SS", a
query with a greater-or-equal '>=' condition matched only
greater values in an indexed TIMESTAMP column.

The problem was introduced by the fix for the bug 46362
and partially solved (for DATE and DATETIME columns only)
by the fix for the bug 47925.

The stored_field_cmp_to_item function has been modified
to take into account TIMESTAMP columns like we do for
DATE and DATETIME columns.
2010-09-13 11:18:35 +04:00
Joerg Bruehe
f6bddff896 Automerge (most) changes of the 5.5.6-rc release build to main 5.5.
This is not the final merge!
2010-09-10 20:48:13 +02:00
Mattias Jonsson
a30b3b43d6 merge 2010-09-10 11:52:35 +02:00
Mattias Jonsson
4770f8d415 merge 2010-09-10 11:50:38 +02:00
Jon Olav Hauglid
e01a1bfdb8 Merge from mysql-5.5-bugfixing to mysql-5.5-runtime. 2010-09-10 09:26:00 +02:00
Marc Alff
2779f0aad1 Bug#56324 Race Condition while shutting down MySQL: "PSI_server"
Before this fix, the server could crash during shutdown,
due to race conditions, that occured when killing the server.

In particular, the performance schema instrumentation handle,
PSI_server, and the performance schema itself would be cleaned up
too soon, causing race conditions with a running kill server thread.

The specifics of the race condition found are that:
the main thread executing "PSI_server= NULL" can cause crashes in
other threads still running, which are executing
"if (PSI_server != NULL) PSI_server->xxx()"
as part of the performance schema instrumentation.

While the bug was reported for the kill server thread,
in theory the same crash could happen with the signal thread,
as found by code analysis.

The correct fix would be to only shutdown the performance schema
and set PSI_server to NULL after every other thread is guaranteed
to be completed, including the kill_server_thread.

However, due to the existing mysqld server design, this is not the case.
See in particular bug number 56666.

The work around used to fix this race condition is to simply not
perform the call to shutdown_performance_schema() when the server exits,
and to keep the PSI_server pointer unchanged.

This will cause memory leaks to be reported by tools like valgrind,
but no memory leak actually happen because the process is about to exit().

As a result, the file mysql-test/valgrind.supp has been updated
to filter out these false positive messages.

This code has been tested with running in a loop the following
tests in parallel, which have been known to fail with race conditions
in the past:
- rpl_change_master
- binlog_max_extension
- events_restart
- rpl_heartbeat_basic
and no crash of test failure has been seen with the changed code.
2010-09-09 15:33:35 -06:00
Alexey Kopytov
637c7529de Manual merge of the fix for bug #54190 and the addendum patch
to 5.5 (removed one test case as it is no longer valid).
2010-09-09 19:00:33 +04:00
Alexey Kopytov
f563a012ce Addendum patch for bug #54190.
The patch caused some test failures when merged to 5.5 because,
unlike 5.1, it utilizes Item_cache_row to actually cache row
values. The problem was that Item_cache_row::bring_value()
essentially did nothing. In particular, it did not update its
null_value, so all Item_cache_row objects were always having
their null_values set to TRUE. This went unnoticed previously,
but now when Arg_comparator::compare_row() actually depends on
the row's null_value to evaluate the comparison, the problem
has surfaced.

Fixed by calling the underlying item's bring_value() and
updating null_value in Item_cache_row::bring_value().

Since the problem also exists in 5.1 code (albeit hidden, since
the relevant code is not used anywhere), the addendum patch is
against 5.1.
2010-09-09 18:44:53 +04:00
Dmitry Lenev
3326614df1 Fix for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge
table causes assert failure".

Attempting to use FLUSH TABLE table_list WITH READ LOCK
statement for a MERGE table led to an assertion failure if
one of its children was not present in the list of tables
to be flushed. The problem was not visible in non-debug builds.

The assertion failure was caused by the fact that in such
situations FLUSH TABLES table_list WITH READ LOCK implementation
tried to use (e.g. lock) such child tables without acquiring
metadata lock on them. This happened because when opening tables
we assumed metadata locks on all tables were already acquired
earlier during statement execution and a such assumption was
false for MERGE children.

This patch fixes the problem by ensuring at open_tables() time
that we try to acquire metadata locks on all tables to be opened. 
For normal tables such requests are satisfied instantly since
locks are already acquired for them. For MERGE children metadata
locks are acquired in normal fashion.

Note that FLUSH TABLES merge_table WITH READ LOCK will lock for
read both the MERGE table and its children but will flush only 
the MERGE table. To flush children one has to mention them in table
list explicitly. This is expected behavior and it is consistent with
usage patterns for this statement (e.g. in mysqlhotcopy script).
2010-09-09 18:29:14 +04:00
Alexey Kopytov
df198b5f6a Automerge. 2010-09-09 16:48:06 +04:00
Alexey Kopytov
9066714c81 Bug #54190: Comparison to row subquery produces incorrect
result

Row subqueries producing no rows were not handled as UNKNOWN
values in row comparison expressions.

That was a result of the following two problems:

1. Item_singlerow_subselect did not mark the resulting row
value as NULL/UNKNOWN when no rows were produced.

2. Arg_comparator::compare_row() did not take into account that
a whole argument may be NULL rather than just individual scalar
values.

Before bug#34384 was fixed, the above problems were hidden
because an uninitialized (i.e. without any stored value) cached
object would appear as NULL for scalar values in a row subquery
returning an empty result. After the fix
Arg_comparator::compare_row() would try to evaluate
uninitialized cached objects.

Fixed by removing the aforementioned problems.
2010-09-09 16:46:13 +04:00
Ramil Kalimullin
5eb7154faa Automerge. 2010-09-09 16:43:45 +04:00
Davi Arnaut
3028e7341c Bug#53251: mysql_library_init fails on second execution with embedded library
Add a virtual destructor. Class has virtual functions.
2010-09-09 09:37:09 -03:00
Evgeny Potemkin
89b53f9908 Auto-merged. 2010-09-09 16:02:02 +04:00
Ramil Kalimullin
9080f681b4 Fix for bug#56679: gis.test: valgrind error
Item_func_spatial_collection::fix_length_and_dec()
changed to use argument's print() method to print
the ER_ILLEGAL_VALUE_FOR_TYPE error.
2010-09-09 13:40:17 +04:00
Alexey Botchkov
9c1fffab17 merging. 2010-09-08 13:54:49 +05:00
Kristofer Pettersson
ccc7ae0e17 merge 5.1-security => 5.5-security 2010-09-08 09:36:39 +02:00
Mattias Jonsson
063a34b681 Bug#55458: Partitioned MyISAM table gets crashed by multi-table update
Updated according to reviewers comments.
2010-09-07 17:56:43 +02:00
Kristofer Pettersson
3a643b0a34 Manual resolve of mysql-test/r/gis.result 2010-09-07 13:34:18 +02:00
Martin Hansson
06b70326ce Merge of fix for Bug#51070. 2010-09-07 12:17:12 +02:00
Kristofer Pettersson
5caea4a995 Bug#55531 crash with conversions of geometry types / strings
Convertion from a floating point number to a string caused a
crash.

During rare circumstances a String object could crash when
it was requested to allocate new memory.
A crash could occcur in Field_double::val_str() because of
a pointer referencing memory inside a String object which was
of unknown size.
And finally, the geometric collection should not accept
arguments which are non geometric.
2010-09-07 11:37:46 +02:00
Martin Hansson
babebf9ceb Bug#51070: Query with a NOT IN subquery predicate returns a wrong result set
The EXISTS transformation has additional switches to catch the known corner
cases that appear when transforming an IN predicate into EXISTS. Guarded
conditions are used which are deactivated when a NULL value is seen in the
outer expression's row. When the inner query block supplies NULL values,
however, they are filtered out because no distinction is made between the
guarded conditions; guarded NOT x IS NULL conditions in the HAVING clause that
filter out NULL values cannot be de-activated in isolation from those that
match values or from the outer expression or NULL's.

The above problem is handled by making the guarded conditions remember whether
they have rejected a NULL value or not, and index access methods are taking
this into account as well. 

The bug consisted of 

1) Not resetting the property for every nested loop iteration on the inner
   query's result.

2) Not propagating the NULL result properly from inner query to IN optimizer.

3) A hack that may or may not have been needed at some point. According to a
   comment it was aimed to fix #2 by returning NULL when FALSE was actually
   the result. This caused failures when #2 was properly fixed. The hack is
   now removed.

The fix resolves all three points.
2010-09-07 11:21:09 +02:00
Dmitry Shulga
417092560c Auto-merge from mysql-5.1-bugteam. 2010-09-07 16:00:41 +07:00
Dmitry Shulga
70807d1473 Fixed bug #55421 - Protocol::end_statement(): Assertion `0' on
multi-table UPDATE IGNORE.
The problem was that if there was an active SELECT statement
during trigger execution, an error risen during the execution
may cause a crash. The fix is to temporary reset LEX::current_select
before trigger execution and restore it afterwards. This way
errors risen during the trigger execution are processed as
if there was no active SELECT.
2010-09-07 15:53:46 +07:00
Martin Hansson
3d5b9792e6 Bug#54543: update ignore with incorrect subquery leads to assertion failure:
inited==INDEX

When an error occurs while sending the data in a temporary table there was no
cleanup performed. This caused a failed assertion in the case when different
access methods were used for populating the table vs. retrieving the data from
the table if IGNORE was specified and sql_safe_updates = 0. In this case
execution continues, but the handler expects to continue with the access
method used for row retrieval.

Fixed by doing the cleanup even if errors occur.
2010-09-07 09:58:05 +02:00
Evgeny Potemkin
e408bf4e14 Bug#56271: Wrong comparison result with STR_TO_DATE function
The Item_func_str_to_date class wasn't providing correct integer DATETIME
representation as expected. This led to wrong comparison result and didn't
allowed the STR_TO_DATE function to be used with indexes.
Also, STR_TO_DATE function was inconsisted on throwing warnings/errors.
Fixed now.

val_int and result_as_longlong methods were added to the Item_func_str_to_date
class.
2010-09-07 10:45:00 +04:00