]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the sqlite3_bind_blob() interface (and its kin) so that the destructor
authordrh <drh@noemail.net>
Tue, 12 Oct 2010 02:13:32 +0000 (02:13 +0000)
committerdrh <drh@noemail.net>
Tue, 12 Oct 2010 02:13:32 +0000 (02:13 +0000)
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

manifest
manifest.uuid
src/sqlite.h.in
src/vdbeapi.c

index bf49d0c6db05b374d5a7841cba1a691f4494669b..ef68334d8cc3af46d86baf8de095ab2f944e6167 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-C Make\ssure\sthe\ssqlite3_create_collation()\sinterfaces\salways\sreturn\san\serror\ncode\sif\sthey\sfail.\s\sTicket\s[a04e42a3fcacaffa3133436].
-D 2010-10-11T17:58:21
+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-12T02:13:33
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in b01fdfcfecf8a0716c29867a67959f6148b79961
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -178,7 +178,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706
 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
 F src/select.c 6a5c72fb0e8dc7f6133f5a9d7a747130ef0a00ea
 F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056
-F src/sqlite.h.in a5b50e1bc4d4d9a3cc95386747220a839d0c40f7
+F src/sqlite.h.in 13f219b9ab78f22603019fd193f09d5c8913795a
 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
 F src/sqliteInt.h c63b0340dfdfde18ff255ddccf004edd2d073288
 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
@@ -231,7 +231,7 @@ F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f
 F src/vdbe.c e1aa917961e69f71c80f46ce231b496d3c841ae1
 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2
 F src/vdbeInt.h 7f4cf1b2b69bef3a432b1f23dfebef57275436b4
-F src/vdbeapi.c 03cddfa4f85cadf608c0d28ff6b622b7da432446
+F src/vdbeapi.c 66abe27b886f82c18bcfb1e27b9b4dd33cb70d41
 F src/vdbeaux.c de0b06b11a25293e820a49159eca9f1c51a64716
 F src/vdbeblob.c 258a6010ba7a82b72b327fb24c55790655689256
 F src/vdbemem.c 23723a12cd3ba7ab3099193094cbb2eb78956aa9
@@ -876,14 +876,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P f818fb6f73ada64eaf8785d9bb2d439b6d755461
-R 6e67c23791ac4b87ba355f665aa4f8b3
+P 6464276ec1c0951a6edc59eb402ca3dd49629a18
+R 10ff206c4aa126ad395bc245dcdbe279
 U drh
-Z e78b695b956c911c4c56255077d3b7a8
+Z 85e4e15dab10d5b63301916ef8daf991
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)
 
-iD8DBQFMs1BAoxKgR168RlERAi+2AJ9B2TrYiXEg9jposxSmI8WCJkwy9wCeMwSq
-4L/h4oOhEJz4eDK7xfNp1DY=
-=Fla5
+iD8DBQFMs8RRoxKgR168RlERAhg6AJ4jB3XuddIoNxkkTHCbMiZCQDkyuwCfQ8DW
+zuydaBOtQGPX4Da5mPFWYaQ=
+=t4eY
 -----END PGP SIGNATURE-----
index 632c0ba399ca5431802dd70128a76e3790ce793c..0e93dacca2ea7ee82caeea8c4a79f14f27d7e022 100644 (file)
@@ -1 +1 @@
-6464276ec1c0951a6edc59eb402ca3dd49629a18
\ No newline at end of file
+d3c95e3a4e08d08028e9bc7f282074e32b9cf950
\ No newline at end of file
index 2bbd68765323b6132d471bdb082ec7510a98ae0b..e827e828bc4d1e9140553fa0cd04a360ad62eb7f 100644 (file)
@@ -2727,7 +2727,10 @@ typedef struct sqlite3_context sqlite3_context;
 **
 ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
 ** 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
 ** information is in static, unmanaged space and does not need to be freed.
 ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
@@ -3368,11 +3371,14 @@ int sqlite3_reset(sqlite3_stmt *pStmt);
 ** callbacks.
 **
 ** ^If the tenth parameter to sqlite3_create_function_v2() is not NULL,
-** then it is invoked when the function is deleted, either by being
-** overloaded or when the database connection closes.
-** ^When the destructure callback of the tenth parameter is invoked, it
-** is passed a single argument which is a copy of the pointer which was
-** the fifth parameter to sqlite3_create_function_v2().
+** then it is destructor for the application data point that is invoked
+** when the function is deleted, either by being
+** overloaded or when the database connection closes.  
+** ^The destructor is also invoked if the call to
+** 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
 ** 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
 ** [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()].
 */
 int sqlite3_create_collation(
@@ -4590,7 +4605,9 @@ struct sqlite3_index_info {
 ** ^The sqlite3_create_module_v2() interface has a fifth parameter which
 ** is a pointer to a destructor for the pClientData.  ^SQLite will
 ** 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
 ** destructor.
 */
index 96a19e04e2d08430869bd85bc8ad390b7d3a6c6a..da709064fcdec6ea5a1c07a1ee03d42d9577c584 100644 (file)
@@ -1022,6 +1022,8 @@ static int bindText(
       rc = sqlite3ApiExit(p->db, rc);
     }
     sqlite3_mutex_leave(p->db->mutex);
+  }else if( xDel ){
+    xDel((void*)zData);
   }
   return rc;
 }