-- source include/have_gbk.inc

#
# Tests with the gbk character set
#
--disable_warnings
drop table if exists t1;
--enable_warnings

SET @test_character_set= 'gbk';
SET @test_collation= 'gbk_chinese_ci';
-- source include/ctype_common.inc

SET NAMES gbk;
SET collation_connection='gbk_chinese_ci';
-- source include/ctype_filesort.inc
-- source include/ctype_innodb_like.inc
-- source include/ctype_like_escape.inc
-- source include/ctype_like_range_f1f2.inc
-- source include/ctype_ascii_order.inc
SET collation_connection='gbk_bin';
-- source include/ctype_filesort.inc
-- source include/ctype_innodb_like.inc
-- source include/ctype_like_escape.inc
-- source include/ctype_like_range_f1f2.inc

#
# Bug#11987 mysql will truncate the text when
# the text contain GBK char:"0xA3A0" and "0xA1"
#
SET NAMES gbk;
CREATE TABLE t1 (a text) character set gbk;
INSERT INTO t1 VALUES (0xA3A0),(0xA1A1);
SELECT hex(a) FROM t1 ORDER BY a;
DROP TABLE t1;

#
# Bugs#15375: Unassigned multibyte codes are broken
# into parts when converting to Unicode.
# This query should return 0x003F0041. I.e. it should
# scan unassigned double-byte character 0xA140, convert
# it as QUESTION MARK 0x003F and then scan the next
# character, which is a single byte character 0x41.
#
select hex(convert(_gbk 0xA14041 using ucs2));

# End of 4.1 tests

#
# Bug#21620 ALTER TABLE affects other columns
#
create table t1 (c1 text not null, c2 text not null) character set gbk;
alter table t1 change c1 c1 mediumtext  character set gbk not null;
show create table t1;
drop table t1;

#
# Bug#35993: severe memory corruption and crash with multibyte conversion
#

CREATE TABLE t1(a MEDIUMTEXT CHARACTER SET gbk,
                b MEDIUMTEXT CHARACTER SET big5);
INSERT INTO t1 VALUES
  (REPEAT(0x1125,200000), REPEAT(0x1125,200000)), ('', ''), ('', '');

SELECT a FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll;
SELECT b FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll;

DROP TABLES t1;

--echo End of 5.0 tests


set names gbk;
--source include/weight_string.inc
--source include/weight_string_l1.inc
--source include/weight_string_A1A1.inc
--source include/weight_string_8140.inc
--source include/weight_string_8EA1.inc

set collation_connection=gbk_bin;
--source include/weight_string.inc
--source include/weight_string_l1.inc
--source include/weight_string_A1A1.inc
--source include/weight_string_8140.inc
--source include/weight_string_8EA1.inc
