Commit graph

27268 commits

Author SHA1 Message Date
Alexey Kopytov
966d6d2fb0 Bug #48537: difference of index selection between rpm binary
and .tar.gz, windows vs linux..

On Intel x86 machines index selection by the MySQL query
optimizer could sometimes depend on the compiler version and
optimization flags used to build the server binary.

The problem was a result of a known issue with floating point
calculations on x86: since internal FPU precision (80 bit)
differs from precision used by programs (32-bit float or 64-bit
double), the result of calculating a complex expression may
depend on how FPU registers are allocated by the compiler and
whether intermediate values are spilled from FPU to memory. In
this particular case compiler versions and optimization flags
had an effect on cost calculation when choosing the best index
in best_access_path().

A possible solution to this problem which has already been
implemented in mysql-trunk is to limit FPU internal precision
to 64 bits. So the fix is a backport of the relevant code to
5.1 from mysql-trunk.
2010-05-29 22:16:45 +04:00
Davi Arnaut
aa28461510 Backport: remove dead code.
Reorganize function to reflect that it does not actually uses curses
and that there is no curses variant.
2010-05-28 19:53:26 -03:00
Davi Arnaut
570c6cc87a Backport: Remove unused and ancient files, functions, and facilities. 2010-05-28 19:13:31 -03:00
Davi Arnaut
d60a0ce9be Backport a old cleanup patch.
Formatting cleanup: removing tabs and trailing spaces
to conform to MySQL Internals Coding Guidelines.
2010-05-28 18:00:18 -03:00
oystein.grovlen@sun.com
80fc19ade7 Bug#52168 decimal casting catastrophes: crashes and valgrind errors on simple casts
The problem is that if a NULL is stored in an Item_cache_decimal object,
the associated my_decimal object is not initialized.  However, it is still
accessed when val_int() is called. The fix is to check for null_value
within val_int(), and return without accessing the my_decimal object when
the cached value is NULL.

Bug#52122 reports the same issue for val_real(), and this patch also includes
fixes for val_real() and val_str() and corresponding test cases from that
bug report.  

Also, NULL is returned from val_decimal() when value is null. This will
avoid that callers access an uninitialized my_decimal object.

Made similar changes to all other Item_cache classes.  Now all val_*
methods should return a well defined value when actual value is NULL.
2010-05-28 17:30:39 +02:00
Mattias Jonsson
7e33652495 Manual merge of bug#49161 into mysql-trunk-merge
(Added a real error message instead of ER_UNKNOWN_ERROR)
2010-05-28 15:14:43 +02:00
Mattias Jonsson
6498472b9d merge 2010-05-28 14:49:25 +02:00
Alexander Nozdrin
4e633ec234 Auto-merge from mysql-trunk. 2010-05-28 09:47:58 +04:00
Dmitry Lenev
1fbdf160b4 Patch that addresses bug #53976 "ALTER TABLE RENAME
is allowed on views (not documented, broken)".

Remove support of ALTER TABLE RENAME for views as:
a) this feature was not documented,
c) does not add any compatibility with other databases,
b) its implementation doesn't follow metadata locking
   protocol by accessing .FRM without holding any
   metadata lock,
c) its implementation complicates ALTER TABLE's code
   by introducing  yet another separate branch to it.

After this patch one can rename a view by using the
documented way - RENAME TABLE statement.
2010-05-28 09:25:11 +04:00
Davi Arnaut
a3d61b0bb2 Fix type mismatch. Table names are represented as LEX_STRING
objects whose length is stored in a size_t type.
2010-05-27 18:28:24 -03:00
Davi Arnaut
3cc56cb5ad Bug#42643: InnoDB does not support replication of TRUNCATE TABLE
Post-merge fix: Pass the right parameter type to open_and_lock_tables.
Passing FALSE ensures that derived table handling is disabled, truncate
only operates on base tables.
2010-05-27 18:11:55 -03:00
Davi Arnaut
2d3e5019d4 Bug#42643: InnoDB does not support replication of TRUNCATE TABLE
Post-merge fix: Retrieve handler statistics to workaround quirks
of the archive storage engine.
2010-05-27 17:40:54 -03:00
Dmitry Lenev
78c6a8ca30 A 5.1-only version of fix for bug #46947 "Embedded SELECT
without FOR UPDATE is causing a lock".

SELECT statements with subqueries referencing InnoDB tables
were acquiring shared locks on rows in these tables when they
were executed in REPEATABLE-READ mode and with statement or
mixed mode binary logging turned on.

This was a regression which were introduced when fixing
bug 39843.

The problem was that for tables belonging to subqueries
parser set TL_READ_DEFAULT as a lock type. In cases when
statement/mixed binary logging at open_tables() time this
type of lock was converted to TL_READ_NO_INSERT lock at
open_tables() time and caused InnoDB engine to acquire
shared locks on reads from these tables. Although in some
cases such behavior was correct (e.g. for subqueries in
DELETE) in case of SELECT it has caused unnecessary locking.

This patch implements minimal version of the fix for the
specific problem described in the bug-report which supposed
to be not too risky for pushing into 5.1 tree.
The 5.5 tree already contains a more appropriate solution
which also addresses other related issues like bug 53921
"Wrong locks for SELECTs used stored functions may lead
to broken SBR".

This patch tries to solve the problem by ensuring that
TL_READ_DEFAULT lock which is set in the parser for
tables participating in subqueries at open_tables()
time is interpreted as TL_READ_NO_INSERT or TL_READ.
TL_READ is used only if we know that this is a SELECT
and that this particular table is not used by a stored
function.

Test coverage is added for both InnoDB and MyISAM.

This patch introduces an "incompatible" change in locking
scheme for subqueries used in SELECT ... FOR UPDATE and
SELECT .. IN SHARE MODE.

In 4.1 (as well as in 5.0 and 5.1 before fix for bug 39843)
the server would use a snapshot InnoDB read for subqueries
in SELECT FOR UPDATE and SELECT .. IN SHARE MODE statements,
regardless of whether the binary log is on or off.

If the user required a different type of read (i.e. locking
read), he/she could request so explicitly by providing FOR
UPDATE/IN SHARE MODE clause for each individual subquery.

The patch for bug 39843 broke this behaviour (which was not
documented or tested), and started to use locking reads for
all subqueries in SELECT ... FOR UPDATE/IN SHARE MODE.
This patch restores 4.1 behaviour.

This patch should be mostly null-merged into 5.5 tree.
2010-05-28 00:07:40 +04:00
Sergey Glukhov
20bd61a6e1 Bug#52430 Incorrect key in the error message for duplicate key error involving BINARY type
For BINARY(N) strip trailing zeroes to make the error message nice-looking
2010-05-27 20:01:43 +04:00
Sergey Glukhov
6f55a81074 Bug#52856 concurrent show columns or show full columns causes a crash!!!1
We should avoid any SHARE fields assignments as
this is shared structure and assignments may
affect other therads. To avoid this
copy of SHARE struct is created and
stored into TABLE struct which is
used in get_schema_coulumns_record later.
2010-05-27 19:54:43 +04:00
Alfranio Correia
9fbf4b723d BUG#53437 @@session.sql_bin_log support in substatements is incorrect
The thd->variables.option_bits & OPTION_BIN_LOG is currently abused: 
it's both a system variable and an implementation switch. The current
approach to this option bit breaks the session variable encapsulation. 
      
Besides it is allowed to change @@session.sql_bin_log within a
transaction what may lead to not correctly logging a transaction.
      
