Fossil SCM

For the "query -nocomplain" TH1 command, make sure the SQLite log does not add error messages to the output.

drh 2016-08-17 15:56 trunk
Commit 801eca62a83757271adf2e112e077fd0a3eecaa8
2 files changed +2 +15 -1
+2
--- src/main.c
+++ src/main.c
@@ -129,10 +129,11 @@
129129
const char *zVfsName; /* The VFS to use for database connections */
130130
sqlite3 *db; /* The connection to the databases */
131131
sqlite3 *dbConfig; /* Separate connection for global_config table */
132132
char *zAuxSchema; /* Main repository aux-schema */
133133
int useAttach; /* True if global_config is attached to repository */
134
+ int dbIgnoreErrors; /* Ignore database errors if true */
134135
const char *zConfigDbName;/* Path of the config database. NULL if not open */
135136
sqlite3_int64 now; /* Seconds since 1970 */
136137
int repositoryOpen; /* True if the main repository database is open */
137138
char *zRepositoryOption; /* Most recent cached repository option value */
138139
char *zRepositoryName; /* Name of the repository database */
@@ -559,10 +560,11 @@
559560
/* Disable the file alias warning on apple products because Time Machine
560561
** creates lots of aliases and the warning alarms people. */
561562
if( iCode==SQLITE_WARNING ) return;
562563
#endif
563564
if( iCode==SQLITE_SCHEMA ) return;
565
+ if( g.dbIgnoreErrors ) return;
564566
fossil_warning("%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg);
565567
}
566568
567569
/*
568570
** This function attempts to find command line options known to contain
569571
--- src/main.c
+++ src/main.c
@@ -129,10 +129,11 @@
129 const char *zVfsName; /* The VFS to use for database connections */
130 sqlite3 *db; /* The connection to the databases */
131 sqlite3 *dbConfig; /* Separate connection for global_config table */
132 char *zAuxSchema; /* Main repository aux-schema */
133 int useAttach; /* True if global_config is attached to repository */
 
134 const char *zConfigDbName;/* Path of the config database. NULL if not open */
135 sqlite3_int64 now; /* Seconds since 1970 */
136 int repositoryOpen; /* True if the main repository database is open */
137 char *zRepositoryOption; /* Most recent cached repository option value */
138 char *zRepositoryName; /* Name of the repository database */
@@ -559,10 +560,11 @@
559 /* Disable the file alias warning on apple products because Time Machine
560 ** creates lots of aliases and the warning alarms people. */
561 if( iCode==SQLITE_WARNING ) return;
562 #endif
563 if( iCode==SQLITE_SCHEMA ) return;
 
