Index: src/sqlite.h.in ================================================================== --- src/sqlite.h.in +++ src/sqlite.h.in @@ -28,11 +28,11 @@ ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** -** @(#) $Id: sqlite.h.in,v 1.257 2007/09/04 12:00:00 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.258 2007/09/04 12:18:42 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include /* Needed for the definition of va_list */ @@ -1701,11 +1701,12 @@ ** The sqlite3_bind_zeroblob() routine binds a BLOB of length n that ** is filled with zeros. A zeroblob uses a fixed amount of memory ** (just an integer to hold it size) while it is being processed. ** Zeroblobs are intended to serve as place-holders for BLOBs whose ** content is later written using -** [sqlite3_blob_open | increment BLOB I/O] routines. +** [sqlite3_blob_open | increment BLOB I/O] routines. A negative +** value for the zeroblob results in a zero-length BLOB. ** ** The sqlite3_bind_*() routines must be called after ** [sqlite3_prepare_v2()] (and its variants) or [sqlite3_reset()] and ** before [sqlite3_step()]. ** Bindings are not cleared by the [sqlite3_reset()] routine. @@ -2056,10 +2057,15 @@ ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns ** the number of bytes in that string. ** The value returned does not include the zero terminator at the end ** of the string. For clarity: the value returned is the number of ** bytes in the string, not the number of characters. +** +** Strings returned by sqlite3_column_text() and sqlite3_column_text16(), +** even zero-length strings, are always zero terminated. The return +** value from sqlite3_column_blob() for a zero-length blob is an arbitrary +** pointer, possibly even a NULL pointer. ** ** The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes() ** but leaves the result in UTF-16 instead of UTF-8. ** The zero terminator is not included in this count. ** Index: test/zeroblob.test ================================================================== --- test/zeroblob.test +++ test/zeroblob.test @@ -11,11 +11,11 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing of the zero-filled blob functionality # including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(), # and the built-in zeroblob() SQL function. # -# $Id: zeroblob.test,v 1.8 2007/09/01 16:16:16 danielk1977 Exp $ +# $Id: zeroblob.test,v 1.9 2007/09/04 12:18:42 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !incrblob { @@ -172,11 +172,17 @@ do_test zeroblob-6.4 { catchsql {select length(zeroblob(2147483648))} } {1 {string or blob too big}} do_test zeroblob-6.5 { catchsql {select zeroblob(2147483648)} -} {1 {string or blob too big}} +} {1 {string or blob too big}} +do_test zeroblob-6.6 { + execsql {select hex(zeroblob(-1))} +} {{}} +do_test zeroblob-6.7 { + execsql {select typeof(zeroblob(-1))} +} {blob} # Test bind_zeroblob() # do_test zeroblob-7.1 { set ::STMT [sqlite3_prepare $::DB "SELECT length(?)" -1 DUMMY]