@@ -491,6 +491,91 @@ public void UsingUtf32()
491
491
}
492
492
493
493
494
+
495
+ /// <summary>
496
+ /// Test for new functionality on 5.7.9 supporting chinese character sets gb18030
497
+ /// WL #4024
498
+ /// (Oracle bug #21098546).
499
+ /// </summary>
500
+ [ Fact ]
501
+ public void CanInsertChineseCharacterSetGB18030 ( )
502
+ {
503
+ if ( st . Version < new Version ( 5 , 7 , 4 ) ) return ;
504
+
505
+ try
506
+ {
507
+ st . execSQL ( "CREATE TABLE Test (id int, name VARCHAR(100) CHAR SET gb18030, KEY(name(20)))" ) ;
508
+ using ( MySqlConnection c = new MySqlConnection ( st . conn . ConnectionString + ";charset=gb18030" ) )
509
+ {
510
+ c . Open ( ) ;
511
+ MySqlCommand cmd = new MySqlCommand ( "INSERT INTO Test VALUES(1, '㭋玤䂜蚌')" , c ) ;
512
+ cmd . ExecuteNonQuery ( ) ;
513
+ cmd = new MySqlCommand ( "INSERT INTO test VALUES(2, 0xC4EEC5ABBDBFA1A4B3E0B1DABBB3B9C520A1A4CBD5B6ABC6C2)" , c ) ;
514
+ cmd . ExecuteNonQuery ( ) ;
515
+ cmd = new MySqlCommand ( "SELECT id, name from test" , c ) ;
516
+ var reader = cmd . ExecuteReader ( ) ;
517
+ while ( reader . Read ( ) )
518
+ {
519
+ if ( reader . GetUInt32 ( 0 ) == 1 )
520
+ Assert . Equal ( "㭋玤䂜蚌" , reader . GetString ( 1 ) ) ;
521
+ if ( reader . GetUInt32 ( 0 ) == 2 )
522
+ Assert . Equal ( "念奴娇·赤壁怀古 ·苏东坡" , reader . GetString ( 1 ) ) ;
523
+ }
524
+ }
525
+ }
526
+ finally
527
+ {
528
+ st . execSQL ( "drop table if exists `Test`" ) ;
529
+ }
530
+ }
531
+
532
+
533
+
534
+ /// <summary>
535
+ /// Test for new functionality on 5.7.9 supporting chinese character sets on gb18030
536
+ /// WL #4024
537
+ /// (Oracle bug #21098546).
538
+ /// </summary>
539
+ [ Fact ]
540
+ public void CanCreateDbUsingChineseCharacterSetGB18030 ( )
541
+ {
542
+ if ( st . Version < new Version ( 5 , 7 , 4 ) ) return ;
543
+
544
+ MySqlConnectionStringBuilder rootSb = new MySqlConnectionStringBuilder ( st . rootConn . ConnectionString ) ;
545
+ rootSb . CharacterSet = "gb18030" ;
546
+ using ( MySqlConnection rootConnection = new MySqlConnection ( rootSb . ToString ( ) ) )
547
+ {
548
+ string database = "㭋玤䂜蚌" ;
549
+
550
+ rootConnection . Open ( ) ;
551
+ MySqlCommand rootCommand = new MySqlCommand ( ) ;
552
+ rootCommand . Connection = rootConnection ;
553
+ rootCommand . CommandText = string . Format ( "CREATE DATABASE `{0}` CHARSET=gb18030;" , database ) ;
554
+ rootCommand . ExecuteNonQuery ( ) ;
555
+
556
+ try
557
+ {
558
+ rootSb . Database = database ;
559
+ using ( MySqlConnection conn = new MySqlConnection ( rootSb . ConnectionString ) )
560
+ {
561
+ conn . Open ( ) ;
562
+ Assert . Equal ( database , conn . Database ) ;
563
+ }
564
+ }
565
+ finally
566
+ {
567
+ if ( rootConnection . State == ConnectionState . Open )
568
+ {
569
+ rootCommand . CommandText = string . Format ( "DROP DATABASE `{0}`;" , database ) ;
570
+ rootCommand . ExecuteNonQuery ( ) ;
571
+ }
572
+ }
573
+ }
574
+ }
575
+
576
+
577
+
578
+
494
579
public void Dispose ( )
495
580
{
496
581
st . execSQL ( "DROP TABLE IF EXISTS TEST" ) ;
0 commit comments