Commit graph

25778 commits

Author SHA1 Message Date
Kristofer Pettersson
f9af124e7d merge 2009-11-20 21:56:43 +01:00
Kristofer Pettersson
3596983d7a automerge 2009-11-20 16:24:48 +01:00
Kristofer Pettersson
0a68603058 Bug#45613 handle failures from my_hash_insert
Not all my_hash_insert() calls are checked for return value.

This patch adds appropriate checks and failure responses
where needed.


mysys/hash.c:
  * Debug hook for testing failures in my_hash_insert()
2009-11-20 16:18:01 +01:00
Vladislav Vaintroub
ff3b424565 merge 2009-11-20 14:20:01 +01:00
Kristofer Pettersson
5181325c27 automerge 2009-11-20 13:57:31 +01:00
Kristofer Pettersson
41085809c3 Bug#39253 Large query cache still freezes server after fix for bug #21074
This patch introduce a limit on the time the query cache can
block with a lock on SELECTs.

Other operations which causes a change in the table
data will still be blocked.


sql/sql_cache.cc:
  * Introduced a timeout value for the qc lock when entering send_result_to_client()
  and store_query() methods.
sql/sql_cache.h:
  * New signature for Query_cache::try_lock()
2009-11-20 13:49:06 +01:00
Vladislav Vaintroub
26a37b36ef Bug#47571 : idle named pipe connection is unkillable
implement Davi's review suggestions (post-push fixes)


include/violite.h:
  Use official abbreviation for milliseconds (ms)
sql/mysqld.cc:
  Fix formatting
  Add error handling for the case of CreateEvent error
vio/vio.c:
  Use official abbreviation for milliseconds(ms)
  Remove superfluous memset
  Fix formatting
vio/viosocket.c:
  Use official abbreviation for milliseconds (ms)
  Use size_t  datatype instead of int in pipe_complete_io
2009-11-20 13:09:50 +01:00
Christopher Powers
c74609b126 Bug #48739 MySQL crashes on specific INTERVAL in select query
Fixed crash caused by x64 int/long incompatibility introduced
in Bug #29125.

sql/item_timefunc.cc:
  Fixed crash caused by int/long incompatibility on x64 systems.
  
  Changed two "uint" casts and a "long" declartion to "int" in order to
  ensure that the integer sign is preserved.
  
  See Bug #48739 for details.
2009-11-19 16:49:13 -06:00
Georgi Kodinov
405c9310cf Bug #48665: sql-bench's insert test fails due to wrong result
When merging ranges during calculation of the result of OR
to two range sets the current range may be obsoleted by the 
resulting merged range.
The first overlapping range can be obsoleted as well.

Fixed by moving the pointer to the first overlapping range to the
pointer of the resulting union range.
Added few comments at key places in key_or().
2009-11-19 18:26:19 +02:00
Sven Sandberg
2f78abd21b BUG#47995: Mark system functions as unsafe
Problem: Some system functions that could return different values on
master and slave were not marked unsafe. In particular:
 GET_LOCK
 IS_FREE_LOCK
 IS_USED_LOCK
 MASTER_POS_WAIT
 RELEASE_LOCK
 SLEEP
 SYSDATE
 VERSION
Fix: Mark these functions unsafe.


mysql-test/extra/rpl_tests/rpl_stm_000001.test:
  - The test does not work in mixed mode any more, since it tries to
    simulate an error in the sql thread in a query that uses get_lock.
    Since get_lock now causes the query to be logged in row format,
    the error didn't happen. Hence, we now force statement mode.
  - Warnings must be disabled when the unsafe query is issued.
  - Replaced some save_master_pos+connection slave+sync_with_master
    by sync_slave_with_master.
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  updated result file
mysql-test/suite/binlog/r/binlog_stm_row.result:
  updated result file
mysql-test/suite/binlog/r/binlog_unsafe.result:
  updated result file
mysql-test/suite/binlog/t/binlog_killed.test:
  binlog_killed only works in statement format now, since
  it switches to row mode in mixed mode.
mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam.test:
  suppress warnings for unsafe statements
