mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 08:56:34 +03:00
A prepared connection can't be canceled.
This commit is contained in:
parent
4dbd4344a3
commit
0c7b0a943b
|
@ -2,6 +2,8 @@
|
|||
|
||||
* Cancel patch from Jan integrated.
|
||||
|
||||
* psycopg/connection_type.c: can't cancel a prepared connection
|
||||
|
||||
2010-11-22 Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||
|
||||
* psycopg/connection_int.c: dropped notices hack to get COPY errors from
|
||||
|
|
|
@ -709,6 +709,7 @@ psyco_conn_cancel(connectionObject *self)
|
|||
char errbuf[256];
|
||||
|
||||
EXC_IF_CONN_CLOSED(self);
|
||||
EXC_IF_TPC_PREPARED(self, cancel);
|
||||
|
||||
/* do not allow cancellation while the connection is being built */
|
||||
Dprintf("psyco_conn_cancel: cancelling with key %p", self->cancel);
|
||||
|
|
|
@ -623,6 +623,12 @@ class ConnectionTwoPhaseTests(unittest.TestCase):
|
|||
self.assertEqual('transaction-id', xid.gtrid)
|
||||
self.assertEqual(None, xid.bqual)
|
||||
|
||||
def test_cancel_fails_prepared(self):
|
||||
cnn = self.connect()
|
||||
cnn.tpc_begin('cancel')
|
||||
cnn.tpc_prepare()
|
||||
self.assertRaises(psycopg2.ProgrammingError, cnn.cancel)
|
||||
|
||||
decorate_all_tests(ConnectionTwoPhaseTests, skip_if_tpc_disabled)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user