Commit e86fc82c authored by unknown's avatar unknown

bug #1434 (and related issues)

parent 08a08a67
...@@ -129,8 +129,28 @@ insert into t1 values ("a", 1), ("b", 2); ...@@ -129,8 +129,28 @@ insert into t1 values ("a", 1), ("b", 2);
drop table t1; drop table t1;
# #
# Bug # 801 # Bug #801
# #
create table t1 select x'4132'; create table t1 select x'4132';
drop table t1; drop table t1;
#
# bug #1434
#
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
--error 1136
create table if not exists t1 select 1,2,3,4;
create table if not exists t1 select 1;
select * from t1;
drop table t1;
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
--error 1136
create table if not exists t1 select 1,2,3,4;
create table if not exists t1 select 1;
select * from t1;
drop table t1;
...@@ -703,6 +703,7 @@ class select_create: public select_insert { ...@@ -703,6 +703,7 @@ class select_create: public select_insert {
HA_CREATE_INFO *create_info; HA_CREATE_INFO *create_info;
MYSQL_LOCK *lock; MYSQL_LOCK *lock;
Field **field; Field **field;
my_bool do_not_drop;
public: public:
select_create (const char *db_name, const char *table_name, select_create (const char *db_name, const char *table_name,
HA_CREATE_INFO *create_info_par, HA_CREATE_INFO *create_info_par,
...@@ -711,8 +712,7 @@ public: ...@@ -711,8 +712,7 @@ public:
List<Item> &select_fields,enum_duplicates duplic) List<Item> &select_fields,enum_duplicates duplic)
:select_insert (NULL, &select_fields, duplic), db(db_name), :select_insert (NULL, &select_fields, duplic), db(db_name),
name(table_name), extra_fields(&fields_par),keys(&keys_par), name(table_name), extra_fields(&fields_par),keys(&keys_par),
create_info(create_info_par), create_info(create_info_par), lock(0), do_not_drop(0)
lock(0)
{} {}
int prepare(List<Item> &list); int prepare(List<Item> &list);
bool send_data(List<Item> &values); bool send_data(List<Item> &values);
......
...@@ -1438,6 +1438,15 @@ select_create::prepare(List<Item> &values) ...@@ -1438,6 +1438,15 @@ select_create::prepare(List<Item> &values)
if (!table) if (!table)
DBUG_RETURN(-1); // abort() deletes table DBUG_RETURN(-1); // abort() deletes table
if (table->fields < values.elements)
{
do_not_drop=1;
my_printf_error(ER_WRONG_VALUE_COUNT_ON_ROW,
ER(ER_WRONG_VALUE_COUNT_ON_ROW),
MYF(0),1);
DBUG_RETURN(-1);
}
/* First field to copy */ /* First field to copy */
field=table->field+table->fields - values.elements; field=table->field+table->fields - values.elements;
...@@ -1519,6 +1528,7 @@ void select_create::abort() ...@@ -1519,6 +1528,7 @@ void select_create::abort()
enum db_type table_type=table->db_type; enum db_type table_type=table->db_type;
if (!table->tmp_table) if (!table->tmp_table)
hash_delete(&open_cache,(byte*) table); hash_delete(&open_cache,(byte*) table);
if (!do_not_drop)
quick_rm_table(table_type,db,name); quick_rm_table(table_type,db,name);
table=0; table=0;
} }
......
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