mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-01 08:17:33 +03:00 
			
		
		
		
	Fix stop_replication: always raise outside the loop.
This commit is contained in:
		
							parent
							
								
									54079072db
								
							
						
					
					
						commit
						fea2260fc5
					
				|  | @ -1624,8 +1624,6 @@ psyco_curs_start_replication_expert(cursorObject *self, PyObject *args, PyObject | |||
|         Py_INCREF(res); | ||||
|     } | ||||
| 
 | ||||
|     self->repl_started = 1; | ||||
| 
 | ||||
|     return res; | ||||
| } | ||||
| 
 | ||||
|  | @ -1676,6 +1674,8 @@ psyco_curs_consume_replication_stream(cursorObject *self, PyObject *args, PyObje | |||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     self->repl_started = 1; | ||||
| 
 | ||||
|     if (pq_copy_both(self, consumer, decode, keepalive_interval) >= 0) { | ||||
|         res = Py_None; | ||||
|         Py_INCREF(res); | ||||
|  |  | |||
|  | @ -1197,6 +1197,18 @@ class ReplicationTest(ConnectingTestCase): | |||
|         cur.execute("IDENTIFY_SYSTEM") | ||||
|         cur.fetchall() | ||||
| 
 | ||||
|     @skip_before_postgres(9, 0) | ||||
|     def test_stop_replication_raises(self): | ||||
|         import psycopg2.extras | ||||
|         conn = self.repl_connect(connection_factory=psycopg2.extras.PhysicalReplicationConnection) | ||||
|         if conn is None: return | ||||
|         cur = conn.cursor() | ||||
|         self.assertRaises(psycopg2.ProgrammingError, cur.stop_replication) | ||||
| 
 | ||||
|         cur.start_replication() | ||||
|         self.assertRaises(psycopg2.ProgrammingError, cur.stop_replication) | ||||
| 
 | ||||
| 
 | ||||
| def test_suite(): | ||||
|     return unittest.TestLoader().loadTestsFromName(__name__) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user