1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-02 09:41:40 +03:00

merge with git://github.com/Tokutek/ft-engine.git up to tokudb-7.0.4

This commit is contained in:
Sergei Golubchik
2013-09-09 11:12:52 +02:00
910 changed files with 1447971 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
# Copyright (C) 2006 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTOKUDB_VERSION=\\\"TOKUDB_VERSION_REPLACE_ME\\\"")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(TOKUDB_DIR_REPLACE_ME/windows
TOKUDB_DIR_REPLACE_ME/src
TOKUDB_DIR_REPLACE_ME/include
TOKUDB_DIR_REPLACE_ME/toku_include)
INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
SET(TOKUDB_SOURCES hatoku_hton.cc ha_tokudb.cc hatoku_cmp.cc)
MYSQL_STORAGE_ENGINE(TOKUDB)
TARGET_LINK_LIBRARIES(ha_tokudb PowrProf optimized TOKUDB_OBJ_DIR_REPLACE_ME/opt/ipo_libtokudb optimized TOKUDB_OBJ_DIR_REPLACE_ME/opt/libtokuportability debug TOKUDB_OBJ_DIR_REPLACE_ME/debug/static_libtokudb debug TOKUDB_OBJ_DIR_REPLACE_ME/debug/libtokuportability)

View File

@@ -0,0 +1,27 @@
IF(DEFINED ENV{TOKUDB_VERSION})
SET(TOKUDB_VERSION $ENV{TOKUDB_VERSION})
ADD_DEFINITIONS("-DTOKUDB_VERSION=\"${TOKUDB_VERSION}\"")
ENDIF()
IF(DEFINED ENV{TOKUDB_PATCHES})
SET(TOKUDB_PATCHES $ENV{TOKUDB_PATCHES})
ADD_DEFINITIONS("-DTOKUDB_PATCHES=${TOKUDB_PATCHES}")
ENDIF()
ADD_SUBDIRECTORY(ft-index)
# TODO: clean up includes in ft-index
INCLUDE_DIRECTORIES(ft-index)
INCLUDE_DIRECTORIES(ft-index/include)
INCLUDE_DIRECTORIES(ft-index/portability)
INCLUDE_DIRECTORIES(ft-index/toku_include)
INCLUDE_DIRECTORIES(ft-index/util)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/ft-index)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/ft-index/buildheader)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/ft-index/toku_include)
SET(TOKUDB_PLUGIN_DYNAMIC "ha_tokudb")
SET(TOKUDB_SOURCES ha_tokudb.cc)
MYSQL_ADD_PLUGIN(tokudb ${TOKUDB_SOURCES} STORAGE_ENGINE MODULE_ONLY
LINK_LIBRARIES tokufractaltree_static tokuportability_static z stdc++)
SET_PROPERTY(TARGET tokudb APPEND PROPERTY LINK_FLAGS_RELEASE "-flto -fuse-linker-plugin")

339
storage/tokudb/COPYING Normal file
View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

72
storage/tokudb/README.md Normal file
View File

