Module: XID::ConnectionAdapters::PostgreSQLAdapter

Defined in:
lib/xid/connection_adapters/postgresql_adapter.rb

Instance Method Summary collapse

Instance Method Details

#supports_transaction_id?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/xid/connection_adapters/postgresql_adapter.rb', line 5

def supports_transaction_id?
  true
end

#transaction_idObject

From the PostgreSQL manual: www.postgresql.org/docs/9.1/static/functions-info.html#FUNCTIONS-TXID-SNAPSHOT

The internal transaction ID type (xid) is 32 bits wide and wraps around every
4 billion transactions. However, these functions export a 64-bit format that
is extended with an "epoch" counter so it will not wrap around during the 
life of an installation.


16
17
18
# File 'lib/xid/connection_adapters/postgresql_adapter.rb', line 16

def transaction_id
  select_value('SELECT txid_current()').to_i
end