summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@tik.mysql.fi>2001-03-21 20:13:46 +0200
committerunknown <monty@tik.mysql.fi>2001-03-21 20:13:46 +0200
commit4b56b0ee43843dae2f5503718bd851f8debbd561 (patch)
tree9acce646cec7017f770114fcd46d65bd4d8e0bf9 /sql
parent6257ee7613836c397bda6c3533ca4a114d60e045 (diff)
downloadmariadb-git-4b56b0ee43843dae2f5503718bd851f8debbd561.tar.gz
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
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_innobase.cc2
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/sql_base.cc67
-rw-r--r--sql/sql_insert.cc6
-rw-r--r--sql/sql_load.cc2
-rw-r--r--sql/sql_parse.cc3
-rw-r--r--sql/sql_select.cc3
-rw-r--r--sql/sql_update.cc2
-rw-r--r--sql/sql_yacc.yy2
9 files changed, 50 insertions, 38 deletions
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<Item> &items);
+bool setup_tables(TABLE_LIST *tables);
int setup_fields(THD *thd,TABLE_LIST *tables,List<Item> &item,
bool set_query_id,List<Item> *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<Item> *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<String> *index_list);
@@ -1711,11 +1711,8 @@ find_item_in_list(Item *find,List<Item> &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<Item> &fields,
@@ -1729,7 +1726,36 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
thd->allow_sum_func= test(sum_func_list);
thd->where="field list";
- /* Remap table numbers if INSERT ... SELECT */
+ while ((item=it++))
+ {
+ if (item->type() == Item::FIELD_ITEM &&
+ ((Item_field*) item)->field_name[0] == '*')
+ {
+ if (insert_fields(thd,tables,((Item_field*) item)->table_name,&it))
+ DBUG_RETURN(-1); /* purecov: inspected */
+ }
+ else
+ {
+ if (item->fix_fields(thd,tables))
+ DBUG_RETURN(-1); /* purecov: inspected */
+ if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
+ item->split_sum_func(*sum_func_list);
+ thd->used_tables|=item->used_tables();
+ }
+ }
+ DBUG_RETURN(test(thd->fatal_error));
+}
+
+
+/*
+ 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++)
{
@@ -1739,48 +1765,31 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
table->table->maybe_null=1; // LEFT OUTER JOIN ...
if (table->use_index)
{
- key_map map= get_key_map_from_key_list(thd,table->table,
+ key_map map= get_key_map_from_key_list(table->table,
table->use_index);
if (map == ~(key_map) 0)
- DBUG_RETURN(-1);
+ 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,
+ key_map map= get_key_map_from_key_list(table->table,
table->ignore_index);
if (map == ~(key_map) 0)
- DBUG_RETURN(-1);
+ 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(1);
}
- while ((item=it++))
- {
- if (item->type() == Item::FIELD_ITEM &&
- ((Item_field*) item)->field_name[0] == '*')
- {
- if (insert_fields(thd,tables,((Item_field*) item)->table_name,&it))
- DBUG_RETURN(-1); /* purecov: inspected */
- }
- else
- {
- if (item->fix_fields(thd,tables))
- DBUG_RETURN(-1); /* purecov: inspected */
- if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
- item->split_sum_func(*sum_func_list);
- thd->used_tables|=item->used_tables();
- }
- }
- DBUG_RETURN(test(thd->fatal_error));
+ DBUG_RETURN(0);
}
-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)
{
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<Item> &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<Item> &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<Item> &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<Item> &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<Item> &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; }