aboutsummaryrefslogtreecommitdiff
path: root/src/test9.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2009-04-02 18:32:26 +0000
committerdrh <drh@noemail.net>2009-04-02 18:32:26 +0000
commit860e077a7aa6c5aa36de9ed6117016c92f9464f0 (patch)
tree9866aff2593a8922d8555ad4478ccb752db2db68 /src/test9.c
parentfa542f1fc80c7c27012b427da9a098eb20f629d6 (diff)
downloadsqlite-860e077a7aa6c5aa36de9ed6117016c92f9464f0.tar.gz
sqlite-860e077a7aa6c5aa36de9ed6117016c92f9464f0.zip
Fix the sqlite3_prepare() family of interfaces so that they zero the *ppStmt
value even on an SQLITE_MISUSE return. Make it clear in the documentation that the ppStmt parameter cannot be zero. (CVS 6441) FossilOrigin-Name: 23bf9f266559603e37b2703715eaf8ef5af6bb17
Diffstat (limited to 'src/test9.c')
-rw-r--r--src/test9.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/test9.c b/src/test9.c
index 2043da23f..222bdc390 100644
--- a/src/test9.c
+++ b/src/test9.c
@@ -14,7 +14,7 @@
** for completeness. Test code is written in C for these cases
** as there is not much point in binding to Tcl.
**
-** $Id: test9.c,v 1.6 2008/07/11 13:53:55 drh Exp $
+** $Id: test9.c,v 1.7 2009/04/02 18:32:27 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -114,6 +114,7 @@ static int c_misuse_test(
){
const char *zErrFunction = "N/A";
sqlite3 *db = 0;
+ sqlite3_stmt *pStmt;
int rc;
if( objc!=1 ){
@@ -138,29 +139,37 @@ static int c_misuse_test(
goto error_out;
}
- rc = sqlite3_prepare(db, 0, 0, 0, 0);
+ pStmt = (sqlite3_stmt*)1234;
+ rc = sqlite3_prepare(db, 0, 0, &pStmt, 0);
if( rc!=SQLITE_MISUSE ){
zErrFunction = "sqlite3_prepare";
goto error_out;
}
+ assert( pStmt==0 ); /* Verify that pStmt is zeroed even on a MISUSE error */
- rc = sqlite3_prepare_v2(db, 0, 0, 0, 0);
+ pStmt = (sqlite3_stmt*)1234;
+ rc = sqlite3_prepare_v2(db, 0, 0, &pStmt, 0);
if( rc!=SQLITE_MISUSE ){
zErrFunction = "sqlite3_prepare_v2";
goto error_out;
}
+ assert( pStmt==0 );
#ifndef SQLITE_OMIT_UTF16
- rc = sqlite3_prepare16(db, 0, 0, 0, 0);
+ pStmt = (sqlite3_stmt*)1234;
+ rc = sqlite3_prepare16(db, 0, 0, &pStmt, 0);
if( rc!=SQLITE_MISUSE ){
zErrFunction = "sqlite3_prepare16";
goto error_out;
}
- rc = sqlite3_prepare16_v2(db, 0, 0, 0, 0);
+ assert( pStmt==0 );
+ pStmt = (sqlite3_stmt*)1234;
+ rc = sqlite3_prepare16_v2(db, 0, 0, &pStmt, 0);
if( rc!=SQLITE_MISUSE ){
zErrFunction = "sqlite3_prepare16_v2";
goto error_out;
}
+ assert( pStmt==0 );
#endif
return TCL_OK;