postgresql_16:5.2.3.1 Creating a Large Object
PostgreSQL 16 > Client Interfaces > Large Objects > Client Interfaces > Creating a Large Object
The function Oid lo_create(PGconn *conn, Oid lobjId); creates a new large object. The OID to be assigned can be specified by *lobjId*; if so, failure occurs if that OID is already in use for some large object. If *lobjId* is InvalidOid (zero) then lo_create assigns an unused OID. The return value is the OID that was assigned to the new large object, or InvalidOid (zero) on failure.
An example: inv_oid = lo_create(conn, desired_oid);
The older function Oid lo_creat(PGconn *conn, int mode); also creates a new large object, always assigning an unused OID. The return value is the OID that was assigned to the new large object, or InvalidOid (zero) on failure.
In PostgreSQL releases 8.1 and later, the *mode* is ignored, so that lo_creat is exactly equivalent to lo_create with a zero second argument. However, there is little reason to use lo_creat unless you need to work with servers older than 8.1. To work with such an old server, you must use lo_creat not lo_create, and you must set *mode* to one of INV_READ, INV_WRITE, or INV_READ | INV_WRITE. (These symbolic constants are defined in the header file libpq/libpq-fs.h.)
An example: inv_oid = lo_creat(conn, INV_READ|INV_WRITE);