开发者

mySQL 5.0.45 LAST_INSERT_ID() and values larger than a signed int

I'm attempting to use LAST_INSERT_ID on an auto incremented index that has moved past the signed int value 2147483647. This column is an unsigned int. However, LAST_INSERT_ID() is returning an invalid negative value. Researching this, I've found a couple comments indicating this is the nature of this function. But I cannot find it officially documented. There are some bug reports dating ba开发者_如何学编程ck several years that are still open.

So I need to know if this is in fact a known bug and/or if there's something I can do about this. Do I need to upgrade mySQL to a newer version?


I'm not 100% sure on this, but since you just need the ID and not to do any mathematical operations on it, could you perhaps process it as a string and have your select statement convert the number to a string?


I'm assuming you are using PHP from the comments on the question. (is not currently tagged as "php" related). I'll just add my 2 cents here

I'm attempting to use LAST_INSERT_ID on an auto incremented index that has moved past the signed int value 2147483647. This column is an unsigned int. However, LAST_INSERT_ID() is returning an invalid negative value. Researching this, I've found a couple comments indicating this is the nature of this function. But I cannot find it officially documented. There are some bug reports dating back several years that are still open.

mySQL's LAST_INSERT_ID function will return the ID from the latest INSERT on an AUTO_INCREMENT column (on the current connection) so, if your column is an INTEGER UNSIGNED like you said, it could return values greater than 2147483647. This is the correct behavior.

So I need to know if this is in fact a known bug and/or if there's something I can do about this. Do I need to upgrade mySQL to a newer version?

The mySQL data type has little to do with the representation you chose to use on PHP so the problema is not in the mySQL server. If your PHP installation can't handle numbers so BIG, then you can treat it as a string (Shadow Radiance said).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