diff --git a/Docs/manual.texi b/Docs/manual.texi index b8651afec34..0f1a1799963 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -18704,7 +18704,13 @@ deleted and the new one is renamed. This is done in such a way that all updates are automatically redirected to the new table without any failed updates. While @code{ALTER TABLE} is executing, the original table is readable by other clients. Updates and writes to the table -are stalled until the new table is ready: +are stalled until the new table is ready. + +Note that if you use any other option to @code{ALTER TABLE} than +@code{RENAME}, @strong{MySQL} will always create a temporary table, even +if the data wouldn't strictly need to be copied (like when you change the +name of a column). We plan to fix this in the future, but as one doesn't +normally do @code{ALTER TABLE} that often this isn't that high on our TODO. @itemize @bullet @item diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 25a429f764a..3dbf7c50ad3 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -79,9 +79,12 @@ then basedir=@prefix@ bindir=@bindir@ execdir=@libexecdir@ -else +elif test -d "$basedir/libexec" bindir="$basedir/bin" execdir="$basedir/libexec" +else + bindir="$basedir/bin" + execdir="$basedir/bin" fi mdata=$ldata/mysql diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 143e207a71c..b36d1ca1ffc 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -2231,7 +2231,7 @@ ha_innobase::create( /* Create the table definition in Innobase */ - if (error = create_table_def(trx, form, norm_name)) { + if ((error = create_table_def(trx, form, norm_name))) { trx_commit_for_mysql(trx); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 1e7f939bf80..2a74979556b 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -402,6 +402,7 @@ TABLE *unlink_open_table(THD *thd,TABLE *list,TABLE *find); SQL_SELECT *make_select(TABLE *head, table_map const_tables, table_map read_tables, COND *conds, int *error); Item ** find_item_in_list(Item *item,List &items); +bool setup_tables(TABLE_LIST *tables); int setup_fields(THD *thd,TABLE_LIST *tables,List &item, bool set_query_id,List *sum_func_list); int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6b92580b449..c235ac6575a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -39,7 +39,7 @@ static bool insert_fields(THD *thd,TABLE_LIST *tables, const char *table_name, List_iterator *it); static void free_cache_entry(TABLE *entry); static void mysql_rm_tmp_tables(void); -static key_map get_key_map_from_key_list(THD *thd, TABLE *table, +static key_map get_key_map_from_key_list(TABLE *table, List *index_list); @@ -1711,11 +1711,8 @@ find_item_in_list(Item *find,List &items) return found; } - /**************************************************************************** ** Check that all given fields exists and fill struct with current data -** Check also that the 'used keys' and 'ignored keys' exists and set up the -** table structure accordingly ****************************************************************************/ int setup_fields(THD *thd, TABLE_LIST *tables, List &fields, @@ -1729,36 +1726,6 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List &fields, thd->allow_sum_func= test(sum_func_list); thd->where="field list"; - /* Remap table numbers if INSERT ... SELECT */ - uint tablenr=0; - for (TABLE_LIST *table=tables ; table ; table=table->next,tablenr++) - { - table->table->tablenr=tablenr; - table->table->map= (table_map) 1 << tablenr; - if ((table->table->outer_join=table->outer_join)) - table->table->maybe_null=1; // LEFT OUTER JOIN ... - if (table->use_index) - { - key_map map= get_key_map_from_key_list(thd,table->table, - table->use_index); - if (map == ~(key_map) 0) - DBUG_RETURN(-1); - table->table->keys_in_use_for_query=map; - } - if (table->ignore_index) - { - key_map map= get_key_map_from_key_list(thd,table->table, - table->ignore_index); - if (map == ~(key_map) 0) - DBUG_RETURN(-1); - table->table->keys_in_use_for_query &= ~map; - } - } - if (tablenr > MAX_TABLES) - { - my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES); - DBUG_RETURN(-1); - } while ((item=it++)) { if (item->type() == Item::FIELD_ITEM && @@ -1780,7 +1747,49 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List &fields, } -static key_map get_key_map_from_key_list(THD *thd, TABLE *table, +/* + Remap table numbers if INSERT ... SELECT + Check also that the 'used keys' and 'ignored keys' exists and set up the + table structure accordingly +*/ + +bool setup_tables(TABLE_LIST *tables) +{ + DBUG_ENTER("setup_tables"); + uint tablenr=0; + for (TABLE_LIST *table=tables ; table ; table=table->next,tablenr++) + { + table->table->tablenr=tablenr; + table->table->map= (table_map) 1 << tablenr; + if ((table->table->outer_join=table->outer_join)) + table->table->maybe_null=1; // LEFT OUTER JOIN ... + if (table->use_index) + { + key_map map= get_key_map_from_key_list(table->table, + table->use_index); + if (map == ~(key_map) 0) + DBUG_RETURN(1); + table->table->keys_in_use_for_query=map; + } + if (table->ignore_index) + { + key_map map= get_key_map_from_key_list(table->table, + table->ignore_index); + if (map == ~(key_map) 0) + DBUG_RETURN(1); + table->table->keys_in_use_for_query &= ~map; + } + } + if (tablenr > MAX_TABLES) + { + my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES); + DBUG_RETURN(1); + } + DBUG_RETURN(0); +} + + +static key_map get_key_map_from_key_list(TABLE *table, List *index_list) { key_map map=0; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e92c5255ef8..192dd3898b3 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -78,7 +78,7 @@ check_insert_fields(THD *thd,TABLE *table,List &fields, table_list.grant=table->grant; thd->dupp_field=0; - if (setup_fields(thd,&table_list,fields,1,0)) + if (setup_tables(&table_list) || setup_fields(thd,&table_list,fields,1,0)) return -1; if (thd->dupp_field) { @@ -151,7 +151,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List &fields, save_time_stamp=table->time_stamp; values= its++; if (check_insert_fields(thd,table,fields,*values,1) || - setup_fields(thd,table_list,*values,0,0)) + setup_tables(table_list) || setup_fields(thd,table_list,*values,0,0)) { table->time_stamp=save_time_stamp; goto abort; @@ -168,7 +168,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List &fields, table->time_stamp=save_time_stamp; goto abort; } - if (setup_fields(thd,table_list,*values,0,0)) + if (setup_tables(table_list) || setup_fields(thd,table_list,*values,0,0)) { table->time_stamp=save_time_stamp; goto abort; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 17f94e88b9b..ce8e34b9265 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -91,7 +91,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, else { // Part field list thd->dupp_field=0; - if (setup_fields(thd,table_list,fields,1,0) < 0) + if (setup_tables(table_list) || setup_fields(thd,table_list,fields,1,0)) DBUG_RETURN(-1); if (thd->dupp_field) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9cb1c9b119f..5a1af55849d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -455,7 +455,8 @@ check_connections(THD *thd) db=strend(passwd)+1; if (thd->client_capabilities & CLIENT_INTERACTIVE) thd->inactive_timeout=net_interactive_timeout; - if (thd->client_capabilities & CLIENT_TRANSACTIONS) + if ((thd->client_capabilities & CLIENT_TRANSACTIONS) && + opt_using_transactions) thd->net.return_status= &thd->server_status; net->timeout=net_read_timeout; if (check_user(thd,COM_CONNECT, user, passwd, db, 1)) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b78e3ad925f..1aa6d1b8ff3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -174,7 +174,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, thd->proc_info="init"; thd->used_tables=0; // Updated by setup_fields - if (setup_fields(thd,tables,fields,1,&all_fields) || + if (setup_tables(tables) || + setup_fields(thd,tables,fields,1,&all_fields) || setup_conds(thd,tables,&conds) || setup_order(thd,tables,fields,all_fields,order) || setup_group(thd,tables,fields,all_fields,group,&hidden_group_fields) || diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 688a5cebfee..87a2f5c7b2b 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -70,7 +70,7 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List &fields, table->quick_keys=0; want_privilege=table->grant.want_privilege; table->grant.want_privilege=(SELECT_ACL & ~table->grant.privilege); - if (setup_conds(thd,table_list,&conds)) + if (setup_tables(table_list) || setup_conds(thd,table_list,&conds)) DBUG_RETURN(-1); /* purecov: inspected */ old_used_keys=table->used_keys; // Keys used in WHERE diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2207d8834b2..0be190b3588 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2785,7 +2785,7 @@ set_isolation: default_tx_isolation= $2; } | SESSION_SYM tx_isolation - { current_thd->session_tx_isolation= $2; } + { current_thd->session_tx_isolation= Lex->tx_isolation= $2; } | tx_isolation { Lex->tx_isolation= $1; }