133133 ),
134134 ('smallint[]' , (
135135 [123 ,321 ,- 123 ,- 321 ],
136+ [],
136137 ),
137138 ),
138139 ('int[]' , [
139140 [123 ,321 ,- 123 ,- 321 ],
140141 [[1 ],[2 ]],
142+ [],
141143 ],
142144 ),
143145 ('bigint[]' , [
150152 ((1 << 64 ) // 2 ) - 1 ,
151153 - ((1 << 64 ) // 2 ),
152154 ],
155+ [],
153156 ],
154157 ),
155158 ('varchar[]' , [
156159 ["foo" , "bar" ,],
157160 ["foo" , "bar" ,],
161+ [],
158162 ],
159163 ),
160164 ('timestamp' , [
@@ -260,6 +264,10 @@ def testProcExecution(self):
260264 self .failUnless (ifoo (1 ) == 1 )
261265 self .failUnless (ifoo (None ) is None )
262266
267+ def testProcExecutionInXact (self ):
268+ with self .db .xact ():
269+ self .testProcExecution ()
270+
263271 def testNULL (self ):
264272 # Directly commpare (SELECT NULL) is None
265273 self .failUnless (
@@ -295,6 +303,10 @@ def testSelect(self):
295303 for tup in s1 :
296304 self .failUnlessEqual (tup ["name" ], 1 )
297305
306+ def testSelectInXact (self ):
307+ with self .db .xact ():
308+ self .testSelect ()
309+
298310 def testChunking (self ):
299311 gs = self .db .prepare ("SELECT i FROM generate_series(1, 10000) AS g(i)" )
300312 self .failUnlessEqual (
@@ -313,7 +325,9 @@ def testChunking(self):
313325 )()
314326 read_chunking = self .db .prepare ('select * FROM chunking' )
315327 write_chunking = db2 .prepare ('insert into chunking values ($1, $2)' )
316- for rows in read_chunking ().chunks :
328+ out = read_chunking ()
329+ out .chunksize = 256
330+ for rows in out .chunks :
317331 write_chunking .load (rows )
318332 self .failUnlessEqual (
319333 self .db .prepare ('select count(*) FROM chunking' ).first (),
@@ -355,6 +369,10 @@ def testDDL(self):
355369 finally :
356370 self .db .execute ("DROP TABLE t" )
357371
372+ def testDDLInXact (self ):
373+ with self .db .xact ():
374+ self .testDDL ()
375+
358376 def testBatchDDL (self ):
359377 self .db .execute ("CREATE TEMP TABLE t(i int)" )
360378 try :
@@ -374,6 +392,10 @@ def testBatchDDL(self):
374392 finally :
375393 self .db .execute ("DROP TABLE t" )
376394
395+ def testBatchDDLInXact (self ):
396+ with self .db .xact ():
397+ self .testBatchDDL ()
398+
377399 def testTypes (self ):
378400 'test basic object I/O--input must equal output'
379401 for (typname , sample_data ) in type_samples :
@@ -508,6 +530,18 @@ def testPreparedTransactionRecovery(self):
508530 x .commit ()
509531 self .db .execute ("drop table distable;" )
510532
533+ def testPreparedTransactionRecoveryAbort (self ):
534+ x = self .db .xact (gid = 'recover dis abort' )
535+ with x :
536+ self .db .execute ("create table distableabort (i int);" )
537+ del x
538+ x = self .db .xact (gid = 'recover dis abort' )
539+ x .recover ()
540+ x .rollback ()
541+ self .failUnlessRaises (pg_exc .UndefinedTableError ,
542+ self .db .prepare ("select * from distableabort" )
543+ )
544+
511545 def testPreparedTransactionFailedRecovery (self ):
512546 x = self .db .xact (gid = "NO XACT HERE" )
513547 self .failUnlessRaises (
0 commit comments