Skip to content

Commit 2029dda

Browse files
author
James William Pye
committed
Note the deprecation of the 2PC features.
1 parent b54a0ab commit 2029dda

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

postgresql/api.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,8 @@ class Transaction(Element):
652652
... with db.xact():
653653
... ...
654654
655+
[DEPRECATED]
656+
655657
Or, in cases where two-phase commit is desired:
656658
657659
>>> with db.xact(gid = 'gid') as gxact:
@@ -696,6 +698,8 @@ def isolation(self) -> (None, str):
696698
@abstractproperty
697699
def gid(self) -> (None, str):
698700
"""
701+
[DEPRECATED]
702+
699703
The global identifier of the transaction block:
700704
701705
PREPARE TRANSACTION <gid>;
@@ -750,20 +754,23 @@ def rollback(self) -> None:
750754
"""
751755
Abort the transaction.
752756
753-
If the transaction is configured with a `gid` *and* has been prepared, issue
754-
a ROLLBACK PREPARE statement with the configured `gid`.
755-
756757
If the transaction is a savepoint, ROLLBACK TO the savepoint identifier.
757758
758759
If the transaction is a transaction block, issue an ABORT.
759760
760761
If the transaction has already been aborted, do nothing.
762+
763+
[DEPRECATED]
764+
If the transaction is configured with a `gid` *and* has been prepared, issue
765+
a ROLLBACK PREPARE statement with the configured `gid`.
761766
"""
762767
abort = rollback
763768

764769
@abstractmethod
765770
def recover(self) -> None:
766771
"""
772+
[DEPRECATED]
773+
767774
If the transaction is assigned a `gid`, recover may be used to identify
768775
the transaction as prepared and ready for committing or aborting.
769776
@@ -783,6 +790,8 @@ def recover(self) -> None:
783790
@abstractmethod
784791
def prepare(self) -> None:
785792
"""
793+
[DEPRECATED]
794+
786795
Explicitly prepare the transaction with the configured `gid` by issuing a
787796
PREPARE TRANSACTION statement with the configured `gid`.
788797
This *must* be called for the first phase of the commit.

postgresql/documentation/driver.txt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,11 @@ The methods and properties on the connection object are ready for use:
337337
occurs. If errors occur, the processing of the statements will stop and the
338338
error will be raised.
339339

340-
``db.xact(gid = None, isolation = None, mode = None)``
340+
``db.xact(isolation = None, mode = None)``
341341
The `postgresql.api.Transaction` constructor for creating transactions.
342342
This method creates a transaction reference. The transaction will not be
343343
started until it's instructed to do so. See `Transactions`_ for more
344-
information.
344+
information. (**gid keyword is deprecated**)
345345

346346
``db.settings``
347347
A property providing a `collections.MutableMapping` interface to the
@@ -1267,17 +1267,13 @@ instruction methods provided by `postgresql.api.Transaction` objects.
12671267
Transaction Configuration
12681268
-------------------------
12691269

1270-
.. warning::
1271-
**All transaction configuration arguments are being deprecated over the**
1272-
**next few versions of py-postgresql. Use should be discontinued**.
1273-
12741270
Keyword arguments given to ``xact()`` provide the means for configuring the
12751271
properties of the transaction. Only three points of configuration are available:
12761272

12771273
``gid``
12781274
The global identifier to use. Identifies the transaction as using two-phase
12791275
commit. The ``prepare()`` method *must* be called prior to ``commit()`` or
1280-
``__exit__()``.
1276+
``__exit__()``. (**Deprecated**)
12811277

12821278
``isolation``
12831279
The isolation level of the transaction. This must be a string. It will be
@@ -1314,8 +1310,8 @@ that change of state.
13141310
Commit the transaction.
13151311

13161312
``x.rollback()``
1317-
Abort the transaction. For prepared transactions, this can be called at any
1318-
phase.
1313+
Abort the transaction.
1314+
(Deprecated: For prepared transactions, this can be called at any phase.)
13191315

13201316
``x.recover()``
13211317
Identify the existence of the prepared transaction. (**Deprecated**)

postgresql/driver/pq3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ class Transaction(pg_api.Transaction):
14221422
def _e_metas(self):
14231423
yield (None, self.state)
14241424

1425-
def __init__(self, database, gid = None, isolation = None, mode = None):
1425+
def __init__(self, database, isolation = None, mode = None, gid = None):
14261426
self.database = database
14271427
self.gid = gid
14281428
self.isolation = isolation

0 commit comments

Comments
 (0)