Acasa Tehnologie Large Objects in PostgreSQL

Large Objects in PostgreSQL

by Dragos Schiopu

PostgreSQL has a large object facility, which provides stream-style access to user data that is stored in a special large-object structure. Streaming access is useful when working with data values that are too large to manipulate conveniently as a whole.
This chapter describes the implementation and the programming and query language interfaces to PostgreSQL large object data. We use the libpq C library for the examples in this chapter, but most programming interfaces native to PostgreSQL support equivalent functionality. Other interfaces may use the large object interface internally to provide generic support for large values. This is not described here.
The large object implementation breaks large objects up into „chunks” and stores the chunks in rows in the database. A B-tree index guarantees fast searches for the correct chunk number when doing random access reads and writes.

Functii PHP pentru lucrul cu large objects:
pg_lo_close(); http://www.php.net/manual/en/function.pg-lo-close.php
pg_lo_close() closes a large object. large_object is a resource for the large object from pg_lo_open(). To use the large object interface, it is necessary to enclose it within a transaction block.

pg_lo_create(); http://www.php.net/manual/en/function.pg-lo-create.php
pg_lo_create() creates a large object and returns the OID of the large object. The object is created always with both read and write access. To use the large object interface, it is necessary to enclose it within a  transaction block.

pg_lo_export(); http://www.php.net/manual/en/function.pg-lo-export.php
pg_lo_export() takes a large object in a PostgreSQL database and saves its contents to a file on the local filesystem. To use the large object interface, it is necessary to enclose it within a transaction block.

pg_lo_import(); http://www.php.net/manual/en/function.pg-lo-import.php
pg_lo_import() creates a new large object in the database using a file on the filesystem as its data source.
To use the large object interface, it is necessary to enclose it within a transaction block.

pg_lo_open(); http://www.php.net/manual/en/function.pg-lo-open.php
pg_lo_open() opens a large object in the database and returns large object resource so that it can be manipulated.
Warning!
Do not close the database connection before closing the large object resource. To use the large object interface, it is necessary to enclose it within a transaction block.

pg_lo_read_all(); http://www.php.net/manual/en/function.pg-lo-read-all.php
pg_lo_read_all() reads a large object and passes it straight through to the browser after sending all pending headers. Mainly intended for sending binary data like images or sound. To use the large object interface, it is necessary to enclose it within a transaction block.

pg_lo_read(); http://www.php.net/manual/en/function.pg-lo-read.php
pg_lo_read() reads at most len bytes from a large object and returns it as a string. To use the large object interface, it is necessary to enclose it within a transaction block.

pg_lo_seek(); http://www.php.net/manual/en/function.pg-lo-seek.php
pg_lo_seek() seeks a position within a large object resource. To use the large object interface, it is necessary to enclose it within a transaction block.

pg_lo_tell(); http://www.php.net/manual/en/function.pg-lo-tell.php
pg_lo_tell() returns the current position (offset from the beginning) of a large object. To use the large object interface, it is necessary to enclose it within a transaction block.

pg_lo_unlink(); http://www.php.net/manual/en/function.pg-lo-unlink.php
pg_lo_unlink() deletes a large object with the oid . Returns TRUE on success or FALSE on failure. To use the large object interface, it is necessary to enclose it within a transaction block.

pg_lo_write(); http://www.php.net/manual/en/function.pg-lo-write.php
pg_lo_write() writes data into a large object at the current seek position. To use the large object interface, it is necessary to enclose it within a transaction block.

s-ar putea sa-ti placa