Module: Sequel::JDBC::Postgres::DatabaseMethods
- Includes:
- Postgres::DatabaseMethods
- Defined in:
- lib/sequel/adapters/jdbc/postgresql.rb
Constant Summary
Constants included from Postgres::DatabaseMethods
Postgres::DatabaseMethods::FOREIGN_KEY_LIST_ON_DELETE_MAP, Postgres::DatabaseMethods::ON_COMMIT, Postgres::DatabaseMethods::SELECT_CUSTOM_SEQUENCE_SQL, Postgres::DatabaseMethods::SELECT_PK_SQL, Postgres::DatabaseMethods::SELECT_SERIAL_SEQUENCE_SQL
Instance Attribute Summary
Attributes included from Postgres::DatabaseMethods
Class Method Summary collapse
- 
  
    
      .extended(db)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Add the primary_keys and primary_key_sequences instance variables, so we can get the correct return values for inserted rows. 
Instance Method Summary collapse
- 
  
    
      #add_conversion_proc(oid)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Remove any current entry for the oid in the oid_convertor_map. 
- 
  
    
      #copy_into(table, opts = OPTS)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    See Sequel::Postgres::Adapter#copy_into. 
- 
  
    
      #copy_table(table, opts = OPTS)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    See Sequel::Postgres::Adapter#copy_table. 
- #oid_convertor_proc(oid) ⇒ Object
Methods included from Postgres::DatabaseMethods
#add_named_conversion_proc, #check_constraints, #commit_prepared_transaction, #convert_serial_to_identity, #create_function, #create_language, #create_schema, #create_table, #create_table?, #create_trigger, #database_type, #defer_constraints, #do, #drop_function, #drop_language, #drop_schema, #drop_trigger, #foreign_key_list, #freeze, #immediate_constraints, #indexes, #locks, #notify, #primary_key, #primary_key_sequence, #refresh_view, #rename_schema, #reset_primary_key_sequence, #rollback_prepared_transaction, #serial_primary_key_options, #server_version, #supports_create_table_if_not_exists?, #supports_deferrable_constraints?, #supports_deferrable_foreign_key_constraints?, #supports_drop_table_if_exists?, #supports_partial_indexes?, #supports_prepared_transactions?, #supports_savepoints?, #supports_transaction_isolation_levels?, #supports_transactional_ddl?, #supports_trigger_conditions?, #tables, #type_supported?, #values, #views, #with_advisory_lock
Class Method Details
.extended(db) ⇒ Object
Add the primary_keys and primary_key_sequences instance variables, so we can get the correct return values for inserted rows.
| 22 23 24 25 | # File 'lib/sequel/adapters/jdbc/postgresql.rb', line 22 def self.extended(db) super db.send(:initialize_postgres_adapter) end | 
Instance Method Details
#add_conversion_proc(oid) ⇒ Object
Remove any current entry for the oid in the oid_convertor_map.
| 28 29 30 31 | # File 'lib/sequel/adapters/jdbc/postgresql.rb', line 28 def add_conversion_proc(oid, *) super Sequel.synchronize{@oid_convertor_map.delete(oid)} end | 
#copy_into(table, opts = OPTS) ⇒ Object
See Sequel::Postgres::Adapter#copy_into
| 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # File 'lib/sequel/adapters/jdbc/postgresql.rb', line 34 def copy_into(table, opts=OPTS) data = opts[:data] data = Array(data) if data.is_a?(String) if defined?(yield) && data raise Error, "Cannot provide both a :data option and a block to copy_into" elsif !defined?(yield) && !data raise Error, "Must provide either a :data option or a block to copy_into" end synchronize(opts[:server]) do |conn| begin copy_manager = Java::OrgPostgresqlCopy::CopyManager.new(conn) copier = copy_manager.copy_in(copy_into_sql(table, opts)) if defined?(yield) while buf = yield java_bytes = buf.to_java_bytes copier.writeToCopy(java_bytes, 0, java_bytes.length) end else data.each do |d| java_bytes = d.to_java_bytes copier.writeToCopy(java_bytes, 0, java_bytes.length) end end rescue Exception => e copier.cancelCopy if copier raise ensure unless e begin copier.endCopy rescue NativeException => e2 raise_error(e2) end end end end end | 
#copy_table(table, opts = OPTS) ⇒ Object
See Sequel::Postgres::Adapter#copy_table
| 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | # File 'lib/sequel/adapters/jdbc/postgresql.rb', line 75 def copy_table(table, opts=OPTS) synchronize(opts[:server]) do |conn| copy_manager = Java::OrgPostgresqlCopy::CopyManager.new(conn) copier = copy_manager.copy_out(copy_table_sql(table, opts)) begin if defined?(yield) while buf = copier.readFromCopy yield(String.from_java_bytes(buf)) end nil else b = String.new while buf = copier.readFromCopy b << String.from_java_bytes(buf) end b end rescue => e raise_error(e, :disconnect=>true) ensure if buf && !e raise DatabaseDisconnectError, "disconnecting as a partial COPY may leave the connection in an unusable state" end end end end | 
#oid_convertor_proc(oid) ⇒ Object
| 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | # File 'lib/sequel/adapters/jdbc/postgresql.rb', line 102 def oid_convertor_proc(oid) if (conv = Sequel.synchronize{@oid_convertor_map[oid]}).nil? conv = if pr = conversion_procs[oid] lambda do |r, i| if v = r.getString(i) pr.call(v) end end else false end Sequel.synchronize{@oid_convertor_map[oid] = conv} end conv end |