SQLite4
Check-in [95275bb370]
Not logged in

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

Overview
Comment:Add an "unsigned int flags" parameter to sqlite4_close(). Currently unused.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 95275bb3708e2274079be8b0070b3d36c205c265
User & Date: dan 2013-05-09 19:47:49
Context
2013-05-10
18:42
Change the sqlite4_exec() function to pass protected sqlite4_value objects to the callback instead of an array of nul-terminated strings. check-in: bbf3a54dcf user: dan tags: trunk
2013-05-09
19:47
Add an "unsigned int flags" parameter to sqlite4_close(). Currently unused. check-in: 95275bb370 user: dan tags: trunk
19:12
Add a destructor parameter to sqlite4_create_function() and create_function16(). Remove create_function_v2(). check-in: b7612a4adb user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

   336    336       }
   337    337     }
   338    338   }
   339    339   
   340    340   /*
   341    341   ** Close an existing SQLite database
   342    342   */
   343         -int sqlite4_close(sqlite4 *db){
          343  +int sqlite4_close(sqlite4 *db, unsigned int flags){
   344    344     HashElem *i;                    /* Hash table iterator */
   345    345     int j;
   346    346   
          347  +  UNUSED_PARAMETER(flags);
   347    348     if( !db ){
   348    349       return SQLITE4_OK;
   349    350     }
   350    351     if( !sqlite4SafetyCheckSickOrOk(db) ){
   351    352       return SQLITE4_MISUSE_BKPT;
   352    353     }
   353    354     sqlite4_mutex_enter(db->mutex);
................................................................................
  1469   1470     if( db ){
  1470   1471       assert( db->mutex!=0 || isThreadsafe==0 || pEnv->bFullMutex==0 );
  1471   1472       sqlite4_mutex_leave(db->mutex);
  1472   1473     }
  1473   1474     rc = sqlite4_errcode(db);
  1474   1475     assert( db!=0 || rc==SQLITE4_NOMEM );
  1475   1476     if( rc==SQLITE4_NOMEM ){
  1476         -    sqlite4_close(db);
         1477  +    sqlite4_close(db, 0);
  1477   1478       db = 0;
  1478   1479     }else if( rc!=SQLITE4_OK ){
  1479   1480       db->magic = SQLITE4_MAGIC_SICK;
  1480   1481     }
  1481   1482     *ppDb = db;
  1482   1483     return sqlite4ApiExit(0, rc);
  1483   1484   }

Changes to src/shell.c.

  2931   2931         }
  2932   2932       }else{
  2933   2933         rc = process_input(&data, stdin);
  2934   2934       }
  2935   2935     }
  2936   2936     set_table_name(&data, 0);
  2937   2937     if( data.db ){
  2938         -    sqlite4_close(data.db);
         2938  +    sqlite4_close(data.db, 0);
  2939   2939     }
  2940   2940     return rc;
  2941   2941   }

Changes to src/sqlite.h.in.

   415    415   ** sqlite4_close() is called on a [database connection] that still has
   416    416   ** outstanding [prepared statements] or [BLOB handles], then it returns
   417    417   ** SQLITE4_BUSY.
   418    418   **
   419    419   ** ^If [sqlite4_close()] is invoked while a transaction is open,
   420    420   ** the transaction is automatically rolled back.
   421    421   **
   422         -** The C parameter to [sqlite4_close(C)] must be either a NULL
          422  +** The C parameter to [sqlite4_close(C,F)] must be either a NULL
   423    423   ** pointer or an [sqlite4] object pointer obtained
   424    424   ** from [sqlite4_open()] and not previously closed.
   425    425   ** ^Calling sqlite4_close() with a NULL pointer argument is a 
   426    426   ** harmless no-op.
          427  +**
          428  +** The second parameter passed to sqlite4_close() is currently unused. It
          429  +** is reserved for future functionality.
   427    430   */
   428         -int sqlite4_close(sqlite4 *);
          431  +int sqlite4_close(sqlite4 *, unsigned int flags);
   429    432   
   430    433   /*
   431    434   ** The type for a callback function.
   432    435   ** This is legacy and deprecated.  It is included for historical
   433    436   ** compatibility and is not documented.
   434    437   */
   435    438   typedef int (*sqlite4_callback)(void*,int,char**, char**);

Changes to src/tclsqlite.c.

   225    225   /*
   226    226   ** TCL calls this procedure when an sqlite4 database command is
   227    227   ** deleted.
   228    228   */
   229    229   static void DbDeleteCmd(void *db){
   230    230     SqliteDb *pDb = (SqliteDb*)db;
   231    231     flushStmtCache(pDb);
   232         -  sqlite4_close(pDb->db);
          232  +  sqlite4_close(pDb->db, 0);
   233    233     while( pDb->pFunc ){
   234    234       SqlFunc *pFunc = pDb->pFunc;
   235    235       pDb->pFunc = pFunc->pNext;
   236    236       Tcl_DecrRefCount(pFunc->pScript);
   237    237       Tcl_Free((char*)pFunc);
   238    238     }
   239    239     while( pDb->pCollate ){
................................................................................
  2222   2222     memset(p, 0, sizeof(*p));
  2223   2223     zFile = Tcl_GetStringFromObj(objv[2], 0);
  2224   2224     zFile = Tcl_TranslateFileName(interp, zFile, &translatedFilename);
  2225   2225     sqlite4_open(0, zFile, &p->db, 0);
  2226   2226     Tcl_DStringFree(&translatedFilename);
  2227   2227     if( SQLITE4_OK!=sqlite4_errcode(p->db) ){
  2228   2228       zErrMsg = sqlite4_mprintf(0, "%s", sqlite4_errmsg(p->db));
  2229         -    sqlite4_close(p->db);
         2229  +    sqlite4_close(p->db, 0);
  2230   2230       p->db = 0;
  2231   2231     }
  2232   2232   #ifdef SQLITE4_TEST
  2233   2233     else{
  2234   2234       extern int sqlite4test_install_test_functions(sqlite4*);
  2235   2235       sqlite4test_install_test_functions(p->db);
  2236   2236     }

Changes to test/test_main.c.

   648    648     int rc;
   649    649     if( argc!=2 ){
   650    650       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   651    651          " FILENAME\"", 0);
   652    652       return TCL_ERROR;
   653    653     }
   654    654     if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
   655         -  rc = sqlite4_close(db);
          655  +  rc = sqlite4_close(db, 0);
   656    656     Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
   657    657     return TCL_OK;
   658    658   }
   659    659   
   660    660   /*
   661    661   ** Implementation of the x_coalesce() function.
   662    662   ** Return the first argument non-NULL argument.

Changes to test/test_misc1.c.

    42     42     if( rc!=SQLITE4_OK ){
    43     43       zErrFunction = "sqlite4_open";
    44     44       goto error_out;
    45     45     }
    46     46   
    47     47     rc = sqlite4_create_collation(db, "collate", 456, 0, 0, 0, 0);
    48     48     if( rc!=SQLITE4_MISUSE ){
    49         -    sqlite4_close(db);
           49  +    sqlite4_close(db, 0);
    50     50       zErrFunction = "sqlite4_create_collation";
    51     51       goto error_out;
    52     52     }
    53     53   
    54         -  sqlite4_close(db);
           54  +  sqlite4_close(db, 0);
    55     55     return TCL_OK;
    56     56   
    57     57   error_out:
    58     58     Tcl_ResetResult(interp);
    59     59     Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0);
    60     60     return TCL_ERROR;
    61     61   }
................................................................................
   124    124     ** we have a "closed database handle" to pass to various API functions.
   125    125     */
   126    126     rc = sqlite4_open(0, ":memory:", &db, 0);
   127    127     if( rc!=SQLITE4_OK ){
   128    128       zErrFunction = "sqlite4_open";
   129    129       goto error_out;
   130    130     }
   131         -  sqlite4_close(db);
          131  +  sqlite4_close(db, 0);
   132    132   
   133    133   
   134    134     rc = sqlite4_errcode(db);
   135    135     if( rc!=SQLITE4_MISUSE ){
   136    136       zErrFunction = "sqlite4_errcode";
   137    137       goto error_out;
   138    138     }

Changes to test/test_thread0.c.

    57     57   
    58     58   /*
    59     59   ** The main loop for a thread.  Threads use busy waiting. 
    60     60   */
    61     61   static void *thread_main(void *pArg){
    62     62     Thread *p = (Thread*)pArg;
    63     63     if( p->db ){
    64         -    sqlite4_close(p->db);
           64  +    sqlite4_close(p->db, 0);
    65     65     }
    66     66     sqlite4_open(0, p->zFilename, &p->db, 0);
    67     67     if( SQLITE4_OK!=sqlite4_errcode(p->db) ){
    68     68       p->zErr = strdup(sqlite4_errmsg(p->db));
    69         -    sqlite4_close(p->db);
           69  +    sqlite4_close(p->db, 0);
    70     70       p->db = 0;
    71     71     }
    72     72     p->pStmt = 0;
    73     73     p->completed = 1;
    74     74     while( p->opnum<=p->completed ) sched_yield();
    75     75     while( p->xOp ){
    76     76       if( p->zErr && p->zErr!=p->zStaticErr ){
................................................................................
    82     82       while( p->opnum<=p->completed ) sched_yield();
    83     83     }
    84     84     if( p->pStmt ){
    85     85       sqlite4_finalize(p->pStmt);
    86     86       p->pStmt = 0;
    87     87     }
    88     88     if( p->db ){
    89         -    sqlite4_close(p->db);
           89  +    sqlite4_close(p->db, 0);
    90     90       p->db = 0;
    91     91     }
    92     92     if( p->zErr && p->zErr!=p->zStaticErr ){
    93     93       sqlite4_free(0, p->zErr);
    94     94       p->zErr = 0;
    95     95     }
    96     96     p->completed++;