mysql-test/suite/binlog/t/binlog_stm_row.test:
  - Suppress warnings in test that causes warnings.
  - The test sets binlog format explicitly, so no need to execute it
    twice.
mysql-test/suite/binlog/t/binlog_unsafe.test:
  Added test for all unsafe system functions. This test also includes
  system functions that were unsafe prior to BUG#47995.
mysql-test/suite/rpl/r/rpl_err_ignoredtable.result:
  updated result file
mysql-test/suite/rpl/r/rpl_get_lock.result:
  updated result file
mysql-test/suite/rpl/r/rpl_nondeterministic_functions.result:
  new result file
mysql-test/suite/rpl/r/rpl_stm_000001.result:
  updated result file
mysql-test/suite/rpl/r/rpl_trigger.result:
  updated result file
mysql-test/suite/rpl/t/rpl_err_ignoredtable.test:
  - suppress warnings for unsafe statement
  - replaced save_master_pos+connection slave+sync_with_master
    with sync_slave_with_master
mysql-test/suite/rpl/t/rpl_get_lock.test:
  update test case that causes new warnings
mysql-test/suite/rpl/t/rpl_nondeterministic_functions.test:
  Added new test case for nondeterministic functions.
mysql-test/suite/rpl/t/rpl_trigger.test:
  update test case that causes new warnings
sql/item_create.cc:
  Marked some system functions unsafe.
sql/item_strfunc.cc:
  Clarified comment related to this bug.
sql/sql_yacc.yy:
  Marked sysdate unsafe.
2009-11-18 15:50:31 +01:00
Mattias Jonsson
f6ec131ff9 merge 2009-11-18 11:21:26 +01:00
Magne Mahre
58f4345957 merge 2009-11-18 10:45:32 +01:00
Magne Mahre
3987c7ac4b Bug #46425 crash in Diagnostics_area::set_ok_status , empty statement,
DELETE IGNORE

The ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG error was set in the
diagnostics area when it happened, but the DELETE cleanup code
never checked for a non-fatal error condition, thus trying to
set diag.area to "ok".  This triggered an assert checking that
the diag.area was empty.

