Commit 59de9c42 authored by unknown's avatar unknown

Merge dator5.(none):/home/pappa/clean-mysql-5.1

into  dator5.(none):/home/pappa/bug19281


sql/sql_insert.cc:
  Auto merged
parents a0e5d9da 2b599547
drop table if exists t1;
create table t1 (a int)
partition by list (a)
(partition p0 values in (1));
create procedure pz()
alter table t1 engine = myisam;
call pz();
call pz();
create table t1 (a bigint)
partition by range (a)
(partition p0 values less than (0xFFFFFFFFFFFFFFFF),
......
......@@ -89,6 +89,9 @@ partitions 3
partition x2 tablespace ts2,
partition x3 tablespace ts3);
ERROR HY000: Field in list of fields for partition function not found in table
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -163,6 +166,9 @@ partitions 2
(partition x1 values less than (4),
partition x2 values less than (5));
ERROR HY000: Only RANGE PARTITIONING can use VALUES LESS THAN in partition definition
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -173,6 +179,9 @@ partitions 2
(partition x1 values in (4),
partition x2 values in (5));
ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -183,6 +192,9 @@ partitions 2
(partition x1 values in (4,6),
partition x2 values in (5,7));
ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -191,6 +203,9 @@ primary key (a,b))
partition by key (a)
subpartition by key (b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -199,6 +214,9 @@ primary key (a,b))
partition by key (a)
subpartition by key (a, b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -207,6 +225,9 @@ primary key (a,b))
partition by key (a)
subpartition by hash (a+b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -215,6 +236,9 @@ primary key (a,b))
partition by key (a)
subpartition by key (b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -223,6 +247,9 @@ primary key (a,b))
partition by key (a)
subpartition by key (a, b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -231,6 +258,9 @@ primary key (a,b))
partition by key (a)
subpartition by hash (a+b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -249,6 +279,9 @@ subpartition by hash (sin(a+b))
(partition x1 (subpartition x11, subpartition x12),
partition x2 (subpartition x21, subpartition x22));
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -271,6 +304,9 @@ subpartition by key (a,d)
(partition x1 values less than (1) (subpartition x11, subpartition x12),
partition x2 values less than (2) (subpartition x21, subpartition x22));
ERROR HY000: Field in list of fields for partition function not found in table
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -296,6 +332,9 @@ c int not null,
primary key(a,b))
partition by range (a);
ERROR HY000: For RANGE partitions each partition must be defined
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par')
NULL
CREATE TABLE t1 (
a int not null,
b int not null,
......
......@@ -191,3 +191,13 @@ SELECT COUNT(*) FROM t1 WHERE s1 < 3;
COUNT(*)
2
DROP TABLE t1;
create table t1 (a int auto_increment primary key)
auto_increment=100
partition by list (a)
(partition p0 values in (1, 100));
create index inx on t1 (a);
insert into t1 values (null);
select * from t1;
a
100
drop table t1;
......@@ -7,6 +7,12 @@ t1 CREATE TABLE `t1` (
`f_date` date DEFAULT NULL,
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2
hello/master-data/test/t1#P#p0.MYD
hello/master-data/test/t1#P#p0.MYI
hello/master-data/test/t1#P#p1.MYD
hello/master-data/test/t1#P#p1.MYI
hello/master-data/test/t1.frm
hello/master-data/test/t1.par
ALTER TABLE t1 COALESCE PARTITION 1;
SHOW CREATE TABLE t1;
Table Create Table
......@@ -14,3 +20,7 @@ t1 CREATE TABLE `t1` (
`f_date` date DEFAULT NULL,
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 1
hello/master-data/test/t1#P#p0.MYD
hello/master-data/test/t1#P#p0.MYI
hello/master-data/test/t1.frm
hello/master-data/test/t1.par
......@@ -9,6 +9,30 @@
drop table if exists t1;
--enable_warnings
#
# Bug 19309 Partitions: Crash if double procedural alter
#
create table t1 (a int)
partition by list (a)
(partition p0 values in (1));
create procedure pz()
alter table t1 engine = myisam;
call pz();
call pz();
drop procedure pz;
drop table t1;
#
# Bug 19307: CSV engine crashes
#
--error ER_PARTITION_MERGE_ERROR
create table t1 (a int)
engine = csv
partition by list (a)
(partition p0 values in (null));
#
# BUG 16002: Handle unsigned integer functions properly
#
......
......@@ -107,6 +107,8 @@ partitions 3
(partition x1 tablespace ts1,
partition x2 tablespace ts2,
partition x3 tablespace ts3);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Partition by hash, invalid field in function
#
......@@ -202,6 +204,7 @@ partition by hash (a)
partitions 2
(partition x1 values less than (4),
partition x2 values less than (5));
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Partition by hash, values in error
......@@ -216,6 +219,7 @@ partition by hash (a)
partitions 2
(partition x1 values in (4),
partition x2 values in (5));
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Partition by hash, values in error
......@@ -230,6 +234,7 @@ partition by hash (a)
partitions 2
(partition x1 values in (4,6),
partition x2 values in (5,7));
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by key, no partitions defined, single field
......@@ -242,6 +247,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by key, no partitions defined, list of fields
......@@ -254,6 +260,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (a, b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined
......@@ -266,6 +273,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by hash (a+b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by key, no partitions defined, single field
......@@ -278,6 +286,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by key, no partitions defined, list of fields
......@@ -290,6 +299,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (a, b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined
......@@ -302,6 +312,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by hash (a+b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined, wrong subpartition function
......@@ -328,6 +339,7 @@ partition by key (a)
subpartition by hash (sin(a+b))
(partition x1 (subpartition x11, subpartition x12),
partition x2 (subpartition x21, subpartition x22));
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined, wrong subpartition function
......@@ -356,6 +368,7 @@ partition by range (a)
subpartition by key (a,d)
(partition x1 values less than (1) (subpartition x11, subpartition x12),
partition x2 values less than (2) (subpartition x21, subpartition x22));
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined, wrong subpartition function
......@@ -393,6 +406,7 @@ b int not null,
c int not null,
primary key(a,b))
partition by range (a);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Partition by range, invalid field in function
......
-- source include/have_innodb.inc
-- source include/have_partition.inc
SET @max_row = 20;
let $engine= 'InnoDB';
let $MAX_VALUE= (2147483646);
......
......@@ -124,3 +124,15 @@ INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
SELECT COUNT(*) FROM t1 WHERE s1 < 3;
DROP TABLE t1;
#
# Bug 19281 Partitions: Auto-increment value lost
#
create table t1 (a int auto_increment primary key)
auto_increment=100
partition by list (a)
(partition p0 values in (1, 100));
create index inx on t1 (a);
insert into t1 values (null);
select * from t1;
drop table t1;
-- source include/have_partition.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
......@@ -5,10 +6,12 @@ CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30))
PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2;
SHOW CREATE TABLE t1;
#--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
--replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
ALTER TABLE t1 COALESCE PARTITION 1;
SHOW CREATE TABLE t1;
#--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
--replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
......
......@@ -1565,6 +1565,7 @@ int ha_partition::copy_partitions(ulonglong *copied, ulonglong *deleted)
void ha_partition::update_create_info(HA_CREATE_INFO *create_info)
{
m_file[0]->update_create_info(create_info);
return;
}
......
......@@ -862,7 +862,8 @@ int prepare_create_field(create_field *sql_field,
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
List<create_field> &fields, List<Key> &keys,
bool tmp_table, uint select_field_count);
bool tmp_table, uint select_field_count,
bool use_copy_create_info);
bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
HA_CREATE_INFO *create_info,
......
......@@ -2654,7 +2654,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
tmp_disable_binlog(thd);
if (!mysql_create_table(thd, create_table->db, create_table->table_name,
create_info, *extra_fields, *keys, 0,
select_field_count))
select_field_count, 0))
{
/*
If we are here in prelocked mode we either create temporary table
......
......@@ -2943,7 +2943,7 @@ mysql_execute_command(THD *thd)
res= mysql_create_table(thd, create_table->db,
create_table->table_name, &lex->create_info,
lex->create_list,
lex->key_list, 0, 0);
lex->key_list, 0, 0, 1);
}
if (!res)
send_ok(thd);
......
......@@ -3001,6 +3001,31 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field)
}
/*
Copy HA_CREATE_INFO struct
SYNOPSIS
copy_create_info()
lex_create_info The create_info struct setup by parser
RETURN VALUES
> 0 A pointer to a copy of the lex_create_info
0 Memory allocation error
DESCRIPTION
Allocate memory for copy of HA_CREATE_INFO structure from parser
to ensure we can reuse the parser struct in stored procedures
and prepared statements.
*/
static HA_CREATE_INFO *copy_create_info(HA_CREATE_INFO *lex_create_info)
{
HA_CREATE_INFO *create_info;
if (!(create_info= (HA_CREATE_INFO*)sql_alloc(sizeof(HA_CREATE_INFO))))
mem_alloc_error(sizeof(HA_CREATE_INFO));
else
memcpy((void*)create_info, (void*)lex_create_info, sizeof(HA_CREATE_INFO));
return create_info;
}
/*
Create a table
......@@ -3009,11 +3034,15 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field)
thd Thread object
db Database
table_name Table name
create_info Create information (like MAX_ROWS)
lex_create_info Create information (like MAX_ROWS)
fields List of fields to create
keys List of keys to create
internal_tmp_table Set to 1 if this is an internal temporary table
(From ALTER TABLE)
select_field_count
use_copy_create_info Should we make a copy of create info (we do this
when this is called from sql_parse.cc where we
want to ensure lex object isn't manipulated.
DESCRIPTION
If one creates a temporary table, this is automatically opened
......@@ -3030,20 +3059,32 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field)
bool mysql_create_table_internal(THD *thd,
const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
HA_CREATE_INFO *lex_create_info,
List<create_field> &fields,
List<Key> &keys,bool internal_tmp_table,
uint select_field_count)
uint select_field_count,
bool use_copy_create_info)
{
char path[FN_REFLEN];
uint path_length;
const char *alias;
uint db_options, key_count;
KEY *key_info_buffer;
HA_CREATE_INFO *create_info;
handler *file;
bool error= TRUE;
DBUG_ENTER("mysql_create_table_internal");
if (use_copy_create_info)
{
if (!(create_info= copy_create_info(lex_create_info)))
{
DBUG_RETURN(TRUE);
}
}
else
create_info= lex_create_info;
/* Check for duplicate fields and check type of table to create */
if (!fields.elements)
{
......@@ -3358,7 +3399,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
List<create_field> &fields,
List<Key> &keys,bool internal_tmp_table,
uint select_field_count)
uint select_field_count,
bool use_copy_create_info)
{
bool result;
DBUG_ENTER("mysql_create_table");
......@@ -3382,7 +3424,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
result= mysql_create_table_internal(thd, db, table_name, create_info,
fields, keys, internal_tmp_table,
select_field_count);
select_field_count,
use_copy_create_info);
pthread_mutex_lock(&LOCK_lock_db);
if (!--creating_table && creating_database)
......@@ -4328,7 +4371,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
*/
bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
HA_CREATE_INFO *create_info,
HA_CREATE_INFO *lex_create_info,
Table_ident *table_ident)
{
TABLE *tmp_table;
......@@ -4341,9 +4384,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
int err;
bool res= TRUE;
enum legacy_db_type not_used;
HA_CREATE_INFO *create_info;
TABLE_LIST src_tables_list;
DBUG_ENTER("mysql_create_like_table");
if (!(create_info= copy_create_info(lex_create_info)))
{
DBUG_RETURN(TRUE);
}
src_db= table_ident->db.str ? table_ident->db.str : thd->db;
/*
......@@ -4889,7 +4938,7 @@ static uint compare_tables(TABLE *table, List<create_field> *create_list,
*/
bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
HA_CREATE_INFO *create_info,
HA_CREATE_INFO *lex_create_info,
TABLE_LIST *table_list,
List<create_field> &fields, List<Key> &keys,
uint order_num, ORDER *order,
......@@ -4907,6 +4956,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
ulonglong next_insert_id;
uint db_create_options, used_fields;
handlerton *old_db_type, *new_db_type;
HA_CREATE_INFO *create_info;
uint need_copy_table= 0;
bool no_table_reopen= FALSE, varchar= FALSE;
#ifdef WITH_PARTITION_STORAGE_ENGINE
......@@ -4932,6 +4982,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
LINT_INIT(index_drop_buffer);
thd->proc_info="init";
if (!(create_info= copy_create_info(lex_create_info)))
{
DBUG_RETURN(TRUE);
}
table_name=table_list->table_name;
alias= (lower_case_table_names == 2) ? table_list->alias : table_name;
db=table_list->db;
......@@ -5686,7 +5740,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
*/
tmp_disable_binlog(thd);
error= mysql_create_table(thd, new_db, tmp_name,
create_info,create_list,key_list,1,0);
create_info,create_list,key_list,1,0,0);
reenable_binlog(thd);
if (error)
DBUG_RETURN(error);
......
......@@ -1484,7 +1484,18 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
tmp= fix_partition_func(thd, outparam, is_create_table);
*root_ptr= old_root;
if (tmp)
{
if (is_create_table)
{
/*
During CREATE/ALTER TABLE it is ok to receive errors here.
It is not ok if it happens during the opening of an frm
file as part of a normal query.
*/
error_reported= TRUE;
}
goto err;
}
}
#endif
......
......@@ -339,6 +339,7 @@ int rea_create_table(THD *thd, const char *path,
DBUG_RETURN(0);
err_handler:
VOID(file->create_handler_files(path, NULL, CHF_DELETE_FLAG, create_info));
my_delete(frm_name, MYF(0));
DBUG_RETURN(1);
} /* rea_create_table */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment