Sha256: afdf2434272cfd0fffd244bf39e1a00a6bff23dc5ab3e2252da96384de8a008a

Contents?: true

Size: 1.08 KB

Versions: 17

Compression:

Stored size: 1.08 KB

Contents

require "postgres"

def main
  conn = PGconn.connect("localhost",5432,"","")
  puts("dbname: " + conn.db + "\thost: " + conn.host + "\tuser: " + conn.user)

  # Transaction
  conn.exec("BEGIN")
  lobj = conn.loimport("losample.rb")
  lobjnum = lobj.oid
  puts("loimport ok! oid=" + lobj.oid.to_s)
  lobj.open
  lobj.seek(0,PGlarge::SEEK_SET) # SEEK_SET or SEEK_CUR or SEEK_END
  buff =  lobj.read(18)
  puts buff
  if 'require "postgres"' == buff
    puts "read ok!"
  end
  lobj.seek(0,PGlarge::SEEK_END)
  buff = lobj.write("write test ok?\n")
  puts lobj.tell
  puts 'export test .file:lowrite.losample add "write test of?"...'
  lobj.export("lowrite.txt")
  lobj.close
  conn.exec("COMMIT")
  begin
    lobj.read(1)
    puts "boo!"
    return
  rescue
    puts "ok! Large Object is closed"
  end
  conn.exec("BEGIN")
  puts lobjnum.to_s
  lobj = conn.loopen(lobjnum)
  puts "large object reopen ok!"
  lobj.seek(0,PGlarge::SEEK_SET) # SEEK_SET or SEEK_CUR or SEEK_END
  buff =  lobj.read(18)
  puts buff
  puts "reread ok!"
  conn.exec("COMMIT")
  lobj.unlink
  puts "large object unlink"
end

main

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
ruby-postgres-0.7.1.2005.11.24-mswin32 sample/losample.rb
ruby-postgres-0.7.1.2006.04.06-mswin32 sample/losample.rb
ruby-postgres-0.7.1.2006.04.05-mswin32 sample/losample.rb
ruby-postgres-0.7.1.2005.12.21-mswin32 sample/losample.rb
ruby-postgres-0.7.1.2005.12.20-mswin32 sample/losample.rb
ruby-postgres-0.7.1.2005.12.19-mswin32 sample/losample.rb
ruby-postgres-0.7.1.2005.11.27-mswin32 sample/losample.rb
postgres-0.7.1 sample/losample.rb
ruby-postgres-0.7.1.2005.11.27 sample/losample.rb
ruby-postgres-0.7.1.2005.12.19 sample/losample.rb
ruby-postgres-0.7.1.2005.11.23 sample/losample.rb
ruby-postgres-0.7.1.2005.12.20 sample/losample.rb
ruby-postgres-0.7.1.2005.11.24 sample/losample.rb
ruby-postgres-0.7.1.2005.11.26 sample/losample.rb
ruby-postgres-0.7.1.2006.04.05 sample/losample.rb
ruby-postgres-0.7.1.2006.04.06 sample/losample.rb
ruby-postgres-0.7.1.2005.12.21 sample/losample.rb