To fix the problems,  we created a thd->variables variable to represent
the "sql_log_bin" and prohibited its update inside a transaction or
sub-statement.
2010-05-27 16:43:08 +01:00
Sergey Glukhov
d7c73e79bd mysql-5.1-bugteam->mysql-trunk-merge 2010-05-27 19:20:10 +04:00
Sergey Glukhov
fa3570f96a Bug#52005 'JOIN_TAB->dependent' may be incorrectly propageted for multilevel outer joins
There are two problems:
1. In simplify_joins function we calculate table dependencies. If STRAIGHT_JOIN hint
is used for whole SELECT we do not count it and as result some dependendecies
might be lost. It leads to incorrect table order which is returned by
join_tab_cmp_straight() function.
2. make_join_statistics() calculate the transitive closure for relations a particular
JOIN_TAB is 'dependent on'.
We aggregate the dependent table_map of a JOIN_TAB by adding dependencies from other
tables which we depend on. However, this may also cause new dependencies to be
available after we have completed processing a certain JOIN_TAB.
Both these problems affect condition pushdown and as result condition might be pushed
into wrong table which leads to crash or even omitted which leads to wrong result.
The fix:
1. Use modified 'transitive closure' algorithm provided by Ole John Aske
2. Update table dependences in simplify_joins according to 
   global STRAIGHT_JOIN hint.
Note: the patch also fixes bugs 46091 & 51492
2010-05-27 19:13:53 +04:00
Alexey Kopytov
eaea879db3 Fixed an incorrect merge from 5.1-bugteam. 2010-05-27 14:48:50 +04:00
Alexey Kopytov
17325b8d67 Manual merge from mysql-5.1-bugteam to mysql-trunk-merge.
Null-merged patch for bug 53907.

Conflicts:

   conflict      sql/sql_parse.cc
2010-05-27 14:42:12 +04:00
Alexey Kopytov
54a006fa0f Automerge. 2010-05-27 14:14:27 +04:00
Alexey Kopytov
b19c880522 Automerge. 2010-05-27 14:08:44 +04:00
Kristofer Pettersson
fd75f56fd5 automerge 2010-05-26 17:17:33 +02:00
Kristofer Pettersson
0ffa3863c7 Bug#52107 Comment in sql/net_serv.cc still makes "GPL protocol" claim
Removed misleading comments.
2010-05-26 17:13:02 +02:00
Tor Didriksen
d8536dfbdd Bug #53445 Build with -Wall and fix warnings that it generates
Add -Wall to gcc/g++
Fix most warnings reported in dbg and opt mode.
2010-05-26 16:12:23 +02:00
Dmitry Lenev
c070e5a1ed Fix for bug #51263 "Deadlock between transactional
SELECT and ALTER TABLE ...  REBUILD PARTITION".

ALTER TABLE on InnoDB table (including partitioned tables)
acquired exclusive locks on rows of table being altered.
In cases when there was concurrent transaction which did
locking reads from this table this sometimes led to a
deadlock which was not detected by MDL subsystem nor by
InnoDB engine (and was reported only after exceeding
innodb_lock_wait_timeout).

This problem stemmed from the fact that ALTER TABLE acquired
TL_WRITE_ALLOW_READ lock on table being altered. This lock
was interpreted as a write lock and thus for table being
altered handler::external_lock() method was called with
F_WRLCK as an argument. As result InnoDB engine treated
ALTER TABLE as an operation which is going to change data
and acquired LOCK_X locks on rows being read from old
version of table.

In case when there was a transaction which already acquired
SR metadata lock on table and some LOCK_S locks on its rows
(e.g. by using it in subquery of DML statement) concurrent
ALTER TABLE was blocked at the moment when it tried to
acquire LOCK_X lock before reading one of these rows.
The transaction's attempt to acquire SW metadata lock on
table being altered led to deadlock, since it had to wait
for ALTER TABLE to release SNW lock. This deadlock was not
detected and got resolved only after timeout expiring
because waiting were happening in two different subsystems.

Similar deadlocks could have occured in other situations.
This patch tries to solve the problem by changing ALTER TABLE
implementation to use TL_READ_NO_INSERT lock instead of
TL_WRITE_ALLOW_READ. After this step handler::external_lock()
is called with F_RDLCK as an argument and InnoDB engine
correctly interprets ALTER TABLE as operation which only
reads data from original version of table. Thanks to this
ALTER TABLE acquires only LOCK_S locks on rows it reads.
This, in its turn, causes inter-subsystem deadlocks to go
away, as all potential lock conflicts and thus deadlocks will
be limited to metadata locking subsystem:

- When ALTER TABLE reads rows from table being altered it
  can't encounter any locks which conflict with LOCK_S row
  locks. There should be no concurrent transactions holding
  LOCK_X row locks. Such a transaction should have been
  acquired SW metadata lock on table first which would have
  conflicted with ALTER's SNW lock.
- Vice versa, when DML which runs concurrently with ALTER
  TABLE tries to lock row it should be requesting only LOCK_S
  lock which is compatible with locks acquired by ALTER,
  as otherwise such DML must own an SW metadata lock on table
  which would be incompatible with ALTER's SNW lock.
2010-05-26 16:18:08 +04:00
Davi Arnaut
3c279d9a5a Bug#42643: InnoDB does not support replication of TRUNCATE TABLE
The problem was that TRUNCATE TABLE didn't take a exclusive
lock on a table if it resorted to truncating via delete of
all rows in the table. Specifically for InnoDB tables, this
could break proper isolation as InnoDB ends up aborting some
granted locks when truncating a table.

The solution is to take a exclusive metadata lock before
TRUNCATE TABLE can proceed. This guarantees that no other
transaction is using the table.

Incompatible change: Truncate via delete no longer fails
if sql_safe_updates is activated (this was a undocumented
side effect).
2010-05-25 17:01:38 -03:00
Ramil Kalimullin
442e0f01f2 Manual merge. 2010-05-25 22:30:08 +04:00
Mattias Jonsson
2e1ade56f8 merge 2010-05-25 17:41:11 +02:00
Mattias Jonsson
e596ae0795 merge 2010-05-25 17:26:48 +02:00
Alexey Kopytov
8fabbdd789 Bug #53830: !table || (!table->read_set ||
bitmap_is_set(table->read_set, field_index))

UPDATE on an InnoDB table modifying the same index that is used
to satisfy the WHERE condition could trigger a debug assertion
under some circumstances.

Since for engines with the HA_PRIMARY_KEY_IN_READ_INDEX flag
set results of an index scan on a secondary index are appended
by the primary key value, if a query involves only columns from
the primary key and a secondary index, the latter is considered
to be covering.

That tricks mysql_update() to mark for reading only columns
from the secondary index when it does an index scan to retrieve
rows to update in case a part of that key is also being
updated. However, there may be other columns in WHERE that are
part of the primary key, but not the secondary one.

What we actually want to do in this case is to add index
columns to the existing WHERE columns bitmap rather than
replace it.
2010-05-25 18:43:45 +04:00
Ramil Kalimullin
422621a43f Automerge. 2010-05-25 18:07:47 +04:00
Ramil Kalimullin
edfea7d590 Fix for bug #53907: Table dump command can be abused to dump arbitrary tables.
Problem: one with SELECT privilege on some table may dump other table
performing COM_TABLE_DUMP command due to missed check of the table name.

Fix: check the table name.
2010-05-25 17:56:23 +04:00
Mattias Jonsson
427436d4b8 merge 2010-05-25 15:45:01 +02:00
Mattias Jonsson
ff36f028c3 Bug#49161: Out of memory; restart server and try again (needed 2 bytes)
Problem was reporting wrong error

Fixed by adding a new error which better explain the problem.
2010-05-25 15:41:00 +02:00
Davi Arnaut
5f5e23fea9 Bug#53908: compile failure with embedded enabled
This fixes a recently introduced regression, where a variable is
not defined for the embedded server. Although the embedded server
is not supported in 5.0, make it at least compile.
2010-05-25 10:36:48 -03:00
Dmitry Lenev
a3c080be7a Pre-requisite patch for bug #51263 "Deadlock between
transactional SELECT and ALTER TABLE ... REBUILD PARTITION".

