You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug#21774967: MYSQL ACCEPTS NON-ASCII IN ASCII COLUMNS
This is caused by the code point check function shared by ascii and
other 8bit charsets. It actually doesn't check the code point. Fix
it by adding seperate code point check function for ascii. Give user
a warning message in current build. Will reject such kind of input
in future.
Reviewed-by: Roy Lyseng <roy.lyseng@oracle.com>
Reviewed-by: Tor Didriksen <tor.didriksen@oracle.com>
# Bug 21774967: MYSQL ACCEPTS NON-ASCII IN ASCII COLUMNS
420
+
CREATE TABLE t1(
421
+
a CHAR(20) CHARACTER SET ascii,
422
+
b VARCHAR(20) CHARACTER SET ascii,
423
+
c TEXT(20) CHARACTER SET ascii
424
+
);
425
+
CREATE TABLE t2(
426
+
a CHAR(20) CHARACTER SET ascii COLLATE ascii_general_ci,
427
+
b VARCHAR(20) CHARACTER SET ascii COLLATE ascii_general_ci,
428
+
c TEXT(20) CHARACTER SET ascii COLLATE ascii_general_ci
429
+
);
430
+
CREATE TABLE t3(
431
+
a CHAR(20) CHARACTER SET ascii COLLATE ascii_bin,
432
+
b VARCHAR(20) CHARACTER SET ascii COLLATE ascii_bin,
433
+
c TEXT(20) CHARACTER SET ascii COLLATE ascii_bin
434
+
);
435
+
SET SQL_MODE="STRICT_TRANS_TABLES";
436
+
Warnings:
437
+
Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
438
+
INSERT INTO t1 values(x'8142', x'8142', x'8142');
439
+
Warnings:
440
+
Warning 1300 Invalid ascii character string: '\x81B'
441
+
Warning 1300 Invalid ascii character string: '\x81B'
442
+
Warning 1300 Invalid ascii character string: '\x81B'
443
+
UPDATE t1 SET a=x'8243' where a=x'8142';
444
+
Warnings:
445
+
Warning 1300 Invalid ascii character string: '\x82C'
446
+
INSERT INTO t2 values(x'8142', x'8142', x'8142');
447
+
Warnings:
448
+
Warning 1300 Invalid ascii character string: '\x81B'
449
+
Warning 1300 Invalid ascii character string: '\x81B'
450
+
Warning 1300 Invalid ascii character string: '\x81B'
451
+
UPDATE t2 SET a=x'8243' where a=x'8142';
452
+
Warnings:
453
+
Warning 1300 Invalid ascii character string: '\x82C'
454
+
INSERT INTO t3 values(x'8142', x'8142', x'8142');
455
+
Warnings:
456
+
Warning 1300 Invalid ascii character string: '\x81B'
457
+
Warning 1300 Invalid ascii character string: '\x81B'
458
+
Warning 1300 Invalid ascii character string: '\x81B'
459
+
UPDATE t3 SET a=x'8243' where a=x'8142';
460
+
Warnings:
461
+
Warning 1300 Invalid ascii character string: '\x82C'
462
+
SET SQL_MODE="";
463
+
INSERT INTO t1 values(x'8142', x'8142', x'8142');
464
+
Warnings:
465
+
Warning 1300 Invalid ascii character string: '\x81B'
466
+
Warning 1300 Invalid ascii character string: '\x81B'
467
+
Warning 1300 Invalid ascii character string: '\x81B'
468
+
UPDATE t1 SET a=x'8243' where a=x'8142';
469
+
Warnings:
470
+
Warning 1300 Invalid ascii character string: '\x82C'
471
+
INSERT INTO t2 values(x'8142', x'8142', x'8142');
472
+
Warnings:
473
+
Warning 1300 Invalid ascii character string: '\x81B'
474
+
Warning 1300 Invalid ascii character string: '\x81B'
475
+
Warning 1300 Invalid ascii character string: '\x81B'
476
+
UPDATE t2 SET a=x'8243' where a=x'8142';
477
+
Warnings:
478
+
Warning 1300 Invalid ascii character string: '\x82C'
479
+
INSERT INTO t3 values(x'8142', x'8142', x'8142');
480
+
Warnings:
481
+
Warning 1300 Invalid ascii character string: '\x81B'
482
+
Warning 1300 Invalid ascii character string: '\x81B'
483
+
Warning 1300 Invalid ascii character string: '\x81B'
484
+
UPDATE t3 SET a=x'8243' where a=x'8142';
485
+
Warnings:
486
+
Warning 1300 Invalid ascii character string: '\x82C'
487
+
CREATE VIEW v1 AS SELECT * FROM t1;
488
+
CREATE VIEW v2 AS SELECT * FROM t2;
489
+
CREATE VIEW v3 AS SELECT * FROM t3;
490
+
SET SQL_MODE="STRICT_TRANS_TABLES";
491
+
Warnings:
492
+
Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
493
+
INSERT INTO v1 values(x'8142', x'8142', x'8142');
494
+
Warnings:
495
+
Warning 1300 Invalid ascii character string: '\x81B'
496
+
Warning 1300 Invalid ascii character string: '\x81B'
497
+
Warning 1300 Invalid ascii character string: '\x81B'
498
+
UPDATE v1 SET a=x'8243' where a=x'8142';
499
+
Warnings:
500
+
Warning 1300 Invalid ascii character string: '\x82C'
501
+
INSERT INTO v2 values(x'8142', x'8142', x'8142');
502
+
Warnings:
503
+
Warning 1300 Invalid ascii character string: '\x81B'
504
+
Warning 1300 Invalid ascii character string: '\x81B'
505
+
Warning 1300 Invalid ascii character string: '\x81B'
506
+
UPDATE v2 SET a=x'8243' where a=x'8142';
507
+
Warnings:
508
+
Warning 1300 Invalid ascii character string: '\x82C'
509
+
INSERT INTO v3 values(x'8142', x'8142', x'8142');
510
+
Warnings:
511
+
Warning 1300 Invalid ascii character string: '\x81B'
512
+
Warning 1300 Invalid ascii character string: '\x81B'
513
+
Warning 1300 Invalid ascii character string: '\x81B'
514
+
UPDATE v3 SET a=x'8243' where a=x'8142';
515
+
Warnings:
516
+
Warning 1300 Invalid ascii character string: '\x82C'
517
+
SET SQL_MODE="";
518
+
INSERT INTO v1 values(x'8142', x'8142', x'8142');
519
+
Warnings:
520
+
Warning 1300 Invalid ascii character string: '\x81B'
521
+
Warning 1300 Invalid ascii character string: '\x81B'
522
+
Warning 1300 Invalid ascii character string: '\x81B'
523
+
UPDATE v1 SET a=x'8243' where a=x'8142';
524
+
Warnings:
525
+
Warning 1300 Invalid ascii character string: '\x82C'
526
+
INSERT INTO v2 values(x'8142', x'8142', x'8142');
527
+
Warnings:
528
+
Warning 1300 Invalid ascii character string: '\x81B'
529
+
Warning 1300 Invalid ascii character string: '\x81B'
530
+
Warning 1300 Invalid ascii character string: '\x81B'
531
+
UPDATE v2 SET a=x'8243' where a=x'8142';
532
+
Warnings:
533
+
Warning 1300 Invalid ascii character string: '\x82C'
534
+
INSERT INTO v3 values(x'8142', x'8142', x'8142');
535
+
Warnings:
536
+
Warning 1300 Invalid ascii character string: '\x81B'
537
+
Warning 1300 Invalid ascii character string: '\x81B'
538
+
Warning 1300 Invalid ascii character string: '\x81B'
539
+
UPDATE v3 SET a=x'8243' where a=x'8142';
540
+
Warnings:
541
+
Warning 1300 Invalid ascii character string: '\x82C'
542
+
DROP VIEW v1;
543
+
DROP VIEW v2;
544
+
DROP VIEW v3;
545
+
DROP TABLE t1;
546
+
DROP TABLE t2;
547
+
DROP TABLE t3;
548
+
CREATE TABLE t_latin1(
549
+
a CHAR(20) CHARACTER SET latin1,
550
+
b VARCHAR(20) CHARACTER SET latin1,
551
+
c TEXT(20) CHARACTER SET latin1
552
+
);
553
+
CREATE TABLE t_gb2312(
554
+
a CHAR(20) CHARACTER SET gb2312,
555
+
b VARCHAR(20) CHARACTER SET gb2312,
556
+
c TEXT(20) CHARACTER SET gb2312
557
+
);
558
+
CREATE TABLE t_utf8(
559
+
a CHAR(20) CHARACTER SET utf8,
560
+
b VARCHAR(20) CHARACTER SET utf8,
561
+
c TEXT(20) CHARACTER SET utf8
562
+
);
563
+
SET SQL_MODE="STRICT_TRANS_TABLES";
564
+
Warnings:
565
+
Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
566
+
INSERT INTO t_latin1 values(x'f242', x'f242', x'f242');
567
+
UPDATE t_latin1 SET a=x'f343' where a=x'f242';
568
+
INSERT INTO t_gb2312 values(x'e5ac', x'e5ac', x'e5ac');
569
+
UPDATE t_gb2312 SET a=x'e6af' where a=x'e5ac';
570
+
INSERT INTO t_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad');
571
+
INSERT INTO t_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad');
572
+
ERROR HY000: Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1
573
+
UPDATE t_utf8 SET a=x'e69687' where a=x'e4b8ad';
574
+
UPDATE t_utf8 SET a=x'f69687' where a=x'e69687';
575
+
ERROR HY000: Incorrect string value: '\xF6\x96\x87' for column 'a' at row 1
576
+
SET SQL_MODE="";
577
+
INSERT INTO t_latin1 values(x'f242', x'f242', x'f242');
578
+
UPDATE t_latin1 SET a=x'f343' where a=x'f242';
579
+
INSERT INTO t_gb2312 values(x'e5ac', x'e5ac', x'e5ac');
580
+
UPDATE t_gb2312 SET a=x'e6af' where a=x'e5ac';
581
+
INSERT INTO t_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad');
582
+
INSERT INTO t_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad');
583
+
Warnings:
584
+
Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1
585
+
Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'b' at row 1
586
+
Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'c' at row 1
587
+
UPDATE t_utf8 SET a=x'e69687' where a=x'e4b8ad';
588
+
UPDATE t_utf8 SET a=x'f69687' where a=x'e69687';
589
+
Warnings:
590
+
Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 1
591
+
Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 2
592
+
CREATE VIEW v_latin1 AS SELECT * FROM t_latin1;
593
+
CREATE VIEW v_gb2312 AS SELECT * FROM t_gb2312;
594
+
CREATE VIEW v_utf8 AS SELECT * FROM t_utf8;
595
+
SET SQL_MODE="STRICT_TRANS_TABLES";
596
+
Warnings:
597
+
Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
598
+
INSERT INTO v_latin1 values(x'f242', x'f242', x'f242');
599
+
UPDATE v_latin1 SET a=x'f343' where a=x'f242';
600
+
INSERT INTO v_gb2312 values(x'e5ac', x'e5ac', x'e5ac');
601
+
UPDATE v_gb2312 SET a=x'e6af' where a=x'e5ac';
602
+
INSERT INTO v_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad');
603
+
INSERT INTO v_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad');
604
+
ERROR HY000: Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1
605
+
UPDATE v_utf8 SET a=x'e69687' where a=x'e4b8ad';
606
+
UPDATE v_utf8 SET a=x'f69687' where a=x'e69687';
607
+
ERROR HY000: Incorrect string value: '\xF6\x96\x87' for column 'a' at row 4
608
+
SET SQL_MODE="";
609
+
INSERT INTO v_latin1 values(x'f242', x'f242', x'f242');
610
+
UPDATE v_latin1 SET a=x'f343' where a=x'f242';
611
+
INSERT INTO v_gb2312 values(x'e5ac', x'e5ac', x'e5ac');
612
+
UPDATE v_gb2312 SET a=x'e6af' where a=x'e5ac';
613
+
INSERT INTO v_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad');
614
+
INSERT INTO v_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad');
615
+
Warnings:
616
+
Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1
617
+
Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'b' at row 1
618
+
Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'c' at row 1
619
+
UPDATE v_utf8 SET a=x'e69687' where a=x'e4b8ad';
620
+
UPDATE v_utf8 SET a=x'f69687' where a=x'e69687';
621
+
Warnings:
622
+
Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 4
623
+
Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 5
0 commit comments