Add the primary_keys and primary_key_sequences instance variables, so we can get the correct return values for inserted rows.
# File lib/sequel/adapters/jdbc/postgresql.rb, line 17 def self.extended(db) db.send(:initialize_postgres_adapter) end
See Sequel::Postgres::Adapter#copy_into
# File lib/sequel/adapters/jdbc/postgresql.rb, line 22 def copy_into(table, opts={}) data = opts[:data] data = Array(data) if data.is_a?(String) if block_given? && data raise Error, "Cannot provide both a :data option and a block to copy_into" elsif !block_given? && !data raise Error, "Must provide either a :data option or a block to copy_into" end synchronize(opts) do |conn| begin copy_manager = org.postgresql.copy.CopyManager.new(conn) copier = copy_manager.copy_in(copy_into_sql(table, opts)) if block_given? while buf = yield copier.writeToCopy(buf.to_java_bytes, 0, buf.length) end else data.each { |d| copier.writeToCopy(d.to_java_bytes, 0, d.length) } end rescue Exception => e copier.cancelCopy raise ensure unless e begin copier.endCopy rescue NativeException => e2 raise_error(e2) end end end end end
See Sequel::Postgres::Adapter#copy_table
# File lib/sequel/adapters/jdbc/postgresql.rb, line 59 def copy_table(table, opts={}) synchronize(opts[:server]) do |conn| copy_manager = org.postgresql.copy.CopyManager.new(conn) copier = copy_manager.copy_out(copy_table_sql(table, opts)) begin if block_given? while buf = copier.readFromCopy yield(String.from_java_bytes(buf)) end nil else b = '' while buf = copier.readFromCopy b << String.from_java_bytes(buf) end b end ensure raise DatabaseDisconnectError, "disconnecting as a partial COPY may leave the connection in an unusable state" if buf end end end
Use setNull for nil arguments as the default behavior of setString with nil doesn't appear to work correctly on PostgreSQL.
# File lib/sequel/adapters/jdbc/postgresql.rb, line 86 def set_ps_arg_nil(cps, i) cps.setNull(i, JavaSQL::Types::NULL) end
Execute the connection configuration SQL queries on the connection.
# File lib/sequel/adapters/jdbc/postgresql.rb, line 91 def setup_connection(conn) conn = super(conn) statement(conn) do |stmt| connection_configuration_sqls.each{|sql| log_yield(sql){stmt.execute(sql)}} end conn end