|
138 | 138 | <title>Creating a Large Object</title>
|
139 | 139 |
|
140 | 140 | <para>
|
141 |
| - <indexterm><primary>lo_creat</primary></indexterm> |
| 141 | + <indexterm><primary>lo_create</primary></indexterm> |
142 | 142 | The function
|
143 | 143 | <synopsis>
|
144 |
| -Oid lo_creat(PGconn *conn, int mode); |
| 144 | +Oid lo_create(PGconn *conn, Oid lobjId); |
145 | 145 | </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. |
147 | 152 | The return value is the OID that was assigned to the new large object,
|
148 | 153 | 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>.) |
157 | 154 | </para>
|
158 | 155 |
|
159 | 156 | <para>
|
160 | 157 | An example:
|
161 | 158 | <programlisting>
|
162 |
| -inv_oid = lo_creat(conn, INV_READ|INV_WRITE); |
| 159 | +inv_oid = lo_create(conn, desired_oid); |
163 | 160 | </programlisting>
|
164 | 161 | </para>
|
165 | 162 |
|
166 | 163 | <para>
|
167 |
| - <indexterm><primary>lo_create</primary></indexterm> |
168 |
| - The function |
| 164 | + <indexterm><primary>lo_creat</primary></indexterm> |
| 165 | + The older function |
169 | 166 | <synopsis>
|
170 |
| -Oid lo_create(PGconn *conn, Oid lobjId); |
| 167 | +Oid lo_creat(PGconn *conn, int mode); |
171 | 168 | </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. |
178 | 170 | The return value is the OID that was assigned to the new large object,
|
179 | 171 | or <symbol>InvalidOid</symbol> (zero) on failure.
|
180 | 172 | </para>
|
181 | 173 |
|
182 | 174 | <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>.) |
186 | 188 | </para>
|
187 | 189 |
|
188 | 190 | <para>
|
189 | 191 | An example:
|
190 | 192 | <programlisting>
|
191 |
| -inv_oid = lo_create(conn, desired_oid); |
| 193 | +inv_oid = lo_creat(conn, INV_READ|INV_WRITE); |
192 | 194 | </programlisting>
|
193 | 195 | </para>
|
194 | 196 | </sect2>
|
|
0 commit comments