diff options
author | unknown <serg@serg.mysql.com> | 2001-10-09 16:01:06 +0200 |
---|---|---|
committer | unknown <serg@serg.mysql.com> | 2001-10-09 16:01:06 +0200 |
commit | a0ed9744f3d12e16e0fa5e784a37f21d7a1d2faf (patch) | |
tree | bace3e172eb9211454c99657fb4493bb3159d503 /sql/item_func.cc | |
parent | 93cc6444ccad2ace36ba354cd96ffe8ede676761 (diff) | |
parent | 85e02d693c10553fd15c1193865a7e6996545838 (diff) | |
download | mariadb-git-a0ed9744f3d12e16e0fa5e784a37f21d7a1d2faf.tar.gz |
merged
BitKeeper/etc/ignore:
auto-union
BitKeeper/deleted/.del-ft_search.c~c011cb6e8041bb59:
the file is deleted anyway
include/my_global.h:
merder
myisam/ft_boolean_search.c:
huh?
mysql-test/r/fulltext.result:
use local
mysql-test/r/fulltext_cache.result:
ur
mysql-test/r/fulltext_left_join.result:
ur
mysql-test/r/fulltext_multi.result:
ur
mysql-test/r/fulltext_order_by.result:
ur
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 111 |
1 files changed, 99 insertions, 12 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 960cadf71e9..bbe5e5fced9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -184,8 +184,10 @@ String *Item_num_func::val_str(String *str) longlong nr=val_int(); if (null_value) return 0; /* purecov: inspected */ - else + else if (!unsigned_flag) str->set(nr); + else + str->set((ulonglong) nr); } else { @@ -207,24 +209,31 @@ void Item_func::fix_num_length_and_dec() max_length=float_length(decimals); } - String *Item_int_func::val_str(String *str) { longlong nr=val_int(); if (null_value) return 0; - else + else if (!unsigned_flag) str->set(nr); + else + str->set((ulonglong) nr); return str; } -/* Change from REAL_RESULT (default) to INT_RESULT if both arguments are integers */ +/* + Change from REAL_RESULT (default) to INT_RESULT if both arguments are + integers +*/ void Item_num_op::find_num_type(void) { if (args[0]->result_type() == INT_RESULT && args[1]->result_type() == INT_RESULT) + { hybrid_type=INT_RESULT; + unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag; + } } String *Item_num_op::val_str(String *str) @@ -234,8 +243,10 @@ String *Item_num_op::val_str(String *str) longlong nr=val_int(); if (null_value) return 0; /* purecov: inspected */ - else + else if (!unsigned_flag) str->set(nr); + else + str->set((ulonglong) nr); } else { @@ -667,8 +678,10 @@ String *Item_func_min_max::val_str(String *str) longlong nr=val_int(); if (null_value) return 0; - else + else if (!unsigned_flag) str->set(nr); + else + str->set((ulonglong) nr); return str; } case REAL_RESULT: @@ -1050,7 +1063,8 @@ udf_handler::~udf_handler() } free_udf(u_d); } - delete [] buffers; + if (buffers) // Because of bug in ecc + delete [] buffers; } @@ -1306,8 +1320,10 @@ String *Item_func_udf_int::val_str(String *str) longlong nr=val_int(); if (null_value) return 0; - else + else if (!unsigned_flag) str->set(nr); + else + str->set((ulonglong) nr); return str; } @@ -1402,19 +1418,16 @@ void item_user_lock_release(ULL *ull) if (mysql_bin_log.is_open()) { THD *thd = current_thd; - int save_errno; char buf[256]; String tmp(buf,sizeof(buf)); tmp.length(0); tmp.append("SELECT release_lock(\""); tmp.append(ull->key,ull->key_length); tmp.append("\")"); - save_errno=thd->net.last_errno; - thd->net.last_errno=0; thd->query_length=tmp.length(); Query_log_event qev(thd,tmp.ptr()); + qev.error_code=0; // this query is always safe to run on slave mysql_bin_log.write(&qev); - thd->net.last_errno=save_errno; } if (--ull->count) pthread_cond_signal(&ull->cond); @@ -1448,6 +1461,80 @@ longlong Item_master_pos_wait::val_int() return event_count; } +#ifdef EXTRA_DEBUG +void debug_sync_point(const char* lock_name, uint lock_timeout) +{ + THD* thd=current_thd; + ULL* ull; + struct timespec abstime; + int lock_name_len,error=0; + lock_name_len=strlen(lock_name); + pthread_mutex_lock(&LOCK_user_locks); + + if (thd->ull) + { + item_user_lock_release(thd->ull); + thd->ull=0; + } + + /* if the lock has not been aquired by some client, we do not want to + create an entry for it, since we immediately release the lock. In + this case, we will not be waiting, but rather, just waste CPU and + memory on the whole deal + */ + if (!(ull= ((ULL*) hash_search(&hash_user_locks,lock_name, + lock_name_len)))) + { + pthread_mutex_unlock(&LOCK_user_locks); + return; + } + ull->count++; + + /* structure is now initialized. Try to get the lock */ + /* Set up control struct to allow others to abort locks */ + thd->proc_info="User lock"; + thd->mysys_var->current_mutex= &LOCK_user_locks; + thd->mysys_var->current_cond= &ull->cond; + +#ifdef HAVE_TIMESPEC_TS_SEC + abstime.ts_sec=time((time_t*) 0)+(time_t) lock_timeout; + abstime.ts_nsec=0; +#else + abstime.tv_sec=time((time_t*) 0)+(time_t) lock_timeout; + abstime.tv_nsec=0; +#endif + + while (!thd->killed && + (error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime)) + != ETIME && error != ETIMEDOUT && ull->locked) ; + if (ull->locked) + { + if (!--ull->count) + delete ull; // Should never happen + } + else + { + ull->locked=1; + ull->thread=thd->real_id; + thd->ull=ull; + } + pthread_mutex_unlock(&LOCK_user_locks); + pthread_mutex_lock(&thd->mysys_var->mutex); + thd->proc_info=0; + thd->mysys_var->current_mutex= 0; + thd->mysys_var->current_cond= 0; + pthread_mutex_unlock(&thd->mysys_var->mutex); + pthread_mutex_lock(&LOCK_user_locks); + if (thd->ull) + { + item_user_lock_release(thd->ull); + thd->ull=0; + } + pthread_mutex_unlock(&LOCK_user_locks); +} + +#endif + /* Get a user level lock. If the thread has an old lock this is first released. Returns 1: Got lock |