summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.local>2006-12-12 01:50:12 +0300
committerunknown <kostja@bodhi.local>2006-12-12 01:50:12 +0300
commita8103a89b4ad39031abd1db242beca1b4332c895 (patch)
tree13f5570546702b83046f58c43a391f93191f3d5a /sql
parent3e3990433a0c8ec7cea01274909fdb17024519e8 (diff)
downloadmariadb-git-a8103a89b4ad39031abd1db242beca1b4332c895.tar.gz
Post-merge fixes for Bug#4968 "Stored procedure crash if cursor opened
on altered table" and Bug#19733 "Repeated alter, or repeated create/drop, fails" mysql-test/r/ps.result: Post-merge fixes: update results with new tests. mysql-test/r/sp.result: Post-merge fixes: update results. mysql-test/t/ps.test: Add more test cases for Bug#4968 and related. mysql-test/t/sp.test: A post-merge fix: add more testcases for Bug#4968 and related. sql/sql_insert.cc: Post-merge fixes: update comments, fix errors of the manual merge. sql/sql_lex.cc: Fix a manual merge error. sql/sql_parse.cc: Fix a few errors of the manual merge, style. sql/sql_table.cc: Post-merge fixes, fix a few errors of the manual merge, fix style. sql/sql_yacc.yy: A post-merge fix.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_insert.cc15
-rw-r--r--sql/sql_lex.cc3
-rw-r--r--sql/sql_parse.cc24
-rw-r--r--sql/sql_table.cc20
-rw-r--r--sql/sql_yacc.yy4
5 files changed, 32 insertions, 34 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 79e91dc4cb1..24c8e9863dd 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2620,11 +2620,11 @@ bool select_insert::send_eof()
temporary table flag)
create_table in Pointer to TABLE_LIST object providing database
and name for table to be created or to be open
- extra_fields in/out Initial list of fields for table to be created
- keys in List of keys for table to be created
+ alter_info in/out Initial list of columns and indexes for the table
+ to be created
items in List of items which should be used to produce rest
of fields for the table (corresponding fields will
- be added to the end of 'extra_fields' list)
+ be added to the end of alter_info->create_list)
lock out Pointer to the MYSQL_LOCK object for table created
(open) will be returned in this parameter. Since
this table is not included in THD::lock caller is
@@ -2646,8 +2646,8 @@ bool select_insert::send_eof()
static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
TABLE_LIST *create_table,
- List<create_field> *extra_fields,
- List<Key> *keys, List<Item> *items,
+ Alter_info *alter_info,
+ List<Item> *items,
MYSQL_LOCK **lock)
{
TABLE tmp_table; // Used during 'create_field()'
@@ -2686,7 +2686,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(0);
if (item->maybe_null)
cr_field->flags &= ~NOT_NULL_FLAG;
- extra_fields->push_back(cr_field);
+ alter_info->create_list.push_back(cr_field);
}
/*
create and lock table
@@ -2707,8 +2707,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))
+ create_info, alter_info, 0, select_field_count))
{
/*
If we are here in prelocked mode we either create temporary table
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index e063db58488..46fa205a25c 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1062,8 +1062,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
create_list(rhs.create_list, mem_root),
flags(rhs.flags),
keys_onoff(rhs.keys_onoff),
- tablespace_op(rhs.tablespace_op),
- is_simple(rhs.is_simple)
+ tablespace_op(rhs.tablespace_op)
{}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index aa69e3133fc..8cf6e84fc2c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2908,12 +2908,13 @@ mysql_execute_command(THD *thd)
{
/* out of memory when creating a copy of alter_info */
res= 1;
- goto unsent_create_error;
+ goto end_with_restore_list;
}
if ((res= create_table_precheck(thd, select_tables, create_table)))
goto end_with_restore_list;
+
#ifndef HAVE_READLINK
create_info.data_file_name= create_info.index_file_name= NULL;
#else
@@ -2969,7 +2970,7 @@ mysql_execute_command(THD *thd)
Is table which we are changing used somewhere in other parts
of query
*/
- if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE))
+ if (!(create_info.options & HA_LEX_CREATE_TMP_TABLE))
{
TABLE_LIST *duplicate;
if ((duplicate= unique_table(thd, create_table, select_tables)))
@@ -2980,10 +2981,10 @@ mysql_execute_command(THD *thd)
}
}
/* If we create merge table, we have to test tables in merge, too */
- if (lex->create_info.used_fields & HA_CREATE_USED_UNION)
+ if (create_info.used_fields & HA_CREATE_USED_UNION)
{
TABLE_LIST *tab;
- for (tab= (TABLE_LIST*) lex->create_info.merge_list.first;
+ for (tab= (TABLE_LIST*) create_info.merge_list.first;
tab;
tab= tab->next_local)
{
@@ -3021,7 +3022,7 @@ mysql_execute_command(THD *thd)
/* regular create */
if (lex->name)
res= mysql_create_like_table(thd, create_table, &create_info,
- (Table_ident *)lex->name);
+ (Table_ident *)lex->name);
else
{
res= mysql_create_table(thd, create_table->db,
@@ -3075,9 +3076,9 @@ end_with_restore_list:
create_info.db_type= DB_TYPE_DEFAULT;
create_info.default_table_charset= thd->variables.collation_database;
- res= mysql_alter_table(thd, first_table->db, first_table->real_name,
+ res= mysql_alter_table(thd, first_table->db, first_table->table_name,
&create_info, first_table, &alter_info,
- 0, (ORDER*)0, DUP_ERROR, 0);
+ 0, (ORDER*) 0, 0);
break;
}
#ifdef HAVE_REPLICATION
@@ -3820,6 +3821,7 @@ end_with_restore_list:
break;
}
#endif
+
if (check_access(thd,CREATE_ACL,lex->name,0,1,0,is_schema_db(lex->name)))
break;
res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias : lex->name),
@@ -4507,7 +4509,7 @@ end_with_restore_list:
goto error;
}
- my_bool nsok= thd->net.no_send_ok;
+ my_bool save_no_send_ok= thd->net.no_send_ok;
thd->net.no_send_ok= TRUE;
if (sp->m_flags & sp_head::MULTI_RESULTS)
{
@@ -4518,7 +4520,7 @@ end_with_restore_list:
back
*/
my_error(ER_SP_BADSELECT, MYF(0), sp->m_qname.str);
- thd->net.no_send_ok= nsok;
+ thd->net.no_send_ok= save_no_send_ok;
goto error;
}
/*
@@ -4534,7 +4536,7 @@ end_with_restore_list:
if (check_routine_access(thd, EXECUTE_ACL,
sp->m_db.str, sp->m_name.str, TRUE, FALSE))
{
- thd->net.no_send_ok= nsok;
+ thd->net.no_send_ok= save_no_send_ok;
goto error;
}
#endif
@@ -4561,7 +4563,7 @@ end_with_restore_list:
thd->variables.select_limit= select_limit;
- thd->net.no_send_ok= nsok;
+ thd->net.no_send_ok= save_no_send_ok;
thd->server_status&= ~bits_to_be_cleared;
if (!res)
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 56691821ce1..8207a3b7909 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1569,7 +1569,7 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field)
create_info [in/out] Create information (like MAX_ROWS)
alter_info [in/out] List of columns and indexes to create
internal_tmp_table Set to 1 if this is an internal temporary table
- (From ALTER TABLE)
+ (From ALTER TABLE)
DESCRIPTION
If one creates a temporary table, this is automatically opened
@@ -1592,7 +1592,7 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field)
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
Alter_info *alter_info,
- List<Key> &keys,bool internal_tmp_table,
+ bool internal_tmp_table,
uint select_field_count)
{
char path[FN_REFLEN];
@@ -2327,9 +2327,12 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
(table->table->file->ha_check_for_upgrade(check_opt) ==
HA_ADMIN_NEEDS_ALTER))
{
+ my_bool save_no_send_ok= thd->net.no_send_ok;
close_thread_tables(thd);
tmp_disable_binlog(thd); // binlogging is done by caller if wanted
- result_code= mysql_recreate_table(thd, table, 0);
+ thd->net.no_send_ok= TRUE;
+ result_code= mysql_recreate_table(thd, table);
+ thd->net.no_send_ok= save_no_send_ok;
reenable_binlog(thd);
goto send_result;
}
@@ -2956,8 +2959,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
HA_CREATE_INFO *create_info,
TABLE_LIST *table_list,
Alter_info *alter_info,
- uint order_num, ORDER *order,
- bool ignore)
+ uint order_num, ORDER *order, bool ignore)
{
TABLE *table,*new_table=0;
int error;
@@ -3565,7 +3567,7 @@ view_err:
{
tmp_disable_binlog(thd);
error= mysql_create_table(thd, new_db, tmp_name,
- create_info,alter_info, 1, 0);
+ create_info, &new_info, 1, 0);
reenable_binlog(thd);
if (error)
DBUG_RETURN(error);
@@ -4021,20 +4023,18 @@ copy_data_between_tables(TABLE *from,TABLE *to,
Like mysql_alter_table().
*/
bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list)
-int mysql_recreate_table(THD *thd, TABLE_LIST *table_list)
{
- LEX *lex= thd->lex;
HA_CREATE_INFO create_info;
Alter_info alter_info;
DBUG_ENTER("mysql_recreate_table");
- bzero((char*) &create_info,sizeof(create_info));
+ bzero((char*) &create_info, sizeof(create_info));
create_info.db_type=DB_TYPE_DEFAULT;
create_info.row_type=ROW_TYPE_NOT_USED;
create_info.default_table_charset=default_charset_info;
/* Force alter table to recreate table */
- lex->alter_info.flags= ALTER_CHANGE_COLUMN;
+ alter_info.flags= ALTER_CHANGE_COLUMN;
DBUG_RETURN(mysql_alter_table(thd, NullS, NullS, &create_info,
table_list, &alter_info,
0, (ORDER *) 0, 0));
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 719d48af33f..abaed88af57 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1190,7 +1190,6 @@ create:
TL_OPTION_UPDATING))
YYABORT;
lex->alter_info.reset();
- lex->alter_info.is_simple= 0;
lex->alter_info.flags= ALTER_ADD_INDEX;
lex->col_list.empty();
lex->change=NullS;
@@ -3313,7 +3312,7 @@ alter:
lex->create_info.db_type= DB_TYPE_DEFAULT;
lex->create_info.default_table_charset= NULL;
lex->create_info.row_type= ROW_TYPE_NOT_USED;
- lex->alter_info.reset();
+ lex->alter_info.reset();
}
alter_list
{}
@@ -6076,7 +6075,6 @@ drop:
LEX *lex=Lex;
lex->sql_command= SQLCOM_DROP_INDEX;
lex->alter_info.reset();
- lex->alter_info.is_simple= 0;
lex->alter_info.flags= ALTER_DROP_INDEX;
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
$3.str));