Commit graph

355 commits

Author SHA1 Message Date
Michael Widenius
165eb1186c Added extra argument to longlong2str() to make it have same prototype is int2str()
Changed to use longlong10_to_str() instead of longlong2str() when base is 10 or -10 as former is much faster than later
Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit.

client/mysqltest.cc:
  longlong2str() -> longlong10_to_str()
include/m_string.h:
  Added extra argument to longlong2str() to make it have same prototype is int2str()
mysys/charset.c:
  Fixed compiler warning
mysys/mf_soundex.c:
  Fixed compiler warning
mysys/my_getopt.c:
  longlong2str() -> longlong10_to_str()
sql/create_options.cc:
  Fixed compiler warning
sql/item_strfunc.cc:
  Added extra argument to longlong2str
sql/opt_range.cc:
  longlong2str() -> longlong10_to_str()
sql/partition_info.cc:
  longlong2str() -> longlong10_to_str()
sql/slave.cc:
  longlong2str() -> longlong10_to_str()
sql/sql_bitmap.h:
  Added extra argument to longlong2str
sql/sql_partition.cc:
  Added extra argument to longlong2str
sql/sql_select.cc:
  longlong2str() -> longlong10_to_str()
sql/sql_show.cc:
  Added extra argument to longlong2str
storage/innodb_plugin/handler/ha_innodb.cc:
  Update to new parameters for longlong2str()
storage/maria/ma_dbug.c:
  longlong2str() -> longlong10_to_str()
storage/maria/maria_chk.c:
  Added extra argument to longlong2str
storage/myisam/mi_dbug.c:
  longlong2str() -> longlong10_to_str()
storage/myisam/myisamchk.c:
  Added extra argument to longlong2str
storage/xtradb/handler/ha_innodb.cc:
  Update to new parameters for longlong2str()
strings/longlong2str.c:
  Added extra argument to longlong2str() to make it have same prototype is int2str()
strings/my_vsnprintf.c:
  Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit.
  Added cast to get rid of compiler warnings
2010-08-07 15:27:23 +03:00
Michael Widenius
d042146e5b Merge with MariaDB 5.1.49
Removed references to HA_END_SPACE_KEY (which has been 0 for a long time)
2010-08-05 22:56:11 +03:00
Michael Widenius
e0a6b02c5d Merge with MySQL 5.1.49
Fixed Bug#52005 'JOIN_TAB->dependent' may be incorrectly propageted for multilevel outer joins' in a better way (patch from Sergey Petrunya)
2010-08-02 12:01:24 +03:00
Sergei Golubchik
ffc8f62b08 merge 5.1->5.2 2010-06-01 21:52:20 +02:00
Alexey Kopytov
c2ebb0ac88 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.

mysql-test/r/error_simulation.result:
  Added a test case for bug #42064.
mysql-test/t/error_simulation.test:
  Added a test case for bug #42064.
mysys/my_alloc.c:
  Added error injection code for the regression test.
mysys/my_malloc.c:
  Added error injection code for the regression test.
mysys/safemalloc.c:
  Added error injection code for the regression test.
sql/event_data_objects.cc:
  Use the new init() member function of Parser_state and check
  its return value to handle memory allocation failures.
sql/mysqld.cc:
  Added error injection code for the regression test.
sql/sp.cc:
  Use the new init() member function of Parser_state and check
  its return value to handle memory allocation failures.
sql/sql_lex.cc:
  Moved memory allocation from constructor to the separate init()
  member function.
  Added error injection code for the regression test.
sql/sql_lex.h:
  Moved memory allocation from constructor to the separate init()
  member function.
sql/sql_parse.cc:
  Use the new init() member function of Parser_state and check
  its return value to handle memory allocation failures.
sql/sql_partition.cc:
  Use the new init() member function of Parser_state and check
  its return value to handle memory allocation failures.
sql/sql_prepare.cc:
  Use the new init() member function of Parser_state and check
  its return value to handle memory allocation failures.
sql/sql_trigger.cc:
  Use the new init() member function of Parser_state and check
  its return value to handle memory allocation failures.
sql/sql_view.cc:
  Use the new init() member function of Parser_state and check
  its return value to handle memory allocation failures..
