/ Check-in [185bc864]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Simple test cases for sqlite3_system_errno()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sqlite_system_errno
Files: files | file ages | folders
SHA1: 185bc8644c806597194dc532a4d547a03a2dedaa
User & Date: drh 2016-03-17 17:23:11
Context
2016-03-17
19:28
Change the xGetLastError() method on the windows VFS so that it continues to format an error message (if requested) but returns the system error code, rather than an SQLite status code. check-in: 1602f6b5 user: drh tags: sqlite_system_errno
17:23
Simple test cases for sqlite3_system_errno() check-in: 185bc864 user: drh tags: sqlite_system_errno
16:01
Experimental implementation of the sqlite3_system_errno() interface. check-in: 6782c87b user: drh tags: sqlite_system_errno
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test1.c.

  4842   4842       Tcl_SetResult(interp, (char *)sqlite3ErrStr(rc), TCL_STATIC);
  4843   4843       return TCL_ERROR;
  4844   4844     }
  4845   4845   
  4846   4846     Tcl_ResetResult(interp);
  4847   4847     return TCL_OK;
  4848   4848   }
         4849  +
         4850  +/*
         4851  +** Usage:  sqlite3_system_errno DB
         4852  +**
         4853  +** Return the low-level system errno value.
         4854  +*/
         4855  +static int test_system_errno(
         4856  +  void * clientData,
         4857  +  Tcl_Interp *interp,
         4858  +  int objc,
         4859  +  Tcl_Obj *CONST objv[]
         4860  +){
         4861  +  sqlite3 *db;
         4862  +  int iErrno;
         4863  +  if( objc!=2 ){
         4864  +    Tcl_WrongNumArgs(interp, 1, objv, "DB");
         4865  +    return TCL_ERROR;
         4866  +  }
         4867  +  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
         4868  +  iErrno = sqlite3_system_errno(db);
         4869  +  Tcl_SetObjResult(interp, Tcl_NewIntObj(iErrno));
         4870  +  return TCL_OK;
         4871  +}
  4849   4872   
  4850   4873   /*
  4851   4874   ** Usage:  sqlite3_db_filename DB DBNAME
  4852   4875   **
  4853   4876   ** Return the name of a file associated with a database.
  4854   4877   */
  4855   4878   static int test_db_filename(
................................................................................
  7080   7103        { "sqlite3_stmt_readonly",         test_stmt_readonly ,0 },
  7081   7104        { "sqlite3_stmt_busy",             test_stmt_busy     ,0 },
  7082   7105        { "uses_stmt_journal",             uses_stmt_journal ,0 },
  7083   7106   
  7084   7107        { "sqlite3_release_memory",        test_release_memory,     0},
  7085   7108        { "sqlite3_db_release_memory",     test_db_release_memory,  0},
  7086   7109        { "sqlite3_db_cacheflush",         test_db_cacheflush,      0},
         7110  +     { "sqlite3_system_errno",          test_system_errno,       0},
  7087   7111        { "sqlite3_db_filename",           test_db_filename,        0},
  7088   7112        { "sqlite3_db_readonly",           test_db_readonly,        0},
  7089   7113        { "sqlite3_soft_heap_limit",       test_soft_heap_limit,    0},
  7090   7114        { "sqlite3_thread_cleanup",        test_thread_cleanup,     0},
  7091   7115        { "sqlite3_pager_refcounts",       test_pager_refcounts,    0},
  7092   7116   
  7093   7117        { "sqlite3_load_extension",        test_load_extension,     0},

Changes to test/capi3.test.

   168    168   do_test capi3-3.2 {
   169    169     sqlite3_close $db2
   170    170   } {SQLITE_OK}
   171    171   do_test capi3-3.3 {
   172    172     catch {
   173    173       set db2 [sqlite3_open /bogus/path/test.db {}]
   174    174     }
   175         -  sqlite3_extended_errcode $db2
   176         -} {SQLITE_CANTOPEN}
          175  +  set ::capi3_errno [sqlite3_system_errno $db2]
          176  +  list [sqlite3_extended_errcode $db2] [expr {$::capi3_errno!=0}]
          177  +} {SQLITE_CANTOPEN 1}
   177    178   do_test capi3-3.4 {
   178    179     sqlite3_errmsg $db2
   179    180   } {unable to open database file}
   180    181   do_test capi3-3.5 {
   181         -  sqlite3_close $db2
   182         -} {SQLITE_OK}
          182  +  list [sqlite3_system_errno $db2] [sqlite3_close $db2]
          183  +} [list $::capi3_errno SQLITE_OK]
   183    184   if {[clang_sanitize_address]==0} {
   184    185     do_test capi3-3.6.1-misuse {
   185    186       sqlite3_close $db2
   186    187     } {SQLITE_MISUSE}
   187    188     do_test capi3-3.6.2-misuse {
   188    189       sqlite3_errmsg $db2
   189    190     } {library routine called out of sequence}