Commit graph

59 commits

Author SHA1 Message Date
Murthy Narkedimilli
496abd0814 Updated/added copyright headers 2014-01-06 10:52:35 +05:30
Mattias Jonsson
f693203e80 Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING
Due to an internal change in the server code in between 5.1 and 5.5
(wl#2649) the hash function used in KEY partitioning changed
for numeric and date/time columns (from binary hash calculation
to character based hash calculation).

Also enum/set changed from latin1 ci based hash calculation to
binary hash between 5.1 and 5.5. (bug#11759782).

These changes makes KEY [sub]partitioned tables on any of
the affected column types incompatible with 5.5 and above,
since the calculation of partition id differs.

Also since InnoDB asserts that a deleted row was previously
read (positioned), the server asserts on delete of a row that
is in the wrong partition.

The solution for this situation is:

1) The partitioning engine will check that delete/update will go to the
partition the row was read from and give an error otherwise, consisting
of the rows partitioning fields. This will avoid asserts in InnoDB and
also alert the user that there is a misplaced row. A detailed error
message will be given, including an entry to the error log consisting
of both table name, partition and row content (PK if exists, otherwise
all partitioning columns).


2) A new optional syntax for KEY () partitioning in 5.5 is allowed:
[SUB]PARTITION BY KEY [ALGORITHM = N] (list_of_cols)
Where N = 1 uses the same hashing as 5.1 (Numeric/date/time fields uses
binary hashing, ENUM/SET uses charset hashing) N = 2 uses the same
hashing as 5.5 (Numeric/date/time fields uses charset hashing,
ENUM/SET uses binary hashing). If not set on CREATE/ALTER it will
default to 2.

This new syntax should probably be ignored by NDB.


3) Since there is a demand for avoiding scanning through the full
table, during upgrade the ALTER TABLE t PARTITION BY ... command is
considered a no-op (only .frm change) if everything except ALGORITHM
is the same and ALGORITHM was not set before, which allows manually
upgrading such table by something like:
ALTER TABLE t PARTITION BY KEY ALGORITHM = 1 () or
ALTER TABLE t PARTITION BY KEY ALGORITHM = 2 ()


4) Enhanced partitioning with CHECK/REPAIR to also check for/repair
misplaced rows. (Also works for ALTER TABLE t CHECK/REPAIR PARTITION)

CHECK FOR UPGRADE:
If the .frm version is < 5.5.3
and uses KEY [sub]partitioning
and an affected column type
then it will fail with an message:
KEY () partitioning changed, please run:
ALTER TABLE `test`.`t1`  PARTITION BY KEY ALGORITHM = 1 (a)
PARTITIONS 12
(i.e. current partitioning clause, with the addition of
ALGORITHM = 1)

CHECK without FOR UPGRADE:
if MEDIUM (default) or EXTENDED options are given:
Scan all rows and verify that it is in the correct partition.
Fail for the first misplaced row.

REPAIR:
if default or EXTENDED (i.e. not QUICK/USE_FRM):
Scan all rows and every misplaced row is moved into its correct
partitions.


5) Updated mysqlcheck (called by mysql_upgrade) to handle the
new output from CHECK FOR UPGRADE, to run the ALTER statement
instead of running REPAIR.

This will allow mysql_upgrade (or CHECK TABLE t FOR UPGRADE) to upgrade
a KEY [sub]partitioned table that has any affected field type
and a .frm version < 5.5.3 to ALGORITHM = 1 without rebuild.


Also notice that if the .frm has a version of >= 5.5.3 and ALGORITHM
is not set, it is not possible to know if it consists of rows from
5.1 or 5.5! In these cases I suggest that the user does:
(optional)
LOCK TABLE t WRITE;
SHOW CREATE TABLE t;
(verify that it has no ALGORITHM = N, and to be safe, I would suggest
backing up the .frm file, to be used if one need to change to another
ALGORITHM = N, without needing to rebuild/repair)
ALTER TABLE t <old partitioning clause, but with ALGORITHM = N>;
which should set the ALGORITHM to N (if the table has rows from
5.1 I would suggest N = 1, otherwise N = 2)
CHECK TABLE t;
(here one could use the backed up .frm instead and change to a new N
and run CHECK again and see if it passes)
and if there are misplaced rows:
REPAIR TABLE t;
(optional)
UNLOCK TABLES;
2013-01-30 17:51:52 +01:00
Kent Boortz
1400d7a2cc Updated/added copyright headers 2011-06-30 17:37:13 +02:00
Kent Boortz
9da00ebec9 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Mattias Jonsson
e7dc80b807 Bug#50036: Inconsistent errors when using TIMESTAMP columns/expressions
It was hard to understand what the error really meant.

