Received: from jennifer.emc.com.ph (una-jennifer.emc.com.ph [208.232.224.3]) by hub.org (8.10.1/8.11.0) with ESMTP id e9O3TTO73559 for ; Mon, 23 Oct 2000 23:29:30 -0400 (EDT) (envelope-from pgsql-sql@fc.emc.com.ph) Received: from fc.emc.com.ph (fc.emc.com.ph [208.232.224.197]) by jennifer.emc.com.ph (Postfix) with ESMTP id 8D2C4D750; Tue, 24 Oct 2000 11:29:05 +0800 (PST) Message-id: Date: Tue, 24 Oct 2000 11:29:31 +0800 Subject: Re: Large Objects To: pgsql-sql@postgresql.org, craig.may@s2.enthdimension.com.au From: "pgsql-sql" MIME-Version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200010/203 X-Sequence-Number: 1865 FROM test.pl of DBD-Pg-0.93.tar ... ######################### test large objects # create large object from binary file my ($ascii, $pgin); foreach $ascii (0..255) { $pgin .= chr($ascii); }; my $PGIN = '/tmp/pgin'; open(PGIN, ">$PGIN") or die "can not open $PGIN"; print PGIN $pgin; close PGIN; # begin transaction $dbh->{AutoCommit} = 0; my $lobjId; ( $lobjId = $dbh->func($PGIN, 'lo_import') ) and print "\$dbh->func(lo_import) ...... ok\n" or print "\$dbh->func(lo_import) ...... not ok\n"; # end transaction $dbh->{AutoCommit} = 1; unlink $PGIN; # blob_read # begin transaction $dbh->{AutoCommit} = 0; $sth = $dbh->prepare( "" ) or die $DBI::errstr; my $blob; ( $blob = $sth->blob_read($lobjId, 0, 0) ) and print "\$sth->blob_read ............ ok\n" or print "\$sth->blob_read ............ not ok\n"; $sth->finish or die $DBI::errstr; # end transaction $dbh->{AutoCommit} = 1; # read large object using lo-functions # begin transaction $dbh->{AutoCommit} = 0; my $lobj_fd; # may be 0 ( defined($lobj_fd = $dbh->func($lobjId, $dbh->{pg_INV_READ}, 'lo_open')) ) and print "\$dbh->func(lo_open) ........ ok\n" or print "\$dbh->func(lo_open) ........ not ok\n"; ( 0 == $dbh->func($lobj_fd, 0, 0, 'lo_lseek') ) and print "\$dbh->func(lo_lseek) ....... ok\n" or print "\$dbh->func(lo_lseek) ....... not ok\n"; my $buf = ''; ( 256 == $dbh->func($lobj_fd, $buf, 256, 'lo_read') ) and print "\$dbh->func(lo_read) ........ ok\n" or print "\$dbh->func(lo_read) ........ not ok\n"; ( 256 == $dbh->func($lobj_fd, 'lo_tell') ) and print "\$dbh->func(lo_tell) ........ ok\n" or print "\$dbh->func(lo_tell) ........ not ok\n"; ( $dbh->func($lobj_fd, 'lo_close') ) and print "\$dbh->func(lo_close) ....... ok\n" or print "\$dbh->func(lo_close) ....... not ok\n"; ( $dbh->func($lobjId, 'lo_unlink') ) and print "\$dbh->func(lo_unlink) ...... ok\n" or print "\$dbh->func(lo_unlink) ...... not ok\n"; # end transaction $dbh->{AutoCommit} = 1; # compare large objects ( $pgin cmp $buf and $pgin cmp $blob ) and print "compare blobs .............. not ok\n" or print "compare blobs .............. ok\n"; ######################### craig.may@s2.enthdimension.com.au writes: >Hi, > >Could someone please provide a demo of creating the type "Lo". > >Regards, >Craig May > >Enth Dimension >http://www.enthdimension.com.au