summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2004-09-16 13:53:22 -0700
committerunknown <igor@rurik.mysql.com>2004-09-16 13:53:22 -0700
commitca65afeb72e7f514d51b7dcf2cc49e85a3b92677 (patch)
tree85c27eb2f9ed1f928ac2035084e728192c2b4be8 /sql
parent7a5fb949209709015a27f7dafcfe06d0b0ae1e9f (diff)
parent38628bca1b08b3f5d97d3e4ec2425e022ed0f501 (diff)
downloadmariadb-git-ca65afeb72e7f514d51b7dcf2cc49e85a3b92677.tar.gz
Merge rurik.mysql.com:/home/igor/mysql-4.1
into rurik.mysql.com:/home/igor/dev/mysql-4.1-0
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_innodb.cc3
-rw-r--r--sql/ha_innodb.h1
-rw-r--r--sql/item.cc10
-rw-r--r--sql/item.h4
-rw-r--r--sql/item_subselect.cc3
-rw-r--r--sql/mysqld.cc6
-rw-r--r--sql/sql_base.cc6
-rw-r--r--sql/sql_cache.cc10
-rw-r--r--sql/sql_class.cc18
-rw-r--r--sql/sql_lex.cc24
-rw-r--r--sql/sql_lex.h1
-rw-r--r--sql/sql_parse.cc25
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sql_update.cc26
-rw-r--r--sql/tztime.cc4
15 files changed, 93 insertions, 50 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index a9a8764c941..bf1be6f5d7e 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -97,7 +97,7 @@ long innobase_mirrored_log_groups, innobase_log_files_in_group,
innobase_buffer_pool_size, innobase_additional_mem_pool_size,
innobase_file_io_threads, innobase_lock_wait_timeout,
innobase_thread_concurrency, innobase_force_recovery,
- innobase_open_files;
+ innobase_open_files, innobase_auto_extend_increment;
/* The default values for the following char* start-up parameters
are determined in innobase_init below: */
@@ -963,6 +963,7 @@ innobase_init(void)
srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;
srv_max_n_open_files = (ulint) innobase_open_files;
+ srv_auto_extend_increment = (ulint) innobase_auto_extend_increment;
srv_innodb_status = (ibool) innobase_create_status_file;
srv_print_verbose_log = mysql_embedded ? 0 : 1;
diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h
index fa6c8a90d21..0ef5f3ddffe 100644
--- a/sql/ha_innodb.h
+++ b/sql/ha_innodb.h
@@ -183,6 +183,7 @@ extern long innobase_buffer_pool_awe_mem_mb;
extern long innobase_file_io_threads, innobase_lock_wait_timeout;
extern long innobase_force_recovery, innobase_thread_concurrency;
extern long innobase_open_files;
+extern long innobase_auto_extend_increment;
extern char *innobase_data_home_dir, *innobase_data_file_path;
extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
extern char *innobase_unix_file_flush_method;
diff --git a/sql/item.cc b/sql/item.cc
index 1e090333bf4..8233d050783 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1271,11 +1271,10 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
prev_subselect_item->parsing_place;
/*
check table fields only if subquery used somewhere out of HAVING
- or SELECT list or outer SELECT do not use groupping (i.e. tables
- are accessable)
+ or outer SELECT do not use groupping (i.e. tables are
+ accessable)
*/
- if (((place != IN_HAVING &&
- place != SELECT_LIST) ||
+ if ((place != IN_HAVING ||
(sl->with_sum_func == 0 && sl->group_list.elements == 0)) &&
(tmp= find_field_in_tables(thd, this,
table_list, &where,
@@ -1954,8 +1953,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
or SELECT list or outer SELECT do not use groupping (i.e. tables
are accessable)
*/
- if (((place != IN_HAVING &&
- place != SELECT_LIST) ||
+ if ((place != IN_HAVING ||
(sl->with_sum_func == 0 && sl->group_list.elements == 0)) &&
(tmp= find_field_in_tables(thd, this,
table_list, &where,
diff --git a/sql/item.h b/sql/item.h
index 23c5c844f21..7a1e7c5d0d2 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -706,8 +706,8 @@ public:
class Item_empty_string :public Item_string
{
public:
- Item_empty_string(const char *header,uint length) :Item_string("",0,
- &my_charset_bin)
+ Item_empty_string(const char *header,uint length, CHARSET_INFO *cs= NULL) :
+ Item_string("",0, cs ? cs : &my_charset_bin)
{ name=(char*) header; max_length=length;}
void make_field(Send_field *field);
};
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 8d140efac5f..3ddf9a1c6bf 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -934,9 +934,6 @@ Item_in_subselect::row_value_transformer(JOIN *join)
}
select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
- select_lex->setup_ref_array(thd,
- select_lex->order_list.elements +
- select_lex->group_list.elements);
{
uint n= left_expr->cols();
List_iterator_fast<Item> li(select_lex->item_list);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index ce64d2a39da..30722d56b2a 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4005,6 +4005,7 @@ enum options_mysqld
OPT_INNODB_STATUS_FILE,
OPT_INNODB_MAX_DIRTY_PAGES_PCT,
OPT_INNODB_OPEN_FILES,
+ OPT_INNODB_AUTOEXTEND_INCREMENT,
OPT_BDB_CACHE_SIZE,
OPT_BDB_LOG_BUFFER_SIZE,
OPT_BDB_MAX_LOCK,
@@ -4752,6 +4753,11 @@ replicating a LOAD DATA INFILE command.",
"How many files at the maximum InnoDB keeps open at the same time.",
(gptr*) &innobase_open_files, (gptr*) &innobase_open_files, 0,
GET_LONG, REQUIRED_ARG, 300L, 10L, ~0L, 0, 1L, 0},
+ {"innodb_autoextend_increment", OPT_INNODB_AUTOEXTEND_INCREMENT,
+ "Data file autoextend increment in megabytes",
+ (gptr*) &innobase_auto_extend_increment,
+ (gptr*) &innobase_auto_extend_increment,
+ 0, GET_LONG, REQUIRED_ARG, 8L, 1L, ~0L, 0, 1L, 0},
#ifdef HAVE_REPLICATION
/*
Disabled for the 4.1.3 release. Disabling just this paragraph of code is
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 30f97cf20a9..75eb5753e1e 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2142,8 +2142,12 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
case sensitive.
In cases where they are not case sensitive, they are always in lower
case.
+
+ item_field->field_name and item_field->table_name can be 0x0 if
+ item is not fix fielded yet.
*/
- if (!my_strcasecmp(system_charset_info, item_field->field_name,
+ if (item_field->field_name && item_field->table_name &&
+ !my_strcasecmp(system_charset_info, item_field->field_name,
field_name) &&
!strcmp(item_field->table_name, table_name) &&
(!db_name || (item_field->db_name &&
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 235558a759d..674452192f8 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1532,11 +1532,11 @@ ulong Query_cache::init_cache()
query_cache_table_get_key, 0, 0));
#else
/*
- On windows, OS/2, MacOS X with HFS+ or any other case insensitive
- file system if lower_case_table_names!=0 we have same situation as
- in previous case, but if lower_case_table_names==0 then we should
- not distinguish cases (to be compatible in behavior with underlaying
- file system) and so should use case insensitive collation for
+ On windows, OS/2, MacOS X with HFS+ or any other case insensitive
+ file system if lower_case_table_names!=0 we have same situation as
+ in previous case, but if lower_case_table_names==0 then we should
+ not distinguish cases (to be compatible in behavior with underlying
+ file system) and so should use case insensitive collation for
comparison.
*/
VOID(hash_init(&tables,
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 349fc792a2a..16c0c206df3 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -654,27 +654,29 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length)
return new_table;
}
+
int THD::send_explain_fields(select_result *result)
{
List<Item> field_list;
Item *item;
+ CHARSET_INFO *cs= system_charset_info;
field_list.push_back(new Item_return_int("id",3, MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_empty_string("select_type",19));
- field_list.push_back(new Item_empty_string("table",NAME_LEN));
- field_list.push_back(new Item_empty_string("type",10));
+ field_list.push_back(new Item_empty_string("select_type", 19, cs));
+ field_list.push_back(new Item_empty_string("table", NAME_LEN, cs));
+ field_list.push_back(new Item_empty_string("type", 10, cs));
field_list.push_back(item=new Item_empty_string("possible_keys",
- NAME_LEN*MAX_KEY));
+ NAME_LEN*MAX_KEY, cs));
item->maybe_null=1;
- field_list.push_back(item=new Item_empty_string("key",NAME_LEN));
+ field_list.push_back(item=new Item_empty_string("key", NAME_LEN, cs));
item->maybe_null=1;
field_list.push_back(item=new Item_return_int("key_len",3,
MYSQL_TYPE_LONGLONG));
item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("ref",
- NAME_LEN*MAX_REF_PARTS));
+ NAME_LEN*MAX_REF_PARTS, cs));
item->maybe_null=1;
- field_list.push_back(new Item_return_int("rows",10, MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_empty_string("Extra",255));
+ field_list.push_back(new Item_return_int("rows", 10, MYSQL_TYPE_LONGLONG));
+ field_list.push_back(new Item_empty_string("Extra", 255, cs));
return (result->send_fields(field_list,1));
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 2fa169ce999..3deecccb4e1 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1550,6 +1550,7 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
1 - found
0 - OK (table did not found)
*/
+
bool st_select_lex_unit::check_updateable(char *db, char *table)
{
for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
@@ -1560,8 +1561,8 @@ bool st_select_lex_unit::check_updateable(char *db, char *table)
/*
- Find db.table which will be updated in this select and
- underlayed ones (except derived tables)
+ Find db.table which will be updated in this select and
+ underlying ones (except derived tables)
SYNOPSIS
st_select_lex::check_updateable()
@@ -1572,11 +1573,30 @@ bool st_select_lex_unit::check_updateable(char *db, char *table)
1 - found
0 - OK (table did not found)
*/
+
bool st_select_lex::check_updateable(char *db, char *table)
{
if (find_real_table_in_list(get_table_list(), db, table))
return 1;
+ return check_updateable_in_subqueries(db, table);
+}
+
+/*
+ Find db.table which will be updated in underlying subqueries
+
+ SYNOPSIS
+ st_select_lex::check_updateable_in_subqueries()
+ db - data base name
+ table - real table name
+
+ RETURN
+ 1 - found
+ 0 - OK (table did not found)
+*/
+
+bool st_select_lex::check_updateable_in_subqueries(char *db, char *table)
+{
for (SELECT_LEX_UNIT *un= first_inner_unit();
un;
un= un->next_unit())
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 7342902c086..dffe7bcb2b0 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -517,6 +517,7 @@ public:
}
bool setup_ref_array(THD *thd, uint order_group_num);
bool check_updateable(char *db, char *table);
+ bool check_updateable_in_subqueries(char *db, char *table);
void print(THD *thd, String *str);
static void print_order(String *str, ORDER *order);
void print_limit(THD *thd, String *str);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 75c1e0b859e..2c5ec34b867 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2796,24 +2796,19 @@ unsent_create_error:
target_tbl;
target_tbl= target_tbl->next)
{
- target_tbl->table= target_tbl->table_list->table;
- /*
+ TABLE_LIST *orig= target_tbl->table_list;
+ target_tbl->table= orig->table;
+ /*
Multi-delete can't be constructed over-union => we always have
- single SELECT on top and have to check underlaying SELECTs of it
+ single SELECT on top and have to check underlying SELECTs of it
*/
- for (SELECT_LEX_UNIT *un= lex->select_lex.first_inner_unit();
- un;
- un= un->next_unit())
+ if (lex->select_lex.check_updateable_in_subqueries(orig->db,
+ orig->real_name))
{
- if (un->first_select()->linkage != DERIVED_TABLE_TYPE &&
- un->check_updateable(target_tbl->table_list->db,
- target_tbl->table_list->real_name))
- {
- my_error(ER_UPDATE_TABLE_USED, MYF(0),
- target_tbl->table_list->real_name);
- res= -1;
- break;
- }
+ my_error(ER_UPDATE_TABLE_USED, MYF(0),
+ orig->real_name);
+ res= -1;
+ break;
}
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 6e8cc843d1a..e8e111a9a37 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8465,6 +8465,8 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
}
}
else if ((pos->type() == Item::FUNC_ITEM ||
+ pos->type() == Item::SUBSELECT_ITEM ||
+ pos->type() == Item::CACHE_ITEM ||
pos->type() == Item::COND_ITEM) &&
!pos->with_sum_func)
{ // Save for send fields
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index db4edff4fa1..b6cd0d967e9 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -490,9 +490,8 @@ int mysql_multi_update(THD *thd,
table->grant.want_privilege= (UPDATE_ACL & ~table->grant.privilege);
}
- if (thd->lex->derived_tables)
+ /* Assign table map values to check updatability of derived tables */
{
- // Assign table map values to check updatability of derived tables
uint tablenr=0;
for (TABLE_LIST *table_list= update_list;
table_list;
@@ -501,11 +500,12 @@ int mysql_multi_update(THD *thd,
table_list->table->map= (table_map) 1 << tablenr;
}
}
+
if (setup_fields(thd, 0, update_list, *fields, 1, 0, 0))
DBUG_RETURN(-1);
- if (thd->lex->derived_tables)
+
+ /* Find tables used in items */
{
- // Find tables used in items
List_iterator_fast<Item> it(*fields);
Item *item;
while ((item= it++))
@@ -527,7 +527,23 @@ int mysql_multi_update(THD *thd,
if (table->timestamp_field &&
table->timestamp_field->query_id == thd->query_id)
table->timestamp_on_update_now= 0;
-
+
+ /* if table will be updated then check that it is unique */
+ if (table->map & item_tables)
+ {
+ /*
+ Multi-update can't be constructed over-union => we always have
+ single SELECT on top and have to check underlaying SELECTs of it
+ */
+ if (select_lex->check_updateable_in_subqueries(tl->db,
+ tl->real_name))
+ {
+ my_error(ER_UPDATE_TABLE_USED, MYF(0),
+ tl->real_name);
+ DBUG_RETURN(-1);
+ }
+ }
+
if (tl->derived)
derived_tables|= table->map;
}
diff --git a/sql/tztime.cc b/sql/tztime.cc
index af9af530fec..08e6fc7026e 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -1636,8 +1636,8 @@ end_with_setting_default_tz:
/* If we have default time zone try to load it */
if (default_tzname)
{
- String tzname(default_tzname, &my_charset_latin1);
- if (!(global_system_variables.time_zone= my_tz_find(&tzname, tables)))
+ String tmp_tzname(default_tzname, &my_charset_latin1);
+ if (!(global_system_variables.time_zone= my_tz_find(&tmp_tzname, tables)))
{
sql_print_error("Fatal error: Illegal or unknown default time zone '%s'",
default_tzname);