/ Check-in [c433672d]
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:Fix sqlite3rbu_close() so that the pzErrmsg parameter may be passed NULL.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c433672dd8ab625628bde2f4f40a2dc000ed915dbe91833d3f753d8ab51baf25
User & Date: dan 2017-06-13 16:52:34
Context
2017-06-15
00:52
Enhance the sqlite3_analyzer.exe utility so that it computes and shows the number of bytes of metadata on btree pages and per table and index entry. check-in: 43ad41ef user: drh tags: trunk
2017-06-13
16:52
Fix sqlite3rbu_close() so that the pzErrmsg parameter may be passed NULL. check-in: c433672d user: dan tags: trunk
04:31
Fix the processing of double-negatives in WHERE clause constraints with STAT4. Ticket [cfa2c908f2182] check-in: 35b34bdf user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rbu/rbuvacuum.test.

   294    294     sqlite3rbu_vacuum rbu test.db state.db
   295    295     rbu step
   296    296   } {SQLITE_ERROR}
   297    297   do_test 2.1.2 {
   298    298     list [catch { rbu close } msg] $msg
   299    299   } {1 {SQLITE_ERROR - cannot vacuum wal mode database}}
   300    300   
          301  +do_test 2.1.3 {
          302  +  sqlite3rbu_vacuum rbu test.db state.db
          303  +  rbu step
          304  +} {SQLITE_ERROR}
          305  +do_test 2.1.4 {
          306  +  list [catch { rbu close_no_error } msg] $msg
          307  +} {1 SQLITE_ERROR}
          308  +
   301    309   reset_db
   302    310   do_execsql_test 2.2.0 {
   303    311     CREATE TABLE tx(a PRIMARY KEY, b BLOB);
   304    312     INSERT INTO tx VALUES(1, randomblob(900));
   305    313     INSERT INTO tx SELECT a+1, randomblob(900) FROM tx;
   306    314     INSERT INTO tx SELECT a+2, randomblob(900) FROM tx;
   307    315     INSERT INTO tx SELECT a+4, randomblob(900) FROM tx;

Changes to ext/rbu/sqlite3rbu.c.

  3783   3783       sqlite3_close(p->dbMain);
  3784   3784       rbuDeleteVfs(p);
  3785   3785       sqlite3_free(p->aBuf);
  3786   3786       sqlite3_free(p->aFrame);
  3787   3787   
  3788   3788       rbuEditErrmsg(p);
  3789   3789       rc = p->rc;
  3790         -    *pzErrmsg = p->zErrmsg;
         3790  +    if( pzErrmsg ){
         3791  +      *pzErrmsg = p->zErrmsg;
         3792  +    }else{
         3793  +      sqlite3_free(p->zErrmsg);
         3794  +    }
  3791   3795       sqlite3_free(p->zState);
  3792   3796       sqlite3_free(p);
  3793   3797     }else{
  3794   3798       rc = SQLITE_NOMEM;
  3795   3799       *pzErrmsg = 0;
  3796   3800     }
  3797   3801     return rc;

Changes to ext/rbu/sqlite3rbu.h.

   416    416   **
   417    417   ** If the RBU update has been completely applied, mark the RBU database
   418    418   ** as fully applied. Otherwise, assuming no error has occurred, save the
   419    419   ** current state of the RBU update appliation to the RBU database.
   420    420   **
   421    421   ** If an error has already occurred as part of an sqlite3rbu_step()
   422    422   ** or sqlite3rbu_open() call, or if one occurs within this function, an
   423         -** SQLite error code is returned. Additionally, *pzErrmsg may be set to
   424         -** point to a buffer containing a utf-8 formatted English language error
   425         -** message. It is the responsibility of the caller to eventually free any 
   426         -** such buffer using sqlite3_free().
          423  +** SQLite error code is returned. Additionally, if pzErrmsg is not NULL,
          424  +** *pzErrmsg may be set to point to a buffer containing a utf-8 formatted
          425  +** English language error message. It is the responsibility of the caller to
          426  +** eventually free any such buffer using sqlite3_free().
   427    427   **
   428    428   ** Otherwise, if no error occurs, this function returns SQLITE_OK if the
   429    429   ** update has been partially applied, or SQLITE_DONE if it has been 
   430    430   ** completely applied.
   431    431   */
   432    432   int sqlite3rbu_close(sqlite3rbu *pRbu, char **pzErrmsg);
   433    433   

Changes to ext/rbu/test_rbu.c.

    74     74       {"create_rbu_delta", 2, ""},  /* 2 */
    75     75       {"savestate", 2, ""},         /* 3 */
    76     76       {"dbMain_eval", 3, "SQL"},    /* 4 */
    77     77       {"bp_progress", 2, ""},       /* 5 */
    78     78       {"db", 3, "RBU"},             /* 6 */
    79     79       {"state", 2, ""},             /* 7 */
    80     80       {"progress", 2, ""},          /* 8 */
           81  +    {"close_no_error", 2, ""},    /* 9 */
    81     82       {0,0,0}
    82     83     };
    83     84     int iCmd;
    84     85   
    85     86     if( objc<2 ){
    86     87       Tcl_WrongNumArgs(interp, 1, objv, "METHOD");
    87     88       return TCL_ERROR;
................................................................................
    98     99     switch( iCmd ){
    99    100       case 0: /* step */ {
   100    101         int rc = sqlite3rbu_step(pRbu);
   101    102         Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
   102    103         break;
   103    104       }
   104    105   
          106  +    case 9: /* close_no_error */ 
   105    107       case 1: /* close */ {
   106    108         char *zErrmsg = 0;
   107    109         int rc;
   108    110         Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
   109         -      rc = sqlite3rbu_close(pRbu, &zErrmsg);
          111  +      if( iCmd==1 ){
          112  +        rc = sqlite3rbu_close(pRbu, &zErrmsg);
          113  +      }else{
          114  +        rc = sqlite3rbu_close(pRbu, 0);
          115  +      }
   110    116         if( rc==SQLITE_OK || rc==SQLITE_DONE ){
   111    117           Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
   112    118           assert( zErrmsg==0 );
   113    119         }else{
   114    120           Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
   115    121           if( zErrmsg ){
   116    122             Tcl_AppendResult(interp, " - ", zErrmsg, 0);