| 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 18
18: def self.extended(db)
19: super
20: db.send(:initialize_postgres_adapter)
21: end
See Sequel::Postgres::Adapter#copy_into
# File lib/sequel/adapters/jdbc/postgresql.rb, line 24
24: def copy_into(table, opts={})
25: data = opts[:data]
26: data = Array(data) if data.is_a?(String)
27:
28: if block_given? && data
29: raise Error, "Cannot provide both a :data option and a block to copy_into"
30: elsif !block_given? && !data
31: raise Error, "Must provide either a :data option or a block to copy_into"
32: end
33:
34: synchronize(opts) do |conn|
35: begin
36: copy_manager = org.postgresql.copy.CopyManager.new(conn)
37: copier = copy_manager.copy_in(copy_into_sql(table, opts))
38: if block_given?
39: while buf = yield
40: copier.writeToCopy(buf.to_java_bytes, 0, buf.length)
41: end
42: else
43: data.each { |d| copier.writeToCopy(d.to_java_bytes, 0, d.length) }
44: end
45: rescue Exception => e
46: copier.cancelCopy
47: raise
48: ensure
49: unless e
50: begin
51: copier.endCopy
52: rescue NativeException => e2
53: raise_error(e2)
54: end
55: end
56: end
57: end
58: end
See Sequel::Postgres::Adapter#copy_table
# File lib/sequel/adapters/jdbc/postgresql.rb, line 61
61: def copy_table(table, opts={})
62: synchronize(opts[:server]) do |conn|
63: copy_manager = org.postgresql.copy.CopyManager.new(conn)
64: copier = copy_manager.copy_out(copy_table_sql(table, opts))
65: begin
66: if block_given?
67: while buf = copier.readFromCopy
68: yield(String.from_java_bytes(buf))
69: end
70: nil
71: else
72: b = ''
73: while buf = copier.readFromCopy
74: b << String.from_java_bytes(buf)
75: end
76: b
77: end
78: ensure
79: raise DatabaseDisconnectError, "disconnecting as a partial COPY may leave the connection in an unusable state" if buf
80: end
81: end
82: end