From 438e9eca68c45e3e735ed21dfaccaf29b0ca16b1 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 8 Jun 2012 22:12:44 +0300 Subject: [PATCH 1/3] Changed last_insert_id() to be unsigned. Fixed MDEV-331: last_insert_id() returns a signed number mysql-test/r/auto_increment.result: Added test case mysql-test/t/auto_increment.test: Added test case sql/item_func.h: Changed last_insert_id() to be unsigned. --- mysql-test/r/auto_increment.result | 22 ++++++++++++++++++++++ mysql-test/t/auto_increment.test | 16 ++++++++++++++++ sql/item_func.h | 1 + 3 files changed, 39 insertions(+) diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index d21e78428c5..30b4ff11227 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -516,3 +516,25 @@ pk 1 18446744073709551614 DROP TABLE t1; +CREATE TABLE t1 (pk BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (pk)); +insert into t1 values((1<<63)+1); +insert into t1 values(null); +select last_insert_id(); +last_insert_id() +9223372036854775810 +select * from t1; +pk +9223372036854775809 +9223372036854775810 +drop table t1; +CREATE TABLE t1 (pk BIGINT AUTO_INCREMENT, PRIMARY KEY (pk)); +insert into t1 values(-5); +insert into t1 values(null); +select last_insert_id(); +last_insert_id() +1 +select * from t1; +pk +-5 +1 +drop table t1; diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index 2854f503034..884e0fabb5e 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -380,3 +380,19 @@ CREATE TABLE t1 (pk BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (pk)); INSERT INTO t1 VALUES (NULL), (18446744073709551615-1), (NULL); SELECT * FROM t1; DROP TABLE t1; + +# MDEV-331 last_insert_id() returns a signed number +# Check that last_insert_id() generates a signed value +CREATE TABLE t1 (pk BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (pk)); +insert into t1 values((1<<63)+1); +insert into t1 values(null); +select last_insert_id(); +select * from t1; +drop table t1; + +CREATE TABLE t1 (pk BIGINT AUTO_INCREMENT, PRIMARY KEY (pk)); +insert into t1 values(-5); +insert into t1 values(null); +select last_insert_id(); +select * from t1; +drop table t1; diff --git a/sql/item_func.h b/sql/item_func.h index 3b1a38cf447..f91107c5445 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1201,6 +1201,7 @@ public: { if (arg_count) max_length= args[0]->max_length; + unsigned_flag=1; } bool fix_fields(THD *thd, Item **ref); bool check_vcol_func_processor(uchar *int_arg) From d48f2e889db5b7a8199949170cc7d9035d3683a1 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 8 Jun 2012 22:13:38 +0300 Subject: [PATCH 2/3] Moved init_log() to be later to not write log entries when one uses --example --- scripts/mysqld_multi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 02316d218e7..99ce187fcd4 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -116,7 +116,6 @@ sub main print "will be disabled\nand some will be enabled.\n\n"; } - init_log() if (!defined($opt_log)); $groupids = $ARGV[1]; if ($opt_version) { @@ -142,6 +141,7 @@ sub main !($ARGV[0] =~ m/^stop$/i) && !($ARGV[0] =~ m/^report$/i))); + init_log() if (!defined($opt_log)); if (!$opt_no_log) { w2log("$my_progname log file version $VER; run: ", From a7229e8c20a0060a7adb599c6d52f3f68fbe4f35 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sun, 10 Jun 2012 13:50:21 +0400 Subject: [PATCH 3/3] BUG#1010351: New "via" keyword in 5.2+ can't be used as identifier anymore - Add the VIA_SYM token into keyword_sp list, which makes it allowed for use as keyword and SP label. --- mysql-test/r/connect.result | 24 ++++++++++++++++++++++++ mysql-test/t/connect.test | 30 ++++++++++++++++++++++++++++++ sql/sql_yacc.yy | 1 + 3 files changed, 55 insertions(+) diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result index 7a972f4814a..e8a09d45877 100644 --- a/mysql-test/r/connect.result +++ b/mysql-test/r/connect.result @@ -254,3 +254,27 @@ connect(localhost,mysqltest_nouser,,test,MASTER_PORT,MASTER_SOCKET); ERROR 28000: Access denied for user 'mysqltest_nouser'@'localhost' (using password: NO) DROP USER mysqltest_up1@'%'; DROP USER mysqltest_up2@'%'; +# +# BUG#1010351: New "via" keyword in 5.2+ can't be used as identifier anymore +# +create table t1 (via int); +alter table t1 add key(via); +drop table t1; +create table t1 (col1 int); +alter table t1 add via int not null; +drop table t1; +drop procedure if exists p1; +create procedure p1(x int) +foo: loop +if x = 0 then +leave foo; +end if; +select 'test'; +set x = x-1; +end loop foo| +call p1(2); +test +test +test +test +drop procedure p1; diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index e5c6e8371bf..cfe4e80fcbd 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -397,3 +397,33 @@ DROP USER mysqltest_up2@'%'; # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc + +--echo # +--echo # BUG#1010351: New "via" keyword in 5.2+ can't be used as identifier anymore +--echo # +create table t1 (via int); +alter table t1 add key(via); +drop table t1; + +create table t1 (col1 int); +alter table t1 add via int not null; +drop table t1; + +--disable_warnings +drop procedure if exists p1; +--enable_warnings + +delimiter |; +create procedure p1(x int) +foo: loop + if x = 0 then + leave foo; + end if; + select 'test'; + set x = x-1; +end loop foo| + +delimiter ;| +call p1(2); +drop procedure p1; + diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 49fe3e5079e..16269f13afe 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -12206,6 +12206,7 @@ keyword_sp: | WORK_SYM {} | X509_SYM {} | YEAR_SYM {} + | VIA_SYM {} ; /* Option functions */