/ Check-in [14e6d19c]
Login

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

Overview
Comment:More explicit type casting to silence VC++. (CVS 6006)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 14e6d19c3157ccdce170e769d678c7f472dd3db2
User & Date: drh 2008-12-10 18:03:46
Context
2008-12-10
19:26
Never use strlen(). Use our own internal sqlite3Strlen30() which is guaranteed to never overflow an integer. Additional explicit casts to avoid nuisance warning messages. (CVS 6007) check-in: c872d554 user: drh tags: trunk
18:03
More explicit type casting to silence VC++. (CVS 6006) check-in: 14e6d19c user: drh tags: trunk
17:20
Remove or rename local variables that shadow other variables or parameters. (CVS 6005) check-in: e7e9fa4f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.264 2008/12/08 16:01:13 drh Exp $
           17  +** @(#) $Id: parse.y,v 1.265 2008/12/10 18:03:46 drh Exp $
    18     18   */
    19     19   
    20     20   // All token codes are small integers with #defines that begin with "TK_"
    21     21   %token_prefix TK_
    22     22   
    23     23   // The type of the data attached to each token is Token.  This is also the
    24     24   // default type for non-terminals.
................................................................................
   145    145   // A "column" is a complete description of a single column in a
   146    146   // CREATE TABLE statement.  This includes the column name, its
   147    147   // datatype, and other keywords such as PRIMARY KEY, UNIQUE, REFERENCES,
   148    148   // NOT NULL and so forth.
   149    149   //
   150    150   column(A) ::= columnid(X) type carglist. {
   151    151     A.z = X.z;
   152         -  A.n = (pParse->sLastToken.z-X.z) + pParse->sLastToken.n;
          152  +  A.n = (int)(pParse->sLastToken.z-X.z) + pParse->sLastToken.n;
   153    153   }
   154    154   columnid(A) ::= nm(X). {
   155    155     sqlite3AddColumn(pParse,&X);
   156    156     A = X;
   157    157   }
   158    158   
   159    159   
................................................................................
   222    222   //
   223    223   %type typetoken {Token}
   224    224   type ::= .
   225    225   type ::= typetoken(X).                   {sqlite3AddColumnType(pParse,&X);}
   226    226   typetoken(A) ::= typename(X).   {A = X;}
   227    227   typetoken(A) ::= typename(X) LP signed RP(Y). {
   228    228     A.z = X.z;
   229         -  A.n = &Y.z[Y.n] - X.z;
          229  +  A.n = (int)(&Y.z[Y.n] - X.z);
   230    230   }
   231    231   typetoken(A) ::= typename(X) LP signed COMMA signed RP(Y). {
   232    232     A.z = X.z;
   233         -  A.n = &Y.z[Y.n] - X.z;
          233  +  A.n = (int)(&Y.z[Y.n] - X.z);
   234    234   }
   235    235   %type typename {Token}
   236    236   typename(A) ::= ids(X).             {A = X;}
   237         -typename(A) ::= typename(X) ids(Y). {A.z=X.z; A.n=Y.n+(Y.z-X.z);}
          237  +typename(A) ::= typename(X) ids(Y). {A.z=X.z; A.n=Y.n+(int)(Y.z-X.z);}
   238    238   signed ::= plus_num.
   239    239   signed ::= minus_num.
   240    240   
   241    241   // "carglist" is a list of additional constraints that come after the
   242    242   // column name and column type in a CREATE TABLE statement.
   243    243   //
   244    244   carglist ::= carglist carg.
................................................................................
   373    373   %type oneselect {Select*}
   374    374   %destructor oneselect {sqlite3SelectDelete(pParse->db, $$);}
   375    375   
   376    376   select(A) ::= oneselect(X).                      {A = X;}
   377    377   %ifndef SQLITE_OMIT_COMPOUND_SELECT
   378    378   select(A) ::= select(X) multiselect_op(Y) oneselect(Z).  {
   379    379     if( Z ){
   380         -    Z->op = Y;
          380  +    Z->op = (u8)Y;
   381    381       Z->pPrior = X;
   382    382     }else{
   383    383       sqlite3SelectDelete(pParse->db, X);
   384    384     }
   385    385     A = Z;
   386    386   }
   387    387   %type multiselect_op {int}
................................................................................
   452    452   }
   453    453   
   454    454   // "seltablist" is a "Select Table List" - the content of the FROM clause
   455    455   // in a SELECT statement.  "stl_prefix" is a prefix of this list.
   456    456   //
   457    457   stl_prefix(A) ::= seltablist(X) joinop(Y).    {
   458    458      A = X;
   459         -   if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = Y;
          459  +   if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = (u8)Y;
   460    460   }
   461    461   stl_prefix(A) ::= .                           {A = 0;}
   462    462   seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) indexed_opt(I) on_opt(N) using_opt(U). {
   463    463     A = sqlite3SrcListAppendFromTerm(pParse,X,&Y,&D,&Z,0,N,U);
   464    464     sqlite3SrcListIndexedBy(pParse, A, &I);
   465    465   }
   466    466   %ifndef SQLITE_OMIT_SUBQUERY
