/ Check-in [476a8b49]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Have sqlite3_blob_bytes() return 0 following a failed call to sqlite3_reopen_blob().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 476a8b492124d31e0656e61a6183ab55684c0bdf
User & Date: dan 2010-12-06 17:11:06
Context
2010-12-06
18:50
Initialize all constants at the very beginning of a prepared statement. Do not allow constant initialization to occur once control flow has a chance to diverge, to avoid the possibility of having uninitialized registers. Ticket [80ba201079ea60807]. check-in: c5c53152 user: drh tags: trunk
17:11
Have sqlite3_blob_bytes() return 0 following a failed call to sqlite3_reopen_blob(). check-in: 476a8b49 user: dan tags: trunk
2010-12-04
19:35
Version 3.7.4 release candidate 2. check-in: 40756fe1 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/sqlite.h.in.

4831
4832
4833
4834
4835
4836
4837
4838

4839
4840
4841
4842
4843
4844
4845
** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -
** it must exist and there must be either a blob or text value stored in
** the nominated column.)^ ^If the new row is not present in the table, or if
** it does not contain a blob or text value, or if another error occurs, an
** SQLite error code is returned and the blob handle is considered aborted.
** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or
** [sqlite3_blob_reopen()] on an aborted blob handle immediately return
** SQLITE_ABORT.

**
** ^This function sets the database handle error code and message.
*/
SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);

/*
** CAPI3REF: Close A BLOB Handle







|
>







4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -
** it must exist and there must be either a blob or text value stored in
** the nominated column.)^ ^If the new row is not present in the table, or if
** it does not contain a blob or text value, or if another error occurs, an
** SQLite error code is returned and the blob handle is considered aborted.
** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or
** [sqlite3_blob_reopen()] on an aborted blob handle immediately return
** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
** always returns zero.
**
** ^This function sets the database handle error code and message.
*/
SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);

/*
** CAPI3REF: Close A BLOB Handle

Changes to src/vdbeblob.c.

415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
...
453
454
455
456
457
458
459

460
461
462
463
464
** Query a blob handle for the size of the data.
**
** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
** so no mutex is required for access.
*/
int sqlite3_blob_bytes(sqlite3_blob *pBlob){
  Incrblob *p = (Incrblob *)pBlob;
  return p ? p->nByte : 0;
}

/*
** Move an existing blob handle to point to a different row of the same
** database table.
**
** If an error occurs, or if the specified row does not exist or does not
................................................................................
      sqlite3Error(db, rc, (zErr ? "%s" : 0), zErr);
      sqlite3DbFree(db, zErr);
    }
    assert( rc!=SQLITE_SCHEMA );
  }

  rc = sqlite3ApiExit(db, rc);

  sqlite3_mutex_leave(db->mutex);
  return rc;
}

#endif /* #ifndef SQLITE_OMIT_INCRBLOB */







|







 







>





415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
...
453
454
455
456
457
458
459
460
461
462
463
464
465
** Query a blob handle for the size of the data.
**
** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
** so no mutex is required for access.
*/
int sqlite3_blob_bytes(sqlite3_blob *pBlob){
  Incrblob *p = (Incrblob *)pBlob;
  return (p && p->pStmt) ? p->nByte : 0;
}

/*
** Move an existing blob handle to point to a different row of the same
** database table.
**
** If an error occurs, or if the specified row does not exist or does not
................................................................................
      sqlite3Error(db, rc, (zErr ? "%s" : 0), zErr);
      sqlite3DbFree(db, zErr);
    }
    assert( rc!=SQLITE_SCHEMA );
  }

  rc = sqlite3ApiExit(db, rc);
  assert( rc==SQLITE_OK || p->pStmt==0 );
  sqlite3_mutex_leave(db->mutex);
  return rc;
}

#endif /* #ifndef SQLITE_OMIT_INCRBLOB */

Changes to test/incrblob3.test.

88
89
90
91
92
93
94



95
96
97
98
99
100
101
102
103
  } {1 SQLITE_ABORT}
  do_test incrblob3-2.2.$tn.4 {
    list [catch {sqlite3_blob_read $::blob 0 10} msg] $msg
  } {1 SQLITE_ABORT}
  do_test incrblob3-2.2.$tn.5 {
    list [catch {sqlite3_blob_write $::blob 0 "abcd"} msg] $msg
  } {1 SQLITE_ABORT}




  do_test incrblob3-2.2.$tn.4 { close $::blob } {}
}

# Test that passing NULL to sqlite3_blob_XXX() APIs returns SQLITE_MISUSE.
#
#   incrblob3-3.1: sqlite3_blob_reopen()
#   incrblob3-3.2: sqlite3_blob_read()
#   incrblob3-3.3: sqlite3_blob_write()







>
>
>

|







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
  } {1 SQLITE_ABORT}
  do_test incrblob3-2.2.$tn.4 {
    list [catch {sqlite3_blob_read $::blob 0 10} msg] $msg
  } {1 SQLITE_ABORT}
  do_test incrblob3-2.2.$tn.5 {
    list [catch {sqlite3_blob_write $::blob 0 "abcd"} msg] $msg
  } {1 SQLITE_ABORT}
  do_test incrblob3-2.2.$tn.6 {
    sqlite3_blob_bytes $::blob
  } {0}

  do_test incrblob3-2.2.$tn.7 { close $::blob } {}
}

# Test that passing NULL to sqlite3_blob_XXX() APIs returns SQLITE_MISUSE.
#
#   incrblob3-3.1: sqlite3_blob_reopen()
#   incrblob3-3.2: sqlite3_blob_read()
#   incrblob3-3.3: sqlite3_blob_write()