@@ -1567,6 +1567,36 @@ def test_rows_query_log_event(self):
15671567 event = self .stream .fetchone ()
15681568 self .assertIsInstance (event , RowsQueryLogEvent )
15691569
1570+ def test_long_query (self ):
1571+ """
1572+ Address issue #601
1573+ Do not use the first byte of the body to determine the length of the query.
1574+ 1 byte can not represent the length of a query that is longer than 255 bytes.
1575+ """
1576+ 1577+ self .stream .close ()
1578+ self .stream = BinLogStreamReader (
1579+ self .database ,
1580+ server_id = 1024 ,
1581+ only_events = [RowsQueryLogEvent ],
1582+ )
1583+ 1584+ self .execute (
1585+ "CREATE TABLE IF NOT EXISTS test (id INT AUTO_INCREMENT PRIMARY KEY, long_text VARCHAR(256))"
1586+ )
1587+ long_query = (
1588+ "INSERT INTO test (long_text) VALUES ('"
1589+ "What is the longest word in english?"
1590+ "Pneumonoultramicroscopicsilicovolcanoconiosis is the longest word in the English language."
1591+ "This text has 256 characters and hence its length can not be represented in a single byte."
1592+ "')"
1593+ )
1594+ self .execute (long_query )
1595+ self .execute ("COMMIT" )
1596+ event = self .stream .fetchone ()
1597+ self .assertIsInstance (event , RowsQueryLogEvent )
1598+ self .assertEqual (event .query , long_query )
1599+ 15701600
15711601class TestLatin1 (base .PyMySQLReplicationTestCase ):
15721602 def setUp (self ):
0 commit comments