Skip to content

Commit a5a9d77

Browse files
committed
Doc: modernize documentation for lo_create()/lo_creat().
At this point lo_creat() is a legacy function with little if any real use-case, so describing it first doesn't make much sense. Describe lo_create() first, and then explain lo_creat() as a backwards-compatibility alternative. Discussion: https://postgr.es/m/164353261519.713.8748040527537500758@wrigleys.postgresql.org
1 parent 0526f2f commit a5a9d77

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

doc/src/sgml/lobj.sgml

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -138,57 +138,59 @@
138138
<title>Creating a Large Object</title>
139139

140140
<para>
141-
<indexterm><primary>lo_creat</primary></indexterm>
141+
<indexterm><primary>lo_create</primary></indexterm>
142142
The function
143143
<synopsis>
144-
Oid lo_creat(PGconn *conn, int mode);
144+
Oid lo_create(PGconn *conn, Oid lobjId);
145145
</synopsis>
146-
creates a new large object.
146+
creates a new large object. The OID to be assigned can be
147+
specified by <replaceable class="parameter">lobjId</replaceable>;
148+
if so, failure occurs if that OID is already in use for some large
149+
object. If <replaceable class="parameter">lobjId</replaceable>
150+
is <symbol>InvalidOid</symbol> (zero) then <function>lo_create</function>
151+
assigns an unused OID.
147152
The return value is the OID that was assigned to the new large object,
148153
or <symbol>InvalidOid</symbol> (zero) on failure.
149-
150-
<replaceable class="parameter">mode</replaceable> is unused and
151-
ignored as of <productname>PostgreSQL</productname> 8.1; however, for
152-
backward compatibility with earlier releases it is best to
153-
set it to <symbol>INV_READ</symbol>, <symbol>INV_WRITE</symbol>,
154-
or <symbol>INV_READ</symbol> <literal>|</literal> <symbol>INV_WRITE</symbol>.
155-
(These symbolic constants are defined
156-
in the header file <filename>libpq/libpq-fs.h</filename>.)
157154
</para>
158155

159156
<para>
160157
An example:
161158
<programlisting>
162-
inv_oid = lo_creat(conn, INV_READ|INV_WRITE);
159+
inv_oid = lo_create(conn, desired_oid);
163160
</programlisting>
164161
</para>
165162

166163
<para>
167-
<indexterm><primary>lo_create</primary></indexterm>
168-
The function
164+
<indexterm><primary>lo_creat</primary></indexterm>
165+
The older function
169166
<synopsis>
170-
Oid lo_create(PGconn *conn, Oid lobjId);
167+
Oid lo_creat(PGconn *conn, int mode);
171168
</synopsis>
172-
also creates a new large object. The OID to be assigned can be
173-
specified by <replaceable class="parameter">lobjId</replaceable>;
174-
if so, failure occurs if that OID is already in use for some large
175-
object. If <replaceable class="parameter">lobjId</replaceable>
176-
is <symbol>InvalidOid</symbol> (zero) then <function>lo_create</function> assigns an unused
177-
OID (this is the same behavior as <function>lo_creat</function>).
169+
also creates a new large object, always assigning an unused OID.
178170
The return value is the OID that was assigned to the new large object,
179171
or <symbol>InvalidOid</symbol> (zero) on failure.
180172
</para>
181173

182174
<para>
183-
<function>lo_create</function> is new as of <productname>PostgreSQL</productname>
184-
8.1; if this function is run against an older server version, it will
185-
fail and return <symbol>InvalidOid</symbol>.
175+
In <productname>PostgreSQL</productname> releases 8.1 and later,
176+
the <replaceable class="parameter">mode</replaceable> is ignored,
177+
so that <function>lo_creat</function> is exactly equivalent to
178+
<function>lo_create</function> with a zero second argument.
179+
However, there is little reason to use <function>lo_creat</function>
180+
unless you need to work with servers older than 8.1.
181+
To work with such an old server, you must
182+
use <function>lo_creat</function> not <function>lo_create</function>,
183+
and you must set <replaceable class="parameter">mode</replaceable> to
184+
one of <symbol>INV_READ</symbol>, <symbol>INV_WRITE</symbol>,
185+
or <symbol>INV_READ</symbol> <literal>|</literal> <symbol>INV_WRITE</symbol>.
186+
(These symbolic constants are defined
187+
in the header file <filename>libpq/libpq-fs.h</filename>.)
186188
</para>
187189

188190
<para>
189191
An example:
190192
<programlisting>
191-
inv_oid = lo_create(conn, desired_oid);
193+
inv_oid = lo_creat(conn, INV_READ|INV_WRITE);
192194
</programlisting>
193195
</para>
194196
</sect2>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy