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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 95275bb3708e2274079be8b0070b3d36c205c265
User & Date: dan 2013-05-09 19:47:49.124
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
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
336
337
338
339
340
341
342
343
344
345
346

347
348
349
350
351
352
353
    }
  }
}

/*
** Close an existing SQLite database
*/
int sqlite4_close(sqlite4 *db){
  HashElem *i;                    /* Hash table iterator */
  int j;


  if( !db ){
    return SQLITE4_OK;
  }
  if( !sqlite4SafetyCheckSickOrOk(db) ){
    return SQLITE4_MISUSE_BKPT;
  }
  sqlite4_mutex_enter(db->mutex);







|



>







336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
    }
  }
}

/*
** Close an existing SQLite database
*/
int sqlite4_close(sqlite4 *db, unsigned int flags){
  HashElem *i;                    /* Hash table iterator */
  int j;

  UNUSED_PARAMETER(flags);
  if( !db ){
    return SQLITE4_OK;
  }
  if( !sqlite4SafetyCheckSickOrOk(db) ){
    return SQLITE4_MISUSE_BKPT;
  }
  sqlite4_mutex_enter(db->mutex);
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
  if( db ){
    assert( db->mutex!=0 || isThreadsafe==0 || pEnv->bFullMutex==0 );
    sqlite4_mutex_leave(db->mutex);
  }
  rc = sqlite4_errcode(db);
  assert( db!=0 || rc==SQLITE4_NOMEM );
  if( rc==SQLITE4_NOMEM ){
    sqlite4_close(db);
    db = 0;
  }else if( rc!=SQLITE4_OK ){
    db->magic = SQLITE4_MAGIC_SICK;
  }
  *ppDb = db;
  return sqlite4ApiExit(0, rc);
}







|







1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
  if( db ){
    assert( db->mutex!=0 || isThreadsafe==0 || pEnv->bFullMutex==0 );
    sqlite4_mutex_leave(db->mutex);
  }
  rc = sqlite4_errcode(db);
  assert( db!=0 || rc==SQLITE4_NOMEM );
  if( rc==SQLITE4_NOMEM ){
    sqlite4_close(db, 0);
    db = 0;
  }else if( rc!=SQLITE4_OK ){
    db->magic = SQLITE4_MAGIC_SICK;
  }
  *ppDb = db;
  return sqlite4ApiExit(0, rc);
}
Changes to src/shell.c.
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
      }
    }else{
      rc = process_input(&data, stdin);
    }
  }
  set_table_name(&data, 0);
  if( data.db ){
    sqlite4_close(data.db);
  }
  return rc;
}







|



2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
      }
    }else{
      rc = process_input(&data, stdin);
    }
  }
  set_table_name(&data, 0);
  if( data.db ){
    sqlite4_close(data.db, 0);
  }
  return rc;
}
Changes to src/sqlite.h.in.
415
416
417
418
419
420
421
422
423
424
425
426



427
428
429
430
431
432
433
434
435
** sqlite4_close() is called on a [database connection] that still has
** outstanding [prepared statements] or [BLOB handles], then it returns
** SQLITE4_BUSY.
**
** ^If [sqlite4_close()] is invoked while a transaction is open,
** the transaction is automatically rolled back.
**
** The C parameter to [sqlite4_close(C)] must be either a NULL
** pointer or an [sqlite4] object pointer obtained
** from [sqlite4_open()] and not previously closed.
** ^Calling sqlite4_close() with a NULL pointer argument is a 
** harmless no-op.



*/
int sqlite4_close(sqlite4 *);

/*
** The type for a callback function.
** This is legacy and deprecated.  It is included for historical
** compatibility and is not documented.
*/
typedef int (*sqlite4_callback)(void*,int,char**, char**);







|




>
>
>

|







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

/*
** The type for a callback function.
** This is legacy and deprecated.  It is included for historical
** compatibility and is not documented.
*/
typedef int (*sqlite4_callback)(void*,int,char**, char**);
Changes to src/tclsqlite.c.
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
** TCL calls this procedure when an sqlite4 database command is
** deleted.
*/
static void DbDeleteCmd(void *db){
  SqliteDb *pDb = (SqliteDb*)db;
  flushStmtCache(pDb);
  sqlite4_close(pDb->db);
  while( pDb->pFunc ){
    SqlFunc *pFunc = pDb->pFunc;
    pDb->pFunc = pFunc->pNext;
    Tcl_DecrRefCount(pFunc->pScript);
    Tcl_Free((char*)pFunc);
  }
  while( pDb->pCollate ){







|







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







|







2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
  memset(p, 0, sizeof(*p));
  zFile = Tcl_GetStringFromObj(objv[2], 0);
  zFile = Tcl_TranslateFileName(interp, zFile, &translatedFilename);
  sqlite4_open(0, zFile, &p->db, 0);
  Tcl_DStringFree(&translatedFilename);
  if( SQLITE4_OK!=sqlite4_errcode(p->db) ){
    zErrMsg = sqlite4_mprintf(0, "%s", sqlite4_errmsg(p->db));
    sqlite4_close(p->db, 0);
    p->db = 0;
  }
#ifdef SQLITE4_TEST
  else{
    extern int sqlite4test_install_test_functions(sqlite4*);
    sqlite4test_install_test_functions(p->db);
  }
Changes to test/test_main.c.
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
  int rc;
  if( argc!=2 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
       " FILENAME\"", 0);
    return TCL_ERROR;
  }
  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
  rc = sqlite4_close(db);
  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
  return TCL_OK;
}