sql/thr_malloc.cc:
  Added error injection code for the regression test.
2010-05-21 15:23:48 +04:00
unknown
b1e00b6be8 Merge MySQL 5.1.46 into MariaDB.
Still two test failures to be solved: main.myisam and main.subselect.
2010-04-28 14:52:24 +02:00
Mattias Jonsson
5196beed02 Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
concurrent I_S query

There were two problem:
1) MYSQL_LOCK_IGNORE_FLUSH also ignored name locks
2) there was a race between abort_and_upgrade_locks and
   alter_close_tables
   (i.e. remove_table_from_cache and
    close_data_files_and_morph_locks)

Which allowed the table to be opened with MYSQL_LOCK_IGNORE_FLUSH flag
resulting in renaming a partition that was already in use,
which could cause the table to be unusable.

Solution was to not allow IGNORE_FLUSH to skip waiting for
a named locked table.

And to not release the LOCK_open mutex between the
calls to remove_table_from_cache and
close_data_files_and_morph_locks by merging the functions
abort_and_upgrade_locks and alter_close_tables.

mysql-test/suite/parts/r/partition_debug_sync_innodb.result:
  Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
  concurrent I_S query
  
  Added test result
mysql-test/suite/parts/t/partition_debug_sync_innodb-master.opt:
  Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
  concurrent I_S query
  
  Added test option
mysql-test/suite/parts/t/partition_debug_sync_innodb.test:
  Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
  concurrent I_S query
  
  Added test file
sql/authors.h:
  Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
  concurrent I_S query
  
  Time to be acknowledged :)
sql/ha_partition.cc:
  Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
  concurrent I_S query
  
  Added DEBUG_SYNC for deterministic testing
sql/mysql_priv.h:
  Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
  concurrent I_S query
  
  Renamed function since merging alter_close_tables into
  abort_and_upgrade_lock.
sql/sql_base.cc:
  Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
  concurrent I_S query
  
  Changed MYSQL_LOCK_IGNORE_FLUSH to not ignore name locks
  (open_placeholder).
  
  Merged alter_close_tables into abort_and_upgrade_locks
  (and added _and_close_table to the name)
  to not release LOCK_open between remove_table_from_cache
  and close_data_files_and_morph_locks.
  
  Added DEBUG_SYNC for deterministic testing.
sql/sql_partition.cc:
  Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
  concurrent I_S query
  
  Removed alter_close_tables, (merged it into
  abort_and_upgrad_lock) so that LOCK_open never is released
  between remove_table_from_cache and
  close_data_files_and_morph_locks.
sql/sql_show.cc:
  Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
  concurrent I_S query
  
  Added DEBUG_SYNC for deterministic testing
2010-03-17 15:10:41 +01:00
Mattias Jonsson
e62c30b5f8 merge 2010-03-12 11:52:38 +01:00
Mattias Jonsson
29b39e7a44 Bug#51830: Incorrect partition pruning on range partition
(regression)

Problem was that partition pruning did not exclude the
last partition if the range was beyond it
(i.e. not using MAXVALUE)

Fix was to not include the last partition if the
partitioning function value was not within the partition
range.

mysql-test/r/partition_innodb.result:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Updated result
mysql-test/r/partition_pruning.result:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Updated result
mysql-test/t/partition_innodb.test:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Added test for pruning in InnoDB, since it does not show
  for MyISAM due to 'Impossible WHERE noticed after reading
  const tables'.
mysql-test/t/partition_pruning.test:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Added test
sql/sql_partition.cc:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Also increase the partition id if not inside the last partition
  (and no MAXVALUE is defined).
  
  Added comments and DBUG_ASSERT.
2010-03-10 12:56:05 +01:00
unknown
c9dffa993a A number of after-merge fixes following merge of MySQL 5.1.44 into MariaDB.
Bug#46949: memory leak with failed alter table to create partitions based on extract()

Bug#51830: Incorrect partition pruning on range partition (regression)

Fixed valgrind failure in select_describe(), read of uninitialized 
  Item_subselect::eliminated.

PBXT test file updates to reflect changes done in MySQL.

mysql-test/suite/pbxt/r/partition_error.result:
  Result file update following MySQL 5.1.44 changes.
