Commit 438e9eca authored by Michael Widenius's avatar Michael Widenius

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.
parent cb6109cd
...@@ -516,3 +516,25 @@ pk ...@@ -516,3 +516,25 @@ pk
1 1
18446744073709551614 18446744073709551614
DROP TABLE t1; 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;
...@@ -380,3 +380,19 @@ CREATE TABLE t1 (pk BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (pk)); ...@@ -380,3 +380,19 @@ CREATE TABLE t1 (pk BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (pk));
INSERT INTO t1 VALUES (NULL), (18446744073709551615-1), (NULL); INSERT INTO t1 VALUES (NULL), (18446744073709551615-1), (NULL);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE 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;
...@@ -1201,6 +1201,7 @@ public: ...@@ -1201,6 +1201,7 @@ public:
{ {
if (arg_count) if (arg_count)
max_length= args[0]->max_length; max_length= args[0]->max_length;
unsigned_flag=1;
} }
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment