/ Check-in [e7073e23]
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:Add some 'const' markers to static data that is really constant.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e7073e23b80e7cae0c76d42f014ee9b2d40a8f2f
User & Date: dan 2010-06-02 05:53:53
Context
2010-06-02
12:58
Undo one of the "const" markers from the previous check-in because the value needs to be changable, even if it is not actually ever changed in the current implementation. check-in: c24ac356 user: drh tags: trunk
05:53
Add some 'const' markers to static data that is really constant. check-in: e7073e23 user: dan tags: trunk
2010-06-01
21:02
The shared-memory used by WAL on linux now really is shared memory in /dev/shm. On other unix flavors, the file is in a temporary directory rather than in the same directory as the database. check-in: fc18c4aa user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/analyze.c.

    32     32   */
    33     33   static void openStatTable(
    34     34     Parse *pParse,          /* Parsing context */
    35     35     int iDb,                /* The database we are looking in */
    36     36     int iStatCur,           /* Open the sqlite_stat1 table on this cursor */
    37     37     const char *zWhere      /* Delete entries associated with this table */
    38     38   ){
    39         -  static struct {
           39  +  static const struct {
    40     40       const char *zName;
    41     41       const char *zCols;
    42     42     } aTable[] = {
    43     43       { "sqlite_stat1", "tbl,idx,stat" },
    44     44   #ifdef SQLITE_ENABLE_STAT2
    45     45       { "sqlite_stat2", "tbl,idx,sampleno,sample" },
    46     46   #endif

Changes to src/attach.c.

   285    285   /*
   286    286   ** This procedure generates VDBE code for a single invocation of either the
   287    287   ** sqlite_detach() or sqlite_attach() SQL user functions.
   288    288   */
   289    289   static void codeAttach(
   290    290     Parse *pParse,       /* The parser context */
   291    291     int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */
   292         -  FuncDef *pFunc,      /* FuncDef wrapper for detachFunc() or attachFunc() */
          292  +  FuncDef const *pFunc,/* FuncDef wrapper for detachFunc() or attachFunc() */
   293    293     Expr *pAuthArg,      /* Expression to pass to authorization callback */
   294    294     Expr *pFilename,     /* Name of database file */
   295    295     Expr *pDbname,       /* Name of the database to use internally */
   296    296     Expr *pKey           /* Database key for encryption extension */
   297    297   ){
   298    298     int rc;
   299    299     NameContext sName;
................................................................................
   366    366   
   367    367   /*
   368    368   ** Called by the parser to compile a DETACH statement.
   369    369   **
   370    370   **     DETACH pDbname
   371    371   */
   372    372   void sqlite3Detach(Parse *pParse, Expr *pDbname){
   373         -  static FuncDef detach_func = {
          373  +  static const FuncDef detach_func = {
   374    374       1,                /* nArg */
   375    375       SQLITE_UTF8,      /* iPrefEnc */
   376    376       0,                /* flags */
   377    377       0,                /* pUserData */
   378    378       0,                /* pNext */
   379    379       detachFunc,       /* xFunc */
   380    380       0,                /* xStep */
................................................................................
   387    387   
   388    388   /*
   389    389   ** Called by the parser to compile an ATTACH statement.
   390    390   **
   391    391   **     ATTACH p AS pDbname KEY pKey
   392    392   */
   393    393   void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){
   394         -  static FuncDef attach_func = {
          394  +  static const FuncDef attach_func = {
   395    395       3,                /* nArg */
   396    396       SQLITE_UTF8,      /* iPrefEnc */
   397    397       0,                /* flags */
   398    398       0,                /* pUserData */
   399    399       0,                /* pNext */
   400    400       attachFunc,       /* xFunc */
   401    401       0,                /* xStep */

Changes to src/build.c.

  3378   3378   ** release or rollback an SQL savepoint. 
  3379   3379   */
  3380   3380   void sqlite3Savepoint(Parse *pParse, int op, Token *pName){
  3381   3381     char *zName = sqlite3NameFromToken(pParse->db, pName);
  3382   3382     if( zName ){
  3383   3383       Vdbe *v = sqlite3GetVdbe(pParse);
  3384   3384   #ifndef SQLITE_OMIT_AUTHORIZATION
  3385         -    static const char *az[] = { "BEGIN", "RELEASE", "ROLLBACK" };
         3385  +    static const char * const az[] = { "BEGIN", "RELEASE", "ROLLBACK" };
  3386   3386       assert( !SAVEPOINT_BEGIN && SAVEPOINT_RELEASE==1 && SAVEPOINT_ROLLBACK==2 );
  3387   3387   #endif
  3388   3388       if( !v || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName, 0) ){
  3389   3389         sqlite3DbFree(pParse->db, zName);
  3390   3390         return;
  3391   3391       }
  3392   3392       sqlite3VdbeAddOp4(v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC);

Changes to src/memjournal.c.

   209    209     *pSize = (sqlite_int64) p->endpoint.iOffset;
   210    210     return SQLITE_OK;
   211    211   }
   212    212   
   213    213   /*
   214    214   ** Table of methods for MemJournal sqlite3_file object.
   215    215   */
   216         -static struct sqlite3_io_methods MemJournalMethods = {
          216  +static const struct sqlite3_io_methods MemJournalMethods = {
   217    217     1,                /* iVersion */
   218    218     memjrnlClose,     /* xClose */
   219    219     memjrnlRead,      /* xRead */
   220    220     memjrnlWrite,     /* xWrite */
   221    221     memjrnlTruncate,  /* xTruncate */
   222    222     memjrnlSync,      /* xSync */
   223    223     memjrnlFileSize,  /* xFileSize */

Changes to src/mutex.c.

    33     33     int rc = SQLITE_OK;
    34     34     if( !sqlite3GlobalConfig.mutex.xMutexAlloc ){
    35     35       /* If the xMutexAlloc method has not been set, then the user did not
    36     36       ** install a mutex implementation via sqlite3_config() prior to 
    37     37       ** sqlite3_initialize() being called. This block copies pointers to
    38     38       ** the default implementation into the sqlite3GlobalConfig structure.
    39     39       */
    40         -    sqlite3_mutex_methods *pFrom;
           40  +    sqlite3_mutex_methods const *pFrom;
    41     41       sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex;
    42     42   
    43     43       if( sqlite3GlobalConfig.bCoreMutex ){
    44     44         pFrom = sqlite3DefaultMutex();
    45     45       }else{
    46     46         pFrom = sqlite3NoopMutex();
    47     47       }

Changes to src/mutex_noop.c.

    39     39   static int noopMutexEnd(void){ return SQLITE_OK; }
    40     40   static sqlite3_mutex *noopMutexAlloc(int id){ return (sqlite3_mutex*)8; }
    41     41   static void noopMutexFree(sqlite3_mutex *p){ return; }
    42     42   static void noopMutexEnter(sqlite3_mutex *p){ return; }
    43     43   static int noopMutexTry(sqlite3_mutex *p){ return SQLITE_OK; }
    44     44   static void noopMutexLeave(sqlite3_mutex *p){ return; }
    45     45   
    46         -sqlite3_mutex_methods *sqlite3NoopMutex(void){
    47         -  static sqlite3_mutex_methods sMutex = {
           46  +sqlite3_mutex_methods const *sqlite3NoopMutex(void){
           47  +  static const sqlite3_mutex_methods sMutex = {
    48     48       noopMutexInit,
    49     49       noopMutexEnd,
    50     50       noopMutexAlloc,
    51     51       noopMutexFree,
    52     52       noopMutexEnter,
    53     53       noopMutexTry,
    54     54       noopMutexLeave,
................................................................................
   166    166   static void debugMutexLeave(sqlite3_mutex *pX){
   167    167     sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
   168    168     assert( debugMutexHeld(pX) );
   169    169     p->cnt--;
   170    170     assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );
   171    171   }
   172    172   
   173         -sqlite3_mutex_methods *sqlite3NoopMutex(void){
   174         -  static sqlite3_mutex_methods sMutex = {
          173  +sqlite3_mutex_methods const *sqlite3NoopMutex(void){
          174  +  static const sqlite3_mutex_methods sMutex = {
   175    175       debugMutexInit,
   176    176       debugMutexEnd,
   177    177       debugMutexAlloc,
   178    178       debugMutexFree,
   179    179       debugMutexEnter,
   180    180       debugMutexTry,
   181    181       debugMutexLeave,
................................................................................
   189    189   #endif /* SQLITE_DEBUG */
   190    190   
   191    191   /*
   192    192   ** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation
   193    193   ** is used regardless of the run-time threadsafety setting.
   194    194   */
   195    195   #ifdef SQLITE_MUTEX_NOOP
   196         -sqlite3_mutex_methods *sqlite3DefaultMutex(void){
          196  +sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
   197    197     return sqliteNoopMutex();
   198    198   }
   199    199   #endif /* SQLITE_MUTEX_NOOP */
   200    200   #endif /* SQLITE_MUTEX_OMIT */

Changes to src/mutex_os2.c.

   247    247     DosQueryMutexSem(p->mutex, &holder1, &tid, &holder2);
   248    248     assert( p->owner==tid );
   249    249     p->nRef--;
   250    250     assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
   251    251     DosReleaseMutexSem(p->mutex);
   252    252   }
   253    253   
   254         -sqlite3_mutex_methods *sqlite3DefaultMutex(void){
   255         -  static sqlite3_mutex_methods sMutex = {
          254  +sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
          255  +  static const sqlite3_mutex_methods sMutex = {
   256    256       os2MutexInit,
   257    257       os2MutexEnd,
   258    258       os2MutexAlloc,
   259    259       os2MutexFree,
   260    260       os2MutexEnter,
   261    261       os2MutexTry,
   262    262       os2MutexLeave,

Changes to src/mutex_unix.c.

   321    321   #ifdef SQLITE_DEBUG
   322    322     if( p->trace ){
   323    323       printf("leave mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
   324    324     }
   325    325   #endif
   326    326   }
   327    327   
   328         -sqlite3_mutex_methods *sqlite3DefaultMutex(void){
   329         -  static sqlite3_mutex_methods sMutex = {
          328  +sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
          329  +  static const sqlite3_mutex_methods sMutex = {
   330    330       pthreadMutexInit,
   331    331       pthreadMutexEnd,
   332    332       pthreadMutexAlloc,
   333    333       pthreadMutexFree,
   334    334       pthreadMutexEnter,
   335    335       pthreadMutexTry,
   336    336       pthreadMutexLeave,

Changes to src/mutex_w32.c.

   303    303   #ifdef SQLITE_DEBUG
   304    304     if( p->trace ){
   305    305       printf("leave mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
   306    306     }
   307    307   #endif
   308    308   }
   309    309   
   310         -sqlite3_mutex_methods *sqlite3DefaultMutex(void){
   311         -  static sqlite3_mutex_methods sMutex = {
          310  +sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
          311  +  static const sqlite3_mutex_methods sMutex = {
   312    312       winMutexInit,
   313    313       winMutexEnd,
   314    314       winMutexAlloc,
   315    315       winMutexFree,
   316    316       winMutexEnter,
   317    317       winMutexTry,
   318    318       winMutexLeave,

Changes to src/pcache1.c.

   712    712   
   713    713   /*
   714    714   ** This function is called during initialization (sqlite3_initialize()) to
   715    715   ** install the default pluggable cache module, assuming the user has not
   716    716   ** already provided an alternative.
   717    717   */
   718    718   void sqlite3PCacheSetDefault(void){
   719         -  static sqlite3_pcache_methods defaultMethods = {
          719  +  static const sqlite3_pcache_methods defaultMethods = {
   720    720       0,                       /* pArg */
   721    721       pcache1Init,             /* xInit */
   722    722       pcache1Shutdown,         /* xShutdown */
   723    723       pcache1Create,           /* xCreate */
   724    724       pcache1Cachesize,        /* xCachesize */
   725    725       pcache1Pagecount,        /* xPagecount */
   726    726       pcache1Fetch,            /* xFetch */

Changes to src/sqliteInt.h.

  2532   2532   #endif
  2533   2533   #ifdef SQLITE_ENABLE_MEMSYS5
  2534   2534   const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
  2535   2535   #endif
  2536   2536   
  2537   2537   
  2538   2538   #ifndef SQLITE_MUTEX_OMIT
  2539         -  sqlite3_mutex_methods *sqlite3DefaultMutex(void);
  2540         -  sqlite3_mutex_methods *sqlite3NoopMutex(void);
         2539  +  sqlite3_mutex_methods const *sqlite3DefaultMutex(void);
         2540  +  sqlite3_mutex_methods const *sqlite3NoopMutex(void);
  2541   2541     sqlite3_mutex *sqlite3MutexAlloc(int);
  2542   2542     int sqlite3MutexInit(void);
  2543   2543     int sqlite3MutexEnd(void);
  2544   2544   #endif
  2545   2545   
  2546   2546   int sqlite3StatusValue(int);
  2547   2547   void sqlite3StatusAdd(int, int);