mysql-test/suite/pbxt/r/partition_pruning.result:
  Result file update following MySQL 5.1.44 changes.
mysql-test/suite/pbxt/t/partition_error.test:
  Test file update following MySQL 5.1.44 changes.
sql/item_subselect.cc:
    Fixed valgrind failure in select_describe(), read of uninitialized 
    Item_subselect::eliminated: 
    - it turns out we can call select_describe() without having fixed 
      subquery items for child subselects. These are not the kind of subqueries
      that we could eliminate, so the fix is to ensure that 
      item_subselect->eliminated==FALSE even before fix_fields is called.
      Also added code to reset item_subselect->eliminated back to FALSE in
      Item::reset() call.
sql/item_subselect.h:
    Fixed valgrind failure in select_describe(), read of uninitialized 
    Item_subselect::eliminated: 
    - it turns out we can call select_describe() without having fixed 
      subquery items for child subselects. These are not the kind of subqueries
      that we could eliminate, so the fix is to ensure that 
      item_subselect->eliminated==FALSE even before fix_fields is called.
      Also added code to reset item_subselect->eliminated back to FALSE in
      Item::reset() call.
sql/sql_partition.cc:
  Fix Bug#51830: Revert part of the patch for Bug#49742, which caused the regression.
sql/table.cc:
  Fix Bug#46949: memory leak in failed ALTER TABLE with partitioning.
2010-03-09 16:03:54 +01:00
Mattias Jonsson
48d986f511 Bug#50104: Partitioned table with just 1 partion works with fk
There was no check for foreign keys when altering partitioned
tables.

Added check for FK when altering partitioned tables.

mysql-test/r/partition_innodb.result:
  Bug#50104: Partitioned table with just 1 partion works with fk
  
  Updated test result
mysql-test/t/partition_innodb.test:
  Bug#50104: Partitioned table with just 1 partion works with fk
  
  Added test for adding FK on partitioned tables (both 1 and 2
  partitions)
sql/sql_partition.cc:
  Bug#50104: Partitioned table with just 1 partion works with fk
  
  Disabled adding foreign key when altering a partitioned table.
2010-03-04 12:29:22 +01:00
unknown
4bf849c23c Merge MySQL 5.1.44 into MariaDB. 2010-03-04 09:03:07 +01:00
Sergei Golubchik
f09ca00e08 merged 2010-03-15 12:51:23 +01:00
unknown
e5099a2c85 merge 5.1->5.2 2010-02-01 08:14:12 +02:00
He Zhenxing
2b16517522 Backport Bug#37148 to 5.1 2010-01-24 15:03:23 +08:00
Michael Widenius
d8ecbbe634 Merge with MySQL 5.1.42
- Marked a couple of tests with --big
- Fixed xtradb/handler/ha_innodb.cc to call explain_filename()

storage/xtradb/handler/ha_innodb.cc:
  Call explain_filename() to get proper names for partitioned tables
2010-01-15 17:27:55 +02:00
Mattias Jonsson
8c6d6c0c6c merge 2010-01-19 12:18:48 +01:00
Mattias Jonsson
eab2be0aee Bug#47343: InnoDB fails to clean-up after lock wait timeout on
REORGANIZE PARTITION

There were several problems which lead to this this,
all related to bad error handling.

1) There was several bugs preventing the ddl-log to be used for
   cleaning up created files on error.

2) The error handling after the copy partition rows did not close
   and unlock the tables, resulting in deletion of partitions
   which were in use, which lead InnoDB to put the partition to
   drop in a background queue.

sql/ha_partition.cc:
  Bug#47343: InnoDB fails to clean-up after lock wait timeout on
             REORGANIZE PARTITION
  
  Better error handling, if partition has been created/opened/locked
  then make sure it is unlocked and closed before returning error.
  The delete of the newly created partition is handled by the ddl-log.
sql/sql_parse.cc:
  Bug#47343: InnoDB fails to clean-up after lock wait timeout on
             REORGANIZE PARTITION
  
  Fix a bug found when experimenting, thd could really be NULL here,
  as mentioned in the function header.