The fix was to test if there existed a non-fatal error condition
(thd->is_error() before ok'ing the operation.
2009-11-18 10:32:03 +01:00
Jon Olav Hauglid
41ba429286 Bug #47682 strange behaviour of INSERT DELAYED
The problem was a "self-deadlock" if the connection issuing INSERT DELAYED
had both the global read lock (FLUSH TABLES WITH READ LOCK) and LOCK TABLES
mode active. The table being inserted into had to be different from the 
table(s) locked by LOCK TABLES.

For INSERT DELAYED, the connection thread waits until the handler thread has
opened and locked its table before returning. But since the global read lock
was active, the handler thread would be unable to lock and would wait for the
global read lock to go away.

So the handler thread would be waiting for the connection thread to release
the global read lock while the connection thread was waiting for the handler
thread to lock the table. This gave a "self-deadlock" (same connection,
different threads).

The deadlock would only happen if we also had LOCK TABLES mode since the
INSERT otherwise will try to get protection against global read lock before
starting the handler thread. It will then notice that the global read lock
is owned by the same connection and report ER_CANT_UPDATE_WITH_READLOCK.

This patch removes the deadlock by reporting ER_CANT_UPDATE_WITH_READLOCK
also if we are inside LOCK TABLES mode.

Test case added to delayed.test.
2009-11-18 10:02:21 +01:00
Mattias Jonsson
3faaf33333 merge 2009-11-17 22:51:49 +01:00
Mattias Jonsson
7a6ab645ab merge 2009-11-17 22:48:28 +01:00
Mattias Jonsson
98fd304278 backport of bug#45904 from mysql-pe to 5.1
sql/sql_partition.cc:
  Bug#45904 Used list_of_part_fields instead of list_of_subpart_fields to discover if KEY subpartitioning => caused failure when charset=utf8 even for subpartitioning by key, would also allow for subpartitioning by hash with utf8 erroneously
2009-11-17 22:47:34 +01:00
Mattias Jonsson
e6d02a127e merge 2009-11-17 16:24:46 +01:00
Jorgen Loland
a120e969a8 Bug#48052: Valgrind warning - uninitialized value in
init_read_record() - (records.cc:274)
      
Item_cond::used_tables_cache was accessed in
records.cc#init_read_record() without being initialized. It had
not been initialized because it was wrongly assumed that the
Item's variables would not be accessed, and hence
quick_fix_field() was used instead of fix_fields() to save a few
CPU cycles at creation time.

The fix is to properly initilize the Item by replacing
quick_fix_field() with fix_fields().


mysql-test/r/select.result:
  Add test for BUG#48052
mysql-test/t/select.test:
  Add test for BUG#48052
sql/sql_select.cc:
  Properly initialize Item_cond_and by calling fix_fields (instead of quick_fix_field) when the Item that "ANDs" WHERE clause conditions with HAVING clause conditions is created.
2009-11-13 12:22:39 +01:00
Alexey Kopytov
cf872354a8 Automerge. 2009-11-12 20:14:07 +03:00
Alexey Kopytov
b31c544eec Automerge. 2009-11-12 20:13:08 +03:00
Alexey Kopytov
fb2e17903f Fixed a gcc warning introduced by the patch for bug #48475. 2009-11-12 20:11:33 +03:00
Georgi Kodinov
4519d5e4f1 Bug #48458: simple query tries to allocate enormous amount of
memory

The server was doing a bad class typecast causing setting of 
wrong value for the maximum number of items in an internal
structure used in equality propagation.
Fixed by not doing the wrong typecast and asserting the type
of the Item where it should be done.
2009-11-09 16:09:46 +02:00
Georgi Kodinov
ddd90017e7 Bug #42760: Select doesn't return desired results when we have null
values
 
 We should re-set the access method functions when changing the access
 method when switching to another index to avoid sorting.
 
 Fixed by doing a little re-engineering : encapsulating all the function
 assignment into a special function and calling it when flipping the 
 indexes.
2009-11-10 10:21:41 +02:00
Mattias Jonsson
785b5c4e7a Bug#48276: can't add column if subpartition exists
Bug when setting up default partitioning,
used an uninitialized variabe.

mysql-test/r/partition.result:
  Bug#48276: can't add column if subpartition exists
  
  Added result
mysql-test/t/partition.test:
  Bug#48276: can't add column if subpartition exists
  
  Added test
sql/sql_partition.cc:
  Bug#48276: can't add column if subpartition exists
  
  even if is_create_table_ind was set, one tried to set no_subparts
  with the unitialized no_parts local variable.
  
  Fixed by rearrange the code to be to only execute
  the statements when is_create_table_ind was not set.
2009-11-09 11:26:01 +01:00
Evgeny Potemkin
5594215c58 Auto-merged fix for the bug#34384. 2009-11-06 22:42:24 +03:00
Evgeny Potemkin
c81e23457a Bug#34384: Slow down on constant conversion.
When values of different types are compared they're converted to a type that
allows correct comparison. This conversion is done for each comparison and
takes some time. When a constant is being compared it's possible to cache the
value after conversion to speedup comparison. In some cases (large dataset,
complex WHERE condition with many type conversions) query might be executed
7% faster.

A test case isn't provided because all changes are internal and isn't visible
outside.

The behavior of the Item_cache is changed to cache values on the first request
of cached value rather than at the moment of storing item to be cached.
A flag named value_cached is added to the Item_cache class. It's set to TRUE
when cache holds the value of the last stored item.
Function named cache_value() is added to the Item_cache class and derived classes.
This function actually caches the value of the saved item.
Item_cache_xxx::store functions now only store item to be cached and set
value_cached flag to FALSE.
Item_cache_xxx::val_xxx functions are changed to call cache_value function
prior to returning cached value if value_cached is FALSE.
The Arg_comparator::set_cmp_func function now calls cache_converted_constant
to cache constants if they need a type conversion.
The Item_cache::get_cache function is overloaded to allow setting of the
cache type.
The cache_converted_constant function is added to the Arg_comparator class.
It checks whether a value can and should be cached and if so caches it.

sql/item.cc:
  Bug#34384: Slow down on constant conversion.
  Function named cache_value() is added to the Item_cache class and derived classes.
  This function actually caches the value of the saved item.
  Item_cache_xxx::store functions now only store item to be cached and set
  value_cached flag to FALSE.
  Item_cache_xxx::val_xxx functions are changed to call cache_value function
  prior to returning cached value if value_cached is FALSE.
  The Item_cache::get_cache function is overloaded to allow setting of the
  cache type.
sql/item.h:
  Bug#34384: Slow down on constant conversion.
  A flag named value_cached is added to the Item_cache class. It's set to TRUE
  when we need to start caching values when the store method is called.
  Function named cache_value() is added to the Item_cache class and derived classes.
sql/item_cmpfunc.cc:
  Bug#34384: Slow down on constant conversion.
  A helper function cache_converted_constant is added to the Arg_comparator class.
  It checks whether a given item can and should be cached and caches it if so.
  The Arg_comparator::set_cmp_func function now calls cache_converted_constant
  to cache constants if they need a type conversion.
sql/item_cmpfunc.h:
  Bug#34384: Slow down on constant conversion.
  The cache_converted_constant function is added to the Arg_comparator class.
  It checks whether a value can and should be cached and if so caches it.
sql/item_subselect.cc:
  Bug#34384: Slow down on constant conversion.
  Force immediate caching of subselect result.
sql/item_xmlfunc.cc:
  Bug#34384: Slow down on constant conversion.
sql/sp_rcontext.cc:
  Bug#34384: Slow down on constant conversion.
  Force immediate caching of values of an SP CASE function.
2009-11-06 22:34:25 +03:00
Alexey Kopytov
ee049964df Automerge. 2009-11-06 17:56:58 +03:00
Alexey Kopytov
05c4f3f396 Automerge. 2009-11-06 17:54:19 +03:00
Alexey Kopytov
39f9a3ffd0 Bug #48475: DISTINCT is ignored with GROUP BY WITH ROLLUP and
only const tables

The problem was caused by two shortcuts in the optimizer that
are inapplicable in the ROLLUP case.

Normally in a case when only const tables are involved in a
query, DISTINCT clause can be safely optimized away since there
may be only one row produced by the join. Similarly, we don't
need to create a temporary table to resolve DISTINCT/GROUP
BY/ORDER BY. Both of these are inapplicable when the WITH
ROLLUP modifier is present.

Fixed by disabling the said optimizations for the WITH ROLLUP
case.

mysql-test/r/olap.result:
  Added a test case for bug #48475.
mysql-test/t/olap.test:
  Added a test case for bug #48475.
sql/sql_select.cc:
  Disabled const-only table optimizations for the WITH ROLLUP
  case.
2009-11-06 09:44:01 +03:00
Georgi Kodinov
43d7fb43cd Bug #46175: NULL read_view and consistent read assertion
The SE API requires mysql to notify the storage engine that
it's going to read certain tables at the beginning of the 
statement (by calling start_stmt(), store_lock() or
external_lock()).
These are typically called by the lock_tables(). 
However SHOW CREATE TABLE is not pre-locking the tables
because it's not expected to access the data at all.
But for some view definitions (that include comparing a
date/datetime/timestamp column to a string returning
scalar subquery) the JOIN::prepare may still access data
when materializing the scalar non-correlated subquery
in Arg_comparator::can_compare_as_dates().
Fixed by not materializing the subquery when the function
is called in a SHOW/EXPLAIN/CREATE VIEW
2009-11-04 13:54:28 +02:00
unknown
b958fc655f Bug #34739 unexpected binlog file name when --log-bin is set to a directory name
If --log-bin is set to a directory name with the trailing 'FN_LIBCHAR', 
which will be '/' on Unix like systems, and '\\' on Windows like systems. 
the basename of the binlog is empty so that the created files named 
'.000001' and '.index'. It is not expected. 
The same thing happened to --log-bin-index, --relay-log and 
--relay-log-index options.

To resolve the problem, in these cases the program should report an error 
and abort.


sql/mysqld.cc:
  Added a check for the value of the --log-bin and --log-bin-index arguments, 
  if it's a directory, reports an error and aborts.
sql/rpl_rli.cc:
  Added a check for the value of the --relay-log and --relay-log-index arguments, 
  if it's a directory, reports an error and aborts.
2009-11-05 14:07:31 +08:00
Konstantin Osipov
cb0cca8655 A fix and a test case for
Bug#41756 "Strange error messages about locks from InnoDB".
      
In JT_EQ_REF (join_read_key()) access method, 
don't try to unlock rows in the handler, unless certain that 
a) they were locked
b) they are not used.

