@@ -585,6 +585,33 @@ def test_drop_column(self):
585
585
finally :
586
586
self .resetBinLog ()
587
587
588
+ @unittest .expectedFailure
589
+ def test_alter_column (self ):
590
+ self .stream .close ()
591
+ self .execute ("CREATE TABLE test_alter_column (id INTEGER(11), data VARCHAR(50))" )
592
+ self .execute ("INSERT INTO test_alter_column VALUES (1, 'A value')" )
593
+ self .execute ("COMMIT" )
594
+ # this is a problem only when column is added in position other than at the end
595
+ self .execute ("ALTER TABLE test_alter_column ADD COLUMN another_data VARCHAR(50) AFTER id" )
596
+ self .execute ("INSERT INTO test_alter_column VALUES (2, 'Another value', 'A value')" )
597
+ self .execute ("COMMIT" )
598
+
599
+ self .stream = BinLogStreamReader (
600
+ self .database ,
601
+ server_id = 1024 ,
602
+ only_events = (WriteRowsEvent ,),
603
+ )
604
+ event = self .stream .fetchone () # insert with two values
605
+ # both of these asserts fail because of issue underlying proble described in issue #118
606
+ # because it got table schema info after the alter table, it wrongly assumes the second
607
+ # column of the first insert is 'another_data'
608
+ # ER: {'id': 1, 'data': 'A value'}
609
+ # AR: {'id': 1, 'another_data': 'A value'}
610
+ self .assertIn ("data" , event .rows [0 ]["values" ])
611
+ self .assertNot ("another_data" , event .rows [0 ]["values" ])
612
+ self .assertEqual (event .rows [0 ]["values" ]["data" ], 'A value' )
613
+ self .stream .fetchone () # insert with three values
614
+
588
615
589
616
class TestGtidBinLogStreamReader (base .PyMySQLReplicationTestCase ):
590
617
def setUp (self ):
0 commit comments