Description:
I have a memory table with the following structure:
+------------------+---------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+---------------+------+-----+---------------------+----------------+
| id_fisa_cont | bigint(20) | NO | PRI | NULL | auto_increment |
| data | datetime | YES | MUL | 0000-00-00 00:00:00 | |
| numar | varchar(100) | YES | | | |
| suma | double(19,7) | YES | | 0.0000000 | |
| din_care | double(19,7) | YES | | 0.0000000 | |
| suma_achitata | double(19,7) | YES | | 0.0000000 | |
| termen | datetime | YES | | 0000-00-00 00:00:00 | |
| data_inchidere | datetime | YES | | 0000-00-00 00:00:00 | |
| zile | mediumint(5) | YES | | 0 | |
| id_client | bigint(20) | YES | MUL | -1 | |
| reserved | varchar(100) | YES | MUL | | |
| ts | timestamp | NO | | CURRENT_TIMESTAMP | |
| id_factura | bigint(20) | YES | | -1 | |
| id_factura_plata | bigint(20) | YES | | -1 | |
| banca | varchar(3) | YES | | | |
| curs | float(9,3) | YES | | 0.000 | |
| fise_casare | varchar(5000) | YES | | | |
+------------------+---------------+------+-----+---------------------+----------------+
I inserted a row in it, I altered the table (the NUMAR column) and all the data was messed up.
How to repeat:
mysql> CREATE TABLE `fisa_cont` (
`id_fisa_cont` bigint(20) NOT NULL AUTO_INCREMENT,
`data` datetime DEFAULT '0000-00-00 00:00:00',
`numar` varchar(100) DEFAULT '',
`suma` double(19,7) DEFAULT '0.0000000',
`din_care` double(19,7) DEFAULT '0.0000000',
`suma_achitata` double(19,7) DEFAULT '0.0000000',
`termen` datetime DEFAULT '0000-00-00 00:00:00',
`data_inchidere` datetime DEFAULT '0000-00-00 00:00:00',
`zile` mediumint(5) DEFAULT '0',
`id_client` bigint(20) DEFAULT '-1',
`reserved` varchar(100) DEFAULT '',
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`id_factura` bigint(20) DEFAULT '-1',
`id_factura_plata` bigint(20) DEFAULT '-1',
`banca` varchar(3) DEFAULT '',
`curs` float(9,3) DEFAULT '0.000',
`fise_casare` varchar(5000) DEFAULT '',
PRIMARY KEY (`id_fisa_cont`),
UNIQUE KEY `id_fisa_cont` (`id_fisa_cont`),
KEY `data` (`data`),
KEY `id_client` (`id_client`),
KEY `reserved` (`reserved`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
mysql> insert into fisa_cont(data, numar, suma, din_care, suma_achitata, termen, data_inchidere, zile, id_client, reserved, id_factura, id_factura_plata, banca, curs, fise_casare) values(now(), '99123499', 1000, 1000, 0, now(), now(), 0, -1, '00003root#192.168.0.3', -1, -1, 'BNC', 2.5, '');
Query OK, 1 row affected (0.00 sec)
mysql> select * from fisa_cont;
+--------------+---------------------+----------+--------------+--------------+---------------+---------------------+---------------------+------+-----------+-----------------------+---------------------+------------+------------------+-------+-------+-------------+
| id_fisa_cont | data | numar | suma | din_care | suma_achitata | termen | data_inchidere | zile | id_client | reserved | ts | id_factura | id_factura_plata | banca | curs | fise_casare |
+--------------+---------------------+----------+--------------+--------------+---------------+---------------------+---------------------+------+-----------+-----------------------+---------------------+------------+------------------+-------+-------+-------------+
| 1 | 2007-02-05 14:28:52 | 99123499 | 1000.0000000 | 1000.0000000 | 0.0000000 | 2007-02-05 14:28:52 | 2007-02-05 14:28:52 | 0 | -1 | 00003root#192.168.0.3 | 2007-02-05 14:28:52 | -1 | -1 | BNC | 2.500 | |
+--------------+---------------------+----------+--------------+--------------+---------------+---------------------+---------------------+------+-----------+-----------------------+---------------------+------------+------------------+-------+-------+-------------+
mysql> select * from fisa_cont where reserved = '00003root#192.168.0.3';
+--------------+---------------------+----------+--------------+--------------+---------------+---------------------+---------------------+------+-----------+-----------------------+---------------------+------------+------------------+-------+-------+-------------+
| id_fisa_cont | data | numar | suma | din_care | suma_achitata | termen | data_inchidere | zile | id_client | reserved | ts | id_factura | id_factura_plata | banca | curs | fise_casare |
+--------------+---------------------+----------+--------------+--------------+---------------+---------------------+---------------------+------+-----------+-----------------------+---------------------+------------+------------------+-------+-------+-------------+
| 1 | 2007-02-05 14:28:52 | 99123499 | 1000.0000000 | 1000.0000000 | 0.0000000 | 2007-02-05 14:28:52 | 2007-02-05 14:28:52 | 0 | -1 | 00003root#192.168.0.3 | 2007-02-05 14:28:52 | -1 | -1 | BNC | 2.500 | |
+--------------+---------------------+----------+--------------+--------------+---------------+---------------------+---------------------+------+-----------+-----------------------+---------------------+------------+------------------+-------+-------+-------------+
mysql> alter table fisa_cont modify column numar varchar(150) default '';
Query OK, 0 rows affected (0.41 sec)
Records: 0 Duplicates: 0 Warnings: 0
(Notice the resul - 0 rows affected, although, there is one row in the table)
mysql> select suma from fisa_cont;
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| suma |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 127947429882512240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000000 |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+