Berkeley DB Reference Version 5.3.33

BFILE C/C++ Objects and Functions

sqlite3_column_bfile

sqlite3_bfile_open

sqlite3_bfile_close

sqlite3_bfile_is_open

sqlite3_bfile_read

sqlite3_bfile_file_exists

sqlite3_bfile_size

sqlite3_bfile_final

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 Berkeley DB Installation and Build Guide for more information.

Once enabled, the BFILE C extension makes the following new structure available to you:

typedef struct sqlite3_bfile sqlite3_bfile;

This structure serves as the BFILE handle when you are using the BFILE extension along with the SQLite C/C++ interface.

In addition to the new structure, you can also use the following new C functions:

sqlite3_column_bfile

int 
sqlite3_column_bfile(sqlite3_stmt *pStmt, int iCol, 
                     sqlite3_bfile **ppBfile); 

Returns a result set from a query against a column of type BFILE.

On success, SQLITE_OK is returned and the new BFILE handle is written to ppBfile. Otherwise, SQLITE_ERROR is returned.

Parameters are:

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:

sqlite3_bfile_open

int
sqlite3_bfile_open(sqlite3_bfile *pBfile); 

Opens a file for incremental read.

On success, SQLITE_OK is returned. Otherwise, SQLITE_ERROR is returned.

To avoid a resource leak, every opened BFILE handle should eventually be closed with the sqlite3_bfile_close function. Note that pBfile is always initialized such that it is always safe to invoke sqlite_bfile_close() against it, regardless of the success or failure of this function.

sqlite3_bfile_close

int
sqlite3_bfile_close(sqlite3_bfile *pBfile); 

Closes an open BFILE handle. The BFILE is closed unconditionally. Even if this function returns an error, the BFILE is still closed.

Calling this routine with a null pointer (such as would be returned by failed call to sqlite3_column_bfile()) is a harmless non-operation.

On success, SQLITE_OK is returned. Otherwise, SQLITE_ERROR is returned.

sqlite3_bfile_is_open

int
sqlite3_bfile_is_open(sqlite3_bfile *pBfile, int *open); 

Checks whether a BFILE handle is open. The open parameter is set to 1 if the file is open, otherwise it is 0.

On success, SQLITE_OK is returned. Otherwise, SQLITE_ERROR is returned.

sqlite3_bfile_read

int 
sqlite3_bfile_read(sqlite3_bfile *pBfile, void *oBuff, int nSize, 
                   int iOffset, int *nRead); 

This function is used to read data from an opened BFILE handle into a caller-supplied buffer.

On success, SQLITE_OK is returned, the data that has been read is written to the output buffer, oBuff, and the amount of data written to the buffer is recorded in nRead. Otherwise, SQLITE_ERROR is returned.

Parameters are:

Note

The size of the BFILE can be determined using the sqlite3_bfile_size function.

sqlite3_bfile_file_exists

int
sqlite3_bfile_file_exists(sqlite3_bfile *pBfile, int *exist); 

Checks whether a BFILE exists. The exists parameter is set to 1 if the file is exists, otherwise it is 0.

On success, SQLITE_OK is returned. Otherwise, SQLITE_ERROR is returned.

sqlite3_bfile_size

int
sqlite3_bfile_size(sqlite3_bfile *pBfile, off_t *size); 

Returns the size of the BFILE, in bytes.

On success, SQLITE_OK is returned, and size is set to the size of the BFILE, in bytes. Otherwise, SQLITE_ERROR is returned.

This function only works on a BFILE handle which has been created by a prior successful call to sqlite3_column_bfile and which has not been finalized by sqlite3_bfile_final. Passing any other pointer in to this function results in undefined and probably undesirable behavior.

sqlite3_bfile_final

int
sqlite3_bfile_final(sqlite3_bfile *pBfile); 

Frees a BFILE handle.

On success, SQLITE_OK is returned. Otherwise, SQLITE_ERROR is returned.