The goal of this patch is to decouple type of metadata
lock acquired for table by open_tables() from type of
table-level lock to be acquired on it.

To achieve this we change approach to how we determine what
type of metadata lock should be acquired on table to be open.
Now instead of inferring it at open_tables() time from flags
and type of table-level lock we rely on that type of metadata
lock is properly set at parsing time and is not changed
further.
2010-05-25 16:35:01 +04:00
Mattias Jonsson
2b846b39c1 merge 2010-05-25 08:35:48 +02:00
Mattias Jonsson
b0ecceb95b merge 2010-05-24 23:21:08 +02:00
Mattias Jonsson
d7e7afd403 Merge of bug#51851.
Also moved HA_DATA_PARTITION from ha_partition.cc to table.h.
2010-05-24 14:51:59 +02:00
Alexey Kopytov
b69a31fad5 Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:

   conflict      Makefile.am
   conflict      mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result
   conflict      mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test
   conflict      sql/opt_sum.cc
   conflict      sql/set_var.cc
   conflict      sql/sql_base.cc
   conflict      sql/sql_priv.h
   conflict      sql/sql_show.cc
2010-05-24 00:41:18 +04:00
Mattias Jonsson
ca0aa95c6d merge 2010-05-23 18:08:33 +02:00
Gleb Shchepa
6e34b8b0ce Bug #53804: serious flaws in the alter database .. upgrade
data directory name command

The check_db_name function has been modified to validate tails of
#mysql50#-prefixed database names for compliance with MySQL 5.0
database name encoding rules (the check_table_name function call
has been reused).
2010-05-21 22:47:32 +04:00
Jon Olav Hauglid
ac9bae9e04 merge from mysql-trunk-runtime 2010-05-21 15:49:15 +02:00
Dmitry Lenev
6ceacd4fb9 Follow-up for the fix for bug #46947 "Embedded SELECT without
FOR UPDATE is causing a lock".
 
This patch tries to address problems which were exposed 
during backporting of original patch to 5.1 tree.
 
- It ensures that we don't change locking behavior of simple
  SELECT statements on InnoDB tables when they are executed
  under LOCK TABLES ... READ and with @@innodb_table_locks=0.
  Also we no longer pass TL_READ_DEFAULT/TL_WRITE_DEFAULT 
  lock types, which are supposed to be parser-only, to 
  handler::start_stmt() method.
- It makes check_/no_concurrent_insert.inc auxiliary scripts 
  more robust against changes in test cases that use them
  and also ensures that they don't unnecessarily change 
  environment of caller.
2010-05-21 16:41:24 +04:00
Mattias Jonsson
ae171f1e40 merge into mysql-5.1-bugteam 2010-05-21 14:18:14 +02:00
Alexey Kopytov
779e2a9686 Bug #42064: low memory crash when importing hex strings, in
Item_hex_string::Item_hex_string

The status of memory allocation in the Lex_input_stream (called
from the Parser_state constructor) was not checked which led to
a parser crash in case of the out-of-memory error.

The solution is to introduce new init() member function in
Parser_state and Lex_input_stream so that status of memory
allocation can be returned to the caller.
2010-05-21 15:23:48 +04:00
Alexander Nozdrin
eff442964a Manual merge from mysql-trunk.
Conflicts:
  - mysql-test/r/partition.result
  - mysql-test/r/variables_debug.result
  - mysql-test/t/partition.test
  - mysql-test/t/variables_debug.test
2010-05-20 16:35:28 +04:00
Sergey Glukhov
7132ccd7ca Bug#52884 mysql-test-run does not work with --debug option
Server crashes on 64bit linux with 'double free or corruption'
message, on 32bit mysql-test-run silently fails on bootstrap
stage. The problem is that FreeState() is called twice
for init_settings struct in _db_end_ function.
The fix is to remove superfluous FreeState() call.
Additional fix:
fixed discrepancy of result file when
debug & valgrind options are enabled
for MTR.
2010-05-20 10:31:03 +04:00
Luis Soares
4ed6fc0457 BUG 52868: automerged bzr bundle from bug report. 2010-05-20 00:50:42 +01:00
Luis Soares
e7eb43a859 BUG 49522: automerged bzr bundle from bug report. 2010-05-20 00:49:18 +01:00
Alexander Nozdrin
091bcacc79 Another incarnation of the patch for Bug#30708
(make relies GNU extentions). The patch was partially
backport from 6.0.

Original comment:
bug#30708: make relies GNU extensions.  Now that we no longer use
BitKeeper we can safely remove the SCCS handling with no loss of
functionality.
2010-05-19 17:00:23 +04:00
Tor Didriksen
a22c69b233 Backport from next-mr-bugfixing of tor.didriksen@sun.com-20100106140051-3j2iuag63eltsr2e
Bug #50087 Interval arithmetic for Event_queue_element is not portable.

Subtraction of two unsigned months yielded a (very large) positive value.
Conversion of this to a signed value was not necessarily well defined.
              
Solution: do the subtraction on signed values.
2010-05-19 11:18:59 +02:00
Andrei Elkin
b530d5660e reverting fixes for Bug@50316 in mysql-trunk 2010-05-18 18:32:44 +03:00
Jon Olav Hauglid
1c02ed3e67 manual merge from mysql-trunk-bugfixing 2010-05-18 14:52:51 +02:00
Sergey Glukhov
f512cb4eaf Bug#48729 SELECT ... FROM INFORMATION_SCHEMA.ROUTINES causes memory to grow
Analysis showed that in case of accessing I_S table
ROUTINES we perform unnecessary allocations
with get_field() function for every processed row that
in their turn causes significant memory growth.
the fix is to avoid use of get_field().
2010-05-18 13:28:21 +05:00
Andrei Elkin
2c966ddda1 merging bug#50316 fixes 2010-05-18 10:13:37 +03:00
Alexander Nozdrin
677bc2e719 Follow-up patch for Bug#27863 (excessive memory usage for many small queries
in a multiquery packet): fix NDB test failures.
2010-05-17 16:10:26 +04:00
Andrei Elkin
9e3c410ae7 bug#50316 Add Master_info_file to SHOW SLAVE STATUS
pushing to next-mr-bugfixing from working branch
2010-05-16 21:40:56 +03:00
Alfranio Correia
8edccf1e41 BUG#49019 Mixing self-logging eng. and regular eng. does not switch to row in mixed
mode
      
Post-push fix after backporting the patch to 5.1-bugteam:

  1 - changed the name of some variables to be equivalent to pe.
  2 - fixed that patch to mark a statement as unsafe when both a
  self-logging eng. and regular eng. are accessed and one of them
  is updated.
2010-05-16 15:37:44 +01:00
Alexander Nozdrin
5c4333bc85 Patch for Bug#27863 (excessive memory usage for many small queries in a
multiquery packet).

Background:

  - a query can contain multiple SQL statements;

  - the server frees resources allocated to process a query when the
    whole query is handled. In other words, resources allocated to process
    one SQL statement from a multi-statement query are freed when all SQL
    statements are handled.

The problem was that the parser allocated a buffer of size of the whole
query for each SQL statement in a multi-statement query. Thus, if a query
had many SQL-statements (so, the query was long), but each SQL statement
was short, ther parser tried to allocate huge amount of memory (number of
small SQL statements * length of the whole query).

The memory was allocated for a so-called "cpp buffer", which is intended to
store pre-processed SQL statement -- SQL text without version specific
comments.

