Module | Sequel::JDBC::Postgres::DatabaseMethods |
In: |
lib/sequel/adapters/jdbc/postgresql.rb
|
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 47 47: def self.extended(db) 48: super 49: db.send(:initialize_postgres_adapter) 50: end
See Sequel::Postgres::Adapter#copy_into
# File lib/sequel/adapters/jdbc/postgresql.rb, line 53 53: def copy_into(table, opts=OPTS) 54: data = opts[:data] 55: data = Array(data) if data.is_a?(String) 56: 57: if block_given? && data 58: raise Error, "Cannot provide both a :data option and a block to copy_into" 59: elsif !block_given? && !data 60: raise Error, "Must provide either a :data option or a block to copy_into" 61: end 62: 63: synchronize(opts) do |conn| 64: begin 65: copy_manager = org.postgresql.copy.CopyManager.new(conn) 66: copier = copy_manager.copy_in(copy_into_sql(table, opts)) 67: if block_given? 68: while buf = yield 69: copier.writeToCopy(buf.to_java_bytes, 0, buf.length) 70: end 71: else 72: data.each { |d| copier.writeToCopy(d.to_java_bytes, 0, d.length) } 73: end 74: rescue Exception => e 75: copier.cancelCopy 76: raise 77: ensure 78: unless e 79: begin 80: copier.endCopy 81: rescue NativeException => e2 82: raise_error(e2) 83: end 84: end 85: end 86: end 87: end
See Sequel::Postgres::Adapter#copy_table
# File lib/sequel/adapters/jdbc/postgresql.rb, line 90 90: def copy_table(table, opts=OPTS) 91: synchronize(opts[:server]) do |conn| 92: copy_manager = org.postgresql.copy.CopyManager.new(conn) 93: copier = copy_manager.copy_out(copy_table_sql(table, opts)) 94: begin 95: if block_given? 96: while buf = copier.readFromCopy 97: yield(String.from_java_bytes(buf)) 98: end 99: nil 100: else 101: b = '' 102: while buf = copier.readFromCopy 103: b << String.from_java_bytes(buf) 104: end 105: b 106: end 107: ensure 108: raise DatabaseDisconnectError, "disconnecting as a partial COPY may leave the connection in an unusable state" if buf 109: end 110: end 111: end
# File lib/sequel/adapters/jdbc/postgresql.rb, line 113 113: def oid_convertor_proc(oid) 114: if (conv = Sequel.synchronize{@oid_convertor_map[oid]}).nil? 115: conv = if pr = conversion_procs[oid] 116: lambda do |r, i| 117: if v = r.getString(i) 118: pr.call(v) 119: end 120: end 121: else 122: false 123: end 124: Sequel.synchronize{@oid_convertor_map[oid] = conv} 125: end 126: conv 127: end