Percona-Lab / sysbench-tpcc

Sysbench scripts to generate a tpcc-like workload for MySQL and PostgreSQL
Apache License 2.0
292 stars 104 forks source link

Data truncated for column 'h_data' at row #16

Open siddontang opened 5 years ago

siddontang commented 5 years ago

I find that the length of h_data field in the history table is 24.

mysql> desc history1;

+----------+--------------+------+------+---------+-------+
| Field    | Type         | Null | Key  | Default | Extra |
+----------+--------------+------+------+---------+-------+
| h_c_id   | int(11)      | YES  |      | NULL    |       |
| h_c_d_id | tinyint(4)   | YES  |      | NULL    |       |
| h_c_w_id | smallint(6)  | YES  | MUL  | NULL    |       |
| h_d_id   | tinyint(4)   | YES  |      | NULL    |       |
| h_w_id   | smallint(6)  | YES  | MUL  | NULL    |       |
| h_date   | datetime     | YES  |      | NULL    |       |
| h_amount | decimal(6,2) | YES  |      | NULL    |       |
| h_data   | varchar(24)  | YES  |      | NULL    |       |
+----------+--------------+------+------+---------+-------+
8 rows in set (0.00 sec)

but https://github.com/Percona-Lab/sysbench-tpcc/blob/master/tpcc_run.lua#L406 inserts a data which length is 25, so here we will meet a warning, I reproduce it in MySQL 5.7.

mysql> INSERT INTO history1 (h_c_d_id, h_c_w_id, h_c_id, h_d_id,  h_w_id, h_date, h_amount, h_data) VALUES (6,1,642,6,1,NOW(),5,'name-ussgn name-zamed    ');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+-------+------+---------------------------------------------+
| Level | Code | Message                                     |
+-------+------+---------------------------------------------+
| Note  | 1265 | Data truncated for column 'h_data' at row 1 |
+-------+------+---------------------------------------------+
1 row in set (0.00 sec)

Do we need to adjust to insert 24 chars or alert the history field length?