The fix is to allocate memory for the "cpp buffer" once for all SQL
statements (once for a query).
2010-05-14 22:11:25 +04:00
Gleb Shchepa
09b6efcc76 Bug #53450: Crash / assertion "virtual int
ha_myisam::index_first(uchar*)") at assert.c:81

Single-table DELETE crash/assertion similar to single-table
UPDATE bug 14272.

Same resolution as for the bug 14272:
Don't run index scan when we should use quick select.
This could cause failures because there are table handlers (like federated)
that support quick select scanning but do not support index scanning.
2010-05-14 15:36:27 +04:00
Alexander Nozdrin
7752ccec48 Patch for Bug#21818 (Return value of ROW_COUNT() is incorrect
for ALTER TABLE, LOAD DATA).

ROW_COUNT is now assigned according to the following rules:

  - In my_ok():
    - for DML statements: to the number of affected rows;
    - for DDL statements: to 0.

  - In my_eof(): to -1 to indicate that there was a result set.

    We derive this semantics from the JDBC specification, where int
    java.sql.Statement.getUpdateCount() is defined to (sic) "return the
    current result as an update count; if the result is a ResultSet
    object or there are no more results, -1 is returned".

  - In my_error(): to -1 to be compatible with the MySQL C API and
    MySQL ODBC driver.

  - For SIGNAL statements: to 0 per WL#2110 specification. Zero is used
    since that's the "default" value of ROW_COUNT in the diagnostics area.
2010-05-14 09:28:51 +04:00
Konstantin Osipov
c40277d8cd Merge trunk -> trunk-runtime. 2010-05-13 19:40:33 +04:00
Dmitry Lenev
017d66b5c8 Small clean-up. Removed standalone enum_open_table_action enum
type, which some time ago became part of Open_table_context class.
Apparently standalone enum type was erroneously re-introduced
during one of merges.
2010-05-13 13:36:49 +04:00
Dmitry Lenev
8a6953dbc5 Fix compiler warning about "assignment used as truth value"
which was introduced by fix for bug 47459 "Assertion in
Diagnostics_area::set_eof_status on OPTIMIZE TABLE.
2010-05-13 13:24:59 +04:00
Ramil Kalimullin
a882f7e683 Fix for bug#52051: Aggregate functions incorrectly returns
NULL from outer join query
      
      Problem: optimising MIN/MAX() queries without GROUP BY clause
      by replacing the aggregate expression with a constant, we may set it
      to NULL disregarding the fact that there may be outer joins involved.
      
      Fix: don't replace MIN/MAX() with NULL if there're outer joins.
      
      Note: the fix itself is just
      - if (!count)
      + if (!count && !outer_tables)
          set to NULL
      
      The rest of the patch eliminates repeated code to improve speed
      and for easy maintenance of the code.
2010-05-12 20:10:33 +04:00
Jonathan Perkin
5b85121ca6 Changes to build using CMake according to existing release packages:
- Update/fix file layouts for each package type, add new types for
   native package formats including deb, rpm and svr4.

 - Build all plugins, including debug versions

 - Update compiler flags to match current release

 - Add missing @VAR@ expansions

 - Install correct mysqclient library symlinks

 - Fix icc/ia64 builds

 - Fix install of libmysqld-debug

 - Don't include mysql_embedded

 - Remove unpackaged manual pages to avoid missing files warnings

 - Don't install mtr's test suite
2010-05-12 12:51:23 +01:00
Staale Smedseng
44fe4c707b Bug #49756 Rows_examined is always 0 in the slow query log for
update statements
      
Only SELECT statements report any examined rows in the slow
log. Slow UPDATE, DELETE and INSERT statements report 0 rows
examined, unless the statement has a condition including a
SELECT substatement.
      
This patch adds counting of examined rows for the UPDATE and
DELETE statements. An INSERT ... VALUES statement will still 
not report any rows as examined.
2010-05-12 13:19:12 +02:00
Alexey Kopytov
a6cf28a7a1 Manual merge from mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:

Text conflict in sql/sql_base.cc
Text conflict in sql/sql_partition.cc
Text conflict in sql/sql_priv.h
Text conflict in sql/sql_show.cc
2010-05-11 20:02:50 +04:00
Martin Hansson
27ac666fea Bug#48157: crash in Item_field::used_tables
MySQL handles the join syntax "JOIN ... USING( field1,
... )" and natural joins by building the same parse tree as
a corresponding join with an "ON t1.field1 = t2.field1 ..."
expression would produce. This parse tree was not cleaned up
properly in the following scenario. If a thread tries to
lock some tables and finds that the tables were dropped and
re-created while waiting for the lock, it cleans up column
references in the statement by means a per-statement free
list. But if the statement was part of a stored procedure,
column references on the stored procedure's free list
weren't cleaned up and thus contained pointers to freed
objects.
      
Fixed by adding a call to clean up the current prepared
statement's free list.

This is a backport from MySQL 5.1
2010-05-11 16:21:05 +02:00
Alexey Kopytov
db9672cfde Manual merge from mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:

Text conflict in tests/mysql_client_test.c
2010-05-11 12:27:53 +04:00
Alexey Kopytov
e47ab5a604 Manual merge from mysql-5.1-bugteam to mysql-trunk-merge.
Text conflict in sql/log.cc
Text conflict in sql/log.h
Text conflict in sql/sql_class.cc
Text conflict in sql/sql_load.cc
2010-05-11 12:23:57 +04:00
Mattias Jonsson
af2de57325 merge 2010-05-10 15:17:06 +02:00
Martin Hansson
1c5200f67d Bug#50939: Loose Index Scan unduly relies on engine to
remember range endpoints

The Loose Index Scan optimization keeps track of a sequence
of intervals. For the current interval it maintains the
current interval's endpoints. But the maximum endpoint was
not stored in the SQL layer; rather, it relied on the
storage engine to retain this value in-between reads. By
coincidence this holds for MyISAM and InnoDB. Not for the
partitioning engine, however.

Fixed by making the key values iterator 
(QUICK_RANGE_SELECT) keep track of the current maximum endpoint.
This is also more efficient as we save a call through the
handler API in case of open-ended intervals.

The code to calculate endpoints was extracted into 
separate methods in QUICK_RANGE_SELECT, and it was possible to
get rid of some code duplication as part of fix.
2010-05-10 09:23:23 +02:00
Alfranio Correia
f438d08aee BUG#49019 Mixing self-logging eng. and regular eng. does not switch to row in mixed mode
Backport of the patch for 5.1-bugteam.
2010-05-09 23:45:25 +01:00
Alexey Kopytov
ad43230e3b Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:

Text conflict in mysql-test/r/grant.result
Text conflict in mysql-test/t/grant.test
Text conflict in mysys/mf_loadpath.c
Text conflict in sql/slave.cc
Text conflict in sql/sql_priv.h
2010-05-09 02:03:35 +04:00
He Zhenxing
455f754e6b Bug#53189 Table map version unused and can be removed
MYSQL_BIN_LOG m_table_map_version member and it's associated 
functions were not used in the logic of binlogging and replication,
this patch removed all related code.
2010-05-08 11:25:33 +08:00
Luis Soares
60ff8469a0 BUG#49522: Replication problem with mixed MyISAM/InnoDB
When using a non-transactional table (t1) on the master 
and with autocommit disabled, no COMMIT is recorded 
in the binary log ending the statement. Therefore, if 
the slave has t1 in a transactional engine, then it will 
be as if a transaction is started but never ends. This is
actually BUG#29288 all over again.

We fix this by cherrypicking the cset for BUG#29288 which
was pushed to a later mysql version. The revision picked
was: mats@sun.com-20090923094343-bnheplq8n95opjay .

