summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/item_cmpfunc.cc39
-rw-r--r--sql/item_cmpfunc.h4
-rw-r--r--sql/item_strfunc.cc10
-rw-r--r--sql/mysqld.cc6
5 files changed, 50 insertions, 11 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 24bf16b3604..930bfa2ed28 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -615,7 +615,7 @@ void handler::print_error(int error, myf errflag)
uint handler::get_dup_key(int error)
{
- DBUG_ENTER("key_error");
+ DBUG_ENTER("get_dup_key");
table->file->errkey = (uint) -1;
if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOUND_DUPP_UNIQUE)
info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK);
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index a2686fd43d9..380ded8943e 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -170,15 +170,44 @@ longlong Item_func_eq::val_int()
/* Same as Item_func_eq, but NULL = NULL */
+void Item_func_equal::fix_length_and_dec()
+{
+ Item_bool_func2::fix_length_and_dec();
+ result_type=item_cmp_type(args[0]->result_type(),args[1]->result_type());
+ maybe_null=null_value=0;
+}
+
longlong Item_func_equal::val_int()
{
- int value=(this->*cmp_func)();
- if (null_value)
+ switch (result_type) {
+ case STRING_RESULT:
{
- null_value=0;
- return (args[0]->null_value && args[1]->null_value) ? 1 : 0;
+ String *res1,*res2;
+ res1=args[0]->val_str(&tmp_value1);
+ res2=args[1]->val_str(&tmp_value2);
+ if (!res1 || !res2)
+ return test(res1 == res2);
+ return (binary ? test(stringcmp(res1,res2) == 0) :
+ test(sortcmp(res1,res2) == 0));
+ }
+ case REAL_RESULT:
+ {
+ double val1=args[0]->val();
+ double val2=args[1]->val();
+ if (args[0]->null_value || args[1]->null_value)
+ return test(args[0]->null_value && args[1]->null_value);
+ return test(val1 == val2);
+ }
+ case INT_RESULT:
+ {
+ longlong val1=args[0]->val_int();
+ longlong val2=args[1]->val_int();
+ if (args[0]->null_value || args[1]->null_value)
+ return test(args[0]->null_value && args[1]->null_value);
+ return test(val1 == val2);
+ }
}
- return value == 0;
+ return 0; // Impossible
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 591d0f6a2f7..790d4f3571f 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -70,11 +70,11 @@ public:
class Item_func_equal :public Item_bool_func2
{
+ Item_result result_type;
public:
Item_func_equal(Item *a,Item *b) :Item_bool_func2(a,b) { };
longlong val_int();
- void fix_length_and_dec()
- { Item_bool_func2::fix_length_and_dec() ; maybe_null=0; }
+ void fix_length_and_dec();
enum Functype functype() const { return EQUAL_FUNC; }
enum Functype rev_functype() const { return EQUAL_FUNC; }
cond_result eq_cmp_result() const { return COND_TRUE; }
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 39bbdcaff1f..103d82f36aa 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1465,7 +1465,10 @@ String *Item_func_rpad::val_str(String *str)
goto err;
null_value=0;
if (count <= (int32) (res_length=res->length()))
- return (res); // String to pad is big enough
+ { // String to pad is big enough
+ res->length(count); // Shorten result if longer
+ return (res);
+ }
length_pad= rpad->length();
if ((ulong) count > max_allowed_packet || args[2]->null_value || !length_pad)
goto err;
@@ -1521,7 +1524,10 @@ String *Item_func_lpad::val_str(String *str)
goto err;
null_value=0;
if (count <= (res_length=res->length()))
- return (res); // String to pad is big enough
+ { // String to pad is big enough
+ res->length(count); // Shorten result if longer
+ return (res);
+ }
length_pad= lpad->length();
if (count > max_allowed_packet || args[2]->null_value || !length_pad)
goto err;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 8ebda66ffdb..93a696bac13 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1042,7 +1042,11 @@ static void init_signals(void)
static sig_handler write_core(int sig)
{
- fprintf(stderr,"Got signal %s in thread %d\n",sys_siglist[sig],getpid());
+ fprintf(stderr,"\
+mysqld got signal %s in thread %d; Writing core file: %s\n\
+The manual section 'Debugging a MySQL server' tells you how to use a \n\
+debugger on the core file to produce a backtrace that may help you find out\n\
+why mysqld died\n",sys_siglist[sig],getpid(),mysql_home);
signal(sig, SIG_DFL);
if (fork() != 0) exit(1); // Abort main program
// Core will be written at exit