The error checking in partitioning is done in several different
parts during the execution of a query which can make it
hard to return useful errors.

Added a new error for bad VALUES part in the per PARTITION clause.
Using the more verbose error that a column is not allowed in
the partitioning function instead of just that the function is
not allowed.
2010-08-30 17:33:55 +02:00
Mattias Jonsson
864d6bc90b Bug#51851: Server with SBR locks mutex twice on LOAD DATA
into partitioned MyISAM table

Problem was that the ha_data structure was introduced in 5.1
and only used for partitioning first, but with the intention
of be of use for others engines as well, and when used by other
engines it would clash if it also was partitioned.

Solution is to move the partitioning specific data to a separate
structure, with its own mutex (which is used for auto_increment).

Also did rename PARTITION_INFO to PARTITION_STATS since there
already exist a class named partition_info, also cleaned up
some related variables.
2010-03-30 22:52:45 +02:00
Mikael Ronstrom
29c60cd5b7 BUG#49591, Fixed version string in SHOW CREATE TABLE to accomodate for column list partitioning and new function to_seconds 2009-12-17 18:39:10 +01:00
Mikael Ronstrom
d9e05040f4 Merged WL#3352 into mysql-next-mr 2009-10-28 18:22:36 +01:00
Mikael Ronstrom
b572e51c30 BUG#48165, needed to introduce length restrictions on partitioning fields to ensure that no stack overruns occur 2009-10-28 01:11:17 +01:00
Mikael Ronstrom
7f446fc76b Upped size limit on varchar/char from 512 to 2048 2009-10-23 09:36:45 +02:00
Mikael Ronstrom
66f056a64c A lot of fixes to make character set work ok, first step to fixing BUG#48163 2009-10-22 16:15:06 +02:00
Mikael Ronstrom
d46abd8b84 Merge 2009-10-21 13:59:11 +02:00
Mikael Ronstrom
8ac7705722 Removed column_list and fixed all issues relating to this change 2009-10-21 12:40:21 +02:00
Mattias Jonsson
49c446059c Manual merge mysql-trunk -> mysql-trunk-wl3352 2009-10-19 12:09:52 +02:00
Mikael Ronstrom
1f38322dc4 Merged in latest changes 2009-10-16 17:44:49 +02:00
Mikael Ronstrom
05d7593fe3 Fixed review comments 2009-10-16 17:08:34 +02:00
Mikael Ronstrom
1ef62bf621 Fixed removal of column_list keyword for VALUES part, retained for PARTITION BY RANGE/LIST COLUMN_LIST, not entirely working yet 2009-10-16 16:16:06 +02:00
Mikael Ronstrom
b216aab1c4 BUG#47837, Duplicate field names were allowed in both column list partitioning and key partitioning, added check to give error in this case 2009-10-06 17:01:59 +02:00
Mikael Ronstrom
1fe164a20e Changed all no_ to num_ to avoid strange names like no_list_values which is not expected to be number of list values, rather a boolea indicating no list values 2009-10-01 15:04:42 +02:00
Mats Kindahl
4ad8ef0602 WL#5016: Fix header file include guards
Adding header include file guards to files that are missing such.
2009-09-23 23:32:31 +02:00
Mikael Ronstrom
12627d4072 WL#3352, Introducing Column list partitioning, makes it possible to partition on most data types, makes it possible to prune on multi-field partitioning 2009-09-15 17:07:52 +02:00
Georgi Kodinov
21a01bd60e fixed a valgrind warning in partition_pruning 2009-09-02 18:42:08 +03:00
Mattias Jonsson
401fb7c6fb 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).
2009-08-26 12:59:49 +02:00
Build Team
366adeab08 Added "Sun Microsystems, Inc." to copyright headers on files modified
since Oct 1st
2008-11-10 21:21:49 +01:00
Alexey Botchkov
79a66a9763 Bug#38083 Error-causing row inserted into partitioned table despite error 2008-10-06 17:22:38 +05:00
istruewing@stella.local
eabe082d6f Manual merge 2008-03-14 12:02:11 +01:00
gluh@mysql.com/eagle.(none)
9d42a09675 Bug#32167 another privilege bypass with DATA/INDEX DIRECORY(3rd version for 5.1)
added new function test_if_data_home_dir() which checks that
path does not contain mysql data home directory.
Using of 'mysql data home'/'any db name' in
DATA DIRECTORY & INDEX DIRECTORY is disallowed
2008-02-28 16:46:52 +04:00
mattiasj@client-10-129-10-137.upp.off.mysql.com
a6a9774849 Bug#31931 Partitions: unjustified 'mix of handlers' error message
Problem was that the mix of handlers was not consistent between
CREATE and ALTER