@@ -0,0 +1,72 @@
TokuDB
======
TokuDB is a high-performance, transactional storage engine for MySQL and
MariaDB. For more details, see our [product page][products].
This repository contains the MySQL plugin that uses the [TokuKV][tokukv]
core.
There are also patches to the MySQL and MariaDB kernels, available in our
forks of [mysql][mysql] and [mariadb][mariadb].
[products]: http://www.tokutek.com/products/tokudb-for-mysql/
[tokukv]: http://github.com/Tokutek/ft-index
[mysql]: http://github.com/Tokutek/mysql
[mariadb]: http://github.com/Tokutek/mariadb
Building
--------
The `scripts/` directory contains a script that can be used to build a
working MySQL or MariaDB with Tokutek patches, and with the TokuDB storage
engine, called `make.mysql.bash`. This script will download copies of the
needed source code from github and build everything.
To build MySQL with TokuDB 7.0.1:
```sh
scripts/make.mysql.bash --mysqlbuild=mysql-5.5.30-tokudb-7.0.1-linux-x86_64
```
To build MariaDB with TokuDB 7.0.1:
```sh
scripts/make.mysql.bash --mysqlbuild=mariadb-5.5.30-tokudb-7.0.1-linux-x86_64
```
Before you start, make sure you have a C++11-compatible compiler (GCC >=
4.7 is recommended), as well as CMake >=2.8.8, and the libraries and
header files for valgrind,zlib, and Berkeley DB. On Centos, `yum install
valgrind-devel zlib-devel libdb-devel`, on Ubuntu, `apt-get install
valgrind zlib1g-dev libdb-dev`.
You can set the compiler by passing `--cc` and `--cxx` to the script, to
select one that's new enough. The default is `scripts/make.mysql.bash
--cc=gcc47 --cxx=g++47`, which may not exist on your system.
Contributing
------------
Please report bugs in TokuDB here on github.
We have two publicly accessible mailing lists:
- tokudb-user@googlegroups.com is for general and support related
questions about the use of TokuDB.
- tokudb-dev@googlegroups.com is for discussion of the development of
TokuDB.
We are also available on IRC on freenode.net, in the #tokutek channel.
License
-------
TokuDB is available under the GPL version 2. See [COPYING][copying]
The TokuKV component of TokuDB is available under the GPL version 2, with
slight modifications. See [README-TOKUDB][license].
[copying]: http://github.com/Tokutek/ft-engine/blob/master/COPYING
[license]: http://github.com/Tokutek/ft-index/blob/master/README-TOKUDB

View File

@@ -0,0 +1,82 @@
== Introduction ==
MySQL interfaces with TokuDB through a set of plugins, which, at
the time of this writing (October 2011) includes the tokudb storage
engine plugin, the user data information schema plugin, and the
user data exact information schema plugin. Each plugin provides
initialize and de-initialize functions for mysql to call when
they are installed or uninstalled by clients.
== Problem ==
It was originally discovered that the two information schema plugins
would crash if the tokudb storage engine failed to init properly. The
information plugins depend on the storage engine plugin, so a quick fix
for this problem was to have the storage engine plugin's init function
set a global flag if it failed. The information schema plugins could first
check this flag before proceeding. This fixed the original problem, but
the following still remain:
* a client connects, uninstalls tokudb storage engine, accesses
the tokudb user data/exact table.
* uninstall the tokudb engine plugin, drop a table, select from
it to see that it does not exist, then install the tokudb engine
to see that it has reappeared.
* any situation where one client is using any plugin while another
client modifies one.
== Proposed solution ==
Use a flag, call it tokudb_hton_initialized, that is set if the
storage engine's init function suceeds. The information schema plugins
will check that this flag is set before proceeding.
To protect against client race conditions, use a reader-writer lock to
protect the flag. Any clients which depend on the status of the flag
grab a read lock. Clients that change the status of the flag grab a write
lock. Using this flag and a protecting reader-writer lock, we can ensure
that no client is under the assumption that the handlerton is usable
while it is not, due to failure or uninstallation, etc.
== Implementation ==
{{{
#!c
static int tokudb_hton_initialized;
// grab a write lock when changing the
// hton_init flag
tokudb_init_func() {
grab_hton_init_writelock();
...
tokudb_hton_initialized = 1;
error:
release_hton_init_writelock();
}
tokudb_end() {
grab_hton_init_writelock();
assert(tokudb_hton_initialized);
...
tokudb_hton_initialized = 0;
release_hton_init_writelock();
}
// grab a read lock while assuming
// the handlerton is usable
//
// same thing for user_data_exact
tokudb_user_data_fill() {
grab_hton_init_readlock();
if (!tokudb_hton_initialized) {
// error
} else {
// fill the user data table
}
release_hton_init_readlock();
}
}}}

8417
storage/tokudb/ha_tokudb.cc Normal file

File diff suppressed because it is too large Load Diff

798
storage/tokudb/ha_tokudb.h Normal file
View File

@@ -0,0 +1,798 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#if !defined(HA_TOKUDB_H)
#define HA_TOKUDB_H
#include <db.h>
#include "hatoku_cmp.h"
#define HA_TOKU_ORIG_VERSION 4
#define HA_TOKU_VERSION 4
//
// no capabilities yet
//
#define HA_TOKU_CAP 0
class ha_tokudb;
typedef struct loader_context {
THD* thd;
char write_status_msg[200];
ha_tokudb* ha;
} *LOADER_CONTEXT;
typedef struct hot_optimize_context {
THD *thd;
char* write_status_msg;
ha_tokudb *ha;
uint progress_stage;
uint current_table;
uint num_tables;
} *HOT_OPTIMIZE_CONTEXT;
//
// This object stores table information that is to be shared
// among all ha_tokudb objects.
// There is one instance per table, shared among threads.
// Some of the variables here are the DB* pointers to indexes,
// and auto increment information.
//
class TOKUDB_SHARE {
public:
char *table_name;
uint table_name_length, use_count;
pthread_mutex_t mutex;
THR_LOCK lock;
ulonglong auto_ident;
ulonglong last_auto_increment, auto_inc_create_value;
//
// estimate on number of rows in table
//
ha_rows rows;
//
// estimate on number of rows added in the process of a locked tables
// this is so we can better estimate row count during a lock table
//
ha_rows rows_from_locked_table;
DB *status_block;
//
// DB that is indexed on the primary key
//
DB *file;
//
// array of all DB's that make up table, includes DB that
// is indexed on the primary key, add 1 in case primary
// key is hidden
//
DB *key_file[MAX_KEY +1];
rw_lock_t key_file_lock;
uint status, version, capabilities;
uint ref_length;
//
// whether table has an auto increment column
//
bool has_auto_inc;
//
// index of auto increment column in table->field, if auto_inc exists
//
uint ai_field_index;
KEY_AND_COL_INFO kc_info;
//
// we want the following optimization for bulk loads, if the table is empty,
// attempt to grab a table lock. emptiness check can be expensive,
// so we try it once for a table. After that, we keep this variable around
// to tell us to not try it again.
//
bool try_table_lock;
bool has_unique_keys;
bool replace_into_fast;
rw_lock_t num_DBs_lock;
uint32_t num_DBs;
};
typedef struct st_filter_key_part_info {
uint offset;
uint part_index;
} FILTER_KEY_PART_INFO;
typedef enum {
lock_read = 0,
lock_write
} TABLE_LOCK_TYPE;
// the number of rows bulk fetched in one callback grows exponentially
// with the bulk fetch iteration, so the max iteration is the max number
// of shifts we can perform on a 64 bit integer.
#define HA_TOKU_BULK_FETCH_ITERATION_MAX 63
class ha_tokudb : public handler {
private:
THR_LOCK_DATA lock; ///< MySQL lock
TOKUDB_SHARE *share; ///< Shared lock info
#ifdef MARIADB_BASE_VERSION
// maria version of MRR
DsMrr_impl ds_mrr;
#elif 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
// maria version of MRR
DsMrr_impl ds_mrr;
#endif
// For ICP. Cache our own copies
Item* toku_pushed_idx_cond;
uint toku_pushed_idx_cond_keyno; /* The index which the above condition is for */
bool icp_went_out_of_range;
//
// last key returned by ha_tokudb's cursor
//
DBT last_key;
//
// pointer used for multi_alloc of key_buff, key_buff2, primary_key_buff
//
void *alloc_ptr;
//
// buffer used to temporarily store a "packed row"
// data pointer of a DBT will end up pointing to this
// see pack_row for usage
//
uchar *rec_buff;
//
// number of bytes allocated in rec_buff
//
ulong alloced_rec_buff_length;
//
// same as above two, but for updates
//
uchar *rec_update_buff;
ulong alloced_update_rec_buff_length;
uint32_t max_key_length;
uchar* range_query_buff; // range query buffer
uint32_t size_range_query_buff; // size of the allocated range query buffer
uint32_t bytes_used_in_range_query_buff; // number of bytes used in the range query buffer
uint32_t curr_range_query_buff_offset; // current offset into the range query buffer for queries to read
uint64_t bulk_fetch_iteration;
uint64_t rows_fetched_using_bulk_fetch;
bool doing_bulk_fetch;
//
// buffer used to temporarily store a "packed key"
// data pointer of a DBT will end up pointing to this
//
uchar *key_buff;
//
// buffer used to temporarily store a "packed key"
// data pointer of a DBT will end up pointing to this
// This is used in functions that require the packing
// of more than one key
//
uchar *key_buff2;
uchar *key_buff3;
//
// buffer used to temporarily store a "packed key"
// data pointer of a DBT will end up pointing to this
// currently this is only used for a primary key in
// the function update_row, hence the name. It
// does not carry any state throughout the class.
//
uchar *primary_key_buff;
//
// ranges of prelocked area, used to know how much to bulk fetch
//
uchar *prelocked_left_range;
uint32_t prelocked_left_range_size;
uchar *prelocked_right_range;
uint32_t prelocked_right_range_size;
//
// individual DBTs for each index
//
DBT mult_key_dbt[2*(MAX_KEY + 1)];
DBT mult_rec_dbt[MAX_KEY + 1];
uint32_t mult_put_flags[MAX_KEY + 1];
uint32_t mult_del_flags[MAX_KEY + 1];
uint32_t mult_dbt_flags[MAX_KEY + 1];
//
// when unpacking blobs, we need to store it in a temporary
// buffer that will persist because MySQL just gets a pointer to the
// blob data, a pointer we need to ensure is valid until the next
// query
//
uchar* blob_buff;
uint32_t num_blob_bytes;
bool unpack_entire_row;
//
// buffers (and their sizes) that will hold the indexes
// of fields that need to be read for a query
//
uint32_t* fixed_cols_for_query;
uint32_t num_fixed_cols_for_query;
uint32_t* var_cols_for_query;
uint32_t num_var_cols_for_query;
bool read_blobs;
bool read_key;
//
// transaction used by ha_tokudb's cursor
//
DB_TXN *transaction;
bool is_fast_alter_running;
// external_lock will set this true for read operations that will be closely followed by write operations.
bool use_write_locks; // use write locks for reads
//
// instance of cursor being used for init_xxx and rnd_xxx functions
//
DBC *cursor;
uint32_t cursor_flags; // flags for cursor
//
// flags that are returned in table_flags()
//
ulonglong int_table_flags;
//
// count on the number of rows that gets changed, such as when write_row occurs
// this is meant to help keep estimate on number of elements in DB
//
ulonglong added_rows;
ulonglong deleted_rows;
uint last_dup_key;
//
// if set to 0, then the primary key is not hidden
// if non-zero (not necessarily 1), primary key is hidden
//
uint hidden_primary_key;
bool key_read, using_ignore;
//
// After a cursor encounters an error, the cursor will be unusable
// In case MySQL attempts to do a cursor operation (such as rnd_next
// or index_prev), we will gracefully return this error instead of crashing
//
int last_cursor_error;
//
// For instances where we successfully prelock a range or a table,
// we set this to true so that successive cursor calls can know
// know to limit the locking overhead in a call to the fractal tree
//
bool range_lock_grabbed;
//
// For bulk inserts, we want option of not updating auto inc
// until all inserts are done. By default, is false
//
bool delay_updating_ai_metadata; // if true, don't update auto-increment metadata until bulk load completes
bool ai_metadata_update_required; // if true, autoincrement metadata must be updated
//
// buffer for updating the status of long insert, delete, and update
// statements. Right now, the the messages are
// "[inserted|updated|deleted] about %llu rows",
// so a buffer of 200 is good enough.
//
char write_status_msg[200]; //buffer of 200 should be a good upper bound.
struct loader_context lc;
DB_LOADER* loader;
bool abort_loader;
int loader_error;
bool num_DBs_locked_in_bulk;
uint32_t lock_count;
bool fix_rec_buff_for_blob(ulong length);
bool fix_rec_update_buff_for_blob(ulong length);
uchar current_ident[TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH];
ulong max_row_length(const uchar * buf);
int pack_row_in_buff(
DBT * row,
const uchar* record,
uint index,
uchar* row_buff
);
int pack_row(
DBT * row,
const uchar* record,
uint index
);
int pack_old_row_for_update(
DBT * row,
const uchar* record,
uint index
);
uint32_t place_key_into_mysql_buff(KEY* key_info, uchar * record, uchar* data);
void unpack_key(uchar * record, DBT const *key, uint index);
uint32_t place_key_into_dbt_buff(KEY* key_info, uchar * buff, const uchar * record, bool* has_null, int key_length);
DBT* create_dbt_key_from_key(DBT * key, KEY* key_info, uchar * buff, const uchar * record, bool* has_null, bool dont_pack_pk, int key_length = MAX_KEY_LENGTH);
DBT *create_dbt_key_from_table(DBT * key, uint keynr, uchar * buff, const uchar * record, bool* has_null, int key_length = MAX_KEY_LENGTH);
DBT* create_dbt_key_for_lookup(DBT * key, KEY* key_info, uchar * buff, const uchar * record, bool* has_null, int key_length = MAX_KEY_LENGTH);
DBT *pack_key(DBT * key, uint keynr, uchar * buff, const uchar * key_ptr, uint key_length, int8_t inf_byte);
#if TOKU_INCLUDE_EXTENDED_KEYS
DBT *pack_ext_key(DBT * key, uint keynr, uchar * buff, const uchar * key_ptr, uint key_length, int8_t inf_byte);
#endif
bool key_changed(uint keynr, const uchar * old_row, const uchar * new_row);
int handle_cursor_error(int error, int err_to_return, uint keynr);
DBT *get_pos(DBT * to, uchar * pos);
int open_main_dictionary(const char* name, bool is_read_only, DB_TXN* txn);
int open_secondary_dictionary(DB** ptr, KEY* key_info, const char* name, bool is_read_only, DB_TXN* txn);
int acquire_table_lock (DB_TXN* trans, TABLE_LOCK_TYPE lt);
int estimate_num_rows(DB* db, uint64_t* num_rows, DB_TXN* txn);
bool has_auto_increment_flag(uint* index);
int write_frm_data(DB* db, DB_TXN* txn, const char* frm_name);
int verify_frm_data(const char* frm_name, DB_TXN* trans);
int remove_frm_data(DB *db, DB_TXN *txn);
int write_to_status(DB* db, HA_METADATA_KEY curr_key_data, void* data, uint size, DB_TXN* txn);
int remove_from_status(DB* db, HA_METADATA_KEY curr_key_data, DB_TXN* txn);
int write_metadata(DB* db, void* key, uint key_size, void* data, uint data_size, DB_TXN* txn);
int remove_metadata(DB* db, void* key_data, uint key_size, DB_TXN* transaction);
int update_max_auto_inc(DB* db, ulonglong val);
int remove_key_name_from_status(DB* status_block, char* key_name, DB_TXN* txn);
int write_key_name_to_status(DB* status_block, char* key_name, DB_TXN* txn);
int write_auto_inc_create(DB* db, ulonglong val, DB_TXN* txn);
void init_auto_increment();
bool can_replace_into_be_fast(TABLE_SHARE* table_share, KEY_AND_COL_INFO* kc_info, uint pk);
int initialize_share(
const char* name,
int mode
);
void set_query_columns(uint keynr);
int prelock_range (const key_range *start_key, const key_range *end_key);
int create_txn(THD* thd, tokudb_trx_data* trx);
bool may_table_be_empty(DB_TXN *txn);
int delete_or_rename_table (const char* from_name, const char* to_name, bool is_delete);
int delete_or_rename_dictionary( const char* from_name, const char* to_name, const char* index_name, bool is_key, DB_TXN* txn, bool is_delete);
int truncate_dictionary( uint keynr, DB_TXN* txn );
int create_secondary_dictionary(
const char* name,
TABLE* form,
KEY* key_info,
DB_TXN* txn,
KEY_AND_COL_INFO* kc_info,
uint32_t keynr,
bool is_hot_index,
enum row_type row_type
);
int create_main_dictionary(const char* name, TABLE* form, DB_TXN* txn, KEY_AND_COL_INFO* kc_info, enum row_type row_type);
void trace_create_table_info(const char *name, TABLE * form);
int is_index_unique(bool* is_unique, DB_TXN* txn, DB* db, KEY* key_info);
int is_val_unique(bool* is_unique, uchar* record, KEY* key_info, uint dict_index, DB_TXN* txn);
int do_uniqueness_checks(uchar* record, DB_TXN* txn, THD* thd);
void set_main_dict_put_flags(THD* thd, bool opt_eligible, uint32_t* put_flags);
int insert_row_to_main_dictionary(uchar* record, DBT* pk_key, DBT* pk_val, DB_TXN* txn);
int insert_rows_to_dictionaries_mult(DBT* pk_key, DBT* pk_val, DB_TXN* txn, THD* thd);
void test_row_packing(uchar* record, DBT* pk_key, DBT* pk_val);
uint32_t fill_row_mutator(
uchar* buf,
uint32_t* dropped_columns,
uint32_t num_dropped_columns,
TABLE* altered_table,
KEY_AND_COL_INFO* altered_kc_info,
uint32_t keynr,
bool is_add
);
// 0 <= active_index < table_share->keys || active_index == MAX_KEY
// tokudb_active_index = active_index if active_index < table_share->keys, else tokudb_active_index = primary_key = table_share->keys
uint tokudb_active_index;
public:
ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg);
~ha_tokudb();
const char *table_type() const;
const char *index_type(uint inx);
const char **bas_ext() const;
//
// Returns a bit mask of capabilities of storage engine. Capabilities
// defined in sql/handler.h
//
ulonglong table_flags(void) const;
ulong index_flags(uint inx, uint part, bool all_parts) const;
//
// Returns limit on the number of keys imposed by tokudb.
//
uint max_supported_keys() const {
return MAX_KEY;
}
uint extra_rec_buf_length() const {
return TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH;
}
ha_rows estimate_rows_upper_bound();
//
// Returns the limit on the key length imposed by tokudb.
//
uint max_supported_key_length() const {
return UINT_MAX32;
}
//
// Returns limit on key part length imposed by tokudb.
//
uint max_supported_key_part_length() const {
return UINT_MAX32;
}
const key_map *keys_to_use_for_scanning() {
return &key_map_full;
}
double scan_time();
double read_time(uint index, uint ranges, ha_rows rows);
// Defined in mariadb
double keyread_time(uint index, uint ranges, ha_rows rows);
// Defined in mysql 5.6
double index_only_read_time(uint keynr, double records);
int open(const char *name, int mode, uint test_if_locked);
int close(void);
void update_create_info(HA_CREATE_INFO* create_info);
int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info);
int delete_table(const char *name);
int rename_table(const char *from, const char *to);
int optimize(THD * thd, HA_CHECK_OPT * check_opt);
int analyze(THD * thd, HA_CHECK_OPT * check_opt);
int write_row(uchar * buf);
int update_row(const uchar * old_data, uchar * new_data);
int delete_row(const uchar * buf);
void start_bulk_insert(ha_rows rows);
int end_bulk_insert();
int end_bulk_insert(bool abort);
int prepare_index_scan();
int prepare_index_key_scan( const uchar * key, uint key_len );
int prepare_range_scan( const key_range *start_key, const key_range *end_key);
void column_bitmaps_signal();
int index_init(uint index, bool sorted);
int index_end();
int index_next_same(uchar * buf, const uchar * key, uint keylen);
int index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag);
int index_read_last(uchar * buf, const uchar * key, uint key_len);
int index_next(uchar * buf);
int index_prev(uchar * buf);
int index_first(uchar * buf);
int index_last(uchar * buf);
int rnd_init(bool scan);
int rnd_end();
int rnd_next(uchar * buf);
int rnd_pos(uchar * buf, uchar * pos);
int read_range_first(const key_range *start_key,
const key_range *end_key,
bool eq_range, bool sorted);
int read_range_next();
void position(const uchar * record);
int info(uint);
int extra(enum ha_extra_function operation);
int reset(void);
int external_lock(THD * thd, int lock_type);
int start_stmt(THD * thd, thr_lock_type lock_type);
ha_rows records_in_range(uint inx, key_range * min_key, key_range * max_key);
uint32_t get_cursor_isolation_flags(enum thr_lock_type lock_type, THD* thd);
THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to, enum thr_lock_type lock_type);
int get_status(DB_TXN* trans);
void init_hidden_prim_key_info();
inline void get_auto_primary_key(uchar * to) {
pthread_mutex_lock(&share->mutex);
share->auto_ident++;
hpk_num_to_char(to, share->auto_ident);
pthread_mutex_unlock(&share->mutex);
}
virtual void get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong * first_value, ulonglong * nb_reserved_values);
bool is_optimize_blocking();
bool is_auto_inc_singleton();
void print_error(int error, myf errflag);
uint8 table_cache_type() {
return HA_CACHE_TBL_TRANSACT;
}
bool primary_key_is_clustered() {
return true;
}
bool supports_clustered_keys() {
return true;
}
int cmp_ref(const uchar * ref1, const uchar * ref2);
bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
// MariaDB MRR introduced in 5.5
#ifdef MARIADB_BASE_VERSION
int multi_range_read_init(RANGE_SEQ_IF* seq,
void* seq_init_param,
uint n_ranges, uint mode,
HANDLER_BUFFER *buf);
int multi_range_read_next(range_id_t *range_info);
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
uint *flags, COST_VECT *cost);
ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
uint key_parts, uint *bufsz,
uint *flags, COST_VECT *cost);
int multi_range_read_explain_info(uint mrr_mode,
char *str, size_t size);
#endif
// MariaDB MRR introduced in 5.6
#if !defined(MARIADB_BASE_VERSION)
#if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode, HANDLER_BUFFER *buf);
int multi_range_read_next(char **range_info);
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
uint *flags, Cost_estimate *cost);
ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
uint *bufsz, uint *flags, Cost_estimate *cost);
#endif
#endif
// ICP introduced in MariaDB 5.5
Item* idx_cond_push(uint keyno, class Item* idx_cond);
#if TOKU_INCLUDE_ALTER_56
public:
enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
bool prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
bool inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
bool commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit);
private:
int alter_table_add_index(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
int alter_table_drop_index(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
int alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
int alter_table_expand_varchar_offsets(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
int alter_table_expand_columns(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
int alter_table_expand_one_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info, int expand_field_num);
void print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
int setup_kc_info(TABLE *altered_table, KEY_AND_COL_INFO *kc_info);
int new_row_descriptor(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, uint32_t idx, DBT *row_descriptor);
public:
#endif
#if TOKU_INCLUDE_ALTER_55
public:
// Returns true of the 5.6 inplace alter table interface is used.
bool try_hot_alter_table();
// We need a txn in the mysql_alter_table function to write new frm data, so this function
// gets called to sometimes create one.
void prepare_for_alter();
// Used by the partition storage engine to provide new frm data for the table.
int new_alter_table_frm_data(const uchar *frm_data, size_t frm_len);
#endif
private:
int tokudb_add_index(
TABLE *table_arg,
KEY *key_info,
uint num_of_keys,
DB_TXN* txn,
bool* inc_num_DBs,
bool* modified_DB
);
void restore_add_index(TABLE* table_arg, uint num_of_keys, bool incremented_numDBs, bool modified_DBs);
int drop_indexes(TABLE *table_arg, uint *key_num, uint num_of_keys, KEY *key_info, DB_TXN* txn);
void restore_drop_indexes(TABLE *table_arg, uint *key_num, uint num_of_keys);
public:
// delete all rows from the table
// effect: all dictionaries, including the main and indexes, should be empty
int discard_or_import_tablespace(my_bool discard);
int truncate();
int delete_all_rows();
void extract_hidden_primary_key(uint keynr, DBT const *found_key);
void read_key_only(uchar * buf, uint keynr, DBT const *found_key);
int read_row_callback (uchar * buf, uint keynr, DBT const *row, DBT const *found_key);
int read_primary_key(uchar * buf, uint keynr, DBT const *row, DBT const *found_key);
int unpack_blobs(
uchar* record,
const uchar* from_tokudb_blob,
uint32_t num_blob_bytes,
bool check_bitmap
);
int unpack_row(
uchar* record,
DBT const *row,
DBT const *key,
uint index
);
int prefix_cmp_dbts( uint keynr, const DBT* first_key, const DBT* second_key) {
return tokudb_prefix_cmp_dbt_key(share->key_file[keynr], first_key, second_key);
}
void track_progress(THD* thd);
void set_loader_error(int err);
void set_dup_value_for_pk(DBT* key);
//
// index into key_file that holds DB* that is indexed on
// the primary_key. this->key_file[primary_index] == this->file
//
uint primary_key;
int check(THD *thd, HA_CHECK_OPT *check_opt);
int fill_range_query_buf(
bool need_val,
DBT const *key,
DBT const *row,
int direction,
THD* thd,
uchar* buf,
DBT* key_to_compare
);
#if MYSQL_VERSION_ID >= 50521
enum row_type get_row_type() const;
#else
enum row_type get_row_type();
#endif
private:
int read_full_row(uchar * buf);
int __close();
int get_next(uchar* buf, int direction, DBT* key_to_compare);
int read_data_from_range_query_buff(uchar* buf, bool need_val);
// for ICP, only in MariaDB and MySQL 5.6
#if defined(MARIADB_BASE_VERSION) || (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699)
enum icp_result toku_handler_index_cond_check(Item* pushed_idx_cond);
#endif
void invalidate_bulk_fetch();
void invalidate_icp();
int delete_all_rows_internal();
void close_dsmrr();
void reset_dsmrr();
#if TOKU_INCLUDE_WRITE_FRM_DATA
int write_frm_data(const uchar *frm_data, size_t frm_len);
#endif
#if TOKU_INCLUDE_UPSERT
private:
int fast_update(THD *thd, List<Item> &update_fields, List<Item> &update_values, Item *conds);
bool check_fast_update(THD *thd, List<Item> &update_fields, List<Item> &update_values, Item *conds);
int send_update_message(List<Item> &update_fields, List<Item> &update_values, Item *conds, DB_TXN *txn);
int upsert(THD *thd, List<Item> &update_fields, List<Item> &update_values);
bool check_upsert(THD *thd, List<Item> &update_fields, List<Item> &update_values);
int send_upsert_message(THD *thd, List<Item> &update_fields, List<Item> &update_values, DB_TXN *txn);
#endif
};
#if MYSQL_VERSION_ID >= 50506
static inline void my_free(void *p, int arg) {
my_free(p);
}
static inline void *memcpy_fixed(void *a, const void *b, size_t n) {
return memcpy(a, b, n);
}
#endif
#endif

View File

@@ -0,0 +1,329 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
volatile int ha_tokudb_analyze_wait = 0; // debug
struct analyze_progress_extra {
THD *thd;
TOKUDB_SHARE *share;
TABLE_SHARE *table_share;
uint key_i;
const char *key_name;
time_t t_start;
char *write_status_msg;
};
static int analyze_progress(void *v_extra, uint64_t rows) {
struct analyze_progress_extra *extra = (struct analyze_progress_extra *) v_extra;
THD *thd = extra->thd;
if (thd->killed)
return ER_ABORTING_CONNECTION;
time_t t_now = time(0);
time_t t_limit = get_analyze_time(thd);
time_t t_start = extra->t_start;
if (t_limit > 0 && t_now - t_start > t_limit)
return ETIME;
float progress_rows = 0.0;
TOKUDB_SHARE *share = extra->share;
if (share->rows > 0)
progress_rows = (float) rows / (float) share->rows;
float progress_time = 0.0;
if (t_limit > 0)
progress_time = (float) (t_now - t_start) / (float) t_limit;
char *write_status_msg = extra->write_status_msg;
TABLE_SHARE *table_share = extra->table_share;
sprintf(write_status_msg, "%s.%s.%s %u of %u %.lf%% rows %.lf%% time",
table_share->db.str, table_share->table_name.str, extra->key_name,
extra->key_i, table_share->keys, progress_rows * 100.0, progress_time * 100.0);
thd_proc_info(thd, write_status_msg);
return 0;
}
int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) {
TOKUDB_DBUG_ENTER("ha_tokudb::analyze");
while (ha_tokudb_analyze_wait) sleep(1); // debug concurrency issues
uint64_t rec_per_key[table_share->key_parts];
int result = HA_ADMIN_OK;
DB_TXN *txn = transaction;
if (!txn)
result = HA_ADMIN_FAILED;
if (result == HA_ADMIN_OK) {
uint next_key_part = 0;
// compute cardinality for each key
for (uint i = 0; result == HA_ADMIN_OK && i < table_share->keys; i++) {
KEY *key_info = &table_share->key_info[i];
uint64_t num_key_parts = get_key_parts(key_info);
const char *key_name = i == primary_key ? "primary" : key_info->name;
struct analyze_progress_extra analyze_progress_extra = {
thd, share, table_share, i, key_name, time(0), write_status_msg
};
bool is_unique = false;
if (i == primary_key || (key_info->flags & HA_NOSAME))
is_unique = true;
int error = tokudb::analyze_card(share->key_file[i], txn, is_unique, num_key_parts, &rec_per_key[next_key_part],
tokudb_cmp_dbt_key_parts, analyze_progress, &analyze_progress_extra);
if (error != 0 && error != ETIME) {
result = HA_ADMIN_FAILED;
} else {
// debug
if (tokudb_debug & TOKUDB_DEBUG_ANALYZE) {
fprintf(stderr, "ha_tokudb::analyze %s.%s.%s ",
table_share->db.str, table_share->table_name.str, i == primary_key ? "primary" : table_share->key_info[i].name);
for (uint j = 0; j < num_key_parts; j++)
fprintf(stderr, "%lu ", rec_per_key[next_key_part+j]);
fprintf(stderr, "\n");
}
}
next_key_part += num_key_parts;
}
}
if (result == HA_ADMIN_OK)
tokudb::set_card_in_status(share->status_block, txn, table_share->key_parts, rec_per_key);
TOKUDB_DBUG_RETURN(result);
}
static int hot_poll_fun(void *extra, float progress) {
HOT_OPTIMIZE_CONTEXT context = (HOT_OPTIMIZE_CONTEXT)extra;
if (context->thd->killed) {
sprintf(context->write_status_msg, "The process has been killed, aborting hot optimize.");
return ER_ABORTING_CONNECTION;
}
float percentage = progress * 100;
sprintf(context->write_status_msg, "Optimization of index %u of %u about %.lf%% done", context->current_table + 1, context->num_tables, percentage);
thd_proc_info(context->thd, context->write_status_msg);
#ifdef HA_TOKUDB_HAS_THD_PROGRESS
if (context->progress_stage < context->current_table) {
// the progress stage is behind the current table, so move up
// to the next stage and set the progress stage to current.
thd_progress_next_stage(context->thd);
context->progress_stage = context->current_table;
}
// the percentage we report here is for the current stage/db
thd_progress_report(context->thd, (unsigned long long) percentage, 100);
#endif
return 0;
}
volatile int ha_tokudb_optimize_wait = 0; // debug
// flatten all DB's in this table, to do so, peform hot optimize on each db
int ha_tokudb::optimize(THD * thd, HA_CHECK_OPT * check_opt) {
TOKUDB_DBUG_ENTER("ha_tokudb::optimize");
while (ha_tokudb_optimize_wait) sleep(1); // debug
int error;
uint curr_num_DBs = table->s->keys + test(hidden_primary_key);
#ifdef HA_TOKUDB_HAS_THD_PROGRESS
// each DB is its own stage. as HOT goes through each db, we'll
// move on to the next stage.
thd_progress_init(thd, curr_num_DBs);
#endif
//
// for each DB, run optimize and hot_optimize
//
for (uint i = 0; i < curr_num_DBs; i++) {
DB* db = share->key_file[i];
error = db->optimize(db);
if (error) {
goto cleanup;
}
struct hot_optimize_context hc;
memset(&hc, 0, sizeof hc);
hc.thd = thd;
hc.write_status_msg = this->write_status_msg;
hc.ha = this;
hc.current_table = i;
hc.num_tables = curr_num_DBs;
error = db->hot_optimize(db, hot_poll_fun, &hc);
if (error) {
goto cleanup;
}
}
error = 0;
cleanup:
#ifdef HA_TOKUDB_HAS_THD_PROGRESS
thd_progress_end(thd);
#endif
TOKUDB_DBUG_RETURN(error);
}
struct check_context {
THD *thd;
};
static int ha_tokudb_check_progress(void *extra, float progress) {
struct check_context *context = (struct check_context *) extra;
int result = 0;
if (context->thd->killed)
result = ER_ABORTING_CONNECTION;
return result;
}
static void ha_tokudb_check_info(THD *thd, TABLE *table, const char *msg) {
if (thd->vio_ok()) {
char tablename[256];
snprintf(tablename, sizeof tablename, "%s.%s", table->s->db.str, table->s->table_name.str);
thd->protocol->prepare_for_resend();
thd->protocol->store(tablename, strlen(tablename), system_charset_info);
thd->protocol->store("check", 5, system_charset_info);
thd->protocol->store("info", 4, system_charset_info);
thd->protocol->store(msg, strlen(msg), system_charset_info);
thd->protocol->write();
}
}
volatile int ha_tokudb_check_wait = 0; // debug
int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) {
TOKUDB_DBUG_ENTER("check");
while (ha_tokudb_check_wait) sleep(1); // debug
const char *old_proc_info = thd->proc_info;
thd_proc_info(thd, "tokudb::check");
int result = HA_ADMIN_OK;
int r;
int keep_going = 1;
if (check_opt->flags & T_QUICK) {
keep_going = 0;
}
if (check_opt->flags & T_EXTEND) {
keep_going = 1;
}
r = acquire_table_lock(transaction, lock_write);
if (r != 0)
result = HA_ADMIN_INTERNAL_ERROR;
if (result == HA_ADMIN_OK) {
uint32_t num_DBs = table_share->keys + test(hidden_primary_key);
snprintf(write_status_msg, sizeof write_status_msg, "%s primary=%d num=%d", share->table_name, primary_key, num_DBs);
if (tokudb_debug & TOKUDB_DEBUG_CHECK) {
ha_tokudb_check_info(thd, table, write_status_msg);
time_t now = time(0);
char timebuf[32];
fprintf(stderr, "%.24s ha_tokudb::check %s\n", ctime_r(&now, timebuf), write_status_msg);
}
for (uint i = 0; i < num_DBs; i++) {
DB *db = share->key_file[i];
const char *kname = i == primary_key ? "primary" : table_share->key_info[i].name;
snprintf(write_status_msg, sizeof write_status_msg, "%s key=%s %u", share->table_name, kname, i);
thd_proc_info(thd, write_status_msg);
if (tokudb_debug & TOKUDB_DEBUG_CHECK) {
ha_tokudb_check_info(thd, table, write_status_msg);
time_t now = time(0);
char timebuf[32];
fprintf(stderr, "%.24s ha_tokudb::check %s\n", ctime_r(&now, timebuf), write_status_msg);
}
struct check_context check_context = { thd };
r = db->verify_with_progress(db, ha_tokudb_check_progress, &check_context, (tokudb_debug & TOKUDB_DEBUG_CHECK) != 0, keep_going);
snprintf(write_status_msg, sizeof write_status_msg, "%s key=%s %u result=%d", share->table_name, kname, i, r);
thd_proc_info(thd, write_status_msg);
if (tokudb_debug & TOKUDB_DEBUG_CHECK) {
ha_tokudb_check_info(thd, table, write_status_msg);
time_t now = time(0);
char timebuf[32];
fprintf(stderr, "%.24s ha_tokudb::check %s\n", ctime_r(&now, timebuf), write_status_msg);
}
if (result == HA_ADMIN_OK && r != 0) {
result = HA_ADMIN_CORRUPT;
if (!keep_going)
break;
}
}
}
thd_proc_info(thd, old_proc_info);
TOKUDB_DBUG_RETURN(result);
}

View File

@@ -0,0 +1,128 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#if TOKU_INCLUDE_ALTER_55
#include "ha_tokudb_alter_common.cc"
bool ha_tokudb::try_hot_alter_table() {
TOKUDB_DBUG_ENTER("try_hot_alter_table");
THD *thd = ha_thd();
bool disable_hot_alter = get_disable_hot_alter(thd);
DBUG_RETURN(!disable_hot_alter);
}
void ha_tokudb::prepare_for_alter() {
TOKUDB_DBUG_ENTER("prepare_for_alter");
// this is here because mysql commits the transaction before prepare_for_alter is called.
// we need a transaction to add indexes, drop indexes, and write the new frm data, so we
// create one. this transaction will be retired by mysql alter table when it commits
//
// if we remove the commit before prepare_for_alter, then this is not needed.
transaction = NULL;
THD *thd = ha_thd();
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
assert(trx);
// for partitioned tables, a transaction may already exist,
// as we call prepare_for_alter on all partitions
if (!trx->sub_sp_level) {
int error = create_txn(thd, trx);
assert(error == 0);
assert(thd->in_sub_stmt == 0);
}
transaction = trx->sub_sp_level;
DBUG_VOID_RETURN;
}
int ha_tokudb::new_alter_table_frm_data(const uchar *frm_data, size_t frm_len) {
return write_frm_data(frm_data, frm_len);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,834 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#if !defined(TOKUDB_ALTER_COMMON)
#define TOKUDB_ALTER_COMMON
static bool tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print_error, bool check_field_index) __attribute__((unused));
static bool tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print_error, bool check_field_index) {
bool retval;
if (table->s->keys != altered_table->s->keys) {
if (print_error) {
sql_print_error("tables have different number of keys");
}
retval = false;
goto cleanup;
}
if (table->s->primary_key != altered_table->s->primary_key) {
if (print_error) {
sql_print_error(
"Tables have different primary keys, %d %d",
table->s->primary_key,
altered_table->s->primary_key
);
}
retval = false;
goto cleanup;
}
for (uint32_t i=0; i < table->s->keys; i++) {
KEY* curr_orig_key = &table->key_info[i];
KEY* curr_altered_key = &altered_table->key_info[i];
if (strcmp(curr_orig_key->name, curr_altered_key->name)) {
if (print_error) {
sql_print_error(
"key %d has different name, %s %s",
i,
curr_orig_key->name,
curr_altered_key->name
);
}
retval = false;
goto cleanup;
}
if (((curr_orig_key->flags & HA_CLUSTERING) == 0) != ((curr_altered_key->flags & HA_CLUSTERING) == 0)) {
if (print_error) {
sql_print_error(
"keys disagree on if they are clustering, %d, %d",
get_key_parts(curr_orig_key),
get_key_parts(curr_altered_key)
);
}
retval = false;
goto cleanup;
}
if (((curr_orig_key->flags & HA_NOSAME) == 0) != ((curr_altered_key->flags & HA_NOSAME) == 0)) {
if (print_error) {
sql_print_error(
"keys disagree on if they are unique, %d, %d",
get_key_parts(curr_orig_key),
get_key_parts(curr_altered_key)
);
}
retval = false;
goto cleanup;
}
if (get_key_parts(curr_orig_key) != get_key_parts(curr_altered_key)) {
if (print_error) {
sql_print_error(
"keys have different number of parts, %d, %d",
get_key_parts(curr_orig_key),
get_key_parts(curr_altered_key)
);
}
retval = false;
goto cleanup;
}
//
// now verify that each field in the key is the same
//
for (uint32_t j = 0; j < get_key_parts(curr_orig_key); j++) {
KEY_PART_INFO* curr_orig_part = &curr_orig_key->key_part[j];
KEY_PART_INFO* curr_altered_part = &curr_altered_key->key_part[j];
Field* curr_orig_field = curr_orig_part->field;
Field* curr_altered_field = curr_altered_part->field;
if (curr_orig_part->length != curr_altered_part->length) {
if (print_error) {
sql_print_error(
"Key %s has different length at index %d",
curr_orig_key->name,
j
);
}
retval = false;
goto cleanup;
}
bool are_fields_same;
are_fields_same = (check_field_index) ?
(curr_orig_part->fieldnr == curr_altered_part->fieldnr &&
fields_are_same_type(curr_orig_field, curr_altered_field)) :
(are_two_fields_same(curr_orig_field,curr_altered_field));
if (!are_fields_same) {
if (print_error) {
sql_print_error(
"Key %s has different field at index %d",
curr_orig_key->name,
j
);
}
retval = false;
goto cleanup;
}
}
}
retval = true;
cleanup:
return retval;
}
// MySQL sets the null_bit as a number that you can bit-wise AND a byte to
// to evaluate whether a field is NULL or not. This value is a power of 2, from
// 2^0 to 2^7. We return the position of the bit within the byte, which is
// lg null_bit
static inline uint32_t get_null_bit_position(uint32_t null_bit) __attribute__((unused));
static inline uint32_t get_null_bit_position(uint32_t null_bit) {
uint32_t retval = 0;
switch(null_bit) {
case (1):
retval = 0;
break;
case (2):
retval = 1;
break;
case (4):
retval = 2;
break;
case (8):
retval = 3;
break;
case (16):
retval = 4;
break;
case (32):
retval = 5;
break;
case (64):
retval = 6;
break;
case (128):
retval = 7;
break;
default:
assert(false);
}
return retval;
}
// returns the index of the null bit of field.
static inline uint32_t get_overall_null_bit_position(TABLE* table, Field* field) __attribute__((unused));
static inline uint32_t get_overall_null_bit_position(TABLE* table, Field* field) {
uint32_t offset = get_null_offset(table, field);
uint32_t null_bit = field->null_bit;
return offset*8 + get_null_bit_position(null_bit);
}
// not static since 51 uses this and 56 does not
static bool are_null_bits_in_order(TABLE* table) __attribute__((unused));
static bool are_null_bits_in_order(TABLE* table) {
uint32_t curr_null_pos = 0;
bool first = true;
bool retval = true;
for (uint i = 0; i < table->s->fields; i++) {
Field* curr_field = table->field[i];
bool nullable = (curr_field->null_bit != 0);
if (nullable) {
uint32_t pos = get_overall_null_bit_position(
table,
curr_field
);
if (!first && pos != curr_null_pos+1){
retval = false;
break;
}
first = false;
curr_null_pos = pos;
}
}
return retval;
}
static uint32_t get_first_null_bit_pos(TABLE* table) __attribute__((unused));
static uint32_t get_first_null_bit_pos(TABLE* table) {
uint32_t table_pos = 0;
for (uint i = 0; i < table->s->fields; i++) {
Field* curr_field = table->field[i];
bool nullable = (curr_field->null_bit != 0);
if (nullable) {
table_pos = get_overall_null_bit_position(
table,
curr_field
);
break;
}
}
return table_pos;
}
static bool is_column_default_null(TABLE* src_table, uint32_t field_index) __attribute__((unused));
static bool is_column_default_null(TABLE* src_table, uint32_t field_index) {
Field* curr_field = src_table->field[field_index];
bool is_null_default = false;
bool nullable = curr_field->null_bit != 0;
if (nullable) {
uint32_t null_bit_position = get_overall_null_bit_position(src_table, curr_field);
is_null_default = is_overall_null_position_set(
src_table->s->default_values,
null_bit_position
);
}
return is_null_default;
}
static uint32_t fill_static_row_mutator(
uchar* buf,
TABLE* orig_table,
TABLE* altered_table,
KEY_AND_COL_INFO* orig_kc_info,
KEY_AND_COL_INFO* altered_kc_info,
uint32_t keynr
)
{
//
// start packing extra
//
uchar* pos = buf;
// says what the operation is
pos[0] = UP_COL_ADD_OR_DROP;
pos++;
//
// null byte information
//
memcpy(pos, &orig_table->s->null_bytes, sizeof(orig_table->s->null_bytes));
pos += sizeof(orig_table->s->null_bytes);
memcpy(pos, &altered_table->s->null_bytes, sizeof(orig_table->s->null_bytes));
pos += sizeof(altered_table->s->null_bytes);
//
// num_offset_bytes
//
assert(orig_kc_info->num_offset_bytes <= 2);
pos[0] = orig_kc_info->num_offset_bytes;
pos++;
assert(altered_kc_info->num_offset_bytes <= 2);
pos[0] = altered_kc_info->num_offset_bytes;
pos++;
//
// size of fixed fields
//
uint32_t fixed_field_size = orig_kc_info->mcp_info[keynr].fixed_field_size;
memcpy(pos, &fixed_field_size, sizeof(fixed_field_size));
pos += sizeof(fixed_field_size);
fixed_field_size = altered_kc_info->mcp_info[keynr].fixed_field_size;
memcpy(pos, &fixed_field_size, sizeof(fixed_field_size));
pos += sizeof(fixed_field_size);
//
// length of offsets
//
uint32_t len_of_offsets = orig_kc_info->mcp_info[keynr].len_of_offsets;
memcpy(pos, &len_of_offsets, sizeof(len_of_offsets));
pos += sizeof(len_of_offsets);
len_of_offsets = altered_kc_info->mcp_info[keynr].len_of_offsets;
memcpy(pos, &len_of_offsets, sizeof(len_of_offsets));
pos += sizeof(len_of_offsets);
uint32_t orig_start_null_pos = get_first_null_bit_pos(orig_table);
memcpy(pos, &orig_start_null_pos, sizeof(orig_start_null_pos));
pos += sizeof(orig_start_null_pos);
uint32_t altered_start_null_pos = get_first_null_bit_pos(altered_table);
memcpy(pos, &altered_start_null_pos, sizeof(altered_start_null_pos));
pos += sizeof(altered_start_null_pos);
assert((pos-buf) == STATIC_ROW_MUTATOR_SIZE);
return pos - buf;
}
static uint32_t fill_dynamic_row_mutator(
uchar* buf,
uint32_t* columns,
uint32_t num_columns,
TABLE* src_table,
KEY_AND_COL_INFO* src_kc_info,
uint32_t keynr,
bool is_add,
bool* out_has_blobs
)
{
uchar* pos = buf;
bool has_blobs = false;
uint32_t cols = num_columns;
memcpy(pos, &cols, sizeof(cols));
pos += sizeof(cols);
for (uint32_t i = 0; i < num_columns; i++) {
uint32_t curr_index = columns[i];
Field* curr_field = src_table->field[curr_index];
pos[0] = is_add ? COL_ADD : COL_DROP;
pos++;
//
// NULL bit information
//
bool is_null_default = false;
bool nullable = curr_field->null_bit != 0;
if (!nullable) {
pos[0] = 0;
pos++;
}
else {
pos[0] = 1;
pos++;
// write position of null byte that is to be removed
uint32_t null_bit_position = get_overall_null_bit_position(src_table, curr_field);
memcpy(pos, &null_bit_position, sizeof(null_bit_position));
pos += sizeof(null_bit_position);
//
// if adding a column, write the value of the default null_bit
//
if (is_add) {
is_null_default = is_overall_null_position_set(
src_table->s->default_values,
null_bit_position
);
pos[0] = is_null_default ? 1 : 0;
pos++;
}
}
if (src_kc_info->field_lengths[curr_index] != 0) {
// we have a fixed field being dropped
// store the offset and the number of bytes
pos[0] = COL_FIXED;
pos++;
//store the offset
uint32_t fixed_field_offset = src_kc_info->cp_info[keynr][curr_index].col_pack_val;
memcpy(pos, &fixed_field_offset, sizeof(fixed_field_offset));
pos += sizeof(fixed_field_offset);
//store the number of bytes
uint32_t num_bytes = src_kc_info->field_lengths[curr_index];
memcpy(pos, &num_bytes, sizeof(num_bytes));
pos += sizeof(num_bytes);
if (is_add && !is_null_default) {
uint curr_field_offset = field_offset(curr_field, src_table);
memcpy(
pos,
src_table->s->default_values + curr_field_offset,
num_bytes
);
pos += num_bytes;
}
}
else if (src_kc_info->length_bytes[curr_index] != 0) {
pos[0] = COL_VAR;
pos++;
//store the index of the variable column
uint32_t var_field_index = src_kc_info->cp_info[keynr][curr_index].col_pack_val;
memcpy(pos, &var_field_index, sizeof(var_field_index));
pos += sizeof(var_field_index);
if (is_add && !is_null_default) {
uint curr_field_offset = field_offset(curr_field, src_table);
uint32_t len_bytes = src_kc_info->length_bytes[curr_index];
uint32_t data_length = get_var_data_length(
src_table->s->default_values + curr_field_offset,
len_bytes
);
memcpy(pos, &data_length, sizeof(data_length));
pos += sizeof(data_length);
memcpy(
pos,
src_table->s->default_values + curr_field_offset + len_bytes,
data_length
);
pos += data_length;
}
}
else {
pos[0] = COL_BLOB;
pos++;
has_blobs = true;
}
}
*out_has_blobs = has_blobs;
return pos-buf;
}
static uint32_t fill_static_blob_row_mutator(
uchar* buf,
TABLE* src_table,
KEY_AND_COL_INFO* src_kc_info
)
{
uchar* pos = buf;
// copy number of blobs
memcpy(pos, &src_kc_info->num_blobs, sizeof(src_kc_info->num_blobs));
pos += sizeof(src_kc_info->num_blobs);
// copy length bytes for each blob
for (uint32_t i = 0; i < src_kc_info->num_blobs; i++) {
uint32_t curr_field_index = src_kc_info->blob_fields[i];
Field* field = src_table->field[curr_field_index];
uint32_t len_bytes = field->row_pack_length();
assert(len_bytes <= 4);
pos[0] = len_bytes;
pos++;
}
return pos-buf;
}
static uint32_t fill_dynamic_blob_row_mutator(
uchar* buf,
uint32_t* columns,
uint32_t num_columns,
TABLE* src_table,
KEY_AND_COL_INFO* src_kc_info,
bool is_add
)
{
uchar* pos = buf;
for (uint32_t i = 0; i < num_columns; i++) {
uint32_t curr_field_index = columns[i];
Field* curr_field = src_table->field[curr_field_index];
if (src_kc_info->field_lengths[curr_field_index] == 0 &&
src_kc_info->length_bytes[curr_field_index]== 0
)
{
// find out which blob it is
uint32_t blob_index = src_kc_info->num_blobs;
for (uint32_t j = 0; j < src_kc_info->num_blobs; j++) {
if (curr_field_index == src_kc_info->blob_fields[j]) {
blob_index = j;
break;
}
}
// assert we found blob in list
assert(blob_index < src_kc_info->num_blobs);
pos[0] = is_add ? COL_ADD : COL_DROP;
pos++;
memcpy(pos, &blob_index, sizeof(blob_index));
pos += sizeof(blob_index);
if (is_add) {
uint32_t len_bytes = curr_field->row_pack_length();
assert(len_bytes <= 4);
pos[0] = len_bytes;
pos++;
// create a zero length blob field that can be directly copied in
// for now, in MySQL, we can only have blob fields
// that have no default value
memset(pos, 0, len_bytes);
pos += len_bytes;
}
}
else {
// not a blob, continue
continue;
}
}
return pos-buf;
}
// TODO: carefully review to make sure that the right information is used
// TODO: namely, when do we get stuff from share->kc_info and when we get
// TODO: it from altered_kc_info, and when is keynr associated with the right thing
uint32_t ha_tokudb::fill_row_mutator(
uchar* buf,
uint32_t* columns,
uint32_t num_columns,
TABLE* altered_table,
KEY_AND_COL_INFO* altered_kc_info,
uint32_t keynr,
bool is_add
)
{
if (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE_INFO) {
printf("*****some info:*************\n");
printf(
"old things: num_null_bytes %d, num_offset_bytes %d, fixed_field_size %d, fixed_field_size %d\n",
table->s->null_bytes,
share->kc_info.num_offset_bytes,
share->kc_info.mcp_info[keynr].fixed_field_size,
share->kc_info.mcp_info[keynr].len_of_offsets
);
printf(
"new things: num_null_bytes %d, num_offset_bytes %d, fixed_field_size %d, fixed_field_size %d\n",
altered_table->s->null_bytes,
altered_kc_info->num_offset_bytes,
altered_kc_info->mcp_info[keynr].fixed_field_size,
altered_kc_info->mcp_info[keynr].len_of_offsets
);
printf("****************************\n");
}
uchar* pos = buf;
bool has_blobs = false;
pos += fill_static_row_mutator(
pos,
table,
altered_table,
&share->kc_info,
altered_kc_info,
keynr
);
if (is_add) {
pos += fill_dynamic_row_mutator(
pos,
columns,
num_columns,
altered_table,
altered_kc_info,
keynr,
is_add,
&has_blobs
);
}
else {
pos += fill_dynamic_row_mutator(
pos,
columns,
num_columns,
table,
&share->kc_info,
keynr,
is_add,
&has_blobs
);
}
if (has_blobs) {
pos += fill_static_blob_row_mutator(
pos,
table,
&share->kc_info
);
if (is_add) {
pos += fill_dynamic_blob_row_mutator(
pos,
columns,
num_columns,
altered_table,
altered_kc_info,
is_add
);
}
else {
pos += fill_dynamic_blob_row_mutator(
pos,
columns,
num_columns,
table,
&share->kc_info,
is_add
);
}
}
return pos-buf;
}
static bool all_fields_are_same_type(TABLE *table_a, TABLE *table_b) {
if (table_a->s->fields != table_b->s->fields)
return false;
for (uint i = 0; i < table_a->s->fields; i++) {
Field *field_a = table_a->field[i];
Field *field_b = table_b->field[i];
if (!fields_are_same_type(field_a, field_b))
return false;
}
return true;
}
static bool column_rename_supported(TABLE* orig_table, TABLE* new_table, bool alter_column_order) __attribute__((unused));
static bool column_rename_supported(TABLE* orig_table, TABLE* new_table, bool alter_column_order) {
bool retval = false;
bool keys_same_for_cr;
uint num_fields_with_different_names = 0;
uint field_with_different_name = orig_table->s->fields;
if (orig_table->s->fields != new_table->s->fields) {
retval = false;
goto cleanup;
}
if (alter_column_order) {
retval = false;
goto cleanup;
}
if (!all_fields_are_same_type(orig_table, new_table)) {
retval = false;
goto cleanup;
}
for (uint i = 0; i < orig_table->s->fields; i++) {
Field* orig_field = orig_table->field[i];
Field* new_field = new_table->field[i];
if (!fields_have_same_name(orig_field, new_field)) {
num_fields_with_different_names++;
field_with_different_name = i;
}
}
// only allow one renamed field
if (num_fields_with_different_names != 1) {
retval = false;
goto cleanup;
}
assert(field_with_different_name < orig_table->s->fields);
//
// at this point, we have verified that the two tables have
// the same field types and with ONLY one field with a different name.
// We have also identified the field with the different name
//
// Now we need to check the indexes
//
keys_same_for_cr = tables_have_same_keys(
orig_table,
new_table,
false,
true
);
if (!keys_same_for_cr) {
retval = false;
goto cleanup;
}
retval = true;
cleanup:
return retval;
}
static int find_changed_columns(uint32_t* changed_columns, uint32_t* num_changed_columns, TABLE* smaller_table, TABLE* bigger_table) __attribute__((unused));
static int find_changed_columns(uint32_t* changed_columns, uint32_t* num_changed_columns, TABLE* smaller_table, TABLE* bigger_table) {
int retval;
uint curr_new_col_index = 0;
uint32_t curr_num_changed_columns=0;
assert(bigger_table->s->fields > smaller_table->s->fields);
for (uint i = 0; i < smaller_table->s->fields; i++, curr_new_col_index++) {
if (curr_new_col_index >= bigger_table->s->fields) {
sql_print_error("error in determining changed columns");
retval = 1;
goto cleanup;
}
Field* curr_field_in_new = bigger_table->field[curr_new_col_index];
Field* curr_field_in_orig = smaller_table->field[i];
while (!fields_have_same_name(curr_field_in_orig, curr_field_in_new)) {
changed_columns[curr_num_changed_columns] = curr_new_col_index;
curr_num_changed_columns++;
curr_new_col_index++;
curr_field_in_new = bigger_table->field[curr_new_col_index];
if (curr_new_col_index >= bigger_table->s->fields) {
sql_print_error("error in determining changed columns");
retval = 1;
goto cleanup;
}
}
// at this point, curr_field_in_orig and curr_field_in_new should be the same, let's verify
// make sure the two fields that have the same name are ok
if (!are_two_fields_same(curr_field_in_orig, curr_field_in_new)) {
sql_print_error(
"Two fields that were supposedly the same are not: \
%s in original, %s in new",
curr_field_in_orig->field_name,
curr_field_in_new->field_name
);
retval = 1;
goto cleanup;
}
}
for (uint i = curr_new_col_index; i < bigger_table->s->fields; i++) {
changed_columns[curr_num_changed_columns] = i;
curr_num_changed_columns++;
}
*num_changed_columns = curr_num_changed_columns;
retval = 0;
cleanup:
return retval;
}
static bool tables_have_same_keys_and_columns(TABLE* first_table, TABLE* second_table, bool print_error) __attribute__((unused));
static bool tables_have_same_keys_and_columns(TABLE* first_table, TABLE* second_table, bool print_error) {
bool retval;
if (first_table->s->null_bytes != second_table->s->null_bytes) {
retval = false;
if (print_error) {
sql_print_error(
"tables have different number of null bytes, %d, %d",
first_table->s->null_bytes,
second_table->s->null_bytes
);
}
goto exit;
}
if (first_table->s->fields != second_table->s->fields) {
retval = false;
if (print_error) {
sql_print_error(
"tables have different number of fields, %d, %d",
first_table->s->fields,
second_table->s->fields
);
}
goto exit;
}
for (uint i = 0; i < first_table->s->fields; i++) {
Field* a = first_table->field[i];
Field* b = second_table->field[i];
if (!are_two_fields_same(a,b)) {
retval = false;
sql_print_error(
"tables have different fields at position %d",
i
);
goto exit;
}
}
if (!tables_have_same_keys(first_table, second_table, print_error, true)) {
retval = false;
goto exit;
}
retval = true;
exit:
return retval;
}
#if TOKU_INCLUDE_WRITE_FRM_DATA
// write the new frm data to the status dictionary using the alter table transaction
int ha_tokudb::write_frm_data(const uchar *frm_data, size_t frm_len) {
TOKUDB_DBUG_ENTER("write_frm_data");
int error = 0;
if (TOKU_PARTITION_WRITE_FRM_DATA || table->part_info == NULL) {
// write frmdata to status
THD *thd = ha_thd();
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
assert(trx);
DB_TXN *txn = trx->stmt; // use alter table transaction
assert(txn);
error = write_to_status(share->status_block, hatoku_frm_data, (void *)frm_data, (uint)frm_len, txn);
}
TOKUDB_DBUG_RETURN(error);
}
#endif
#endif

View File

@@ -0,0 +1,136 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
/****************************************************************************
* DS-MRR implementation, essentially copied from InnoDB/MyISAM/Maria
***************************************************************************/
/**
* Multi Range Read interface, DS-MRR calls
*/
int ha_tokudb::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode,
HANDLER_BUFFER *buf)
{
return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf);
}
int ha_tokudb::multi_range_read_next(range_id_t *range_info)
{
return ds_mrr.dsmrr_next(range_info);
}
ha_rows ha_tokudb::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
uint *flags,
COST_VECT *cost)
{
/* See comments in ha_myisam::multi_range_read_info_const */
ds_mrr.init(this, table);
ha_rows res= ds_mrr.dsmrr_info_const(keyno, seq, seq_init_param, n_ranges,
bufsz, flags, cost);
return res;
}
ha_rows ha_tokudb::multi_range_read_info(uint keyno, uint n_ranges, uint keys,
uint key_parts, uint *bufsz,
uint *flags, COST_VECT *cost)
{
ds_mrr.init(this, table);
ha_rows res= ds_mrr.dsmrr_info(keyno, n_ranges, keys, key_parts, bufsz,
flags, cost);
return res;
}
int ha_tokudb::multi_range_read_explain_info(uint mrr_mode, char *str, size_t size)
{
return ds_mrr.dsmrr_explain_info(mrr_mode, str, size);
}

View File

@@ -0,0 +1,128 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
/****************************************************************************
* MRR implementation: use DS-MRR, essentially copied from MyISAM
***************************************************************************/
int ha_tokudb::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode,
HANDLER_BUFFER *buf)
{
return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf);
}
int ha_tokudb::multi_range_read_next(char **range_info)
{
return ds_mrr.dsmrr_next(range_info);
}
ha_rows ha_tokudb::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
uint *flags, Cost_estimate *cost)
{
/*
This call is here because there is no location where this->table would
already be known.
TODO: consider moving it into some per-query initialization call.
*/
ds_mrr.init(this, table);
return ds_mrr.dsmrr_info_const(keyno, seq, seq_init_param, n_ranges, bufsz,
flags, cost);
}
ha_rows ha_tokudb::multi_range_read_info(uint keyno, uint n_ranges, uint keys,
uint *bufsz, uint *flags,
Cost_estimate *cost)
{
ds_mrr.init(this, table);
return ds_mrr.dsmrr_info(keyno, n_ranges, keys, bufsz, flags, cost);
}

File diff suppressed because it is too large Load Diff

3300
storage/tokudb/hatoku_cmp.cc Normal file

File diff suppressed because it is too large Load Diff

480
storage/tokudb/hatoku_cmp.h Normal file
View File

@@ -0,0 +1,480 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#ifndef _HATOKU_CMP
#define _HATOKU_CMP
#include "stdint.h"
#include <db.h>
//
// A MySQL row is encoded in TokuDB, as follows:
// Keys:
// Keys pack the defined columns in the order that they are declared.
// The primary key contains only the columns listed
// If no primary key is defined, then an eight byte hidden primary key is autogenerated (like an auto increment) and used
// Secondary keys contains the defined key and the primary key.
// Two examples:
// 1) table foo (a int, b int, c int, d int, key(b))
// The key of the main dictionary contains an eight byte autogenerated hidden primary key
// The key of key-b is the column 'b' followed by the hidden primary key
// 2) table foo (a int, b int, c int, d int, primary key(a), key(b))
// The key of the main dictionary contains 'a'
// The key of key-b is the column 'b followed by 'a'
// Vals:
// For secondary keys they are empty.
// For the main dictionary and clustering keys, they contain all columns that do not show up in the dictionary's key
// Two examples:
// 1) table foo (a int, b int, c int, d varchar(100), primary key(a), clustering key d(d), clustering key d2(d(20))
// the val of the main dictionary contains (b,c,d)
// the val of d contains (b,c)
// the val of d2 contains (b,c,d). d is there because the entire row does not show up in the key
// Vals are encoded as follows. They have four components:
// 1) Null bytes: contains a bit field that states what columns are NULL.
// 2) Fixed fields: all fixed fields are then packed together. If a fixed field is NULL, its data is considered junk
// 3) varchars and varbinaries: stored in two pieces, first all the offsets and then all the data. If a var field is NULL, its data is considered junk
// 4) blobs: stored in (length, data) pairs. If a blob is NULL, its data is considered junk
// An example:
// Table: (a int, b varchar(20), c blob, d bigint, e varbinary(10), f largeblob, g varchar(10)) <-- no primary key defined
// Row inserted: (1, "bbb", "cc", 100, "eeeee", "ffff", "g")
// The packed format of the val looks like:
// NULL byte <-- 1 byte to encode nothing is NULL
// 1 <-- four bytes for 'a'
// 100 <-- four bytes for 'd'
// 3,8,9 <--offsets for location of data fields, note offsets point to where data ENDS
// "bbbeeeeeg" <-- data for variable length stuff
// 2,"cc",4,"ffff"<-- data that stores the blobs
// The structures below describe are used for the TokuDB encoding of a row
//
// used for queries
typedef struct st_col_pack_info {
uint32_t col_pack_val; //offset if fixed, pack_index if var
} COL_PACK_INFO;
//
// used to define a couple of characteristics of a packed val for the main dictionary or a clustering dictionary
// fixed_field_size is the size of the fixed fields in the val.
// len_of_offsets is the size of the bytes that make up the offsets of variable size columns
// Some notes:
// If the val has no fixed fields, fixed_field_size is 0
// If the val has no variable fields, len_of_offsets is 0
// The number of null bytes at the beginning of a row is not saved, it is derived from table_share->null_bytes
// The pointer to where the variable data in a val starts is table_share->null_bytes + fixed_field_size + len_of_offsets
// To figure out where the blobs start, find the last offset listed (if offsets exist)
//
typedef struct st_multi_col_pack_info {
uint32_t fixed_field_size; //where the fixed length stuff ends and the offsets for var stuff begins
uint32_t len_of_offsets; //length of the offset bytes in a packed row
} MULTI_COL_PACK_INFO;
typedef struct st_key_and_col_info {
//
// bitmaps for each key. key_filters[i] is associated with the i'th dictionary
// States what columns are not stored in the vals of each key, because
// the column is stored in the key. So, for example, the table (a int, b int, c int, d int, primary key (b,d)) will
// have bit 1 (for 'b') and bit 3 (for 'd') of the primary key's bitmap set for the main dictionary's bitmap,
// because 'b' and 'd' do not show up in the val
//
MY_BITMAP key_filters[MAX_KEY+1];
//
// following three arrays are used to identify the types of rows in the field
// If table->field[i] is a fixed field:
// field_lengths[i] stores the field length, which is fixed
// length_bytes[i] is 0
// 'i' does not show up in the array blob_fields
// If table->field[i] is a varchar or varbinary:
// field_lengths[i] is 0
// length_bytes[i] stores the number of bytes MySQL uses to encode the length of the field in table->record[0]
// 'i' does not show up in the array blob_fields
// If table->field[i] is a blob:
// field_lengths[i] is 0
// length_bytes[i] is 0
// 'i' shows up in blob_fields
//
uint16_t* field_lengths; //stores the field lengths of fixed size fields (1<<16 - 1 max),
uchar* length_bytes; // stores the length of lengths of varchars and varbinaries
uint32_t* blob_fields; // list of indexes of blob fields,
uint32_t num_blobs; // number of blobs in the table
//
// val packing info for all dictionaries. i'th one represents info for i'th dictionary
//
MULTI_COL_PACK_INFO mcp_info[MAX_KEY+1];
COL_PACK_INFO* cp_info[MAX_KEY+1];
//
// number bytes used to represent an offset in a val. Can be 1 or 2.
// The number of var fields in a val for dictionary i can be evaluated by
// mcp_info[i].len_of_offsets/num_offset_bytes.
//
uint32_t num_offset_bytes; //number of bytes needed to encode the offset
} KEY_AND_COL_INFO;
bool field_valid_for_tokudb_table(Field* field);
void get_var_field_info(
uint32_t* field_len,
uint32_t* start_offset,
uint32_t var_field_index,
const uchar* var_field_offset_ptr,
uint32_t num_offset_bytes
);
void get_blob_field_info(
uint32_t* start_offset,
uint32_t len_of_offsets,
const uchar* var_field_data_ptr,
uint32_t num_offset_bytes
);
static inline uint32_t get_blob_field_len(
const uchar* from_tokudb,
uint32_t len_bytes
)
{
uint32_t length = 0;
switch (len_bytes) {
case (1):
length = (uint32_t)(*from_tokudb);
break;
case (2):
length = uint2korr(from_tokudb);
break;
case (3):
length = uint3korr(from_tokudb);
break;
case (4):
length = uint4korr(from_tokudb);
break;
default:
assert(false);
}
return length;
}
static inline const uchar* unpack_toku_field_blob(
uchar *to_mysql,
const uchar* from_tokudb,
uint32_t len_bytes,
bool skip
)
{
uint32_t length = 0;
const uchar* data_ptr = NULL;
if (!skip) {
memcpy(to_mysql, from_tokudb, len_bytes);
}
length = get_blob_field_len(from_tokudb,len_bytes);
data_ptr = from_tokudb + len_bytes;
if (!skip) {
memcpy(to_mysql + len_bytes, (uchar *)(&data_ptr), sizeof(uchar *));
}
return (from_tokudb + len_bytes + length);
}
static inline uint get_null_offset(TABLE* table, Field* field) {
#if 50606 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
return field->null_offset(table->record[0]);
#else
return (uint) ((uchar*) field->null_ptr - (uchar*) table->record[0]);
#endif
}
typedef enum {
toku_type_int = 0,
toku_type_double,
toku_type_float,
toku_type_fixbinary,
toku_type_fixstring,
toku_type_varbinary,
toku_type_varstring,
toku_type_blob,
toku_type_hpk, //for hidden primary key
toku_type_unknown
} TOKU_TYPE;
TOKU_TYPE mysql_to_toku_type (Field* field);
uchar* pack_toku_varbinary_from_desc(
uchar* to_tokudb,
const uchar* from_desc,
uint32_t key_part_length, //number of bytes to use to encode the length in to_tokudb
uint32_t field_length //length of field
);
uchar* pack_toku_varstring_from_desc(
uchar* to_tokudb,
const uchar* from_desc,
uint32_t key_part_length, //number of bytes to use to encode the length in to_tokudb
uint32_t field_length,
uint32_t charset_num//length of field
);
uchar* pack_toku_key_field(
uchar* to_tokudb,
uchar* from_mysql,
Field* field,
uint32_t key_part_length //I really hope this is temporary as I phase out the pack_cmp stuff
);
uchar* pack_key_toku_key_field(
uchar* to_tokudb,
uchar* from_mysql,
Field* field,
uint32_t key_part_length //I really hope this is temporary as I phase out the pack_cmp stuff
);
uchar* unpack_toku_key_field(
uchar* to_mysql,
uchar* from_tokudb,
Field* field,
uint32_t key_part_length
);
//
// for storing NULL byte in keys
//
#define NULL_COL_VAL 0
#define NONNULL_COL_VAL 1
//
// for storing if rest of key is +/- infinity
//
#define COL_NEG_INF -1
#define COL_ZERO 0
#define COL_POS_INF 1
//
// information for hidden primary keys
//
#define TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH 8
//
// function to convert a hidden primary key into a byte stream that can be stored in DBT
//
static inline void hpk_num_to_char(uchar* to, ulonglong num) {
int8store(to, num);
}
//
// function that takes a byte stream of a hidden primary key and returns a ulonglong
//
static inline ulonglong hpk_char_to_num(uchar* val) {
return uint8korr(val);
}
int tokudb_compare_two_keys(
const void* new_key_data,
const uint32_t new_key_size,
const void* saved_key_data,
const uint32_t saved_key_size,
const void* row_desc,
const uint32_t row_desc_size,
bool cmp_prefix
);
int tokudb_cmp_dbt_key(DB* db, const DBT *keya, const DBT *keyb);
//TODO: QQQ Only do one direction for prefix.
int tokudb_prefix_cmp_dbt_key(DB *file, const DBT *keya, const DBT *keyb);
static int tokudb_compare_two_key_parts(
const void* new_key_data,
const uint32_t new_key_size,
const void* saved_key_data,
const uint32_t saved_key_size,
const void* row_desc,
const uint32_t row_desc_size,
uint max_parts
);
static int tokudb_cmp_dbt_key_parts(DB *file, const DBT *keya, const DBT *keyb, uint max_parts);
int create_toku_key_descriptor(
uchar* buf,
bool is_first_hpk,
KEY* first_key,
bool is_second_hpk,
KEY* second_key
);
uint32_t create_toku_main_key_pack_descriptor (
uchar* buf
);
uint32_t get_max_clustering_val_pack_desc_size(
TABLE_SHARE* table_share
);
uint32_t create_toku_clustering_val_pack_descriptor (
uchar* buf,
uint pk_index,
TABLE_SHARE* table_share,
KEY_AND_COL_INFO* kc_info,
uint32_t keynr,
bool is_clustering
);
static inline bool is_key_clustering(
void* row_desc,
uint32_t row_desc_size
)
{
return (row_desc_size > 0);
}
uint32_t pack_clustering_val_from_desc(
uchar* buf,
void* row_desc,
uint32_t row_desc_size,
const DBT* pk_val
);
uint32_t get_max_secondary_key_pack_desc_size(
KEY_AND_COL_INFO* kc_info
);
uint32_t create_toku_secondary_key_pack_descriptor (
uchar* buf,
bool has_hpk,
uint pk_index,
TABLE_SHARE* table_share,
TABLE* table,
KEY_AND_COL_INFO* kc_info,
KEY* key_info,
KEY* prim_key
);
static inline bool is_key_pk(
void* row_desc,
uint32_t row_desc_size
)
{
uchar* buf = (uchar *)row_desc;
return buf[0];
}
uint32_t max_key_size_from_desc(
void* row_desc,
uint32_t row_desc_size
);
uint32_t pack_key_from_desc(
uchar* buf,
void* row_desc,
uint32_t row_desc_size,
const DBT* pk_key,
const DBT* pk_val
);
bool fields_have_same_name(
Field* a,
Field* b
);
bool fields_are_same_type(
Field* a,
Field* b
);
bool are_two_fields_same(
Field* a,
Field* b
);
#endif

View File

@@ -0,0 +1,353 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#ifndef _HATOKU_DEF
#define _HATOKU_DEF
#include "mysql_version.h"
#if MYSQL_VERSION_ID < 50506
#include "mysql_priv.h"
#else
#include "sql_table.h"
#include "handler.h"
#include "table.h"
#include "log.h"
#include "sql_class.h"
#include "sql_show.h"
#include "discover.h"
#endif
#include "db.h"
#include "toku_os.h"
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
// In MariaDB 5.3, thread progress reporting was introduced.
// Only include that functionality if we're using maria 5.3 +
#ifdef MARIADB_BASE_VERSION
#if MYSQL_VERSION_ID >= 50300
#define HA_TOKUDB_HAS_THD_PROGRESS
#endif
#endif
#if defined(TOKUDB_PATCHES) && TOKUDB_PATCHES == 0
#elif 100000 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100099
#define TOKU_INCLUDE_ALTER_56 0
#define TOKU_INCLUDE_ALTER_55 0
#define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 0
#define TOKU_INCLUDE_XA 1
#define TOKU_PARTITION_WRITE_FRM_DATA 0
#define TOKU_INCLUDE_WRITE_FRM_DATA 0
#elif 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
#define TOKU_INCLUDE_ALTER_56 1
#define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 1
#define TOKU_INCLUDE_XA 1
#define TOKU_PARTITION_WRITE_FRM_DATA 1
#define TOKU_INCLUDE_WRITE_FRM_DATA 1
#define TOKU_INCLUDE_UPSERT 1
#define TOKU_INCLUDE_EXTENDED_KEYS 1
#define TOKU_INCLUDE_OTHER_DB_TYPE 0
#elif 50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599
#define TOKU_INCLUDE_ALTER_56 1
#define TOKU_INCLUDE_ALTER_55 1
#define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 1
#define TOKU_INCLUDE_XA 1
#define TOKU_PARTITION_WRITE_FRM_DATA 1
#define TOKU_INCLUDE_WRITE_FRM_DATA 1
#define TOKU_INCLUDE_UPSERT 1
#if defined(MARIADB_BASE_VERSION)
#define TOKU_INCLUDE_EXTENDED_KEYS 1
#endif
#define TOKU_INCLUDE_OTHER_DB_TYPE 1
#else
#error
#endif
#if !defined(HA_CLUSTERING)
#define HA_CLUSTERING 0
#endif
#if !defined(HA_CLUSTERED_INDEX)
#define HA_CLUSTERED_INDEX 0
#endif
#if !defined(HA_CAN_WRITE_DURING_OPTIMIZE)
#define HA_CAN_WRITE_DURING_OPTIMIZE 0
#endif
// In older (< 5.5) versions of MySQL and MariaDB, it is necessary to
// use a read/write lock on the key_file array in a table share,
// because table locks do not protect the race of some thread closing
// a table and another calling ha_tokudb::info()
//
// In version 5.5 and, a higher layer "metadata lock" was introduced
// to synchronize threads that open, close, call info(), etc on tables.
// In these versions, we don't need the key_file lock
#if MYSQL_VERSION_ID < 50500
#define HA_TOKUDB_NEEDS_KEY_FILE_LOCK
#endif
extern ulong tokudb_debug;
//
// returns maximum length of dictionary name, such as key-NAME
// NAME_CHAR_LEN is max length of the key name, and have upper bound of 10 for key-
//
#define MAX_DICT_NAME_LEN NAME_CHAR_LEN + 10
// QQQ how to tune these?
#define HA_TOKUDB_RANGE_COUNT 100
/* extra rows for estimate_rows_upper_bound() */
#define HA_TOKUDB_EXTRA_ROWS 100
/* Bits for share->status */
#define STATUS_PRIMARY_KEY_INIT 0x1
// tokudb debug tracing
#define TOKUDB_DEBUG_INIT 1
#define TOKUDB_DEBUG_OPEN 2
#define TOKUDB_DEBUG_ENTER 4
#define TOKUDB_DEBUG_RETURN 8
#define TOKUDB_DEBUG_ERROR 16
#define TOKUDB_DEBUG_TXN 32
#define TOKUDB_DEBUG_AUTO_INCREMENT 64
#define TOKUDB_DEBUG_LOCK 256
#define TOKUDB_DEBUG_LOCKRETRY 512
#define TOKUDB_DEBUG_CHECK_KEY 1024
#define TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS 2048
#define TOKUDB_DEBUG_ALTER_TABLE_INFO 4096
#define TOKUDB_DEBUG_UPSERT 8192
#define TOKUDB_DEBUG_CHECK (1<<14)
#define TOKUDB_DEBUG_ANALYZE (1<<15)
#define TOKUDB_TRACE(f, ...) \
printf("%d:%s:%d:" f, my_tid(), __FILE__, __LINE__, ##__VA_ARGS__);
static inline unsigned int my_tid() {
return (unsigned int)toku_os_gettid();
}
#define TOKUDB_DBUG_ENTER(f, ...) \
{ \
if (tokudb_debug & TOKUDB_DEBUG_ENTER) { \
TOKUDB_TRACE(f "\n", ##__VA_ARGS__); \
} \
} \
DBUG_ENTER(__FUNCTION__);
#define TOKUDB_DBUG_RETURN(r) \
{ \
int rr = (r); \
if ((tokudb_debug & TOKUDB_DEBUG_RETURN) || (rr != 0 && (tokudb_debug & TOKUDB_DEBUG_ERROR))) { \
TOKUDB_TRACE("%s:return %d\n", __FUNCTION__, rr); \
} \
DBUG_RETURN(rr); \
}
#define TOKUDB_DBUG_DUMP(s, p, len) \
{ \
TOKUDB_TRACE("%s:%s", __FUNCTION__, s); \
uint i; \
for (i=0; i<len; i++) { \
printf("%2.2x", ((uchar*)p)[i]); \
} \
printf("\n"); \
}
typedef enum {
hatoku_iso_not_set = 0,
hatoku_iso_read_uncommitted,
hatoku_iso_read_committed,
hatoku_iso_repeatable_read,
hatoku_iso_serializable
} HA_TOKU_ISO_LEVEL;
typedef struct st_tokudb_stmt_progress {
ulonglong inserted;
ulonglong updated;
ulonglong deleted;
ulonglong queried;
bool using_loader;
} tokudb_stmt_progress;
typedef struct st_tokudb_trx_data {
DB_TXN *all;
DB_TXN *stmt;
DB_TXN *sp_level;
DB_TXN *sub_sp_level;
uint tokudb_lock_count;
tokudb_stmt_progress stmt_progress;
bool checkpoint_lock_taken;
} tokudb_trx_data;
extern char *tokudb_data_dir;
extern const char *ha_tokudb_ext;
static inline void reset_stmt_progress (tokudb_stmt_progress* val) {
val->deleted = 0;
val->inserted = 0;
val->updated = 0;
val->queried = 0;
}
static inline int get_name_length(const char *name) {
int n = 0;
const char *newname = name;
n += strlen(newname);
n += strlen(ha_tokudb_ext);
return n;
}
//
// returns maximum length of path to a dictionary
//
static inline int get_max_dict_name_path_length(const char *tablename) {
int n = 0;
n += get_name_length(tablename);
n += 1; //for the '-'
n += MAX_DICT_NAME_LEN;
return n;
}
static inline void make_name(char *newname, const char *tablename, const char *dictname) {
const char *newtablename = tablename;
char *nn = newname;
assert(tablename);
assert(dictname);
nn += sprintf(nn, "%s", newtablename);
nn += sprintf(nn, "-%s", dictname);
}
static inline void commit_txn(DB_TXN* txn, uint32_t flags) {
if (tokudb_debug & TOKUDB_DEBUG_TXN)
TOKUDB_TRACE("commit_txn %p\n", txn);
int r = txn->commit(txn, flags);
if (r != 0) {
sql_print_error("tried committing transaction %p and got error code %d", txn, r);
}
assert(r == 0);
}
static inline void abort_txn(DB_TXN* txn) {
if (tokudb_debug & TOKUDB_DEBUG_TXN)
TOKUDB_TRACE("abort_txn %p\n", txn);
int r = txn->abort(txn);
if (r != 0) {
sql_print_error("tried aborting transaction %p and got error code %d", txn, r);
}
assert(r == 0);
}
/* The purpose of this file is to define assert() for use by the handlerton.
* The intention is for a failed handlerton assert to invoke a failed assert
* in the fractal tree layer, which dumps engine status to the error log.
*/
void toku_hton_assert_fail(const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/, int/*errno*/) __attribute__((__visibility__("default"))) __attribute__((__noreturn__));
#undef assert
#define assert(expr) ((expr) ? (void)0 : toku_hton_assert_fail(#expr, __FUNCTION__, __FILE__, __LINE__, errno))
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,140 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#ifndef _HATOKU_HTON
#define _HATOKU_HTON
#include "db.h"
extern handlerton *tokudb_hton;
extern DB_ENV *db_env;
extern DB *metadata_db;
enum srv_row_format_enum {
SRV_ROW_FORMAT_UNCOMPRESSED = 0,
SRV_ROW_FORMAT_ZLIB = 1,
SRV_ROW_FORMAT_QUICKLZ = 2,
SRV_ROW_FORMAT_LZMA = 3,
SRV_ROW_FORMAT_FAST = 4,
SRV_ROW_FORMAT_SMALL = 5,
SRV_ROW_FORMAT_DEFAULT = 6
};
typedef enum srv_row_format_enum srv_row_format_t;
// thread variables
uint get_pk_insert_mode(THD* thd);
bool get_load_save_space(THD* thd);
bool get_disable_slow_alter(THD* thd);
bool get_disable_hot_alter(THD* thd);
bool get_create_index_online(THD* thd);
bool get_disable_prefetching(THD* thd);
bool get_prelock_empty(THD* thd);
bool get_log_client_errors(THD* thd);
uint get_tokudb_block_size(THD* thd);
uint get_tokudb_read_block_size(THD* thd);
uint get_tokudb_read_buf_size(THD* thd);
srv_row_format_t get_row_format(THD *thd);
#if TOKU_INCLUDE_UPSERT
bool get_enable_fast_update(THD *thd);
bool get_disable_slow_update(THD *thd);
bool get_enable_fast_upsert(THD *thd);
bool get_disable_slow_upsert(THD *thd);
#endif
uint get_analyze_time(THD *thd);
extern HASH tokudb_open_tables;
extern pthread_mutex_t tokudb_mutex;
extern pthread_mutex_t tokudb_meta_mutex;
extern uint32_t tokudb_write_status_frequency;
extern uint32_t tokudb_read_status_frequency;
void toku_hton_update_primary_key_bytes_inserted(uint64_t row_size);
#endif //#ifdef _HATOKU_HTON

View File

@@ -0,0 +1,26 @@
The MySQL tests for TokuDB are divided into common tests and tests specific to a
particular MySQL distribution.
The tests that are common for all MySQL distributions can be found in the
svn:tokudb/mysql/tests/mysql-test directory.
The tests that are specific to a particular distribution can be found in that
distribution's mysql-test directory. For example, tests that are specific to
MySQL 5.5.21 are found in the svn:tokudb/mysql.com/mysql-5.5.21/mysql-test directory.
When we run tests on a particular MySQL distribution, we run the union of the common
tests and the tests that are in that distributions mysql-test directory. The union
is formed by overlaying the common tests with the distribution specific tests.
Here is an example. There are a bunch of alter table tests in that should be common
to all MySQL distributions. These tests are in the
svn:tokudb/mysql/tests/mysql-test/suite/tokudb.alter_table directory.
However, the ai_di.test has behaviour that is different on MySQL 5.5 than previous
MySQL distributions. There is another version of this test in the MySQL 5.5.21 source
directory. This version replaces the common test since it has the same test name.
It is easy to disable a test. Just add the test name to the "disabled.def" file in the
test directory.
We use the run.mysql.tests.bash script from the mysql/scripts directory to run the tests.

View File

@@ -0,0 +1,13 @@
include/master-slave.inc
[connection master]
CREATE TABLE t1(`a` INT) ENGINE=TokuDB;
CREATE TABLE t2(`a` INT) ENGINE=InnoDB;
begin;
insert into t1 values (1);
insert into t2 values (1);
commit;
TABLES t1 and t2 must be equal otherwise an error will be thrown.
include/diff_tables.inc [master:test.t1, slave:test.t1]
include/diff_tables.inc [master:test.t2, slave:test.t2]
drop table t1,t2;
include/rpl_end.inc

View File

@@ -0,0 +1 @@
--log-slave-updates=0

View File

@@ -0,0 +1,25 @@
--source include/master-slave.inc
--source include/have_tokudb.inc
--source include/have_innodb.inc
eval CREATE TABLE t1(`a` INT) ENGINE=TokuDB;
eval CREATE TABLE t2(`a` INT) ENGINE=InnoDB;
connection master;
begin;
insert into t1 values (1);
insert into t2 values (1);
commit;
sync_slave_with_master;
--echo TABLES t1 and t2 must be equal otherwise an error will be thrown.
let $diff_tables= master:test.t1, slave:test.t1;
source include/diff_tables.inc;
let $diff_tables= master:test.t2, slave:test.t2;
source include/diff_tables.inc;
connection master;
drop table t1,t2;
--source include/rpl_end.inc

View File

@@ -0,0 +1,15 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1 (a int, b int) engine=tokudb;
insert into t1 values (1,1),(1,2),(2,1),(2,2);
select count(*) from t1 where b > 0;
count(*)
4
alter table t1 add clustering index b(b);
explain select count(*) from t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NA b b 5 NA NA NA
select count(*) from t1 where b > 0;
count(*)
4
DROP TABLE t1;

View File

@@ -0,0 +1,43 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, str varchar(3), b int, c int, z int, y int, x int, r int, s int, t int, d char(4), primary key (a,b), key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r a b
0 20 10 0
2 18 9 1
4 16 8 2
6 14 7 3
8 12 6 4
10 10 5 5
12 8 4 6
14 6 3 7
16 4 2 8
18 2 1 9
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a str b c z y x r s t d
1 s 9 18 10 100 1000 2 3 4 AB
2 s 8 16 20 200 2000 4 6 8 AB
3 s 7 14 30 300 3000 6 9 12 AB
4 s 6 12 40 400 4000 8 12 16 AB
5 s 5 10 50 500 5000 10 15 20 AB
6 s 4 8 60 600 6000 12 18 24 AB
7 s 3 6 70 700 7000 14 21 28 AB
8 s 2 4 80 800 8000 16 24 32 AB
9 s 1 2 90 900 9000 18 27 36 AB
10 s 0 0 100 1000 10000 20 30 40 AB

View File

@@ -0,0 +1,17 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
ERROR 23000: Can't write; duplicate key in table 't1'
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
5 52 18 5 5 5 2 5 5

View File

@@ -0,0 +1,30 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, str varchar(3), b int, c int, z int, y int, x int, r int, s int, t int, d char(4), key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a str b c z y x r s t d
1 s 9 18 10 100 1000 2 3 4 AB
2 s 8 16 20 200 2000 4 6 8 AB
3 s 7 14 30 300 3000 6 9 12 AB
4 s 6 12 40 400 4000 8 12 16 AB
5 s 5 10 50 500 5000 10 15 20 AB
6 s 4 8 60 600 6000 12 18 24 AB
7 s 3 6 70 700 7000 14 21 28 AB
8 s 2 4 80 800 8000 16 24 32 AB
9 s 1 2 90 900 9000 18 27 36 AB
10 s 0 0 100 1000 10000 20 30 40 AB

View File

@@ -0,0 +1,30 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int,key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40

View File

@@ -0,0 +1,30 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, str varchar(3), b int, c int, z int, y int, x int, r int, s int, t int, d char(4), key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo1 foo1 NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a str b c z y x r s t d
1 s 9 18 10 100 1000 2 3 4 AB
2 s 8 16 20 200 2000 4 6 8 AB
3 s 7 14 30 300 3000 6 9 12 AB
4 s 6 12 40 400 4000 8 12 16 AB
5 s 5 10 50 500 5000 10 15 20 AB
6 s 4 8 60 600 6000 12 18 24 AB
7 s 3 6 70 700 7000 14 21 28 AB
8 s 2 4 80 800 8000 16 24 32 AB
9 s 1 2 90 900 9000 18 27 36 AB
10 s 0 0 100 1000 10000 20 30 40 AB

View File

@@ -0,0 +1,30 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo1 foo1 NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40

View File

@@ -0,0 +1,161 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL; Using where
c r
18 2
16 4
14 6
12 8
10 10
8 12
6 14
4 16
2 18
0 20
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
ERROR 42000: Duplicate key name 'foo'
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL z z NULL NULL NULL; Using where; Using index
z a
10 1
20 2
30 3
40 4
50 5
60 6
70 7
80 8
90 9
100 10
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40

View File

@@ -0,0 +1,5 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
ERROR 23000: Can't write; duplicate key in table 't1'

View File

@@ -0,0 +1,5 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
ERROR 23000: Duplicate entry '18-2' for key 'foo'

View File

@@ -0,0 +1,56 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL foo 10 NULL 10 Using index
c z
0 100
2 90
4 80
6 70
8 60
10 50
12 40
14 30
16 20
18 10
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL bar 10 NULL 10 Using index
t r
4 2
8 4
12 6
16 8
20 10
24 12
28 14
32 16
36 18
40 20
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40

View File

@@ -0,0 +1,43 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r a b
0 20 10 0
2 18 9 1
4 16 8 2
6 14 7 3
8 12 6 4
10 10 5 5
12 8 4 6
14 6 3 7
16 4 2 8
18 2 1 9
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40

View File

@@ -0,0 +1,43 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, str varchar(3), b int, c int, z int, y int, x int, r int, s int, t int, d char(4), primary key (a,b), key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo1 foo1 NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo1 foo1 NULL NULL NULL; Using where; Using index
c r a b
0 20 10 0
2 18 9 1
4 16 8 2
6 14 7 3
8 12 6 4
10 10 5 5
12 8 4 6
14 6 3 7
16 4 2 8
18 2 1 9
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a str b c z y x r s t d
1 s 9 18 10 100 1000 2 3 4 AB
2 s 8 16 20 200 2000 4 6 8 AB
3 s 7 14 30 300 3000 6 9 12 AB
4 s 6 12 40 400 4000 8 12 16 AB
5 s 5 10 50 500 5000 10 15 20 AB
6 s 4 8 60 600 6000 12 18 24 AB
7 s 3 6 70 700 7000 14 21 28 AB
8 s 2 4 80 800 8000 16 24 32 AB
9 s 1 2 90 900 9000 18 27 36 AB
10 s 0 0 100 1000 10000 20 30 40 AB

View File

@@ -0,0 +1,43 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo1 foo1 NULL NULL NULL; Using where; Using index
c r
0 20
2 18
4 16
6 14
8 12
10 10
12 8
14 6
16 4
18 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo1 foo1 NULL NULL NULL; Using where; Using index
c r a b
0 20 10 0
2 18 9 1
4 16 8 2
6 14 7 3
8 12 6 4
10 10 5 5
12 8 4 6
14 6 3 7
16 4 2 8
18 2 1 9
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40

View File

@@ -0,0 +1,161 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r a b
0 20 10 0
2 18 9 1
4 16 8 2
6 14 7 3
8 12 6 4
10 10 5 5
12 8 4 6
14 6 3 7
16 4 2 8
18 2 1 9
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL; Using where
c r a b
18 2 1 9
16 4 2 8
14 6 3 7
12 8 4 6
10 10 5 5
8 12 6 4
6 14 7 3
4 16 8 2
2 18 9 1
0 20 10 0
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r a b
0 20 10 0
2 18 9 1
4 16 8 2
6 14 7 3
8 12 6 4
10 10 5 5
12 8 4 6
14 6 3 7
16 4 2 8
18 2 1 9
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
ERROR 42000: Duplicate key name 'foo'
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r a b
0 20 10 0
2 18 9 1
4 16 8 2
6 14 7 3
8 12 6 4
10 10 5 5
12 8 4 6
14 6 3 7
16 4 2 8
18 2 1 9
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL z z NULL NULL NULL; Using where; Using index
z a b
10 1 9
20 2 8
30 3 7
40 4 6
50 5 5
60 6 4
70 7 3
80 8 2
90 9 1
100 10 0
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL foo foo NULL NULL NULL; Using where; Using index
c r a b
0 20 10 0
2 18 9 1
4 16 8 2
6 14 7 3
8 12 6 4
10 10 5 5
12 8 4 6
14 6 3 7
16 4 2 8
18 2 1 9
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL NULL NULL NULL NULL NULL;
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40

View File

@@ -0,0 +1,5 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
ERROR 23000: Can't write; duplicate key in table 't1'

View File

@@ -0,0 +1,5 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
ERROR 23000: Duplicate entry '18-2' for key 'foo'

View File

@@ -0,0 +1,56 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL foo 10 NULL 10 Using index
c z a b
0 100 10 0
2 90 9 1
4 80 8 2
6 70 7 3
8 60 6 4
10 50 5 5
12 40 4 6
14 30 3 7
16 20 2 8
18 10 1 9
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL bar 10 NULL 10 Using index
t r a b
4 2 1 9
8 4 2 8
12 6 3 7
16 8 4 6
20 10 5 5
24 12 6 4
28 14 7 3
32 16 8 2
36 18 9 1
40 20 10 0
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40

View File

@@ -0,0 +1,56 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL foo 10 NULL 10 Using index
c z
0 100
2 90
4 80
6 70
8 60
10 50
12 40
14 30
16 20
18 10
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL bar 10 NULL 10 Using index
t r
4 2
8 4
12 6
16 8
20 10
24 12
28 14
32 16
36 18
40 20
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
a b c z y x r s t
1 9 18 10 100 1000 2 3 4
2 8 16 20 200 2000 4 6 8
3 7 14 30 300 3000 6 9 12
4 6 12 40 400 4000 8 12 16
5 5 10 50 500 5000 10 15 20
6 4 8 60 600 6000 12 18 24
7 3 6 70 700 7000 14 21 28
8 2 4 80 800 8000 16 24 32
9 1 2 90 900 9000 18 27 36
10 0 0 100 1000 10000 20 30 40

View File

@@ -0,0 +1,72 @@
DROP TABLE IF EXISTS t1;
set session tokudb_disable_slow_alter=ON;
CREATE TABLE t1 (
sca_code char(6) NOT NULL,
cat_code char(6) NOT NULL,
lan_code char(2) NOT NULL,
sca_pic varchar(100),
sca_sdesc varchar(50),
sca_sch_desc varchar(16)
, PRIMARY KEY (sca_code, cat_code, lan_code)
) Engine = tokudb ;
INSERT INTO t1 ( sca_code, cat_code, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES
( 'PD', 'J', 'EN', NULL, NULL, 'PENDANT'),
( 'RI', 'J', 'EN', NULL, NULL, 'RING'),
( 'QQ', 'N', 'EN', 'not null', NULL, 'RING');
alter table t1 add index sca_pic (cat_code, sca_pic);
select count(*) from t1 where sca_pic >= 'n';
count(*)
1
alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
ERROR 42000: Table 't1' uses an extension that doesn't exist in this XYZ version
select count(*) from t1 where sca_pic >= 'n';
count(*)
1
DROP TABLE t1;
DROP TABLE t1;
ERROR 42S02: Unknown table 't1'
CREATE TABLE t1 (
sca_code char(6) NOT NULL,
cat_code char(6) NOT NULL,
sca_desc varchar(50),
lan_code char(2) NOT NULL,
sca_pic varchar(100),
sca_sdesc varchar(50),
sca_sch_desc varchar(16),
PRIMARY KEY (sca_code, cat_code, lan_code),
INDEX sca_pic (sca_pic)
) Engine = tokudb ;
INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'
),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
select count(*) from t1 where sca_code = 'PD';
count(*)
1
select count(*) from t1 where sca_code <= 'PD';
count(*)
1
select count(*) from t1 where sca_pic is null;
count(*)
2
alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
ERROR 42000: Table 't1' uses an extension that doesn't exist in this XYZ version
select count(*) from t1 where sca_code='PD' and sca_pic is null;
count(*)
1
select count(*) from t1 where cat_code='E';
count(*)
0
alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
ERROR 42000: Table 't1' uses an extension that doesn't exist in this XYZ version
select count(*) from t1 where sca_code='PD' and sca_pic is null;
count(*)
1
select count(*) from t1 where sca_pic >= 'n';
count(*)
1
select sca_pic from t1 where sca_pic is null;
sca_pic
NULL
NULL
update t1 set sca_pic="test" where sca_pic is null;
delete from t1 where sca_code='pd';
DROP TABLE t1;

View File

@@ -0,0 +1,10 @@
SET DEFAULT_STORAGE_ENGINE = tokudb;
*** Bug #23691 ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a char(5));
CREATE INDEX i1 on t1 (a(3));
INSERT INTO t1 VALUES ('abcde');
SELECT * FROM t1 WHERE a = 'abcde';
a
abcde
DROP TABLE t1;

View File

@@ -0,0 +1,68 @@
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
*** Bug #23692 ***
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
DROP TABLE IF EXISTS t4;
CREATE TABLE t1 (a char(1), key (a));
INSERT INTO t1 VALUES (0x00);
SELECT count(*) FROM t1 WHERE a < '';
count(*)
1
SELECT count(*) FROM t1 WHERE a = '';
count(*)
0
SELECT count(*) FROM t1 WHERE a > '';
count(*)
0
CREATE TABLE t2 (a varbinary(5));
CREATE INDEX i ON t2 (a);
INSERT INTO t2 VALUES (0x02), (0x0202);
SELECT count(*) FROM t2 WHERE a >= 0x02 OR a = 0x0202;
count(*)
2
SELECT hex(a) FROM t2 WHERE a < 0x02;
hex(a)
SELECT hex(a) FROM t2 WHERE a = 0x02;
hex(a)
02
SELECT hex(a) FROM t2 WHERE a > 0x02;
hex(a)
0202
CREATE TABLE t3 (a char(5));
CREATE INDEX i ON t3 (a);
INSERT INTO t3 VALUES (0x4200), (0x4209), (0x42), (0x4220), (0x4242);
SELECT hex(a) FROM t3 WHERE a < 0x42;
hex(a)
4200
4209
SELECT hex(a) FROM t3 WHERE a = 0x42;
hex(a)
42
42
SELECT hex(a) FROM t3 WHERE a > 0x42;
hex(a)
4242
SELECT hex(a) FROM t3 WHERE a LIKE 'a%';
hex(a)
CREATE TABLE t4 (a varchar(5) character set ucs2, key(a)) engine=tokudb;
INSERT INTO t4 VALUES (0x00420000), (0x00420009), (0x0041001f), (0x0042), (0x00420020), (0x00420042);
SELECT hex(a) FROM t4 WHERE a < 'a';
hex(a)
0041001F
SELECT hex(a) FROM t4 WHERE a = 'a';
hex(a)
SELECT hex(a) FROM t4 WHERE a > 'a';
hex(a)
00420000
00420009
0042
00420020
00420042
SELECT hex(a) FROM t4 WHERE a LIKE 'a%';
hex(a)
0041001F
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;

View File

@@ -0,0 +1,22 @@
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
*** Bug #23818_I ***
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS p1;
/* Does not fail with "b varchar(256) character set ucs2" */
CREATE TABLE t1 (a int, b varchar(1000) character set ucs2, c varchar(10000));
INSERT INTO t1 VALUES (null,null,null),(1,'',''),(2,'a','a');
CREATE INDEX i1 ON t1 (b(550));
CREATE PROCEDURE p1 ()
BEGIN
declare v int default 0;
while v < 100 do
SET @x = concat('update t1 set a = ', v,', b = repeat(0x', hex(rand()*10000),',rand()*549), c = repeat(0x', hex(rand()*255), ',rand()*9999)');
/* select v,@x; */
PREPARE stmt1 FROM @x;
EXECUTE stmt1;
SET v = v + 1;
END while;
END//
CALL p1()//
DROP TABLE t1;
DROP PROCEDURE p1;

View File

@@ -0,0 +1,21 @@
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
*** Bug #23818_II ***
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS p1;
CREATE TABLE t1 (a int, b varchar(1100) character set latin1, c varchar(10000));
INSERT INTO t1 VALUES (null,null,null),(1,'',''),(2,'a','a');
CREATE INDEX i1 ON t1 (b);
CREATE PROCEDURE p1 ()
BEGIN
declare v int default 0;
while v < 1000 do
SET @x = concat('update t1 set a = ', v,', b = repeat(0x', hex(rand()*255),',rand()*999), c = repeat(0x', hex(rand()*255), ',rand()*9999)');
/* select v,@x; */
PREPARE stmt1 FROM @x;
EXECUTE stmt1;
SET v = v + 1;
END while;
END//
CALL p1()//
DROP TABLE t1;
DROP PROCEDURE p1;

View File

@@ -0,0 +1,7 @@
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
*** Bug #23818_A ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b varchar(1100));
INSERT INTO t1 VALUES (0,null),(0,null),(0,null);
CREATE INDEX i1 ON t1 (b);
DROP TABLE t1;

View File

@@ -0,0 +1,7 @@
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
*** Bug #23818_B ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b varchar(1100));
INSERT INTO t1 VALUES (0,null),(0,null),(0,null);
CREATE INDEX i1 ON t1 (b);
DROP TABLE t1;

View File

@@ -0,0 +1,7 @@
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
*** Bug #23818_C ***
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int, b varchar(1100));
INSERT INTO t1 VALUES (0,null),(0,null),(0,null);
CREATE INDEX i1 ON t1 (b);
DROP TABLE t1;

View File

@@ -0,0 +1,12 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a1 int,a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int) engine = tokudb;
insert into t1 (a9,a10) values (1,2);
alter table t1 add index blah(a9,a10);
select * from t1;
a1 a2 a3 a4 a5 a6 a7 a8 a9 a10
NULL NULL NULL NULL NULL NULL NULL NULL 1 2
select a9,a10 from t1;
a9 a10
1 2
DROP table t1;

View File

@@ -0,0 +1,16 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
create table t1 (a int, b int) engine=tokudb;
insert into t1 values (1,1),(1,2),(2,1),(2,2);
select count(*) from t1 where b > 0;
alter table t1 add clustering index b(b);
--replace_column 4 NA 8 NA 9 NA 10 NA
explain select count(*) from t1 where b > 0;
select count(*) from t1 where b > 0;
DROP TABLE t1;

View File

@@ -0,0 +1,44 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, str varchar(3), b int, c int, z int, y int, x int, r int, s int, t int, d char(4), primary key (a,b), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
SET @d = 'AB';
INSERT INTO t1 VALUES (@a,"s", @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a,@d);
SET @a=@a+1;
dec $1;
}
create index foo on t1 (c,r);
# Ignore the type, key_len, and rows columns.
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r,a,b from t1 WHERE c>=0;
select c,r,a,b from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,32 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
insert into t1 values (5,52,18,5,5,5,2,5,5);
--error ER_DUP_KEY
create unique index foo on t1 (c,r);
select * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,40 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, str varchar(3), b int, c int, z int, y int, x int, r int, s int, t int, d char(4), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
SET @d = 'AB';
INSERT INTO t1 VALUES (@a,"s", @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a,@d);
SET @a=@a+1;
dec $1;
}
create index foo on t1 (c,r);
# Ignore type, key_len, and rows columns
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,39 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int,key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
create index foo on t1 (c,r);
# Ignore type, key_len, and rows columns
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,39 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, str varchar(3), b int, c int, z int, y int, x int, r int, s int, t int, d char(4), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
SET @d = 'AB';
INSERT INTO t1 VALUES (@a,"s", @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a,@d);
SET @a=@a+1;
dec $1;
}
create unique index foo1 on t1 (c,r);
# Ignore type, key_len, and rows columns
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,39 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
create unique index foo1 on t1 (c,r);
# Ignore type, key_len, and rows columns
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,78 @@
--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
create unique index foo on t1 (c,r);
# Ignore type, key_len, and rows columns
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
drop index foo on t1;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
create index foo on t1 (c,r);
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
drop index z on t1;
--error ER_DUP_KEYNAME
create unique index foo on t1 (c,r);
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
create index z on t1 (z,a);
--replace_column 4 NULL 7 NULL 9 NULL;
explain select z,a from t1 where z>=0;
select z,a from t1 where z>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select * from t1;
select * from t1;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,32 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
insert into t1 values (5,52,18,5,5,5,2,5,5);
--error ER_DUP_KEY
create unique index foo on t1 (c,r);
DROP TABLE t1;

View File

@@ -0,0 +1,32 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
create unique index foo on t1 (c,r);
--error ER_DUP_ENTRY
insert into t1 values (5,52,18,5,5,5,2,5,5);
DROP TABLE t1;

View File

@@ -0,0 +1,43 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
#create index foo on t1 (c,r);
#alter table t1 add index foo (z);
#alter table t1 add index foo (a);
alter table t1 drop index z, add index foo (c,z), add index bar (t,r);
explain select c,z from t1;
select c,z from t1;
explain select * from t1;
select * from t1;
explain select t,r from t1;
select t,r from t1;
explain select * from t1;
select * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,41 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
create index foo on t1 (c,r);
# Ignore type, key_len, and rows columns
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r,a,b from t1 WHERE c>=0;
select c,r,a,b from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,42 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, str varchar(3), b int, c int, z int, y int, x int, r int, s int, t int, d char(4), primary key (a,b), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
SET @d = 'AB';
INSERT INTO t1 VALUES (@a,"s", @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a,@d);
SET @a=@a+1;
dec $1;
}
create unique index foo1 on t1 (c,r);
# Ignore type, key_len, and rows columns
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r,a,b from t1 WHERE c>=0;
select c,r,a,b from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,41 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
create unique index foo1 on t1 (c,r);
# Ignore type, key_len, and rows columns
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r from t1 WHERE c>=0;
select c,r from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r,a,b from t1 WHERE c>=0;
select c,r,a,b from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,78 @@
--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
create unique index foo on t1 (c,r);
# Ignore type, key_len, and rows columns
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r,a,b from t1 WHERE c>=0;
select c,r,a,b from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
drop index foo on t1;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r,a,b from t1 WHERE c>=0;
select c,r,a,b from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
create index foo on t1 (c,r);
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r,a,b from t1 WHERE c>=0;
select c,r,a,b from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
drop index z on t1;
--error ER_DUP_KEYNAME
create unique index foo on t1 (c,r);
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r,a,b from t1 WHERE c>=0;
select c,r,a,b from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
create index z on t1 (z,a);
--replace_column 4 NULL 7 NULL 9 NULL;
explain select z,a,b from t1 where z>=0;
select z,a,b from t1 where z>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select * from t1;
select * from t1;
--replace_column 4 NULL 7 NULL 9 NULL;
explain select c,r,a,b from t1 WHERE c>=0;
select c,r,a,b from t1 WHERE c>=0;
--replace_column 4 NULL 7 NULL 9 NULL;
explain SELECT * from t1;
SELECT * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,32 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
insert into t1 values (5,52,18,5,5,5,2,5,5);
--error ER_DUP_KEY
create unique index foo on t1 (c,r);
DROP TABLE t1;

View File

@@ -0,0 +1,32 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
create unique index foo on t1 (c,r);
--error ER_DUP_ENTRY
insert into t1 values (5,52,18,5,5,5,2,5,5);
DROP TABLE t1;

View File

@@ -0,0 +1,43 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
#create index foo on t1 (c,r);
#alter table t1 add index foo (z);
#alter table t1 add index foo (a);
alter table t1 drop index z, add index foo (c,z), add index bar (t,r);
explain select c,z,a,b from t1;
select c,z,a,b from t1;
explain select * from t1;
select * from t1;
explain select t,r,a,b from t1;
select t,r,a,b from t1;
explain select * from t1;
select * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,43 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b int, c int, z int, y int, x int, r int, s int, t int, primary key (a,b), key (z), key(x), key(t));
--disable_query_log
let $1 = 10;
SET @length = 10;
SET @a=1;
while ($1)
{
SET @b=@length-@a;
SET @c = @b + @b;
INSERT INTO t1 VALUES (@a, @b,@c,10*@a,100*@a,1000*@a,2*@a,3*@a,4*@a);
SET @a=@a+1;
dec $1;
}
#create index foo on t1 (c,r);
#alter table t1 add index foo (z);
#alter table t1 add index foo (a);
alter table t1 drop index z, add index foo (c,z), add index bar (t,r), drop primary key;
explain select c,z from t1;
select c,z from t1;
explain select * from t1;
select * from t1;
explain select t,r from t1;
select t,r from t1;
explain select * from t1;
select * from t1;
DROP TABLE t1;

View File

@@ -0,0 +1,78 @@
# Testcase derived from mix2_falcon
--source include/have_tokudb.inc
let $engine_type= tokudb;
--disable_abort_on_error
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
set session tokudb_disable_slow_alter=ON;
# Slightly simplified testcase
#
# Test of index only reads
#
eval CREATE TABLE t1 (
sca_code char(6) NOT NULL,
cat_code char(6) NOT NULL,
lan_code char(2) NOT NULL,
sca_pic varchar(100),
sca_sdesc varchar(50),
sca_sch_desc varchar(16)
, PRIMARY KEY (sca_code, cat_code, lan_code)
) Engine = $engine_type ;
INSERT INTO t1 ( sca_code, cat_code, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES
( 'PD', 'J', 'EN', NULL, NULL, 'PENDANT'),
( 'RI', 'J', 'EN', NULL, NULL, 'RING'),
( 'QQ', 'N', 'EN', 'not null', NULL, 'RING');
alter table t1 add index sca_pic (cat_code, sca_pic);
select count(*) from t1 where sca_pic >= 'n';
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
# alter table t1 drop index sca_pic;
# alter table t1 add index (sca_pic, cat_code);
select count(*) from t1 where sca_pic >= 'n';
DROP TABLE t1;
# The original testcase
DROP TABLE t1;
#
# Test of index only reads
#
eval CREATE TABLE t1 (
sca_code char(6) NOT NULL,
cat_code char(6) NOT NULL,
sca_desc varchar(50),
lan_code char(2) NOT NULL,
sca_pic varchar(100),
sca_sdesc varchar(50),
sca_sch_desc varchar(16),
PRIMARY KEY (sca_code, cat_code, lan_code),
INDEX sca_pic (sca_pic)
) Engine = $engine_type ;
INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'
),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
select count(*) from t1 where sca_code = 'PD';
select count(*) from t1 where sca_code <= 'PD';
select count(*) from t1 where sca_pic is null;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
select count(*) from t1 where cat_code='E';
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
select count(*) from t1 where sca_pic >= 'n';
select sca_pic from t1 where sca_pic is null;
update t1 set sca_pic="test" where sca_pic is null;
delete from t1 where sca_code='pd';
# Final cleanup
DROP TABLE t1;

View File

@@ -0,0 +1,18 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE = tokudb;
#
# Bug #23691: Falcon: searches fail if partial index
#
--echo *** Bug #23691 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a char(5));
CREATE INDEX i1 on t1 (a(3));
INSERT INTO t1 VALUES ('abcde');
SELECT * FROM t1 WHERE a = 'abcde';
# Final cleanup.
DROP TABLE t1;

View File

@@ -0,0 +1,47 @@
#--source include/have_tokudb.inc
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
#
# Bug #23692: Falcon: searches fail if data is 0x00
#
--echo *** Bug #23692 ***
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
DROP TABLE IF EXISTS t4;
--enable_warnings
CREATE TABLE t1 (a char(1), key (a));
INSERT INTO t1 VALUES (0x00);
SELECT count(*) FROM t1 WHERE a < '';
SELECT count(*) FROM t1 WHERE a = '';
SELECT count(*) FROM t1 WHERE a > '';
CREATE TABLE t2 (a varbinary(5));
CREATE INDEX i ON t2 (a);
INSERT INTO t2 VALUES (0x02), (0x0202);
SELECT count(*) FROM t2 WHERE a >= 0x02 OR a = 0x0202;
SELECT hex(a) FROM t2 WHERE a < 0x02;
SELECT hex(a) FROM t2 WHERE a = 0x02;
SELECT hex(a) FROM t2 WHERE a > 0x02;
CREATE TABLE t3 (a char(5));
CREATE INDEX i ON t3 (a);
INSERT INTO t3 VALUES (0x4200), (0x4209), (0x42), (0x4220), (0x4242);
SELECT hex(a) FROM t3 WHERE a < 0x42;
SELECT hex(a) FROM t3 WHERE a = 0x42;
SELECT hex(a) FROM t3 WHERE a > 0x42;
SELECT hex(a) FROM t3 WHERE a LIKE 'a%';
CREATE TABLE t4 (a varchar(5) character set ucs2, key(a)) engine=tokudb;
INSERT INTO t4 VALUES (0x00420000), (0x00420009), (0x0041001f), (0x0042), (0x00420020), (0x00420042);
SELECT hex(a) FROM t4 WHERE a < 'a';
SELECT hex(a) FROM t4 WHERE a = 'a';
SELECT hex(a) FROM t4 WHERE a > 'a';
SELECT hex(a) FROM t4 WHERE a LIKE 'a%';
# Final cleanup.
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;

View File

@@ -0,0 +1,36 @@
--source include/have_tokudb.inc
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
#
# Bug #23818 Falcon: crash with random updates of long varchar columns
# First part. Original bug reports loops 100000 times.
# Use UCS2 which uses two bytes for every char.
#
--echo *** Bug #23818_I ***
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS p1;
--enable_warnings
/* Does not fail with "b varchar(256) character set ucs2" */
CREATE TABLE t1 (a int, b varchar(1000) character set ucs2, c varchar(10000));
INSERT INTO t1 VALUES (null,null,null),(1,'',''),(2,'a','a');
CREATE INDEX i1 ON t1 (b(550));
DELIMITER //;
CREATE PROCEDURE p1 ()
BEGIN
declare v int default 0;
while v < 100 do
SET @x = concat('update t1 set a = ', v,', b = repeat(0x', hex(rand()*10000),',rand()*549), c = repeat(0x', hex(rand()*255), ',rand()*9999)');
/* select v,@x; */
PREPARE stmt1 FROM @x;
EXECUTE stmt1;
SET v = v + 1;
END while;
END//
CALL p1()//
# Final cleanup.
DELIMITER ;//
DROP TABLE t1;
DROP PROCEDURE p1;

View File

@@ -0,0 +1,35 @@
--source include/have_tokudb.inc
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
#
# Bug #23818 Falcon: crash with random updates of long varchar columns
# Second part. Original bug reports loops 100000 times.
# Use character set LATIN1, loop more times
#
--echo *** Bug #23818_II ***
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS p1;
--enable_warnings
CREATE TABLE t1 (a int, b varchar(1100) character set latin1, c varchar(10000));
INSERT INTO t1 VALUES (null,null,null),(1,'',''),(2,'a','a');
CREATE INDEX i1 ON t1 (b);
DELIMITER //;
CREATE PROCEDURE p1 ()
BEGIN
declare v int default 0;
while v < 1000 do
SET @x = concat('update t1 set a = ', v,', b = repeat(0x', hex(rand()*255),',rand()*999), c = repeat(0x', hex(rand()*255), ',rand()*9999)');
/* select v,@x; */
PREPARE stmt1 FROM @x;
EXECUTE stmt1;
SET v = v + 1;
END while;
END//
CALL p1()//
# Final cleanup.
DELIMITER ;//
DROP TABLE t1;
DROP PROCEDURE p1;

View File

@@ -0,0 +1,35 @@
--source include/have_tokudb.inc
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
#
# Bug #23818 Falcon: crash with random updates of long varchar columns
# First part. Original bug reports loops 100000 times.
#
--echo *** Bug #23818_A ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b varchar(1100));
INSERT INTO t1 VALUES (0,null),(0,null),(0,null);
CREATE INDEX i1 ON t1 (b);
--disable_result_log
--disable_query_log
set @a = 32710;
let $k = 200;
while ($k)
{
SELECT @a + 1 into @a;
SELECT rand(@a) * DEGREES(@a) into @b;
SELECT FLOOR(MOD(@b,255)) into @c;
SELECT @a, @b, @c;
UPDATE t1 SET a = a + 1;
UPDATE t1 SET b = repeat(hex(@c), rand(@c) * 550);
SELECT a, length(b), left(b,10) from t1;
dec $k;
}
--enable_query_log
--enable_result_log
# Final cleanup.
DROP TABLE t1;

View File

@@ -0,0 +1,35 @@
--source include/have_tokudb.inc
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
#
# Bug #23818 Falcon: crash with random updates of long varchar columns
# First part. Original bug reports loops 100000 times.
#
--echo *** Bug #23818_B ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b varchar(1100));
INSERT INTO t1 VALUES (0,null),(0,null),(0,null);
CREATE INDEX i1 ON t1 (b);
--disable_result_log
--disable_query_log
set @a = 5510;
let $k = 200;
while ($k)
{
SELECT @a + 1 into @a;
SELECT rand(@a) * DEGREES(@a) into @b;
SELECT FLOOR(MOD(@b,255)) into @c;
SELECT @a, @b, @c;
UPDATE t1 SET a = a + 1;
UPDATE t1 SET b = repeat(hex(@c), rand(@c) * 550);
SELECT a, length(b), left(b,10) from t1;
dec $k;
}
--enable_query_log
--enable_result_log
# Final cleanup.
DROP TABLE t1;

View File

@@ -0,0 +1,35 @@
--source include/have_tokudb.inc
SET @@DEFAULT_STORAGE_ENGINE = tokudb;
#
# Bug #23818 Falcon: crash with random updates of long varchar columns
# First part. Original bug reports loops 100000 times.
#
--echo *** Bug #23818_C ***
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a int, b varchar(1100));
INSERT INTO t1 VALUES (0,null),(0,null),(0,null);
CREATE INDEX i1 ON t1 (b);
--disable_result_log
--disable_query_log
set @a = 28410;
let $k = 200;
while ($k)
{
SELECT @a + 1 into @a;
SELECT rand(@a) * DEGREES(@a) into @b;
SELECT FLOOR(MOD(@b,255)) into @c;
SELECT @a, @b, @c;
UPDATE t1 SET a = a + 1;
UPDATE t1 SET b = repeat(hex(@c), rand(@c) * 550);
SELECT a, length(b), left(b,10) from t1;
dec $k;
}
--enable_query_log
--enable_result_log
# Final cleanup.
DROP TABLE t1;

View File

@@ -0,0 +1,16 @@
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a1 int,a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int) engine = tokudb;
insert into t1 (a9,a10) values (1,2);
alter table t1 add index blah(a9,a10);
select * from t1;
select a9,a10 from t1;
DROP table t1;

View File

@@ -0,0 +1,25 @@
SET DEFAULT_STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
set session tokudb_disable_slow_alter=ON;
create table foo (a int);
insert into foo values (1),(2),(3);
alter table foo add column b blob;
select * from foo;
a b
1 NULL
2 NULL
3 NULL
alter table foo add column c blob NOT NULL;
select * from foo;
a b c
1 NULL
2 NULL
3 NULL
alter table foo add column d blob DEFAULT="asdf";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your XYZ server version for the right syntax to use near '="asdf"' at line 1
select * from foo;
a b c
1 NULL
2 NULL
3 NULL
DROP TABLE foo;

View File

@@ -0,0 +1,12 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS hcad;
set session tokudb_disable_slow_alter=1;
set session tokudb_row_format=tokudb_zlib;
CREATE TABLE hcad (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
k int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (id),
KEY k (k)
) engine=tokudb;
alter table hcad add column tmc int null;
drop table hcad;

View File

@@ -0,0 +1,6 @@
set default_storage_engine='tokudb';
drop table if exists t;
create table t (a int primary key, b int, c int);
set session tokudb_disable_slow_alter=1;
alter table t add key(b), add unique key(c);
drop table t;

View File

@@ -0,0 +1,50 @@
set default_storage_engine='tokudb';
drop table if exists foo;
set session tokudb_disable_slow_alter=ON;
create table foo (a int, b int, c int, key(a))engine=TokuDB;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(3,30,300);
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
3 30 300
explain select sum(a) from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index NULL a 5 NULL 4 Using index
select sum(a) from foo;
sum(a)
9
alter table foo add unique index b(b), drop index a;
ERROR 23000: Can't write; duplicate key in table 'foo'
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
3 30 300
explain select sum(a) from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index NULL a 5 NULL 4 Using index
select sum(a) from foo;
sum(a)
9
#test that we can still add an index named 'b'
alter table foo add index b(b);
explain select sum(b) from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index NULL b 5 NULL 4 Using index
select sum(b) from foo;
sum(b)
90
set autocommit=0;
drop index b on foo;
create index b on foo (b);
explain select sum(b) from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index NULL b 5 NULL 4 Using index
select sum(b) from foo;
sum(b)
90
set autocommit=1;
drop table foo;

View File

@@ -0,0 +1,26 @@
SET DEFAULT_STORAGE_ENGINE='TokuDB';
DROP TABLE IF EXISTS foo;
SET SESSION tokudb_disable_slow_alter=1;
CREATE TABLE foo (a INT, b INT, PRIMARY KEY (a)) PARTITION BY HASH(a) PARTITIONS 2;
INSERT INTO foo VALUES (1,0),(2,0);
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (a)
PARTITIONS 2 */
ALTER TABLE foo ADD KEY(b);
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (a)
PARTITIONS 2 */
DROP TABLE foo;

View File

@@ -0,0 +1,39 @@
SET DEFAULT_STORAGE_ENGINE='TokuDB';
DROP TABLE IF EXISTS foo;
SET SESSION tokudb_disable_slow_alter=1;
CREATE TABLE foo (a INT NOT NULL DEFAULT 0, b INT DEFAULT NULL);
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL
) ENGINE=TokuDB DEFAULT CHARSET=latin1
ALTER TABLE foo ALTER COLUMN a SET DEFAULT 100;
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '100',
`b` int(11) DEFAULT NULL
) ENGINE=TokuDB DEFAULT CHARSET=latin1
ALTER TABLE foo ALTER COLUMN a DROP DEFAULT;
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=TokuDB DEFAULT CHARSET=latin1
ALTER TABLE foo ALTER COLUMN b SET DEFAULT 42;
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT '42'
) ENGINE=TokuDB DEFAULT CHARSET=latin1
ALTER TABLE foo ALTER COLUMN b DROP DEFAULT;
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL,
`b` int(11)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
DROP TABLE foo;

View File

@@ -0,0 +1,69 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS foo;
set session tokudb_disable_slow_alter=ON;
create table foo(a int auto_increment, b int, primary key (a));
insert into foo (b) values (11),(21),(32);
select * from foo;
a b
1 11
2 21
3 32
alter table foo auto_increment=1000;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TokuDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
insert into foo (b) values (11),(21),(32);
select * from foo;
a b
1 11
2 21
3 32
1000 11
1001 21
1002 32
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TokuDB AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1
alter table foo auto_increment=10;
insert into foo (b) values (11),(21),(32);
select * from foo;
a b
1 11
2 21
3 32
1000 11
1001 21
1002 32
1003 11
1004 21
1005 32
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TokuDB AUTO_INCREMENT=1006 DEFAULT CHARSET=latin1
alter table foo auto_increment=100000, add column c int;
ERROR 42000: Table 'foo' uses an extension that doesn't exist in this XYZ version
alter table foo auto_increment=100000, drop column b;
ERROR 42000: Table 'foo' uses an extension that doesn't exist in this XYZ version
alter table foo auto_increment=100000, add key b(b);
ERROR 42000: Table 'foo' uses an extension that doesn't exist in this XYZ version
alter table foo auto_increment=100000, change b b bigint;
ERROR 42000: Table 'foo' uses an extension that doesn't exist in this XYZ version
alter table foo auto_increment=100000, change b c int;
ERROR 42000: Table 'foo' uses an extension that doesn't exist in this XYZ version
alter table foo auto_increment=100000, ROW_FORMAT=TOKUDB_LZMA;
ERROR 42000: Table 'foo' uses an extension that doesn't exist in this XYZ version
alter table foo auto_increment=100000, change b b int DEFAULT 111;
ERROR 42000: Table 'foo' uses an extension that doesn't exist in this XYZ version
DROP TABLE foo;

View File

@@ -0,0 +1,6 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
drop table if exists t;
create table t (a int, b int, c int, primary key(a), key(b), unique key(c));
set session tokudb_disable_slow_alter=1;
alter table t drop key b, drop key c;
drop table t;

View File

@@ -0,0 +1,33 @@
DROP TABLE IF EXISTS foo, bar;
SET SESSION DEFAULT_STORAGE_ENGINE='TokuDB';
CREATE TABLE foo (id INT PRIMARY KEY);
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
CREATE TABLE bar LIKE foo;
SHOW CREATE TABLE bar;
Table Create Table
bar CREATE TABLE `bar` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
ALTER TABLE foo ADD COLUMN a INT;
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`id` int(11) NOT NULL,
`a` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
FLUSH TABLES;
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`id` int(11) NOT NULL,
`a` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
DROP TABLE foo, bar;

View File

@@ -0,0 +1,41 @@
DROP TABLE IF EXISTS foo, bar;
SET SESSION DEFAULT_STORAGE_ENGINE='TokuDB';
CREATE TABLE foo (id INT PRIMARY KEY) PARTITION BY HASH(id) PARTITIONS 2;
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (id)
PARTITIONS 2 */
CREATE TABLE bar LIKE foo;
SHOW CREATE TABLE bar;
Table Create Table
bar CREATE TABLE `bar` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (id)
PARTITIONS 2 */
ALTER TABLE foo ADD COLUMN a INT;
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`id` int(11) NOT NULL,
`a` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (id)
PARTITIONS 2 */
FLUSH TABLES;
SHOW CREATE TABLE foo;
Table Create Table
foo CREATE TABLE `foo` (
`id` int(11) NOT NULL,
`a` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=TokuDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (id)
PARTITIONS 2 */
DROP TABLE foo, bar;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,283 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS foo,bar;
set session tokudb_disable_slow_alter=ON;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aa;
alter table bar drop column aa;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bb;
alter table bar drop column bb;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column cc;
alter table bar drop column cc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column dd;
alter table bar drop column dd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aa, drop column bb;
alter table bar drop column aa, drop column bb;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aa, drop column cc;
alter table bar drop column aa, drop column cc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aa, drop column dd;
alter table bar drop column aa, drop column dd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bb, drop column aa;
alter table bar drop column bb, drop column aa;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bb, drop column cc;
alter table bar drop column bb, drop column cc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bb, drop column dd;
alter table bar drop column bb, drop column dd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column cc, drop column aa;
alter table bar drop column cc, drop column aa;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column cc, drop column bb;
alter table bar drop column cc, drop column bb;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column cc, drop column dd;
alter table bar drop column cc, drop column dd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column dd, drop column aa;
alter table bar drop column dd, drop column aa;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column dd, drop column bb;
alter table bar drop column dd, drop column bb;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column dd, drop column cc;
alter table bar drop column dd, drop column cc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aa, drop column bb, drop column cc;
alter table bar drop column aa, drop column bb, drop column cc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aa, drop column bb, drop column dd;
alter table bar drop column aa, drop column bb, drop column dd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aa, drop column cc, drop column dd;
alter table bar drop column aa, drop column cc, drop column dd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aa blob, bb longblob, cc tinyblob, dd mediumblob) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values ("adsf",NULL,"hjfdshj",NULL);
insert into foo values (NULL,"oifds",NULL,"fdsjfds");
insert into foo values ("rewoiu","fds","fr","oiufdsrew");
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bb, drop column cc, drop column dd;
alter table bar drop column bb, drop column cc, drop column dd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,283 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS foo,bar;
set session tokudb_disable_slow_alter=ON;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column a;
alter table bar drop column a;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column b;
alter table bar drop column b;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column c;
alter table bar drop column c;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column d;
alter table bar drop column d;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column a, drop column b;
alter table bar drop column a, drop column b;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column a, drop column c;
alter table bar drop column a, drop column c;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column a, drop column d;
alter table bar drop column a, drop column d;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column b, drop column a;
alter table bar drop column b, drop column a;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column b, drop column c;
alter table bar drop column b, drop column c;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column b, drop column d;
alter table bar drop column b, drop column d;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column c, drop column a;
alter table bar drop column c, drop column a;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column c, drop column b;
alter table bar drop column c, drop column b;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column c, drop column d;
alter table bar drop column c, drop column d;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column d, drop column a;
alter table bar drop column d, drop column a;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column d, drop column b;
alter table bar drop column d, drop column b;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column d, drop column c;
alter table bar drop column d, drop column c;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column a, drop column b, drop column c;
alter table bar drop column a, drop column b, drop column c;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column a, drop column b, drop column d;
alter table bar drop column a, drop column b, drop column d;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column a, drop column c, drop column d;
alter table bar drop column a, drop column c, drop column d;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (a int, b bigint, c date, d tinyint) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column b, drop column c, drop column d;
alter table bar drop column b, drop column c, drop column d;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,283 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS foo,bar;
set session tokudb_disable_slow_alter=ON;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aaa;
alter table bar drop column aaa;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bbb;
alter table bar drop column bbb;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column ccc;
alter table bar drop column ccc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column ddd;
alter table bar drop column ddd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aaa, drop column bbb;
alter table bar drop column aaa, drop column bbb;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aaa, drop column ccc;
alter table bar drop column aaa, drop column ccc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aaa, drop column ddd;
alter table bar drop column aaa, drop column ddd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bbb, drop column aaa;
alter table bar drop column bbb, drop column aaa;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bbb, drop column ccc;
alter table bar drop column bbb, drop column ccc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bbb, drop column ddd;
alter table bar drop column bbb, drop column ddd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column ccc, drop column aaa;
alter table bar drop column ccc, drop column aaa;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column ccc, drop column bbb;
alter table bar drop column ccc, drop column bbb;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column ccc, drop column ddd;
alter table bar drop column ccc, drop column ddd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column ddd, drop column aaa;
alter table bar drop column ddd, drop column aaa;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column ddd, drop column bbb;
alter table bar drop column ddd, drop column bbb;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column ddd, drop column ccc;
alter table bar drop column ddd, drop column ccc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aaa, drop column bbb, drop column ccc;
alter table bar drop column aaa, drop column bbb, drop column ccc;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aaa, drop column bbb, drop column ddd;
alter table bar drop column aaa, drop column bbb, drop column ddd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column aaa, drop column ccc, drop column ddd;
alter table bar drop column aaa, drop column ccc, drop column ddd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;
create table foo (aaa varchar(12), bbb varbinary(20), ccc varchar(50), ddd varchar(3000)) engine=TokuDB;
create table bar like foo;
alter table bar engine=MyISAM;
insert into foo values (NULL,NULL,NULL,NULL);
insert into foo values (-1,NULL,'2008-1-1',NULL);
insert into foo values (NULL,12345678987,NULL,1);
insert into foo values (2,20,'1999-11-11',0);
insert into bar select * from foo;
include/diff_tables.inc [test.foo, test.bar]
alter table foo drop column bbb, drop column ccc, drop column ddd;
alter table bar drop column bbb, drop column ccc, drop column ddd;
include/diff_tables.inc [test.foo, test.bar]
drop table foo;
drop table bar;

View File

@@ -0,0 +1,16 @@
DROP TABLE IF EXISTS s, t;
CREATE TABLE s (a INT) ENGINE=TokuDB;
SHOW CREATE TABLE s;
Table Create Table
s CREATE TABLE `s` (
`a` int(11) DEFAULT NULL
) ENGINE=TokuDB DEFAULT CHARSET=latin1
SET tokudb_disable_slow_alter=1;
ALTER TABLE s RENAME TO t, ADD COLUMN b INT;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=TokuDB DEFAULT CHARSET=latin1
DROP TABLE t;

Some files were not shown because too many files have changed in this diff Show More