Re: ALTER TABLE - how to fix truncated data?

2005-10-19 Thread Martijn Tonies
Gleb, As a sidenote - shouldn't MySQL raise an error when data gets truncated? MySQL raises a warning after such ALTER operation. See: mysql create table dt(a decimal(4,1)); Query OK, 0 rows affected (0.01 sec) mysql insert into dt set a=999.1; Query OK, 1 row affected (0.00 sec)

Re: ALTER TABLE - how to fix truncated data?

2005-10-19 Thread Harald Fuchs
In article [EMAIL PROTECTED], Martijn Tonies [EMAIL PROTECTED] writes: mysql insert into dt set a=999.1; Query OK, 1 row affected (0.00 sec) mysql alter table dt change a a decimal(2,1); Query OK, 1 row affected, 1 warning (0.02 sec) Records: 1 Duplicates: 0 Warnings: 1 mysql show

Re: ALTER TABLE - how to fix truncated data?

2005-10-19 Thread Martijn Tonies
mysql insert into dt set a=999.1; Query OK, 1 row affected (0.00 sec) mysql alter table dt change a a decimal(2,1); Query OK, 1 row affected, 1 warning (0.02 sec) Records: 1 Duplicates: 0 Warnings: 1 mysql show warnings;

Re: ALTER TABLE - how to fix truncated data?

2005-10-19 Thread Jigal van Hemert
Martijn Tonies wrote: | Warning | 1264 | Out of range value adjusted for column 'a' at row 1 Could be me ... but isn't this a little too late? eg: AFTER you have lost your data? IMO, it should raise an error UNLESS you force it to truncate the data. This would contradict the MySQL design

Re: ALTER TABLE - how to fix truncated data?

2005-10-19 Thread Martijn Tonies
As a sidenote - shouldn't MySQL raise an error when data gets truncated? MySQL raises a warning after such ALTER operation. See: mysql create table dt(a decimal(4,1)); Query OK, 0 rows affected (0.01 sec) mysql insert into dt set a=999.1; Query OK, 1 row affected (0.00 sec) mysql

Re: ALTER TABLE - how to fix truncated data?

2005-10-19 Thread Gleb Paharenko
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

Re: ALTER TABLE - how to fix truncated data?

2005-10-18 Thread Gleb Paharenko
Hello. I don't think that it is possible to recover the data from the new table, because ALTER operation creates a new table and fills it with data (and truncates the data). But why did the system backup not help you? Could you describe the situation more in detail. If you haven't flushed

Re: ALTER TABLE - how to fix truncated data?

2005-10-18 Thread Martijn Tonies
Gleb, I don't think that it is possible to recover the data from the new table, because ALTER operation creates a new table and fills it with data (and truncates the data). But why did the system backup not help you? Could you describe the situation more in detail. If you haven't flushed you

Re: ALTER TABLE - how to fix truncated data?

2005-10-18 Thread Gleb Paharenko
Hello. As a sidenote - shouldn't MySQL raise an error when data gets truncated? MySQL raises a warning after such ALTER operation. See: mysql create table dt(a decimal(4,1)); Query OK, 0 rows affected (0.01 sec) mysql insert into dt set a=999.1; Query OK, 1 row affected (0.00 sec)