Sha256: a04325cb3157361ac73c1ad78493430eab2dc7aaeb34a44edd5dde65a8ddf4db

Contents?: true

Size: 1.46 KB

Versions: 20

Compression:

Stored size: 1.46 KB

Contents

module DBI::DBD::Pg
    ################################################################
    # Convenience adaptor to hide details command execution API calls.
    # See PgExecutorAsync subclass
    class PgExecutor
        def initialize(pg_conn)
            @pg_conn = pg_conn
        end

        def exec(sql, parameters = nil)
            @pg_conn.exec(sql, parameters)
        end

        def exec_prepared(stmt_name, parameters = nil)
            @pg_conn.exec_prepared(stmt_name, parameters)
        end

        def prepare(stmt_name, sql)
            @pg_conn.prepare(stmt_name, sql)
        end
    end

    # Asynchronous implementation of PgExecutor, useful for 'green
    # thread' implementations (e.g., MRI <= 1.8.x) which would otherwise
    # suspend other threads while awaiting query results.
    #--
    # FIXME:  PQsetnonblocking + select/poll would make the exec*
    #         methods truly 'async', though this is rarely needed in
    #         practice.
    class PgExecutorAsync < PgExecutor
        def exec(sql, parameters = nil)
            @pg_conn.async_exec(sql, parameters)
        end

        def exec_prepared(stmt_name, parameters = nil)
            @pg_conn.send_query_prepared(stmt_name, parameters)
            @pg_conn.block()
            @pg_conn.get_last_result()
        end

        def prepare(stmt_name, sql)
            @pg_conn.send_prepare(stmt_name, sql)
            @pg_conn.block()
            @pg_conn.get_last_result()
        end
    end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
ydbd-pg-0.6.0 lib/dbd/pg/exec.rb
ydbi-0.6.0 lib/dbd/pg/exec.rb
ydbd-pg-0.5.9 lib/dbd/pg/exec.rb
ydbd-pg-0.5.8 lib/dbd/pg/exec.rb
ydbd-pg-0.5.7 lib/dbd/pg/exec.rb
ydbi-0.5.7 lib/dbd/pg/exec.rb
ydbd-pg-0.5.6 lib/dbd/pg/exec.rb
ydbd-pg-0.5.5 lib/dbd/pg/exec.rb
ydbd-pg-0.5.4 lib/dbd/pg/exec.rb
ydbd-pg-0.5.3 lib/dbd/pg/exec.rb
ydbd-pg-0.5.2 lib/dbd/pg/exec.rb
ydbd-pg-0.5.1 lib/dbd/pg/exec.rb
ydbi-0.5.0 lib/dbd/pg/exec.rb
dbd-pg-0.3.9 lib/dbd/pg/exec.rb
dbd-pg-0.3.8 lib/dbd/pg/exec.rb
dbd-pg-0.3.5 lib/dbd/pg/exec.rb
dbd-pg-0.3.4 lib/dbd/pg/exec.rb
dbd-pg-0.3.3 lib/dbd/pg/exec.rb
dbd-pg-0.3.6 lib/dbd/pg/exec.rb
dbd-pg-0.3.7 lib/dbd/pg/exec.rb