sql/sql_partition.cc:
  Bug#47343: InnoDB fails to clean-up after lock wait timeout on
             REORGANIZE PARTITION
  
  Used the correct .frm shadow name to put into the ddl-log.
  Really use the ddl-log to handle errors.
sql/sql_table.cc:
  Bug#47343: InnoDB fails to clean-up after lock wait timeout on
             REORGANIZE PARTITION
  
  Fixes of the ddl-log when used as error recovery (no crash).
  When executing an entry from memory (not read from disk)
  the name_len was not set correctly.
2010-01-18 17:49:18 +01:00
Mattias Jonsson
28e64daf2d Bug#49742: Partition Pruning not working correctly for RANGE
Problem was when calculating the range of partitions for
pruning.

Solution was to get the calculation correct. I also simplified
it a bit for easier understanding.

mysql-test/r/partition_pruning.result:
  Bug#49742: Partition Pruning not working correctly for RANGE
  
  Added results.
mysql-test/t/partition_pruning.test:
  Bug#49742: Partition Pruning not working correctly for RANGE
  
  Added tests to prevent regressions.
sql/sql_partition.cc:
  Bug#49742: Partition Pruning not working correctly for RANGE
  
  Simplified calculation for partition id for ranges.
  Easier to get right and understand.
  
  Added comments.
2009-12-22 18:59:37 +01:00
Alexey Kopytov
d65fdb3168 Automerge 2009-12-13 23:57:57 +03:00
Alexey Kopytov
c08e6c8867 Bug #42849: innodb crash with varying time_zone on partitioned
timestamp primary key 
 
Since TIMESTAMP values are adjusted by the current time zone  
settings in both numeric and string contexts, using any 
expressions involving TIMESTAMP values as a  
(sub)partitioning function leads to undeterministic behavior of  
partitioned tables. The effect may vary depending on a storage  
engine, it can be either incorrect data being retrieved or  
stored, or an assertion failure. The root cause of this is the  
fact that the calculated partition ID may differ from a  
previously calculated ID for the same data due to timezone  
adjustments of the partitioning expression value. 
 
Fixed by disabling any expressions involving TIMESTAMP values  
to be used in partitioning functions with the follwing two 
exceptions: 
 
1. Creating or altering into a partitioned table that violates 
the above rule is not allowed, but opening existing such tables 
results in a warning rather than an error so that such tables 
could be fixed. 
 
2. UNIX_TIMESTAMP() is the only way to get a 
timezone-independent value from a TIMESTAMP column, because it 
returns the internal representation (a time_t value) of a 
TIMESTAMP argument verbatim. So UNIX_TIMESTAMP(timestamp_column)
is allowed and should be used to fix existing tables if one 
wants to use TIMESTAMP columns with partitioning.

mysql-test/r/partition_bug18198.result:
  Corrected the error.
mysql-test/r/partition_error.result:
  Corrected error texts.
  Added test cases for bug #42849.
mysql-test/t/partition_bug18198.test:
  Corrected error code.
mysql-test/t/partition_error.test:
  Corrected error codes.
  Added test cases for bug #42849.
sql/item.h:
  Added is_timezone_dependent_processor() to Item.
sql/item_func.h:
  Added has_timestamp_args() and the implementation of
  is_timezone_dependent_processor() for Item_func.
sql/item_timefunc.h:
  Added is_timezone_dependent_processor() to 
  Item_func_unix_timestamp.
sql/share/errmsg.txt:
  Renamed ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR to
  ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR to better reflect the
  meaning. Adjusted the error message.
sql/sql_partition.cc:
  Modified fix_fields_part_func() to walk through partitioning
  expression tree with is_timezone_dependent_processor() and issue
  a warning/error if it depends on the timezone settings.
  
  Changed fix_fields_part_func() to a static function since it is
  not used anywhere except sql_partition.cc
sql/sql_partition.h:
  Removed the unneeded declaration of fix_fields_part_func()
  since it is now a static function.
sql/sql_yacc.yy:
  ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR ->
  ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR.
2009-12-13 23:29:50 +03:00
unknown
08e4635fba merge 5.1-> 5.2 2009-12-08 23:47:54 +02: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
unknown
a962160eec Merge with MySQL 5.1, with following additions:
- Moved some code from innodb_plugin to xtradb, to ensure that all tests runs
- Did changes in pbxt and maria storage engines becasue of changes in thd->query
- Reverted wrong code in sql_table.cc for how ROW_FORMAT is used.

