From: Michael N. <mne...@us...> - 2002-09-26 13:40:36
|
Update of /cvsroot/ruby-dbi/src/lib/dbd_pg In directory usw-pr-cvs1:/tmp/cvs-serv7587 Modified Files: Pg.rb Log Message: removed method send_sql and inlined it's code instead (little speed improvement) Index: Pg.rb =================================================================== RCS file: /cvsroot/ruby-dbi/src/lib/dbd_pg/Pg.rb,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- Pg.rb 26 Sep 2002 13:32:58 -0000 1.26 +++ Pg.rb 26 Sep 2002 13:40:32 -0000 1.27 @@ -36,7 +36,7 @@ module DBD module Pg - VERSION = "0.3.1" + VERSION = "0.3.2" USED_DBD_VERSION = "0.2" class Driver < DBI::BaseDriver @@ -110,13 +110,13 @@ def disconnect unless @attr['AutoCommit'] - send_sql("ROLLBACK", 2) # rollback outstanding transactions + @connection.exec("ROLLBACK") # rollback outstanding transactions end @connection.close end def ping - answer = send_sql("SELECT 1", 3) + answer = @connection.exec("SELECT 1") if answer return answer.num_tuples == 1 else @@ -250,7 +250,7 @@ case attr when 'AutoCommit' # TODO: Are outstanding transactions committed? - send_sql("SET AUTOCOMMIT TO " + (value ? "ON" : "OFF"), 2) + @connection.exec("SET AUTOCOMMIT TO " + (value ? "ON" : "OFF")) when 'pg_client_encoding' @connection.set_client_encoding(value) else @@ -265,12 +265,12 @@ def commit # TODO: what if in autocommit mode? - send_sql("COMMIT", 2) + @connection.exec("COMMIT") end def rollback # TODO: what if in autocommit mode? - send_sql("ROLLBACK", 2) + @connection.exec("ROLLBACK") end # Other Public Methods --------------------------------------- @@ -282,11 +282,6 @@ @coerce.coerce(converter, obj) end - def send_sql(sql, level=1) - #puts "SQL TRACE: |#{sql}|" if @debug_level >= level - @connection.exec(sql) - end - def quote(value) # TODO: new quote function of Pg driver case value @@ -304,7 +299,7 @@ @type_map = Hash.new @coerce = PgCoerce.new - res = send_sql("SELECT typname, typelem FROM pg_type") + res = @connection.exec("SELECT typname, typelem FROM pg_type") res.result.each { |name, idstr| @type_map[idstr.to_i] = @@ -423,7 +418,7 @@ boundsql = @prep_sql.bind(@bindvars) - pg_result = @db.send_sql(boundsql) + pg_result = @db.connection.exec(boundsql) @result = Tuples.new(@db, pg_result) rescue PGError, RuntimeError => err |