summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorNeeraj Bisht <neeraj.x.bisht@oracle.com>2012-10-16 23:26:35 +0530
committerNeeraj Bisht <neeraj.x.bisht@oracle.com>2012-10-16 23:26:35 +0530
commit510d048b7cae63dee674a5212105473b666208e1 (patch)
treee8cf396d84fc02b74a2ce395a4dc04a464fc7a07 /sql/item_func.cc
parent5f37d738bed86552ab8e4589a1c4c514e27e67d2 (diff)
parentbdb4104cf6b658b0b614f2b5b3c690535fde3726 (diff)
downloadmariadb-git-510d048b7cae63dee674a5212105473b666208e1.tar.gz
Bug#11745891 - LAST_INSERT(ID) DOES NOT SUPPORT BIGINT UNSIGNED
Problem:- using last_insert_id() on an auto_incremented bigint unsigned does not work for values which are greater than max-bigint-signed. Analysis:- last_insert_id() returns the first auto_incremented value for a column and an auto_incremented value can have only positive values. In our code, when we are initializing a last_insert_id object, we are taking it as a signed BIGINT, So when the auto_incremented value reaches greater than max signed bigint, last_insert_id gives negative result. Solution: When we are fetching the value from last_insert_id, We are setting the unsigned_flag, so that it take only unsigned BIGINT value. sql/item_func.cc: here unsigned value is converted to signed value. sql/item_func.h: last_insert_id() gives an auto_incremented value which can be positive only,so defined it as a unsigned longlong sets the unsigned_flag to 1.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 0cd6ff6357e..be8ee84712a 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4023,7 +4023,8 @@ longlong Item_func_last_insert_id::val_int()
thd->first_successful_insert_id_in_prev_stmt= value;
return value;
}
- return thd->read_first_successful_insert_id_in_prev_stmt();
+ return
+ static_cast<longlong>(thd->read_first_successful_insert_id_in_prev_stmt());
}