1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Produce a "truncated" warning if a value cannot be converted

into the column character set on INSERT/UPDATE.


sql/sql_string.cc:
  New argument to report an error.
sql/sql_string.h:
  New argument to report an error.
This commit is contained in:
unknown
2004-10-28 15:21:20 +05:00
parent 9b041682cc
commit 5be6c328f5
8 changed files with 66 additions and 16 deletions

View File

@ -349,6 +349,7 @@ alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
a hex(a)
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
delete from t1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (

View File

@ -166,3 +166,11 @@ ERROR HY000: Invalid utf8 character string: '
SET NAMES utf8;
CREATE TABLE `good<6F><64><EFBFBD><EFBFBD><EFBFBD>` (a int);
ERROR HY000: Invalid utf8 character string: '<27><><EFBFBD><EFBFBD><EFBFBD>` (a int)'
set names latin1;
create table t1 (a char(10) character set koi8r, b text character set koi8r);
insert into t1 values ('test','test');
insert into t1 values ('<27><><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD>');
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'b' at row 1
drop table t1;

View File

@ -356,6 +356,11 @@ SELECT t, collation(t),MATCH t AGAINST ('Osnabruck') FROM t1 WHERE MATCH t AGAIN
t collation(t) MATCH t AGAINST ('Osnabruck')
aus Osnabr<62>ck utf8_general_ci 1.591139793396
alter table t1 modify t varchar(200) collate latin1_german2_ci not null;
Warnings:
Warning 1265 Data truncated for column 't' at row 3
Warning 1265 Data truncated for column 't' at row 4
Warning 1265 Data truncated for column 't' at row 5
Warning 1265 Data truncated for column 't' at row 6
SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabr<62>ck');
t collation(t)
aus Osnabr<62>ck latin1_german2_ci

View File

@ -207,6 +207,7 @@ alter table t1 change a a text character set cp1251;
select a,hex(a) from t1;
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
delete from t1;
#
# Test ALTER TABLE .. CHARACTER SET ..

View File

@ -121,3 +121,13 @@ CREATE TABLE `good
SET NAMES utf8;
--error 1300
CREATE TABLE `good<6F><64><EFBFBD><EFBFBD><EFBFBD>` (a int);
#
# Test that we produce a warnign when conversion loses data.
#
set names latin1;
create table t1 (a char(10) character set koi8r, b text character set koi8r);
insert into t1 values ('test','test');
insert into t1 values ('<27><><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD>');
drop table t1;