Small. Fast. Reliable.
Choose any three.

SQLite C Interface

Open A BLOB For Incremental I/O

int sqlite3_blob_open(
  sqlite3*,
  const char *zDb,
  const char *zTable,
  const char *zColumn,
  sqlite3_int64 iRow,
  int flags,
  sqlite3_blob **ppBlob
);

This interfaces opens a handle to the BLOB located in row iRow, column zColumn, table zTable in database zDb; in other words, the same BLOB that would be selected by:

SELECT zColumn FROM zDb.zTable WHERE rowid = iRow;

If the flags parameter is non-zero, the the BLOB is opened for read and write access. If it is zero, the BLOB is opened for read access.

Note that the database name is not the filename that contains the database but rather the symbolic name of the database that is assigned when the database is connected using ATTACH. For the main database file, the database name is "main". For TEMP tables, the database name is "temp".

On success, SQLITE_OK is returned and the new BLOB handle is written to *ppBlob. Otherwise an error code is returned and any value written to *ppBlob should not be used by the caller. This function sets the database connection error code and message accessible via sqlite3_errcode() and sqlite3_errmsg().

If the row that a BLOB handle points to is modified by an UPDATE, DELETE, or by ON CONFLICT side-effects then the BLOB handle is marked as "expired". This is true if any column of the row is changed, even a column other than the one the BLOB handle is open on. Calls to sqlite3_blob_read() and sqlite3_blob_write() for a expired BLOB handle fail with an return code of SQLITE_ABORT. Changes written into a BLOB prior to the BLOB expiring are not rollback by the expiration of the BLOB. Such changes will eventually commit if the transaction continues to completion.

Invariants:

H17813 A successful invocation of the sqlite3_blob_open(D,B,T,C,R,F,P) interface shall open an sqlite3_blob object P on the BLOB in column C of the table T in the database B on the database connection D.
H17814 A successful invocation of sqlite3_blob_open(D,...) shall start a new transaction on the database connection D if that connection is not already in a transaction.
H17816 The sqlite3_blob_open(D,B,T,C,R,F,P) interface shall open the BLOB for read and write access if and only if the F parameter is non-zero.
H17819 The sqlite3_blob_open() interface shall return SQLITE_OK on success and an appropriate error code on failure.
H17821 If an error occurs during evaluation of sqlite3_blob_open(D,...) then subsequent calls to sqlite3_errcode(D), sqlite3_extended_errcode(), sqlite3_errmsg(D), and sqlite3_errmsg16(D) shall return information appropriate for that error.
H17824 If any column in the row that a sqlite3_blob has open is changed by a separate UPDATE or DELETE statement or by an ON CONFLICT side effect, then the sqlite3_blob shall be marked as invalid.

See also lists of Objects, Constants, and Functions.


This page last modified 2008/12/09 18:44:04 UTC