Additional documentation and tests making it clear that whenever

sqlite3_prepare() fails it sets *ppStmt to NULL. (CVS 4818)

FossilOrigin-Name: 39769f00c5d9ea20ad5d1c0569464529e953fa9d
This commit is contained in:
drh
2008-03-03 18:47:28 +00:00
parent 47524b8c47
commit 17eaae7493
4 changed files with 32 additions and 16 deletions
+8 -8
View File
@@ -1,5 +1,5 @@
C Add\sfts2/3\sfiles\sto\sautoconf-generated\sMakefile\s(needed\sfor\samalgamation)\s(CVS\s4817)
D 2008-03-02T05:40:06
C Additional\sdocumentation\sand\stests\smaking\sit\sclear\sthat\swhenever\nsqlite3_prepare()\sfails\sit\ssets\s*ppStmt\sto\sNULL.\s(CVS\s4818)
D 2008-03-03T18:47:28
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 671087b1907a3c3f2afa18d4fd9e8d180d28adfc
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -131,13 +131,13 @@ F src/pager.c d09885bb88e9868a5c322a0181d4022cf294d98b
F src/pager.h 8174615ffd14ccc2cad2b081b919a398fa95e3f9
F src/parse.y 00f2698c8ae84f315be5e3f10b63c94f531fdd6d
F src/pragma.c e3f39f8576234887ecd0c1de43dc51af5855930c
F src/prepare.c 1b0601ca3f97a9d253cc08697484e3045a1678e9
F src/prepare.c 98c763fb124769473c6dc1622803db2d45fbff4e
F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
F src/random.c 02ef38b469237482f1ea14a78b2087cfbaec48bd
F src/select.c aef06a4b157cc7defe8f99255f9a13cf693c8f13
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c c1ef4eb7872afb7417e52d6ec3f2d15be90cba8a
F src/sqlite.h.in 16c6ed1b8e7a2bcdff41306f5115cbe5ed0c8c23
F src/sqlite.h.in b8158aa606f0b39426d63132ae0530d91c021abb
F src/sqlite3ext.h 50c70a894ffe8e6ada5948c89b91db0a80a6b2a7
F src/sqliteInt.h 073801285d2650b22033a20c2389241c5e0361d6
F src/sqliteLimit.h ee4430f88f69bf63527967bb35ca52af7b0ccb1e
@@ -621,7 +621,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 8c1b6357f0bc86645017913e8b6ea8e82473f7df
R 0f28afaa044cd07bdf94dc35bfef7299
U mlcreech
Z 095a32a308b58ef01f8c4afd9a830ab2
P 89666f94906c0ad651a444800dcf8ac886fe0c22
R e97d51235ba5646643ee97dc2217d740
U drh
Z 9cd6c366577fcadd7704c59f2f60a3cb
+1 -1
View File
@@ -1 +1 @@
89666f94906c0ad651a444800dcf8ac886fe0c22
39769f00c5d9ea20ad5d1c0569464529e953fa9d
+17 -5
View File
@@ -13,7 +13,7 @@
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.75 2008/01/23 03:03:05 drh Exp $
** $Id: prepare.c,v 1.76 2008/03/03 18:47:28 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -681,7 +681,10 @@ int sqlite3_prepare(
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const char **pzTail /* OUT: End of parsed string */
){
return sqlite3LockAndPrepare(db,zSql,nBytes,0,ppStmt,pzTail);
int rc;
rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,ppStmt,pzTail);
assert( rc==SQLITE_OK || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
int sqlite3_prepare_v2(
sqlite3 *db, /* Database handle. */
@@ -690,7 +693,10 @@ int sqlite3_prepare_v2(
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const char **pzTail /* OUT: End of parsed string */
){
return sqlite3LockAndPrepare(db,zSql,nBytes,1,ppStmt,pzTail);
int rc;
rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,ppStmt,pzTail);
assert( rc==SQLITE_OK || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
@@ -753,7 +759,10 @@ int sqlite3_prepare16(
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const void **pzTail /* OUT: End of parsed string */
){
return sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);
int rc;
rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);
assert( rc==SQLITE_OK || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
int sqlite3_prepare16_v2(
sqlite3 *db, /* Database handle. */
@@ -762,7 +771,10 @@ int sqlite3_prepare16_v2(
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const void **pzTail /* OUT: End of parsed string */
){
return sqlite3Prepare16(db,zSql,nBytes,1,ppStmt,pzTail);
int rc;
rc = sqlite3Prepare16(db,zSql,nBytes,1,ppStmt,pzTail);
assert( rc==SQLITE_OK || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
#endif /* SQLITE_OMIT_UTF16 */
+6 -2
View File
@@ -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.288 2008/03/01 23:34:47 mlcreech Exp $
** @(#) $Id: sqlite.h.in,v 1.289 2008/03/03 18:47:28 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
@@ -2157,7 +2157,7 @@ typedef struct sqlite3_stmt sqlite3_stmt;
** uncompiled.
**
** *ppStmt is left pointing to a compiled [prepared statement] that can be
** executed using [sqlite3_step()]. Or if there is an error, *ppStmt may be
** executed using [sqlite3_step()]. Or if there is an error, *ppStmt is
** set to NULL. If the input text contains no SQL (if the input
** is and empty string or a comment) then *ppStmt is set to NULL.
** {U13018} The calling procedure is responsible for deleting the
@@ -2231,6 +2231,10 @@ typedef struct sqlite3_stmt sqlite3_stmt;
**
** {F13019} The [sqlite3_prepare_v2()] interface and its variants return
** [SQLITE_OK] or an appropriate [error code] upon failure.
**
** {F13021} Before [sqlite3_prepare(db,zSql,nByte,ppStmt,pzTail)] or its
** variants returns an error (any value other than [SQLITE_OK])
** it first sets *ppStmt to NULL.
*/
int sqlite3_prepare(
sqlite3 *db, /* Database handle */