mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fix a harmless problem in the CLI in which SQL errors that occur during
the ".schema" command are properly ignored, yes still appear in the ".log" output. [forum:/forumpost/42fe6520b803be51|Forum post 42fe6520b8] FossilOrigin-Name: 20abf1ec107f942e4527901685d61283c9c2fe7bcefad63dbf5c6cbf050da849
This commit is contained in:
@@ -1243,30 +1243,6 @@ static void shellDtostr(
|
||||
sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** SQL function: shell_module_schema(X)
|
||||
**
|
||||
** Return a fake schema for the table-valued function or eponymous virtual
|
||||
** table X.
|
||||
*/
|
||||
static void shellModuleSchema(
|
||||
sqlite3_context *pCtx,
|
||||
int nVal,
|
||||
sqlite3_value **apVal
|
||||
){
|
||||
const char *zName;
|
||||
char *zFake;
|
||||
UNUSED_PARAMETER(nVal);
|
||||
zName = (const char*)sqlite3_value_text(apVal[0]);
|
||||
zFake = zName? shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName) : 0;
|
||||
if( zFake ){
|
||||
sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake),
|
||||
-1, sqlite3_free);
|
||||
free(zFake);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** SQL function: shell_add_schema(S,X)
|
||||
**
|
||||
@@ -5710,6 +5686,39 @@ static void shellUSleepFunc(
|
||||
sqlite3_result_int(context, sleep);
|
||||
}
|
||||
|
||||
/*
|
||||
** SQL function: shell_module_schema(X)
|
||||
**
|
||||
** Return a fake schema for the table-valued function or eponymous virtual
|
||||
** table X.
|
||||
*/
|
||||
static void shellModuleSchema(
|
||||
sqlite3_context *pCtx,
|
||||
int nVal,
|
||||
sqlite3_value **apVal
|
||||
){
|
||||
const char *zName;
|
||||
char *zFake;
|
||||
ShellState *p = (ShellState*)sqlite3_user_data(pCtx);
|
||||
FILE *pSavedLog = p->pLog;
|
||||
UNUSED_PARAMETER(nVal);
|
||||
zName = (const char*)sqlite3_value_text(apVal[0]);
|
||||
|
||||
/* Temporarily disable the ".log" when calling shellFakeSchema() because
|
||||
** shellFakeSchema() might generate failures for some ephemeral virtual
|
||||
** tables due to missing arguments. Example: fts4aux.
|
||||
** https://sqlite.org/forum/forumpost/42fe6520b803be51 */
|
||||
p->pLog = 0;
|
||||
zFake = zName? shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName) : 0;
|
||||
p->pLog = pSavedLog;
|
||||
|
||||
if( zFake ){
|
||||
sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake),
|
||||
-1, sqlite3_free);
|
||||
free(zFake);
|
||||
}
|
||||
}
|
||||
|
||||
/* Flags for open_db().
|
||||
**
|
||||
** The default behavior of open_db() is to exit(1) if the database fails to
|
||||
@@ -5853,7 +5862,7 @@ static void open_db(ShellState *p, int openFlags){
|
||||
shellDtostr, 0, 0);
|
||||
sqlite3_create_function(p->db, "shell_add_schema", 3, SQLITE_UTF8, 0,
|
||||
shellAddSchemaName, 0, 0);
|
||||
sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, 0,
|
||||
sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, p,
|
||||
shellModuleSchema, 0, 0);
|
||||
sqlite3_create_function(p->db, "shell_putsnl", 1, SQLITE_UTF8, p,
|
||||
shellPutsFunc, 0, 0);
|
||||
|
Reference in New Issue
Block a user