2929from ..python .itertools import interlace
3030
3131from ..protocol .buffer import pq_message_stream
32- from ..protocol import client3 as pq
32+ from ..protocol import xact3 as pq
3333from ..protocol import typio as pg_typio
3434
3535TypeLookup = """
@@ -248,7 +248,7 @@ def __init__(self, cursor_id, database):
248248 if not cursor_id :
249249 # Driver uses the empty id(b'').
250250 ##
251- raise TypeError ("invalid cursor identifier, " + repr (cursor_id ))
251+ raise ValueError ("invalid cursor identifier, " + repr (cursor_id ))
252252 self .cursor_id = str (cursor_id )
253253 self ._quoted_cursor_id = '"' + self .cursor_id .replace ('"' , '""' ) + '"'
254254 self .database = database
@@ -287,25 +287,6 @@ def close(self):
287287 self ._complete_message = None
288288 self .__class__ = Cursor
289289
290- def restart (self ):
291- if self .parameters is None :
292- e = pg_exc .OperationError (
293- "cannot restart cursor when parameters are unknown"
294- )
295- self .ife_descend (e )
296- e .raise_exception ()
297-
298- if self .statement is None :
299- e = pg_exc .OperationError (
300- "cannot restart cursor when statement is unknown"
301- )
302- self .ife_descend (e )
303- e .raise_exception ()
304-
305- if not self .closed :
306- self .close ()
307- self ._init ()
308-
309290 def _pq_parameters (self ):
310291 return list (pg_typio .row_pack (
311292 self .parameters ,
@@ -518,7 +499,7 @@ def _init(self, setup):
518499 self .chunksize = 0
519500
520501 more = self ._pq_xp_fetchmore (self .chunksize )
521- x = pq .Transaction (
502+ x = pq .Instruction (
522503 setup + more + (pq .element .SynchronizeMessage ,)
523504 )
524505 self ._state = (
@@ -534,7 +515,7 @@ def _dispatch_for_more(self):
534515 more = self ._pq_xp_fetchmore (self .chunksize )
535516 if more :
536517 new_x = more + (pq .element .SynchronizeMessage ,)
537- new_x = pq .Transaction (new_x )
518+ new_x = pq .Instruction (new_x )
538519 self .ife_descend (new_x )
539520 self ._state = (
540521 self ._state [0 ],
@@ -567,7 +548,7 @@ def _buffer_more(self, count):
567548 # No previous transaction started, so make one.
568549 ##
569550 more = self ._pq_xp_fetchmore (count )
570- x = pq .Transaction (more + (pq .element .SynchronizeMessage ,))
551+ x = pq .Instruction (more + (pq .element .SynchronizeMessage ,))
571552 self .ife_descend (x )
572553 self ._state = (offset , buffer , x )
573554 self .database ._pq_push (x )
@@ -638,7 +619,7 @@ def seek(self, offset, whence = 'ABSOLUTE'):
638619 cmd = self ._pq_xp_move (b'' , b'LAST' ) + \
639620 self ._pq_xp_move (str (offset ).encode ('ascii' ), b'BACKWARD' )
640621
641- x = pq .Transaction (cmd + (pq .element .SynchronizeMessage ,))
622+ x = pq .Instruction (cmd + (pq .element .SynchronizeMessage ,))
642623 self .ife_descend (x )
643624 self ._state = (0 , [], x )
644625 self .database ._pq_push (x )
@@ -775,7 +756,7 @@ def _init(self):
775756 pq .element .DescribePortal (self ._pq_cursor_id ),
776757 pq .element .FlushMessage ,
777758 )
778- self ._state = (0 , [], pq .Transaction (setup ))
759+ self ._state = (0 , [], pq .Instruction (setup ))
779760 self .database ._pq_push (self ._state [2 ])
780761
781762 def _fini (self ):
@@ -809,7 +790,7 @@ class UtilityCursor(CursorStrategy):
809790 cursor_type = 'utility'
810791
811792 def _init (self ):
812- self ._pq_xact = pq .Transaction ((
793+ self ._pq_xact = pq .Instruction ((
813794 pq .element .Bind (
814795 b'' ,
815796 self .statement ._pq_statement_id ,
@@ -1031,7 +1012,7 @@ def _init(self):
10311012 pq .element .SynchronizeMessage ,
10321013 )
10331014 )
1034- self ._pq_xact = pq .Transaction (cmd )
1015+ self ._pq_xact = pq .Instruction (cmd )
10351016 self .ife_descend (self ._pq_xact )
10361017 self .database ._pq_push (self ._pq_xact )
10371018
@@ -1109,7 +1090,7 @@ def first(self, *parameters):
11091090 params = ()
11101091
11111092 # Run the statement
1112- x = pq .Transaction ((
1093+ x = pq .Instruction ((
11131094 pq .element .Bind (
11141095 b'' ,
11151096 self ._pq_statement_id ,
@@ -1166,7 +1147,7 @@ def _copy_data_in(self,
11661147 to the socket's send.
11671148 """
11681149 tps = tps or 500
1169- x = pq .Transaction ((
1150+ x = pq .Instruction ((
11701151 pq .element .Bind (
11711152 b'' ,
11721153 self ._pq_statement_id ,
@@ -1248,7 +1229,7 @@ def _load_bulk_tuples(self, tupleseq, tps = None):
12481229 else :
12491230 last = pq .element .SynchronizeMessage
12501231 xm .append (last )
1251- self .database ._pq_push (pq .Transaction (xm ))
1232+ self .database ._pq_push (pq .Instruction (xm ))
12521233 self .database ._pq_complete ()
12531234 except :
12541235 ##
@@ -1934,7 +1915,7 @@ def synchronize(self):
19341915 """
19351916 if self ._pq_xact is not None :
19361917 self ._pq_complete ()
1937- x = pq .Transaction ((pq .element .SynchronizeMessage ,))
1918+ x = pq .Instruction ((pq .element .SynchronizeMessage ,))
19381919 self ._pq_xact = x
19391920 self ._pq_complete ()
19401921
@@ -1950,7 +1931,7 @@ def interrupt(self, timeout = None):
19501931 s .close ()
19511932
19521933 def execute (self , query : str ) -> None :
1953- q = pq .Transaction ((
1934+ q = pq .Instruction ((
19541935 pq .element .Query (self .typio ._encode (query )[0 ]),
19551936 ))
19561937 self .ife_descend (q )
@@ -2405,12 +2386,12 @@ def _backend_gc(self):
24052386 xm .append (pq .element .CloseStatement (x ))
24062387 statements += 1
24072388 xm .append (pq .element .SynchronizeMessage )
2408- x = pq .Transaction (xm )
2389+ x = pq .Instruction (xm )
24092390 self ._pq_xact = x
24102391 del self ._closeportals [:portals ], self ._closestatements [:statements ]
24112392 self ._pq_complete ()
24122393
2413- def _pq_push (self , xact : pq .ProtocolState ):
2394+ def _pq_push (self , xact : pq .Transaction ):
24142395 '[internal] setup the given transaction to be processed'
24152396 # Push any queued closures onto the transaction or a new transaction.
24162397 if xact .state is pq .Complete :
0 commit comments