Fossil SCM
For the "query -nocomplain" TH1 command, make sure the SQLite log does not add error messages to the output.
Commit
801eca62a83757271adf2e112e077fd0a3eecaa8
Parent
27d743e70835782…
2 files changed
+2
+15
-1
+2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -129,10 +129,11 @@ | ||
| 129 | 129 | const char *zVfsName; /* The VFS to use for database connections */ |
| 130 | 130 | sqlite3 *db; /* The connection to the databases */ |
| 131 | 131 | sqlite3 *dbConfig; /* Separate connection for global_config table */ |
| 132 | 132 | char *zAuxSchema; /* Main repository aux-schema */ |
| 133 | 133 | int useAttach; /* True if global_config is attached to repository */ |
| 134 | + int dbIgnoreErrors; /* Ignore database errors if true */ | |
| 134 | 135 | const char *zConfigDbName;/* Path of the config database. NULL if not open */ |
| 135 | 136 | sqlite3_int64 now; /* Seconds since 1970 */ |
| 136 | 137 | int repositoryOpen; /* True if the main repository database is open */ |
| 137 | 138 | char *zRepositoryOption; /* Most recent cached repository option value */ |
| 138 | 139 | char *zRepositoryName; /* Name of the repository database */ |
| @@ -559,10 +560,11 @@ | ||
| 559 | 560 | /* Disable the file alias warning on apple products because Time Machine |
| 560 | 561 | ** creates lots of aliases and the warning alarms people. */ |
| 561 | 562 | if( iCode==SQLITE_WARNING ) return; |
| 562 | 563 | #endif |
| 563 | 564 | if( iCode==SQLITE_SCHEMA ) return; |
| 565 | + if( g.dbIgnoreErrors ) return; | |
| 564 | 566 | fossil_warning("%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg); |
| 565 | 567 | } |
| 566 | 568 | |
| 567 | 569 | /* |
| 568 | 570 | ** This function attempts to find command line options known to contain |
| 569 | 571 |
| --- 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 @@ | ||
| 1426 | 1426 | sqlite3_randomness(n, aRand); |
| 1427 | 1427 | encode16(aRand, zOut, n); |
| 1428 | 1428 | Th_SetResult(interp, (const char *)zOut, -1); |
| 1429 | 1429 | return TH_OK; |
| 1430 | 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 | +} | |
| 1431 | 1443 | |
| 1432 | 1444 | /* |
| 1433 | 1445 | ** TH1 command: query [-nocomplain] SQL CODE |
| 1434 | 1446 | ** |
| 1435 | 1447 | ** Run the SQL query given by the SQL argument. For each row in the result |
| @@ -1474,11 +1486,13 @@ | ||
| 1474 | 1486 | zSql = argv[1]; |
| 1475 | 1487 | nSql = argl[1]; |
| 1476 | 1488 | while( res==TH_OK && nSql>0 ){ |
| 1477 | 1489 | zErr = 0; |
| 1478 | 1490 | sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr); |
| 1491 | + g.dbIgnoreErrors++; | |
| 1479 | 1492 | rc = sqlite3_prepare_v2(g.db, argv[1], argl[1], &pStmt, &zTail); |
| 1493 | + g.dbIgnoreErrors--; | |
| 1480 | 1494 | sqlite3_set_authorizer(g.db, 0, 0); |
| 1481 | 1495 | if( rc!=0 || zErr!=0 ){ |
| 1482 | 1496 | if( noComplain ) return TH_OK; |
| 1483 | 1497 | Th_ErrorMessage(interp, "SQL error: ", |
| 1484 | 1498 | zErr ? zErr : sqlite3_errmsg(g.db), -1); |
| @@ -1497,11 +1511,11 @@ | ||
| 1497 | 1511 | int nVal; |
| 1498 | 1512 | const char *zVal = Th_GetResult(interp, &nVal); |
| 1499 | 1513 | sqlite3_bind_text(pStmt, i, zVal, nVal, SQLITE_TRANSIENT); |
| 1500 | 1514 | } |
| 1501 | 1515 | } |
| 1502 | - while( res==TH_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ | |
| 1516 | + while( res==TH_OK && ignore_errors_step(pStmt)==SQLITE_ROW ){ | |
| 1503 | 1517 | int nCol = sqlite3_column_count(pStmt); |
| 1504 | 1518 | for(i=0; i<nCol; i++){ |
| 1505 | 1519 | const char *zCol = sqlite3_column_name(pStmt, i); |
| 1506 | 1520 | int szCol = th_strlen(zCol); |
| 1507 | 1521 | const char *zVal = (const char*)sqlite3_column_text(pStmt, i); |
| 1508 | 1522 |
| --- 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 |