Oracle 5.0 Reference Manual page 171

Table of Contents

Advertisement

• Incompatible change: By default, integer subtraction involving an unsigned value should produce
an unsigned result. Tracking of the "unsignedness" of an expression was improved in MySQL 5.0.13.
This means that, in some cases where an unsigned subtraction would have resulted in a signed
integer, it now results in an unsigned integer. One context in which this difference manifests itself is
when a subtraction involving an unsigned operand would be negative.
Suppose that
is a
i
TINYINT UNSIGNED
following expression using 64-bit unsigned integer arithmetic with the following result:
mysql>
SELECT i - 1 FROM t;
+----------------------+
| i - 1
+----------------------+
| 18446744073709551615 |
+----------------------+
If the expression is used in an
and the result assigned to
range or 0 to 255. That is, the value is clipped to the nearest endpoint of the range. However, the
result is version-specific:
• Before MySQL 5.0.13, the expression is evaluated but is treated as the equivalent 64-bit signed
value (–1) for the assignment. The value of –1 is clipped to the nearest endpoint of the column
range, resulting in a value of 0:
mysql>
UPDATE t SET i = i - 1; SELECT i FROM t;
+------+
| i
|
+------+
|
0 |
+------+
• As of MySQL 5.0.13, the expression is evaluated and retains its unsigned attribute for the
assignment. The value of 18446744073709551615 is clipped to the nearest endpoint of the
column range, resulting in a value of 255:
mysql>
UPDATE t SET i = i - 1; SELECT i FROM t;
+------+
| i
|
+------+
|
255 |
+------+
To get the older behavior, use
UPDATE t SET i = CAST(i - 1 AS SIGNED);
Alternatively, set the
integer subtractions involving unsigned values.
• Incompatible change: Before MySQL 5.0.12,
same value (the time at which the statement in which the function occurs begins executing). As
of MySQL 5.0.12,
SYSDATE()
the value returned by
replication, and use of indexes, see the description for
and Time Functions"
behavior for
SYSDATE()
the
--sysdate-is-now
• Incompatible change: Before MySQL 5.0.13,
[879]
LEAST(x,NULL)
if any argument is NULL, the same as Oracle. This change can cause problems for applications
NULL
that rely on the old behavior.
Upgrading MySQL
column and has a value of 0. The server evaluates the
|
UPDATE t SET i = i - 1
according to the usual rules for handling values outside the column
i
[948]
CAST()
NO_UNSIGNED_SUBTRACTION
[928]
returns the time at which it executes, which can differ from
[926]. For information about the implications for binary logging,
NOW()
and for
SET TIMESTAMP
[928]
and cause it to be an alias for
[423]
option (available as of MySQL 5.0.20).
return
when
is a
x
x
151
statement, the expression is evaluated
to convert the expression result to a signed value:
[537]
SQL mode. However, this will affect all
[926]
and
NOW()
SYSDATE()
SYSDATE()
in
Section 13.7.4,
"SET
NOW()
GREATEST(x,NULL)
non-NULL
value. As of 5.0.13, both functions return
[928]
return the
[928]
in
Section 12.7, "Date
Syntax". To restore the former
[926], start the server with
[878]
and

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents