aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest18
-rw-r--r--manifest.uuid2
-rw-r--r--src/prepare.c12
-rw-r--r--src/sqlite.h.in16
-rw-r--r--src/test9.c19
5 files changed, 39 insertions, 28 deletions
diff --git a/manifest b/manifest
index ca77fb3bd..ae7a13e34 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\scausing\sthe\sBtShared.isPending\sflag\sto\sbe\scleared\sto\searly.\sAlso\scoverage\simprovements\sfor\sbtree.c.\s(CVS\s6440)
-D 2009-04-02T18:28:08
+C Fix\sthe\ssqlite3_prepare()\sfamily\sof\sinterfaces\sso\sthat\sthey\szero\sthe\s*ppStmt\nvalue\seven\son\san\sSQLITE_MISUSE\sreturn.\s\sMake\sit\sclear\sin\sthe\sdocumentation\nthat\sthe\sppStmt\sparameter\scannot\sbe\szero.\s(CVS\s6441)
+D 2009-04-02T18:32:27
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -150,14 +150,14 @@ F src/pcache.c 395f752a13574120bd7513a400ba02a265aaa76d
F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324
F src/pcache1.c f587565f4ba0fd1772067eaa96814dce761b7a4c
F src/pragma.c 22ed04836aab8ce134c53be1ca896f3ad20fabdb
-F src/prepare.c aa3e7dc01a011269b9152e5103fad2eea2c96e7a
+F src/prepare.c 0ad1ba3290e0626aa4e7589ed6ab6af2572875b0
F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f
F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628
F src/resolve.c 094e44450371fb27869eb8bf679aacbe51fdc56d
F src/rowset.c badb9f36b3a2ced9ee9551f4ce730f5fab442791
F src/select.c 462d9671e91accd983110fa38674be0d2a3daa66
F src/shell.c 0a11f831603f17fea20ca97133c0f64e716af4a7
-F src/sqlite.h.in 0db1e59d89aeacb8fe64a19fd14c13a796060ccb
+F src/sqlite.h.in 0721c11055d2c60cc7579e56560916de82cf7620
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
F src/sqliteInt.h 22114af78e17ab06b4ccd3b3f7db8ab14b5f2bb9
F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d
@@ -172,7 +172,7 @@ F src/test5.c 162a1cea2105a2c460a3f39fa6919617b562a288
F src/test6.c 1a0a7a1f179469044b065b4a88aab9faee114101
F src/test7.c b94e68c2236de76889d82b8d7d8e00ad6a4d80b1
F src/test8.c 3637439424d0d21ff2dcf9b015c30fcc1e7bcb24
-F src/test9.c 904ebe0ed1472d6bad17a81e2ecbfc20017dc237
+F src/test9.c 963d380922f25c1c323712d05db01b19197ee6f7
F src/test_async.c da1402a61a99d9707f9d65df063cb8e7d0df605a
F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad
F src/test_backup.c 1384a18985a5a2d275c2662e48473bf1542ebd08
@@ -715,7 +715,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 058a2f20930d7707c03c3c27db8e761d5657ee46
-R 3a4050ae67f1e8a6ec248bda7bba7d51
-U danielk1977
-Z dc4c28528723be8812cc90fabf0cbd80
+P 8f1423445b29a5f52ed907de6db82128a96ebfe2
+R d66b51a142fefca07584ceedbb6d0a07
+U drh
+Z 86a6d740a23a4566ad36f5b8a9a6d901
diff --git a/manifest.uuid b/manifest.uuid
index 64cdd9b09..88f094362 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-8f1423445b29a5f52ed907de6db82128a96ebfe2 \ No newline at end of file
+23bf9f266559603e37b2703715eaf8ef5af6bb17 \ No newline at end of file
diff --git a/src/prepare.c b/src/prepare.c
index c4d88a3be..e3479f3b8 100644
--- a/src/prepare.c
+++ b/src/prepare.c
@@ -13,7 +13,7 @@
** interface, and routines that contribute to loading the database schema
** from disk.
**
-** $Id: prepare.c,v 1.115 2009/04/01 16:33:38 drh Exp $
+** $Id: prepare.c,v 1.116 2009/04/02 18:32:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -528,11 +528,8 @@ static int sqlite3Prepare(
int rc = SQLITE_OK;
int i;
- assert( ppStmt );
- *ppStmt = 0;
- if( sqlite3SafetyOn(db) ){
- return SQLITE_MISUSE;
- }
+ if( sqlite3SafetyOn(db) ) return SQLITE_MISUSE;
+ assert( ppStmt && *ppStmt==0 );
assert( !db->mallocFailed );
assert( sqlite3_mutex_held(db->mutex) );
@@ -671,6 +668,8 @@ static int sqlite3LockAndPrepare(
const char **pzTail /* OUT: End of parsed string */
){
int rc;
+ assert( ppStmt!=0 );
+ *ppStmt = 0;
if( !sqlite3SafetyCheckOk(db) ){
return SQLITE_MISUSE;
}
@@ -773,6 +772,7 @@ static int sqlite3Prepare16(
const char *zTail8 = 0;
int rc = SQLITE_OK;
+ assert( ppStmt );
*ppStmt = 0;
if( !sqlite3SafetyCheckOk(db) ){
return SQLITE_MISUSE;
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index d8f51e79c..1ecd14c23 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -30,7 +30,7 @@
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
**
-** @(#) $Id: sqlite.h.in,v 1.436 2009/03/20 13:15:30 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.437 2009/04/02 18:32:27 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
@@ -2229,7 +2229,8 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
** program using one of these routines.
**
** The first argument, "db", is a [database connection] obtained from a
-** prior call to [sqlite3_open()], [sqlite3_open_v2()] or [sqlite3_open16()].
+** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
+** [sqlite3_open16()]. The database connection must not have been closed.
**
** The second argument, "zSql", is the statement to be compiled, encoded
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
@@ -2246,17 +2247,18 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
** is equal to the number of bytes in the input string <i>including</i>
** the nul-terminator bytes.
**
-** *pzTail is made to point to the first byte past the end of the
-** first SQL statement in zSql. These routines only compile the first
-** statement in zSql, so *pzTail is left pointing to what remains
-** uncompiled.
+** If pzTail is not NULL then *pzTail is made to point to the first byte
+** past the end of the first SQL statement in zSql. These routines only
+** compile the first statement in zSql, so *pzTail is left pointing to
+** what remains uncompiled.
**
** *ppStmt is left pointing to a compiled [prepared statement] that can be
** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
** to NULL. If the input text contains no SQL (if the input is an empty
** string or a comment) then *ppStmt is set to NULL.
-** {A13018} The calling procedure is responsible for deleting the compiled
+** The calling procedure is responsible for deleting the compiled
** SQL statement using [sqlite3_finalize()] after it has finished with it.
+** ppStmt may not be NULL.
**
** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
**
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;