Fix the sqlite3_bind_blob() interface (and its kin) so that the destructor

is invoked if the binding fails.  Ticket [860399cc408f2dd5f41aed44b]
Update the documentation to explain which interfaces invoke their
destructors on failure and which do not.

FossilOrigin-Name: d3c95e3a4e08d08028e9bc7f282074e32b9cf950
This commit is contained in:
drh 2010-10-12 02:13:32 +00:00
parent 88404c2a7d
commit 6fec9ee34c
4 changed files with 37 additions and 18 deletions

View File

@ -1,8 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE----- -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Hash: SHA1
C Make\ssure\sthe\ssqlite3_create_collation()\sinterfaces\salways\sreturn\san\serror\ncode\sif\sthey\sfail.\s\sTicket\s[a04e42a3fcacaffa3133436]. C Fix\sthe\ssqlite3_bind_blob()\sinterface\s(and\sits\skin)\sso\sthat\sthe\sdestructor\nis\sinvoked\sif\sthe\sbinding\sfails.\s\sTicket\s[860399cc408f2dd5f41aed44b]\nUpdate\sthe\sdocumentation\sto\sexplain\swhich\sinterfaces\sinvoke\stheir\ndestructors\son\sfailure\sand\swhich\sdo\snot.
D 2010-10-11T17:58:21 D 2010-10-12T02:13:33
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in b01fdfcfecf8a0716c29867a67959f6148b79961 F Makefile.in b01fdfcfecf8a0716c29867a67959f6148b79961
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -178,7 +178,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c 6a5c72fb0e8dc7f6133f5a9d7a747130ef0a00ea F src/select.c 6a5c72fb0e8dc7f6133f5a9d7a747130ef0a00ea
F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056 F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056
F src/sqlite.h.in a5b50e1bc4d4d9a3cc95386747220a839d0c40f7 F src/sqlite.h.in 13f219b9ab78f22603019fd193f09d5c8913795a
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
F src/sqliteInt.h c63b0340dfdfde18ff255ddccf004edd2d073288 F src/sqliteInt.h c63b0340dfdfde18ff255ddccf004edd2d073288
F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
@ -231,7 +231,7 @@ F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f
F src/vdbe.c e1aa917961e69f71c80f46ce231b496d3c841ae1 F src/vdbe.c e1aa917961e69f71c80f46ce231b496d3c841ae1
F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2
F src/vdbeInt.h 7f4cf1b2b69bef3a432b1f23dfebef57275436b4 F src/vdbeInt.h 7f4cf1b2b69bef3a432b1f23dfebef57275436b4
F src/vdbeapi.c 03cddfa4f85cadf608c0d28ff6b622b7da432446 F src/vdbeapi.c 66abe27b886f82c18bcfb1e27b9b4dd33cb70d41
F src/vdbeaux.c de0b06b11a25293e820a49159eca9f1c51a64716 F src/vdbeaux.c de0b06b11a25293e820a49159eca9f1c51a64716
F src/vdbeblob.c 258a6010ba7a82b72b327fb24c55790655689256 F src/vdbeblob.c 258a6010ba7a82b72b327fb24c55790655689256
F src/vdbemem.c 23723a12cd3ba7ab3099193094cbb2eb78956aa9 F src/vdbemem.c 23723a12cd3ba7ab3099193094cbb2eb78956aa9
@ -876,14 +876,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P f818fb6f73ada64eaf8785d9bb2d439b6d755461 P 6464276ec1c0951a6edc59eb402ca3dd49629a18
R 6e67c23791ac4b87ba355f665aa4f8b3 R 10ff206c4aa126ad395bc245dcdbe279
U drh U drh
Z e78b695b956c911c4c56255077d3b7a8 Z 85e4e15dab10d5b63301916ef8daf991
-----BEGIN PGP SIGNATURE----- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux) Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFMs1BAoxKgR168RlERAi+2AJ9B2TrYiXEg9jposxSmI8WCJkwy9wCeMwSq iD8DBQFMs8RRoxKgR168RlERAhg6AJ4jB3XuddIoNxkkTHCbMiZCQDkyuwCfQ8DW
4L/h4oOhEJz4eDK7xfNp1DY= zuydaBOtQGPX4Da5mPFWYaQ=
=Fla5 =t4eY
-----END PGP SIGNATURE----- -----END PGP SIGNATURE-----