................................................................................
   542    542   %type sortitem {Expr*}
   543    543   %destructor sortitem {sqlite3ExprDelete(pParse->db, $$);}
   544    544   
   545    545   orderby_opt(A) ::= .                          {A = 0;}
   546    546   orderby_opt(A) ::= ORDER BY sortlist(X).      {A = X;}
   547    547   sortlist(A) ::= sortlist(X) COMMA sortitem(Y) sortorder(Z). {
   548    548     A = sqlite3ExprListAppend(pParse,X,Y,0);
   549         -  if( A ) A->a[A->nExpr-1].sortOrder = Z;
          549  +  if( A ) A->a[A->nExpr-1].sortOrder = (u8)Z;
   550    550   }
   551    551   sortlist(A) ::= sortitem(Y) sortorder(Z). {
   552    552     A = sqlite3ExprListAppend(pParse,0,Y,0);
   553         -  if( A && A->a ) A->a[0].sortOrder = Z;
          553  +  if( A && A->a ) A->a[0].sortOrder = (u8)Z;
   554    554   }
   555    555   sortitem(A) ::= expr(X).   {A = X;}
   556    556   
   557    557   %type sortorder {int}
   558    558   
   559    559   sortorder(A) ::= ASC.           {A = SQLITE_SO_ASC;}
   560    560   sortorder(A) ::= DESC.          {A = SQLITE_SO_DESC;}
................................................................................
   946    946     Expr *p = 0;
   947    947     if( C.n>0 ){
   948    948       p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
   949    949       sqlite3ExprSetColl(pParse, p, &C);
   950    950     }
   951    951     A = sqlite3ExprListAppend(pParse,X, p, &Y);
   952    952     sqlite3ExprListCheckLength(pParse, A, "index");
   953         -  if( A ) A->a[A->nExpr-1].sortOrder = Z;
          953  +  if( A ) A->a[A->nExpr-1].sortOrder = (u8)Z;
   954    954   }
   955    955   idxlist(A) ::= nm(Y) collate(C) sortorder(Z). {
   956    956     Expr *p = 0;
   957    957     if( C.n>0 ){
   958    958       p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
   959    959       sqlite3ExprSetColl(pParse, p, &C);
   960    960     }
   961    961     A = sqlite3ExprListAppend(pParse,0, p, &Y);
   962    962     sqlite3ExprListCheckLength(pParse, A, "index");
   963         -  if( A ) A->a[A->nExpr-1].sortOrder = Z;
          963  +  if( A ) A->a[A->nExpr-1].sortOrder = (u8)Z;
   964    964   }
   965    965   
   966    966   %type collate {Token}
   967    967   collate(C) ::= .                {C.z = 0; C.n = 0;}
   968    968   collate(C) ::= COLLATE ids(X).   {C = X;}
   969    969   
   970    970   