This is a re-commit of Monty's merge to eliminate an extra commit from
MySQL-5.1.42 that was accidentally included in the merge.

This is a merge of the MySQL 5.1.41 clone-off (clone-5.1.41-build). In
case there are any extra changes done before final MySQL 5.1.41
release, these will need to be merged later before MariaDB 5.1.41
release.
2009-11-16 21:49:51 +01:00
Igor Babaev
d749c7e600 Merge 2009-11-09 18:32:39 -08: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
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
Igor Babaev
f7a75b999b The main commit of Andrey Zhakov's patch introducing vurtual(computed) columns.
The original patch has been ameliorated by Sanja and Igor.
2009-10-16 15:57:48 -07:00
Georgi Kodinov
7b4ef910f7 Bug #40877: multi statement execution fails in 5.1.30
Implemented the server infrastructure for the fix:

1. Added a function LEX_STRING *thd_query_string(THD) to return
a LEX_STRING structure instead of char *.
This is the function that must be called in innodb instead of 
thd_query()

2. Did some encapsulation in THD : aggregated thd_query and 
thd_query_length into a LEX_STRING and made accessor and mutator 
methods for easy code updating. 

3. Updated the server code to use the new methods where applicable.
2009-10-16 13:29:42 +03:00
unknown
6aad537a6a Merge MySQL 5.1.39 into MariaDB 5.1. 2009-10-15 23:38:29 +02:00
Staale Smedseng
6a89842e36 Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2

Cleaning up warnings not present in 5.0.
2009-09-23 15:21:29 +02:00
Sergey Petrunya
29f0dcb563 Merge MySQL->MariaDB
* Finished Monty and Jani's merge
* Some InnoDB tests still fail (because it's old xtradb code run against
  newer testsuite). They are expected to go after mergning with the latest
  xtradb.
2009-09-08 00:50:10 +04:00
Georgi Kodinov
7c9e39f5c5 fixed a valgrind warning in partitioning code 2009-09-02 15:20:47 +03:00
Mattias Jonsson
0a76397171 Manual merge between bug#46362 and bug#20577.
sql/opt_range.cc:
  Removed duplicate code (if statement must have been duplicated during earlier merge).
sql/sql_partition.cc:
  After mergeing bug#46362 and bug#20577, the NULL partition was also searched
  when col = const, fixed by checking if = or range.
2009-08-28 12:55:59 +02:00
Mattias Jonsson
67214ef433 Bug#20577: Partitions: use of to_days() function leads to selection failures
Problem was that the partition containing NULL values
was pruned away, since '2001-01-01' < '2001-02-00' but
TO_DAYS('2001-02-00') is NULL.

Added the NULL partition for RANGE/LIST partitioning on TO_DAYS()
function to be scanned too.

Also fixed a bug that added ALLOW_INVALID_DATES to sql_mode
(SELECT * FROM t WHERE date_col < '1999-99-99' on a RANGE/LIST
partitioned table would add it).

mysql-test/include/partition_date_range.inc:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Added include file to decrease test code duplication
mysql-test/r/partition_pruning.result:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Added test results
mysql-test/r/partition_range.result:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Updated test result.
  This fix adds the partition containing NULL values to
  the list of partitions to be scanned.
mysql-test/t/partition_pruning.test:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Added test case
sql/item.h:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Added MONOTONIC_*INCREASE_NOT_NULL values to be used by TO_DAYS.
sql/item_timefunc.cc:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Calculate the number of days as return value even for invalid dates.
  This is so that pruning can be used even for invalid dates.
sql/opt_range.cc:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Fixed a bug that added ALLOW_INVALID_DATES to sql_mode
  (SELECT * FROM t WHERE date_col < '1999-99-99' on a RANGE/LIST
  partitioned table would add it).
sql/partition_info.h:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Resetting ret_null_part when a single partition is to be used, this
  to avoid adding the NULL partition.
