1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Split setup_fields to setup_tables and setup_fields

Fixed problem with UPDATE TABLE when keys wheren't always used.


Docs/manual.texi:
  Added comment to ALTER TABLE
scripts/mysql_install_db.sh:
  Added test for mysqld in libexec
sql/ha_innobase.cc:
  Removed compiler warning
sql/mysql_priv.h:
  Split setup_fields to setup_tables and setup_fields
sql/sql_base.cc:
  Split setup_fields to setup_tables and setup_fields
sql/sql_insert.cc:
  Split setup_fields to setup_tables and setup_fields
sql/sql_load.cc:
  Split setup_fields to setup_tables and setup_fields
sql/sql_parse.cc:
  Fixed missing 'mysql_info" with now clients.
sql/sql_select.cc:
  Split setup_fields to setup_tables and setup_fields
sql/sql_update.cc:
  Fixed problem with UPDATE TABLE when keys wheren't always used.
sql/sql_yacc.yy:
  Small isolation change
This commit is contained in:
unknown
2001-03-21 20:13:46 +02:00
parent 6257ee7613
commit 4b56b0ee43
11 changed files with 67 additions and 46 deletions

View File

@ -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 all updates are automatically redirected to the new table without
any failed updates. While @code{ALTER TABLE} is executing, the original any failed updates. While @code{ALTER TABLE} is executing, the original
table is readable by other clients. Updates and writes to the table 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 @itemize @bullet
@item @item

View File

@ -79,9 +79,12 @@ then
basedir=@prefix@ basedir=@prefix@
bindir=@bindir@ bindir=@bindir@
execdir=@libexecdir@ execdir=@libexecdir@
else elif test -d "$basedir/libexec"
bindir="$basedir/bin" bindir="$basedir/bin"
execdir="$basedir/libexec" execdir="$basedir/libexec"
else
bindir="$basedir/bin"
execdir="$basedir/bin"
fi fi
mdata=$ldata/mysql mdata=$ldata/mysql

View File

@ -2231,7 +2231,7 @@ ha_innobase::create(
/* Create the table definition in Innobase */ /* 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); trx_commit_for_mysql(trx);

View File

@ -402,6 +402,7 @@ TABLE *unlink_open_table(THD *thd,TABLE *list,TABLE *find);
SQL_SELECT *make_select(TABLE *head, table_map const_tables, SQL_SELECT *make_select(TABLE *head, table_map const_tables,
table_map read_tables, COND *conds, int *error); table_map read_tables, COND *conds, int *error);
Item ** find_item_in_list(Item *item,List<Item> &items); Item ** find_item_in_list(Item *item,List<Item> &items);
bool setup_tables(TABLE_LIST *tables);
int setup_fields(THD *thd,TABLE_LIST *tables,List<Item> &item, int setup_fields(THD *thd,TABLE_LIST *tables,List<Item> &item,
bool set_query_id,List<Item> *sum_func_list); bool set_query_id,List<Item> *sum_func_list);
int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds); int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds);

View File

@ -39,7 +39,7 @@ static bool insert_fields(THD *thd,TABLE_LIST *tables, const char *table_name,
List_iterator<Item> *it); List_iterator<Item> *it);
static void free_cache_entry(TABLE *entry); static void free_cache_entry(TABLE *entry);
static void mysql_rm_tmp_tables(void); 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<String> *index_list); List<String> *index_list);
@ -1711,11 +1711,8 @@ find_item_in_list(Item *find,List<Item> &items)
return found; return found;
} }
/**************************************************************************** /****************************************************************************
** Check that all given fields exists and fill struct with current data ** 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<Item> &fields, int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
@ -1729,36 +1726,6 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
thd->allow_sum_func= test(sum_func_list); thd->allow_sum_func= test(sum_func_list);
thd->where="field 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++)) while ((item=it++))
{ {
if (item->type() == Item::FIELD_ITEM && if (item->type() == Item::FIELD_ITEM &&
@ -1780,7 +1747,49 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &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<String> *index_list) List<String> *index_list)
{ {
key_map map=0; key_map map=0;

View File

@ -78,7 +78,7 @@ check_insert_fields(THD *thd,TABLE *table,List<Item> &fields,
table_list.grant=table->grant; table_list.grant=table->grant;
thd->dupp_field=0; 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; return -1;
if (thd->dupp_field) if (thd->dupp_field)
{ {
@ -151,7 +151,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
save_time_stamp=table->time_stamp; save_time_stamp=table->time_stamp;
values= its++; values= its++;
if (check_insert_fields(thd,table,fields,*values,1) || 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; table->time_stamp=save_time_stamp;
goto abort; goto abort;
@ -168,7 +168,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
table->time_stamp=save_time_stamp; table->time_stamp=save_time_stamp;
goto abort; 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; table->time_stamp=save_time_stamp;
goto abort; goto abort;

View File

@ -91,7 +91,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else else
{ // Part field list { // Part field list
thd->dupp_field=0; 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); DBUG_RETURN(-1);
if (thd->dupp_field) if (thd->dupp_field)
{ {

View File

@ -455,7 +455,8 @@ check_connections(THD *thd)
db=strend(passwd)+1; db=strend(passwd)+1;
if (thd->client_capabilities & CLIENT_INTERACTIVE) if (thd->client_capabilities & CLIENT_INTERACTIVE)
thd->inactive_timeout=net_interactive_timeout; 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; thd->net.return_status= &thd->server_status;
net->timeout=net_read_timeout; net->timeout=net_read_timeout;
if (check_user(thd,COM_CONNECT, user, passwd, db, 1)) if (check_user(thd,COM_CONNECT, user, passwd, db, 1))

View File

@ -174,7 +174,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
thd->proc_info="init"; thd->proc_info="init";
thd->used_tables=0; // Updated by setup_fields 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_conds(thd,tables,&conds) ||
setup_order(thd,tables,fields,all_fields,order) || setup_order(thd,tables,fields,all_fields,order) ||
setup_group(thd,tables,fields,all_fields,group,&hidden_group_fields) || setup_group(thd,tables,fields,all_fields,group,&hidden_group_fields) ||

View File

@ -70,7 +70,7 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List<Item> &fields,
table->quick_keys=0; table->quick_keys=0;
want_privilege=table->grant.want_privilege; want_privilege=table->grant.want_privilege;
table->grant.want_privilege=(SELECT_ACL & ~table->grant.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 */ DBUG_RETURN(-1); /* purecov: inspected */
old_used_keys=table->used_keys; // Keys used in WHERE old_used_keys=table->used_keys; // Keys used in WHERE

View File

@ -2785,7 +2785,7 @@ set_isolation:
default_tx_isolation= $2; default_tx_isolation= $2;
} }
| SESSION_SYM tx_isolation | SESSION_SYM tx_isolation
{ current_thd->session_tx_isolation= $2; } { current_thd->session_tx_isolation= Lex->tx_isolation= $2; }
| tx_isolation | tx_isolation
{ Lex->tx_isolation= $1; } { Lex->tx_isolation= $1; }