................................................................................
  1006   1006   //////////////////////////// The CREATE TRIGGER command /////////////////////
  1007   1007   
  1008   1008   %ifndef SQLITE_OMIT_TRIGGER
  1009   1009   
  1010   1010   cmd ::= CREATE trigger_decl(A) BEGIN trigger_cmd_list(S) END(Z). {
  1011   1011     Token all;
  1012   1012     all.z = A.z;
  1013         -  all.n = (Z.z - A.z) + Z.n;
         1013  +  all.n = (int)(Z.z - A.z) + Z.n;
  1014   1014     sqlite3FinishTrigger(pParse, S, &all);
  1015   1015   }
  1016   1016   
  1017   1017   trigger_decl(A) ::= temp(T) TRIGGER ifnotexists(NOERR) nm(B) dbnm(Z) 
  1018   1018                       trigger_time(C) trigger_event(D)
  1019   1019                       ON fullname(E) foreach_clause when_clause(G). {
  1020   1020     sqlite3BeginTrigger(pParse, &B, &Z, C, D.a, D.b, E, G, T, NOERR);

Changes to src/pcache1.c.

    12     12   **
    13     13   ** This file implements the default page cache implementation (the
    14     14   ** sqlite3_pcache interface). It also contains part of the implementation
    15     15   ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.
    16     16   ** If the default page cache implementation is overriden, then neither of
    17     17   ** these two features are available.
    18     18   **
    19         -** @(#) $Id: pcache1.c,v 1.5 2008/12/06 14:34:34 drh Exp $
           19  +** @(#) $Id: pcache1.c,v 1.6 2008/12/10 18:03:46 drh Exp $
    20     20   */
    21     21   
    22     22   #include "sqliteInt.h"
    23     23   
    24     24   typedef struct PCache1 PCache1;
    25     25   typedef struct PgHdr1 PgHdr1;
    26     26   typedef struct PgFreeslot PgFreeslot;
................................................................................
   268    268     if( p->nHash ){ sqlite3EndBenignMalloc(); }
   269    269     pcache1EnterMutex();
   270    270     if( apNew ){
   271    271       memset(apNew, 0, sizeof(PgHdr1 *)*nNew);
   272    272       for(i=0; i<p->nHash; i++){
   273    273         PgHdr1 *pPage;
   274    274         PgHdr1 *pNext = p->apHash[i];
   275         -      while( (pPage = pNext) ){
          275  +      while( (pPage = pNext)!=0 ){
   276    276           unsigned int h = pPage->iKey % nNew;
   277    277           pNext = pPage->pNext;
   278    278           pPage->pNext = apNew[h];
   279    279           apNew[h] = pPage;
   280    280         }
   281    281       }
   282    282       sqlite3_free(p->apHash);
................................................................................
   360    360     unsigned int iLimit 
   361    361   ){
   362    362     unsigned int h;
   363    363     assert( sqlite3_mutex_held(pcache1.mutex) );
   364    364     for(h=0; h<pCache->nHash; h++){
   365    365       PgHdr1 **pp = &pCache->apHash[h]; 
   366    366       PgHdr1 *pPage;
   367         -    while( (pPage = *pp) ){
          367  +    while( (pPage = *pp)!=0 ){
   368    368         if( pPage->iKey>=iLimit ){
   369    369           pcache1PinPage(pPage);
   370    370           *pp = pPage->pNext;
   371    371           pcache1FreePage(pPage);
   372    372         }else{
   373    373           pp = &pPage->pNext;
   374    374         }

Changes to src/printf.c.

     1      1   /*
     2      2   ** The "printf" code that follows dates from the 1980's.  It is in
     3      3   ** the public domain.  The original comments are included here for
     4      4   ** completeness.  They are very out-of-date but might be useful as
     5      5   ** an historical reference.  Most of the "enhancements" have been backed
     6      6   ** out so that the functionality is now the same as standard printf().
     7      7   **
     8         -** $Id: printf.c,v 1.97 2008/11/22 18:28:51 drh Exp $
            8  +** $Id: printf.c,v 1.98 2008/12/10 18:03:46 drh Exp $
     9      9   **
    10     10   **************************************************************************
    11     11   **
    12     12   ** The following modules is an enhanced replacement for the "printf" subroutines
    13     13   ** found in the standard C library.  The following enhancements are
    14     14   ** supported:
    15     15   **
................................................................................
   241    241     etByte flag_longlong;      /* True if the "ll" flag is present */
   242    242     etByte done;               /* Loop termination flag */
   243    243     sqlite_uint64 longvalue;   /* Value for integer types */
   244    244     LONGDOUBLE_TYPE realvalue; /* Value for real types */
   245    245     const et_info *infop;      /* Pointer to the appropriate info structure */
   246    246     char buf[etBUFSIZE];       /* Conversion buffer */
   247    247     char prefix;               /* Prefix character.  "+" or "-" or " " or '\0'. */
   248         -  etByte xtype;              /* Conversion paradigm */
          248  +  etByte xtype = 0;          /* Conversion paradigm */
   249    249     char *zExtra;              /* Extra memory used for etTCLESCAPE conversions */
   250    250   #ifndef SQLITE_OMIT_FLOATING_POINT
   251    251     int  exp, e2;              /* exponent of real numbers */
   252    252     double rounder;            /* Used for rounding floating point values */
   253    253     etByte flag_dp;            /* True if decimal point should be shown */
   254    254     etByte flag_rtz;           /* True if trailing zeros should be removed */
   255    255     etByte flag_exp;           /* True to force display of the exponent */

Changes to src/resolve.c.

    10     10   **
    11     11   *************************************************************************
    12     12   **
    13     13   ** This file contains routines used for walking the parser tree and
    14     14   ** resolve all identifiers by associating them with a particular
    15     15   ** table and column.
    16     16   **
    17         -** $Id: resolve.c,v 1.13 2008/12/09 14:03:22 drh Exp $
           17  +** $Id: resolve.c,v 1.14 2008/12/10 18:03:46 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
    22     22   
    23     23   /*
    24     24   ** Turn the pExpr expression into an alias for the iCol-th column of the
................................................................................
   215    215   #ifndef SQLITE_OMIT_TRIGGER
   216    216       /* If we have not already resolved the name, then maybe 
   217    217       ** it is a new.* or old.* trigger argument reference
   218    218       */
   219    219       if( zDb==0 && zTab!=0 && cnt==0 && pParse->trigStack!=0 ){
   220    220         TriggerStack *pTriggerStack = pParse->trigStack;
   221    221         Table *pTab = 0;
   222         -      u32 *piColMask;
          222  +      u32 *piColMask = 0;
   223    223         if( pTriggerStack->newIdx != -1 && sqlite3StrICmp("new", zTab) == 0 ){
   224    224           pExpr->iTable = pTriggerStack->newIdx;
   225    225           assert( pTriggerStack->pTab );
   226    226           pTab = pTriggerStack->pTab;
   227    227           piColMask = &(pTriggerStack->newColMask);
   228    228         }else if( pTriggerStack->oldIdx != -1 && sqlite3StrICmp("old", zTab)==0 ){
   229    229           pExpr->iTable = pTriggerStack->oldIdx;

Changes to src/select.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle SELECT statements in SQLite.
    14     14   **
    15         -** $Id: select.c,v 1.491 2008/12/10 17:20:01 drh Exp $
           15  +** $Id: select.c,v 1.492 2008/12/10 18:03:46 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Delete all the content of a Select structure but do not deallocate
    22     22   ** the select structure itself.
................................................................................
  2030   2030     int regAddrB;         /* Address register for select-B coroutine */
  2031   2031     int regEofB;          /* Flag to indicate when select-B is complete */
  2032   2032     int addrSelectA;      /* Address of the select-A coroutine */
  2033   2033     int addrSelectB;      /* Address of the select-B coroutine */
  2034   2034     int regOutA;          /* Address register for the output-A subroutine */
  2035   2035     int regOutB;          /* Address register for the output-B subroutine */
  2036   2036     int addrOutA;         /* Address of the output-A subroutine */
  2037         -  int addrOutB;         /* Address of the output-B subroutine */
         2037  +  int addrOutB = 0;     /* Address of the output-B subroutine */
  2038   2038     int addrEofA;         /* Address of the select-A-exhausted subroutine */
  2039   2039     int addrEofB;         /* Address of the select-B-exhausted subroutine */
  2040   2040     int addrAltB;         /* Address of the A<B subroutine */
  2041   2041     int addrAeqB;         /* Address of the A==B subroutine */
  2042   2042     int addrAgtB;         /* Address of the A>B subroutine */
  2043   2043     int regLimitA;        /* Limit register for select-A */
  2044   2044     int regLimitB;        /* Limit register for select-A */
................................................................................
  3535   3535       ** results, so remove it if it were specified.
  3536   3536       */
  3537   3537       assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union || 
  3538   3538              pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard);
  3539   3539       p->selFlags &= ~SF_Distinct;
  3540   3540     }
  3541   3541     sqlite3SelectPrep(pParse, p, 0);
         3542  +  pTabList = p->pSrc;
         3543  +  pEList = p->pEList;
  3542   3544     if( pParse->nErr || db->mallocFailed ){
  3543   3545       goto select_end;
  3544   3546     }
  3545   3547     p->pOrderBy = pOrderBy;
  3546         -
  3547         -
  3548         -  /* Make local copies of the parameters for this query.
  3549         -  */
  3550         -  pTabList = p->pSrc;
  3551   3548     isAgg = (p->selFlags & SF_Aggregate)!=0;
  3552         -  pEList = p->pEList;
  3553   3549     if( pEList==0 ) goto select_end;
  3554   3550   
  3555   3551     /* 
  3556   3552     ** Do not even attempt to generate any code if we have already seen
  3557   3553     ** errors before this routine starts.
  3558   3554     */
  3559   3555     if( pParse->nErr>0 ) goto select_end;

Changes to src/update.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle UPDATE statements.
    14     14   **
    15         -** $Id: update.c,v 1.188 2008/12/04 20:40:10 drh Exp $
           15  +** $Id: update.c,v 1.189 2008/12/10 18:03:47 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   #ifndef SQLITE_OMIT_VIRTUALTABLE
    20     20   /* Forward declaration */
    21     21   static void updateVirtualTable(
    22     22     Parse *pParse,       /* The parsing context */
................................................................................
   105    105     int j1;                /* Addresses of jump instructions */
   106    106     int okOnePass;         /* True for one-pass algorithm without the FIFO */
   107    107   
   108    108   #ifndef SQLITE_OMIT_TRIGGER
   109    109     int isView;                  /* Trying to update a view */
   110    110     int triggers_exist = 0;      /* True if any row triggers exist */
   111    111   #endif
   112         -  int iBeginAfterTrigger;      /* Address of after trigger program */
   113         -  int iEndAfterTrigger;        /* Exit of after trigger program */
   114         -  int iBeginBeforeTrigger;     /* Address of before trigger program */
   115         -  int iEndBeforeTrigger;       /* Exit of before trigger program */
          112  +  int iBeginAfterTrigger = 0;  /* Address of after trigger program */
          113  +  int iEndAfterTrigger = 0;    /* Exit of after trigger program */
          114  +  int iBeginBeforeTrigger = 0; /* Address of before trigger program */
          115  +  int iEndBeforeTrigger = 0;   /* Exit of before trigger program */
   116    116     u32 old_col_mask = 0;        /* Mask of OLD.* columns in use */
   117    117     u32 new_col_mask = 0;        /* Mask of NEW.* columns in use */
   118    118   
   119    119     int newIdx      = -1;  /* index of trigger "new" temp table       */
   120    120     int oldIdx      = -1;  /* index of trigger "old" temp table       */
   121    121   
   122    122     /* Register Allocations */

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.793 2008/12/09 02:51:24 drh Exp $
           46  +** $Id: vdbe.c,v 1.794 2008/12/10 18:03:47 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include <ctype.h>
    50     50   #include "vdbeInt.h"
    51     51   
    52     52   /*
    53     53   ** The following global variable is incremented every time a cursor
................................................................................
   534    534     Vdbe *p                    /* The VDBE */
   535    535   ){
   536    536     int pc;                    /* The program counter */
   537    537     Op *pOp;                   /* Current operation */
   538    538     int rc = SQLITE_OK;        /* Value to return */
   539    539     sqlite3 *db = p->db;       /* The database */
   540    540     u8 encoding = ENC(db);     /* The database encoding */
   541         -  Mem *pIn1, *pIn2, *pIn3;   /* Input operands */
   542         -  Mem *pOut;                 /* Output operand */
          541  +  Mem *pIn1 = 0;             /* 1st input operand */
          542  +  Mem *pIn2 = 0;             /* 2nd input operand */
          543  +  Mem *pIn3 = 0;             /* 3rd input operand */
          544  +  Mem *pOut = 0;             /* Output operand */
   543    545     u8 opProperty;
   544    546     int iCompare = 0;          /* Result of last OP_Compare operation */
   545    547     int *aPermute = 0;         /* Permuation of columns for OP_Compare */
   546    548   #ifdef VDBE_PROFILE
   547    549     u64 start;                 /* CPU clock count at start of opcode */
   548    550     int origPc;                /* Program counter at start of opcode */
   549    551   #endif
................................................................................
  1973   1975     int nField;        /* number of fields in the record */
  1974   1976     int len;           /* The length of the serialized data for the column */
  1975   1977     int i;             /* Loop counter */
  1976   1978     char *zData;       /* Part of the record being decoded */
  1977   1979     Mem *pDest;        /* Where to write the extracted value */
  1978   1980     Mem sMem;          /* For storing the record being decoded */
  1979   1981   
  1980         -  sMem.flags = 0;
  1981         -  sMem.db = 0;
  1982         -  sMem.zMalloc = 0;
         1982  +  memset(&sMem, 0, sizeof(sMem));
  1983   1983     assert( p1<p->nCursor );
  1984   1984     assert( pOp->p3>0 && pOp->p3<=p->nMem );
  1985   1985     pDest = &p->aMem[pOp->p3];
  1986   1986     MemSetTypeFlag(pDest, MEM_Null);
  1987   1987   
  1988   1988     /* This block sets the variable payloadSize to be the total number of
  1989   1989     ** bytes in the record.
................................................................................
  2050   2050     if( pC->cacheStatus==p->cacheCtr ){
  2051   2051       aOffset = pC->aOffset;
  2052   2052     }else{
  2053   2053       u8 *zIdx;        /* Index into header */
  2054   2054       u8 *zEndHdr;     /* Pointer to first byte after the header */
  2055   2055       int offset;      /* Offset into the data */
  2056   2056       int szHdrSz;     /* Size of the header size field at start of record */
  2057         -    int avail;       /* Number of bytes of available data */
         2057  +    int avail = 0;   /* Number of bytes of available data */
  2058   2058   
  2059   2059       assert(aType);
  2060   2060       pC->aOffset = aOffset = &aType[nField];
  2061   2061       pC->payloadSize = payloadSize;
  2062   2062       pC->cacheStatus = p->cacheCtr;
  2063   2063   
  2064   2064       /* Figure out how many bytes are in the header */

Changes to src/vdbeapi.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   **
    13     13   ** This file contains code use to implement APIs that are part of the
    14     14   ** VDBE.
    15     15   **
    16         -** $Id: vdbeapi.c,v 1.149 2008/11/19 09:05:27 danielk1977 Exp $
           16  +** $Id: vdbeapi.c,v 1.150 2008/12/10 18:03:47 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "vdbeInt.h"
    20     20   
    21     21   #if 0 && defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)
    22     22   /*
    23     23   ** The following structure contains pointers to the end points of a
................................................................................
   280    280   int sqlite3_value_bytes16(sqlite3_value *pVal){
   281    281     return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);
   282    282   }
   283    283   double sqlite3_value_double(sqlite3_value *pVal){
   284    284     return sqlite3VdbeRealValue((Mem*)pVal);
   285    285   }
   286    286   int sqlite3_value_int(sqlite3_value *pVal){
   287         -  return sqlite3VdbeIntValue((Mem*)pVal);
          287  +  return (int)sqlite3VdbeIntValue((Mem*)pVal);
   288    288   }
   289    289   sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
   290    290     return sqlite3VdbeIntValue((Mem*)pVal);
   291    291   }
   292    292   const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
   293    293     return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
   294    294   }
................................................................................
   459    459         db->u1.isInterrupted = 0;
   460    460       }
   461    461   
   462    462   #ifndef SQLITE_OMIT_TRACE
   463    463       if( db->xProfile && !db->init.busy ){
   464    464         double rNow;
   465    465         sqlite3OsCurrentTime(db->pVfs, &rNow);
   466         -      p->startTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0;
          466  +      p->startTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0);
   467    467       }
   468    468   #endif
   469    469   
   470    470       db->activeVdbeCnt++;
   471    471       if( p->readOnly==0 ) db->writeVdbeCnt++;
   472    472       p->pc = 0;
   473    473       stmtLruRemove(p);
................................................................................
   490    490     */
   491    491     if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->nOp>0
   492    492              && p->aOp[0].opcode==OP_Trace && p->aOp[0].p4.z!=0 ){
   493    493       double rNow;
   494    494       u64 elapseTime;
   495    495   
   496    496       sqlite3OsCurrentTime(db->pVfs, &rNow);
   497         -    elapseTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0 - p->startTime;
          497  +    elapseTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0);
          498  +    elapseTime -= p->startTime;
   498    499       db->xProfile(db->pProfileArg, p->aOp[0].p4.z, elapseTime);
   499    500     }
   500    501   #endif
   501    502   
   502    503     db->errCode = rc;
   503    504     /*sqlite3Error(p->db, rc, 0);*/
   504    505     p->rc = sqlite3ApiExit(p->db, p->rc);
................................................................................
  1048   1049   */
  1049   1050   static int bindText(
  1050   1051     sqlite3_stmt *pStmt,   /* The statement to bind against */
  1051   1052     int i,                 /* Index of the parameter to bind */
  1052   1053     const void *zData,     /* Pointer to the data to be bound */
  1053   1054     int nData,             /* Number of bytes of data to be bound */
  1054   1055     void (*xDel)(void*),   /* Destructor for the data */
  1055         -  int encoding           /* Encoding for the data */
         1056  +  u8 encoding            /* Encoding for the data */
  1056   1057   ){
  1057   1058     Vdbe *p = (Vdbe *)pStmt;
  1058   1059     Mem *pVar;
  1059   1060     int rc;
  1060   1061   
  1061   1062     rc = vdbeUnbind(p, i);
  1062   1063     if( rc==SQLITE_OK ){

Changes to src/vdbemem.c.

    11     11   *************************************************************************
    12     12   **
    13     13   ** This file contains code use to manipulate "Mem" structure.  A "Mem"
    14     14   ** stores a single value in the VDBE.  Mem is an opaque structure visible
    15     15   ** only within the VDBE.  Interface routines refer to a Mem using the
    16     16   ** name sqlite_value
    17     17   **
    18         -** $Id: vdbemem.c,v 1.131 2008/12/10 11:49:06 drh Exp $
           18  +** $Id: vdbemem.c,v 1.132 2008/12/10 18:03:47 drh Exp $
    19     19   */
    20     20   #include "sqliteInt.h"
    21     21   #include <ctype.h>
    22     22   #include "vdbeInt.h"
    23     23   
    24     24   /*
    25     25   ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*)
................................................................................
    39     39   ** SQLITE_OK is returned if the conversion is successful (or not required).
    40     40   ** SQLITE_NOMEM may be returned if a malloc() fails during conversion
    41     41   ** between formats.
    42     42   */
    43     43   int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
    44     44     int rc;
    45     45     assert( (pMem->flags&MEM_RowSet)==0 );
           46  +  assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE
           47  +           || desiredEnc==SQLITE_UTF16BE );
    46     48     if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){
    47     49       return SQLITE_OK;
    48     50     }
    49     51     assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
    50     52   #ifdef SQLITE_OMIT_UTF16
    51     53     return SQLITE_ERROR;
    52     54   #else
    53     55   
    54     56     /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned,
    55     57     ** then the encoding of the value may not have changed.
    56     58     */
    57         -  rc = sqlite3VdbeMemTranslate(pMem, desiredEnc);
           59  +  rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);
    58     60     assert(rc==SQLITE_OK    || rc==SQLITE_NOMEM);
    59     61     assert(rc==SQLITE_OK    || pMem->enc!=desiredEnc);
    60     62     assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);
    61     63     return rc;
    62     64   #endif
    63     65   }
    64     66   

Changes to src/vtab.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to help implement virtual tables.
    13     13   **
    14         -** $Id: vtab.c,v 1.79 2008/12/10 17:20:01 drh Exp $
           14  +** $Id: vtab.c,v 1.80 2008/12/10 18:03:47 drh Exp $
    15     15   */
    16     16   #ifndef SQLITE_OMIT_VIRTUALTABLE
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   static int createModule(
    20     20     sqlite3 *db,                    /* Database in which module is registered */
    21     21     const char *zName,              /* Name assigned to this module */
................................................................................
    23     23     void *pAux,                     /* Context pointer for xCreate/xConnect */
    24     24     void (*xDestroy)(void *)        /* Module destructor function */
    25     25   ) {
    26     26     int rc, nName;
    27     27     Module *pMod;
    28     28   
    29     29     sqlite3_mutex_enter(db->mutex);
    30         -  nName = strlen(zName);
           30  +  nName = (int)strlen(zName);
    31     31     pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1);
    32     32     if( pMod ){
    33     33       Module *pDel;
    34     34       char *zCopy = (char *)(&pMod[1]);
    35     35       memcpy(zCopy, zName, nName+1);
    36     36       pMod->zName = zCopy;
    37     37       pMod->pModule = pModule;
................................................................................
   189    189     assert( iDb>=0 );
   190    190   
   191    191     pTable->tabFlags |= TF_Virtual;
   192    192     pTable->nModuleArg = 0;
   193    193     addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
   194    194     addModuleArgument(db, pTable, sqlite3DbStrDup(db, db->aDb[iDb].zName));
   195    195     addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
   196         -  pParse->sNameToken.n = pModuleName->z + pModuleName->n - pName1->z;
          196  +  pParse->sNameToken.n = (int)(&pModuleName->z[pModuleName->n] - pName1->z);
   197    197   
   198    198   #ifndef SQLITE_OMIT_AUTHORIZATION
   199    199     /* Creating a virtual table invokes the authorization callback twice.
   200    200     ** The first invocation, to obtain permission to INSERT a row into the
   201    201     ** sqlite_master table, has already been made by sqlite3StartTable().
   202    202     ** The second call, to obtain permission to create the table, is made now.
   203    203     */
................................................................................
   237    237   
   238    238     /* Lookup the module name. */
   239    239     pTab = pParse->pNewTable;
   240    240     if( pTab==0 ) return;
   241    241     db = pParse->db;
   242    242     if( pTab->nModuleArg<1 ) return;
   243    243     zModule = pTab->azModuleArg[0];
   244         -  pMod = (Module *)sqlite3HashFind(&db->aModule, zModule, strlen(zModule));
          244  +  pMod = (Module*)sqlite3HashFind(&db->aModule, zModule, (int)strlen(zModule));
   245    245     pTab->pMod = pMod;
   246    246     
   247    247     /* If the CREATE VIRTUAL TABLE statement is being entered for the
   248    248     ** first time (in other words if the virtual table is actually being
   249    249     ** created now instead of just being read out of sqlite_master) then
   250    250     ** do additional initialization work and store the statement text
   251    251     ** in the sqlite_master table.
................................................................................
   254    254       char *zStmt;
   255    255       char *zWhere;
   256    256       int iDb;
   257    257       Vdbe *v;
   258    258   
   259    259       /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
   260    260       if( pEnd ){
   261         -      pParse->sNameToken.n = pEnd->z - pParse->sNameToken.z + pEnd->n;
          261  +      pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;
   262    262       }
   263    263       zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);
   264    264   
   265    265       /* A slot for the record has already been allocated in the 
   266    266       ** SQLITE_MASTER table.  We just need to update that slot with all
   267    267       ** the information we've collected.  
   268    268       **
................................................................................
   285    285       v = sqlite3GetVdbe(pParse);
   286    286       sqlite3ChangeCookie(pParse, iDb);
   287    287   
   288    288       sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
   289    289       zWhere = sqlite3MPrintf(db, "name='%q'", pTab->zName);
   290    290       sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 1, 0, zWhere, P4_DYNAMIC);
   291    291       sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, 
   292         -                         pTab->zName, strlen(pTab->zName) + 1);
          292  +                         pTab->zName, (int)strlen(pTab->zName) + 1);
   293    293     }
   294    294   
   295    295     /* If we are rereading the sqlite_master table create the in-memory
   296    296     ** record of the table. If the module has already been registered,
   297    297     ** also call the xConnect method here.
   298    298     */
   299    299     else {
   300    300       Table *pOld;
   301    301       Schema *pSchema = pTab->pSchema;
   302    302       const char *zName = pTab->zName;
   303         -    int nName = strlen(zName) + 1;
          303  +    int nName = (int)strlen(zName) + 1;
   304    304       pOld = sqlite3HashInsert(&pSchema->tblHash, zName, nName, pTab);
   305    305       if( pOld ){
   306    306         db->mallocFailed = 1;
   307    307         assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */
   308    308         return;
   309    309       }
   310    310       pSchema->db = pParse->db;
................................................................................
   329    329   void sqlite3VtabArgExtend(Parse *pParse, Token *p){
   330    330     Token *pArg = &pParse->sArg;
   331    331     if( pArg->z==0 ){
   332    332       pArg->z = p->z;
   333    333       pArg->n = p->n;
   334    334     }else{
   335    335       assert(pArg->z < p->z);
   336         -    pArg->n = (p->z + p->n - pArg->z);
          336  +    pArg->n = (int)(&p->z[p->n] - pArg->z);
   337    337     }
   338    338   }
   339    339   
   340    340   /*
   341    341   ** Invoke a virtual table constructor (either xCreate or xConnect). The
   342    342   ** pointer to the function to invoke is passed as the fourth parameter
   343    343   ** to this procedure.
................................................................................
   401    401     if( rc==SQLITE_OK ){
   402    402       int iCol;
   403    403       for(iCol=0; iCol<pTab->nCol; iCol++){
   404    404         char *zType = pTab->aCol[iCol].zType;
   405    405         int nType;
   406    406         int i = 0;
   407    407         if( !zType ) continue;
   408         -      nType = strlen(zType);
          408  +      nType = (int)strlen(zType);
   409    409         if( sqlite3StrNICmp("hidden", zType, 6) || (zType[6] && zType[6]!=' ') ){
   410    410           for(i=0; i<nType; i++){
   411    411             if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))
   412    412              && (zType[i+7]=='\0' || zType[i+7]==' ')
   413    413             ){
   414    414               i++;
   415    415               break;
................................................................................
   800    800     }
   801    801     if( rc==0 ){
   802    802       return pDef;
   803    803     }
   804    804   
   805    805     /* Create a new ephemeral function definition for the overloaded
   806    806     ** function */
   807         -  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) + strlen(pDef->zName) );
          807  +  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) + (int)strlen(pDef->zName) );
   808    808     if( pNew==0 ){
   809    809       return pDef;
   810    810     }
   811    811     *pNew = *pDef;
   812    812     pNew->zName = (char *)&pNew[1];
   813    813     memcpy(pNew->zName, pDef->zName, strlen(pDef->zName)+1);
   814    814     pNew->xFunc = xFunc;

Changes to tool/lempar.c.

   381    381       return yy_default[stateno];
   382    382     }
   383    383     assert( iLookAhead!=YYNOCODE );
   384    384     i += iLookAhead;
   385    385     if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
   386    386       if( iLookAhead>0 ){
   387    387   #ifdef YYFALLBACK
   388         -      int iFallback;            /* Fallback token */
          388  +      YYCODETYPE iFallback;            /* Fallback token */
   389    389         if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
   390    390                && (iFallback = yyFallback[iLookAhead])!=0 ){
   391    391   #ifndef NDEBUG
   392    392           if( yyTraceFILE ){
   393    393             fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
   394    394                yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
   395    395           }
................................................................................
   498    498       if( yypParser->yyidx>=yypParser->yystksz ){
   499    499         yyStackOverflow(yypParser, yypMinor);
   500    500         return;
   501    501       }
   502    502     }
   503    503   #endif
   504    504     yytos = &yypParser->yystack[yypParser->yyidx];
   505         -  yytos->stateno = yyNewState;
   506         -  yytos->major = yyMajor;
          505  +  yytos->stateno = (YYACTIONTYPE)yyNewState;
          506  +  yytos->major = (YYCODETYPE)yyMajor;
   507    507     yytos->minor = *yypMinor;
   508    508   #ifndef NDEBUG
   509    509     if( yyTraceFILE && yypParser->yyidx>0 ){
   510    510       int i;
   511    511       fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
   512    512       fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
   513    513       for(i=1; i<=yypParser->yyidx; i++)
................................................................................
   765    765         if( yymx==YYERRORSYMBOL || yyerrorhit ){
   766    766   #ifndef NDEBUG
   767    767           if( yyTraceFILE ){
   768    768             fprintf(yyTraceFILE,"%sDiscard input token %s\n",
   769    769                yyTracePrompt,yyTokenName[yymajor]);
   770    770           }
   771    771   #endif
   772         -        yy_destructor(yypParser, yymajor,&yyminorunion);
          772  +        yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
   773    773           yymajor = YYNOCODE;
   774    774         }else{
   775    775            while(
   776    776             yypParser->yyidx >= 0 &&
   777    777             yymx != YYERRORSYMBOL &&
   778    778             (yyact = yy_find_reduce_action(
   779    779                           yypParser->yystack[yypParser->yyidx].stateno,
   780    780                           YYERRORSYMBOL)) >= YYNSTATE
   781    781           ){
   782    782             yy_pop_parser_stack(yypParser);
   783    783           }
   784    784           if( yypParser->yyidx < 0 || yymajor==0 ){
   785         -          yy_destructor(yypParser,yymajor,&yyminorunion);
          785  +          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
   786    786             yy_parse_failed(yypParser);
   787    787             yymajor = YYNOCODE;
   788    788           }else if( yymx!=YYERRORSYMBOL ){
   789    789             YYMINORTYPE u2;
   790    790             u2.YYERRSYMDT = 0;
   791    791             yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
   792    792           }
................................................................................
   803    803         ** As before, subsequent error messages are suppressed until
   804    804         ** three input tokens have been successfully shifted.
   805    805         */
   806    806         if( yypParser->yyerrcnt<=0 ){
   807    807           yy_syntax_error(yypParser,yymajor,yyminorunion);
   808    808         }
   809    809         yypParser->yyerrcnt = 3;
   810         -      yy_destructor(yypParser,yymajor,&yyminorunion);
          810  +      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
   811    811         if( yyendofinput ){
   812    812           yy_parse_failed(yypParser);
   813    813         }
   814    814         yymajor = YYNOCODE;
   815    815   #endif
   816    816       }
   817    817     }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
   818    818     return;
   819    819   }