1.Dd $Mdocdate$ 2.Dt SQLITE3_BLOB_OPEN 3 3.Os 4.Sh NAME 5.Nm sqlite3_blob_open 6.Nd Open A BLOB For Incremental I/O 7.Sh SYNOPSIS 8.Ft int SQLITE_STDCALL 9.Fo sqlite3_blob_open 10.Fa "sqlite3*" 11.Fa "const char *zDb" 12.Fa "const char *zTable" 13.Fa "const char *zColumn" 14.Fa "sqlite3_int64 iRow" 15.Fa "int flags" 16.Fa "sqlite3_blob **ppBlob " 17.Fc 18.Sh DESCRIPTION 19This interfaces opens a handle to the BLOB located in row iRow, 20column zColumn, table zTable in database zDb; in other words, the same 21BLOB that would be selected by: 22.Bd -literal 23SELECT zColumn FROM zDb.zTable WHERE rowid = iRow; 24.Ed 25.Pp 26Parameter zDb is not the filename that contains the database, but rather 27the symbolic name of the database. 28For attached databases, this is the name that appears after the AS 29keyword in the ATTACH statement. 30For the main database file, the database name is "main". 31For TEMP tables, the database name is "temp". 32.Pp 33If the flags parameter is non-zero, then the BLOB is opened for read 34and write access. 35If the flags parameter is zero, the BLOB is opened for read-only access. 36.Pp 37On success, SQLITE_OK is returned and the new BLOB handle 38is stored in *ppBlob. 39Otherwise an error code is returned and, unless the error 40code is SQLITE_MISUSE, *ppBlob is set to NULL. 41This means that, provided the API is not misused, it is always safe 42to call sqlite3_blob_close() on *ppBlob after this 43function it returns. 44.Pp 45This function fails with SQLITE_ERROR if any of the following are true: 46.Bl -bullet 47.It 48Database zDb does not exist , 49.It 50Table zTable does not exist within database zDb , 51.It 52Table zTable is a WITHOUT ROWID table , 53.It 54Column zColumn does not exist , 55.It 56Row iRow is not present in the table , 57.It 58The specified column of row iRow contains a value that is not a TEXT 59or BLOB value , 60.It 61Column zColumn is part of an index, PRIMARY KEY or UNIQUE constraint 62and the blob is being opened for read/write access , 63.It 64 Foreign key constraints are enabled, column 65zColumn is part of a child key definition and the blob is 66being opened for read/write access . 67.El 68.Pp 69Unless it returns SQLITE_MISUSE, this function sets the database connection 70error code and message accessible via sqlite3_errcode() 71and sqlite3_errmsg() and related functions. 72.Pp 73If the row that a BLOB handle points to is modified by an UPDATE, 74DELETE, or by ON CONFLICT side-effects then the BLOB 75handle is marked as "expired". 76This is true if any column of the row is changed, even a column other 77than the one the BLOB handle is open on. 78Calls to sqlite3_blob_read() and sqlite3_blob_write() 79for an expired BLOB handle fail with a return code of SQLITE_ABORT. 80Changes written into a BLOB prior to the BLOB expiring are not rolled 81back by the expiration of the BLOB. 82Such changes will eventually commit if the transaction continues to 83completion. 84.Pp 85Use the sqlite3_blob_bytes() interface to determine 86the size of the opened blob. 87The size of a blob may not be changed by this interface. 88Use the UPDATE SQL command to change the size of a blob. 89.Pp 90The sqlite3_bind_zeroblob() and sqlite3_result_zeroblob() 91interfaces and the built-in zeroblob SQL function may be used 92to create a zero-filled blob to read or write using the incremental-blob 93interface. 94.Pp 95To avoid a resource leak, every open BLOB handle should 96eventually be released by a call to sqlite3_blob_close(). 97.Sh SEE ALSO 98.Xr sqlite3_blob 3 , 99.Xr sqlite3 3 , 100.Xr sqlite3_bind_blob 3 , 101.Xr sqlite3_blob_bytes 3 , 102.Xr sqlite3_blob_close 3 , 103.Xr sqlite3_blob_read 3 , 104.Xr sqlite3_blob_write 3 , 105.Xr sqlite3_errcode 3 , 106.Xr sqlite3_result_blob 3 , 107.Xr SQLITE_OK 3 108