Bug #6999 Traditional: Wrong SQLSTATE returned for string truncation
| Submitted: | 3 Dec 2004 23:15 | Modified: | 11 Mar 2005 16:45 |
|---|---|---|---|
| Reporter: | Trudy Pelzer | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 5.0.3-alpha-debug | OS: | Linux (SuSE 9.1) |
| Assigned to: | Ramil Kalimullin | CPU Architecture: | Any |
[14 Feb 2005 4:57]
Alexander Barkov
Ramil, Trudy,
what should happen on multiple inserts, with say
three values:
INSERT INTO varchar_3_column VALUES ('ok1'), ('too-long1'),('ok2');
I.e. the first and the last values fit into the column. Then second does not fit.
Which of them should be returned by a SELECT query afterwards?
Ramil, whatever happens, I suggest to cover this situation in the test.
As well as add a SELECT query after UPDATEs producing the error.
The patch looks fine for me. I vote OK to push after extending the test.
[1 Mar 2005 12:08]
Ramil Kalimullin
fixed in 5.0.3
[11 Mar 2005 16:45]
Paul DuBois
Noted in 5.0.3 changelog.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: Under sql_mode='traditional', too-long strings that are assigned to a CHAR/VARCHAR field must be rejected, with SQLSTATE 22001 "String data, right truncation". MySQL is correctly rejecting such assignments, but is returning the wrong SQLSTATE: 01000, which just means "warning" rather than "error". How to repeat: mysql> set sql_mode='traditional'; mysql> create table t1 (col1 char(5)); mysql> insert into t1 (col1) values ('hellobob'); ERROR 1265 (01000): Data truncated for column 'col1' at row 1 -- The action (rejection of INSERT) is correct, but the SQLSTATE must be 22001, which means "I've rejected this INSERT because there's an error". SQLSTATE 01000 just means "Warning: I've allowed this INSERT even though the string was too long". mysql> select * from t1; Empty set (0.00 sec)