sql/sql_partition.cc:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Always include the NULL partition if RANGE or LIST.
  Use the returned value for the function for pruning, even if
  it is marked as NULL, so that even '2000-00-00' can be
  used for pruning, even if TO_DAYS('2000-00-00') is NULL.
  
  Changed == to >= in get_next_partition_id_list to avoid
  crash if part_iter->part_nums is not correctly setup.
2009-08-26 12:59:49 +02:00
Mattias Jonsson
dd10de57d3 Bug#46478: timestamp field incorrectly defaulted
when partition is reoganized.

Problem was that table->timestamp_field_type was not changed
before copying rows between partitions.

fixed by setting it to TIMESTAMP_NO_AUTO_SET as the first thing
in fast_alter_partition_table, so that all if-branches is covered.
2009-08-06 14:28:39 +02:00
Tatiana A. Nurnberg
717d6054f5 Bug#40281, partitioning the general log table crashes the server
We disallow the partitioning of a log table. You could however
partition a table first, and then point logging to it. This is
not only against the docs, it also crashes the server.

We catch this case now.

mysql-test/r/partition.result:
  results for 40281
mysql-test/t/partition.test:
  test for 40281: show that trying to log to partitioned table fails rather
  to crash the server
sql/ha_partition.cc:
  Signal that we no longer support logging to partitioned tables,
  as per the docs.
sql/sql_partition.cc:
  Some commands like "USE ..." have no select, yet we may try
  to parse partition info after their execution if user set a
  partitioned table as log target. This shouldn't lead to a
  NULL-deref/crash.
2009-07-31 14:38:18 +02:00
Georgi Kodinov
ead1ce94e6 Addendum to the fix for bug 45807 : initialize a member needed in
Item_field::fix_fields()
2009-07-08 13:12:27 +03:00
Georgi Kodinov
ae8950f1e8 Bug #45807: crash accessing partitioned table and sql_mode
contains ONLY_FULL_GROUP_BY

The partitioning code needs to issue a Item::fix_fields()
on the partitioning expression in order to prepare 
it for being evaluated.
It does this by creating a special table and a table list 
for the scope of the partitioning expression.
But when checking ONLY_FULL_GROUP_BY the 
Item_field::fix_fields() was relying that there always be
cached_table set and was trying to use it to get the 
select_lex of the SELECT the field's table is in.
But the cached_table was not set by the partitioning code
that creates the artificial TABLE_LIST used to resolve the
partitioning expression and this resulted in a crash.
 
Fixed by rectifying the following errors :
1. Item_field::fix_fields() : the code that check for 
ONLY_FULL_GROUP_BY relies on having tables with 
cacheable_table set. This is mostly true, the only 
two exceptions being the partitioning context table
and the trigger context table.
Fixed by taking the current parsing context if no pointer
to the TABLE_LIST instance is present in the cached_table.

2. fix_fields_part_func() : 

2a. The code that adds the table being created to the 
scope for the partitioning expression is mostly a copy 
of the add_table_to_list and friends with one exception :
it was not marking the table as cacheable (something that
normal add_table_to_list is doing). This caused the 
problem in the check for ONLY_FULL_GROUP_BY in 
Item_field::fix_fields() to appear.
Fixed by setting the correct members to make the table
cacheable.
The ideal structural fix for this is to use a unified 
interface for adding a table to a table list 
(add_table_to_list?) : noted in a TODO comment

2b. The Item::fix_fields() was called with a NULL destination
pointer. This causes uninitalized memory reads in the 
overloaded ::fix_fields() function (namely 
Item_field::fix_fields()) as it expects a non-zero pointer 
there. Fixed by passing the source pointer similarly to how 
it's done in JOIN::prepare().

mysql-test/r/partition.result:
  Bug #45807: test case
mysql-test/t/partition.test:
  Bug #45807: test case
sql/item.cc:
  Bug #45807: fix the ONLY_FULL_GROUP_BY check code to 
  handle correctly non-cacheable tables.
sql/sql_partition.cc:
  Bug #45807: fix the Item::fix_fields() context
  initializatio for the partitioning expression in 
  CREATE TABLE.
2009-07-02 17:42:00 +03:00
Sergey Glukhov
9347649c16 Bug#44834 strxnmov is expected to behave as you'd expect
The problem: described in the bug report.
The fix:
--increase buffers where it's necessary
  (buffers which are used in stxnmov)
