Bug #30553 subtraction from 0 not working correctly

Submitted: 22 Aug 2007 4:08 Modified: 22 Sep 2007 7:31
Reporter: doug johnson Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Data Types Severity:S2 (Serious)
Version:4.1.19-standard OS:Linux (mysql-standard-4.1.19-pc-linux-gnu-i686-glibc23)
Assigned to: CPU Architecture:Any

[22 Aug 2007 4:08] doug johnson
Description:
when I execute this query (via php):

update sometable set somefield = somefield + 1 where condition...

it work (increments somefield) and if I do:

update sometable set somefield = somefield - 1 where condition...

it works as well (subtracts 1 from somefield) except when somefield starts out as 0. when somefield starts out as zero the result is -2 instead of -1 as expected.

I did a workaround by doing:

update sometable set somefield = somefield +- 1 where condition...

but I am sure that other people would miss this if they didnt test their results properly.

How to repeat:

update sometable set somefield = somefield - 1 where condition...

will return -2 if somefield starts out == 0

Suggested fix:
update sometable set somefield = somefield +- 1 where condition...

will give the desired result when the initial value of somefield == 0
[22 Aug 2007 7:31] Hartmut Holzgraefe
Hi,

could you provide real CREATE, INSERT and UPDATE statements 
for this problem?

I can't reproduce this using generic tables and statements
so we need to know your exact setup for this ...
[22 Sep 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.