List:General Discussion« Previous MessageNext Message »
From:Gleb Paharenko Date:October 19 2005 11:16am
Subject:Re: ALTER TABLE - how to fix truncated data?
View as plain text  
Hello.

> If a value doesn't fit (in the "domain" of "tinyint"), an exception
> should be raised. Plain and simple.

MySQL 5.0 has this ability. Check STRICT_ALL_TABLES and
STRICT_TRANS_TABLES SQL modes at:

  http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html








>>  CREATE TEMPORARY TABLE t1 (
>>    i TINYINT
>>  );
>>
>>  INSERT INTO  t1 VALUES (42);
>>
>>  SELECT * FROM t1;
>>  -- Ok, shows 42
>>
>>  UPDATE t1 SET i = 4242;
>>  -- SHOW WARNINGS;
>>
>>  SELECT * FROM t1;
>>  -- Oops, shows 127
> 
> 
> Yeah, total rubbish.
> 
> Do this in your application - by accident - and explain your
> boss that the totals are wrong or that he had an input value
> of "4242" and got "127" in return. Rubbish.
> 
> If a value doesn't fit (in the "domain" of "tinyint"), an exception
> should be raised. Plain and simple.
> 
> With regards,
> 
> Martijn Tonies
> Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
> Server
> Upscene Productions
> http://www.upscene.com
> Database development questions? Check the forum!
> http://www.databasedevelopmentforum.com
> 
> 


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   Gleb.Paharenko@stripped
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
       <___/   www.mysql.com



Thread
ALTER TABLE - how to fix truncated data?Jim Seymour17 Oct
  • Re: ALTER TABLE - how to fix truncated data?Gleb Paharenko18 Oct
  • Re: ALTER TABLE - how to fix truncated data?Martijn Tonies18 Oct
    • Re: ALTER TABLE - how to fix truncated data?Gleb Paharenko18 Oct
  • Re: ALTER TABLE - how to fix truncated data?Martijn Tonies19 Oct
  • Re: ALTER TABLE - how to fix truncated data?Harald Fuchs19 Oct
  • Re: ALTER TABLE - how to fix truncated data?Martijn Tonies19 Oct
    • Re: ALTER TABLE - how to fix truncated data?Jigal van Hemert19 Oct
    • Re: ALTER TABLE - how to fix truncated data?Gleb Paharenko19 Oct
  • Re: ALTER TABLE - how to fix truncated data?Martijn Tonies19 Oct