View File

@ -1 +1 @@
6464276ec1c0951a6edc59eb402ca3dd49629a18 d3c95e3a4e08d08028e9bc7f282074e32b9cf950

View File

@ -2727,7 +2727,10 @@ typedef struct sqlite3_context sqlite3_context;
** **
** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
** string after SQLite has finished with it. ^If the fifth argument is ** string after SQLite has finished with it. ^The destructor is called
** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),
** sqlite3_bind_text(), or sqlite3_bind_text16() fails.
** ^If the fifth argument is
** the special value [SQLITE_STATIC], then SQLite assumes that the ** the special value [SQLITE_STATIC], then SQLite assumes that the
** information is in static, unmanaged space and does not need to be freed. ** information is in static, unmanaged space and does not need to be freed.
** ^If the fifth argument has the value [SQLITE_TRANSIENT], then ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
@ -3368,11 +3371,14 @@ int sqlite3_reset(sqlite3_stmt *pStmt);
** callbacks. ** callbacks.
** **
** ^If the tenth parameter to sqlite3_create_function_v2() is not NULL, ** ^If the tenth parameter to sqlite3_create_function_v2() is not NULL,
** then it is invoked when the function is deleted, either by being ** then it is destructor for the application data point that is invoked
** overloaded or when the database connection closes. ** when the function is deleted, either by being
** ^When the destructure callback of the tenth parameter is invoked, it ** overloaded or when the database connection closes.
** is passed a single argument which is a copy of the pointer which was ** ^The destructor is also invoked if the call to
** the fifth parameter to sqlite3_create_function_v2(). ** sqlite3_create_function_v2() fails.
** ^When the destructor callback of the tenth parameter is invoked, it
** is passed a single argument which is a copy of the application data
** pointer which was the fifth parameter to sqlite3_create_function_v2().
** **
** ^It is permitted to register multiple implementations of the same ** ^It is permitted to register multiple implementations of the same
** functions with the same name but with either differing numbers of ** functions with the same name but with either differing numbers of
@ -3836,6 +3842,15 @@ void sqlite3_result_zeroblob(sqlite3_context*, int n);
** calls to the collation creation functions or when the ** calls to the collation creation functions or when the
** [database connection] is closed using [sqlite3_close()]. ** [database connection] is closed using [sqlite3_close()].
** **
** ^The xDestroy callback is <u>not</u> called if the
** sqlite3_create_collation_v2() function fails. Applications that invoke
** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should
** check the return code and dispose of the application data pointer
** themselves rather than expecting SQLite to deal with it for them.
** This is different from every other SQLite interface. The inconsistency
** is unfortunate but cannot be changed without breaking backwards
** compatibility.
**
** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
*/ */
int sqlite3_create_collation( int sqlite3_create_collation(
@ -4590,7 +4605,9 @@ struct sqlite3_index_info {
** ^The sqlite3_create_module_v2() interface has a fifth parameter which ** ^The sqlite3_create_module_v2() interface has a fifth parameter which
** is a pointer to a destructor for the pClientData. ^SQLite will ** is a pointer to a destructor for the pClientData. ^SQLite will
** invoke the destructor function (if it is not NULL) when SQLite ** invoke the destructor function (if it is not NULL) when SQLite
** no longer needs the pClientData pointer. ^The sqlite3_create_module() ** no longer needs the pClientData pointer. ^The destructor will also
** be invoked if the call to sqlite3_create_module_v2() fails.
** ^The sqlite3_create_module()
** interface is equivalent to sqlite3_create_module_v2() with a NULL ** interface is equivalent to sqlite3_create_module_v2() with a NULL
** destructor. ** destructor.
*/ */

View File

@ -1022,6 +1022,8 @@ static int bindText(
rc = sqlite3ApiExit(p->db, rc); rc = sqlite3ApiExit(p->db, rc);
} }
sqlite3_mutex_leave(p->db->mutex); sqlite3_mutex_leave(p->db->mutex);
}else if( xDel ){
xDel((void*)zData);
} }
return rc; return rc;
} }