564 fossil_warning("%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg);
565 }
566
567 /*
568 ** This function attempts to find command line options known to contain
569
--- src/main.c
+++ src/main.c
@@ -129,10 +129,11 @@
129 const char *zVfsName; /* The VFS to use for database connections */
130 sqlite3 *db; /* The connection to the databases */
131 sqlite3 *dbConfig; /* Separate connection for global_config table */
132 char *zAuxSchema; /* Main repository aux-schema */
133 int useAttach; /* True if global_config is attached to repository */
134 int dbIgnoreErrors; /* Ignore database errors if true */
135 const char *zConfigDbName;/* Path of the config database. NULL if not open */
136 sqlite3_int64 now; /* Seconds since 1970 */
137 int repositoryOpen; /* True if the main repository database is open */
138 char *zRepositoryOption; /* Most recent cached repository option value */
139 char *zRepositoryName; /* Name of the repository database */
@@ -559,10 +560,11 @@
560 /* Disable the file alias warning on apple products because Time Machine
561 ** creates lots of aliases and the warning alarms people. */
562 if( iCode==SQLITE_WARNING ) return;
563 #endif
564 if( iCode==SQLITE_SCHEMA ) return;
565 if( g.dbIgnoreErrors ) return;
566 fossil_warning("%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg);
567 }
568
569 /*
570 ** This function attempts to find command line options known to contain
571
+15 -1
--- src/th_main.c
+++ src/th_main.c
@@ -1426,10 +1426,22 @@
14261426
sqlite3_randomness(n, aRand);
14271427
encode16(aRand, zOut, n);
14281428
Th_SetResult(interp, (const char *)zOut, -1);
14291429
return TH_OK;
14301430
}
1431
+
1432
+/*
1433
+** Run sqlite3_step() while suppressing error messages sent to the
1434
+** rendered webpage or to the console.
1435
+*/
1436
+static int ignore_errors_step(sqlite3_stmt *pStmt){
1437
+ int rc;
1438
+ g.dbIgnoreErrors++;
1439
+ rc = sqlite3_step(pStmt);
1440
+ g.dbIgnoreErrors--;
1441
+ return rc;
1442
+}
14311443
14321444
/*
14331445
** TH1 command: query [-nocomplain] SQL CODE
14341446
**
14351447
** Run the SQL query given by the SQL argument. For each row in the result
@@ -1474,11 +1486,13 @@
14741486
zSql = argv[1];
14751487
nSql = argl[1];
14761488
while( res==TH_OK && nSql>0 ){
14771489
zErr = 0;
14781490
sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr);
1491
+ g.dbIgnoreErrors++;
14791492
rc = sqlite3_prepare_v2(g.db, argv[1], argl[1], &pStmt, &zTail);
1493
+ g.dbIgnoreErrors--;
14801494
sqlite3_set_authorizer(g.db, 0, 0);
14811495
if( rc!=0 || zErr!=0 ){
14821496
if( noComplain ) return TH_OK;
14831497
Th_ErrorMessage(interp, "SQL error: ",
14841498
zErr ? zErr : sqlite3_errmsg(g.db), -1);
@@ -1497,11 +1511,11 @@
14971511
int nVal;
14981512
const char *zVal = Th_GetResult(interp, &nVal);
14991513
sqlite3_bind_text(pStmt, i, zVal, nVal, SQLITE_TRANSIENT);
15001514
}
15011515
}
1502
- while( res==TH_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
1516
+ while( res==TH_OK && ignore_errors_step(pStmt)==SQLITE_ROW ){
15031517
int nCol = sqlite3_column_count(pStmt);
15041518
for(i=0; i<nCol; i++){
15051519
const char *zCol = sqlite3_column_name(pStmt, i);
15061520
int szCol = th_strlen(zCol);
15071521
const char *zVal = (const char*)sqlite3_column_text(pStmt, i);
15081522
--- src/th_main.c
+++ src/th_main.c
@@ -1426,10 +1426,22 @@
1426 sqlite3_randomness(n, aRand);
1427 encode16(aRand, zOut, n);
1428 Th_SetResult(interp, (const char *)zOut, -1);
1429 return TH_OK;
1430 }
 
 
 
 
 
 
 
 
 
 
 
 
1431
1432 /*
1433 ** TH1 command: query [-nocomplain] SQL CODE
1434 **
1435 ** Run the SQL query given by the SQL argument. For each row in the result
@@ -1474,11 +1486,13 @@
1474 zSql = argv[1];
1475 nSql = argl[1];
1476 while( res==TH_OK && nSql>0 ){
1477 zErr = 0;
1478 sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr);
 
1479 rc = sqlite3_prepare_v2(g.db, argv[1], argl[1], &pStmt, &zTail);
 
1480 sqlite3_set_authorizer(g.db, 0, 0);
1481 if( rc!=0 || zErr!=0 ){
1482 if( noComplain ) return TH_OK;
1483 Th_ErrorMessage(interp, "SQL error: ",
1484 zErr ? zErr : sqlite3_errmsg(g.db), -1);
@@ -1497,11 +1511,11 @@
1497 int nVal;
1498 const char *zVal = Th_GetResult(interp, &nVal);
1499 sqlite3_bind_text(pStmt, i, zVal, nVal, SQLITE_TRANSIENT);
1500 }
1501 }
1502 while( res==TH_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
1503 int nCol = sqlite3_column_count(pStmt);
1504 for(i=0; i<nCol; i++){
1505 const char *zCol = sqlite3_column_name(pStmt, i);
1506 int szCol = th_strlen(zCol);
1507 const char *zVal = (const char*)sqlite3_column_text(pStmt, i);
1508
--- src/th_main.c
+++ src/th_main.c
@@ -1426,10 +1426,22 @@
1426 sqlite3_randomness(n, aRand);
1427 encode16(aRand, zOut, n);
1428 Th_SetResult(interp, (const char *)zOut, -1);
1429 return TH_OK;
1430 }
1431
1432 /*
1433 ** Run sqlite3_step() while suppressing error messages sent to the
1434 ** rendered webpage or to the console.
1435 */
1436 static int ignore_errors_step(sqlite3_stmt *pStmt){
1437 int rc;
1438 g.dbIgnoreErrors++;
1439 rc = sqlite3_step(pStmt);
1440 g.dbIgnoreErrors--;
1441 return rc;
1442 }
1443
1444 /*
1445 ** TH1 command: query [-nocomplain] SQL CODE
1446 **
1447 ** Run the SQL query given by the SQL argument. For each row in the result
@@ -1474,11 +1486,13 @@
1486 zSql = argv[1];
1487 nSql = argl[1];
1488 while( res==TH_OK && nSql>0 ){
1489 zErr = 0;
1490 sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr);
1491 g.dbIgnoreErrors++;
1492 rc = sqlite3_prepare_v2(g.db, argv[1], argl[1], &pStmt, &zTail);
1493 g.dbIgnoreErrors--;
1494 sqlite3_set_authorizer(g.db, 0, 0);
1495 if( rc!=0 || zErr!=0 ){
1496 if( noComplain ) return TH_OK;
1497 Th_ErrorMessage(interp, "SQL error: ",
1498 zErr ? zErr : sqlite3_errmsg(g.db), -1);
@@ -1497,11 +1511,11 @@
1511 int nVal;
1512 const char *zVal = Th_GetResult(interp, &nVal);
1513 sqlite3_bind_text(pStmt, i, zVal, nVal, SQLITE_TRANSIENT);
1514 }
1515 }
1516 while( res==TH_OK && ignore_errors_step(pStmt)==SQLITE_ROW ){
1517 int nCol = sqlite3_column_count(pStmt);
1518 for(i=0; i<nCol; i++){
1519 const char *zCol = sqlite3_column_name(pStmt, i);
1520 int szCol = th_strlen(zCol);
1521 const char *zVal = (const char*)sqlite3_column_text(pStmt, i);
1522

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button