--decrease buffer lengths which are used


client/mysql.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/ha_ndbcluster.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/ha_ndbcluster_binlog.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/handler.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/log.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/mysqld.cc:
  removed unnecessary line
sql/parse_file.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/sql_acl.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/sql_base.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/sql_db.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/sql_delete.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/sql_partition.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/sql_rename.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/sql_show.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/sql_table.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
sql/sql_view.cc:
  --increase buffers where it's necessary
    (buffers which are used in stxnmov)
  --decrease buffer lengths which are used
    as argument for strxnmov function
2009-06-19 13:24:43 +05:00
Ramil Kalimullin
968069d845 Fix for bug#42944: partition not pruned correctly
Problem: we don't prune a LESS THAN partition if MAXVALUE is given and
given value is equal to a LESS THAN value.

Fix: prune partitions in such cases.


mysql-test/r/partition.result:
  Fix for bug#42944: partition not pruned correctly
    - test result.
mysql-test/t/partition.test:
  Fix for bug#42944: partition not pruned correctly
    - test case.
sql/sql_partition.cc:
  Fix for bug#42944: partition not pruned correctly
    - prune partition if given value is equal to a LESS THAN value
      and it's not a "PARTITION ... LESS THAN MAXVALUE" one.
2009-04-01 10:34:59 +05:00
Michael Widenius
a8fdaa6f2c Merge with base MySQL 5.1
Contains fixes for test cases
Changed release tag to beta

configure.in:
  change release tag to beta
2009-02-15 12:58:34 +02:00
Michael Widenius
bd4e65515f Fixed compiler warnings found by gcc 4.3.2
- Added braces around expressions with &&, ||, & and |
- Added empty line before ; for empty while and for loops
- Added () around if with assignments
- Removed const before function returning simple type

Changed BUILD scripts to not build with NDB 


BUILD/SETUP.sh:
  By default, don't build ndb with --max in Maria tree.
  NDB is not kept up to date anyway in 5.1
client/mysql.cc:
  Added braces around && to get rid of compiler warnings
sql/event_db_repository.cc:
  Added braces around && to get rid of compiler warnings
sql/events.cc:
  Added braces around && to get rid of compiler warnings
sql/field.cc:
  Added braces around && to get rid of compiler warnings
  Fixed for loops
sql/field.h:
  Added braces around & to get rid of compiler warnings
sql/field_conv.cc:
  Added braces around && to get rid of compiler warnings
  Fixed bug when copying between DATETIME fields and strict dates are used
  Removed not needeed else
sql/gstream.cc:
  Added braces around && to get rid of compiler warnings
sql/ha_ndbcluster.cc:
  Added braces around && to get rid of compiler warnings
  Added {} to get rid of compiler warnings
sql/handler.cc:
  Added braces around && to get rid of compiler warnings
sql/item.cc:
  Added braces around && to get rid of compiler warnings
sql/item_cmpfunc.cc:
  Added braces around && to get rid of compiler warnings
  Removed some not needed space
sql/item_func.cc:
  Added braces around && to get rid of compiler warnings
sql/item_strfunc.cc:
  Added braces around && to get rid of compiler warnings
sql/item_subselect.cc:
  Added braces around && to get rid of compiler warnings
sql/item_sum.cc:
  Added braces around && to get rid of compiler warnings
sql/item_timefunc.cc:
  Added braces around && to get rid of compiler warnings
sql/item_xmlfunc.cc:
  Added empty line before ; for empty while and for loops
sql/log.cc:
  Added braces around && to get rid of compiler warnings
sql/log_event.cc:
  Added braces around && to get rid of compiler warnings
  Removed not needed else
sql/log_event_old.cc:
  Added braces around && to get rid of compiler warnings
sql/opt_range.cc:
  Added braces around && to get rid of compiler warnings
sql/opt_sum.cc:
  Added braces around && to get rid of compiler warnings
sql/set_var.cc:
  Added empty line before ; for empty while and for loops
  Added () around if with assignments
sql/slave.cc:
  Added braces around && to get rid of compiler warnings
  Added empty line before ; for empty while and for loops
