Skip to content

Commit 0d5cdcd

Browse files
committed
Extract _build_execute_message()
1 parent e9802aa commit 0d5cdcd

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

asyncpg/protocol/coreproto.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ cdef class CoreProtocol:
147147
cdef WriteBuffer _build_bind_message(self, str portal_name,
148148
str stmt_name,
149149
WriteBuffer bind_data)
150+
cdef WriteBuffer _build_execute_message(self, str portal_name,
151+
int32_t limit)
150152

151153

152154
cdef _connect(self)

asyncpg/protocol/coreproto.pyx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,17 @@ cdef class CoreProtocol:
699699
buf.end_message()
700700
return buf
701701

702+
cdef WriteBuffer _build_execute_message(self, str portal_name,
703+
int32_t limit):
704+
cdef WriteBuffer buf
705+
706+
buf = WriteBuffer.new_message(b'E')
707+
buf.write_str(portal_name, self.encoding) # name of the portal
708+
buf.write_int32(limit) # number of rows to return; 0 - all
709+
710+
buf.end_message()
711+
return buf
712+
702713
# API for subclasses
703714

704715
cdef _connect(self):
@@ -776,10 +787,7 @@ cdef class CoreProtocol:
776787
buf = self._build_bind_message(portal_name, stmt_name, bind_data)
777788
self._write(buf)
778789

779-
buf = WriteBuffer.new_message(b'E')
780-
buf.write_str(portal_name, self.encoding) # name of the portal
781-
buf.write_int32(limit) # number of rows to return; 0 - all
782-
buf.end_message()
790+
buf = self._build_execute_message(portal_name, limit)
783791
self._write(buf)
784792

785793
self._write_sync_message()
@@ -829,10 +837,7 @@ cdef class CoreProtocol:
829837

830838
self.result = []
831839

832-
buf = WriteBuffer.new_message(b'E')
833-
buf.write_str(portal_name, self.encoding) # name of the portal
834-
buf.write_int32(limit) # number of rows to return; 0 - all
835-
buf.end_message()
840+
buf = self._build_execute_message(portal_name, limit)
836841
self._write(buf)
837842
self._write_sync_message()
838843

0 commit comments

Comments
 (0)