class PG::Connection
Overrides for PG
connection
Constants
- SQL_BEGIN
- SQL_COMMIT
- SQL_ROLLBACK
Public Instance Methods
async_exec(*args, &block)
click to toggle source
# File lib/polyphony/adapters/postgres.rb, line 52 def async_exec(*args, &block) send_query(*args) get_result(&block) ensure # cleanup result in order to allow next query while get_result; end end
Also aliased as: orig_async_exec
block(_timeout = 0)
click to toggle source
# File lib/polyphony/adapters/postgres.rb, line 60 def block(_timeout = 0) while is_busy Polyphony.backend_wait_io(socket_io, false) consume_input end end
get_result(&block)
click to toggle source
# File lib/polyphony/adapters/postgres.rb, line 43 def get_result(&block) while is_busy Polyphony.backend_wait_io(socket_io, false) consume_input end orig_get_result(&block) end
Also aliased as: orig_get_result
perform_transaction() { || ... }
click to toggle source
# File lib/polyphony/adapters/postgres.rb, line 81 def perform_transaction query(SQL_BEGIN) began = true @transaction = true yield query(SQL_COMMIT) rescue StandardError => e query(SQL_ROLLBACK) if began raise e ensure @transaction = false end
transaction() { || ... }
click to toggle source
Starts a transaction, runs given block, and commits transaction. If an error is raised, the transaction is rolled back and the error is raised again. @return [void]
# File lib/polyphony/adapters/postgres.rb, line 75 def transaction(&block) return yield if @transaction # allow nesting of calls to #transactions perform_transaction(&block) end
wait_for_notify(timeout = nil, &block)
click to toggle source
# File lib/polyphony/adapters/postgres.rb, line 96 def wait_for_notify(timeout = nil, &block) return move_on_after(timeout) { wait_for_notify(&block) } if timeout while true Polyphony.backend_wait_io(socket_io, false) consume_input notice = notifies next unless notice values = notice.values block&.(*values) return values.first end end