| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>BFILE C/C++ Objects and Functions</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Getting Started with the Oracle Berkeley DB SQL APIs" /> |
| 10 | <link rel="up" href="bfile-extension.html" title="Appendix A. Using the BFILE Extension" /> |
| 11 | <link rel="prev" href="bfile-sql.html" title="BFILE SQL Objects and Functions" /> |
| 12 | </head> |
| 13 | <body> |
| 14 | <div xmlns="" class="navheader"> |
| 15 | <div class="libver"> |
| 16 | <p>Library Version 11.2.5.3</p> |
| 17 | </div> |
| 18 | <table width="100%" summary="Navigation header"> |
| 19 | <tr> |
| 20 | <th colspan="3" align="center">BFILE C/C++ Objects and Functions</th> |
| 21 | </tr> |
| 22 | <tr> |
| 23 | <td width="20%" align="left"><a accesskey="p" href="bfile-sql.html">Prev</a> </td> |
| 24 | <th width="60%" align="center">Appendix A. Using the BFILE Extension</th> |
| 25 | <td width="20%" align="right"> </td> |
| 26 | </tr> |
| 27 | </table> |
| 28 | <hr /> |
| 29 | </div> |
| 30 | <div class="sect1" lang="en" xml:lang="en"> |
| 31 | <div class="titlepage"> |
| 32 | <div> |
| 33 | <div> |
| 34 | <h2 class="title" style="clear: both"><a id="bfile-c"></a>BFILE C/C++ Objects and Functions</h2> |
| 35 | </div> |
| 36 | </div> |
| 37 | </div> |
| 38 | <div class="toc"> |
| 39 | <dl> |
| 40 | <dt> |
| 41 | <span class="sect2"> |
| 42 | <a href="bfile-c.html#sqlite3_column_bfile">sqlite3_column_bfile</a> |
| 43 | </span> |
| 44 | </dt> |
| 45 | <dt> |
| 46 | <span class="sect2"> |
| 47 | <a href="bfile-c.html#sqlite3_bfile_open">sqlite3_bfile_open</a> |
| 48 | </span> |
| 49 | </dt> |
| 50 | <dt> |
| 51 | <span class="sect2"> |
| 52 | <a href="bfile-c.html#sqlite3_bfile_close">sqlite3_bfile_close</a> |
| 53 | </span> |
| 54 | </dt> |
| 55 | <dt> |
| 56 | <span class="sect2"> |
| 57 | <a href="bfile-c.html#sqlite3_bfile_is_open">sqlite3_bfile_is_open</a> |
| 58 | </span> |
| 59 | </dt> |
| 60 | <dt> |
| 61 | <span class="sect2"> |
| 62 | <a href="bfile-c.html#sqlite3_bfile_read">sqlite3_bfile_read</a> |
| 63 | </span> |
| 64 | </dt> |
| 65 | <dt> |
| 66 | <span class="sect2"> |
| 67 | <a href="bfile-c.html#sqlite3_bfile_file_exists">sqlite3_bfile_file_exists</a> |
| 68 | </span> |
| 69 | </dt> |
| 70 | <dt> |
| 71 | <span class="sect2"> |
| 72 | <a href="bfile-c.html#sqlite3_bfile_size">sqlite3_bfile_size</a> |
| 73 | </span> |
| 74 | </dt> |
| 75 | <dt> |
| 76 | <span class="sect2"> |
| 77 | <a href="bfile-c.html#sqlite3_bfile_final">sqlite3_bfile_final</a> |
| 78 | </span> |
| 79 | </dt> |
| 80 | </dl> |
| 81 | </div> |
| 82 | <p> |
| 83 | The BFILE extension can optionally make available to you some |
| 84 | additional C language data types and functions for use with the |
| 85 | SQLite C/C++ interface. These are available to you only if |
| 86 | you take the proper steps when you compile Berkeley DB. See the |
| 87 | <em class="citetitle">Berkeley DB Installation and Build Guide</em> for more information. |
| 88 | </p> |
| 89 | <p> |
| 90 | Once enabled, the BFILE C extension makes the following new |
| 91 | structure available to you: |
| 92 | </p> |
| 93 | <pre class="programlisting">typedef struct sqlite3_bfile sqlite3_bfile;</pre> |
| 94 | <p> |
| 95 | This structure serves as the BFILE handle when you are using |
| 96 | the BFILE extension along with the SQLite C/C++ interface. |
| 97 | </p> |
| 98 | <p> |
| 99 | In addition to the new structure, you can also use the |
| 100 | following new C functions: |
| 101 | </p> |
| 102 | <div class="sect2" lang="en" xml:lang="en"> |
| 103 | <div class="titlepage"> |
| 104 | <div> |
| 105 | <div> |
| 106 | <h3 class="title"><a id="sqlite3_column_bfile"></a>sqlite3_column_bfile</h3> |
| 107 | </div> |
| 108 | </div> |
| 109 | </div> |
| 110 | <pre class="programlisting">int |
| 111 | sqlite3_column_bfile(sqlite3_stmt *pStmt, int iCol, |
| 112 | sqlite3_bfile **ppBfile); </pre> |
| 113 | <p> |
| 114 | Returns a result set from a query against a column of type |
| 115 | BFILE. |
| 116 | </p> |
| 117 | <p> |
| 118 | On success, <code class="literal">SQLITE_OK</code> is returned and |
| 119 | the new BFILE handle is written to |
| 120 | <span class="bold"><strong>ppBfile</strong></span>. Otherwise, |
| 121 | <code class="literal">SQLITE_ERROR</code> is returned. |
| 122 | </p> |
| 123 | <p> |
| 124 | Parameters are: |
| 125 | </p> |
| 126 | <div class="itemizedlist"> |
| 127 | <ul type="disc"> |
| 128 | <li> |
| 129 | <p> |
| 130 | <span class="bold"><strong>pStmt</strong></span> |
| 131 | </p> |
| 132 | <p> |
| 133 | Pointer to the prepared statement that the function |
| 134 | is evaluating. The statement is created |
| 135 | using <code class="literal">sqlite3_prepare_v2()</code> |
| 136 | or one of its variants. |
| 137 | </p> |
| 138 | <p> |
| 139 | If this statement does not point to a valid row, |
| 140 | the result is undefined. |
| 141 | </p> |
| 142 | </li> |
| 143 | <li> |
| 144 | <p> |
| 145 | <span class="bold"><strong>iCol</strong></span> |
| 146 | </p> |
| 147 | <p> |
| 148 | Index of the column for which information should be |
| 149 | returned. The left-most column of the result set |
| 150 | is index <code class="literal">0</code>. Use |
| 151 | <code class="literal">sqlite3_column_count()</code> to discover |
| 152 | the number of columns in the result set. |
| 153 | </p> |
| 154 | <p> |
| 155 | If the column index is out of range, the result is |
| 156 | undefined. |
| 157 | </p> |
| 158 | </li> |
| 159 | <li> |
| 160 | <p> |
| 161 | <span class="bold"><strong>ppBfile</strong></span> |
| 162 | </p> |
| 163 | <p> |
| 164 | The BFILE handle that you are using for the query. |
| 165 | This pointer is valid only until |
| 166 | <code class="literal">sqlite3_step()</code>, |
| 167 | <code class="literal">sqlite3_reset()</code> or |
| 168 | <code class="literal">sqlite3_finalize()</code> have been |
| 169 | called. |
| 170 | </p> |
| 171 | <p> |
| 172 | The memory space used to hold this handle is freed by |
| 173 | <a class="xref" href="bfile-c.html#sqlite3_bfile_final" title="sqlite3_bfile_final">sqlite3_bfile_final</a> |
| 174 | Do not pass these pointers to <code class="literal">sqlite3_free()</code>. |
| 175 | </p> |
| 176 | </li> |
| 177 | </ul> |
| 178 | </div> |
| 179 | <p> |
| 180 | This function can be called successfully only if all of the |
| 181 | following conditions are true. If any of the following are |
| 182 | not true, the result is undefined: |
| 183 | </p> |
| 184 | <div class="itemizedlist"> |
| 185 | <ul type="disc"> |
| 186 | <li> |
| 187 | <p> |
| 188 | The most recent call to |
| 189 | <code class="literal">sqlite3_step()</code> has returned |
| 190 | <code class="literal">SQLITE_ROW</code>. |
| 191 | </p> |
| 192 | </li> |
| 193 | <li> |
| 194 | <p> |
| 195 | Neither <code class="literal">sqlite3_reset()</code> nor |
| 196 | <code class="literal">sqlite3_finalize()</code> have been |
| 197 | called since the last time |
| 198 | <code class="literal">sqlite3_step()</code> was called. |
| 199 | </p> |
| 200 | </li> |
| 201 | <li> |
| 202 | <p> |
| 203 | <code class="literal">sqlite3_step()</code>, |
| 204 | <code class="literal">sqlite3_reset()</code> or |
| 205 | <code class="literal">sqlite3_finalize()</code> have not been |
| 206 | called from a different thread while this routine |
| 207 | is pending. |
| 208 | </p> |
| 209 | </li> |
| 210 | </ul> |
| 211 | </div> |
| 212 | </div> |
| 213 | <div class="sect2" lang="en" xml:lang="en"> |
| 214 | <div class="titlepage"> |
| 215 | <div> |
| 216 | <div> |
| 217 | <h3 class="title"><a id="sqlite3_bfile_open"></a>sqlite3_bfile_open</h3> |
| 218 | </div> |
| 219 | </div> |
| 220 | </div> |
| 221 | <pre class="programlisting">int |
| 222 | sqlite3_bfile_open(sqlite3_bfile *pBfile); </pre> |
| 223 | <p> |
| 224 | Opens a file for incremental read. |
| 225 | </p> |
| 226 | <p> |
| 227 | On success, <code class="literal">SQLITE_OK</code> is returned. |
| 228 | Otherwise, <code class="literal">SQLITE_ERROR</code> is returned. |
| 229 | </p> |
| 230 | <p> |
| 231 | To avoid a resource leak, every opened BFILE handle should |
| 232 | eventually be closed with the |
| 233 | <a class="xref" href="bfile-c.html#sqlite3_bfile_close" title="sqlite3_bfile_close">sqlite3_bfile_close</a> |
| 234 | function. Note that <span class="bold"><strong>pBfile</strong></span> |
| 235 | is always initialized such that it is always safe to invoke |
| 236 | <code class="literal">sqlite_bfile_close()</code> against it, |
| 237 | regardless of the success or failure of this function. |
| 238 | </p> |
| 239 | </div> |
| 240 | <div class="sect2" lang="en" xml:lang="en"> |
| 241 | <div class="titlepage"> |
| 242 | <div> |
| 243 | <div> |
| 244 | <h3 class="title"><a id="sqlite3_bfile_close"></a>sqlite3_bfile_close</h3> |
| 245 | </div> |
| 246 | </div> |
| 247 | </div> |
| 248 | <pre class="programlisting">int |
| 249 | sqlite3_bfile_close(sqlite3_bfile *pBfile); </pre> |
| 250 | <p> |
| 251 | Closes an open BFILE handle. The BFILE is closed |
| 252 | unconditionally. Even if this function returns an error, |
| 253 | the BFILE is still closed. |
| 254 | </p> |
| 255 | <p> |
| 256 | Calling this routine with a null pointer (such as would be |
| 257 | returned by failed call to sqlite3_column_bfile()) is a |
| 258 | harmless non-operation. |
| 259 | </p> |
| 260 | <p> |
| 261 | On success, <code class="literal">SQLITE_OK</code> is returned. |
| 262 | Otherwise, <code class="literal">SQLITE_ERROR</code> is returned. |
| 263 | </p> |
| 264 | </div> |
| 265 | <div class="sect2" lang="en" xml:lang="en"> |
| 266 | <div class="titlepage"> |
| 267 | <div> |
| 268 | <div> |
| 269 | <h3 class="title"><a id="sqlite3_bfile_is_open"></a>sqlite3_bfile_is_open</h3> |
| 270 | </div> |
| 271 | </div> |
| 272 | </div> |
| 273 | <pre class="programlisting">int |
| 274 | sqlite3_bfile_is_open(sqlite3_bfile *pBfile, int *open); </pre> |
| 275 | <p> |
| 276 | Checks whether a BFILE handle is open. The |
| 277 | <code class="literal">open</code> parameter is set to 1 if the file |
| 278 | is open, otherwise it is 0. |
| 279 | </p> |
| 280 | <p> |
| 281 | On success, <code class="literal">SQLITE_OK</code> is returned. |
| 282 | Otherwise, <code class="literal">SQLITE_ERROR</code> is returned. |
| 283 | </p> |
| 284 | </div> |
| 285 | <div class="sect2" lang="en" xml:lang="en"> |
| 286 | <div class="titlepage"> |
| 287 | <div> |
| 288 | <div> |
| 289 | <h3 class="title"><a id="sqlite3_bfile_read"></a>sqlite3_bfile_read</h3> |
| 290 | </div> |
| 291 | </div> |
| 292 | </div> |
| 293 | <pre class="programlisting">int |
| 294 | sqlite3_bfile_read(sqlite3_bfile *pBfile, void *oBuff, int nSize, |
| 295 | int iOffset, int *nRead); </pre> |
| 296 | <p> |
| 297 | This function is used to read data from an opened BFILE |
| 298 | handle into a caller-supplied buffer. |
| 299 | </p> |
| 300 | <p> |
| 301 | On success, <code class="literal">SQLITE_OK</code> is returned, the |
| 302 | data that has been read is written to the output buffer, |
| 303 | <span class="bold"><strong>oBuff</strong></span>, |
| 304 | and the amount of data written to the buffer is recorded in |
| 305 | <span class="bold"><strong>nRead</strong></span>. |
| 306 | Otherwise, <code class="literal">SQLITE_ERROR</code> is returned. |
| 307 | </p> |
| 308 | <p> |
| 309 | Parameters are: |
| 310 | </p> |
| 311 | <div class="itemizedlist"> |
| 312 | <ul type="disc"> |
| 313 | <li> |
| 314 | <p> |
| 315 | <span class="bold"><strong>pBfile</strong></span> |
| 316 | </p> |
| 317 | <p> |
| 318 | The BFILE handle from which the data is read. |
| 319 | </p> |
| 320 | <p> |
| 321 | This function only works on a BFILE handle which |
| 322 | has been created by a prior successful call to |
| 323 | <a class="xref" href="bfile-c.html#sqlite3_bfile_open" title="sqlite3_bfile_open">sqlite3_bfile_open</a> |
| 324 | and which has not been closed by |
| 325 | <a class="xref" href="bfile-c.html#sqlite3_bfile_close" title="sqlite3_bfile_close">sqlite3_bfile_close</a>. |
| 326 | Passing any other pointer in to this function |
| 327 | results in undefined and probably undesirable |
| 328 | behavior. |
| 329 | </p> |
| 330 | </li> |
| 331 | <li> |
| 332 | <p> |
| 333 | <span class="bold"><strong>oBuff</strong></span> |
| 334 | </p> |
| 335 | <p> |
| 336 | The buffer used to contain the data that is read |
| 337 | from <span class="bold"><strong>pBfile</strong></span>. It |
| 338 | must be at least <span class="bold"><strong>nSize</strong></span> |
| 339 | bytes in size. |
| 340 | </p> |
| 341 | </li> |
| 342 | <li> |
| 343 | <p> |
| 344 | <span class="bold"><strong>nSize</strong></span> |
| 345 | </p> |
| 346 | <p> |
| 347 | The amount of data, in bytes, to read from the |
| 348 | BFILE. |
| 349 | </p> |
| 350 | </li> |
| 351 | <li> |
| 352 | <p> |
| 353 | <span class="bold"><strong>iOffset</strong></span> |
| 354 | </p> |
| 355 | <p> |
| 356 | The offset from the beginning of the file where the |
| 357 | read operation is to begin. |
| 358 | </p> |
| 359 | </li> |
| 360 | <li> |
| 361 | <p> |
| 362 | <span class="bold"><strong>nRead</strong></span> |
| 363 | </p> |
| 364 | <p> |
| 365 | Contains the amount of data, in bytes, actually |
| 366 | written to buffer <span class="bold"><strong>oBuff</strong></span> |
| 367 | once the read operation is completed. |
| 368 | </p> |
| 369 | </li> |
| 370 | </ul> |
| 371 | </div> |
| 372 | <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| 373 | <h3 class="title">Note</h3> |
| 374 | <p> |
| 375 | The size of the BFILE can be determined using the |
| 376 | <a class="xref" href="bfile-c.html#sqlite3_bfile_size" title="sqlite3_bfile_size">sqlite3_bfile_size</a> |
| 377 | function. |
| 378 | </p> |
| 379 | </div> |
| 380 | </div> |
| 381 | <div class="sect2" lang="en" xml:lang="en"> |
| 382 | <div class="titlepage"> |
| 383 | <div> |
| 384 | <div> |
| 385 | <h3 class="title"><a id="sqlite3_bfile_file_exists"></a>sqlite3_bfile_file_exists</h3> |
| 386 | </div> |
| 387 | </div> |
| 388 | </div> |
| 389 | <pre class="programlisting">int |
| 390 | sqlite3_bfile_file_exists(sqlite3_bfile *pBfile, int *exist); </pre> |
| 391 | <p> |
| 392 | Checks whether a BFILE exists. The |
| 393 | <code class="literal">exists</code> parameter is set to 1 if the file |
| 394 | is exists, otherwise it is 0. |
| 395 | </p> |
| 396 | <p> |
| 397 | On success, <code class="literal">SQLITE_OK</code> is returned. |
| 398 | Otherwise, <code class="literal">SQLITE_ERROR</code> is returned. |
| 399 | </p> |
| 400 | </div> |
| 401 | <div class="sect2" lang="en" xml:lang="en"> |
| 402 | <div class="titlepage"> |
| 403 | <div> |
| 404 | <div> |
| 405 | <h3 class="title"><a id="sqlite3_bfile_size"></a>sqlite3_bfile_size</h3> |
| 406 | </div> |
| 407 | </div> |
| 408 | </div> |
| 409 | <pre class="programlisting">int |
| 410 | sqlite3_bfile_size(sqlite3_bfile *pBfile, off_t *size); </pre> |
| 411 | <p> |
| 412 | Returns the size of the BFILE, in bytes. |
| 413 | </p> |
| 414 | <p> |
| 415 | On success, <code class="literal">SQLITE_OK</code> is returned, and |
| 416 | <span class="bold"><strong>size</strong></span> is set to the size of |
| 417 | the BFILE, in bytes. |
| 418 | Otherwise, <code class="literal">SQLITE_ERROR</code> is returned. |
| 419 | </p> |
| 420 | <p> |
| 421 | This function only works on a BFILE handle which |
| 422 | has been created by a prior successful call to |
| 423 | <a class="xref" href="bfile-c.html#sqlite3_column_bfile" title="sqlite3_column_bfile">sqlite3_column_bfile</a> |
| 424 | and which has not been finalized by |
| 425 | <a class="xref" href="bfile-c.html#sqlite3_bfile_final" title="sqlite3_bfile_final">sqlite3_bfile_final</a>. |
| 426 | Passing any other pointer in to this function |
| 427 | results in undefined and probably undesirable |
| 428 | behavior. |
| 429 | </p> |
| 430 | </div> |
| 431 | <div class="sect2" lang="en" xml:lang="en"> |
| 432 | <div class="titlepage"> |
| 433 | <div> |
| 434 | <div> |
| 435 | <h3 class="title"><a id="sqlite3_bfile_final"></a>sqlite3_bfile_final</h3> |
| 436 | </div> |
| 437 | </div> |
| 438 | </div> |
| 439 | <pre class="programlisting">int |
| 440 | sqlite3_bfile_final(sqlite3_bfile *pBfile); </pre> |
| 441 | <p> |
| 442 | Frees a BFILE handle. |
| 443 | </p> |
| 444 | <p> |
| 445 | On success, <code class="literal">SQLITE_OK</code> is returned. |
| 446 | Otherwise, <code class="literal">SQLITE_ERROR</code> is returned. |
| 447 | </p> |
| 448 | </div> |
| 449 | </div> |
| 450 | <div class="navfooter"> |
| 451 | <hr /> |
| 452 | <table width="100%" summary="Navigation footer"> |
| 453 | <tr> |
| 454 | <td width="40%" align="left"><a accesskey="p" href="bfile-sql.html">Prev</a> </td> |
| 455 | <td width="20%" align="center"> |
| 456 | <a accesskey="u" href="bfile-extension.html">Up</a> |
| 457 | </td> |
| 458 | <td width="40%" align="right"> </td> |
| 459 | </tr> |
| 460 | <tr> |
| 461 | <td width="40%" align="left" valign="top">BFILE SQL Objects and Functions </td> |
| 462 | <td width="20%" align="center"> |
| 463 | <a accesskey="h" href="index.html">Home</a> |
| 464 | </td> |
| 465 | <td width="40%" align="right" valign="top"> </td> |
| 466 | </tr> |
| 467 | </table> |
| 468 | </div> |
| 469 | </body> |
| 470 | </html> |