Unlocking of rows is done by the logic of the nested join loop,
and is unaware of the possible caching that the access method may
have. This could lead to double unlocking, when a row
was unlocked first after reading into the cache, and then 
when taken from cache, as well as to unlocking of rows which
were actually used (but taken from cache).
      
Delegate part of the unlocking logic to the access method,
and in JT_EQ_REF count how many times a record was actually 
used in the join. Unlock it only if it's usage count is 0.

Implemented review comments.

mysql-test/r/innodb_lock_wait_timeout_1.result:
  Update results (Bug41756).
mysql-test/t/innodb_lock_wait_timeout_1.test:
  Add a test case (Bug#41756).
sql/item_subselect.cc:
  Complete struct READ_RECORD initialization with a new
  member to unlock records.
sql/records.cc:
  Extend READ_RECORD API with a method to unlock read records.
sql/sql_select.cc:
  In JT_EQ_REF (join_read_key()) access method, 
  don't try to unlock rows in the handler, unless certain that 
  a) they were locked
  b) they are not used.
sql/sql_select.h:
  Add members to TABLE_REF to count TABLE_REF buffer usage count.
sql/structs.h:
  Update declarations.
2009-11-03 20:45:52 +03:00
Konstantin Osipov
06c9d62a9f A fix and a test case for
Bug#41756 "Strange error messages about locks from InnoDB".

