return( $self->error( "Unable to write to the large object file descriptor.") ) if( !defined( $bytes) );
return( $bytes);
}
1;
# NOTE: POD
__END__
=encoding utf-8
=head1 NAME
DB::Object::Postgres::Lo - Large Object
=head1 SYNOPSIS
use DB::Object::Postgres::Lo( $dbh );
my $lo = DB::Object::Postgres::Lo->new || die( DB::Object::Postgres::Lo->error, "\n" );
=head1 DESCRIPTION
This is the PostgreSQL large object class
=head1 METHODS
=head2 new
Instantiate a new PostgreSQL large object.
This takes only parameter: a database handler (L<DB::Object> or one of its inheriting package).
=head2 close
Close the large object by calling L<DBD::Pg/pg_lo_close>
=head2 create
Provided with an octal mode such as 077 and this creates a new large object by calling L<DBD::Pg/pg_lo_creat> passing it the octal mode.
Save the id returned in the object property C<id>
It returns the id.
=head2 export_file
Provided with a file and this will export the large object to file by calling L<DBD::Pg/pg_lo_export> and passing it the file.
Upon error, this returns an error, otherwise this returns the current object.
=head2 id
Sets or gets the id.
=head2 import_file
Provided with a file and this will import it as a large object by calling L<DBD::Pg/pg_lo_import> and passing it the file.
This creates a new L<DB::Object::Postgres::Lo> object, sets the id retrieved from PostgreSQL.
Upon error, this returns an error, otherwise this returns the newly created object.
=head2 import_with_oid
Provided with a file and an oid and this will import the file by calling L<DBD::Pg/pg_lo_import_with_oid> passing it the file and the oid arguments.
Upon error, this returns an error, otherwise this returns a newly created L<DB::Object::Postgres::Lo> object with the id set to the value returned by L<DBD::Pg/pg_lo_import_with_oid>.
=head2 open
Provided with large object id and an octal mode, and this will open it by calling L<DBD::Pg/pg_lo_open> passing it the id and the octal mode.
It will save the file handle returned in the object property C<fh>
Upon error, this returns an error, otherwise this returns the current object.
=head2 read
This method requires the large object to have been opened before so that a file handle is readily available.
Provided with a buffer and a length and this will attempt to read the length provided into the buffer by calling L<DBD::Pg/pg_lo_read> passing it the file handle, buffer and length.
Upon error, this returns an error, otherwise this returns the number of bytes actually read.
=head2 seek
This method requires the large object to have been opened before so that a file handle is readily available.
Provided with an offset and a whence and this will attempt to do a seek by calling L<DBD::Pg/pg_lo_lseek> passing it the file handle, the offset and the whence.
Upon error, this returns an error, otherwise this returns the new offset position received from L<DBD::Pg/pg_lo_lseek>
=head2 tell
This method requires the large object to have been opened before so that a file handle is readily available.
This will attempt to do a tell by calling L<DBD::Pg/pg_lo_tell> passing it only the file handle.
Upon error, this returns an error, otherwise this returns the current offset position received from L<DBD::Pg/pg_lo_tell>
=head2 truncate
This method requires the large object to have been opened before so that a file handle is readily available.
This will attempt to do a tell by calling L<DBD::Pg/pg_lo_truncate> passing it only the file handle.
Upon error, this returns an error, otherwise this returns the returned value received from L<DBD::Pg/pg_lo_truncate>
=head2 unlink
This method requires the large object to have been opened before so that a file handle is readily available.
This will attempt to remove the file by calling L<DBD::Pg/pg_lo_unlink> passing it only the file handle.
Upon error, this returns an error, otherwise this returns the returned value received from L<DBD::Pg/pg_lo_unlink>
=head2 write
This method requires the large object to have been opened before so that a file handle is readily available.
Provided with a buffer and a length and this will attempt to write to the large object by calling L<DBD::Pg/pg_lo_write> passing it the file handle, the buffer and the length.
Upon error, this returns an error, otherwise this returns the actual number writen from L<DBD::Pg/pg_lo_write>
=head1 SEE ALSO
L<DBD::Pg>, L<DBI>, L<Apache::DBI>
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2019-2021 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
=cut
Keyboard Shortcuts
Global
s
Focus search bar
?
Bring up this help dialog
GitHub
gp
Go to pull requests
gi
go to github issues (only if github is preferred repository)