sql/spatial.h:
  Added braces around && to get rid of compiler warnings
sql/sql_acl.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_analyse.cc:
  Added empty line before ; for empty while and for loops
sql/sql_base.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_connect.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_db.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_delete.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_help.cc:
  Added empty line before ; for empty while and for loops
sql/sql_insert.cc:
  Added braces around && to get rid of compiler warnings
  Added () around if with assignments
sql/sql_lex.cc:
  Cast char array references to uchar; Fixed wrong array referencing when using characters > ASCII 128 in SQL statments
  Added empty line before ; for empty while and for loops
  Trivial indent fixes
  Added braces around && to get rid of compiler warnings
sql/sql_load.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_parse.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_partition.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_plugin.cc:
  Fixed bug in detecing if option variable should be readonly
  Added empty line before ; for empty while and for loops
sql/sql_prepare.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_select.cc:
  Added braces around && to get rid of compiler warnings
  Added () around if with assignments
  Added empty line before ; for empty while and for loops
sql/sql_show.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_table.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_trigger.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_update.cc:
  Added braces around && to get rid of compiler warnings
sql/sql_yacc.yy:
  Added braces around && to get rid of compiler warnings
sql/table.cc:
  Added braces around && to get rid of compiler warnings
sql/table.h:
  Added braces around && to get rid of compiler warnings
sql/time.cc:
  Added braces around && to get rid of compiler warnings
sql/tztime.cc:
  Added braces around && to get rid of compiler warnings
sql/uniques.cc:
  Added braces around && to get rid of compiler warnings
storage/federated/ha_federated.cc:
  Fixed bug in testing of variable to ha_info() (Not critical)
storage/heap/ha_heap.cc:
  Added braces around && to get rid of compiler warnings
storage/maria/ha_maria.cc:
  Fixed bug: Mark that maria_log_dir_path is readonly
  Added braces around && to get rid of compiler warnings
storage/ndb/include/ndbapi/NdbEventOperation.hpp:
  Removed const before function returning simple type
storage/ndb/include/ndbapi/NdbOperation.hpp:
  Removed const before function returning simple type
storage/ndb/src/ndbapi/Ndb.cpp:
  Added empty line before ; for empty while and for loops
storage/ndb/src/ndbapi/NdbEventOperation.cpp:
  Removed const before function returning simple type
storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp:
  Removed const before function returning simple type
storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp:
  Removed const before function returning simple type
storage/ndb/src/ndbapi/NdbRecAttr.cpp:
  Added empty line before ; for empty while and for loops
storage/ndb/src/ndbapi/TransporterFacade.hpp:
  Added braces around && to get rid of compiler warnings
2009-01-31 23:22:44 +02:00
Mattias Jonsson
efea2e68d8 Bug#40972: Partition pruning can lead to crash for bad dates
post push fix, added test found a valgrind warning

sql/sql_partition.cc:
  Bug#40972: Partition pruning can lead to crash for bad dates
  
  Fix for valgrind warning
2009-01-09 14:18:08 +01:00
Mattias Jonsson
f1731568e6 merge 2009-01-07 23:28:49 +01:00
Georgi Kodinov
f97ef7a40e merged 5.1-main -> 5.1-bugteam 2009-01-05 18:10:20 +02:00
Mattias Jonsson
f257aac814 Bug#40972: some sql execution lead the whole databse crashing
Problem was an errornous date that lead to end partition
was before the start, leading to a crash.

Solution was to check greater or equal instead of only
equal between start and end partition.

NOTE: partitioning pruning handles incorrect dates
differently than index lookup, which can give different
results in a partitioned table versus a non partitioned
table for queries having 'bad' dates in the where clause.

mysql-test/r/partition_pruning.result:
  Bug#40972: some sql execution lead the whole databse crashing
  
  Updated result file
mysql-test/t/partition_pruning.test:
  Bug#40972: some sql execution lead the whole databse crashing
  
  Added test.
sql/sql_partition.cc:
  Bug#40972: some sql execution lead the whole databse crashing
  
  There can be cases where the start/cur partition is greater
  than the end partition, so it must not continue, since that
  can lead to a crash.
2008-12-28 12:33:49 +01:00