mysql max integer value

uint16 handling is broken

care to cite examples

really? do i need to show that unsigned integers are broken?

Yes really… making a statement without supporting it does nobody any good. If they were so obviously “broken” then there would be a fire-storm of complaints…
So without that , I am forced to assume one of 3 things.

  • there is nothing wrong
  • you did in fact find an “edge case” that has not affected others in the past
  • you don’t understand how/what is supposed to be happening … we already identified that there probably is an issue with the database interface… but you last statement was very specific to “UInt”…

I think that the issue that Alexandre is running into is this:

for i as UInt8 = 10 downto 0 system.debuglog str(i) if i = 255 then exit // Will loop endlessly without an exit next

After i reaches 0 it loops back around to 255 (or 65535 in the case of UInt16), so the for loop will run endlessly.
Now, i’m not sure if this is an inherent limitation of trying to use unsigned integers in for loops that iterate down to 0, or if it is a specifically a Xojo bug.

[quote=387956:@Jared Feder]I think that the issue that Alexandre is running into is this:

for i as UInt8 = 10 downto 0 system.debuglog str(i) if i = 255 then exit // Will loop endlessly without an exit next

After i reaches 0 it loops back around to 255 (or 65535 in the case of UInt16), so the for loop will run endlessly.
Now, i’m not sure if this is an inherent limitation of trying to use unsigned integers in for loops that iterate down to 0, or if it is a specifically a Xojo bug.[/quote]

thank you so much.

I thought I was so stupid that I could not even discover a bug so unacceptable.

[quote=387916:@Dave S]Yes really… making a statement without supporting it does nobody any good. If they were so obviously “broken” then there would be a fire-storm of complaints…
So without that , I am forced to assume one of 3 things.

  • there is nothing wrong
  • you did in fact find an “edge case” that has not affected others in the past
  • you don’t understand how/what is supposed to be happening … we already identified that there probably is an issue with the database interface… but you last statement was very specific to “UInt”…[/quote]

Nothing wrong???

Really?

Did you tried to “max(id)” from a mysql database where this id are unsigned tinyint??…

Did you?…

Do you think i’m here wasting my time?

Believe me, i have a lot of more important things to do than beg for you (xojo.inc) to correct an absurd bug, and the only workaround would be change all the columns on mysql to INT

Nothing wrong…?!?!??!?!

[quote=388040:@Alexandre Cunha]Nothing wrong???

Really?

Did you tried to “max(id)” from a mysql database where this id are unsigned tinyint??…

Did you?…

Do you think i’m here wasting my time?

Believe me, i have a lot of more important things to do than beg for you (xojo.inc) to correct an absurd bug, and the only workaround would be change all the columns on mysql to INT

Nothing wrong…?!?!??!?![/quote]
This is not productive.

I created the feedback on 2015 about the “infinite for next” but

Now i discovered another bug, now with mysql unsigned tinyint.

It’s much more problematic than the other. The older one, it’s simple. just put an if inside the “for next”. Done

But the mysql problem is really serious. it’s insane i think i’ll need to change my mysql structures, relations, indexes because a xojo bug!

No way!

Care to explain why you use UInt8 in a loop ?

Is there’s a difference in your application using UInt8 instead of Integer ?
(or for your user)

[quote=387956:@Jared Feder]I think that the issue that Alexandre is running into is this:

for i as UInt8 = 10 downto 0 system.debuglog str(i) if i = 255 then exit // Will loop endlessly without an exit next

After i reaches 0 it loops back around to 255 (or 65535 in the case of UInt16), so the for loop will run endlessly.
Now, i’m not sure if this is an inherent limitation of trying to use unsigned integers in for loops that iterate down to 0, or if it is a specifically a Xojo bug.[/quote]

If you think about how FOR/NEXT works. this result is in no way surprising…
The DOWNTO loop terminates, when at the NEXT the value of I is LESS than the specified end.
it can be expressed this way

i=10
while I>=0 
  system.debuglog str(i)
  if i = 255 then exit  // Will loop endlessly without an exit
i=i-1  ///  ZERO - 1 causes the roll over, hence endless loop, as I can never be less than zero
wend

This is NOT a bug, this is how Xojo and any other language would react in the same circumstance

This is an inherent limitation of unsigned integers in for loops that iterate down to 0. It qualifies as a coding error, not a bug in the framework. I cannot comment on the database related issues.

You’d encounter the same kind of error with this loop, too.

for n as uint8 = 0 to 255
    ...
next

The loop doesn’t exit until n is greater than 255, which it cannot ever be.

That is the reason why I made feature request to check condition before increment.
It fixes those nasty bugs we can run into.

You might be able to use CAST to convert to a larger unsigned something like:

select cast(max(id) as unsigned) as id from zendesk

yes, it is a bug.
it works perfectly on uint32 or uint64.

And the problem aren’t talked here, when i get a value from mysql (unsigned tinyint) it’s buggy!
this is the big problem. I CAN’T CHANGE MY MYSQL STRUCTURE because of a XOJO bug dealing with unsigned values from mysql

Ok… you think it is a bug, despite having multiple people explain exactly what is happening, then there is nothing more to say.

But I do suggest you study Boolean Arithmetic…

I’m done here, and removing this topic…

I think you guys are talking past each other, partly because there are 2 distinct and unrelated issues being discussed.

  1. Unsigned int in a for loop - not a bug.
  2. Unsigned smallint in a mysql database doesn’t return an unsigned value - sounds like a bug.

Good to hear this!
Got mad searching an error in my source…
Just changed from MS SQL Server to MySQL and found that annoying error…

Had to use .StringValue and convert it then in Xojo.

Thanks a lot for discussing and clarifying this!

hummm… i’ll try this workaround!