changed so that it works like:
    - All partitions must use the same engine
      AND it must be the same as the table.
    - if one does NOT specify an engine on the table level
      then one must either NOT specify any engine on any
      partition/subpartition OR for ALL partitions/subpartitions

Note: that after a table have been created, the storage engine
is specified for all parts of the table (table/partition/subpartition)
and so when using alter, one does not need to specify it (unless one
wants to change the storage engine, then one have to specify it on the
table level)
2008-01-09 13:15:50 +01:00
sergefp@mysql.com
41404ec52e BUG#27927:Partition pruning not optimal with TO_DAYS and YEAR functions
- Introduced val_int_endpoint() function which converts between func 
  argument intervals and func value intervals for monotonic functions.
- Made partition interval analyzer use part_expr->val_int_endpoint()
  to check if the edge values should be included.
2007-09-14 14:18:42 +04:00
istruewing@chilla.local
dc82068c96 Bug#26827 - table->read_set is set incorrectly,
causing update of a different column

For efficiency some storage engines do not read a complete record
for update, but only the columns required for selecting the rows.

When updating a row of a partitioned table, modifying a column
that is part of the partition or subpartition expression, then
the row may need to move from one [sub]partition to another one.
This is done by inserting the new row into the target
[sub]partition and deleting the old row from the originating one.
For the insert we need a complete record.

If an above mentioned engine was used for a partitioned table, we
did not have a complete record in update_row(). The implicitly
executed write_row() got an incomplete record.

This is solved by instructing the engine to read a complete record
if one of the columns of the partition or subpartiton is to be
updated.

No testcase. This can be reproduced with Falcon only. The engines
contained in standard 5.1 do always return complete records on
update.
2007-07-04 21:55:26 +02:00
monty@mysql.com/narttu.mysql.fi
088e2395f1 WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:

- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t

Removed declaration of byte, gptr, my_string, my_size_t and size_s. 

Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
  instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
  as this requires fewer casts in the code and is more in line with how the
  standard functions work.
- Added extra length argument to dirname_part() to return the length of the
  created string.
