summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@magare.gmz>2007-06-12 16:34:54 +0300
committerunknown <gkodinov/kgeorge@magare.gmz>2007-06-12 16:34:54 +0300
commite53dfc6df42d83c45ec5121c98dcbcff7960beab (patch)
tree49f65594ef7867ace676423b3635cec9297e4936 /sql/item_func.cc
parent023f3dd0df68b04f5bca6e0a15f1f4d426731383 (diff)
parent119412f8d0cc364678e8e3b3c36c42e6fea69e3d (diff)
downloadmariadb-git-e53dfc6df42d83c45ec5121c98dcbcff7960beab.tar.gz
Merge bk-internal:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/work/merge-5.1-opt mysql-test/r/insert_update.result: Auto merged mysql-test/r/trigger.result: Auto merged mysql-test/t/insert_update.test: Auto merged mysql-test/t/trigger.test: Auto merged sql/item_strfunc.cc: Auto merged sql/mysqld.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_show.cc: Auto merged sql/item_func.cc: merge of 5.0-opt -> 5.1-opt sql/sql_insert.cc: merge of 5.0-opt -> 5.1-opt sql/structs.h: merge of 5.0-opt -> 5.1-opt tests/mysql_client_test.c: merge of 5.0-opt -> 5.1-opt
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc34
1 files changed, 26 insertions, 8 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index b0346cc5224..606bb5fd561 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3439,6 +3439,7 @@ longlong Item_func_get_lock::val_int()
THD *thd=current_thd;
User_level_lock *ull;
int error;
+ DBUG_ENTER("Item_func_get_lock::val_int");
/*
In slave thread no need to get locks, everything is serialized. Anyway
@@ -3448,7 +3449,7 @@ longlong Item_func_get_lock::val_int()
it's not guaranteed to be same as on master.
*/
if (thd->slave_thread)
- return 1;
+ DBUG_RETURN(1);
pthread_mutex_lock(&LOCK_user_locks);
@@ -3456,8 +3457,10 @@ longlong Item_func_get_lock::val_int()
{
pthread_mutex_unlock(&LOCK_user_locks);
null_value=1;
- return 0;
+ DBUG_RETURN(0);
}
+ DBUG_PRINT("info", ("lock %.*s, thd=%ld", res->length(), res->ptr(),
+ (long) thd->real_id));
null_value=0;
if (thd->ull)
@@ -3477,14 +3480,16 @@ longlong Item_func_get_lock::val_int()
delete ull;
pthread_mutex_unlock(&LOCK_user_locks);
null_value=1; // Probably out of memory
- return 0;
+ DBUG_RETURN(0);
}
ull->set_thread(thd);
thd->ull=ull;
pthread_mutex_unlock(&LOCK_user_locks);
- return 1; // Got new lock
+ DBUG_PRINT("info", ("made new lock"));
+ DBUG_RETURN(1); // Got new lock
}
ull->count++;
+ DBUG_PRINT("info", ("ull->count=%d", ull->count));
/*
Structure is now initialized. Try to get the lock.
@@ -3498,9 +3503,13 @@ longlong Item_func_get_lock::val_int()
error= 0;
while (ull->locked && !thd->killed)
{
+ DBUG_PRINT("info", ("waiting on lock"));
error= pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime);
if (error == ETIMEDOUT || error == ETIME)
+ {
+ DBUG_PRINT("info", ("lock wait timeout"));
break;
+ }
error= 0;
}
@@ -3524,6 +3533,7 @@ longlong Item_func_get_lock::val_int()
ull->thread_id= thd->thread_id;
thd->ull=ull;
error=0;
+ DBUG_PRINT("info", ("got the lock"));
}
pthread_mutex_unlock(&LOCK_user_locks);
@@ -3533,7 +3543,7 @@ longlong Item_func_get_lock::val_int()
thd->mysys_var->current_cond= 0;
pthread_mutex_unlock(&thd->mysys_var->mutex);
- return !error ? 1 : 0;
+ DBUG_RETURN(!error ? 1 : 0);
}
@@ -3551,11 +3561,14 @@ longlong Item_func_release_lock::val_int()
String *res=args[0]->val_str(&value);
User_level_lock *ull;
longlong result;
+ THD *thd=current_thd;
+ DBUG_ENTER("Item_func_release_lock::val_int");
if (!res || !res->length())
{
null_value=1;
- return 0;
+ DBUG_RETURN(0);
}
+ DBUG_PRINT("info", ("lock %.*s", res->length(), res->ptr()));
null_value=0;
result=0;
@@ -3568,15 +3581,20 @@ longlong Item_func_release_lock::val_int()
}
else
{
+ DBUG_PRINT("info", ("ull->locked=%d ull->thread=%ld thd=%ld",
+ (int) ull->locked,
+ (long)ull->thread,
+ (long)thd->real_id));
if (ull->locked && current_thd->thread_id == ull->thread_id)
{
+ DBUG_PRINT("info", ("release lock"));
result=1; // Release is ok
item_user_lock_release(ull);
- current_thd->ull=0;
+ thd->ull=0;
}
}
pthread_mutex_unlock(&LOCK_user_locks);
- return result;
+ DBUG_RETURN(result);
}