summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@gleb.loc>2007-06-16 22:40:25 +0500
committerunknown <gshchepa/uchum@gleb.loc>2007-06-16 22:40:25 +0500
commit200c69e3e6dd7a59796f1fd1ac78f90ec402a6c3 (patch)
tree210b1122be877ed2b2834f7ee6aeb6fd33668092
parentf6a7490c387c5752df6b10007efe19f993f64e43 (diff)
parent67988a75fc3030462d43c9625caa924bfc8c443d (diff)
downloadmariadb-git-200c69e3e6dd7a59796f1fd1ac78f90ec402a6c3.tar.gz
Merge gleb.loc:/home/uchum/work/bk/5.0-opt
into gleb.loc:/home/uchum/work/bk/5.1-opt mysql-test/r/func_str.result: Auto merged mysql-test/t/func_str.test: Auto merged mysql-test/r/bigint.result: Merge with 5.0-opt. mysql-test/t/bigint.test: Merge with 5.0-opt. sql/item_func.cc: Merge with 5.0-opt.
-rw-r--r--mysql-test/r/bigint.result26
-rw-r--r--mysql-test/r/func_str.result76
-rw-r--r--mysql-test/t/bigint.test16
-rw-r--r--mysql-test/t/func_str.test33
-rw-r--r--sql/item_func.cc23
5 files changed, 164 insertions, 10 deletions
diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result
index 8d831ba800b..0d6cf8e7d30 100644
--- a/mysql-test/r/bigint.result
+++ b/mysql-test/r/bigint.result
@@ -362,6 +362,32 @@ cast(-19999999999999999999 as signed)
-9223372036854775808
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
+select -9223372036854775808;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def -9223372036854775808 8 20 20 N 32897 0 63
+-9223372036854775808
+-9223372036854775808
+select -(9223372036854775808);
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def -(9223372036854775808) 8 20 20 N 32897 0 63
+-(9223372036854775808)
+-9223372036854775808
+select -((9223372036854775808));
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def -((9223372036854775808)) 8 20 20 N 32897 0 63
+-((9223372036854775808))
+-9223372036854775808
+select -(-(9223372036854775808));
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def -(-(9223372036854775808)) 246 21 19 N 129 0 63
+-(-(9223372036854775808))
+9223372036854775808
+select --9223372036854775808, ---9223372036854775808, ----9223372036854775808;
+--9223372036854775808 ---9223372036854775808 ----9223372036854775808
+9223372036854775808 -9223372036854775808 9223372036854775808
+select -(-9223372036854775808), -(-(-9223372036854775808));
+-(-9223372036854775808) -(-(-9223372036854775808))
+9223372036854775808 -9223372036854775808
create table t1 select -9223372036854775808 bi;
describe t1;
Field Type Null Key Default Extra
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 9253f28d038..2622e070587 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -2394,4 +2394,80 @@ C
2707236321
DROP TABLE t1, t2;
DROP VIEW v1;
+SELECT LOCATE('foo', NULL) FROM DUAL;
+LOCATE('foo', NULL)
+NULL
+SELECT LOCATE(NULL, 'o') FROM DUAL;
+LOCATE(NULL, 'o')
+NULL
+SELECT LOCATE(NULL, NULL) FROM DUAL;
+LOCATE(NULL, NULL)
+NULL
+SELECT LOCATE('foo', NULL) IS NULL FROM DUAL;
+LOCATE('foo', NULL) IS NULL
+1
+SELECT LOCATE(NULL, 'o') IS NULL FROM DUAL;
+LOCATE(NULL, 'o') IS NULL
+1
+SELECT LOCATE(NULL, NULL) IS NULL FROM DUAL;
+LOCATE(NULL, NULL) IS NULL
+1
+SELECT ISNULL(LOCATE('foo', NULL)) FROM DUAL;
+ISNULL(LOCATE('foo', NULL))
+1
+SELECT ISNULL(LOCATE(NULL, 'o')) FROM DUAL;
+ISNULL(LOCATE(NULL, 'o'))
+1
+SELECT ISNULL(LOCATE(NULL, NULL)) FROM DUAL;
+ISNULL(LOCATE(NULL, NULL))
+1
+SELECT LOCATE('foo', NULL) <=> NULL FROM DUAL;
+LOCATE('foo', NULL) <=> NULL
+1
+SELECT LOCATE(NULL, 'o') <=> NULL FROM DUAL;
+LOCATE(NULL, 'o') <=> NULL
+1
+SELECT LOCATE(NULL, NULL) <=> NULL FROM DUAL;
+LOCATE(NULL, NULL) <=> NULL
+1
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a varchar(10), p varchar(10));
+INSERT INTO t1 VALUES (1, 'foo', 'o');
+INSERT INTO t1 VALUES (2, 'foo', NULL);
+INSERT INTO t1 VALUES (3, NULL, 'o');
+INSERT INTO t1 VALUES (4, NULL, NULL);
+SELECT id, LOCATE(a,p) FROM t1;
+id LOCATE(a,p)
+1 0
+2 NULL
+3 NULL
+4 NULL
+SELECT id, LOCATE(a,p) IS NULL FROM t1;
+id LOCATE(a,p) IS NULL
+1 0
+2 1
+3 1
+4 1
+SELECT id, ISNULL(LOCATE(a,p)) FROM t1;
+id ISNULL(LOCATE(a,p))
+1 0
+2 1
+3 1
+4 1
+SELECT id, LOCATE(a,p) <=> NULL FROM t1;
+id LOCATE(a,p) <=> NULL
+1 0
+2 1
+3 1
+4 1
+SELECT id FROM t1 WHERE LOCATE(a,p) IS NULL;
+id
+2
+3
+4
+SELECT id FROM t1 WHERE LOCATE(a,p) <=> NULL;
+id
+2
+3
+4
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test
index 52f34e58e97..9b4fc3f39b0 100644
--- a/mysql-test/t/bigint.test
+++ b/mysql-test/t/bigint.test
@@ -295,6 +295,22 @@ drop table t1;
select cast(19999999999999999999 as signed);
select cast(-19999999999999999999 as signed);
+#
+# Bug #28625: -9223372036854775808 doesn't fit in BIGINT.
+#
+
+# PS protocol gives different metadata for `Max length' column
+--disable_ps_protocol
+--enable_metadata
+select -9223372036854775808;
+select -(9223372036854775808);
+select -((9223372036854775808));
+select -(-(9223372036854775808));
+--disable_metadata
+--endble_ps_protocol
+select --9223372036854775808, ---9223372036854775808, ----9223372036854775808;
+select -(-9223372036854775808), -(-(-9223372036854775808));
+
# Bug #28005 Partitions: can't use -9223372036854775808
create table t1 select -9223372036854775808 bi;
describe t1;
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index ddb3d2baf7f..9148b757b29 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -1183,4 +1183,37 @@ SELECT * FROM (SELECT * FROM v1) x;
DROP TABLE t1, t2;
DROP VIEW v1;
+#
+# Bug #27932: LOCATE with argument evaluated to NULL
+#
+
+SELECT LOCATE('foo', NULL) FROM DUAL;
+SELECT LOCATE(NULL, 'o') FROM DUAL;
+SELECT LOCATE(NULL, NULL) FROM DUAL;
+SELECT LOCATE('foo', NULL) IS NULL FROM DUAL;
+SELECT LOCATE(NULL, 'o') IS NULL FROM DUAL;
+SELECT LOCATE(NULL, NULL) IS NULL FROM DUAL;
+SELECT ISNULL(LOCATE('foo', NULL)) FROM DUAL;
+SELECT ISNULL(LOCATE(NULL, 'o')) FROM DUAL;
+SELECT ISNULL(LOCATE(NULL, NULL)) FROM DUAL;
+SELECT LOCATE('foo', NULL) <=> NULL FROM DUAL;
+SELECT LOCATE(NULL, 'o') <=> NULL FROM DUAL;
+SELECT LOCATE(NULL, NULL) <=> NULL FROM DUAL;
+
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a varchar(10), p varchar(10));
+
+INSERT INTO t1 VALUES (1, 'foo', 'o');
+INSERT INTO t1 VALUES (2, 'foo', NULL);
+INSERT INTO t1 VALUES (3, NULL, 'o');
+INSERT INTO t1 VALUES (4, NULL, NULL);
+
+SELECT id, LOCATE(a,p) FROM t1;
+SELECT id, LOCATE(a,p) IS NULL FROM t1;
+SELECT id, ISNULL(LOCATE(a,p)) FROM t1;
+SELECT id, LOCATE(a,p) <=> NULL FROM t1;
+SELECT id FROM t1 WHERE LOCATE(a,p) IS NULL;
+SELECT id FROM t1 WHERE LOCATE(a,p) <=> NULL;
+
+DROP TABLE t1;
+
--echo End of 5.0 tests
diff --git a/sql/item_func.cc b/sql/item_func.cc
index fb2f361f676..f14091b4592 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1520,16 +1520,20 @@ void Item_func_neg::fix_length_and_dec()
Use val() to get value as arg_type doesn't mean that item is
Item_int or Item_real due to existence of Item_param.
*/
- if (hybrid_type == INT_RESULT &&
- args[0]->type() == INT_ITEM &&
- ((ulonglong) args[0]->val_int() > (ulonglong) LONGLONG_MIN))
+ if (hybrid_type == INT_RESULT && args[0]->const_item())
{
- /*
- Ensure that result is converted to DECIMAL, as longlong can't hold
- the negated number
- */
- hybrid_type= DECIMAL_RESULT;
- DBUG_PRINT("info", ("Type changed: DECIMAL_RESULT"));
+ longlong val= args[0]->val_int();
+ if ((ulonglong) val >= (ulonglong) LONGLONG_MIN &&
+ ((ulonglong) val != (ulonglong) LONGLONG_MIN ||
+ args[0]->type() != INT_ITEM))
+ {
+ /*
+ Ensure that result is converted to DECIMAL, as longlong can't hold
+ the negated number
+ */
+ hybrid_type= DECIMAL_RESULT;
+ DBUG_PRINT("info", ("Type changed: DECIMAL_RESULT"));
+ }
}
unsigned_flag= 0;
DBUG_VOID_RETURN;
@@ -2499,7 +2503,6 @@ longlong Item_func_coercibility::val_int()
void Item_func_locate::fix_length_and_dec()
{
- maybe_null= 0;
max_length= MY_INT32_NUM_DECIMAL_DIGITS;
agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1);
}