Additionally, a test case for covering the scenario depicted
in the bug report is included in this cset.
2010-05-07 18:48:35 +01:00
Konstantin Osipov
5ac769be68 Draft patch that fixes and a sketches test cases for:
Bug#20837 Apparent change of isolation level during transaction,
Bug#46527 COMMIT AND CHAIN RELEASE does not make sense,
Bug#53343 completion_type=1, COMMIT/ROLLBACK AND CHAIN don't 
preserve the isolation level
Bug#53346 completion_type has strange effect in a stored 
procedure/prepared statement

Make thd->tx_isolation mean strictly "current transaction 
isolation level"
Make thd->variables.tx_isolation mean "current session isolation
level".
The current transaction isolation level is now established
at transaction start. If there was a SET TRANSACTION
ISOLATION LEVEL statement, the value is taken from it.
Otherwise, the session value is used.
A change in a session value, made while a transaction is active,
whereas still allowed, no longer has any effect on the
current transaction isolation level. This is an incompatible
change.
A change in a session isolation level, made while there is
no active transaction, overrides SET TRANSACTION statement,
if there was any.
Changed the impelmentation to not look at @@session.completion_type
in the parser, and thus fixed Bug#53346.
Changed the parser to not allow AND NO CHAIN RELEASE,
and thus fixed Bug#46527.
Changed the transaction API to take the current transaction
isolation level into account:
- BEGIN/COMMIT now do preserve the current transaction
isolation level if chaining is on.
- implicit commit, XA COMMIT or XA ROLLBACK or autocommit don't.
2010-05-07 20:28:59 +04:00
Alexey Kopytov
9a2f981989 Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:

Text conflict in mysql-test/r/explain.result
Text conflict in mysql-test/t/explain.test
Text conflict in sql/net_serv.cc
Text conflict in sql/sp_head.cc
Text conflict in sql/sql_priv.h
2010-05-07 20:17:55 +04:00
Alexey Kopytov
480a4852a0 Manual merge of local mysql-trunk-merge with bk-internal.
Conflicts:

Text conflict in sql/CMakeLists.txt
2010-05-07 18:56:46 +04:00
Alexander Nozdrin
fe8f7052fc Manual merge from mysql-trunk.
Conflicts:
  - mysql-test/suite/engines/funcs/t/disabled.def
  - mysql-test/suite/engines/iuds/t/disabled.def
  - mysql-test/suite/engines/iuds/t/insert_number.test
2010-05-07 13:37:16 +04:00
Martin Hansson
31a79ec3c6 Merge of fix for Bug#52357 2010-05-07 09:12:16 +02:00
Sergey Glukhov
2c83fc6266 Bug#53334 Incorrect result for InnoDB in LEFT JOIN with impossible condition
The fix actually reverts the change introduced
by the patch for bug 51494.
The fact is that patches for bugs 52177&48419
fix bugs 51194&50575 as well.
2010-05-07 10:38:42 +05:00
Gleb Shchepa
c4021e2d43 Bug #53088: mysqldump with -T & --default-character-set set
truncates text/blob to 766 chars

mysqldump and SELECT ... INTO OUTFILE truncated long BLOB/TEXT
values to size of 766 bytes (MAX_FIELD_WIDTH or 255 * 3 + 1).

The select_export::send_data method has been modified to
reallocate a conversion buffer for long field data.
2010-05-07 00:41:37 +04:00
Martin Hansson
9bd08c192a Merge of fix for Bug#52357 2010-05-06 10:59:28 +02:00
Martin Hansson
4e75f7c053 Bug#52357: Assertion failed: join->best_read in
greedy_search optimizer_search_depth=0

The algorithm inside restore_prev_nj_state failed to
properly update the counters within the NESTED_JOIN
tree. The counter was decremented each time a table in the
node was removed from the QEP, the correct thing to do being
only to decrement it when the last table in the child node
was removed from the plan. This lead to node counters
getting negative values and the plan thus appeared
impossible. An assertion caught this.

Fixed by not recursing up the tree unless the last table in
the join nest node is removed from the plan
2010-05-06 10:45:00 +02:00
Konstantin Osipov
cca59e83d7 Clean-up, give better names, add comments to
thd->in_multi_stmt_transaction() and thd->active_transaction().
2010-05-06 02:02:08 +04:00
Alexander Nozdrin
d91c271b2b Patch for Bug#50511 (Sometimes wrong handling of user variables containing NULL).
The bug happened under the following condition:
  - there was a user variable of type REAL, containing NULL value
  - there was a table with a NOT_NULL column of any type but REAL, having
    default value (or auto increment);
  - a row was inserted into the table with the user variable as value.
    A warning was emitted here.

The problem was that handling of NULL values of REAL type was not properly
implemented: it didn't expect that REAL NULL value can be assigned to other
data type.

Basically, the problem was that set_field_to_null() was used instead of
set_field_to_null_with_conversions().

The fix is to use the right function, or more generally, to allow conversion of
REAL NULL values to other data types.
2010-05-05 15:00:59 +04:00
Alexander Barkov
25d31b8f7c Bug#51571 load xml infile causes server crash
Problem:
  item->name was NULL for Item_user_var_as_out_param
  which made strcmp(something, item->name) crash in the LOAD XML code.
  
  Fix:
  - item_func.h: Adding set_name() in constuctor for Item_user_var_as_out_param
  - sql_load.cc: Changing the condition in write_execute_load_query_log_event() which
  distiguished between Item_user_var_as_out_param and Item_field
  from
    if (item->name == NULL)
  to
    if (item->type() == Item::FIELD_ITEM)
  - loadxml.result, loadxml.test: adding tests
2010-05-05 14:34:20 +04:00
Alexander Barkov
6bf10a8623 Bug#52849 [Com]: datetime index not work
Problem: after introduction of "WL#2649 Number-to-string conversions"

This query:
  SET NAMES cp850; -- Or any other non-latin1 ASCII-based character set
  SELECT * FROM t1
  WHERE datetime_column='2010-01-01 00:00:00'
started to add extra character set conversion: 
  SELECT * FROM t1
  WHERE CONVERT(datetime_column USING cp850)='2010-01-01 00:00:00';

so index on DATETIME column was not used anymore.
Fix:
  avoid convertion of NUMERIC/DATETIME items
  (i.e. those with derivation DERIVATION_NUMERIC).
2010-05-05 13:28:37 +04:00
Georgi Kodinov
1132c35475 On behalf of Kristofer :
Bug#53417 my_getwd() makes assumptions on the buffer sizes which not always hold true
      
The mysys library contains many functions for rewriting file paths. Most of these
functions makes implicit assumptions on the buffer sizes they write to. If a path is put
in my_realpath() it will propagate to my_getwd() which assumes that the buffer holding
the path name is greater than 2. This is not true in cases.
      
In the special case where a VARBIN_ITEM is passed as argument to the LOAD_FILE function
this can lead to a crash.
      
