dbTalk Databases Forums  

last_insert_id() should return ulonglong, but is longlong

mailing.database.mysql-internals mailing.database.mysql-internals


Discuss last_insert_id() should return ulonglong, but is longlong in the mailing.database.mysql-internals forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dvir Azulay
 
Posts: n/a

Default last_insert_id() should return ulonglong, but is longlong - 05-31-2012 , 12:05 PM






Hello, this is my first time on this mailing list so I hope I'm on the
right place.

Last night I encountered an issue with LAST_INSERT_ID(), when my ID
column is an UNSIGNED BIGINT; the return value was a SIGNED BIGINT.

So I looked at the source code and saw this line:
*longlong Item_func_last_insert_id::val_int()

When in other places, it was referred to as ulonglong, here it is
longlong. (When it should be ulonglong of course).

Is this correct or am I looking at the wrong place?

--
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe: http://lists.mysql.com/internals

Reply With Quote
  #2  
Old   
Michael Widenius
 
Posts: n/a

Default re: last_insert_id() should return ulonglong, but is longlong - 06-08-2012 , 02:00 PM






Hi!

Quote:
"Dvir" == Dvir Azulay <dvir.azulay (AT) gmail (DOT) com> 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

Reply With Quote
  #3  
Old   
Michael Widenius
 
Posts: n/a

Default re: last_insert_id() should return ulonglong, but is longlong - 06-08-2012 , 02:15 PM



Hi!

Quote:
"Dvir" == Dvir Azulay <dvir.azulay (AT) gmail (DOT) com> 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?

Now fixed and pushed into MariaDB 5.5

Regards,
Monty

--
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe: http://lists.mysql.com/internals

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.