summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-08-12 03:33:46 +0300
committerunknown <monty@hundin.mysql.fi>2002-08-12 03:33:46 +0300
commit9b1930152db6ecd30b8cbcc7200af2baf7f82295 (patch)
treee90396228cd90fe22d0c1831170866e47b1602aa /sql/item_cmpfunc.cc
parent6148e5a42f1a6f0ea2a3bd127d2455267d419def (diff)
downloadmariadb-git-9b1930152db6ecd30b8cbcc7200af2baf7f82295.tar.gz
Changed IF(expr, column, NULL) to take type from column
Fixed some windows portability problems and removed some compiler warnings Cleaned up QUOTE() function and fixed bug in \0 and \Z handling. Docs/manual.texi: Changelog Added information about new IF() behaviour. libmysql/libmysql.def: Removed mysql_ssl_clear myisam/mi_dynrec.c: Minor cleanup mysql-test/r/func_str.result: Added more tests for QUOTE mysql-test/t/func_str.test: Added more tests for QUOTE mysys/mf_iocache.c: Removed compiler warnings sql/ha_innodb.cc: Added missing null to generated string. sql/item_cmpfunc.cc: Changed IF(expr, column, NULL) to take type from column sql/item_strfunc.cc: Cleaned up QUOTE() function and fixed bug in \0 and \Z handling. sql/log.cc: Minor cleanup sql/mysql_priv.h: Fixed problem with opt_enable_named_pipe sql/mysqld.cc: Fixed problem with opt_enable_named_pipe Fixed some syntax errors in windows code sql/set_var.cc: Removed compiler warnings sql/slave.cc: Removed compiler warnings sql/sql_show.cc: Removed compiler warnings
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc27
1 files changed, 22 insertions, 5 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 90e8a0e451f..19d64812f34 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -486,6 +486,7 @@ Item_func_ifnull::val_str(String *str)
return res;
}
+
void
Item_func_if::fix_length_and_dec()
{
@@ -494,16 +495,32 @@ Item_func_if::fix_length_and_dec()
decimals=max(args[1]->decimals,args[2]->decimals);
enum Item_result arg1_type=args[1]->result_type();
enum Item_result arg2_type=args[2]->result_type();
- binary=1;
- if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT)
+ bool null1=args[1]->null_value;
+ bool null2=args[2]->null_value;
+
+ if (null1)
+ {
+ cached_result_type= arg2_type;
+ binary= args[1]->binary;
+ }
+ else if (null2)
+ {
+ cached_result_type= arg2_type;
+ binary= args[2]->binary;
+ }
+ else if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT)
{
cached_result_type = STRING_RESULT;
binary=args[1]->binary | args[2]->binary;
}
- else if (arg1_type == REAL_RESULT || arg2_type == REAL_RESULT)
- cached_result_type = REAL_RESULT;
else
- cached_result_type=arg1_type; // Should be INT_RESULT
+ {
+ binary=1; // Number
+ if (arg1_type == REAL_RESULT || arg2_type == REAL_RESULT)
+ cached_result_type = REAL_RESULT;
+ else
+ cached_result_type=arg1_type; // Should be INT_RESULT
+ }
}