This patch fixes the issue by introduce more safe guards agaist buffer overruns.
2010-05-05 11:54:52 +03:00
Jon Olav Hauglid
27da41cc2e merge from mysql-trunk-bugfixing 2010-05-05 09:25:04 +02:00
Alfranio Correia
0ca7c012ac merge mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2010-05-04 23:15:10 +01:00
Jon Olav Hauglid
efe69e7c42 Followup to Bug#42546 Backup: RESTORE fails, thinking it finds an existing table
Fixes a bug where bool* was used as an argument to a function where the parameter
was of type bool.
2010-05-04 16:33:42 +02:00
Georgi Kodinov
0f26a0533b Bug #53371: COM_FIELD_LIST can be abused to bypass table level grants.
This is the 5.1 merge and extension of the fix.
The server was happily accepting paths in table name in all places a table
name is accepted (e.g. a SELECT). This allowed all users that have some 
privilege over some database to read all tables in all databases in all
mysql server instances that the server file system has access to.
Fixed by :
1. making sure no path elements are allowed in quoted table name when
constructing the path (note that the path symbols are still valid in table names
when they're properly escaped by the server).
2. checking the #mysql50# prefixed names the same way they're checked for
path elements in mysql-5.0.
2010-05-04 17:03:28 +03:00
Mattias Jonsson
07c765aa42 merge 2010-05-04 14:26:44 +02:00
Alfranio Correia
ee36464703 BUG#43407 SET GLOBAL SQL_SLAVE_SKIP_COUNTER should log previous state in error log
When issuing a 'SET GLOBAL SQL_SLAVE_SKIP_COUNTER' statement, the previous
position along with the new position is dumped into the error log. Namely,
the following information is printed out: skip_counter, group_relay_log_name
and group_relay_log_pos.
2010-05-04 10:41:28 +01:00
Alfranio Correia
5bfbfb2fb4 BUG#43406 CHANGE MASTER TO should log previous state in error log
When issuing a 'CHANGE MASTER TO' statement, key elements of the previous
state, namely the host, port, the master_log_file and the master_log_pos
are dumped into the error log.
2010-05-04 10:17:20 +01:00
Kristofer Pettersson
5b6ebdf086 Bug#50373 --secure-file-priv=""
Iterative patch improvement. Previously committed patch
caused wrong result on Windows. The previous patch also
broke secure_file_priv for symlinks since not all file
paths which must be compared against this variable are
normalized using the same norm.

The server variable opt_secure_file_priv wasn't
normalized properly and caused the operations
LOAD DATA INFILE .. INTO TABLE ..
and
SELECT load_file(..)
to do different interpretations of the 
--secure-file-priv option.
     
The patch moves code to the server initialization
routines so that the path always is normalized
once and only once.
      
It was also intended that setting the option
to an empty string should be equal to 
lifting all previously set restrictions. This
is also fixed by this patch.
2010-05-03 18:14:39 +02:00
Georgi Kodinov
6ae9c70109 Bug #53371: COM_FIELD_LIST can be abused to bypass table level grants.
The server was not checking the supplied to COM_FIELD_LIST table name
for validity and compliance to acceptable table names standards.
Fixed by checking the table name for compliance similar to how it's 
normally checked by the parser and returning an error message if 
it's not compliant.
2010-05-03 18:16:51 +03:00
Alexey Kopytov
0f5afe5d7f Automerge. 2010-04-30 15:27:17 +04:00
Alexey Kopytov
96366e1196 Bug #48419: another explain crash..
WHERE predicates containing references to empty tables in a
subquery were handled incorrectly by the optimizer when
executing EXPLAIN. As a result, the optimizer could try to
evaluate such predicates rather than just stop with
"Impossible WHERE noticed after reading const tables" as 
it would do in a non-subquery case. This led to valgrind 
errors and crashes.

Fixed the code checking the above condition so that subqueries
are not excluded and hence are handled in the same way as top
level SELECTs.
2010-04-30 15:10:48 +04:00
Davi Arnaut
55b7b75637 Manual merge. 2010-04-29 20:18:19 -03:00
Alexey Kopytov
940ad61b71 Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:

Text conflict in configure.in
Text conflict in dbug/dbug.c
Text conflict in mysql-test/r/ps.result
Text conflict in mysql-test/t/ps.test
Text conflict in sql/CMakeLists.txt
Text conflict in sql/ha_ndbcluster.cc
Text conflict in sql/mysqld.cc
Text conflict in sql/sql_plugin.cc
Text conflict in sql/sql_table.cc
2010-04-30 00:33:06 +04:00
Davi Arnaut
14ccbeb4e4 Bug#50974: Server keeps receiving big (> max_allowed_packet) packets indefinitely.
The server could be tricked to read packets indefinitely if it
received a packet larger than the maximum size of one packet.
This problem is aggravated by the fact that it can be triggered
before authentication.

The solution is to no skip big packets for non-authenticated
sessions. If a big packet is sent before a session is authen-
ticated, a error is returned and the connection is closed.
2010-04-29 10:28:16 -03:00
Alfranio Correia
ae2eafc098 Post-merge fix for BUG#51894, BUG#53075
thread_temporary_used is not initialized causing
valgrind's warnings.
2010-04-29 11:43:54 +01:00
Ramil Kalimullin
e287445d41 Manual merge. 2010-04-29 08:54:09 +04:00
Ramil Kalimullin
933e5ca5f0 Fix for bug #53237: mysql_list_fields/COM_FIELD_LIST stack smashing
Problem: "COM_FIELD_LIST is an old command of the MySQL server, before there was real move to only
SQL. Seems that the data sent to COM_FIELD_LIST( mysql_list_fields() function) is not
checked for sanity. By sending long data for the table a buffer is overflown, which can
be used deliberately to include code that harms".

Fix: check incoming data length.
2010-04-29 08:42:32 +04:00
Georgi Kodinov
70a969139c Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when JOINed
during an UPDATE

Extended the fix for bug 29310 to multi-table update:

When a table is being updated it has two set of fields - fields required for
checks of conditions and fields to be updated. A storage engine is allowed
not to retrieve columns marked for update. Due to this fact records can't
be compared to see whether the data has been changed or not. This makes the
server always update records independently of data change.
  
Now when an auto-updatable timestamp field is present and server sees that
a table handle isn't going to retrieve write-only fields then all of such
fields are marked as to be read to force the handler to retrieve them.
2010-04-28 15:55:54 +03:00
Sven Sandberg
a651824329 BUG#50670: Slave stops with error code 1644
Clarified error messages related to unsafe statements:
 - avoid the internal technical term "row injection"
 - use 'binary log' instead of 'binlog'
 - avoid the word 'unsafeness'
2010-04-28 14:47:49 +02:00
Konstantin Osipov
8280fdd3c3 Committing on behalf or Dmitry Lenev:
Fix for bug #46947 "Embedded SELECT without FOR UPDATE is
causing a lock", with after-review fixes.

SELECT statements with subqueries referencing InnoDB tables
were acquiring shared locks on rows in these tables when they
were executed in REPEATABLE-READ mode and with statement or
mixed mode binary logging turned on.

This was a regression which were introduced when fixing
bug 39843.

The problem was that for tables belonging to subqueries
parser set TL_READ_DEFAULT as a lock type. In cases when
statement/mixed binary logging at open_tables() time this
type of lock was converted to TL_READ_NO_INSERT lock at
open_tables() time and caused InnoDB engine to acquire
shared locks on reads from these tables. Although in some
cases such behavior was correct (e.g. for subqueries in
DELETE) in case of SELECT it has caused unnecessary locking.

This patch tries to solve this problem by rethinking our
approach to how we handle locking for SELECT and subqueries.
Now we always set TL_READ_DEFAULT lock type for all cases
when we read data. When at open_tables() time this lock
is interpreted as TL_READ_NO_INSERT or TL_READ depending
on whether this statement as a whole or call to function
which uses particular table should be written to the
binary log or not (if yes then statement should be properly
serialized with concurrent statements and stronger lock
should be acquired).

Test coverage is added for both InnoDB and MyISAM.

This patch introduces an "incompatible" change in locking
scheme for subqueries used in SELECT ... FOR UPDATE and
SELECT .. IN SHARE MODE.
In 4.1 the server would use a snapshot InnoDB read for 
subqueries in SELECT FOR UPDATE and SELECT .. IN SHARE MODE
statements, regardless of whether the binary log is on or off.
If the user required a different type of read (i.e. locking read),
he/she could request so explicitly by providing FOR UPDATE/IN SHARE MODE
clause for each individual subquery.
On of the patches for 5.0 broke this behaviour (which was not documented
or tested), and started to use locking reads fora all subqueries in SELECT ... 
FOR UPDATE/IN SHARE MODE. This patch restored 4.1 behaviour.
2010-04-28 14:04:11 +04:00
fa28ba8ba6 Bug #51839 mixup of DDL causes slave to stop
Stored routine DDL statements use statement-based replication
regardless of the current binlog format. The problem here was
that if a DDL statement failed during metadata lock acquisition
or opening of mysql.proc, the binlog format would not be reset
before returning. So the following DDL or DML statements are 
binlogged with a wrong binlog format, which causes the slave 
to stop.

The problem can be resolved by grabbing an exclusive MDL lock firstly
instead of clearing the current binlog format. So that the binlog
format will not be affected when the lock grab returns directly with
an error. The same way is taken to open a proc table for update.
2010-04-28 11:26:47 +08:00
Alexander Nozdrin
d328d5be33 Manual merge from mysql-trunk.
Conflicts:
  - mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result
2010-04-27 13:58:21 +04:00
Vladislav Vaintroub
147d1c854e Bug#48042 The description for Event ID ( 100 ) in Source ( MySQL ) cannot be found.
The problem is that message resource  (message.rc) is compiled as part of static library
sql.lib rather than with executable mysqld.exe. resource files do not work in static
libraries.
      
The fix is to add message.rc to mysqld.exe source files list.
2010-04-27 11:37:46 +02:00
Vladislav Vaintroub
9847a2355a Bug #48042 The description for Event ID ( 100 ) in Source ( MySQL ) cannot be found.
The problem is that message resource  (message.rc) is compiled as part of static library
sql.lib rather than with executable mysqld.exe. resource files do not work in static
libraries.

The fix is to add message.rc to mysqld.exe source files list.
2010-04-26 23:59:50 +02:00
Alexey Kopytov
1a1fd04d84 Backport of the fix for bug #50335 to 5.0.
The problem was in an incorrect debug assertion. The expression
used in the failing assertion states that when finding
references matching ORDER BY expressions, there can be only one
reference to a single table. But that does not make any sense,
all test cases for this bug are valid examples with multiple
identical WHERE expressions referencing the same table which
are also present in the ORDER BY list.

Fixed by removing the failing assertion. We also have to take
care of the 'found' counter so that we count multiple
references only once. We rely on this fact later in
eq_ref_table().
2010-04-27 00:06:00 +04:00
Alfranio Correia
a6d6ac3dbe BUG#53075 SBR: Strange warning around CONNECTION_ID
Statements with CONNECTION_ID were forced to be kept in the transactional
cache and by consequence non-transactional changes that were supposed to
be flushed ahead of the transaction were kept in the transactional cache.

This happened because after BUG#51894 any statement whose thd's
thread_specific_used was set was kept in the transactional cache. The idea
was to keep changes on temporary tables in the transactional cache. However,
the thread_specific_used was set not only for statements that accessed
temporary tables but also when the CONNECTION_ID was used.

To fix the problem, we created a new variable to keep track of updates
to temporary tables.
2010-04-26 10:02:29 +01:00
Ramil Kalimullin
4a1a64ec53 Fix for bug#50946: fast index creation still seems to copy the table
Problem: ALTER TABLE ADD INDEX may lead to table copying if there's
numeric field(s) with non-default display width modificator specified.

Fix: compare numeric field's storage lenghts when we decide whether 
they can be considered 'equal' for table alteration purposes.
2010-04-25 15:06:40 +04:00
Alexander Nozdrin
53af29c086 Patch for Bug#53022: Compilation of "embedded" is broken.
The bug was a side effect of WL#5030 (fix header files) and
WL#5161 (CMake).

The problem was that CMake-generated config.h (and my_config.h
as a copy of it) had a header guard. GNU autotools-generated
[my_]config.h did not. During WL#5030 the order of header files
was changed, so the following started to happen (using GNU autotools,
in embedded server):
  - my_config.h included, defining HAVE_OPENSSL
  - my_global.h included, un-defining  HAVE_OPENSSL
  - zlib.h included, including config.h,
    defining HAVE_OPENSSL again.

The fix is to check HAVE_OPENSSL in conjuction with EMBEDDED_LIBRARY.
More common fix would be to define a macros as HAVE_OPENSSL && !EMBEDDED_LIBRARY
and use it instead of HAVE_OPENSSL.
2010-04-22 22:53:26 +04:00
Staale Smedseng
9ea5576662 Bug#46261 Plugins can be installed with --skip-grant-tables
Previously installed dynamic plugins are explicitly not loaded
on startup with --skip-grant-tables enabled. However, INSTALL
PLUGIN/UNINSTALL PLUGIN commands are allowed, and result in
inconsistent error messages (reporting duplicate plugin or
plugin does not exist).

This patch adds a check for --skip-grant-tables mode, and
returns error ER_OPTION_PREVENTS_STATEMENT to the user when
the above commands are attempted.
2010-04-22 15:52:00 +02:00
Mattias Jonsson
2faf4ddfd4 Bug#52815: LIST COLUMNS doesn't insert rows in correct
partition if muliple columns used

Problem was that range scanning through the sorted array of
the column list values did not use a correct index calculation.

Fixed by also taking the number of columns in the calculation.
2010-04-21 15:32:27 -07:00
Alexander Nozdrin
fd64b18545 Patch for Bug#53022: Compilation of "embedded" is broken.
The bug was a side effect of WL#5030 (fix header files) and
WL#5161 (CMake).

The problem was that CMake-generated config.h (and my_config.h
as a copy of it) had a header guard. GNU autotools-generated
[my_]config.h did not. During WL#5030 the order of header files
was changed, so the following started to happen (using GNU autotools,
in embedded server):
  - my_config.h included, defining HAVE_OPENSSL
  - my_global.h included, un-defining  HAVE_OPENSSL
  - zlib.h included, including config.h,
    defining HAVE_OPENSSL again.

The fix is to change the order of header file, moving zlib.h
to the top of the header list. More proper fix would be to wrap
unguarded auto-generated [my_]config.h by guarded non-generated
header file.
2010-04-21 23:58:54 +04:00
Daniel Fischer
50edf454b1 Merge 2010-04-21 14:58:09 +02:00
Luis Soares
ddb5d63346 BUG#52868: Wrong handling of NULL value during update, replication out
of sync

In RBR, sometimes the table->s->last_null_bit_pos can be zero. This
has impact at the slave when it compares records fetched from the
storage engine against records in the binary log event. If
last_null_bit_pos is zero the slave, while comparing in
log_event.cc:record_compare function, would set all bits in the last
null_byte to 1 (assumed all 8 were unused) . Thence it would loose the
ability to distinguish records that were similar in contents except
for the fact that some field was null in one record, but not in the
other. Ultimately this would cause wrong matches, and in the specific
case depicted in the bug report the same record would be updated
twice, resulting in a lost update.

Additionally, in the record_compare function the slave was setting the
X bit unconditionally. There are cases that the X bit does not exist
in the record header. This could also lead to wrong matches between
records.

We fix both by conditionally resetting the bits: (i) unused null_bits
are set if last_null_bit_pos > 0; (ii) X bit is set if
HA_OPTION_PACK_RECORD is in use.
2010-04-21 13:47:55 +01:00
Jon Olav Hauglid
da1fbb375e merge from mysql-trunk-bugfixing 2010-04-21 08:50:58 +02:00
Mats Kindahl
26d34c0324 Merging with mysql-trunk-bugfixing 2010-04-21 08:15:10 +02:00
Mats Kindahl
f96694f9c7 WL#5030: Splitting mysql_priv.h
Removing traces of mysql_priv.h from comments and other
non-source files that were missed before.
2010-04-21 00:29:30 +02:00
Kristofer Pettersson
f62105453b automerge 2010-04-20 20:19:20 +02:00
Jonathan Perkin
c6c992e1cb Fix Windows data directory, from wlad. 2010-04-20 19:58:54 +02:00
Kristofer Pettersson
9d63e36ca7 Bug#50373 --secure-file-priv=""
Correcting a patch misstake. The converted file path is placed in 'buff' not in opt_secure_file_priv.
2010-04-20 16:17:34 +02:00
Alfranio Correia
9ba731c299 BUG#51894 Replication failure with SBR on DROP TEMPORARY TABLE inside a
transaction
BUG#52616 Temp table prevents switch binlog format from STATEMENT to ROW

Before the WL#2687 and BUG#46364, every non-transactional change that happened
after a transactional change was written to trx-cache and flushed upon
committing the transaction. WL#2687 and BUG#46364 changed this behavior and
non-transactional changes are now written to the binary log upon committing
the statement.

A binary log event is identified as transactional or non-transactional through
a flag in the Log_event which is set taking into account the underlie storage
engine on what it is stems from. In the current bug, this flag was not being
set properly when the DROP TEMPORARY TABLE was executed.

However, while fixing this bug we figured out that changes to temporary tables
should be always written to the trx-cache if there is an on-going transaction.
Otherwise, binlog events in the reversed order would be produced.

Regarding concurrency, keeping changes to temporary tables in the trx-cache is
also safe as temporary tables are only visible to the owner connection.

In this patch, we classify the following statements as unsafe:
   1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp

   2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam

   3 - CREATE TEMPORARY TABLE t_myisam_temp SELECT * FROM t_myisam

On the other hand, the following statements are classified as safe:

   1 - INSERT INTO t_innodb SELECT * FROM t_myisam_temp

   2 - INSERT INTO t_myisam_temp SELECT * FROM t_innodb

The patch also guarantees that transactions that have a DROP TEMPORARY are
always written to the binary log regardless of the mode and the outcome:
commit or rollback. In particular, the DROP TEMPORARY is extended with the
IF EXISTS clause when the current statement logging format is set to row.

Finally, the patch allows to switch from STATEMENT to MIXED/ROW when there
are temporary tables but the contrary is not possible.
2010-04-20 10:10:43 +01:00
Jon Olav Hauglid
f2587df7ba merge from mysql-trunk-bugfixing 2010-04-20 10:51:50 +02:00
Staale Smedseng
06f8e3f975 Bug#51591 deadlock in the plugins+status+variables
Unlocking/locking of LOCK_plugin in ha_ndbcluster.cc not 
needed anymore (but missing from the initial patch).
2010-04-19 15:48:37 +02:00
Jon Olav Hauglid
b12af816d5 Additional test coverage for
Bug#30977 Concurrent statement using stored function and
          DROP FUNCTION breaks SBR
Bug#48246 assert in close_thread_table
2010-04-19 15:35:13 +02:00
Alexey Kopytov
ee09f97211 Manual merge of mysql-5.1-bugteam to
mysql-trunk-merge.

Conflicts:

Text conflict in sql/sql_priv.h
2010-04-19 16:09:44 +04:00
Alfranio Correia
de3e233b8a auto-merge mysql-trunk-bugfixing (local) --> mysql-trunk-bugfixing 2010-04-19 12:05:07 +01:00
Joerg Bruehe
8dcbf6e20c Merge the changes of the 5.5.3-m3 release build
back into the development branches.
2010-04-18 15:32:05 +02:00
Kristofer Pettersson
f394543181 Automerge 2010-04-16 16:56:16 +02:00
Kristofer Pettersson
2a37d531be Bug#50373 --secure-file-priv=""
The server variable opt_secure_file_priv wasn't
normalized properly and caused the operations
LOAD DATA INFILE .. INTO TABLE ..
and
SELECT load_file(..)
to do different interpretations of the 
--secure-file-priv option.

The patch moves code to the server initialization
routines so that the path always is normalized
once and only once.

It was also intended that setting the option
to an empty string should be equal to 
lifting all previously set restrictions. This
is also fixed by this patch.
2010-04-16 16:10:47 +02:00
Staale Smedseng
6156581e07 Bug#51591 deadlock in the plugins+status+variables
Potential deadlock situation involving LOCK_plugin,
LOCK_global_system_variables and LOCK_status.
      
This patch backports the fix from next-mr, unlocking
LOCK_plugin before calling plugin->init() and
add_status_vars().
2010-04-16 15:02:23 +02:00
Sergey Glukhov
0d242648b5 Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings
Arg_comparator initializes 'comparators' array in case of
ROW comparison and does not free this array on destruction.
It leads to memory leaks.
The fix:
-added Arg_comparator::cleanup() method which frees
 'comparators' array.
-added Item_bool_func2::cleanup() method which calls 
 Arg_comparator::cleanup() method
2010-04-16 16:42:34 +05:00
Luis Soares
b5c258a829 automerge: merged bug clone into latest mysql-5.1-bugteam. 2010-04-16 01:59:21 +01:00
Luis Soares
697da8cf16 Automerge: merged bug bundle from bug report into latest
mysql-trunk-bugfixing.
2010-04-16 00:56:26 +01:00
Jon Olav Hauglid
1a1a96e7af Bug #47459 Assertion in Diagnostics_area::set_eof_status on OPTIMIZE TABLE
This assertion could be triggered during execution of OPTIMIZE TABLE for
InnoDB tables. As part of optimize for InnoDB tables, the table is recreated
and then opened again. If the reopen failed for any reason, the assertion
would be triggered. This could for example be caused by a concurrent DROP
TABLE executed by a different connection. The reason for the assertion was
that any failures during reopening were ignored.

This patch fixes the problem by making sure that the result of reopening the
table is checked and that any error messages are sent to the client.

Test case added to innodb_mysql_sync.test.
2010-04-15 18:53:57 +02:00
Sergey Vojtovich
a2ed9137cc Merge fixes for BUG46587 and BUG47059 to trunk-bugfixing. 2010-04-15 13:36:36 +04:00
Sergey Vojtovich
1b12f4c233 BUG#47059 - In audit plugin I cannot see the event subclasses,
e.g.MYSQL_AUDIT_GENERAL_ERROR

General audit API (MYSQL_AUDIT_GENERAL_CLASS) didn't expose event
subclass to plugins.

This patch exposes event subclass to plugins via
struct mysql_event_general::event_subclass.

This change is not compatible with existing general audit plugins.
Audit interface major version has been incremented.
2010-04-15 13:05:17 +04:00
Sergey Vojtovich
2fe708727f Merge fix for BUG39053 to 5.1-bugteam. 2010-04-14 15:53:43 +04:00
Sergey Vojtovich
b89feb5b28 BUG#39053 - UNISTALL PLUGIN does not allow the storage engine
to cleanup open connections

It was possible to UNINSTALL storage engine plugin when binding
between THD object and storage engine is still active (e.g. in
the middle of transaction).

To avoid unclean deactivation (uninstall) of storage engine plugin
in the middle of transaction, additional storage engine plugin
lock is acquired by thd_set_ha_data().

If ha_data is not null and storage engine plugin was not locked
by thd_set_ha_data() in this connection before, storage engine
plugin gets locked.

If ha_data is null and storage engine plugin was locked by
thd_set_ha_data() in this connection before, storage engine
plugin lock gets released.

If handlerton::close_connection() didn't reset ha_data, server does
it immediately after calling handlerton::close_connection().

Note that this is just a framework fix, storage engines must switch
to thd_set_ha_data() from thd_ha_data() if they want to see fit.
2010-04-14 13:53:59 +04:00