SQLite

Check-in [c81fc40b2b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Move test logic for SQLITE_FCNTL_PRAGMA out of os_unix.c and into test_vfs.c.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | file-control-pragma
Files: files | file ages | folders
SHA1: c81fc40b2b584820ac7d1c3848ebeb7225d4eeeb
User & Date: drh 2012-02-22 20:08:49.412
Context
2012-02-23
14:28
Expose the sqlite3_stricmp() interface. Add the SQLITE_FCNTL_PRAGMA file control. (check-in: c539cf21ef user: drh tags: trunk)
2012-02-22
20:08
Move test logic for SQLITE_FCNTL_PRAGMA out of os_unix.c and into test_vfs.c. (Closed-Leaf check-in: c81fc40b2b user: drh tags: file-control-pragma)
19:56
If the SQLITE_FCNTL_PRAGMA file-control returns anything other than SQLTIE_NOTFOUND and SQLITE_OK, then treat the result as an error. (check-in: 5643618108 user: drh tags: file-control-pragma)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
      unixModeBit(pFile, UNIXFILE_PSOW, (int*)pArg);
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_VFSNAME: {
      *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_PRAGMA: {
      char **azArg = (char**)pArg;
#ifdef SQLITE_TEST
      if( sqlite3_stricmp(azArg[1], "filename")==0 ){
        azArg[0] = sqlite3_mprintf("%s", pFile->zPath);
        return SQLITE_OK;
      }
#endif
      break;
    }
#ifndef NDEBUG
    /* The pager calls this method to signal that it has done
    ** a rollback and that the database is therefore unchanged and
    ** it hence it is OK for the transaction change counter to be
    ** unchanged.
    */
    case SQLITE_FCNTL_DB_UNCHANGED: {







<
<
<
<
<
<
<
<
<
<







3583
3584
3585
3586
3587
3588
3589










3590
3591
3592
3593
3594
3595
3596
      unixModeBit(pFile, UNIXFILE_PSOW, (int*)pArg);
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_VFSNAME: {
      *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
      return SQLITE_OK;
    }










#ifndef NDEBUG
    /* The pager calls this method to signal that it has done
    ** a rollback and that the database is therefore unchanged and
    ** it hence it is OK for the transaction change counter to be
    ** unchanged.
    */
    case SQLITE_FCNTL_DB_UNCHANGED: {
Changes to src/test_vfs.c.
491
492
493
494
495
496
497




498
499
500
501
502
503
504
          rc = x;
          while( sqlite3Isdigit(z[0]) ){ z++; }
          while( sqlite3Isspace(z[0]) ){ z++; }
        }
        if( z[0] ) argv[0] = sqlite3_mprintf("%s", z);
      }
      return rc;




    }
  }
  return sqlite3OsFileControl(p->pReal, op, pArg);
}

/*
** Return the sector-size in bytes for an tvfs-file.







>
>
>
>







491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
          rc = x;
          while( sqlite3Isdigit(z[0]) ){ z++; }
          while( sqlite3Isspace(z[0]) ){ z++; }
        }
        if( z[0] ) argv[0] = sqlite3_mprintf("%s", z);
      }
      return rc;
    }
    if( sqlite3_stricmp(argv[1], "filename")==0 ){
      argv[0] = sqlite3_mprintf("%s", p->zFilename);
      return SQLITE_OK;
    }
  }
  return sqlite3OsFileControl(p->pReal, op, pArg);
}

/*
** Return the sector-size in bytes for an tvfs-file.
Changes to test/attach.test.
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
    do_test attach-1.29 {
      db_list db
    } {0 main}
  }
} ;# ifcapable schema_pragmas


if {[regexp unix [file_control_vfsname db]]} {
  ifcapable debug {
    do_test attach-1.30.1 {
      file tail [db eval {PRAGMA main.filename}]
    } {test.db}
    do_test attach-1.30.2 {
      db eval {PRAGMA temp.filename}
    } {}
  }
}

ifcapable {trigger} {  # Only do the following tests if triggers are enabled
do_test attach-2.1 {
  execsql {
    CREATE TABLE tx(x1,x2,y1,y2);
    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN
      INSERT INTO tx(x1,x2,y1,y2) VALUES(OLD.x,NEW.x,OLD.y,NEW.y);
    END;







<
<
<
<
<
<
<
<
<
<
<







268
269
270
271
272
273
274











275
276
277
278
279
280
281
    do_test attach-1.29 {
      db_list db
    } {0 main}
  }
} ;# ifcapable schema_pragmas













ifcapable {trigger} {  # Only do the following tests if triggers are enabled
do_test attach-2.1 {
  execsql {
    CREATE TABLE tx(x1,x2,y1,y2);
    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN
      INSERT INTO tx(x1,x2,y1,y2) VALUES(OLD.x,NEW.x,OLD.y,NEW.y);
    END;
Changes to test/pragma.test.
1502
1503
1504
1505
1506
1507
1508



1509
1510
1511
} {1 {This is the error message}}
do_test pragma-19.3 {
  catchsql {PRAGMA error='7 This is the error message'}
} {1 {This is the error message}}
do_test pragma-19.4 {
  catchsql {PRAGMA error=7}
} {1 {out of memory}}





finish_test







>
>
>



1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
} {1 {This is the error message}}
do_test pragma-19.3 {
  catchsql {PRAGMA error='7 This is the error message'}
} {1 {This is the error message}}
do_test pragma-19.4 {
  catchsql {PRAGMA error=7}
} {1 {out of memory}}
do_test pragma-19.5 {
  file tail [execsql {PRAGMA filename}]
} {test.db}


finish_test