aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2024-12-06 18:35:16 +0000
committerdrh <>2024-12-06 18:35:16 +0000
commitef636cc3cd72b2a7f5803777b95419b279baacab (patch)
treee63ca77a8ecf6f630b5de5b921b7b2ce1ee5cd87 /src
parentc40329c9bf497896c3b58bf8918840a574f64b86 (diff)
downloadsqlite-ef636cc3cd72b2a7f5803777b95419b279baacab.tar.gz
sqlite-ef636cc3cd72b2a7f5803777b95419b279baacab.zip
Add the SQLITE_PREPARE_DONT_LOG option for sqlite3_prepare_v3(), that prevents
errors in the compilation of the SQL from being sent to sqlite3_log(). FossilOrigin-Name: 870403425493866232cf9e8fa62288861b7d0a4091b15d75727f8bb31da46f94
Diffstat (limited to 'src')
-rw-r--r--src/pragma.c3
-rw-r--r--src/sqlite.h.in11
-rw-r--r--src/tokenize.c4
-rw-r--r--src/vdbe.h2
4 files changed, 17 insertions, 3 deletions
diff --git a/src/pragma.c b/src/pragma.c
index 785676e04..ae0c86f03 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -1279,7 +1279,8 @@ void sqlite3Pragma(
char *zSql = sqlite3MPrintf(db, "SELECT*FROM\"%w\"", pTab->zName);
if( zSql ){
sqlite3_stmt *pDummy = 0;
- (void)sqlite3_prepare(db, zSql, -1, &pDummy, 0);
+ (void)sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_DONT_LOG,
+ &pDummy, 0);
(void)sqlite3_finalize(pDummy);
sqlite3DbFree(db, zSql);
}
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index b84938b45..9a117fa54 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -4204,11 +4204,22 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
** to return an error (error code SQLITE_ERROR) if the statement uses
** any virtual tables.
+**
+** [[SQLITE_PREPARE_DONT_LOG]] <dt>SQLITE_PREPARE_DONT_LOG</dt>
+** <dd>The SQLITE_PREPARE_DONT_LOG flag prevents SQL compiler
+** errors from being sent to the error log defined by
+** [SQLITE_CONFIG_LOG]. This can be used, for example, to do test
+** compiles to see if some SQL syntax is well-formed, without generating
+** messages on the global error log when it is not. If the test compile
+** fails, the sqlite3_prepare_v3() call returns the same error indications
+** with or without this flag; it just omits the call to [sqlite3_log()] that
+** logs the error.
** </dl>
*/
#define SQLITE_PREPARE_PERSISTENT 0x01
#define SQLITE_PREPARE_NORMALIZE 0x02
#define SQLITE_PREPARE_NO_VTAB 0x04
+#define SQLITE_PREPARE_DONT_LOG 0x10
/*
** CAPI3REF: Compiling An SQL Statement
diff --git a/src/tokenize.c b/src/tokenize.c
index 65d1fbf35..b49b2aa16 100644
--- a/src/tokenize.c
+++ b/src/tokenize.c
@@ -728,7 +728,9 @@ int sqlite3RunParser(Parse *pParse, const char *zSql){
if( pParse->zErrMsg==0 ){
pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
}
- sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
+ if( (pParse->prepFlags & SQLITE_PREPARE_DONT_LOG)==0 ){
+ sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
+ }
nErr++;
}
pParse->zTail = zSql;
diff --git a/src/vdbe.h b/src/vdbe.h
index f40f68d24..71aae29a0 100644
--- a/src/vdbe.h
+++ b/src/vdbe.h
@@ -185,7 +185,7 @@ typedef struct VdbeOpList VdbeOpList;
** Additional non-public SQLITE_PREPARE_* flags
*/
#define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */
-#define SQLITE_PREPARE_MASK 0x0f /* Mask of public flags */
+#define SQLITE_PREPARE_MASK 0x1f /* Mask of public flags */
/*
** Prototypes for the VDBE interface. See comments on the implementation