In JT_EQ_REF (join_read_key()) access method,
don't try to unlock rows in the handler, unless certain that
a) they were locked
b) they are not used.

Unlocking of rows is done by the logic of the nested join loop,
and is unaware of the possible caching that the access method may
have. This could lead to double unlocking, when a row
was unlocked first after reading into the cache, and then
when taken from cache, as well as to unlocking of rows which
were actually used (but taken from cache).

Delegate part of the unlocking logic to the access method,
and in JT_EQ_REF count how many times a record was actually
used in the join. Unlock it only if it's usage count is 0.

Implemented review comments.


mysql-test/r/bug41756.result:
  Add result file (Bug#41756)
mysql-test/t/bug41756-master.opt:
  Use --innodb-locks-unsafe-for-binlog, as in 5.0 just
  using read_committed isolation is not sufficient to 
  reproduce the bug.
mysql-test/t/bug41756.test:
  Add a test file (Bug#41756)
sql/item_subselect.cc:
  Complete struct READ_RECORD initialization with a new
  member to unlock records.
sql/records.cc:
  Extend READ_RECORD API with a method to unlock read records.
sql/sql_select.cc:
  In JT_EQ_REF (join_read_key()) access method,
  don't try to unlock rows in the handler, unless certain that
  a) they were locked
  b) they are not used.
sql/sql_select.h:
  Add members to TABLE_REF to count TABLE_REF buffer usage count.
sql/structs.h:
  Update declarations.
2009-11-03 19:58:54 +03:00
Jorgen Loland
bec35067d3 Bug#48177 - SELECTs with NOT IN subqueries containing NULL
values return too many records

WHERE clauses with "outer_value_list NOT IN subselect" were
handled incorrectly if the outer value list contained multiple 
items where at least one of these could be NULL. The first 
outer record with NULL value was handled correctly, but if a 
second record with NULL value existed, the optimizer would 
choose to reuse the result it got on the last execution of the 
subselect. This is incorrect if the outer value list has 
multiple items.
     
The fix is to make Item_in_optimizer::val_int (in 
item_cmpfunc.cc) reuse the result of the latest execution
for NULL values only if all values in the outer_value_list 
are NULL.


mysql-test/r/subselect3.result:
  Added test for BUG#48177
mysql-test/t/subselect3.test:
  Added test for BUG#48177
