diff options
author | unknown <serg@serg.mylan> | 2004-07-20 15:34:57 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-07-20 15:34:57 +0200 |
commit | 4118ce3fb5dda66250e89a191cc185f9d4582a4f (patch) | |
tree | 25cbffcf973dd7f352a4bcdc885aa172cb20a57a /sql | |
parent | 58f4db90db784e8b827d3cb7e9f125cd01be8527 (diff) | |
parent | 6979cda63a94c73d7571dad0d9ef040f2f4e54ac (diff) | |
download | mariadb-git-4118ce3fb5dda66250e89a191cc185f9d4582a4f.tar.gz |
manual merge
client/mysql.cc:
Auto merged
client/mysqlbinlog.cc:
Auto merged
include/my_global.h:
Auto merged
innobase/include/row0mysql.h:
Auto merged
mysql-test/r/ps_1general.result:
Auto merged
mysql-test/r/subselect.result:
Auto merged
mysql-test/r/system_mysql_db.result:
Auto merged
mysql-test/t/subselect.test:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/ha_myisam.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item_subselect.h:
Auto merged
sql/sql_load.cc:
Auto merged
sql/sql_table.cc:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_innodb.cc | 4 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 4 | ||||
-rw-r--r-- | sql/handler.cc | 14 | ||||
-rw-r--r-- | sql/item_strfunc.h | 5 | ||||
-rw-r--r-- | sql/item_subselect.cc | 53 | ||||
-rw-r--r-- | sql/item_subselect.h | 10 | ||||
-rw-r--r-- | sql/sql_acl.cc | 50 | ||||
-rw-r--r-- | sql/sql_db.cc | 3 | ||||
-rw-r--r-- | sql/sql_insert.cc | 8 | ||||
-rw-r--r-- | sql/sql_load.cc | 5 |
10 files changed, 91 insertions, 65 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 9f14e22ce38..fdaf5198b7f 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4795,8 +4795,8 @@ ha_innobase::external_lock( trx->n_mysql_tables_in_use--; prebuilt->mysql_has_locked = FALSE; auto_inc_counter_for_this_stat = 0; - if (trx->n_tables_locked) { - row_unlock_table_for_mysql(trx); + if (trx->n_lock_table_exp) { + row_unlock_tables_for_mysql(trx); } /* If the MySQL lock count drops to zero we know that the current SQL diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index d3dc0bb58de..79e1d7b463b 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -337,7 +337,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) HA_STATUS_CONST); } } - else if (!mi_is_crashed(file)) + else if (!mi_is_crashed(file) && !thd->killed) { mi_mark_crashed(file); file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; @@ -379,7 +379,7 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt) error=update_state_info(¶m,file,UPDATE_STAT); pthread_mutex_unlock(&share->intern_lock); } - else if (!mi_is_crashed(file)) + else if (!mi_is_crashed(file) && !thd->killed) mi_mark_crashed(file); return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK; } diff --git a/sql/handler.cc b/sql/handler.cc index 8ca842efebe..9342d20ec24 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -62,21 +62,21 @@ static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES; struct show_table_type_st sys_table_types[]= { {"MyISAM", &have_yes, - "Default type from 3.23 with great performance", DB_TYPE_MYISAM}, + "Default engine as of MySQL 3.23 with great performance", DB_TYPE_MYISAM}, {"HEAP", &have_yes, - "Hash based, stored in memory, useful for temporary tables", DB_TYPE_HEAP}, + "Alias for MEMORY", DB_TYPE_HEAP}, {"MEMORY", &have_yes, - "Alias for HEAP", DB_TYPE_HEAP}, + "Hash based, stored in memory, useful for temporary tables", DB_TYPE_HEAP}, {"MERGE", &have_yes, "Collection of identical MyISAM tables", DB_TYPE_MRG_MYISAM}, {"MRG_MYISAM",&have_yes, "Alias for MERGE", DB_TYPE_MRG_MYISAM}, {"ISAM", &have_isam, - "Obsolete table type; Is replaced by MyISAM", DB_TYPE_ISAM}, + "Obsolete storage engine, now replaced by MyISAM", DB_TYPE_ISAM}, {"MRG_ISAM", &have_isam, - "Obsolete table type; Is replaced by MRG_MYISAM", DB_TYPE_MRG_ISAM}, + "Obsolete storage engine, now replaced by MERGE", DB_TYPE_MRG_ISAM}, {"InnoDB", &have_innodb, - "Supports transactions, row-level locking and foreign keys", DB_TYPE_INNODB}, + "Supports transactions, row-level locking, and foreign keys", DB_TYPE_INNODB}, {"INNOBASE", &have_innodb, "Alias for INNODB", DB_TYPE_INNODB}, {"BDB", &have_berkeley_db, @@ -84,7 +84,7 @@ struct show_table_type_st sys_table_types[]= {"BERKELEYDB",&have_berkeley_db, "Alias for BDB", DB_TYPE_BERKELEY_DB}, {"NDBCLUSTER", &have_ndbcluster, - "Clustered, fault tolerant memory based tables", DB_TYPE_NDBCLUSTER}, + "Clustered, fault-tolerant, memory-based tables", DB_TYPE_NDBCLUSTER}, {"NDB", &have_ndbcluster, "Alias for NDBCLUSTER", DB_TYPE_NDBCLUSTER}, {"EXAMPLE",&have_example_db, diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 22134733393..08123370bc6 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -359,9 +359,10 @@ class Item_func_database :public Item_str_func public: Item_func_database() { collation.set(system_charset_info,DERIVATION_IMPLICIT); } String *val_str(String *); - void fix_length_and_dec() - { + void fix_length_and_dec() + { max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; + maybe_null=1; } const char *func_name() const { return "database"; } }; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 33e661ce46e..766fa215a8f 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* +/* subselect Item SUBSELECT TODO: @@ -41,7 +41,7 @@ Item_subselect::Item_subselect(): { reset(); /* - item value is NULL if select_subselect not changed this value + item value is NULL if select_subselect not changed this value (i.e. some rows will be found returned) */ null_value= 1; @@ -114,7 +114,7 @@ Item_subselect::~Item_subselect() } Item_subselect::trans_res -Item_subselect::select_transformer(JOIN *join) +Item_subselect::select_transformer(JOIN *join) { DBUG_ENTER("Item_subselect::select_transformer"); DBUG_RETURN(RES_OK); @@ -128,7 +128,12 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) arena= thd->current_arena; char const *save_where= thd->where; - int res= engine->prepare(); + int res; + + if (check_stack_overrun(thd, (gptr)&res)) + return 1; + + res= engine->prepare(); // all transformetion is done (used by prepared statements) changed= 1; @@ -148,11 +153,11 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) if (have_to_be_excluded) engine->exclude(); substitution= 0; - thd->where= "checking transformed subquery"; + thd->where= "checking transformed subquery"; if (!(*ref)->fixed) ret= (*ref)->fix_fields(thd, tables, ref); - // We can't substitute aggregate functions (like (SELECT (max(i))) - if ((*ref)->with_sum_func) + // We can't substitute aggregate functions like "SELECT (max(i))" + if (substype() == SINGLEROW_SUBS && (*ref)->with_sum_func) { my_error(ER_INVALID_GROUP_FUNC_USE, MYF(0)); return 1; @@ -161,7 +166,7 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) } // Is it one field subselect? if (engine->cols() > max_columns) - { + { my_error(ER_OPERAND_COLUMNS, MYF(0), 1); return 1; } @@ -199,7 +204,7 @@ bool Item_subselect::exec() return (res); } -Item::Type Item_subselect::type() const +Item::Type Item_subselect::type() const { return SUBSELECT_ITEM; } @@ -277,7 +282,7 @@ Item_maxmin_subselect::Item_maxmin_subselect(Item_subselect *parent, */ used_tables_cache= parent->get_used_tables_cache(); const_item_cache= parent->get_const_item_cache(); - + DBUG_VOID_RETURN; } @@ -299,7 +304,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) { if (changed) return RES_OK; - + SELECT_LEX *select_lex= join->select_lex; Statement backup; @@ -314,10 +319,10 @@ Item_singlerow_subselect::select_transformer(JOIN *join) TODO: solve above problem */ !(select_lex->item_list.head()->type() == FIELD_ITEM || - select_lex->item_list.head()->type() == REF_ITEM) + select_lex->item_list.head()->type() == REF_ITEM) ) { - + have_to_be_excluded= 1; if (join->thd->lex->describe) { @@ -355,7 +360,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) return RES_REDUCE; } return RES_OK; - + err: if (arena) thd->restore_backup_item_arena(arena, &backup); @@ -418,7 +423,7 @@ void Item_singlerow_subselect::bring_value() exec(); } -double Item_singlerow_subselect::val() +double Item_singlerow_subselect::val() { DBUG_ASSERT(fixed == 1); if (!exec() && !value->null_value) @@ -433,7 +438,7 @@ double Item_singlerow_subselect::val() } } -longlong Item_singlerow_subselect::val_int() +longlong Item_singlerow_subselect::val_int() { DBUG_ASSERT(fixed == 1); if (!exec() && !value->null_value) @@ -448,7 +453,7 @@ longlong Item_singlerow_subselect::val_int() } } -String *Item_singlerow_subselect::val_str (String *str) +String *Item_singlerow_subselect::val_str (String *str) { if (!exec() && !value->null_value) { @@ -553,7 +558,7 @@ double Item_exists_subselect::val() return (double) value; } -longlong Item_exists_subselect::val_int() +longlong Item_exists_subselect::val_int() { DBUG_ASSERT(fixed == 1); if (exec()) @@ -590,7 +595,7 @@ double Item_in_subselect::val() return (double) value; } -longlong Item_in_subselect::val_int() +longlong Item_in_subselect::val_int() { DBUG_ASSERT(fixed == 1); if (exec()) @@ -825,7 +830,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, */ select_lex->having= join->having= - func->create(expr, + func->create(expr, new Item_null_helper(this, item, (char *)"<no matter>", (char *)"<result>")); @@ -842,7 +847,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, { // it is single select without tables => possible optimization item= func->create(left_expr, item); - // fix_field of item will be done in time of substituting + // fix_field of item will be done in time of substituting substitution= item; have_to_be_excluded= 1; if (thd->lex->describe) @@ -885,7 +890,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) thd->where= "row IN/ALL/ANY subquery"; if (arena) - thd->set_n_backup_item_arena(arena, &backup); + thd->set_n_backup_item_arena(arena, &backup); SELECT_LEX *select_lex= join->select_lex; @@ -926,7 +931,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) List_iterator_fast<Item> li(select_lex->item_list); for (uint i= 0; i < n; i++) { - Item *func= new Item_ref_null_helper(this, + Item *func= new Item_ref_null_helper(this, select_lex->ref_pointer_array+i, (char *) "<no matter>", (char *) "<list ref>"); @@ -1119,7 +1124,7 @@ int subselect_single_select_engine::prepare() (ORDER*) select_lex->order_list.first, (ORDER*) select_lex->group_list.first, select_lex->having, - (ORDER*) 0, select_lex, + (ORDER*) 0, select_lex, select_lex->master_unit())) return 1; thd->lex->current_select= save_select; diff --git a/sql/item_subselect.h b/sql/item_subselect.h index d50688e0b58..90c301c6571 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -47,7 +47,7 @@ protected: /* old engine if engine was changed */ subselect_engine *old_engine; /* cache of used external tables */ - table_map used_tables_cache; + table_map used_tables_cache; /* allowed number of columns (1 for single value subqueries) */ uint max_columns; /* work with 'substitution' */ @@ -69,17 +69,17 @@ public: virtual subs_type substype() { return UNKNOWN_SUBS; } - /* + /* We need this method, because some compilers do not allow 'this' pointer in constructor initialization list, but we need pass pointer to subselect Item class to select_subselect classes constructor. */ - virtual void init (st_select_lex *select_lex, + virtual void init (st_select_lex *select_lex, select_subselect *result); ~Item_subselect(); void cleanup(); - virtual void reset() + virtual void reset() { null_value= 1; } @@ -276,7 +276,7 @@ public: } virtual ~subselect_engine() {}; // to satisfy compiler virtual void cleanup()= 0; - + // set_thd should be called before prepare() void set_thd(THD *thd_arg) { thd= thd_arg; } THD * get_thd() { return thd; } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 10a12ef6d04..890f6629b11 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -36,8 +36,6 @@ #ifndef NO_EMBEDDED_ACCESS_CHECKS -#define FIRST_NON_YN_FIELD 26 - class acl_entry :public hash_filo_element { public: @@ -66,7 +64,7 @@ static DYNAMIC_ARRAY acl_wild_hosts; static hash_filo *acl_cache; static uint grant_version=0; static uint priv_version=0; /* Version of priv tables. incremented by acl_init */ -static ulong get_access(TABLE *form,uint fieldnr); +static ulong get_access(TABLE *form,uint fieldnr, uint *next_field=0); static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b); static ulong get_sort(uint count,...); static void init_check_host(void); @@ -301,18 +299,15 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) } else // password is correct { - user.access= get_access(table,3) & GLOBAL_ACLS; + uint next_field; + user.access= get_access(table,3,&next_field) & GLOBAL_ACLS; user.sort= get_sort(2,user.host.hostname,user.user); user.hostname_length= (user.host.hostname ? (uint) strlen(user.host.hostname) : 0); if (table->fields >= 31) /* Starting from 4.0.2 we have more fields */ { - uint base_field= 24; - if (table->fields > 31) /* Starting from 5.1 we have more privileges */ - base_field= 26; - - char *ssl_type=get_field(&mem, table->field[base_field]); + char *ssl_type=get_field(&mem, table->field[next_field++]); if (!ssl_type) user.ssl_type=SSL_TYPE_NONE; else if (!strcmp(ssl_type, "ANY")) @@ -322,16 +317,16 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) else /* !strcmp(ssl_type, "SPECIFIED") */ user.ssl_type=SSL_TYPE_SPECIFIED; - user.ssl_cipher= get_field(&mem, table->field[base_field+1]); - user.x509_issuer= get_field(&mem, table->field[base_field+2]); - user.x509_subject= get_field(&mem, table->field[base_field+3]); + user.ssl_cipher= get_field(&mem, table->field[next_field++]); + user.x509_issuer= get_field(&mem, table->field[next_field++]); + user.x509_subject= get_field(&mem, table->field[next_field++]); - char *ptr = get_field(&mem, table->field[base_field+4]); - user.user_resource.questions=atoi(ptr); - ptr = get_field(&mem, table->field[base_field+5]); - user.user_resource.updates=atoi(ptr); - ptr = get_field(&mem, table->field[base_field+6]); - user.user_resource.connections=atoi(ptr); + char *ptr = get_field(&mem, table->field[next_field++]); + user.user_resource.questions=ptr ? atoi(ptr) : 0; + ptr = get_field(&mem, table->field[next_field++]); + user.user_resource.updates=ptr ? atoi(ptr) : 0; + ptr = get_field(&mem, table->field[next_field++]); + user.user_resource.connections=ptr ? atoi(ptr) : 0; if (user.user_resource.questions || user.user_resource.updates || user.user_resource.connections) mqh_used=1; @@ -496,11 +491,24 @@ void acl_reload(THD *thd) /* Get all access bits from table after fieldnr + + IMPLEMENTATION We know that the access privileges ends when there is no more fields or the field is not an enum with two elements. + + SYNOPSIS + get_access() + form an open table to read privileges from. + The record should be already read in table->record[0] + fieldnr number of the first privilege (that is ENUM('N','Y') field + next_field on return - number of the field next to the last ENUM + (unless next_field == 0) + + RETURN VALUE + privilege mask */ -static ulong get_access(TABLE *form, uint fieldnr) +static ulong get_access(TABLE *form, uint fieldnr, uint *next_field) { ulong access_bits=0,bit; char buff[2]; @@ -510,12 +518,14 @@ static ulong get_access(TABLE *form, uint fieldnr) for (pos=form->field+fieldnr, bit=1; *pos && (*pos)->real_type() == FIELD_TYPE_ENUM && ((Field_enum*) (*pos))->typelib->count == 2 ; - pos++ , bit<<=1) + pos++, fieldnr++, bit<<=1) { (*pos)->val_str(&res); if (my_toupper(&my_charset_latin1, res[0]) == 'Y') access_bits|= bit; } + if (next_field) + *next_field=fieldnr; return access_bits; } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index a1ccfe8d22c..c898c46a3f0 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -225,7 +225,8 @@ void del_dbopt(const char *path) { my_dbopt_t *opt; rw_wrlock(&LOCK_dboptions); - if ((opt= (my_dbopt_t *)hash_search(&dboptions, (byte*) path, strlen(path)))) + if ((opt= (my_dbopt_t *)hash_search(&dboptions, (const byte*) path, + strlen(path)))) hash_delete(&dboptions, (byte*) opt); rw_unlock(&LOCK_dboptions); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c0682d9d4c8..a9a7d9b4d5a 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1833,9 +1833,13 @@ void select_create::abort() table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); enum db_type table_type=table->db_type; if (!table->tmp_table) + { hash_delete(&open_cache,(byte*) table); - if (!create_info->table_existed) - quick_rm_table(table_type, create_table->db, create_table->real_name); + if (!create_info->table_existed) + quick_rm_table(table_type, create_table->db, create_table->real_name); + } + else if (!create_info->table_existed) + close_temporary_table(thd, create_table->db, create_table->real_name); table=0; } VOID(pthread_mutex_unlock(&LOCK_open)); diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 47295d4c6a0..fa3adf236fe 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -320,6 +320,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, { if (transactional_table) ha_autocommit_or_rollback(thd,error); + + if (read_file_from_client) + while (!read_info.next_line()) + ; + #ifndef EMBEDDED_LIBRARY if (mysql_bin_log.is_open()) { |