mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Enhance fuzzcheck so that the --sqlid and --dbid options can specify a
range of tests to be run. FossilOrigin-Name: cdd0af6f86e49ade1339ad5a3cc444400a9722a9efdf84a30b3ff9428b7ac36d
This commit is contained in:
@ -507,7 +507,8 @@ static void writefileFunc(
|
||||
static void blobListLoadFromDb(
|
||||
sqlite3 *db, /* Read from this database */
|
||||
const char *zSql, /* Query used to extract the blobs */
|
||||
int onlyId, /* Only load where id is this value */
|
||||
int firstId, /* First sqlid to load */
|
||||
int lastId, /* Last sqlid to load */
|
||||
int *pN, /* OUT: Write number of blobs loaded here */
|
||||
Blob **ppList /* OUT: Write the head of the blob list here */
|
||||
){
|
||||
@ -518,8 +519,9 @@ static void blobListLoadFromDb(
|
||||
int rc;
|
||||
char *z2;
|
||||
|
||||
if( onlyId>0 ){
|
||||
z2 = sqlite3_mprintf("%s WHERE rowid=%d", zSql, onlyId);
|
||||
if( firstId>0 ){
|
||||
z2 = sqlite3_mprintf("%s WHERE rowid BETWEEN %d AND %d", zSql,
|
||||
firstId, lastId);
|
||||
}else{
|
||||
z2 = sqlite3_mprintf("%s", zSql);
|
||||
}
|
||||
@ -1883,8 +1885,10 @@ int main(int argc, char **argv){
|
||||
Blob *pDb; /* For looping over template databases */
|
||||
int i; /* Loop index for the argv[] loop */
|
||||
int dbSqlOnly = 0; /* Only use scripts that are dbsqlfuzz */
|
||||
int onlySqlid = -1; /* --sqlid */
|
||||
int onlyDbid = -1; /* --dbid */
|
||||
int firstSqlid = -1; /* First --sqlid range */
|
||||
int lastSqlid = 0x7fffffff; /* Last --sqlid range */
|
||||
int firstDbid = -1; /* --dbid */
|
||||
int lastDbid = 0x7fffffff; /* --dbid end */
|
||||
int nativeFlag = 0; /* --native-vfs */
|
||||
int rebuildFlag = 0; /* --rebuild */
|
||||
int vdbeLimitFlag = 0; /* --limit-vdbe */
|
||||
@ -1942,8 +1946,18 @@ int main(int argc, char **argv){
|
||||
cellSzCkFlag = 1;
|
||||
}else
|
||||
if( strcmp(z,"dbid")==0 ){
|
||||
const char *zDotDot;
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
onlyDbid = integerValue(argv[++i]);
|
||||
i++;
|
||||
zDotDot = strstr(argv[i], "..");
|
||||
if( zDotDot ){
|
||||
firstDbid = atoi(argv[i]);
|
||||
if( zDotDot[2] ){
|
||||
lastDbid = atoi(&zDotDot[2]);
|
||||
}
|
||||
}else{
|
||||
lastDbid = firstDbid = integerValue(argv[++i]);
|
||||
}
|
||||
}else
|
||||
if( strcmp(z,"export-db")==0 ){
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
@ -2043,8 +2057,19 @@ int main(int argc, char **argv){
|
||||
bTimer = 1;
|
||||
}else
|
||||
if( strcmp(z,"sqlid")==0 ){
|
||||
const char *zDotDot;
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
onlySqlid = integerValue(argv[++i]);
|
||||
i++;
|
||||
zDotDot = strstr(argv[i], "..");
|
||||
if( zDotDot ){
|
||||
firstSqlid = atoi(argv[i]);
|
||||
if( zDotDot[2] ){
|
||||
lastSqlid = atoi(&zDotDot[2]);
|
||||
}
|
||||
}else{
|
||||
firstSqlid = integerValue(argv[++i]);
|
||||
lastSqlid = firstSqlid;
|
||||
}
|
||||
}else
|
||||
if( strcmp(z,"timeout")==0 ){
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
@ -2292,13 +2317,14 @@ int main(int argc, char **argv){
|
||||
const char *zExDb =
|
||||
"SELECT writefile(printf('%s/db%06d.db',?1,dbid),dbcontent),"
|
||||
" dbid, printf('%s/db%06d.db',?1,dbid), length(dbcontent)"
|
||||
" FROM db WHERE ?2<0 OR dbid=?2;";
|
||||
" FROM db WHERE dbid BETWEEN ?2 AND ?3;";
|
||||
rc = sqlite3_prepare_v2(db, zExDb, -1, &pStmt, 0);
|
||||
if( rc ) fatalError("cannot prepare statement [%s]: %s",
|
||||
zExDb, sqlite3_errmsg(db));
|
||||
sqlite3_bind_text64(pStmt, 1, zExpDb, strlen(zExpDb),
|
||||
SQLITE_STATIC, SQLITE_UTF8);
|
||||
sqlite3_bind_int(pStmt, 2, onlyDbid);
|
||||
sqlite3_bind_int(pStmt, 2, firstDbid);
|
||||
sqlite3_bind_int(pStmt, 3, lastDbid);
|
||||
while( sqlite3_step(pStmt)==SQLITE_ROW ){
|
||||
printf("write db-%d (%d bytes) into %s\n",
|
||||
sqlite3_column_int(pStmt,1),
|
||||
@ -2311,13 +2337,14 @@ int main(int argc, char **argv){
|
||||
const char *zExSql =
|
||||
"SELECT writefile(printf('%s/sql%06d.txt',?1,sqlid),sqltext),"
|
||||
" sqlid, printf('%s/sql%06d.txt',?1,sqlid), length(sqltext)"
|
||||
" FROM xsql WHERE ?2<0 OR sqlid=?2;";
|
||||
" FROM xsql WHERE sqlid BETWEEN ?2 AND ?3;";
|
||||
rc = sqlite3_prepare_v2(db, zExSql, -1, &pStmt, 0);
|
||||
if( rc ) fatalError("cannot prepare statement [%s]: %s",
|
||||
zExSql, sqlite3_errmsg(db));
|
||||
sqlite3_bind_text64(pStmt, 1, zExpSql, strlen(zExpSql),
|
||||
SQLITE_STATIC, SQLITE_UTF8);
|
||||
sqlite3_bind_int(pStmt, 2, onlySqlid);
|
||||
sqlite3_bind_int(pStmt, 2, firstSqlid);
|
||||
sqlite3_bind_int(pStmt, 3, lastSqlid);
|
||||
while( sqlite3_step(pStmt)==SQLITE_ROW ){
|
||||
printf("write sql-%d (%d bytes) into %s\n",
|
||||
sqlite3_column_int(pStmt,1),
|
||||
@ -2333,11 +2360,11 @@ int main(int argc, char **argv){
|
||||
/* Load all SQL script content and all initial database images from the
|
||||
** source db
|
||||
*/
|
||||
blobListLoadFromDb(db, "SELECT sqlid, sqltext FROM xsql", onlySqlid,
|
||||
&g.nSql, &g.pFirstSql);
|
||||
blobListLoadFromDb(db, "SELECT sqlid, sqltext FROM xsql", firstSqlid,
|
||||
lastSqlid, &g.nSql, &g.pFirstSql);
|
||||
if( g.nSql==0 ) fatalError("need at least one SQL script");
|
||||
blobListLoadFromDb(db, "SELECT dbid, dbcontent FROM db", onlyDbid,
|
||||
&g.nDb, &g.pFirstDb);
|
||||
blobListLoadFromDb(db, "SELECT dbid, dbcontent FROM db", firstDbid,
|
||||
lastDbid, &g.nDb, &g.pFirstDb);
|
||||
if( g.nDb==0 ){
|
||||
g.pFirstDb = safe_realloc(0, sizeof(Blob));
|
||||
memset(g.pFirstDb, 0, sizeof(Blob));
|
||||
|
Reference in New Issue
Block a user