Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse status variables in query event #360

Merged
merged 5 commits into from
Oct 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add create_table function for testing query events only
  • Loading branch information
dongwook-chan committed Sep 24, 2021
commit 1b789e6570c0f94902c989834efc7148fee2a86e
30 changes: 0 additions & 30 deletions pymysqlreplication/constants/STATUS_VAR_KEY.py
Original file line number Diff line number Diff line change
@@ -36,33 +36,3 @@
Q_DEFAULT_COLLATION_FOR_UTF8MB4 = 0X12
Q_SQL_REQUIRE_PRIMARY_KEY = 0X13
Q_DEFAULT_TABLE_ENCRYPTION = 0X14

"""
is_fixed_length_value = [
True,
True,
False,
True,
True,

]

# length for VALUE
value_length_fixed_for_key = [

]

value_length_multiplier_for_key = [

]

value_length_remainder_for_key = [

]
"""
"""
#@classmethod
@staticmethod
def value_length_for_key():
pass
"""
1 change: 0 additions & 1 deletion pymysqlreplication/event.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
import binascii
import struct
import datetime
#from .constants import STATUS_VAR_KEY
from pymysqlreplication.constants.STATUS_VAR_KEY import *


17 changes: 1 addition & 16 deletions pymysqlreplication/packet.py
Original file line number Diff line number Diff line change
@@ -465,11 +465,7 @@ def _read(x):
def read_string(self):
"""Read a 'Length Coded String' from the data buffer.

A 'Length Coded String' consists first of a length coded
(unsigned, positive) integer represented in 1-9 bytes followed by
that many bytes of binary data. (For example "cat" would be "3cat".)

From PyMYSQL source code edited by dongwook-chan

"""
string = b''
while True:
@@ -479,14 +475,3 @@ def read_string(self):
string += char

return string

"""
#self.buf = __data_buffer #@
end_pos = self.__data_buffer.find(b"\0")
self.read_bytes += end_pos + 1
if end_pos < 0:
return None
result = self.__data_buffer[ : end_pos]
self.__data_buffer = self.__data_buffer[end_pos + 1 : ]
return result
"""
15 changes: 13 additions & 2 deletions pymysqlreplication/tests/test_data_type.py
Original file line number Diff line number Diff line change
@@ -57,6 +57,18 @@ def create_and_insert_value(self, create_query, insert_query):
self.assertIsInstance(event, WriteRowsEvent)
return event

def create_table(self, create_query):
self.execute(create_query)

self.assertIsInstance(self.stream.fetchone(), RotateEvent)
self.assertIsInstance(self.stream.fetchone(), FormatDescriptionEvent)

event = self.stream.fetchone()

self.assertEqual(event.event_type, QueryEvent)

return event

def test_decimal(self):
create_query = "CREATE TABLE test (test DECIMAL(2,1))"
insert_query = "INSERT INTO test VALUES(4.2)"
@@ -643,8 +655,7 @@ def test_partition_id(self):

def test_status_vars(self):
create_query = "CREATE TABLE test (id INTEGER)"
insert_query = "insert into test values (1)" # not necessary
event = self.create_and_insert_value(create_query, insert_query)
event = self.create_table(create_query)
self.assertEqual(event.catalog_nz_code, b'std')
self.assertEqual(event.mts_accessed_db_names, [b'pymysqlreplication_test'])