re: last_insert_id() should return ulonglong, but is longlong
Michael Widenius <[email protected]> Fri, 8 Jun 2012 22:00:49 +0300
| Newsgroups | gmane.comp.db.mysql.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi! >>>>> "Dvir" == Dvir Azulay <[email protected]> writes: Dvir> Hello, this is my first time on this mailing list so I hope I'm on the Dvir> right place. Dvir> Last night I encountered an issue with LAST_INSERT_ID(), when my ID Dvir> column is an UNSIGNED BIGINT; the return value was a SIGNED BIGINT. Dvir> So I looked at the source code and saw this line: Dvir> longlong Item_func_last_insert_id::val_int() Dvir> When in other places, it was referred to as ulonglong, here it is Dvir> longlong. (When it should be ulonglong of course). Dvir> Is this correct or am I looking at the wrong place? The val_int() is always returning a longlong. This is ok as the storage space of longlong and ulonglong are idential and longlong can easily be cast to ulonglong. MySQL/MariaDB has a flag for each field (unsigned_flag) and item that tells if the longlong value should be regarded as signed or unsigned value. I checked the Item_func_last_insert_id() function and you are right that it's not declared as an unsigned function. This is probably wrong, however it's not 100 % clear if changing it to unsigned is the best way to go as the auto_increment column may be signed or unsigned. I will look into it if we can change it in MariaDB to be unsigned without causing any backward compatibility problems. Regards, Monty -- MySQL Internals Mailing List For list archives: http://lists.mysql.com/internals To unsubscribe: http://lists.mysql.com/internals