Commit 9543cae6 authored by mikael@dator5.(none)'s avatar mikael@dator5.(none)

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

into  dator5.(none):/home/pappa/bug19281
parents 43409d98 cb504319
drop table if exists t1; 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();
drop procedure pz;
drop table t1;
create table t1 (a int)
engine = csv
partition by list (a)
(partition p0 values in (null));
ERROR HY000: CSV handler cannot be used in partitioned tables
create table t1 (a bigint) create table t1 (a bigint)
partition by range (a) partition by range (a)
(partition p0 values less than (0xFFFFFFFFFFFFFFFF), (partition p0 values less than (0xFFFFFFFFFFFFFFFF),
......
...@@ -89,6 +89,9 @@ partitions 3 ...@@ -89,6 +89,9 @@ partitions 3
partition x2 tablespace ts2, partition x2 tablespace ts2,
partition x3 tablespace ts3); partition x3 tablespace ts3);
ERROR HY000: Field in list of fields for partition function not found in table 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -163,6 +166,9 @@ partitions 2 ...@@ -163,6 +166,9 @@ partitions 2
(partition x1 values less than (4), (partition x1 values less than (4),
partition x2 values less than (5)); partition x2 values less than (5));
ERROR HY000: Only RANGE PARTITIONING can use VALUES LESS THAN in partition definition 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -173,6 +179,9 @@ partitions 2 ...@@ -173,6 +179,9 @@ partitions 2
(partition x1 values in (4), (partition x1 values in (4),
partition x2 values in (5)); partition x2 values in (5));
ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -183,6 +192,9 @@ partitions 2 ...@@ -183,6 +192,9 @@ partitions 2
(partition x1 values in (4,6), (partition x1 values in (4,6),
partition x2 values in (5,7)); partition x2 values in (5,7));
ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -191,6 +203,9 @@ primary key (a,b)) ...@@ -191,6 +203,9 @@ primary key (a,b))
partition by key (a) partition by key (a)
subpartition by key (b); subpartition by key (b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -199,6 +214,9 @@ primary key (a,b)) ...@@ -199,6 +214,9 @@ primary key (a,b))
partition by key (a) partition by key (a)
subpartition by key (a, b); subpartition by key (a, b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -207,6 +225,9 @@ primary key (a,b)) ...@@ -207,6 +225,9 @@ primary key (a,b))
partition by key (a) partition by key (a)
subpartition by hash (a+b); subpartition by hash (a+b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -215,6 +236,9 @@ primary key (a,b)) ...@@ -215,6 +236,9 @@ primary key (a,b))
partition by key (a) partition by key (a)
subpartition by key (b); subpartition by key (b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -223,6 +247,9 @@ primary key (a,b)) ...@@ -223,6 +247,9 @@ primary key (a,b))
partition by key (a) partition by key (a)
subpartition by key (a, b); subpartition by key (a, b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -231,6 +258,9 @@ primary key (a,b)) ...@@ -231,6 +258,9 @@ primary key (a,b))
partition by key (a) partition by key (a)
subpartition by hash (a+b); subpartition by hash (a+b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -249,6 +279,9 @@ subpartition by hash (sin(a+b)) ...@@ -249,6 +279,9 @@ subpartition by hash (sin(a+b))
(partition x1 (subpartition x11, subpartition x12), (partition x1 (subpartition x11, subpartition x12),
partition x2 (subpartition x21, subpartition x22)); partition x2 (subpartition x21, subpartition x22));
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -271,6 +304,9 @@ subpartition by key (a,d) ...@@ -271,6 +304,9 @@ subpartition by key (a,d)
(partition x1 values less than (1) (subpartition x11, subpartition x12), (partition x1 values less than (1) (subpartition x11, subpartition x12),
partition x2 values less than (2) (subpartition x21, subpartition x22)); partition x2 values less than (2) (subpartition x21, subpartition x22));
ERROR HY000: Field in list of fields for partition function not found in table 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
...@@ -296,6 +332,9 @@ c int not null, ...@@ -296,6 +332,9 @@ c int not null,
primary key(a,b)) primary key(a,b))
partition by range (a); partition by range (a);
ERROR HY000: For RANGE partitions each partition must be defined 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 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
......
...@@ -191,3 +191,13 @@ SELECT COUNT(*) FROM t1 WHERE s1 < 3; ...@@ -191,3 +191,13 @@ SELECT COUNT(*) FROM t1 WHERE s1 < 3;
COUNT(*) COUNT(*)
2 2
DROP TABLE t1; 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` ( ...@@ -7,6 +7,12 @@ t1 CREATE TABLE `t1` (
`f_date` date DEFAULT NULL, `f_date` date DEFAULT NULL,
`f_varchar` varchar(30) 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 ) 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; ALTER TABLE t1 COALESCE PARTITION 1;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
...@@ -14,3 +20,7 @@ t1 CREATE TABLE `t1` ( ...@@ -14,3 +20,7 @@ t1 CREATE TABLE `t1` (
`f_date` date DEFAULT NULL, `f_date` date DEFAULT NULL,
`f_varchar` varchar(30) 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 ) 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 @@ ...@@ -9,6 +9,30 @@
drop table if exists t1; drop table if exists t1;
--enable_warnings --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 # BUG 16002: Handle unsigned integer functions properly
# #
......
...@@ -107,6 +107,8 @@ partitions 3 ...@@ -107,6 +107,8 @@ partitions 3
(partition x1 tablespace ts1, (partition x1 tablespace ts1,
partition x2 tablespace ts2, partition x2 tablespace ts2,
partition x3 tablespace ts3); partition x3 tablespace ts3);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Partition by hash, invalid field in function # Partition by hash, invalid field in function
# #
...@@ -202,6 +204,7 @@ partition by hash (a) ...@@ -202,6 +204,7 @@ partition by hash (a)
partitions 2 partitions 2
(partition x1 values less than (4), (partition x1 values less than (4),
partition x2 values less than (5)); partition x2 values less than (5));
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Partition by hash, values in error # Partition by hash, values in error
...@@ -216,6 +219,7 @@ partition by hash (a) ...@@ -216,6 +219,7 @@ partition by hash (a)
partitions 2 partitions 2
(partition x1 values in (4), (partition x1 values in (4),
partition x2 values in (5)); partition x2 values in (5));
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Partition by hash, values in error # Partition by hash, values in error
...@@ -230,6 +234,7 @@ partition by hash (a) ...@@ -230,6 +234,7 @@ partition by hash (a)
partitions 2 partitions 2
(partition x1 values in (4,6), (partition x1 values in (4,6),
partition x2 values in (5,7)); partition x2 values in (5,7));
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Subpartition by key, no partitions defined, single field # Subpartition by key, no partitions defined, single field
...@@ -242,6 +247,7 @@ c int not null, ...@@ -242,6 +247,7 @@ c int not null,
primary key (a,b)) primary key (a,b))
partition by key (a) partition by key (a)
subpartition by key (b); subpartition by key (b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Subpartition by key, no partitions defined, list of fields # Subpartition by key, no partitions defined, list of fields
...@@ -254,6 +260,7 @@ c int not null, ...@@ -254,6 +260,7 @@ c int not null,
primary key (a,b)) primary key (a,b))
partition by key (a) partition by key (a)
subpartition by key (a, b); subpartition by key (a, b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Subpartition by hash, no partitions defined # Subpartition by hash, no partitions defined
...@@ -266,6 +273,7 @@ c int not null, ...@@ -266,6 +273,7 @@ c int not null,
primary key (a,b)) primary key (a,b))
partition by key (a) partition by key (a)
subpartition by hash (a+b); subpartition by hash (a+b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Subpartition by key, no partitions defined, single field # Subpartition by key, no partitions defined, single field
...@@ -278,6 +286,7 @@ c int not null, ...@@ -278,6 +286,7 @@ c int not null,
primary key (a,b)) primary key (a,b))
partition by key (a) partition by key (a)
subpartition by key (b); subpartition by key (b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Subpartition by key, no partitions defined, list of fields # Subpartition by key, no partitions defined, list of fields
...@@ -290,6 +299,7 @@ c int not null, ...@@ -290,6 +299,7 @@ c int not null,
primary key (a,b)) primary key (a,b))
partition by key (a) partition by key (a)
subpartition by key (a, b); subpartition by key (a, b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Subpartition by hash, no partitions defined # Subpartition by hash, no partitions defined
...@@ -302,6 +312,7 @@ c int not null, ...@@ -302,6 +312,7 @@ c int not null,
primary key (a,b)) primary key (a,b))
partition by key (a) partition by key (a)
subpartition by hash (a+b); subpartition by hash (a+b);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Subpartition by hash, no partitions defined, wrong subpartition function # Subpartition by hash, no partitions defined, wrong subpartition function
...@@ -328,6 +339,7 @@ partition by key (a) ...@@ -328,6 +339,7 @@ partition by key (a)
subpartition by hash (sin(a+b)) subpartition by hash (sin(a+b))
(partition x1 (subpartition x11, subpartition x12), (partition x1 (subpartition x11, subpartition x12),
partition x2 (subpartition x21, subpartition x22)); 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 # Subpartition by hash, no partitions defined, wrong subpartition function
...@@ -356,6 +368,7 @@ partition by range (a) ...@@ -356,6 +368,7 @@ partition by range (a)
subpartition by key (a,d) subpartition by key (a,d)
(partition x1 values less than (1) (subpartition x11, subpartition x12), (partition x1 values less than (1) (subpartition x11, subpartition x12),
partition x2 values less than (2) (subpartition x21, subpartition x22)); 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 # Subpartition by hash, no partitions defined, wrong subpartition function
...@@ -393,6 +406,7 @@ b int not null, ...@@ -393,6 +406,7 @@ b int not null,
c int not null, c int not null,
primary key(a,b)) primary key(a,b))
partition by range (a); partition by range (a);
select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
# #
# Partition by range, invalid field in function # Partition by range, invalid field in function
......
-- source include/have_innodb.inc -- source include/have_innodb.inc
-- source include/have_partition.inc
SET @max_row = 20; SET @max_row = 20;
let $engine= 'InnoDB'; let $engine= 'InnoDB';
let $MAX_VALUE= (2147483646); let $MAX_VALUE= (2147483646);
......
...@@ -124,3 +124,15 @@ INSERT INTO t1 VALUES (1), (2), (3), (4), (5); ...@@ -124,3 +124,15 @@ INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
SELECT COUNT(*) FROM t1 WHERE s1 < 3; SELECT COUNT(*) FROM t1 WHERE s1 < 3;
DROP TABLE t1; 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 --disable_warnings
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--enable_warnings --enable_warnings
...@@ -5,10 +6,12 @@ CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30)) ...@@ -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; PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2;
SHOW CREATE TABLE t1; 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; ALTER TABLE t1 COALESCE PARTITION 1;
SHOW CREATE TABLE t1; 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 @@ error: ...@@ -1565,6 +1565,7 @@ error:
void ha_partition::update_create_info(HA_CREATE_INFO *create_info) void ha_partition::update_create_info(HA_CREATE_INFO *create_info)
{ {
m_file[0]->update_create_info(create_info);
return; return;
} }
......
...@@ -862,7 +862,8 @@ int prepare_create_field(create_field *sql_field, ...@@ -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, bool mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &fields, List<Key> &keys, 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, bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
......
...@@ -2684,7 +2684,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, ...@@ -2684,7 +2684,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
tmp_disable_binlog(thd); tmp_disable_binlog(thd);
if (!mysql_create_table(thd, create_table->db, create_table->table_name, if (!mysql_create_table(thd, create_table->db, create_table->table_name,
create_info, *extra_fields, *keys, 0, 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 If we are here in prelocked mode we either create temporary table
......
...@@ -2943,7 +2943,7 @@ mysql_execute_command(THD *thd) ...@@ -2943,7 +2943,7 @@ mysql_execute_command(THD *thd)
res= mysql_create_table(thd, create_table->db, res= mysql_create_table(thd, create_table->db,
create_table->table_name, &lex->create_info, create_table->table_name, &lex->create_info,
lex->create_list, lex->create_list,
lex->key_list, 0, 0); lex->key_list, 0, 0, 1);
} }
if (!res) if (!res)
send_ok(thd); send_ok(thd);
......
...@@ -3001,6 +3001,31 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field) ...@@ -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 Create a table
...@@ -3009,11 +3034,15 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field) ...@@ -3009,11 +3034,15 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field)
thd Thread object thd Thread object
db Database db Database
table_name Table name 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 fields List of fields to create
keys List of keys to create keys List of keys to create
internal_tmp_table Set to 1 if this is an internal temporary table internal_tmp_table Set to 1 if this is an internal temporary table
(From ALTER 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 DESCRIPTION
If one creates a temporary table, this is automatically opened 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) ...@@ -3030,20 +3059,32 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field)
bool mysql_create_table_internal(THD *thd, bool mysql_create_table_internal(THD *thd,
const char *db, const char *table_name, const char *db, const char *table_name,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *lex_create_info,
List<create_field> &fields, List<create_field> &fields,
List<Key> &keys,bool internal_tmp_table, List<Key> &keys,bool internal_tmp_table,
uint select_field_count) uint select_field_count,
bool use_copy_create_info)
{ {
char path[FN_REFLEN]; char path[FN_REFLEN];
uint path_length; uint path_length;
const char *alias; const char *alias;
uint db_options, key_count; uint db_options, key_count;
KEY *key_info_buffer; KEY *key_info_buffer;
HA_CREATE_INFO *create_info;
handler *file; handler *file;
bool error= TRUE; bool error= TRUE;
DBUG_ENTER("mysql_create_table_internal"); 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 */ /* Check for duplicate fields and check type of table to create */
if (!fields.elements) if (!fields.elements)
{ {
...@@ -3358,7 +3399,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, ...@@ -3358,7 +3399,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &fields, List<create_field> &fields,
List<Key> &keys,bool internal_tmp_table, List<Key> &keys,bool internal_tmp_table,
uint select_field_count) uint select_field_count,
bool use_copy_create_info)
{ {
bool result; bool result;
DBUG_ENTER("mysql_create_table"); DBUG_ENTER("mysql_create_table");
...@@ -3382,7 +3424,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, ...@@ -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, result= mysql_create_table_internal(thd, db, table_name, create_info,
fields, keys, internal_tmp_table, fields, keys, internal_tmp_table,
select_field_count); select_field_count,
use_copy_create_info);
pthread_mutex_lock(&LOCK_lock_db); pthread_mutex_lock(&LOCK_lock_db);
if (!--creating_table && creating_database) if (!--creating_table && creating_database)
...@@ -4328,7 +4371,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables) ...@@ -4328,7 +4371,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
*/ */
bool mysql_create_like_table(THD* thd, TABLE_LIST* table, 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_ident *table_ident)
{ {
TABLE *tmp_table; TABLE *tmp_table;
...@@ -4341,9 +4384,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -4341,9 +4384,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
int err; int err;
bool res= TRUE; bool res= TRUE;
enum legacy_db_type not_used; enum legacy_db_type not_used;
HA_CREATE_INFO *create_info;
TABLE_LIST src_tables_list; TABLE_LIST src_tables_list;
DBUG_ENTER("mysql_create_like_table"); 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; 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, ...@@ -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, 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, TABLE_LIST *table_list,
List<create_field> &fields, List<Key> &keys, List<create_field> &fields, List<Key> &keys,
uint order_num, ORDER *order, uint order_num, ORDER *order,
...@@ -4907,6 +4956,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -4907,6 +4956,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
ulonglong next_insert_id; ulonglong next_insert_id;
uint db_create_options, used_fields; uint db_create_options, used_fields;
handlerton *old_db_type, *new_db_type; handlerton *old_db_type, *new_db_type;
HA_CREATE_INFO *create_info;
uint need_copy_table= 0; uint need_copy_table= 0;
bool no_table_reopen= FALSE, varchar= FALSE; bool no_table_reopen= FALSE, varchar= FALSE;
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
...@@ -4932,6 +4982,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -4932,6 +4982,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
LINT_INIT(index_drop_buffer); LINT_INIT(index_drop_buffer);
thd->proc_info="init"; thd->proc_info="init";
if (!(create_info= copy_create_info(lex_create_info)))
{
DBUG_RETURN(TRUE);
}
table_name=table_list->table_name; table_name=table_list->table_name;
alias= (lower_case_table_names == 2) ? table_list->alias : table_name; alias= (lower_case_table_names == 2) ? table_list->alias : table_name;
db=table_list->db; db=table_list->db;
...@@ -5686,7 +5740,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -5686,7 +5740,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
*/ */
tmp_disable_binlog(thd); tmp_disable_binlog(thd);
error= mysql_create_table(thd, new_db, tmp_name, 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); reenable_binlog(thd);
if (error) if (error)
DBUG_RETURN(error); DBUG_RETURN(error);
......
...@@ -1484,8 +1484,19 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, ...@@ -1484,8 +1484,19 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
tmp= fix_partition_func(thd, outparam, is_create_table); tmp= fix_partition_func(thd, outparam, is_create_table);
*root_ptr= old_root; *root_ptr= old_root;
if (tmp) 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; goto err;
} }
}
#endif #endif
/* Allocate bitmaps */ /* Allocate bitmaps */
......
...@@ -339,6 +339,7 @@ int rea_create_table(THD *thd, const char *path, ...@@ -339,6 +339,7 @@ int rea_create_table(THD *thd, const char *path,
DBUG_RETURN(0); DBUG_RETURN(0);
err_handler: err_handler:
VOID(file->create_handler_files(path, NULL, CHF_DELETE_FLAG, create_info));
my_delete(frm_name, MYF(0)); my_delete(frm_name, MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
} /* rea_create_table */ } /* 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