sql/item_cmpfunc.cc:
  Make Item_in_optimizer::val_int (in item_cmpfunc.cc) reuse the result of the latest execution for NULL values only if all values in the outer_value_list are NULL.
2009-11-03 13:48:59 +01:00
unknown
9519c8e597 Manual Merge 2009-11-03 18:20:08 +08:00
unknown
9819885177 BUG#48216 Replication fails on all slaves after upgrade to 5.0.86 on master
When a sessione is closed, all temporary tables of the session are automatically 
dropped and are binlogged. But it will be binlogged with wrong database names when
the length of the temporary tables' database names are greater than the 
length of the current database name or the current database is not set.

Query_log_event's db_len is forgot to set when Query_log_event's db is set.
This patch wrote code to set db_len immediately after db has set.
2009-11-03 17:00:41 +08:00
Mattias Jonsson
b35feb1ed0 Bug#46923: select count(*) from partitioned table fails with
ONLY_FULL_GROUP_BY

Problem was that during checking and preparation of the
partitioining function as a side effect in fix_fields
the full_group_by_flag was changed.

Solution was to set it back to its original value after
calling fix_fields.

Updated patch, to also exclude allow_sum_func from being
affected of fix_fields, as requested by reviewer.

mysql-test/r/partition.result:
  Bug#46923: select count(*) from partitioned table fails with
  ONLY_FULL_GROUP_BY
  
  Updated result file
mysql-test/t/partition.test:
  Bug#46923: select count(*) from partitioned table fails with
  ONLY_FULL_GROUP_BY
  
  Extended test case to cover this bug
sql/sql_partition.cc:
  Bug#46923: select count(*) from partitioned table fails with
  ONLY_FULL_GROUP_BY
  
  Resetting full_group_by_flag and allow_sum_func
  back to their original values,
  not conflicting with the sql_mode 'ONLY_FULL_GROUP_BY'
2009-11-03 09:22:01 +01:00
Davi Arnaut
1ca80ed19e Bug#48370: Absolutely wrong calculations with GROUP BY and decimal fields when using IF
Bug#45261: Crash, stored procedure + decimal

Revert fix for Bug#45261 due to unforeseen bugs.
2009-11-02 09:21:39 -02:00
Vladislav Vaintroub
b51777484f merge 2009-11-03 01:52:57 +01:00
Vladislav Vaintroub
e080080711 Bug#47571: idle named pipe connection is unkillable
Bug#31621: Windows server hanging during shutdown using named pipes 
           and idle connection
            
Problem: when idle pipe connection is forcefully closed with KILL
statement or when the server goes down, thread that is closing connection
would hang infinitely in CloseHandle(). The reason for the hang is that 
named pipe operations are performed synchronously. In this mode all IOs
on pipe are serialized, that is CloseHandle() will not abort ReadFile() 
in another thread, but wait for ReadFile() to complete.
            
The fix implements asynchrnous mode for named pipes, where operation of file
are not synchronized. Read/Write operation would fire an async IO and wait for
either IO completion or timeout.
            
Note, that with this patch timeouts are properly handled for named pipes.
      
Post-review: Win32 timeout code has been fixed for named pipes and shared
memory. We do not store pointer to NET in vio structure, only the read and 
write timeouts.


include/violite.h:
  Add pipe_overlapped to Vio structure for async IO for named pipes.
sql-common/client.c:
  Use asynchronous pipe IO.
sql/mysqld.cc:
  Use asynchronous pipe IO.
vio/vio.c:
  -Refactor timeouts for win32 protocols: shared memory and named pipes.
  Store read/write timeout in VIO structure, instead of storing pointer
  to NET. New function vio_win32_timeout called indirectly via 
  vio_timeout changes these values.
vio/vio_priv.h:
  Remove vio_ignore_timeout.
  Add vio_win32_timeout to be used for named pipes and shared memory.
vio/viosocket.c:
  Use async IO for named pipes.
  After issuing IO, wait for either IO completion, pipe_close_event
  or timeout.
          
  Refactor timeouts for named pipe and shared memory.
2009-11-02 23:19:58 +01:00
Luis Soares
b4eead7e20 Auto-merging mysql-5.1-bugteam-gca into mysql-5.1-bugteam latest. 2009-11-02 16:02:55 +00:00
Luis Soares
d699ba3b74 Auto-merging bzr bundle from bug report in mysql-5.1-bugteam-gca 2009-11-02 15:57:25 +00:00
Martin Hansson
740b7c4e36 Bug#47925: regression of range optimizer and date comparison in 5.1.39!
When a query was using a DATE or DATETIME value formatted
using any other separator characters beside hyphen '-', a
query with a greater-or-equal '>=' condition matching only
the greatest value in an indexed column, the result was
empty if index range scan was employed.

The range optimizer got a new feature between 5.1.38 and
5.1.39 that changes a greater-or-equal condition to a
greater-than if the value matching that in the query was not
present in the table. But the value comparison function
compared the dates as strings instead of dates.

The bug was fixed by splitting the function
get_date_from_str in two: One part that parses and does
error checking. This function is now visible outside the
module. The old get_date_from_str now calls the new
function.


mysql-test/r/range.result:
  Bug#47925: Test result
mysql-test/t/range.test:
  Bug#47925: Test case
sql/item.cc:
  Bug#47925: Fix + some edit on the comments
sql/item.h:
  Bug#47925: Changed function signature
sql/item_cmpfunc.cc:
  Bug#47925: Split function in two
sql/item_cmpfunc.h:
  Bug#47925: Declaration of new function
sql/opt_range.cc:
  Bug#47925: Added THD to function call
sql/time.cc:
  Bug#47925: Added microsecond comparison
2009-11-02 13:24:07 +01:00
Tatiana A. Nurnberg
09c50b6303 auto-merge 2009-11-02 00:13:13 -08:00
Luis Soares
2ad0d6910c BUG#42829: manually merged approved bzr bundle from bug report.
Conflicts
=========

Text conflict in sql/sql_class.cc
1 conflicts encountered.
2009-11-01 23:13:11 +00:00
Sergey Vojtovich
d395e824ad Merge fix for BUG#43171. 2009-10-31 14:50:25 +04:00
Alexey Kopytov
3df1ae7a1a Automerge. 2009-10-30 19:16:29 +03:00
Alexey Kopytov
23cbd659a0 Automerge. 2009-10-30 18:59:06 +03:00
Alexey Kopytov
b67cdaa351 Bug #48131: crash group by with rollup, distinct, filesort,
with temporary tables

There were two problems the test case from this bug was
triggering:

1. JOIN::rollup_init() was supposed to wrap all constant Items
into another object for queries with the WITH ROLLUP modifier
to ensure they are never considered as constants and therefore
are written into temporary tables if the optimizer chooses to
employ them for DISTINCT/GROUP BY handling.

However, JOIN::rollup_init() was called before
make_join_statistics(), so Items corresponding to fields in
const tables could not be handled as intended, which was
causing all kinds of problems later in the query execution. In
particular, create_tmp_table() assumed all constant items
except "hidden" ones to be removed earlier by remove_const()
which led to improperly initialized Field objects for the
temporary table being created. This is what was causing crashes
and valgrind errors in storage engines.

2. Even when the above problem had been fixed, the query from
the test case produced incorrect results due to some
DISTINCT/GROUP BY optimizations being performed by the
optimizer that are inapplicable in the WITH ROLLUP case.

Fixed by disabling inapplicable DISTINCT/GROUP BY optimizations
when the WITH ROLLUP modifier is present, and splitting the
const-wrapping part of JOIN::rollup_init() into a separate
method which is now invoked after make_join_statistics() when
the const tables are already known.

mysql-test/r/olap.result:
  Added a test case for bug #48131.
mysql-test/t/olap.test:
  Added a test case for bug #48131.
sql/sql_select.cc:
  1. Disabled inapplicable DISTINCT/GROUP BY optimizations when
  the WITH ROLLUP modifier is present.
  2. Split the const-wrapping part of JOIN::rollup_init() into a
  separate method.
sql/sql_select.h:
  Added rollup_process_const_fields() declaration.
2009-10-30 18:54:53 +03:00