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