agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: pgsql-sql <pgsql-sql@fc.emc.com.ph>
To: pgsql-sql@postgresql.org
To: craig.may@s2.enthdimension.com.au
Subject: Re: Large Objects
Date: Tue, 24 Oct 2000 11:29:31 +0800
Message-ID: <fc.000f56720076f41a000f56720076f41a.76f4d3@fc.emc.com.ph> (raw)
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
view thread (16+ messages) latest in thread
Message-ID: <fc.000f56720076f41a000f56720076f41a.76f4d3@fc.emc.com.ph>
Permalink: ../fc.000f56720076f41a000f56720076f41a.76f4d3@fc.emc.com.ph/
Also on: postgresql.org/message-id/fc.000f56720076f41a000f56720076f41a.76f4d3@fc.emc.com.ph
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: pgsql-sql@fc.emc.com.ph, craig.may@s2.enthdimension.com.au
Subject: Re: Large Objects
In-Reply-To: <fc.000f56720076f41a000f56720076f41a.76f4d3@fc.emc.com.ph>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox