Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 27a3bd8

Browse files
committedNov 9, 2012
Cache getting column names
1 parent 95d2f7d commit 27a3bd8

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed
 

‎TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
* Cache column name
21
* Support ALTER TABLE
32
* End user documentation
43
* Test transaction support

‎pymysqlreplication/row_event.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,17 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection):
323323

324324
self.columns = []
325325

326-
column_schemas = self.__get_table_informations(self.schema, self.table)
326+
if self.table_id in table_map:
327+
self.column_schemas = table_map[self.table_id].column_schemas
328+
else:
329+
self.column_schemas = self.__get_table_informations(self.schema, self.table)
327330

328331
#Read columns meta data
329332
column_types = list(self.packet.read(self.column_count))
330333
metadata_length = self.packet.read_length_coded_binary()
331334
for i in range(0, len(column_types)):
332335
column_type = column_types[i]
333-
column_schema = column_schemas[i]
336+
column_schema = self.column_schemas[i]
334337
col = Column(byte2int(column_type), column_schema, from_packet)
335338
self.columns.append(col)
336339

@@ -339,7 +342,6 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection):
339342
# n NULL-bitmask, length: (column-length * 8) / 7
340343

341344
def __get_table_informations(self, schema, table):
342-
#TODO: Cache this information
343345
cur = self._ctl_connection.cursor()
344346
cur.execute("""SELECT * FROM columns WHERE table_schema = %s AND table_name = %s""", (schema, table))
345347
return cur.fetchall()

0 commit comments

Comments
 (0)
Please sign in to comment.