17 messages in com.mysql.lists.bugsRe: int unsigned subtraction problem| From | Sent On | Attachments |
|---|---|---|
| gr...@acm.org | 24 Jan 2002 16:22 | |
| Sinisa Milivojevic | 25 Jan 2002 02:49 | |
| Michael Widenius | 25 Jan 2002 04:11 | |
| Alexander Keremidarski | 25 Jan 2002 04:20 | |
| Alexander Keremidarski | 25 Jan 2002 04:36 | |
| Michael Widenius | 26 Jan 2002 07:37 | |
| Michael Widenius | 26 Jan 2002 07:51 | |
| Alexander Keremidarski | 28 Jan 2002 02:54 | |
| Michael Widenius | 28 Jan 2002 18:12 | |
| Colin Faber | 28 Jan 2002 19:05 | |
| Alexander Keremidarski | 29 Jan 2002 04:14 | |
| Michael Widenius | 29 Jan 2002 04:54 | |
| Michael Widenius | 29 Jan 2002 17:53 | |
| SDiZ (UHome) | 30 Jan 2002 00:43 | |
| Alexander Keremidarski | 30 Jan 2002 04:36 | |
| Michael Widenius | 31 Jan 2002 08:59 | |
| Michael Widenius | 26 Feb 2002 02:07 |
| Subject: | Re: int unsigned subtraction problem![]() |
|---|---|
| From: | Alexander Keremidarski (sal...@online.bg) |
| Date: | 01/30/2002 04:36:32 AM |
| List: | com.mysql.lists.bugs |
Michael Widenius wrote: Hi again, (and last time in this thread I hope)
Hi!
In unsigned arithmetic, it's completely normal that:
<cut>
This is not a wrong answer, this is the RIGHT answer. (as long as we assume 64 bit arithmetic)
<cut>
If we would not do this with unsigned arithmetic, the above would return -3, which is also wrong!
<cut>
You may argue that it's more 'common that you get a problem around 0 than around 2<<63, but this doesn't change the fact.
Yes I can, but this will never change your mind because we use different definitions :)
If we would do unsigned arithmetic in any other way than we are doing it now, the arithmetic rules would be inconsistent and would make it much harder for the user to figure out what is the right answer.
The whole question here is that you don't like how unsigned values work and you think they are 'illogical' when it comes to subtraction. I tend to agree, but it still not worth to break the arithmetic rules just because of this.
The major reason you should declare something as 'unsigned' is that you want to use the bigger positive range the unsigned value gives you. If we would change the rules for how arithmetic works, you would not get this benefit.
Hmm.... Difference again. Let me think. Maybe this is just matter of style and habits. My reason is usually 'don't use more than you need' i.e. If you never need negative values use unsigned. If you don't need > 5 letters char use char(5) and so on.
I always use (and recommend) create ... id int unsigned auto_increment primary key ...; Not because of range, but because I don't see the reason of signed auto_increment . Is my logic about auto_increment correct? I don't argue. I would like to know what do you think.
<cut>
Alexander> Again against SQL server nature.
No; This IS according to the SQL server nature. To have not consistent arithmetic would be going against the SQL server nature.
Strange. I am sure we both will agree MySQL is not calculator nor spreadsheet but DB server. How it happens we discuss arithmetics all the time?
I do however understand the concern of having to change old applications. (During the time MySQL 4.0.1 has been out, we have however only got 1 bug report regarding this, so this is not REALLY critical but...)
I have now for 4.0.2 added the following startup option:
--sql-mode=NO_UNSIGNED_SUBTRACTION
If you use this, then MySQL will not regard the result from a subtraction as unsigned.
Is this enough for your needs ?
My needs? :) With all my respect Monty we are talking about MySQL not SalleSQL :)
I don't want to see ./configure --with-salle-support or runtime --sql-mode=salle_sql_mode
then you will be asked to implement option: --who-the-***-is-salle :)
I'm regular user after all and try to represent users point of view.
P.S.
Honestly I would like to see options like: --with-statistics --with-transactions (for MyISAM) --with-stored-procedures=path_to_language_interpreter --with-cluster-support --with-rawdisks --with-....
but that's another story
Best regards




