The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DB::Object::Postgres::Lo - Large Object

SYNOPSIS

    use DB::Object::Postgres::Lo( $dbh );
    my $lo = DB::Object::Postgres::Lo->new || die( DB::Object::Postgres::Lo->error, "\n" );

DESCRIPTION

This is the PostgreSQL large object class

METHODS

new

Instantiate a new PostgreSQL large object.

This takes only parameter: a database handler (DB::Object or one of its inheriting package).

close

Close the large object by calling "pg_lo_close" in DBD::Pg

create

Provided with an octal mode such as 077 and this creates a new large object by calling "pg_lo_creat" in DBD::Pg passing it the octal mode.

Save the id returned in the object property id

It returns the id.

export_file

Provided with a file and this will export the large object to file by calling "pg_lo_export" in DBD::Pg and passing it the file.

Upon error, this returns an error, otherwise this returns the current object.

id

Sets or gets the id.

import_file

Provided with a file and this will import it as a large object by calling "pg_lo_import" in DBD::Pg and passing it the file.

This creates a new DB::Object::Postgres::Lo object, sets the id retrieved from PostgreSQL.

Upon error, this returns an error, otherwise this returns the newly created object.

import_with_oid

Provided with a file and an oid and this will import the file by calling "pg_lo_import_with_oid" in DBD::Pg passing it the file and the oid arguments.

Upon error, this returns an error, otherwise this returns a newly created DB::Object::Postgres::Lo object with the id set to the value returned by "pg_lo_import_with_oid" in DBD::Pg.

open

Provided with large object id and an octal mode, and this will open it by calling "pg_lo_open" in DBD::Pg passing it the id and the octal mode.

It will save the file handle returned in the object property fh

Upon error, this returns an error, otherwise this returns the current object.

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 "pg_lo_read" in DBD::Pg passing it the file handle, buffer and length.

Upon error, this returns an error, otherwise this returns the number of bytes actually read.

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 "pg_lo_lseek" in DBD::Pg 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 "pg_lo_lseek" in DBD::Pg

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 "pg_lo_tell" in DBD::Pg passing it only the file handle.

Upon error, this returns an error, otherwise this returns the current offset position received from "pg_lo_tell" in DBD::Pg

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 "pg_lo_truncate" in DBD::Pg passing it only the file handle.

Upon error, this returns an error, otherwise this returns the returned value received from "pg_lo_truncate" in DBD::Pg

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 "pg_lo_unlink" in DBD::Pg passing it only the file handle.

Upon error, this returns an error, otherwise this returns the returned value received from "pg_lo_unlink" in DBD::Pg

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 "pg_lo_write" in DBD::Pg passing it the file handle, the buffer and the length.

Upon error, this returns an error, otherwise this returns the actual number writen from "pg_lo_write" in DBD::Pg

SEE ALSO

DBD::Pg, DBI, Apache::DBI

AUTHOR

Jacques Deguest <jack@deguest.jp>

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.