summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/mysql-test-run.sh10
-rw-r--r--mysql-test/r/bigint.result192
-rw-r--r--mysql-test/r/range.result4
-rw-r--r--mysql-test/r/strict.result10
-rw-r--r--mysql-test/r/type_ranges.result6
-rw-r--r--mysql-test/t/bigint.test153
-rw-r--r--mysql-test/t/innodb.test3
-rw-r--r--mysql-test/t/mysqldump.test2
-rw-r--r--mysql-test/t/range.test4
-rw-r--r--mysql-test/t/strict.test4
-rw-r--r--sql-common/client.c11
-rw-r--r--sql/field.cc211
-rw-r--r--sql/field.h55
-rw-r--r--sql/field_conv.cc7
-rw-r--r--sql/ha_ndbcluster.cc6
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/item.cc14
-rw-r--r--sql/item_sum.cc4
-rw-r--r--sql/sp.cc2
-rw-r--r--sql/sql_acl.cc19
-rw-r--r--sql/sql_help.cc4
-rw-r--r--sql/sql_show.cc34
-rw-r--r--sql/sql_table.cc1
-rw-r--r--sql/sql_udf.cc4
-rw-r--r--sql/tztime.cc6
-rw-r--r--sql/unireg.cc2
26 files changed, 586 insertions, 184 deletions
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index d9460dcdd72..aadf9080348 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -235,6 +235,7 @@ DO_GDB=""
MANUAL_GDB=""
DO_DDD=""
DO_CLIENT_GDB=""
+DO_VALGRIND_MYSQL_TEST=""
SLEEP_TIME_AFTER_RESTART=1
SLEEP_TIME_FOR_DELETE=10
SLEEP_TIME_FOR_FIRST_MASTER=400 # Enough time to create innodb tables
@@ -432,6 +433,9 @@ while test $# -gt 0; do
TMP=`$ECHO "$1" | $SED -e "s;--valgrind-options=;;"`
VALGRIND="$VALGRIND $TMP"
;;
+ --valgrind-mysqltest)
+ DO_VALGRIND_MYSQL_TEST=1
+ ;;
--skip-ndbcluster | --skip-ndb)
USE_NDBCLUSTER=""
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-ndbcluster"
@@ -666,7 +670,7 @@ else
MYSQL_CLIENT_TEST="$CLIENT_BINDIR/mysql_client_test_embedded"
fi
else
- MYSQL_TEST="$CLIENT_BINDIR/mysqltest"
+ MYSQL_TEST="$VALGRIND_MYSQLTEST $CLIENT_BINDIR/mysqltest"
MYSQL_CLIENT_TEST="$CLIENT_BINDIR/mysql_client_test"
fi
fi
@@ -681,6 +685,10 @@ then
SLAVE_MYSQLD=$MYSQLD
fi
+if [ x$DO_VALGRIND_MYSQL_TEST = x1 ] ; then
+ MYSQL_TEST="$VALGRIND $MYSQL_TEST"
+fi
+
# If we should run all tests cases, we will use a local server for that
if [ -z "$1" ]
diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result
index 1b5619eb18d..ca9a2662f94 100644
--- a/mysql-test/r/bigint.result
+++ b/mysql-test/r/bigint.result
@@ -46,6 +46,14 @@ a
drop table t1;
create table t1 ( a int not null default 1, big bigint );
insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(18446744073709551615);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'big' at row 4
+select * from t1;
+a big
+1 -1
+1 12345678901234567
+1 9223372036854775807
+1 9223372036854775807
select min(big),max(big),max(big)-1 from t1;
min(big) max(big) max(big)-1
-1 9223372036854775807 9223372036854775806
@@ -53,26 +61,51 @@ select min(big),max(big),max(big)-1 from t1 group by a;
min(big) max(big) max(big)-1
-1 9223372036854775807 9223372036854775806
alter table t1 modify big bigint unsigned not null;
+Warnings:
+Warning 1264 Out of range value adjusted for column 'big' at row 1
+select min(big),max(big),max(big)-1 from t1;
+min(big) max(big) max(big)-1
+0 9223372036854775807 9223372036854775806
+select min(big),max(big),max(big)-1 from t1 group by a;
+min(big) max(big) max(big)-1
+0 9223372036854775807 9223372036854775806
+insert into t1 (big) values (18446744073709551615);
+select * from t1;
+a big
+1 0
+1 12345678901234567
+1 9223372036854775807
+1 9223372036854775807
+1 18446744073709551615
select min(big),max(big),max(big)-1 from t1;
min(big) max(big) max(big)-1
-12345678901234567 18446744073709551615 18446744073709551614
+0 18446744073709551615 18446744073709551614
select min(big),max(big),max(big)-1 from t1 group by a;
min(big) max(big) max(big)-1
-12345678901234567 18446744073709551615 18446744073709551614
+0 18446744073709551615 18446744073709551614
alter table t1 add key (big);
select min(big),max(big),max(big)-1 from t1;
min(big) max(big) max(big)-1
-12345678901234567 18446744073709551615 18446744073709551614
+0 18446744073709551615 18446744073709551614
select min(big),max(big),max(big)-1 from t1 group by a;
min(big) max(big) max(big)-1
-12345678901234567 18446744073709551615 18446744073709551614
+0 18446744073709551615 18446744073709551614
alter table t1 modify big bigint not null;
+Warnings:
+Warning 1264 Out of range value adjusted for column 'big' at row 5
+select * from t1;
+a big
+1 0
+1 12345678901234567
+1 9223372036854775807
+1 9223372036854775807
+1 9223372036854775807
select min(big),max(big),max(big)-1 from t1;
min(big) max(big) max(big)-1
--1 9223372036854775807 9223372036854775806
+0 9223372036854775807 9223372036854775806
select min(big),max(big),max(big)-1 from t1 group by a;
min(big) max(big) max(big)-1
--1 9223372036854775807 9223372036854775806
+0 9223372036854775807 9223372036854775806
drop table t1;
create table t1 (id bigint auto_increment primary key, a int) auto_increment=9999999999;
insert into t1 values (null,1);
@@ -89,7 +122,7 @@ insert into t1 values (10000000000000000000.0);
insert into t1 values ('10000000000000000000');
select * from t1;
quantity
--8446744073709551616
+10000000000000000000
10000000000000000000
10000000000000000000
drop table t1;
@@ -154,3 +187,148 @@ select * from t1;
a
9223372036854775809
drop table t1;
+DROP DATABASE IF EXISTS `scott`;
+Warnings:
+Note 1008 Can't drop database 'scott'; database doesn't exist
+create table t1 (a char(100), b varchar(100), c text, d blob);
+insert into t1 values(
+18446744073709551615,18446744073709551615,
+18446744073709551615, 18446744073709551615
+);
+insert into t1 values (-1 | 0,-1 | 0,-1 | 0 ,-1 | 0);
+select * from t1;
+a b c d
+18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+drop table t1;
+create table t1 ( quantity decimal(2) unsigned);
+insert into t1 values (500), (-500), (~0), (-1);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'quantity' at row 1
+Warning 1264 Out of range value adjusted for column 'quantity' at row 2
+Warning 1264 Out of range value adjusted for column 'quantity' at row 3
+Warning 1264 Out of range value adjusted for column 'quantity' at row 4
+select * from t1;
+quantity
+99
+0
+99
+0
+drop table t1;
+CREATE TABLE t1 (
+`col1` INT(1) NULL,
+`col2` INT(2) NULL,
+`col3` INT(3) NULL,
+`col4` INT(4) NULL,
+`col5` INT(5) NULL,
+`col6` INT(6) NULL,
+`col7` INT(7) NULL,
+`col8` INT(8) NULL,
+`col9` INT(9) NULL,
+`col10` BIGINT(10) NULL,
+`col11` BIGINT(11) NULL,
+`col12` BIGINT(12) NULL,
+`col13` BIGINT(13) NULL,
+`col14` BIGINT(14) NULL,
+`col15` BIGINT(15) NULL,
+`col16` BIGINT(16) NULL,
+`col17` BIGINT(17) NULL,
+`col18` BIGINT(18) NULL,
+`col19` DECIMAL(19, 0) NULL,
+`col20` DECIMAL(20, 0) NULL,
+`col21` DECIMAL(21, 0) NULL,
+`col22` DECIMAL(22, 0) NULL,
+`col23` DECIMAL(23, 0) NULL,
+`col24` DECIMAL(24, 0) NULL,
+`col25` DECIMAL(25, 0) NULL,
+`col26` DECIMAL(26, 0) NULL,
+`col27` DECIMAL(27, 0) NULL,
+`col28` DECIMAL(28, 0) NULL,
+`col29` DECIMAL(29, 0) NULL,
+`col30` DECIMAL(30, 0) NULL,
+`col31` DECIMAL(31, 0) NULL,
+`col32` DECIMAL(32, 0) NULL,
+`col33` DECIMAL(33, 0) NULL,
+`col34` DECIMAL(34, 0) NULL,
+`col35` DECIMAL(35, 0) NULL,
+`col36` DECIMAL(36, 0) NULL,
+`col37` DECIMAL(37, 0) NULL,
+`col38` DECIMAL(38, 0) NULL,
+`fix1` DECIMAL(38, 1) NULL,
+`fix2` DECIMAL(38, 2) NULL,
+`fix3` DECIMAL(38, 3) NULL,
+`fix4` DECIMAL(38, 4) NULL,
+`fix5` DECIMAL(38, 5) NULL,
+`fix6` DECIMAL(38, 6) NULL,
+`fix7` DECIMAL(38, 7) NULL,
+`fix8` DECIMAL(38, 8) NULL,
+`fix9` DECIMAL(38, 9) NULL,
+`fix10` DECIMAL(38, 10) NULL,
+`fix11` DECIMAL(38, 11) NULL,
+`fix12` DECIMAL(38, 12) NULL,
+`fix13` DECIMAL(38, 13) NULL,
+`fix14` DECIMAL(38, 14) NULL,
+`fix15` DECIMAL(38, 15) NULL,
+`fix16` DECIMAL(38, 16) NULL,
+`fix17` DECIMAL(38, 17) NULL,
+`fix18` DECIMAL(38, 18) NULL,
+`fix19` DECIMAL(38, 19) NULL,
+`fix20` DECIMAL(38, 20) NULL,
+`fix21` DECIMAL(38, 21) NULL,
+`fix22` DECIMAL(38, 22) NULL,
+`fix23` DECIMAL(38, 23) NULL,
+`fix24` DECIMAL(38, 24) NULL,
+`fix25` DECIMAL(38, 25) NULL,
+`fix26` DECIMAL(38, 26) NULL,
+`fix27` DECIMAL(38, 27) NULL,
+`fix28` DECIMAL(38, 28) NULL,
+`fix29` DECIMAL(38, 29) NULL,
+`fix30` DECIMAL(38, 30) NULL
+);
+INSERT INTO t1(`col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`, `col19`, `col20`, `col21`, `col22`, `col23`, `col24`, `col25`, `col26`, `col27`, `col28`, `col29`, `col30`, `col31`, `col32`, `col33`, `col34`, `col35`, `col36`, `col37`, `col38`, `fix1`, `fix2`, `fix3`, `fix4`, `fix5`, `fix6`, `fix7`, `fix8`, `fix9`, `fix10`, `fix11`, `fix12`, `fix13`, `fix14`, `fix15`, `fix16`, `fix17`, `fix18`, `fix19`, `fix20`, `fix21`, `fix22`, `fix23`, `fix24`, `fix25`, `fix26`, `fix27`, `fix28`, `fix29`, `fix30`)
+VALUES (9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999,
+9999999999, 99999999999, 999999999999, 9999999999999, 99999999999999,
+999999999999999, 9999999999999999, 99999999999999999, 999999999999999999,
+9999999999999999999, 99999999999999999999, 999999999999999999999,
+9999999999999999999999, 99999999999999999999999, 999999999999999999999999,
+9999999999999999999999999, 99999999999999999999999999,
+999999999999999999999999999, 9999999999999999999999999999,
+99999999999999999999999999999, 999999999999999999999999999999,
+9999999999999999999999999999999, 99999999999999999999999999999999,
+999999999999999999999999999999999, 9999999999999999999999999999999999,
+99999999999999999999999999999999999, 999999999999999999999999999999999999,
+9999999999999999999999999999999999999, 99999999999999999999999999999999999999,
+9999999999999999999999999999999999999.9,
+999999999999999999999999999999999999.99,
+99999999999999999999999999999999999.999,
+9999999999999999999999999999999999.9999,
+999999999999999999999999999999999.99999,
+99999999999999999999999999999999.999999,
+9999999999999999999999999999999.9999999,
+999999999999999999999999999999.99999999,
+99999999999999999999999999999.999999999,
+9999999999999999999999999999.9999999999,
+999999999999999999999999999.99999999999,
+99999999999999999999999999.999999999999,
+9999999999999999999999999.9999999999999,
+999999999999999999999999.99999999999999,
+99999999999999999999999.999999999999999,
+9999999999999999999999.9999999999999999,
+999999999999999999999.99999999999999999,
+99999999999999999999.999999999999999999,
+9999999999999999999.9999999999999999999,
+999999999999999999.99999999999999999999,
+99999999999999999.999999999999999999999,
+9999999999999999.9999999999999999999999,
+999999999999999.99999999999999999999999,
+99999999999999.999999999999999999999999,
+9999999999999.9999999999999999999999999,
+999999999999.99999999999999999999999999,
+99999999999.999999999999999999999999999,
+9999999999.9999999999999999999999999999,
+999999999.99999999999999999999999999999,
+99999999.999999999999999999999999999999);
+SELECT * FROM t1;
+col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 col13 col14 col15 col16 col17 col18 col19 col20 col21 col22 col23 col24 col25 col26 col27 col28 col29 col30 col31 col32 col33 col34 col35 col36 col37 col38 fix1 fix2 fix3 fix4 fix5 fix6 fix7 fix8 fix9 fix10 fix11 fix12 fix13 fix14 fix15 fix16 fix17 fix18 fix19 fix20 fix21 fix22 fix23 fix24 fix25 fix26 fix27 fix28 fix29 fix30
+9 99 999 9999 99999 999999 9999999 99999999 999999999 9999999999 99999999999 999999999999 9999999999999 99999999999999 999999999999999 9999999999999999 99999999999999999 999999999999999999 9999999999999999999 99999999999999999999 999999999999999999999 9999999999999999999999 99999999999999999999999 999999999999999999999999 9999999999999999999999999 99999999999999999999999999 999999999999999999999999999 9999999999999999999999999999 99999999999999999999999999999 999999999999999999999999999999 9999999999999999999999999999999 99999999999999999999999999999999 999999999999999999999999999999999 9999999999999999999999999999999999 99999999999999999999999999999999999 999999999999999999999999999999999999 9999999999999999999999999999999999999 99999999999999999999999999999999999999 9999999999999999999999999999999999999.9 999999999999999999999999999999999999.99 99999999999999999999999999999999999.999 9999999999999999999999999999999999.9999 999999999999999999999999999999999.99999 99999999999999999999999999999999.999999 9999999999999999999999999999999.9999999 999999999999999999999999999999.99999999 99999999999999999999999999999.999999999 9999999999999999999999999999.9999999999 999999999999999999999999999.99999999999 99999999999999999999999999.999999999999 9999999999999999999999999.9999999999999 999999999999999999999999.99999999999999 99999999999999999999999.999999999999999 9999999999999999999999.9999999999999999 999999999999999999999.99999999999999999 99999999999999999999.999999999999999999 9999999999999999999.9999999999999999999 999999999999999999.99999999999999999999 99999999999999999.999999999999999999999 9999999999999999.9999999999999999999999 999999999999999.99999999999999999999999 99999999999999.999999999999999999999999 9999999999999.9999999999999999999999999 999999999999.99999999999999999999999999 99999999999.999999999999999999999999999 9999999999.9999999999999999999999999999 999999999.99999999999999999999999999999 99999999.999999999999999999999999999999
+DROP TABLE t1;
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index e8e30b3653a..f490c2e1383 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -521,8 +521,8 @@ select count(*) from t1 where x = 18446744073709551601;
count(*)
1
create table t2 (x bigint not null);
-insert into t2(x) values (0xfffffffffffffff0);
-insert into t2(x) values (0xfffffffffffffff1);
+insert into t2(x) values (cast(0xfffffffffffffff0+0 as signed));
+insert into t2(x) values (cast(0xfffffffffffffff1+0 as signed));
select * from t2;
x
-16
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index 6299e8dcc88..2b1a47ed337 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -667,7 +667,9 @@ INSERT INTO t1 VALUES(-9223372036854774000.0,0.0),(9223372036854775700.0,1844674
INSERT INTO t1 (col1) VALUES(-9223372036854775809);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(9223372036854775808);
+ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 (col2) VALUES(-1);
+ERROR 22003: Out of range value adjusted for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(18446744073709551616);
ERROR 22003: Out of range value adjusted for column 'col2' at row 1
INSERT INTO t1 (col1) VALUES('-9223372036854775809');
@@ -706,6 +708,8 @@ Error 1365 Division by 0
INSERT IGNORE INTO t1 VALUES(-9223372036854775809,-1),(9223372036854775808,18446744073709551616);
Warnings:
Warning 1264 Out of range value adjusted for column 'col1' at row 1
+Warning 1264 Out of range value adjusted for column 'col2' at row 1
+Warning 1264 Out of range value adjusted for column 'col1' at row 2
Warning 1264 Out of range value adjusted for column 'col2' at row 2
INSERT IGNORE INTO t1 VALUES('-9223372036854775809','-1'),('9223372036854775808','18446744073709551616');
Warnings:
@@ -729,12 +733,10 @@ col1 col2
9223372036854775807 18446744073709551615
-9223372036854774000 0
9223372036854775700 1844674407370954000
--9223372036854775808 NULL
-NULL 18446744073709551615
2 NULL
NULL NULL
--9223372036854775808 18446744073709551615
--9223372036854775808 18446744073709551615
+-9223372036854775808 0
+9223372036854775807 18446744073709551615
-9223372036854775808 0
9223372036854775807 18446744073709551615
-9223372036854775808 0
diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result
index 1342603f755..ff07dcca106 100644
--- a/mysql-test/r/type_ranges.result
+++ b/mysql-test/r/type_ranges.result
@@ -95,6 +95,7 @@ Warning 1264 Out of range value adjusted for column 'utiny' at row 1
Warning 1264 Out of range value adjusted for column 'ushort' at row 1
Warning 1264 Out of range value adjusted for column 'umedium' at row 1
Warning 1264 Out of range value adjusted for column 'ulong' at row 1
+Warning 1264 Out of range value adjusted for column 'ulonglong' at row 1
Warning 1265 Data truncated for column 'options' at row 1
Warning 1265 Data truncated for column 'flags' at row 1
insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree");
@@ -108,6 +109,7 @@ Warning 1264 Out of range value adjusted for column 'utiny' at row 1
Warning 1264 Out of range value adjusted for column 'ushort' at row 1
Warning 1264 Out of range value adjusted for column 'umedium' at row 1
Warning 1264 Out of range value adjusted for column 'ulong' at row 1
+Warning 1264 Out of range value adjusted for column 'ulonglong' at row 1
Warning 1265 Data truncated for column 'options' at row 1
insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0);
Warnings:
@@ -125,8 +127,8 @@ auto string tiny short medium long_int longlong real_float real_double utiny ush
10 1 1 1 1 1 1 1.0 1.0000 1 00001 1 1 1 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 1 1 1
11 2 2 2 2 2 2 2.0 2.0000 2 00002 2 2 2 0 NULL NULL NULL NULL NULL 2 2
12 0.33333333 3 3 3 3 3 3.0 3.0000 3 00003 3 3 3 0 1997-03-03 10:10:10 1997-03-03 10:10:10 3
-13 -1 -1 -1 -1 -1 -1 -1.0 -1.0000 0 00000 0 0 18446744073709551615 0 1997-08-07 08:07:06 1997-04-03 09:08:07 -1 -1 -1 -1
-14 -429496729 -128 -32768 -8388608 -2147483648 -4294967295 -4294967296.0 -4294967295.0000 0 00000 0 0 18446744069414584321 0 0000-00-00 00:00:00 0000-00-00 00:00:00 -4294967295 -4294967295 -4294967295 -4294967295
+13 -1 -1 -1 -1 -1 -1 -1.0 -1.0000 0 00000 0 0 0 0 1997-08-07 08:07:06 1997-04-03 09:08:07 -1 -1 -1 -1
+14 -429496729 -128 -32768 -8388608 -2147483648 -4294967295 -4294967296.0 -4294967295.0000 0 00000 0 0 0 0 0000-00-00 00:00:00 0000-00-00 00:00:00 -4294967295 -4294967295 -4294967295 -4294967295
15 4294967295 127 32767 8388607 2147483647 4294967295 4294967296.0 4294967295.0000 255 65535 16777215 4294967295 4294967295 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4294967295 4294967295 4294967295 4294967295
16 hello 1 1 0 0 0 0.0 NULL 0 00000 0 0 0 0 NULL NULL NULL NULL NULL
ALTER TABLE t1
diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test
index 5f21d2b5813..d9c1abd9ba9 100644
--- a/mysql-test/t/bigint.test
+++ b/mysql-test/t/bigint.test
@@ -35,21 +35,27 @@ drop table t1;
create table t1 ( a int not null default 1, big bigint );
insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(18446744073709551615);
+select * from t1;
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
alter table t1 modify big bigint unsigned not null;
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
+insert into t1 (big) values (18446744073709551615);
+select * from t1;
+select min(big),max(big),max(big)-1 from t1;
+select min(big),max(big),max(big)-1 from t1 group by a;
alter table t1 add key (big);
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
alter table t1 modify big bigint not null;
+select * from t1;
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
drop table t1;
#
-# Test problem with big values fir auto_increment
+# Test problem with big values for auto_increment
#
create table t1 (id bigint auto_increment primary key, a int) auto_increment=9999999999;
@@ -112,6 +118,7 @@ drop table t1, t2;
#
# Test of CREATE ... SELECT and unsigned integers
#
+
create table t1 select 1 as 'a';
show create table t1;
drop table t1;
@@ -119,3 +126,147 @@ create table t1 select 9223372036854775809 as 'a';
show create table t1;
select * from t1;
drop table t1;
+DROP DATABASE IF EXISTS `scott`;
+
+
+#
+# Check various conversions from/to unsigned bigint.
+#
+
+create table t1 (a char(100), b varchar(100), c text, d blob);
+insert into t1 values(
+ 18446744073709551615,18446744073709551615,
+ 18446744073709551615, 18446744073709551615
+);
+
+insert into t1 values (-1 | 0,-1 | 0,-1 | 0 ,-1 | 0);
+select * from t1;
+drop table t1;
+
+create table t1 ( quantity decimal(2) unsigned);
+insert into t1 values (500), (-500), (~0), (-1);
+select * from t1;
+drop table t1;
+
+#
+# Test of storing decimal values in BIGINT range
+# (Bug #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0))
+#
+
+CREATE TABLE t1 (
+ `col1` INT(1) NULL,
+ `col2` INT(2) NULL,
+ `col3` INT(3) NULL,
+ `col4` INT(4) NULL,
+ `col5` INT(5) NULL,
+ `col6` INT(6) NULL,
+ `col7` INT(7) NULL,
+ `col8` INT(8) NULL,
+ `col9` INT(9) NULL,
+ `col10` BIGINT(10) NULL,
+ `col11` BIGINT(11) NULL,
+ `col12` BIGINT(12) NULL,
+ `col13` BIGINT(13) NULL,
+ `col14` BIGINT(14) NULL,
+ `col15` BIGINT(15) NULL,
+ `col16` BIGINT(16) NULL,
+ `col17` BIGINT(17) NULL,
+ `col18` BIGINT(18) NULL,
+ `col19` DECIMAL(19, 0) NULL,
+ `col20` DECIMAL(20, 0) NULL,
+ `col21` DECIMAL(21, 0) NULL,
+ `col22` DECIMAL(22, 0) NULL,
+ `col23` DECIMAL(23, 0) NULL,
+ `col24` DECIMAL(24, 0) NULL,
+ `col25` DECIMAL(25, 0) NULL,
+ `col26` DECIMAL(26, 0) NULL,
+ `col27` DECIMAL(27, 0) NULL,
+ `col28` DECIMAL(28, 0) NULL,
+ `col29` DECIMAL(29, 0) NULL,
+ `col30` DECIMAL(30, 0) NULL,
+ `col31` DECIMAL(31, 0) NULL,
+ `col32` DECIMAL(32, 0) NULL,
+ `col33` DECIMAL(33, 0) NULL,
+ `col34` DECIMAL(34, 0) NULL,
+ `col35` DECIMAL(35, 0) NULL,
+ `col36` DECIMAL(36, 0) NULL,
+ `col37` DECIMAL(37, 0) NULL,
+ `col38` DECIMAL(38, 0) NULL,
+ `fix1` DECIMAL(38, 1) NULL,
+ `fix2` DECIMAL(38, 2) NULL,
+ `fix3` DECIMAL(38, 3) NULL,
+ `fix4` DECIMAL(38, 4) NULL,
+ `fix5` DECIMAL(38, 5) NULL,
+ `fix6` DECIMAL(38, 6) NULL,
+ `fix7` DECIMAL(38, 7) NULL,
+ `fix8` DECIMAL(38, 8) NULL,
+ `fix9` DECIMAL(38, 9) NULL,
+ `fix10` DECIMAL(38, 10) NULL,
+ `fix11` DECIMAL(38, 11) NULL,
+ `fix12` DECIMAL(38, 12) NULL,
+ `fix13` DECIMAL(38, 13) NULL,
+ `fix14` DECIMAL(38, 14) NULL,
+ `fix15` DECIMAL(38, 15) NULL,
+ `fix16` DECIMAL(38, 16) NULL,
+ `fix17` DECIMAL(38, 17) NULL,
+ `fix18` DECIMAL(38, 18) NULL,
+ `fix19` DECIMAL(38, 19) NULL,
+ `fix20` DECIMAL(38, 20) NULL,
+ `fix21` DECIMAL(38, 21) NULL,
+ `fix22` DECIMAL(38, 22) NULL,
+ `fix23` DECIMAL(38, 23) NULL,
+ `fix24` DECIMAL(38, 24) NULL,
+ `fix25` DECIMAL(38, 25) NULL,
+ `fix26` DECIMAL(38, 26) NULL,
+ `fix27` DECIMAL(38, 27) NULL,
+ `fix28` DECIMAL(38, 28) NULL,
+ `fix29` DECIMAL(38, 29) NULL,
+ `fix30` DECIMAL(38, 30) NULL
+);
+
+INSERT INTO t1(`col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`, `col19`, `col20`, `col21`, `col22`, `col23`, `col24`, `col25`, `col26`, `col27`, `col28`, `col29`, `col30`, `col31`, `col32`, `col33`, `col34`, `col35`, `col36`, `col37`, `col38`, `fix1`, `fix2`, `fix3`, `fix4`, `fix5`, `fix6`, `fix7`, `fix8`, `fix9`, `fix10`, `fix11`, `fix12`, `fix13`, `fix14`, `fix15`, `fix16`, `fix17`, `fix18`, `fix19`, `fix20`, `fix21`, `fix22`, `fix23`, `fix24`, `fix25`, `fix26`, `fix27`, `fix28`, `fix29`, `fix30`)
+VALUES (9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999,
+9999999999, 99999999999, 999999999999, 9999999999999, 99999999999999,
+999999999999999, 9999999999999999, 99999999999999999, 999999999999999999,
+9999999999999999999, 99999999999999999999, 999999999999999999999,
+9999999999999999999999, 99999999999999999999999, 999999999999999999999999,
+9999999999999999999999999, 99999999999999999999999999,
+999999999999999999999999999, 9999999999999999999999999999,
+99999999999999999999999999999, 999999999999999999999999999999,
+9999999999999999999999999999999, 99999999999999999999999999999999,
+999999999999999999999999999999999, 9999999999999999999999999999999999,
+99999999999999999999999999999999999, 999999999999999999999999999999999999,
+9999999999999999999999999999999999999, 99999999999999999999999999999999999999,
+9999999999999999999999999999999999999.9,
+999999999999999999999999999999999999.99,
+99999999999999999999999999999999999.999,
+9999999999999999999999999999999999.9999,
+999999999999999999999999999999999.99999,
+99999999999999999999999999999999.999999,
+9999999999999999999999999999999.9999999,
+999999999999999999999999999999.99999999,
+99999999999999999999999999999.999999999,
+9999999999999999999999999999.9999999999,
+999999999999999999999999999.99999999999,
+99999999999999999999999999.999999999999,
+9999999999999999999999999.9999999999999,
+999999999999999999999999.99999999999999,
+99999999999999999999999.999999999999999,
+9999999999999999999999.9999999999999999,
+999999999999999999999.99999999999999999,
+99999999999999999999.999999999999999999,
+9999999999999999999.9999999999999999999,
+999999999999999999.99999999999999999999,
+99999999999999999.999999999999999999999,
+9999999999999999.9999999999999999999999,
+999999999999999.99999999999999999999999,
+99999999999999.999999999999999999999999,
+9999999999999.9999999999999999999999999,
+999999999999.99999999999999999999999999,
+99999999999.999999999999999999999999999,
+9999999999.9999999999999999999999999999,
+999999999.99999999999999999999999999999,
+99999999.999999999999999999999999999999);
+
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index ed238f46e0b..beec3b0f8c7 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -1274,9 +1274,6 @@ select count(*) from t1 where x<0;
select count(*) from t1 where x < -16;
select count(*) from t1 where x = -16;
explain select count(*) from t1 where x > -16;
-
-# The following result should be (2). To be fixed when we add 'unsigned flag' to
-# Field::store(longlong)
select count(*) from t1 where x > -16;
select * from t1 where x > -16;
select count(*) from t1 where x = 18446744073709551601;
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index c34840b0725..89fc206eeec 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -769,7 +769,7 @@ DROP TABLE t1, t2;
--exec echo "[client]" > $MYSQL_TEST_DIR/var/tmp/tmp.cnf
--exec echo "port=1234" >> $MYSQL_TEST_DIR/var/tmp/tmp.cnf
--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQL_TEST_DIR/var/tmp/tmp.cnf client
---exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQL_TEST_DIR/var/tmp/tmp.cnf client
+--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQL_TEST_DIR/var/tmp/tmp.cnf -e $MYSQL_TEST_DIR/var/tmp/tmp.cnf client client
--exec rm $MYSQL_TEST_DIR/var/tmp/tmp.cnf
#
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index 12dda022cb9..bbe5798e7e5 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -406,8 +406,8 @@ select count(*) from t1 where x = 18446744073709551601;
create table t2 (x bigint not null);
-insert into t2(x) values (0xfffffffffffffff0);
-insert into t2(x) values (0xfffffffffffffff1);
+insert into t2(x) values (cast(0xfffffffffffffff0+0 as signed));
+insert into t2(x) values (cast(0xfffffffffffffff1+0 as signed));
select * from t2;
select count(*) from t2 where x>0;
select count(*) from t2 where x=0;
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index 6af0a10d831..d3b36cbc2a8 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -659,9 +659,11 @@ INSERT INTO t1 VALUES(-9223372036854775808,0),(0,0),(9223372036854775807,1844674
INSERT INTO t1 VALUES('-9223372036854775808','0'),('9223372036854775807','18446744073709551615');
INSERT INTO t1 VALUES(-9223372036854774000.0,0.0),(9223372036854775700.0,1844674407370954000.0);
--- error 1264
+--error 1264
INSERT INTO t1 (col1) VALUES(-9223372036854775809);
+--error 1264
INSERT INTO t1 (col1) VALUES(9223372036854775808);
+--error 1264
INSERT INTO t1 (col2) VALUES(-1);
--error 1264
diff --git a/sql-common/client.c b/sql-common/client.c
index 43c50f12ae1..08ad906e2b6 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -2203,8 +2203,9 @@ my_bool mysql_reconnect(MYSQL *mysql)
DBUG_RETURN(1);
}
mysql_init(&tmp_mysql);
- tmp_mysql.options=mysql->options;
- tmp_mysql.rpl_pivot = mysql->rpl_pivot;
+ tmp_mysql.options= mysql->options;
+ tmp_mysql.rpl_pivot= mysql->rpl_pivot;
+
if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
mysql->db, mysql->port, mysql->unix_socket,
mysql->client_flag | CLIENT_REMEMBER_OPTIONS))
@@ -2216,6 +2217,8 @@ my_bool mysql_reconnect(MYSQL *mysql)
}
if (mysql_set_character_set(&tmp_mysql, mysql->charset->csname))
{
+ DBUG_PRINT("error", ("mysql_set_character_set() failed"));
+ bzero((char*) &tmp_mysql.options,sizeof(tmp_mysql.options));
mysql_close(&tmp_mysql);
mysql->net.last_errno= tmp_mysql.net.last_errno;
strmov(mysql->net.last_error, tmp_mysql.net.last_error);
@@ -2223,6 +2226,7 @@ my_bool mysql_reconnect(MYSQL *mysql)
DBUG_RETURN(1);
}
+ DBUG_PRINT("info", ("reconnect succeded"));
tmp_mysql.reconnect= 1;
tmp_mysql.free_me= mysql->free_me;
@@ -2286,6 +2290,8 @@ mysql_select_db(MYSQL *mysql, const char *db)
static void mysql_close_free_options(MYSQL *mysql)
{
+ DBUG_ENTER("mysql_close_free_options");
+
my_free(mysql->options.user,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.host,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.password,MYF(MY_ALLOW_ZERO_PTR));
@@ -2314,6 +2320,7 @@ static void mysql_close_free_options(MYSQL *mysql)
my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
#endif /* HAVE_SMEM */
bzero((char*) &mysql->options,sizeof(mysql->options));
+ DBUG_VOID_RETURN;
}
diff --git a/sql/field.cc b/sql/field.cc
index 224b6c279f3..e8731cb0ea5 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1199,7 +1199,7 @@ static bool test_if_real(const char *str,int length, CHARSET_INFO *cs)
This is used for printing bit_fields as numbers while debugging
*/
-String *Field::val_int_as_str(String *val_buffer, my_bool unsigned_flag)
+String *Field::val_int_as_str(String *val_buffer, my_bool unsigned_val)
{
CHARSET_INFO *cs= &my_charset_bin;
uint length= 21;
@@ -1208,7 +1208,7 @@ String *Field::val_int_as_str(String *val_buffer, my_bool unsigned_flag)
return 0;
length= (uint) (*cs->cset->longlong10_to_str)(cs, (char*) val_buffer->ptr(),
length,
- unsigned_flag ? 10 : -10,
+ unsigned_val ? 10 : -10,
value);
val_buffer->length(length);
return val_buffer;
@@ -1360,7 +1360,7 @@ int Field_num::store_decimal(const my_decimal *val)
{
int err= 0;
longlong i= convert_decimal2longlong(val, unsigned_flag, &err);
- return test(err | store(i));
+ return test(err | store(i, unsigned_flag));
}
@@ -2122,36 +2122,37 @@ int Field_decimal::store(double nr)
}
-int Field_decimal::store(longlong nr)
+int Field_decimal::store(longlong nr, bool unsigned_val)
{
- if (unsigned_flag && nr < 0)
+ char buff[22];
+ uint length, int_part;
+ char fyllchar, *to;
+
+ if (nr < 0 && unsigned_flag && !unsigned_val)
{
overflow(1);
return 1;
}
- char buff[22];
- uint length=(uint) (longlong10_to_str(nr,buff,-10)-buff);
- uint int_part=field_length- (dec ? dec+1 : 0);
+ length= (uint) (longlong10_to_str(nr,buff,unsigned_val ? 10 : -10) - buff);
+ int_part= field_length- (dec ? dec+1 : 0);
if (length > int_part)
{
- overflow(test(nr < 0L)); /* purecov: inspected */
+ overflow(!unsigned_val && nr < 0L); /* purecov: inspected */
return 1;
}
- else
+
+ fyllchar = zerofill ? (char) '0' : (char) ' ';
+ to= ptr;
+ for (uint i=int_part-length ; i-- > 0 ;)
+ *to++ = fyllchar;
+ memcpy(to,buff,length);
+ if (dec)
{
- char fyllchar = zerofill ? (char) '0' : (char) ' ';
- char *to=ptr;
- for (uint i=int_part-length ; i-- > 0 ;)
- *to++ = fyllchar;
- memcpy(to,buff,length);
- if (dec)
- {
- to[length]='.';
- bfill(to+length+1,dec,'0');
- }
- return 0;
+ to[length]='.';
+ bfill(to+length+1,dec,'0');
}
+ return 0;
}
@@ -2482,13 +2483,13 @@ int Field_new_decimal::store(double nr)
}
-int Field_new_decimal::store(longlong nr)
+int Field_new_decimal::store(longlong nr, bool unsigned_val)
{
my_decimal decimal_value;
int err;
if ((err= int2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
- nr, FALSE, &decimal_value)))
+ nr, unsigned_val, &decimal_value)))
{
if (check_overflow(err))
set_value_on_overflow(&decimal_value, decimal_value.sign());
@@ -2663,18 +2664,20 @@ int Field_tiny::store(double nr)
return error;
}
-int Field_tiny::store(longlong nr)
+
+int Field_tiny::store(longlong nr, bool unsigned_val)
{
int error= 0;
+
if (unsigned_flag)
{
- if (nr < 0L)
+ if (nr < 0 && !unsigned_val)
{
- *ptr=0;
+ *ptr= 0;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
error= 1;
}
- else if (nr > 255L)
+ else if ((ulonglong) nr > (ulonglong) 255)
{
*ptr= (char) 255;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
@@ -2685,13 +2688,15 @@ int Field_tiny::store(longlong nr)
}
else
{
- if (nr < -128L)
+ if (nr < 0 && unsigned_val)
+ nr= 256; // Generate overflow
+ if (nr < -128)
{
*ptr= (char) -128;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
error= 1;
}
- else if (nr > 127L)
+ else if (nr > 127)
{
*ptr=127;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
@@ -2711,6 +2716,7 @@ double Field_tiny::val_real(void)
return (double) tmp;
}
+
longlong Field_tiny::val_int(void)
{
int tmp= unsigned_flag ? (int) ((uchar*) ptr)[0] :
@@ -2718,6 +2724,7 @@ longlong Field_tiny::val_int(void)
return (longlong) tmp;
}
+
String *Field_tiny::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
@@ -2877,19 +2884,21 @@ int Field_short::store(double nr)
return error;
}
-int Field_short::store(longlong nr)
+
+int Field_short::store(longlong nr, bool unsigned_val)
{
int error= 0;
int16 res;
+
if (unsigned_flag)
{
- if (nr < 0L)
+ if (nr < 0L && !unsigned_val)
{
res=0;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
error= 1;
}
- else if (nr > (longlong) UINT_MAX16)
+ else if ((ulonglong) nr > (ulonglong) UINT_MAX16)
{
res=(int16) UINT_MAX16;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
@@ -2900,13 +2909,16 @@ int Field_short::store(longlong nr)
}
else
{
+ if (nr < 0 && unsigned_val)
+ nr= UINT_MAX16+1; // Generate overflow
+
if (nr < INT_MIN16)
{
res=INT_MIN16;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
error= 1;
}
- else if (nr > INT_MAX16)
+ else if (nr > (longlong) INT_MAX16)
{
res=INT_MAX16;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
@@ -3134,20 +3146,22 @@ int Field_medium::store(double nr)
return error;
}
-int Field_medium::store(longlong nr)
+
+int Field_medium::store(longlong nr, bool unsigned_val)
{
int error= 0;
+
if (unsigned_flag)
{
- if (nr < 0L)
+ if (nr < 0 && !unsigned_val)
{
int3store(ptr,0);
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
error= 1;
}
- else if (nr >= (longlong) (long) (1L << 24))
+ else if ((ulonglong) nr >= (ulonglong) (long) (1L << 24))
{
- long tmp=(long) (1L << 24)-1L;;
+ long tmp= (long) (1L << 24)-1L;
int3store(ptr,tmp);
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
error= 1;
@@ -3157,9 +3171,12 @@ int Field_medium::store(longlong nr)
}
else
{
+ if (nr < 0 && unsigned_val)
+ nr= (ulonglong) (long) (1L << 24); // Generate overflow
+
if (nr < (longlong) INT_MIN24)
{
- long tmp=(long) INT_MIN24;
+ long tmp= (long) INT_MIN24;
int3store(ptr,tmp);
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
error= 1;
@@ -3397,7 +3414,7 @@ int Field_long::store(double nr)
}
-int Field_long::store(longlong nr)
+int Field_long::store(longlong nr, bool unsigned_val)
{
int error= 0;
int32 res;
@@ -3405,12 +3422,12 @@ int Field_long::store(longlong nr)
if (unsigned_flag)
{
- if (nr < 0)
+ if (nr < 0 && !unsigned_val)
{
res=0;
error= 1;
}
- else if (nr >= (LL(1) << 32))
+ else if ((ulonglong) nr >= (LL(1) << 32))
{
res=(int32) (uint32) ~0L;
error= 1;
@@ -3420,7 +3437,9 @@ int Field_long::store(longlong nr)
}
else
{
- if (nr < (longlong) INT_MIN32)
+ if (nr < 0 && unsigned_val)
+ nr= INT_MAX32+1; // Generate overflow
+ if (nr < (longlong) INT_MIN32)
{
res=(int32) INT_MIN32;
error= 1;
@@ -3657,8 +3676,24 @@ int Field_longlong::store(double nr)
}
-int Field_longlong::store(longlong nr)
+int Field_longlong::store(longlong nr, bool unsigned_val)
{
+ int error= 0;
+
+ if (nr < 0) // Only possible error
+ {
+ /*
+ if field is unsigned and value is signed (< 0) or
+ if field is signed and value is unsigned we have an overflow
+ */
+ if (unsigned_flag != unsigned_val)
+ {
+ nr= unsigned_flag ? (ulonglong) 0 : (ulonglong) LONGLONG_MAX;
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
+ error= 1;
+ }
+ }
+
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
{
@@ -3667,7 +3702,7 @@ int Field_longlong::store(longlong nr)
else
#endif
longlongstore(ptr,nr);
- return 0;
+ return error;
}
@@ -3886,11 +3921,12 @@ int Field_float::store(double nr)
}
-int Field_float::store(longlong nr)
+int Field_float::store(longlong nr, bool unsigned_val)
{
- return store((double)nr);
+ return store(unsigned_val ? ulonglong2double((ulonglong) nr) : (double) nr);
}
+
double Field_float::val_real(void)
{
float j;
@@ -4166,11 +4202,12 @@ int Field_double::store(double nr)
}
-int Field_double::store(longlong nr)
+int Field_double::store(longlong nr, bool unsigned_val)
{
- return store((double)nr);
+ return store(unsigned_val ? ulonglong2double((ulonglong) nr) : (double) nr);
}
+
int Field_real::store_decimal(const my_decimal *dm)
{
double dbl;
@@ -4529,12 +4566,12 @@ int Field_timestamp::store(double nr)
nr= 0; // Avoid overflow on buff
error= 1;
}
- error|= Field_timestamp::store((longlong) rint(nr));
+ error|= Field_timestamp::store((longlong) rint(nr), FALSE);
return error;
}
-int Field_timestamp::store(longlong nr)
+int Field_timestamp::store(longlong nr, bool unsigned_val)
{
TIME l_time;
my_time_t timestamp= 0;
@@ -4829,7 +4866,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
if (ltime.neg)
tmp= -tmp;
- error |= Field_time::store((longlong) tmp);
+ error |= Field_time::store((longlong) tmp, FALSE);
return error;
}
@@ -4881,21 +4918,21 @@ int Field_time::store(double nr)
}
-int Field_time::store(longlong nr)
+int Field_time::store(longlong nr, bool unsigned_val)
{
long tmp;
int error= 0;
- if (nr > (longlong) 8385959L)
+ if (nr < (longlong) -8385959L && !unsigned_val)
{
- tmp=8385959L;
+ tmp= -8385959L;
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE, nr,
MYSQL_TIMESTAMP_TIME, 1);
error= 1;
}
- else if (nr < (longlong) -8385959L)
+ else if (nr > (longlong) 8385959 || nr < 0 && unsigned_val)
{
- tmp= -8385959L;
+ tmp=8385959L;
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE, nr,
MYSQL_TIMESTAMP_TIME, 1);
@@ -5076,18 +5113,18 @@ int Field_year::store(double nr)
{
if (nr < 0.0 || nr >= 2155.0)
{
- (void) Field_year::store((longlong) -1);
+ (void) Field_year::store((longlong) -1, FALSE);
return 1;
}
- else
- return Field_year::store((longlong) nr);
+ return Field_year::store((longlong) nr, FALSE);
}
-int Field_year::store(longlong nr)
+
+int Field_year::store(longlong nr, bool unsigned_val)
{
if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155)
{
- *ptr=0;
+ *ptr= 0;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
return 1;
}
@@ -5102,17 +5139,20 @@ int Field_year::store(longlong nr)
return 0;
}
+
bool Field_year::send_binary(Protocol *protocol)
{
ulonglong tmp= Field_year::val_int();
return protocol->store_short(tmp);
}
+
double Field_year::val_real(void)
{
return (double) Field_year::val_int();
}
+
longlong Field_year::val_int(void)
{
int tmp= (int) ((uchar*) ptr)[0];
@@ -5123,6 +5163,7 @@ longlong Field_year::val_int(void)
return (longlong) tmp;
}
+
String *Field_year::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
@@ -5133,6 +5174,7 @@ String *Field_year::val_str(String *val_buffer,
return val_buffer;
}
+
void Field_year::sql_type(String &res) const
{
CHARSET_INFO *cs=res.charset();
@@ -5203,7 +5245,7 @@ int Field_date::store(double nr)
}
-int Field_date::store(longlong nr)
+int Field_date::store(longlong nr, bool unsigned_val)
{
TIME not_used;
int error;
@@ -5262,6 +5304,7 @@ double Field_date::val_real(void)
return (double) (uint32) j;
}
+
longlong Field_date::val_int(void)
{
int32 j;
@@ -5274,6 +5317,7 @@ longlong Field_date::val_int(void)
return (longlong) (uint32) j;
}
+
String *Field_date::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
@@ -5382,11 +5426,11 @@ int Field_newdate::store(double nr)
WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATE);
return 1;
}
- return Field_newdate::store((longlong) rint(nr));
+ return Field_newdate::store((longlong) rint(nr), FALSE);
}
-int Field_newdate::store(longlong nr)
+int Field_newdate::store(longlong nr, bool unsigned_val)
{
TIME l_time;
longlong tmp;
@@ -5576,12 +5620,12 @@ int Field_datetime::store(double nr)
nr= 0.0;
error= 1;
}
- error|= Field_datetime::store((longlong) rint(nr));
+ error|= Field_datetime::store((longlong) rint(nr), FALSE);
return error;
}
-int Field_datetime::store(longlong nr)
+int Field_datetime::store(longlong nr, bool unsigned_val)
{
TIME not_used;
int error;
@@ -5905,12 +5949,13 @@ int Field_str::store(double nr)
}
-int Field_string::store(longlong nr)
+int Field_string::store(longlong nr, bool unsigned_val)
{
char buff[64];
int l;
CHARSET_INFO *cs=charset();
- l= (cs->cset->longlong10_to_str)(cs,buff,sizeof(buff),-10,nr);
+ l= (cs->cset->longlong10_to_str)(cs,buff,sizeof(buff),
+ unsigned_val ? 10 : -10, nr);
return Field_string::store(buff,(uint)l,cs);
}
@@ -6234,14 +6279,16 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
}
-int Field_varstring::store(longlong nr)
+int Field_varstring::store(longlong nr, bool unsigned_val)
{
char buff[64];
uint length;
length= (uint) (field_charset->cset->longlong10_to_str)(field_charset,
buff,
sizeof(buff),
- -10,nr);
+ (unsigned_val ? 10:
+ -10),
+ nr);
return Field_varstring::store(buff, length, field_charset);
}
@@ -6859,13 +6906,17 @@ int Field_blob::store(double nr)
}
-int Field_blob::store(longlong nr)
+int Field_blob::store(longlong nr, bool unsigned_val)
{
CHARSET_INFO *cs=charset();
- value.set(nr, cs);
+ if (unsigned_val)
+ value.set((ulonglong) nr, cs);
+ else
+ value.set(nr, cs);
return Field_blob::store(value.ptr(), (uint) value.length(), cs);
}
+
double Field_blob::val_real(void)
{
int not_used;
@@ -7330,7 +7381,7 @@ int Field_geom::store(double nr)
}
-int Field_geom::store(longlong nr)
+int Field_geom::store(longlong nr, bool unsigned_val)
{
my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
@@ -7483,14 +7534,14 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
int Field_enum::store(double nr)
{
- return Field_enum::store((longlong) nr);
+ return Field_enum::store((longlong) nr, FALSE);
}
-int Field_enum::store(longlong nr)
+int Field_enum::store(longlong nr, bool unsigned_val)
{
int error= 0;
- if ((uint) nr > typelib->count || nr == 0)
+ if ((ulonglong) nr > typelib->count || nr == 0)
{
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
nr=0;
@@ -7661,7 +7712,7 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
}
-int Field_set::store(longlong nr)
+int Field_set::store(longlong nr, bool unsigned_val)
{
int error= 0;
if ((ulonglong) nr > (ulonglong) (((longlong) 1 << typelib->count) -
@@ -7881,11 +7932,11 @@ int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
int Field_bit::store(double nr)
{
- return store((longlong) nr);
+ return store((longlong) nr, FALSE);
}
-int Field_bit::store(longlong nr)
+int Field_bit::store(longlong nr, bool unsigned_val)
{
char buf[8];
@@ -8466,8 +8517,8 @@ create_field::create_field(Field *old_field,Field *orig_field)
else
interval=0;
def=0;
+
if (!(flags & (NO_DEFAULT_VALUE_FLAG | BLOB_FLAG)) &&
- !old_field->is_real_null() &&
old_field->ptr && orig_field &&
(sql_type != FIELD_TYPE_TIMESTAMP || /* set def only if */
old_field->table->timestamp_field != old_field || /* timestamp field */
diff --git a/sql/field.h b/sql/field.h
index 2b67ed3f599..632169868bc 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -97,7 +97,7 @@ public:
/* Store functions returns 1 on overflow and -1 on fatal error */
virtual int store(const char *to,uint length,CHARSET_INFO *cs)=0;
virtual int store(double nr)=0;
- virtual int store(longlong nr)=0;
+ virtual int store(longlong nr, bool unsigned_val)=0;
virtual int store_decimal(const my_decimal *d)=0;
virtual int store_time(TIME *ltime, timestamp_type t_type);
virtual double val_real(void)=0;
@@ -357,7 +357,7 @@ public:
Item_result result_type () const { return STRING_RESULT; }
uint decimals() const { return NOT_FIXED_DEC; }
int store(double nr);
- int store(longlong nr)=0;
+ int store(longlong nr, bool unsigned_val)=0;
int store_decimal(const my_decimal *);
int store(const char *to,uint length,CHARSET_INFO *cs)=0;
uint size_of() const { return sizeof(*this); }
@@ -422,7 +422,7 @@ public:
void reset(void);
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -464,7 +464,7 @@ public:
void set_value_on_overflow(my_decimal *decimal_value, bool sign);
int store(const char *to, uint length, CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *);
double val_real(void);
longlong val_int(void);
@@ -497,7 +497,7 @@ public:
{ return unsigned_flag ? HA_KEYTYPE_BINARY : HA_KEYTYPE_INT8; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { ptr[0]=0; }
double val_real(void);
longlong val_int(void);
@@ -533,7 +533,7 @@ public:
{ return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;}
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { ptr[0]=ptr[1]=0; }
double val_real(void);
longlong val_int(void);
@@ -564,7 +564,7 @@ public:
{ return unsigned_flag ? HA_KEYTYPE_UINT24 : HA_KEYTYPE_INT24; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void);
longlong val_int(void);
@@ -600,7 +600,7 @@ public:
{ return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void);
longlong val_int(void);
@@ -638,7 +638,7 @@ public:
{ return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
double val_real(void);
longlong val_int(void);
@@ -674,7 +674,7 @@ public:
enum ha_base_keytype key_type() const { return HA_KEYTYPE_FLOAT; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { bzero(ptr,sizeof(float)); }
double val_real(void);
longlong val_int(void);
@@ -708,7 +708,7 @@ public:
enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { bzero(ptr,sizeof(double)); }
double val_real(void);
longlong val_int(void);
@@ -737,7 +737,7 @@ public:
int store(const char *to, uint length, CHARSET_INFO *cs)
{ null[0]=1; return 0; }
int store(double nr) { null[0]=1; return 0; }
- int store(longlong nr) { null[0]=1; return 0; }
+ int store(longlong nr, bool unsigned_val) { null[0]=1; return 0; }
int store_decimal(const my_decimal *d) { null[0]=1; return 0; }
void reset(void) {}
double val_real(void) { return 0.0;}
@@ -766,7 +766,7 @@ public:
enum Item_result cmp_type () const { return INT_RESULT; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void);
longlong val_int(void);
@@ -818,7 +818,7 @@ public:
enum_field_types type() const { return FIELD_TYPE_YEAR;}
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -845,7 +845,7 @@ public:
enum Item_result cmp_type () const { return INT_RESULT; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void);
longlong val_int(void);
@@ -873,7 +873,7 @@ public:
enum Item_result cmp_type () const { return INT_RESULT; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
int store_time(TIME *ltime, timestamp_type type);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void);
@@ -909,7 +909,7 @@ public:
int store_time(TIME *ltime, timestamp_type type);
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void);
longlong val_int(void);
@@ -946,7 +946,7 @@ public:
uint decimals() const { return DATETIME_DEC; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
int store_time(TIME *ltime, timestamp_type type);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
double val_real(void);
@@ -990,7 +990,7 @@ public:
bool zero_pack() const { return 0; }
void reset(void) { charset()->cset->fill(charset(),ptr,field_length,' '); }
int store(const char *to,uint length,CHARSET_INFO *charset);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
double val_real(void);
longlong val_int(void);
@@ -1049,7 +1049,7 @@ public:
uint32 pack_length() const { return (uint32) field_length+length_bytes; }
uint32 key_length() const { return (uint32) field_length; }
int store(const char *to,uint length,CHARSET_INFO *charset);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
double val_real(void);
longlong val_int(void);
@@ -1106,7 +1106,7 @@ public:
{ return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -1201,7 +1201,7 @@ public:
void sql_type(String &str) const;
int store(const char *to, uint length, CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *);
void get_key_image(char *buff,uint length,imagetype type);
uint size_of() const { return sizeof(*this); }
@@ -1232,7 +1232,7 @@ public:
enum ha_base_keytype key_type() const;
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
void reset() { bzero(ptr,packlength); }
double val_real(void);
longlong val_int(void);
@@ -1268,8 +1268,8 @@ public:
flags=(flags & ~ENUM_FLAG) | SET_FLAG;
}
int store(const char *to,uint length,CHARSET_INFO *charset);
- int store(double nr) { return Field_set::store((longlong) nr); }
- int store(longlong nr);
+ int store(double nr) { return Field_set::store((longlong) nr, FALSE); }
+ int store(longlong nr, bool unsigned_val);
virtual bool zero_pack() const { return 1; }
String *val_str(String*,String *);
void sql_type(String &str) const;
@@ -1296,7 +1296,7 @@ public:
void reset(void) { bzero(ptr, field_length); }
int store(const char *to, uint length, CHARSET_INFO *charset);
int store(double nr);
- int store(longlong nr);
+ int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *);
double val_real(void);
longlong val_int(void);
@@ -1342,7 +1342,8 @@ public:
uint size_of() const { return sizeof(*this); }
int store(const char *to, uint length, CHARSET_INFO *charset);
int store(double nr) { return Field_bit::store(nr); }
- int store(longlong nr) { return Field_bit::store(nr); }
+ int store(longlong nr, bool unsigned_val)
+ { return Field_bit::store(nr, unsigned_val); }
void sql_type(String &str) const;
};
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 40f3ff85c58..bbe2dbe5e9f 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -311,8 +311,9 @@ static void do_field_string(Copy_field *copy)
static void do_field_int(Copy_field *copy)
{
- longlong value=copy->from_field->val_int();
- copy->to_field->store(value);
+ longlong value= copy->from_field->val_int();
+ copy->to_field->store(value,
+ test(copy->from_field->flags & UNSIGNED_FLAG));
}
static void do_field_real(Copy_field *copy)
@@ -689,5 +690,5 @@ void field_conv(Field *to,Field *from)
to->store_decimal(from->val_decimal(&buff));
}
else
- to->store(from->val_int());
+ to->store(from->val_int(), test(from->flags & UNSIGNED_FLAG));
}
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 146fbee93c8..ff631ac9db8 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -2332,7 +2332,8 @@ void ha_ndbcluster::unpack_record(byte* buf)
DBUG_PRINT("info", ("bit field H'%.8X",
(*value).rec->u_32_value()));
((Field_bit *) *field)->store((longlong)
- (*value).rec->u_32_value());
+ (*value).rec->u_32_value(),
+ FALSE);
}
else
{
@@ -2340,7 +2341,8 @@ void ha_ndbcluster::unpack_record(byte* buf)
*(Uint32 *)(*value).rec->aRef(),
*((Uint32 *)(*value).rec->aRef()+1)));
((Field_bit *) *field)->store((longlong)
- (*value).rec->u_64_value()); }
+ (*value).rec->u_64_value(), TRUE);
+ }
}
}
else
diff --git a/sql/handler.cc b/sql/handler.cc
index 3acca812a13..b3754891d05 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1518,7 +1518,7 @@ bool handler::update_auto_increment()
/* Mark that we should clear next_insert_id before next stmt */
thd->clear_next_insert_id= 1;
- if (!table->next_number_field->store((longlong) nr))
+ if (!table->next_number_field->store((longlong) nr, TRUE))
thd->insert_id((ulonglong) nr);
else
thd->insert_id(table->next_number_field->val_int());
diff --git a/sql/item.cc b/sql/item.cc
index e7da646ae73..2086d8cc161 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2341,7 +2341,7 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
switch (state) {
case INT_VALUE:
- return field->store(value.integer);
+ return field->store(value.integer, unsigned_flag);
case REAL_VALUE:
return field->store(value.real);
case DECIMAL_VALUE:
@@ -3895,7 +3895,7 @@ int Item::save_in_field(Field *field, bool no_conversions)
if (null_value)
return set_field_to_null_with_conversions(field, no_conversions);
field->set_notnull();
- error=field->store(nr);
+ error=field->store(nr, unsigned_flag);
}
return error;
}
@@ -3911,12 +3911,10 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
return field->store(result->ptr(),result->length(),collation.collation);
}
+
int Item_uint::save_in_field(Field *field, bool no_conversions)
{
- /*
- TODO: To be fixed when wen have a
- field->store(longlong, unsigned_flag) method
- */
+ /* Item_int::save_in_field handles both signed and unsigned. */
return Item_int::save_in_field(field, no_conversions);
}
@@ -3927,7 +3925,7 @@ int Item_int::save_in_field(Field *field, bool no_conversions)
if (null_value)
return set_field_to_null(field);
field->set_notnull();
- return field->store(nr);
+ return field->store(nr, unsigned_flag);
}
@@ -4134,7 +4132,7 @@ int Item_hex_string::save_in_field(Field *field, bool no_conversions)
else
{
longlong nr=val_int();
- error=field->store(nr);
+ error=field->store(nr, TRUE); // Assume hex numbers are unsigned
}
return error;
}
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 4f991615bfa..880ab4c8cb1 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1614,7 +1614,7 @@ void Item_sum_hybrid::reset_field()
else
result_field->set_notnull();
}
- result_field->store(nr);
+ result_field->store(nr, unsigned_flag);
break;
}
case REAL_RESULT:
@@ -1930,7 +1930,7 @@ Item_sum_hybrid::min_max_update_int_field()
}
else if (result_field->is_null(0))
result_field->set_null();
- result_field->store(old_nr);
+ result_field->store(old_nr, unsigned_flag);
}
diff --git a/sql/sp.cc b/sql/sp.cc
index 016703662a5..271a5d3a4f8 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -223,7 +223,7 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, TABLE *table)
table->field[0]->store(name->m_db.str, name->m_db.length, &my_charset_bin);
table->field[1]->store(name->m_name.str, name->m_name.length,
&my_charset_bin);
- table->field[2]->store((longlong) type);
+ table->field[2]->store((longlong) type, TRUE);
key_copy(key, table->record[0], table->key_info,
table->key_info->key_length);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 4127129576b..9cd19b8e8e6 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1800,11 +1800,11 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
USER_RESOURCES mqh= lex->mqh;
if (mqh.specified_limits & USER_RESOURCES::QUERIES_PER_HOUR)
- table->field[next_field]->store((longlong) mqh.questions);
+ table->field[next_field]->store((longlong) mqh.questions, TRUE);
if (mqh.specified_limits & USER_RESOURCES::UPDATES_PER_HOUR)
- table->field[next_field+1]->store((longlong) mqh.updates);
+ table->field[next_field+1]->store((longlong) mqh.updates, TRUE);
if (mqh.specified_limits & USER_RESOURCES::CONNECTIONS_PER_HOUR)
- table->field[next_field+2]->store((longlong) mqh.conn_per_hour);
+ table->field[next_field+2]->store((longlong) mqh.conn_per_hour, TRUE);
if (table->s->fields >= 36 &&
(mqh.specified_limits & USER_RESOURCES::USER_CONNECTIONS))
table->field[next_field+3]->store((longlong) mqh.user_conn);
@@ -2306,7 +2306,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
store_record(table,record[1]); // copy original row
}
- table->field[6]->store((longlong) get_rights_for_column(privileges));
+ table->field[6]->store((longlong) get_rights_for_column(privileges), TRUE);
if (old_row_exists)
{
@@ -2373,7 +2373,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
privileges&= ~rights;
table->field[6]->store((longlong)
- get_rights_for_column(privileges));
+ get_rights_for_column(privileges), TRUE);
table->field[4]->val_str(&column_name);
grant_column = column_hash_search(g_t,
column_name.ptr(),
@@ -2492,8 +2492,8 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
}
table->field[4]->store(grantor,(uint) strlen(grantor), system_charset_info);
- table->field[6]->store((longlong) store_table_rights);
- table->field[7]->store((longlong) store_col_rights);
+ table->field[6]->store((longlong) store_table_rights, TRUE);
+ table->field[7]->store((longlong) store_col_rights, TRUE);
rights=fix_rights_for_table(store_table_rights);
col_rights=fix_rights_for_column(store_col_rights);
@@ -2568,7 +2568,8 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name,
table->field[3]->store(routine_name,(uint) strlen(routine_name),
&my_charset_latin1);
table->field[4]->store((longlong)(is_proc ?
- TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION));
+ TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION),
+ TRUE);
store_record(table,record[1]); // store at pos 1
if (table->file->index_read_idx(table->record[0],0,
@@ -2609,7 +2610,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name,
}
table->field[5]->store(grantor,(uint) strlen(grantor), &my_charset_latin1);
- table->field[6]->store((longlong) store_proc_rights);
+ table->field[6]->store((longlong) store_proc_rights, TRUE);
rights=fix_rights_for_procedure(store_proc_rights);
if (old_row_exists)
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index 799758f7d1e..f4d835541cf 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -289,7 +289,7 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations,
topics->file->ha_index_init(iindex_topic);
relations->file->ha_index_init(iindex_relations);
- rkey_id->store((longlong) key_id);
+ rkey_id->store((longlong) key_id, TRUE);
rkey_id->get_key_image(buff, rkey_id->pack_length(), Field::itRAW);
int key_res= relations->file->index_read(relations->record[0],
(byte *)buff, rkey_id->pack_length(),
@@ -302,7 +302,7 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations,
char topic_id_buff[8];
longlong topic_id= rtopic_id->val_int();
Field *field= find_fields[help_topic_help_topic_id].field;
- field->store((longlong) topic_id);
+ field->store((longlong) topic_id, TRUE);
field->get_key_image(topic_id_buff, field->pack_length(), Field::itRAW);
if (!topics->file->index_read(topics->record[0], (byte *)topic_id_buff,
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 51330a6109b..d657183b8f4 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2255,7 +2255,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
}
tmp_buff= file->table_type();
table->field[4]->store(tmp_buff, strlen(tmp_buff), cs);
- table->field[5]->store((longlong) share->frm_version);
+ table->field[5]->store((longlong) share->frm_version, TRUE);
enum row_type row_type = file->get_row_type();
switch (row_type) {
case ROW_TYPE_NOT_USED:
@@ -2284,7 +2284,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
table->field[6]->store(tmp_buff, strlen(tmp_buff), cs);
if (!tables->schema_table)
{
- table->field[7]->store((longlong) file->records);
+ table->field[7]->store((longlong) file->records, TRUE);
table->field[7]->set_notnull();
}
table->field[8]->store((longlong) file->mean_rec_length);
@@ -2297,7 +2297,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
table->field[12]->store((longlong) file->delete_length);
if (show_table->found_next_number_field)
{
- table->field[13]->store((longlong) file->auto_increment_value);
+ table->field[13]->store((longlong) file->auto_increment_value, TRUE);
table->field[13]->set_notnull();
}
if (file->create_time)
@@ -2325,7 +2325,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
table->field[17]->store(tmp_buff, strlen(tmp_buff), cs);
if (file->table_flags() & (ulong) HA_HAS_CHECKSUM)
{
- table->field[18]->store((longlong) file->checksum());
+ table->field[18]->store((longlong) file->checksum(), TRUE);
table->field[18]->set_notnull();
}
@@ -2476,7 +2476,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
table->field[2]->store(file_name, file_name_length, cs);
table->field[3]->store(field->field_name, strlen(field->field_name),
cs);
- table->field[4]->store((longlong) count);
+ table->field[4]->store((longlong) count, TRUE);
field->sql_type(type);
table->field[14]->store(type.ptr(), type.length(), cs);
tmp_buff= strchr(type.ptr(), '(');
@@ -2520,7 +2520,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
{
longlong c_octet_len= is_blob ? (longlong) field->max_length() :
(longlong) field->max_length()/field->charset()->mbmaxlen;
- table->field[8]->store(c_octet_len);
+ table->field[8]->store(c_octet_len, TRUE);
table->field[8]->set_notnull();
table->field[9]->store((longlong) field->max_length());
table->field[9]->set_notnull();
@@ -2568,7 +2568,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
}
if (decimals >= 0)
{
- table->field[11]->store((longlong) decimals);
+ table->field[11]->store((longlong) decimals, TRUE);
table->field[11]->set_notnull();
}
@@ -2624,7 +2624,7 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond)
table->field[1]->store(tmp_cs->name, strlen(tmp_cs->name), scs);
comment= tmp_cs->comment ? tmp_cs->comment : "";
table->field[2]->store(comment, strlen(comment), scs);
- table->field[3]->store((longlong) tmp_cs->mbmaxlen);
+ table->field[3]->store((longlong) tmp_cs->mbmaxlen, TRUE);
if (schema_table_store_record(thd, table))
return 1;
}
@@ -2659,12 +2659,12 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond)
restore_record(table, s->default_values);
table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
- table->field[2]->store((longlong) tmp_cl->number);
+ table->field[2]->store((longlong) tmp_cl->number, TRUE);
tmp_buff= (tmp_cl->state & MY_CS_PRIMARY) ? "Yes" : "";
table->field[3]->store(tmp_buff, strlen(tmp_buff), scs);
tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : "";
table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
- table->field[5]->store((longlong) tmp_cl->strxfrm_multiply);
+ table->field[5]->store((longlong) tmp_cl->strxfrm_multiply, TRUE);
if (schema_table_store_record(thd, table))
return 1;
}
@@ -2865,10 +2865,10 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
table->field[1]->store(base_name, strlen(base_name), cs);
table->field[2]->store(file_name, strlen(file_name), cs);
table->field[3]->store((longlong) ((key_info->flags &
- HA_NOSAME) ? 0 :1));
+ HA_NOSAME) ? 0 : 1), TRUE);
table->field[4]->store(base_name, strlen(base_name), cs);
table->field[5]->store(key_info->name, strlen(key_info->name), cs);
- table->field[6]->store((longlong) (j+1));
+ table->field[6]->store((longlong) (j+1), TRUE);
str=(key_part->field ? key_part->field->field_name :
"?unknown field?");
table->field[7]->store(str, strlen(str), cs);
@@ -2884,7 +2884,7 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
{
ha_rows records=(show_table->file->records /
key->rec_per_key[j]);
- table->field[9]->store((longlong) records);
+ table->field[9]->store((longlong) records, TRUE);
table->field[9]->set_notnull();
}
if (!(key_info->flags & HA_FULLTEXT) &&
@@ -3123,7 +3123,7 @@ void store_key_column_usage(TABLE *table, const char*db, const char *tname,
table->field[4]->store(db, strlen(db), cs);
table->field[5]->store(tname, strlen(tname), cs);
table->field[6]->store(con_type, con_len, cs);
- table->field[7]->store((longlong) idx);
+ table->field[7]->store((longlong) idx, TRUE);
}
@@ -3195,7 +3195,7 @@ static int get_schema_key_column_usage_record(THD *thd,
f_key_info->forein_id->length,
f_info->str, f_info->length,
(longlong) f_idx);
- table->field[8]->store((longlong) f_idx);
+ table->field[8]->store((longlong) f_idx, TRUE);
table->field[8]->set_notnull();
table->field[9]->store(f_key_info->referenced_db->str,
f_key_info->referenced_db->length,
@@ -3233,8 +3233,8 @@ int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond)
restore_record(table, s->default_values);
table->field[0]->store(open_list->db, strlen(open_list->db), cs);
table->field[1]->store(open_list->table, strlen(open_list->table), cs);
- table->field[2]->store((longlong) open_list->in_use);
- table->field[3]->store((longlong) open_list->locked);
+ table->field[2]->store((longlong) open_list->in_use, TRUE);
+ table->field[3]->store((longlong) open_list->locked, TRUE);
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 611ab0f16aa..64437ce26ce 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1712,6 +1712,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
DBUG_ENTER("create_table_from_items");
tmp_table.alias= 0;
+ tmp_table.timestamp_field= 0;
tmp_table.s= &tmp_table.share_not_to_be_used;
tmp_table.s->db_create_options=0;
tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr;
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index e0c3034a58a..ba3c598a784 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -472,10 +472,10 @@ int mysql_create_function(THD *thd,udf_func *udf)
restore_record(table, s->default_values); // Default values for fields
table->field[0]->store(u_d->name.str, u_d->name.length, system_charset_info);
- table->field[1]->store((longlong) u_d->returns);
+ table->field[1]->store((longlong) u_d->returns, TRUE);
table->field[2]->store(u_d->dl,(uint) strlen(u_d->dl), system_charset_info);
if (table->s->fields >= 4) // If not old func format
- table->field[3]->store((longlong) u_d->type);
+ table->field[3]->store((longlong) u_d->type, TRUE);
error = table->file->write_row(table->record[0]);
close_thread_tables(thd);
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 5a907f0d170..537050e94db 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -1826,7 +1826,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
*/
table= tz_tables->table;
tz_tables= tz_tables->next_local;
- table->field[0]->store((longlong)tzid);
+ table->field[0]->store((longlong) tzid, TRUE);
(void)table->file->ha_index_init(0);
if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr,
@@ -1853,7 +1853,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
*/
table= tz_tables->table;
tz_tables= tz_tables->next_local;
- table->field[0]->store((longlong)tzid);
+ table->field[0]->store((longlong) tzid, TRUE);
(void)table->file->ha_index_init(0);
// FIXME Is there any better approach than explicitly specifying 4 ???
@@ -1925,7 +1925,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
in ascending order by index scan also satisfies us.
*/
table= tz_tables->table;
- table->field[0]->store((longlong)tzid);
+ table->field[0]->store((longlong) tzid, TRUE);
(void)table->file->ha_index_init(0);
// FIXME Is there any better approach than explicitly specifying 4 ???
diff --git a/sql/unireg.cc b/sql/unireg.cc
index a89d89426a6..70b0fb400f9 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -754,7 +754,7 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
(field->flags & NOT_NULL_FLAG))
{
regfield->set_notnull();
- regfield->store((longlong) 1);
+ regfield->store((longlong) 1, TRUE);
}
else if (type == Field::YES) // Old unireg type
regfield->store(ER(ER_YES),(uint) strlen(ER(ER_YES)),system_charset_info);