pingcap/tidb

unexpect error result when insert too long data with unimportant suffix to varchar column

Open

#8 280 ouverte le 12 nov. 2018

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)Go (6 186 forks)batch import
help wantedpriority/P4sig/executiontype/compatibility

Métriques du dépôt

Stars
 (40 090 stars)
Métriques de merge PR
 (Merge moyen 14j 4h) (346 PRs mergées en 30 j)

Description

Bug Report

  1. What did you do? If possible, provide a recipe for reproducing the error.
CREATE TABLE `history1` (
  `h_c_id` int(11) DEFAULT NULL,
  `h_c_d_id` tinyint(4) DEFAULT NULL,
  `h_c_w_id` smallint(6) DEFAULT NULL,
  `h_d_id` tinyint(4) DEFAULT NULL,
  `h_w_id` smallint(6) DEFAULT NULL,
  `h_date` datetime DEFAULT NULL,
  `h_amount` decimal(6,2) DEFAULT NULL,
  `h_data` varchar(24) DEFAULT NULL,
  KEY `fkey_history_11` (`h_c_w_id`,`h_c_d_id`,`h_c_id`),
  KEY `fkey_history_21` (`h_w_id`,`h_d_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

set sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

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 (1,3,1450,1,3,NOW(),3242,'name-rwmwt name-uzqka       ');
  1. What did you expect to see?
Query OK, 1 row affected, 1 warning (0.01 sec)

mysql> show warnings;
+-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                                                   |
+-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'warning' at line 1 |
+-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
  1. What did you see instead?
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 (1,3,1450,1,3,NOW(),3242,'name-rwmwt name-uzqka       ');
ERROR 1406 (22001): Data too long for column 'h_data' at row 1
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
Git Commit Hash: None
Git Branch: None
UTC Build Time: None
GoVersion: None
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false

Guide contributeur