Module Sequel::JDBC::Postgres::DatabaseMethods
In: lib/sequel/adapters/jdbc/postgresql.rb

Methods

Included Modules

Sequel::Postgres::DatabaseMethods

Public Class methods

Add the primary_keys and primary_key_sequences instance variables, so we can get the correct return values for inserted rows.

[Source]

    # File lib/sequel/adapters/jdbc/postgresql.rb, line 40
40:         def self.extended(db)
41:           super
42:           db.send(:initialize_postgres_adapter)
43:         end

Public Instance methods

Remove any current entry for the oid in the oid_convertor_map.

[Source]

    # File lib/sequel/adapters/jdbc/postgresql.rb, line 46
46:         def add_conversion_proc(oid, *)
47:           super
48:           Sequel.synchronize{@oid_convertor_map.delete(oid)}
49:         end

See Sequel::Postgres::Adapter#copy_into

[Source]

    # File lib/sequel/adapters/jdbc/postgresql.rb, line 52
52:         def copy_into(table, opts=OPTS)
53:           data = opts[:data]
54:           data = Array(data) if data.is_a?(String)
55: 
56:           if block_given? && data
57:             raise Error, "Cannot provide both a :data option and a block to copy_into"
58:           elsif !block_given? && !data
59:             raise Error, "Must provide either a :data option or a block to copy_into"
60:           end
61: 
62:           synchronize(opts[:server]) do |conn|
63:             begin
64:               copy_manager = org.postgresql.copy.CopyManager.new(conn)
65:               copier = copy_manager.copy_in(copy_into_sql(table, opts))
66:               if block_given?
67:                 while buf = yield
68:                   java_bytes = buf.to_java_bytes
69:                   copier.writeToCopy(java_bytes, 0, java_bytes.length)
70:                 end
71:               else
72:                 data.each do |d|
73:                   java_bytes = d.to_java_bytes
74:                   copier.writeToCopy(java_bytes, 0, java_bytes.length)
75:                 end
76:               end
77:             rescue Exception => e
78:               copier.cancelCopy if copier
79:               raise
80:             ensure
81:               unless e
82:                 begin
83:                   copier.endCopy
84:                 rescue NativeException => e2
85:                   raise_error(e2)
86:                 end
87:               end
88:             end
89:           end
90:         end

See Sequel::Postgres::Adapter#copy_table

[Source]

     # File lib/sequel/adapters/jdbc/postgresql.rb, line 93
 93:         def copy_table(table, opts=OPTS)
 94:           synchronize(opts[:server]) do |conn|
 95:             copy_manager = org.postgresql.copy.CopyManager.new(conn)
 96:             copier = copy_manager.copy_out(copy_table_sql(table, opts))
 97:             begin
 98:               if block_given?
 99:                 while buf = copier.readFromCopy
100:                   yield(String.from_java_bytes(buf))
101:                 end
102:                 nil
103:               else
104:                 b = String.new
105:                 while buf = copier.readFromCopy
106:                   b << String.from_java_bytes(buf)
107:                 end
108:                 b
109:               end
110:             rescue => e
111:               raise_error(e, :disconnect=>true)
112:             ensure
113:               if buf && !e
114:                 raise DatabaseDisconnectError, "disconnecting as a partial COPY may leave the connection in an unusable state"
115:               end
116:             end
117:           end
118:         end

[Source]

     # File lib/sequel/adapters/jdbc/postgresql.rb, line 120
120:         def oid_convertor_proc(oid)
121:           if (conv = Sequel.synchronize{@oid_convertor_map[oid]}).nil?
122:             conv = if pr = conversion_procs[oid]
123:               lambda do |r, i|
124:                 if v = r.getString(i)
125:                   pr.call(v)
126:                 end
127:               end
128:             else
129:               false
130:             end
131:             Sequel.synchronize{@oid_convertor_map[oid] = conv}
132:           end
133:           conv
134:         end

[Validate]