- Changed (at least) following functions to take uchar* as argument:
  - db_dump()
  - my_net_write()
  - net_write_command()
  - net_store_data()
  - DBUG_DUMP()
  - decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
  argument to my_uncompress() from a pointer to a value as we only return
  one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
  the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
  casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.

Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
  needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
  explicitely as this conflict was often hided by casting the function to
  hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
  get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
  size_t. This was needed to properly detect errors (which are
  returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
  (portability fix)
- Removed windows specific code to restore cursor position as this
  causes slowdown on windows and we should not mix read() and pread()
  calls anyway as this is not thread safe. Updated function comment to
  reflect this. Changed function that depended on original behavior of
  my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
  m_size is the number of elements in the array, not a string/memory
  length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
  Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
  - Replaced some calls to alloc_root + memcpy to use
    strmake_root()/strdup_root().
  - Changed some calls from memdup() to strmake() (Safety fix)
  - Simpler loops in client-simple.c
2007-05-10 12:59:39 +03:00
kostja@bodhi.local
b42b416400 Remove unnecessary casts to uchar. The casts are stemming from
the lexer API which internally uses  unsigned char variables to
address its state map. The implementation of the lexer should be
internal to the lexer, and not influence the rest of the code.
2007-03-27 21:09:56 +04:00
kent@mysql.com/kent-amd64.(none)
67868597bb Many files:
Removed "MySQL Finland AB & TCX DataKonsult AB" from copyright header
  Adjusted year(s) in copyright header 
  Added GPL copyright text
my_vle.h, rpl_utility.h, my_vle.c, base64-t.c, rpl_utility.cc:
  Changed copyright header formatting some
plugin_example.c, daemon_example.c:
  Added "Copyright (C) 2006 MySQL AB" to GPL header
2006-12-31 02:29:11 +01:00
kent@mysql.com/kent-amd64.(none)
1e3237fefa Many files:
Changed header to GPL version 2 only
2006-12-27 02:23:51 +01:00
mikael/pappa@dator5.(none)
1cdf82e012 BUG#18198: Partition function handling
Fixes of after review fixes
2006-10-02 15:52:29 -04:00
mikael/pappa@dator5.(none)
6be97e4e43 Final step of Take 7 on review fixes of this
fairly complex bug
2006-09-26 16:30:39 -04:00
mikael/pappa@dator5.(none)
6425e33530 BUG#18198: Fixes to handle VARCHAR strings properly
New methods to handle VARCHAR strings and CHAR's which are not
using a binary collation.
Indentation fixes
Now strings are run through strnxfrm before they are processed
by the partition function
We do not allow collations where strnxfrm expands the string since
we want the resulting string to fit in the same value range as
the original.
2006-08-02 06:40:25 -04:00
mikael/pappa@dator5.(none)
032d208be2 BUG#18198: Partition function handling
Review fixes
2006-07-21 10:23:32 -04:00
mikael/pappa@dator5.(none)
eae8c963c5 Merge mronstrom@bk-internal.mysql.com:/home/bk/bugs/bug18198
into  dator5.(none):/home/pappa/bug18198
2006-07-12 11:33:22 -04:00
tomas@poseidon.ndb.mysql.com
9791d53445 partition functions to pass create_info, not only max_rows 2006-06-27 22:19:27 +02:00
mikael@dator5.(none)
5771a711f0 BUG#18198: Less flexibility in defining partition functions
Changed test for functions if they are supported.
3 categories:
1) Fully supported
2) Supported for single character collations
3) Supported for binary collations
2006-06-23 01:21:26 -04:00
mikael@c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se
67e6e8b423 merge update 2006-06-14 19:40:06 -04:00
mikael@c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se
e91454f89e Merge c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/clean-mysql-5.1
into  c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/bug16002
2006-06-14 09:12:07 -04:00
mikael@c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se
56b97747de BUG#19010: Fix issues with that ALTER TABLE from auto-partitioned NDB table doesn't work unless primary key exists on table. 2006-05-10 12:53:40 -04:00
mikael@c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se
fa3c74b420 Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into  c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/wl2826
2006-04-21 09:30:05 -04:00
mikael@c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se
fe46ee9111 BUG#18962: Crash of ALTER TABLE .. DROP PARTITION ...
Review fixes
2006-04-21 08:37:09 -04:00
mikael@c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se
09e95da616 Merge c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/clean-mysql-5.1-new
into  c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/wl2826
2006-04-19 21:22:35 -04:00
mikael@c-4909e253.1238-1-64736c10.cust.bredbandsbolaget.se
cef06fdb61 BUG#16002: Make partition functions that are unsigned work properly 2006-04-17 22:51:34 -04:00
mikael@c-4908e253.1238-1-64736c10.cust.bredbandsbolaget.se
fa5e50943d BUG#18962: DROP PARTITION fails when partitions dropped for subpartitions with default naming procedure
Fixed naming procedures for default partitioning and default subpartitioning
2006-04-11 23:35:48 -04:00
sergefp@mysql.com
68bd945ca3 BUG#18558 "Partition pruning results are incorrect for certain class of WHERE clauses" :
* Produce right results for conditions that were transformed to "(partitioning_range) AND
  (list_of_subpartitioning_ranges)": make each partition id set iterator auto-reset itself
  after it has returned all partition ids in the sequence 
* Fix "Range mapping" and "Range mapping" partitioning interval analysis functions to 
  correctly deal with NULL values.
2006-04-06 21:23:33 +04:00