Gda.XaTransaction

g GObject.Object GObject.Object Gda.XaTransaction Gda.XaTransaction GObject.Object->Gda.XaTransaction

Subclasses:None

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
class error_quark ()
class new (format, global_transaction_id)
  begin ()
  commit ()
  commit_recovered ()
  register_connection (cnc, branch)
  rollback ()
  unregister_connection (cnc)

Virtual Methods

Inherited:GObject.Object (7)

Properties

Name Type Flags Short Description
format-id int r/w/co  
transaction-id str r/w/co  

Signals

Inherited:GObject.Object (1)

Fields

Inherited:GObject.Object (1)
Name Type Access Description
object GObject.Object r  

Class Details

class Gda.XaTransaction(**kwargs)
Bases:GObject.Object
Abstract:No
Structure:Gda.XaTransactionClass
classmethod error_quark()
Return type:int
classmethod new(format, global_transaction_id)
Parameters:
  • format (int) – a format ID
  • global_transaction_id (str) – the global transaction ID
Returns:

the newly created object.

Return type:

Gda.XaTransaction

Creates a new Gda.XaTransaction object, which will control the process of performing a distributed transaction across several connections.

begin()
Raises:GLib.Error
Returns:True if no error occurred
Return type:bool

Begins a distributed transaction (managed by self). Please note that this phase may fail for some connections if a (normal) transaction is already started (this depends on the database provider being used), so it’s better to avoid starting any (normal) transaction on any of the connections registered with self.

commit()
Raises:GLib.Error
Returns:True if no error occurred (there may be some connections to recover, though)
cnc_to_recover:a place to store the list of connections for which the commit phase failed, or None
Return type:(bool, cnc_to_recover: [Gda.Connection])

Commits a distributed transaction (managed by self). The commit is composed of two phases:

  • a PREPARE phase where all the connections are required to store their transaction data to a permanent place (to be able to complete the commit should a problem occur afterwards)
  • a COMMIT phase where the transaction data is actually written to the database

If the PREPARE phase fails for any of the connection registered with self, then the distributed commit fails and False is returned. During the COMMIT phase, some commit may actually fail but the transaction can still be completed because the PREPARE phase succeeded (through the recover method).

commit_recovered()
Raises:GLib.Error
Returns:True if all the data which was still uncommitted has been committed
cnc_to_recover:a place to store the list of connections for which the there were data to recover and which failed to be actually committed, or None
Return type:(bool, cnc_to_recover: [Gda.Connection])

Tries to commit the data prepared but which failed to commit (see Gda.XaTransaction.commit()). This method allows one to terminate a distributed transaction which succeeded but for which some connections needed to be recovered.

register_connection(cnc, branch)
Parameters:
  • cnc (Gda.Connection) – the connection to add to self
  • branch (str) – the branch qualifier
Raises:

GLib.Error

Returns:

True if no error occurred

Return type:

bool

Registers cnc to be used by self to create a distributed transaction.

Note: any Gda.Connection object can only be registered with at most one Gda.XaTransaction object; also some connections may not be registered at all with a Gda.XaTransaction object because the database provider being used does not support it.

rollback()
Raises:GLib.Error
Returns:True if no error occurred
Return type:bool

Cancels a distributed transaction (managed by self).

unregister_connection(cnc)
Parameters:cnc (Gda.Connection) – the connection to add to self

Unregisters cnc to be used by self to create a distributed transaction. This is the opposite of Gda.XaTransaction.register_connection().

Property Details

Gda.XaTransaction.props.format_id
Name:format-id
Type:int
Default Value:1
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY
Gda.XaTransaction.props.transaction_id
Name:transaction-id
Type:str
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY