@@ -35,9 +35,6 @@ cdef class CoreProtocol:
35
35
cdef _write(self , buf):
36
36
self .transport.write(memoryview(buf))
37
37
38
- cdef inline _write_sync_message(self ):
39
- self .transport.write(SYNC_MESSAGE)
40
-
41
38
cdef _read_server_messages(self ):
42
39
cdef:
43
40
char mtype
@@ -749,14 +746,12 @@ cdef class CoreProtocol:
749
746
self ._ensure_connected()
750
747
self ._set_state(PROTOCOL_PREPARE)
751
748
752
- packet = WriteBuffer.new()
753
-
754
749
buf = WriteBuffer.new_message(b' P' )
755
750
buf.write_str(stmt_name, self .encoding)
756
751
buf.write_str(query, self .encoding)
757
752
buf.write_int16(0 )
758
753
buf.end_message()
759
- packet.write_buffer( buf)
754
+ packet = buf
760
755
761
756
buf = WriteBuffer.new_message(b' D' )
762
757
buf.write_byte(b' S' )
@@ -766,23 +761,27 @@ cdef class CoreProtocol:
766
761
767
762
packet.write_bytes(SYNC_MESSAGE)
768
763
769
- self .transport.write(memoryview( packet) )
764
+ self ._write( packet)
770
765
771
766
cdef _send_bind_message(self , str portal_name, str stmt_name,
772
767
WriteBuffer bind_data, int32_t limit):
773
768
774
- cdef WriteBuffer buf
769
+ cdef:
770
+ WriteBuffer packet
771
+ WriteBuffer buf
775
772
776
773
buf = self ._build_bind_message(portal_name, stmt_name, bind_data)
777
- self ._write( buf)
774
+ packet = buf
778
775
779
776
buf = WriteBuffer.new_message(b' E' )
780
777
buf.write_str(portal_name, self .encoding) # name of the portal
781
778
buf.write_int32(limit) # number of rows to return; 0 - all
782
779
buf.end_message()
783
- self ._write (buf)
780
+ packet.write_buffer (buf)
784
781
785
- self ._write_sync_message()
782
+ packet.write_bytes(SYNC_MESSAGE)
783
+
784
+ self ._write(packet)
786
785
787
786
cdef _bind_execute(self , str portal_name, str stmt_name,
788
787
WriteBuffer bind_data, int32_t limit):
@@ -833,8 +832,10 @@ cdef class CoreProtocol:
833
832
buf.write_str(portal_name, self .encoding) # name of the portal
834
833
buf.write_int32(limit) # number of rows to return; 0 - all
835
834
buf.end_message()
835
+
836
+ buf.write_bytes(SYNC_MESSAGE)
837
+
836
838
self ._write(buf)
837
- self ._write_sync_message()
838
839
839
840
cdef _bind(self , str portal_name, str stmt_name,
840
841
WriteBuffer bind_data):
@@ -845,8 +846,10 @@ cdef class CoreProtocol:
845
846
self ._set_state(PROTOCOL_BIND)
846
847
847
848
buf = self ._build_bind_message(portal_name, stmt_name, bind_data)
849
+
850
+ buf.write_bytes(SYNC_MESSAGE)
851
+
848
852
self ._write(buf)
849
- self ._write_sync_message()
850
853
851
854
cdef _close(self , str name, bint is_portal):
852
855
cdef WriteBuffer buf
@@ -863,9 +866,10 @@ cdef class CoreProtocol:
863
866
864
867
buf.write_str(name, self .encoding)
865
868
buf.end_message()
866
- self ._write(buf)
867
869
868
- self ._write_sync_message()
870
+ buf.write_bytes(SYNC_MESSAGE)
871
+
872
+ self ._write(buf)
869
873
870
874
cdef _simple_query(self , str query):
871
875
cdef WriteBuffer buf
0 commit comments