@@ -451,6 +451,36 @@ def test_encoding_utf8(self):
451
451
event = self .create_and_insert_value (create_query , insert_query )
452
452
self .assertMultiLineEqual (event .rows [0 ]["values" ]["test" ], string )
453
453
454
+ def test_encoding_latin1_statement (self ):
455
+ binlog_format = self .execute ("show variables like 'binlog_format'" ).fetchone ()[1 ]
456
+ if binlog_format .upper () != "STATEMENT" :
457
+ raise unittest .SkipTest ("Test test_encoding_latin1_statement is skipped, binlog_format"
458
+ " is %s. It test require STATEMENT" % binlog_format )
459
+
460
+ db = copy .copy (self .database )
461
+ db ["charset" ] = "latin1"
462
+ self .connect_conn_control (db )
463
+
464
+ create_query = "CREATE TABLE test (test CHAR(12)) CHARACTER SET latin1 COLLATE latin1_bin;"
465
+ insert_query = b"INSERT INTO test VALUES('\x96 ')"
466
+
467
+ self .execute (create_query )
468
+ self .execute (insert_query )
469
+ self .execute ("COMMIT" )
470
+
471
+ self .assertIsInstance (self .stream .fetchone (), RotateEvent )
472
+ self .assertIsInstance (self .stream .fetchone (), FormatDescriptionEvent )
473
+ # QueryEvent for the Create Table
474
+ self .assertIsInstance (self .stream .fetchone (), QueryEvent )
475
+
476
+ # QueryEvent for the BEGIN
477
+ self .assertIsInstance (self .stream .fetchone (), QueryEvent )
478
+
479
+ event = self .stream .fetchone ()
480
+ self .assertIsInstance (event , QueryEvent )
481
+
482
+ self .assertEqual (event .query , insert_query .decode ("latin-1" ))
483
+
454
484
455
485
if __name__ == "__main__" :
456
486
unittest .main ()
0 commit comments