diff options
author | unknown <monty@mysql.com> | 2005-10-12 00:58:22 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-10-12 00:58:22 +0300 |
commit | 0ce12f70ed2eee1b92e2af27e7dda30db544f492 (patch) | |
tree | ce0e98ba05247bbe755ac299d0ceaa8c42d63b7a /sql | |
parent | c2621f3dcb785e5f78734e20dabbd98bff4fd844 (diff) | |
download | mariadb-git-0ce12f70ed2eee1b92e2af27e7dda30db544f492.tar.gz |
Reviewing new pushed code
- CHAR() now returns binary string as default
- CHAR(X*65536+Y*256+Z) is now equal to CHAR(X,Y,Z) independent of the character set for CHAR()
- Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
(Some old systems returns ETIME and it's safer to test for both values
than to try to write a wrapper for each old system)
- Fixed new introduced bug in NOT BETWEEN X and X
- Ensure we call commit_by_xid or rollback_by_xid for all engines, even if one engine has failed
- Use octet2hex() for all conversion of string to hex
- Simplify and optimize code
client/mysqldump.c:
Simple optimizations of new code
Indentation fixes
client/mysqltest.c:
Removed not needed variable
include/mysql_com.h:
Made octec2hex() more usable
mysql-test/r/ctype_utf8.result:
CHAR() now returns binary string as default
mysql-test/r/func_str.result:
CHAR() now returns binary string as default
mysql-test/r/range.result:
Added test to verify new introduced bug in NOT BETWEEN X and X
mysql-test/r/user_var-binlog.result:
CHAR() now returns binary string as default
mysql-test/r/view.result:
More tests of view rename
mysql-test/t/ctype_utf8.test:
CHAR() now returns binary string as default
mysql-test/t/func_str.test:
CHAR() now returns binary string as default
mysql-test/t/range.test:
Added test to verify new introduced bug in NOT BETWEEN X and X
mysql-test/t/view.test:
More tests of view rename
mysys/mf_keycache.c:
Indentation changes
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
mysys/my_os2cond.c:
Fix to MySQL coding style
Optimized functions
mysys/thr_lock.c:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
mysys/thr_mutex.c:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
server-tools/instance-manager/instance.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
server-tools/instance-manager/thread_registry.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/ha_federated.cc:
Use octet2hex()
sql/ha_ndbcluster.cc:
Removed not used variable
sql/handler.cc:
Simplify code
Use *NONE* instead of 'none' for not existing storage engine
Ensure we call commit_by_xid or rollback_by_xid for all engines, even if one engine has failed
sql/item.h:
Remove not needed test for *ref. (If ref is set, it should never point at 0)
sql/item_func.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
Simplify code
More comments
Require that last argument to find_and_check_access() is given
(Made code shorter and faster)
sql/item_strfunc.cc:
Changed CHAR() to return result in binary collation
CHAR(X*65536+Y*256+Z) is now equal to CHAR(X,Y,Z) independent of the character set for CHAR()
Bar will shortly add the following syntax:
CHAR(.... USING character_set)
and ensure that
CONVERT(CHAR(....) USING utf8) cuts not legal utf8 strings
Use ocet2hex()
sql/item_strfunc.h:
CHAR() now returns a binary string
sql/log_event.cc:
Use octet2hex()
Simplify code
sql/parse_file.cc:
Indentation fixes
Use for() instead of while()
sql/password.c:
Make octet2hex() more generally usable by returning pointer to end 0
sql/slave.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/sql_base.cc:
Indentation fixes
sql/sql_insert.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/sql_manager.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/sql_parse.cc:
Don't check thd->db when checking for function privileges
sql/sql_prepare.cc:
Fixed wrong merge
sql/sql_select.cc:
Fixed new bug for NOT BETWEEN X and X
sql/sql_show.cc:
Removed not used variable
sql/sql_table.cc:
Indentation fixed
Removed DBUG_PRINT that is obvious from context
sql/sql_view.cc:
Simplify code
sql/unireg.cc:
Use octet2hex()
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_federated.cc | 9 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 7 | ||||
-rw-r--r-- | sql/handler.cc | 27 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 103 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 42 | ||||
-rw-r--r-- | sql/item_strfunc.h | 2 | ||||
-rw-r--r-- | sql/log_event.cc | 18 | ||||
-rw-r--r-- | sql/parse_file.cc | 7 | ||||
-rw-r--r-- | sql/password.c | 13 | ||||
-rw-r--r-- | sql/slave.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 | ||||
-rw-r--r-- | sql/sql_insert.cc | 2 | ||||
-rw-r--r-- | sql/sql_manager.cc | 12 | ||||
-rw-r--r-- | sql/sql_parse.cc | 11 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 8 | ||||
-rw-r--r-- | sql/sql_show.cc | 3 | ||||
-rw-r--r-- | sql/sql_table.cc | 7 | ||||
-rw-r--r-- | sql/sql_view.cc | 2 | ||||
-rw-r--r-- | sql/unireg.cc | 8 |
21 files changed, 149 insertions, 142 deletions
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 20badb05f09..3c5adb3f10f 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -821,13 +821,8 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part, *buf++= '0'; *buf++= 'x'; - for (; len; ptr++,len--) - { - uint tmp= (uint)(uchar) *ptr; - *buf++= _dig_vec_upper[tmp >> 4]; - *buf++= _dig_vec_upper[tmp & 15]; - } - if (to->append(buff, (uint)(buf - buff))) + buf= octet2hex(buf, (char*) ptr, len); + if (to->append((char*) buff, (uint)(buf - buff))) DBUG_RETURN(1); } else if (part->key_part_flag & HA_BLOB_PART) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 6f2c7670b88..50f53ecf410 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -5931,7 +5931,6 @@ extern "C" pthread_handler_decl(ndb_util_thread_func, { THD *thd; /* needs to be first for thread_stack */ Ndb* ndb; - int error= 0; struct timespec abstime; my_thread_init(); @@ -5960,9 +5959,9 @@ extern "C" pthread_handler_decl(ndb_util_thread_func, { pthread_mutex_lock(&LOCK_ndb_util_thread); - error= pthread_cond_timedwait(&COND_ndb_util_thread, - &LOCK_ndb_util_thread, - &abstime); + pthread_cond_timedwait(&COND_ndb_util_thread, + &LOCK_ndb_util_thread, + &abstime); pthread_mutex_unlock(&LOCK_ndb_util_thread); DBUG_PRINT("ndb_util_thread", ("Started, ndb_cache_check_time: %d", diff --git a/sql/handler.cc b/sql/handler.cc index d449a0b90f2..1e38b6dc2ab 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -209,6 +209,8 @@ retest: return DB_TYPE_UNKNOWN; } + + const char *ha_get_storage_engine(enum db_type db_type) { handlerton **types; @@ -217,25 +219,19 @@ const char *ha_get_storage_engine(enum db_type db_type) if (db_type == (*types)->db_type) return (*types)->name; } - - return "none"; + return "*NONE*"; } + bool ha_check_storage_engine_flag(enum db_type db_type, uint32 flag) { handlerton **types; for (types= sys_table_types; *types; types++) { if (db_type == (*types)->db_type) - { - if ((*types)->flags & flag) - return TRUE; - else - return FALSE; - } + return test((*types)->flags & flag); } - - return FALSE; + return FALSE; // No matching engine } @@ -850,18 +846,25 @@ int ha_autocommit_or_rollback(THD *thd, int error) DBUG_RETURN(error); } + int ha_commit_or_rollback_by_xid(XID *xid, bool commit) { handlerton **types; int res= 1; for (types= sys_table_types; *types; types++) + { if ((*types)->state == SHOW_OPTION_YES && (*types)->recover) - res= res && - (*(commit ? (*types)->commit_by_xid : (*types)->rollback_by_xid))(xid); + { + if ((*(commit ? (*types)->commit_by_xid : + (*types)->rollback_by_xid))(xid)); + res= 0; + } + } return res; } + #ifndef DBUG_OFF /* this does not need to be multi-byte safe or anything */ static char* xid_to_str(char *buf, XID *xid) diff --git a/sql/item.h b/sql/item.h index 8e6b4e245d2..320591d4d99 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1616,7 +1616,7 @@ public: } Item *real_item() { - return (ref && *ref) ? (*ref)->real_item() : this; + return ref ? (*ref)->real_item() : this; } bool walk(Item_processor processor, byte *arg) { return (*ref)->walk(processor, arg); } diff --git a/sql/item_func.cc b/sql/item_func.cc index ef896ca3cfd..b716f56f21f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -32,6 +32,11 @@ #include "sp_rcontext.h" #include "sp.h" +#ifdef NO_EMBEDDED_ACCESS_CHECKS +#define sp_restore_security_context(A,B) while (0) {} +#endif + + bool check_reserved_words(LEX_STRING *name) { if (!my_strcasecmp(system_charset_info, name->str, "GLOBAL") || @@ -3028,9 +3033,13 @@ void debug_sync_point(const char* lock_name, uint lock_timeout) thd->mysys_var->current_cond= &ull->cond; set_timespec(abstime,lock_timeout); - while (!thd->killed && - pthread_cond_timedwait(&ull->cond, &LOCK_user_locks, - &abstime) != ETIMEDOUT && ull->locked) ; + while (ull->locked && !thd->killed) + { + int error= pthread_cond_timedwait(&ull->cond, &LOCK_user_locks, &abstime); + if (error == ETIMEDOUT || error == ETIME) + break; + } + if (ull->locked) { if (!--ull->count) @@ -3074,7 +3083,7 @@ longlong Item_func_get_lock::val_int() struct timespec abstime; THD *thd=current_thd; User_level_lock *ull; - int error=0; + int error; /* In slave thread no need to get locks, everything is serialized. Anyway @@ -3130,22 +3139,29 @@ longlong Item_func_get_lock::val_int() thd->mysys_var->current_cond= &ull->cond; set_timespec(abstime,timeout); - while (!thd->killed && - (error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime)) - != ETIMEDOUT && error != EINVAL && ull->locked) ; - if (thd->killed) - error=EINTR; // Return NULL + error= 0; + while (ull->locked && !thd->killed) + { + error= pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime); + if (error == ETIMEDOUT || error == ETIME) + break; + error= 0; + } + if (ull->locked) { if (!--ull->count) + { + DBUG_ASSERT(0); delete ull; // Should never happen - if (error != ETIMEDOUT) + } + if (!error) // Killed (thd->killed != 0) { error=1; null_value=1; // Return NULL } } - else + else // We got the lock { ull->locked=1; ull->thread=thd->real_id; @@ -3267,6 +3283,7 @@ void Item_func_benchmark::print(String *str) str->append(')'); } + /* This function is just used to create tests with time gaps */ longlong Item_func_sleep::val_int() @@ -3287,10 +3304,14 @@ longlong Item_func_sleep::val_int() thd->mysys_var->current_mutex= &LOCK_user_locks; thd->mysys_var->current_cond= &cond; - while (!thd->killed && - (error= pthread_cond_timedwait(&cond, &LOCK_user_locks, - &abstime)) != ETIMEDOUT && - error != EINVAL) ; + error= 0; + while (!thd->killed) + { + error= pthread_cond_timedwait(&cond, &LOCK_user_locks, &abstime); + if (error == ETIMEDOUT || error == ETIME) + break; + error= 0; + } pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= 0; @@ -3300,7 +3321,7 @@ longlong Item_func_sleep::val_int() pthread_mutex_unlock(&LOCK_user_locks); pthread_cond_destroy(&cond); - return (error == ETIMEDOUT) ? 0 : 1; + return test(!error); // Return 1 killed } @@ -4729,10 +4750,7 @@ Item_func_sp::execute(Item **itp) ER_FAILED_ROUTINE_BREAK_BINLOG, ER(ER_FAILED_ROUTINE_BREAK_BINLOG)); -#ifndef NO_EMBEDDED_ACCESS_CHECKS sp_restore_security_context(thd, save_ctx); -#endif - error: DBUG_RETURN(res); } @@ -4846,11 +4864,12 @@ Item_func_sp::tmp_table_field(TABLE *t_arg) find_and_check_access() thd thread handler want_access requested access - backup backup of security context or 0 + save backup of security context RETURN FALSE Access granted TRUE Requested access can't be granted or function doesn't exists + In this case security context is not changed and *save = 0 NOTES Checks if requested access to function can be granted to user. @@ -4865,12 +4884,11 @@ Item_func_sp::tmp_table_field(TABLE *t_arg) bool Item_func_sp::find_and_check_access(THD *thd, ulong want_access, - Security_context **backup) + Security_context **save) { - bool res; - Security_context *local_save, - **save= (backup ? backup : &local_save); - res= TRUE; + bool res= TRUE; + + *save= 0; // Safety if error if (! m_sp && ! (m_sp= sp_find_function(thd, m_name, TRUE))) { my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str); @@ -4880,26 +4898,31 @@ Item_func_sp::find_and_check_access(THD *thd, ulong want_access, #ifndef NO_EMBEDDED_ACCESS_CHECKS if (check_routine_access(thd, want_access, m_sp->m_db.str, m_sp->m_name.str, 0, FALSE)) - { goto error; - } sp_change_security_context(thd, m_sp, save); + /* + If we changed context to run as another user, we need to check the + access right for the new context again as someone may have deleted + this person the right to use the procedure + + TODO: + Cache if the definer has the right to use the object on the first + usage and only reset the cache if someone does a GRANT statement + that 'may' affect this. + */ if (*save && check_routine_access(thd, want_access, m_sp->m_db.str, m_sp->m_name.str, 0, FALSE)) { - goto error_check_ctx; + sp_restore_security_context(thd, *save); + *save= 0; // Safety + goto error; } - res= FALSE; -error_check_ctx: - if (*save && (res || !backup)) - sp_restore_security_context(thd, local_save); -error: -#else - res= 0; -error: #endif + res= FALSE; // no error + +error: return res; } @@ -4909,7 +4932,11 @@ Item_func_sp::fix_fields(THD *thd, Item **ref) bool res; DBUG_ASSERT(fixed == 0); res= Item_func::fix_fields(thd, ref); - if (!res && find_and_check_access(thd, EXECUTE_ACL, NULL)) - res= 1; + if (!res) + { + Security_context *save_ctx; + if (!(res= find_and_check_access(thd, EXECUTE_ACL, &save_ctx))) + sp_restore_security_context(thd, save_ctx); + } return res; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 018afac3812..1812256d532 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1964,21 +1964,16 @@ String *Item_func_char::val_str(String *str) int32 num=(int32) args[i]->val_int(); if (!args[i]->null_value) { -#ifdef USE_MB - if (use_mb(collation.collation)) - { - if (num&0xFF000000L) { - str->append((char)(num>>24)); - goto b2; - } else if (num&0xFF0000L) { -b2: str->append((char)(num>>16)); - goto b1; - } else if (num&0xFF00L) { -b1: str->append((char)(num>>8)); - } + if (num&0xFF000000L) { + str->append((char)(num>>24)); + goto b2; + } else if (num&0xFF0000L) { + b2: str->append((char)(num>>16)); + goto b1; + } else if (num&0xFF00L) { + b1: str->append((char)(num>>8)); } -#endif - str->append((char)num); + str->append((char) num); } } str->set_charset(collation.collation); @@ -1997,7 +1992,7 @@ b1: str->append((char)(num>>8)); enum MYSQL_ERROR::enum_warning_level level; uint diff= str->length() - wlen; set_if_smaller(diff, 3); - octet2hex(hexbuf, (const uchar*) str->ptr() + wlen, diff); + octet2hex(hexbuf, str->ptr() + wlen, diff); if (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)) { @@ -2436,6 +2431,7 @@ String *Item_func_collation::val_str(String *str) String *Item_func_hex::val_str(String *str) { + String *res; DBUG_ASSERT(fixed == 1); if (args[0]->result_type() != STRING_RESULT) { @@ -2464,24 +2460,16 @@ String *Item_func_hex::val_str(String *str) } /* Convert given string to a hex string, character by character */ - String *res= args[0]->val_str(str); - const char *from, *end; - char *to; - if (!res || tmp_value.alloc(res->length()*2)) + res= args[0]->val_str(str); + if (!res || tmp_value.alloc(res->length()*2+1)) { null_value=1; return 0; } null_value=0; tmp_value.length(res->length()*2); - for (from=res->ptr(), end=from+res->length(), to= (char*) tmp_value.ptr(); - from < end ; - from++, to+=2) - { - uint tmp=(uint) (uchar) *from; - to[0]=_dig_vec_upper[tmp >> 4]; - to[1]=_dig_vec_upper[tmp & 15]; - } + + octet2hex((char*) tmp_value.ptr(), res->ptr(), res->length()); return &tmp_value; } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index fa098849a43..ec470bb242b 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -484,7 +484,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - collation.set(default_charset()); + collation.set(&my_charset_bin); maybe_null=0; max_length=arg_count; } const char *func_name() const { return "char"; } diff --git a/sql/log_event.cc b/sql/log_event.cc index 55c761d4c6e..ed6599f692f 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -212,24 +212,18 @@ static inline int read_str(char **buf, char *buf_end, char **str, /* Transforms a string into "" or its expression in 0x... form. */ + char *str_to_hex(char *to, const char *from, uint len) { - char *p= to; if (len) { - p= strmov(p, "0x"); - for (uint i= 0; i < len; i++, p+= 2) - { - /* val[i] is char. Casting to uchar helps greatly if val[i] < 0 */ - uint tmp= (uint) (uchar) from[i]; - p[0]= _dig_vec_upper[tmp >> 4]; - p[1]= _dig_vec_upper[tmp & 15]; - } - *p= 0; + *to++= '0'; + *to++= 'x'; + to= octet2hex(to, from, len); } else - p= strmov(p, "\"\""); - return p; // pointer to end 0 of 'to' + to= strmov(to, "\"\""); + return to; // pointer to end 0 of 'to' } /* diff --git a/sql/parse_file.cc b/sql/parse_file.cc index 5c7053e6e2a..d3e5645bafc 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -372,8 +372,10 @@ my_bool rename_in_schema_file(const char *schema, const char *old_name, if (revision > 0 && !access(arc_path, F_OK)) { - ulonglong limit= (revision > num_view_backups) ? revision - num_view_backups : 0; - while (revision > limit) { + ulonglong limit= ((revision > num_view_backups) ? + revision - num_view_backups : 0); + for (; revision > limit ; revision--) + { my_snprintf(old_path, FN_REFLEN, "%s/%s%s-%04lu", arc_path, old_name, reg_ext, (ulong)revision); (void) unpack_filename(old_path, old_path); @@ -381,7 +383,6 @@ my_bool rename_in_schema_file(const char *schema, const char *old_name, arc_path, new_name, reg_ext, (ulong)revision); (void) unpack_filename(new_path, new_path); my_rename(old_path, new_path, MYF(0)); - revision--; } } return 0; diff --git a/sql/password.c b/sql/password.c index aa05be8c740..562df3ae226 100644 --- a/sql/password.c +++ b/sql/password.c @@ -316,18 +316,21 @@ void create_random_string(char *to, uint length, struct rand_struct *rand_st) octet2hex() buf OUT output buffer. Must be at least 2*len+1 bytes str, len IN the beginning and the length of the input string + + RETURN + buf+len*2 */ -void -octet2hex(char *to, const unsigned char *str, uint len) +char *octet2hex(char *to, const char *str, uint len) { - const uint8 *str_end= str + len; + const byte *str_end= str + len; for (; str != str_end; ++str) { - *to++= _dig_vec_upper[(*str & 0xF0) >> 4]; - *to++= _dig_vec_upper[*str & 0x0F]; + *to++= _dig_vec_upper[((uchar) *str) >> 4]; + *to++= _dig_vec_upper[((uchar) *str) & 0x0F]; } *to= '\0'; + return to; } diff --git a/sql/slave.cc b/sql/slave.cc index b1763187d04..cc7ec5e5ae8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2747,7 +2747,7 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, else pthread_cond_wait(&data_cond, &data_lock); DBUG_PRINT("info",("Got signal of master update or timed out")); - if (error == ETIMEDOUT) + if (error == ETIMEDOUT || error == ETIME) { error= -1; break; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 51b9fe43796..35187047364 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2784,7 +2784,6 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, Natural_join_column *nj_col; Field *found_field; Query_arena *arena, backup; - DBUG_ENTER("find_field_in_natural_join"); DBUG_PRINT("enter", ("field name: '%s', ref 0x%lx", name, (ulong) ref)); @@ -2809,6 +2808,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, if (nj_col->view_field) { + Item *item; /* The found field is a view field, we do as in find_field_in_view() and return a pointer to pointer to the Item of that field. @@ -2816,7 +2816,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, if (register_tree_change) arena= thd->activate_stmt_arena_if_needed(&backup); - Item *item= nj_col->create_item(thd); + item= nj_col->create_item(thd); if (register_tree_change && arena) thd->restore_active_arena(arena, &backup); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index cc4b291b5d1..fbfce2e3a31 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1809,7 +1809,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg) #endif if (thd->killed || di->status) break; - if (error == ETIMEDOUT) + if (error == ETIMEDOUT || error == ETIME) { thd->killed= THD::KILL_CONNECTION; break; diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc index 0af6a80d4c2..54599314293 100644 --- a/sql/sql_manager.cc +++ b/sql/sql_manager.cc @@ -58,12 +58,14 @@ extern "C" pthread_handler_decl(handle_manager,arg __attribute__((unused))) set_timespec(abstime, flush_time); reset_flush_time = FALSE; } - while (!manager_status && !error && !abort_loop) - error = pthread_cond_timedwait(&COND_manager, &LOCK_manager, &abstime); + while (!manager_status && (!error || error == EINTR) && !abort_loop) + error= pthread_cond_timedwait(&COND_manager, &LOCK_manager, &abstime); } else - while (!manager_status && !error && !abort_loop) - error = pthread_cond_wait(&COND_manager, &LOCK_manager); + { + while (!manager_status && (!error || error == EINTR) && !abort_loop) + error= pthread_cond_wait(&COND_manager, &LOCK_manager); + } status = manager_status; manager_status = 0; pthread_mutex_unlock(&LOCK_manager); @@ -71,7 +73,7 @@ extern "C" pthread_handler_decl(handle_manager,arg __attribute__((unused))) if (abort_loop) break; - if (error) /* == ETIMEDOUT */ + if (error == ETIMEDOUT || error == ETIME) { flush_tables(); error = 0; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8a6b776e803..e28eff4f577 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5054,11 +5054,16 @@ check_routine_access(THD *thd, ulong want_access,char *db, char *name, tables->db= db; tables->table_name= tables->alias= name; - if ((thd->security_ctx->master_access & want_access) == want_access && - !thd->db) + /* + The following test is just a shortcut for check_access() (to avoid + calculating db_access) under the assumption that it's common to + give persons global right to execute all stored SP (but not + necessary to create them). + */ + if ((thd->security_ctx->master_access & want_access) == want_access) tables->grant.privilege= want_access; else if (check_access(thd,want_access,db,&tables->grant.privilege, - 0, no_errors, test(tables->schema_table))) + 0, no_errors, 0)) return TRUE; #ifndef NO_EMBEDDED_ACCESS_CHECKS diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index aebe7880451..5f3539ca1e9 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2887,7 +2887,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) thd->protocol= &thd->protocol_simple; /* use normal protocol */ /* Assert that if an error, no cursor is open */ - DBUG_ASSERT(! (rc && cursor)); + DBUG_ASSERT(! (error && cursor)); if (! cursor) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1b1a35d2584..f38ef19614e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2474,11 +2474,11 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, Item_func *cond, and use them in equality propagation process (see details in OptimizerKBAndTodo) */ - if ((cond->functype() == Item_func::BETWEEN) && - value[0]->eq(value[1], field->binary())) - eq_func= TRUE; - else + if ((cond->functype() != Item_func::BETWEEN) || + ((Item_func_between*) cond)->negated || + !value[0]->eq(value[1], field->binary())) return; + eq_func= TRUE; } if (field->result_type() == STRING_RESULT) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2d98e834de7..1eb8aa1acb9 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1258,9 +1258,6 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) VOID(pthread_mutex_unlock(&LOCK_thread_count)); thread_info *thd_info; -#ifndef NO_EMBEDDED_ACCESS_CHECKS - Security_context *sctx; -#endif time_t now= time(0); while ((thd_info=thread_infos.get())) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8fb39ea3098..9c3ea710dfc 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3156,15 +3156,14 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (create_info->row_type == ROW_TYPE_NOT_USED) create_info->row_type= table->s->row_type; - DBUG_PRINT("info", ("old type: %d new type: %d", old_db_type, new_db_type)); - if (ha_check_storage_engine_flag(old_db_type, HTON_ALTER_NOT_SUPPORTED) - || ha_check_storage_engine_flag(new_db_type, HTON_ALTER_NOT_SUPPORTED)) + DBUG_PRINT("info", ("old type: %d new type: %d", old_db_type, new_db_type)); + if (ha_check_storage_engine_flag(old_db_type, HTON_ALTER_NOT_SUPPORTED) || + ha_check_storage_engine_flag(new_db_type, HTON_ALTER_NOT_SUPPORTED)) { DBUG_PRINT("info", ("doesn't support alter")); my_error(ER_ILLEGAL_HA, MYF(0), table_name); DBUG_RETURN(TRUE); } - DBUG_PRINT("info", ("supports alter")); thd->proc_info="setup"; if (!(alter_info->flags & ~(ALTER_RENAME | ALTER_KEYS_ONOFF)) && diff --git a/sql/sql_view.cc b/sql/sql_view.cc index f956d9d4928..5db08275735 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1427,7 +1427,7 @@ mysql_rename_view(THD *thd, /* get view definition and source */ if (parser->parse((gptr)&view_def, thd->mem_root, view_parameters, - sizeof(view_parameters)/sizeof(view_parameters[0])-1)) + array_elements(view_parameters)-1)) goto err; /* rename view and it's backups */ diff --git a/sql/unireg.cc b/sql/unireg.cc index d297b143d3b..7c244b20a8b 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -474,16 +474,10 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, char *dst; uint length= field->interval->type_lengths[pos], hex_length; const char *src= field->interval->type_names[pos]; - const char *srcend= src + length; hex_length= length * 2; field->interval->type_lengths[pos]= hex_length; field->interval->type_names[pos]= dst= sql_alloc(hex_length + 1); - for ( ; src < srcend; src++) - { - *dst++= _dig_vec_upper[((uchar) *src) >> 4]; - *dst++= _dig_vec_upper[((uchar) *src) & 15]; - } - *dst= '\0'; + octet2hex(dst, src, length); } } |