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