Insert of string in int column does not report error
am 21.05.2003 13:42:07 von lars-goran.forsberg
I am running MySQL 4.0.12 on Windows 2000.
If I insert a string value in an int column (MyISAM table), it silently
converts the string value to 0, and does not report an error.
Example:
mysql> create table asdf(asdf int, fdsa varchar(10));
Query OK, 0 rows affected (0.18 sec)
mysql> insert into asdf(asdf, fdsa) values('asdf', 2);
Query OK, 1 row affected (0.07 sec)
mysql> select * from asdf;
+------+------+
| asdf | fdsa |
+------+------+
| 0 | 2 |
+------+------+
2 rows in set (0.01 sec)
Regards,
Lars-Göran Forsberg
____________________________________________________________ ____________
> lars-göran forsberg > software engineer
> incomit ab > p.o. box 83 > se-651 03 karlstad > sweden
> phone +46 54 17 67 36 > fax + 46 54 17 67 99
> lars-goran.forsberg@incomit.com > www.incomit.com
____________________________________________________________ ____________
--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org
Re: Insert of string in int column does not report error
am 21.05.2003 13:59:27 von Lenz Grimmer
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wed, 21 May 2003, Lars-Göran Forsberg wrote:
> I am running MySQL 4.0.12 on Windows 2000.
>
> If I insert a string value in an int column (MyISAM table), it silently
> converts the string value to 0, and does not report an error.
>
> Example:
>
> mysql> create table asdf(asdf int, fdsa varchar(10));
> Query OK, 0 rows affected (0.18 sec)
>
> mysql> insert into asdf(asdf, fdsa) values('asdf', 2);
> Query OK, 1 row affected (0.07 sec)
>
> mysql> select * from asdf;
> +------+------+
> | asdf | fdsa |
> +------+------+
> | 0 | 2 |
> +------+------+
> 2 rows in set (0.01 sec)
This is documented behaviour:
http://www.mysql.com/doc/en/INSERT.html
"Setting a numeric column to a value such as '10.34 a'. The trailing
garbage is stripped and the remaining numeric part is inserted. If the
value doesn't make sense as a number at all, the column is set to 0."
Bye,
=09LenZ
- --=20
For technical support contracts, visit https://order.mysql.com/?ref=3Dmlgr
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Lenz Grimmer
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Production Engineer
/_/ /_/\_, /___/\___\_\___/ Hamburg, Germany
<___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
Comment: For info see http://quantumlab.net/pine_privacy_guard/
iD8DBQE+y2ogSVDhKrJykfIRAtd5AJ9zudxLj7yEx04iOfq3rc+A5E8/SgCf Rl4p
NWmRf5jxn2HnClmraVArh3I=3D
=3Dugym
-----END PGP SIGNATURE-----
--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=3Dgcdmb-bugs@m.gmane.org