/*
** Implementation of the x_coalesce() function.
** Return the first argument non-NULL argument.







|







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

/*
** Implementation of the x_coalesce() function.
** Return the first argument non-NULL argument.
Changes to test/test_misc1.c.
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  if( rc!=SQLITE4_OK ){
    zErrFunction = "sqlite4_open";
    goto error_out;
  }

  rc = sqlite4_create_collation(db, "collate", 456, 0, 0, 0, 0);
  if( rc!=SQLITE4_MISUSE ){
    sqlite4_close(db);
    zErrFunction = "sqlite4_create_collation";
    goto error_out;
  }

  sqlite4_close(db);
  return TCL_OK;

error_out:
  Tcl_ResetResult(interp);
  Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0);
  return TCL_ERROR;
}







|




|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  if( rc!=SQLITE4_OK ){
    zErrFunction = "sqlite4_open";
    goto error_out;
  }

  rc = sqlite4_create_collation(db, "collate", 456, 0, 0, 0, 0);
  if( rc!=SQLITE4_MISUSE ){
    sqlite4_close(db, 0);
    zErrFunction = "sqlite4_create_collation";
    goto error_out;
  }

  sqlite4_close(db, 0);
  return TCL_OK;

error_out:
  Tcl_ResetResult(interp);
  Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0);
  return TCL_ERROR;
}
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
  ** we have a "closed database handle" to pass to various API functions.
  */
  rc = sqlite4_open(0, ":memory:", &db, 0);
  if( rc!=SQLITE4_OK ){
    zErrFunction = "sqlite4_open";
    goto error_out;
  }
  sqlite4_close(db);


  rc = sqlite4_errcode(db);
  if( rc!=SQLITE4_MISUSE ){
    zErrFunction = "sqlite4_errcode";
    goto error_out;
  }







|







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
  ** we have a "closed database handle" to pass to various API functions.
  */
  rc = sqlite4_open(0, ":memory:", &db, 0);
  if( rc!=SQLITE4_OK ){
    zErrFunction = "sqlite4_open";
    goto error_out;
  }
  sqlite4_close(db, 0);


  rc = sqlite4_errcode(db);
  if( rc!=SQLITE4_MISUSE ){
    zErrFunction = "sqlite4_errcode";
    goto error_out;
  }
Changes to test/test_thread0.c.
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

/*
** The main loop for a thread.  Threads use busy waiting. 
*/
static void *thread_main(void *pArg){
  Thread *p = (Thread*)pArg;
  if( p->db ){
    sqlite4_close(p->db);
  }
  sqlite4_open(0, p->zFilename, &p->db, 0);
  if( SQLITE4_OK!=sqlite4_errcode(p->db) ){
    p->zErr = strdup(sqlite4_errmsg(p->db));
    sqlite4_close(p->db);
    p->db = 0;
  }
  p->pStmt = 0;
  p->completed = 1;
  while( p->opnum<=p->completed ) sched_yield();
  while( p->xOp ){
    if( p->zErr && p->zErr!=p->zStaticErr ){
      sqlite4_free(0, p->zErr);
      p->zErr = 0;
    }
    (*p->xOp)(p);
    p->completed++;
    while( p->opnum<=p->completed ) sched_yield();
  }
  if( p->pStmt ){
    sqlite4_finalize(p->pStmt);
    p->pStmt = 0;
  }
  if( p->db ){
    sqlite4_close(p->db);
    p->db = 0;
  }
  if( p->zErr && p->zErr!=p->zStaticErr ){
    sqlite4_free(0, p->zErr);
    p->zErr = 0;
  }
  p->completed++;







|




|



















|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

/*
** The main loop for a thread.  Threads use busy waiting. 
*/
static void *thread_main(void *pArg){
  Thread *p = (Thread*)pArg;
  if( p->db ){
    sqlite4_close(p->db, 0);
  }
  sqlite4_open(0, p->zFilename, &p->db, 0);
  if( SQLITE4_OK!=sqlite4_errcode(p->db) ){
    p->zErr = strdup(sqlite4_errmsg(p->db));
    sqlite4_close(p->db, 0);
    p->db = 0;
  }
  p->pStmt = 0;
  p->completed = 1;
  while( p->opnum<=p->completed ) sched_yield();
  while( p->xOp ){
    if( p->zErr && p->zErr!=p->zStaticErr ){
      sqlite4_free(0, p->zErr);
      p->zErr = 0;
    }
    (*p->xOp)(p);
    p->completed++;
    while( p->opnum<=p->completed ) sched_yield();
  }
  if( p->pStmt ){
    sqlite4_finalize(p->pStmt);
    p->pStmt = 0;
  }
  if( p->db ){
    sqlite4_close(p->db, 0);
    p->db = 0;
  }
  if( p->zErr && p->zErr!=p->zStaticErr ){
    sqlite4_free(0, p->zErr);
    p->zErr = 0;
  }
  p->completed++;