mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
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.
This commit is contained in:
commit
d974ea7f53
2 changed files with 3 additions and 1 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1130,6 +1130,7 @@ public:
|
|||
const char *func_name() const { return "last_insert_id"; }
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
unsigned_flag= TRUE;
|
||||
if (arg_count)
|
||||
max_length= args[0]->max_length;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue