/ Check-in [33cf8359]
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:Rework the logic that generates a schema for tables created using "CREATE TABLE ... AS SELECT ...". Instead of trying to copy the raw datatype string from the right-hand side, just make the type one of TEXT, INT, REAL, NUM, or nothing. This is much simpler than trying to parse and quote datatype strings. Other minor implifications to build.c are bundled with this change. (CVS 6626)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 33cf83591e6e13875ef6ada5b8ac8ab07619d8bc
User & Date: drh 2009-05-11 20:53:29
References
2019-08-05
13:06 Fixed ticket [d52a29a9]: Unexpected affinity conversion in view plus 8 other changes artifact: ac513e2e user: drh
Context
2009-05-11
23:38
If a virtual table constructor returns SQLITE_NOMEM, set the mallocFailed flag in the corresponding database connection to insure that the error is propagated back to the top layer. (CVS 6627) check-in: 5635666f user: drh tags: trunk
20:53
Rework the logic that generates a schema for tables created using "CREATE TABLE ... AS SELECT ...". Instead of trying to copy the raw datatype string from the right-hand side, just make the type one of TEXT, INT, REAL, NUM, or nothing. This is much simpler than trying to parse and quote datatype strings. Other minor implifications to build.c are bundled with this change. (CVS 6626) check-in: 33cf8359 user: drh tags: trunk
18:22
Enhance the parser to allow nested parentheses in the module argument of a CREATE VIRTUAL TABLE statement. (CVS 6625) check-in: 93772bd7 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.537 2009/05/06 18:42:21 drh Exp $
           25  +** $Id: build.c,v 1.538 2009/05/11 20:53:29 drh Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   
    29     29   /*
    30     30   ** This routine is called when a new SQL statement is beginning to
    31     31   ** be parsed.  Initialize the pParse structure as needed.
    32     32   */
................................................................................
   338    338   }
   339    339   
   340    340   /*
   341    341   ** Reclaim the memory used by an index
   342    342   */
   343    343   static void freeIndex(Index *p){
   344    344     sqlite3 *db = p->pTable->dbMem;
          345  +  testcase( db==0 );
   345    346     sqlite3DbFree(db, p->zColAff);
   346    347     sqlite3DbFree(db, p);
   347    348   }
   348    349   
   349    350   /*
   350    351   ** Remove the given index from the index hash table, and free
   351    352   ** its memory structures.
................................................................................
   466    467   /*
   467    468   ** Clear the column names from a table or view.
   468    469   */
   469    470   static void sqliteResetColumnNames(Table *pTable){
   470    471     int i;
   471    472     Column *pCol;
   472    473     sqlite3 *db = pTable->dbMem;
          474  +  testcase( db==0 );
   473    475     assert( pTable!=0 );
   474    476     if( (pCol = pTable->aCol)!=0 ){
   475    477       for(i=0; i<pTable->nCol; i++, pCol++){
   476    478         sqlite3DbFree(db, pCol->zName);
   477    479         sqlite3ExprDelete(db, pCol->pDflt);
   478    480         sqlite3DbFree(db, pCol->zType);
   479    481         sqlite3DbFree(db, pCol->zColl);
................................................................................
   496    498   void sqlite3DeleteTable(Table *pTable){
   497    499     Index *pIndex, *pNext;
   498    500     FKey *pFKey, *pNextFKey;
   499    501     sqlite3 *db;
   500    502   
   501    503     if( pTable==0 ) return;
   502    504     db = pTable->dbMem;
          505  +  testcase( db==0 );
   503    506   
   504    507     /* Do not delete the table until the reference count reaches zero. */
   505    508     pTable->nRef--;
   506    509     if( pTable->nRef>0 ){
   507    510       return;
   508    511     }
   509    512     assert( pTable->nRef==0 );
................................................................................
   650    653     Token *pName1,      /* The "xxx" in the name "xxx.yyy" or "xxx" */
   651    654     Token *pName2,      /* The "yyy" in the name "xxx.yyy" */
   652    655     Token **pUnqual     /* Write the unqualified object name here */
   653    656   ){
   654    657     int iDb;                    /* Database holding the object */
   655    658     sqlite3 *db = pParse->db;
   656    659   
   657         -  if( pName2 && pName2->n>0 ){
          660  +  if( ALWAYS(pName2!=0) && pName2->n>0 ){
   658    661       if( db->init.busy ) {
   659    662         sqlite3ErrorMsg(pParse, "corrupt database");
   660    663         pParse->nErr++;
   661    664         return -1;
   662    665       }
   663    666       *pUnqual = pName2;
   664    667       iDb = sqlite3FindDb(db, pName1);
................................................................................
   815    818       pParse->nErr++;
   816    819       goto begin_table_error;
   817    820     }
   818    821     pTable->zName = zName;
   819    822     pTable->iPKey = -1;
   820    823     pTable->pSchema = db->aDb[iDb].pSchema;
   821    824     pTable->nRef = 1;
   822         -  pTable->dbMem = db->lookaside.bEnabled ? db : 0;
   823         -  if( pParse->pNewTable ) sqlite3DeleteTable(pParse->pNewTable);
          825  +  pTable->dbMem = 0;
          826  +  assert( pParse->pNewTable==0 );
   824    827     pParse->pNewTable = pTable;
   825    828   
   826    829     /* If this is the magic sqlite_sequence table used by autoincrement,
   827    830     ** then record a pointer to this table in the main database structure
   828    831     ** so that INSERT can find the table easily.
   829    832     */
   830    833   #ifndef SQLITE_OMIT_AUTOINCREMENT
................................................................................
   972    975   ** This routine is called by the parser while in the middle of
   973    976   ** parsing a CREATE TABLE statement.  A "NOT NULL" constraint has
   974    977   ** been seen on a column.  This routine sets the notNull flag on
   975    978   ** the column currently under construction.
   976    979   */
   977    980   void sqlite3AddNotNull(Parse *pParse, int onError){
   978    981     Table *p;
   979         -  int i;
   980         -  if( (p = pParse->pNewTable)==0 ) return;
   981         -  i = p->nCol-1;
   982         -  if( i>=0 ) p->aCol[i].notNull = (u8)onError;
          982  +  p = pParse->pNewTable;
          983  +  if( p==0 || NEVER(p->nCol<1) ) return;
          984  +  p->aCol[p->nCol-1].notNull = (u8)onError;
   983    985   }
   984    986   
   985    987   /*
   986    988   ** Scan the column type name zType (length nType) and return the
   987    989   ** associated affinity type.
   988    990   **
   989    991   ** This routine does a case-independent search of zType for the 
................................................................................
  1052   1054   ** column currently under construction.   pLast is the last token
  1053   1055   ** in the sequence.  Use this information to construct a string
  1054   1056   ** that contains the typename of the column and store that string
  1055   1057   ** in zType.
  1056   1058   */ 
  1057   1059   void sqlite3AddColumnType(Parse *pParse, Token *pType){
  1058   1060     Table *p;
  1059         -  int i;
  1060   1061     Column *pCol;
  1061         -  sqlite3 *db;
  1062   1062   
  1063         -  if( (p = pParse->pNewTable)==0 ) return;
  1064         -  i = p->nCol-1;
  1065         -  if( i<0 ) return;
  1066         -  pCol = &p->aCol[i];
  1067         -  db = pParse->db;
  1068         -  sqlite3DbFree(db, pCol->zType);
  1069         -  pCol->zType = sqlite3NameFromToken(db, pType);
         1063  +  p = pParse->pNewTable;
         1064  +  if( p==0 || NEVER(p->nCol<1) ) return;
         1065  +  pCol = &p->aCol[p->nCol-1];
         1066  +  assert( pCol->zType==0 );
         1067  +  pCol->zType = sqlite3NameFromToken(pParse->db, pType);
  1070   1068     pCol->affinity = sqlite3AffinityType(pType);
  1071   1069   }
  1072   1070   
  1073   1071   /*
  1074   1072   ** The expression is the default value for the most recently added column
  1075   1073   ** of the table currently under construction.
  1076   1074   **
................................................................................
  1080   1078   ** This routine is called by the parser while in the middle of
  1081   1079   ** parsing a CREATE TABLE statement.
  1082   1080   */
  1083   1081   void sqlite3AddDefaultValue(Parse *pParse, Expr *pExpr){
  1084   1082     Table *p;
  1085   1083     Column *pCol;
  1086   1084     sqlite3 *db = pParse->db;
  1087         -  if( (p = pParse->pNewTable)!=0 ){
         1085  +  p = pParse->pNewTable;
         1086  +  if( p!=0 ){
  1088   1087       pCol = &(p->aCol[p->nCol-1]);
  1089   1088       if( !sqlite3ExprIsConstantOrFunction(pExpr) ){
  1090   1089         sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",
  1091   1090             pCol->zName);
  1092   1091       }else{
  1093   1092         /* A copy of pExpr is used instead of the original, as pExpr contains
  1094   1093         ** tokens that point to volatile memory. The 'span' of the expression
................................................................................
  1209   1208   
  1210   1209     if( (p = pParse->pNewTable)==0 ) return;
  1211   1210     i = p->nCol-1;
  1212   1211     db = pParse->db;
  1213   1212     zColl = sqlite3NameFromToken(db, pToken);
  1214   1213     if( !zColl ) return;
  1215   1214   
  1216         -  if( sqlite3LocateCollSeq(pParse, zColl, -1) ){
         1215  +  if( sqlite3LocateCollSeq(pParse, zColl) ){
  1217   1216       Index *pIdx;
  1218   1217       p->aCol[i].zColl = zColl;
  1219   1218     
  1220   1219       /* If the column is declared as "<name> PRIMARY KEY COLLATE <type>",
  1221   1220       ** then an index may have been created on this column before the
  1222   1221       ** collation type was added. Correct this if it is the case.
  1223   1222       */
................................................................................
  1245   1244   ** If no versions of the requested collations sequence are available, or
  1246   1245   ** another error occurs, NULL is returned and an error message written into
  1247   1246   ** pParse.
  1248   1247   **
  1249   1248   ** This routine is a wrapper around sqlite3FindCollSeq().  This routine
  1250   1249   ** invokes the collation factory if the named collation cannot be found
  1251   1250   ** and generates an error message.
         1251  +**
         1252  +** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()
  1252   1253   */
  1253         -CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName, int nName){
         1254  +CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){
  1254   1255     sqlite3 *db = pParse->db;
  1255   1256     u8 enc = ENC(db);
  1256   1257     u8 initbusy = db->init.busy;
  1257   1258     CollSeq *pColl;
  1258   1259   
  1259         -  pColl = sqlite3FindCollSeq(db, enc, zName, nName, initbusy);
         1260  +  pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);
  1260   1261     if( !initbusy && (!pColl || !pColl->xCmp) ){
  1261         -    pColl = sqlite3GetCollSeq(db, pColl, zName, nName);
         1262  +    pColl = sqlite3GetCollSeq(db, pColl, zName);
  1262   1263       if( !pColl ){
  1263         -      if( nName<0 ){
  1264         -        nName = sqlite3Strlen30(zName);
  1265         -      }
  1266         -      sqlite3ErrorMsg(pParse, "no such collation sequence: %.*s", nName, zName);
         1264  +      sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
  1267   1265         pColl = 0;
  1268   1266       }
  1269   1267     }
  1270   1268   
  1271   1269     return pColl;
  1272   1270   }
  1273   1271   
................................................................................
  1309   1307     int n;
  1310   1308     for(n=0; *z; n++, z++){
  1311   1309       if( *z=='"' ){ n++; }
  1312   1310     }
  1313   1311     return n + 2;
  1314   1312   }
  1315   1313   
  1316         -/*
  1317         -** This function is a wrapper around sqlite3GetToken() used by 
  1318         -** isValidDimension(). This function differs from sqlite3GetToken() in
  1319         -** that:
  1320         -**
  1321         -**   * Whitespace is ignored, and
  1322         -**   * The output variable *peToken is set to 0 if the end of the
  1323         -**     nul-terminated input string is reached.
  1324         -*/
  1325         -static int getTokenNoSpace(unsigned char *z, int *peToken){
  1326         -  int n = 0;
  1327         -  while( sqlite3Isspace(z[n]) ) n++;
  1328         -  if( !z[n] ){
  1329         -    *peToken = 0;
  1330         -    return 0;
  1331         -  }
  1332         -  return n + sqlite3GetToken(&z[n], peToken);
  1333         -}
  1334         -
  1335         -/*
  1336         -** Parameter z points to a nul-terminated string. Return true if, when
  1337         -** whitespace is ignored, the contents of this string matches one of 
  1338         -** the following patterns:
  1339         -**
  1340         -**     ""
  1341         -**     "(number)"
  1342         -**     "(number,number)"
  1343         -*/
  1344         -static int isValidDimension(unsigned char *z){
  1345         -  int eToken;
  1346         -  int n = 0;
  1347         -  n += getTokenNoSpace(&z[n], &eToken);
  1348         -  if( eToken ){
  1349         -    if( eToken!=TK_LP ) return 0;
  1350         -    n += getTokenNoSpace(&z[n], &eToken);
  1351         -    if( eToken==TK_PLUS || eToken==TK_MINUS ){
  1352         -      n += getTokenNoSpace(&z[n], &eToken);
  1353         -    }
  1354         -    if( eToken!=TK_INTEGER && eToken!=TK_FLOAT ) return 0;
  1355         -    n += getTokenNoSpace(&z[n], &eToken);
  1356         -    if( eToken==TK_COMMA ){
  1357         -      n += getTokenNoSpace(&z[n], &eToken);
  1358         -      if( eToken==TK_PLUS || eToken==TK_MINUS ){
  1359         -        n += getTokenNoSpace(&z[n], &eToken);
  1360         -      }
  1361         -      if( eToken!=TK_INTEGER && eToken!=TK_FLOAT ) return 0;
  1362         -      n += getTokenNoSpace(&z[n], &eToken);
  1363         -    }
  1364         -    if( eToken!=TK_RP ) return 0;
  1365         -    getTokenNoSpace(&z[n], &eToken);
  1366         -  }
  1367         -  if( eToken ) return 0;
  1368         -  return 1;
  1369         -}
  1370         -
  1371   1314   /*
  1372   1315   ** The first parameter is a pointer to an output buffer. The second 
  1373   1316   ** parameter is a pointer to an integer that contains the offset at
  1374   1317   ** which to write into the output buffer. This function copies the
  1375   1318   ** nul-terminated string pointed to by the third parameter, zSignedIdent,
  1376   1319   ** to the specified offset in the buffer and updates *pIdx to refer
  1377   1320   ** to the first byte after the last byte written before returning.
  1378   1321   ** 
  1379   1322   ** If the string zSignedIdent consists entirely of alpha-numeric
  1380   1323   ** characters, does not begin with a digit and is not an SQL keyword,
  1381   1324   ** then it is copied to the output buffer exactly as it is. Otherwise,
  1382   1325   ** it is quoted using double-quotes.
  1383   1326   */
  1384         -static void identPut(char *z, int *pIdx, char *zSignedIdent, int isTypename){
         1327  +static void identPut(char *z, int *pIdx, char *zSignedIdent){
  1385   1328     unsigned char *zIdent = (unsigned char*)zSignedIdent;
  1386   1329     int i, j, needQuote;
  1387   1330     i = *pIdx;
  1388   1331   
  1389   1332     for(j=0; zIdent[j]; j++){
  1390   1333       if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;
  1391   1334     }
  1392   1335     needQuote = sqlite3Isdigit(zIdent[0]) || sqlite3KeywordCode(zIdent, j)!=TK_ID;
  1393   1336     if( !needQuote ){
  1394         -    if( isTypename ){
  1395         -      /* If this is a type-name, allow a little more flexibility. In SQLite,
  1396         -      ** a type-name is specified as:
  1397         -      **
  1398         -      **   ids [ids] [(number [, number])]
  1399         -      **
  1400         -      ** where "ids" is either a quoted string or a simple identifier (in the
  1401         -      ** above notation, [] means optional). It is a bit tricky to check
  1402         -      ** for all cases, but it is good to avoid unnecessarily quoting common
  1403         -      ** typenames like VARCHAR(10).
  1404         -      */
  1405         -      needQuote = !isValidDimension(&zIdent[j]);
  1406         -    }else{
  1407         -      needQuote = zIdent[j];
  1408         -    }
         1337  +    needQuote = zIdent[j];
  1409   1338     }
  1410   1339   
  1411   1340     if( needQuote ) z[i++] = '"';
  1412   1341     for(j=0; zIdent[j]; j++){
  1413   1342       z[i++] = zIdent[j];
  1414   1343       if( zIdent[j]=='"' ) z[i++] = '"';
  1415   1344     }
................................................................................
  1422   1351   ** Generate a CREATE TABLE statement appropriate for the given
  1423   1352   ** table.  Memory to hold the text of the statement is obtained
  1424   1353   ** from sqliteMalloc() and must be freed by the calling function.
  1425   1354   */
  1426   1355   static char *createTableStmt(sqlite3 *db, Table *p){
  1427   1356     int i, k, n;
  1428   1357     char *zStmt;
  1429         -  char *zSep, *zSep2, *zEnd, *z;
         1358  +  char *zSep, *zSep2, *zEnd;
  1430   1359     Column *pCol;
  1431   1360     n = 0;
  1432   1361     for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){
  1433         -    n += identLength(pCol->zName);
  1434         -    z = pCol->zType;
  1435         -    if( z ){
  1436         -      n += identLength(z);
  1437         -    }
         1362  +    n += identLength(pCol->zName) + 5;
  1438   1363     }
  1439   1364     n += identLength(p->zName);
  1440         -  if( n<50 ){
         1365  +  if( n<50 ){ 
  1441   1366       zSep = "";
  1442   1367       zSep2 = ",";
  1443   1368       zEnd = ")";
  1444   1369     }else{
  1445   1370       zSep = "\n  ";
  1446   1371       zSep2 = ",\n  ";
  1447   1372       zEnd = "\n)";
................................................................................
  1450   1375     zStmt = sqlite3Malloc( n );
  1451   1376     if( zStmt==0 ){
  1452   1377       db->mallocFailed = 1;
  1453   1378       return 0;
  1454   1379     }
  1455   1380     sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
  1456   1381     k = sqlite3Strlen30(zStmt);
  1457         -  identPut(zStmt, &k, p->zName, 0);
         1382  +  identPut(zStmt, &k, p->zName);
  1458   1383     zStmt[k++] = '(';
  1459   1384     for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
         1385  +    static const char * const azType[] = {
         1386  +        /* SQLITE_AFF_TEXT    */ " TEXT",
         1387  +        /* SQLITE_AFF_NONE    */ "",
         1388  +        /* SQLITE_AFF_NUMERIC */ " NUM",
         1389  +        /* SQLITE_AFF_INTEGER */ " INT",
         1390  +        /* SQLITE_AFF_REAL    */ " REAL"
         1391  +    };
         1392  +    int len;
         1393  +    const char *zType;
         1394  +
  1460   1395       sqlite3_snprintf(n-k, &zStmt[k], zSep);
  1461   1396       k += sqlite3Strlen30(&zStmt[k]);
  1462   1397       zSep = zSep2;
  1463         -    identPut(zStmt, &k, pCol->zName, 0);
  1464         -    if( (z = pCol->zType)!=0 ){
  1465         -      zStmt[k++] = ' ';
  1466         -      assert( (int)(sqlite3Strlen30(z)+k+1)<=n );
  1467         -      identPut(zStmt, &k, z, 1);
         1398  +    identPut(zStmt, &k, pCol->zName);
         1399  +    assert( pCol->affinity-SQLITE_AFF_TEXT >= 0 );
         1400  +    assert( pCol->affinity-SQLITE_AFF_TEXT < sizeof(azType)/sizeof(azType[0]) );
         1401  +    testcase( pCol->affinity==SQLITE_AFF_TEXT );
         1402  +    testcase( pCol->affinity==SQLITE_AFF_NONE );
         1403  +    testcase( pCol->affinity==SQLITE_AFF_NUMERIC );
         1404  +    testcase( pCol->affinity==SQLITE_AFF_INTEGER );
         1405  +    testcase( pCol->affinity==SQLITE_AFF_REAL );
         1406  +    
         1407  +    zType = azType[pCol->affinity - SQLITE_AFF_TEXT];
         1408  +    len = sqlite3Strlen30(zType);
         1409  +#ifndef NDEBUG
         1410  +    if( pCol->affinity!=SQLITE_AFF_NONE ){
         1411  +       Token typeToken;
         1412  +       typeToken.z = (u8*)zType;
         1413  +       typeToken.n = len;
         1414  +       assert( pCol->affinity==sqlite3AffinityType(&typeToken) );
  1468   1415       }
         1416  +#endif
         1417  +    memcpy(&zStmt[k], zType, len);
         1418  +    k += len;
         1419  +    assert( k<=n );
  1469   1420     }
  1470   1421     sqlite3_snprintf(n-k, &zStmt[k], "%s", zEnd);
  1471   1422     return zStmt;
  1472   1423   }
  1473   1424   
  1474   1425   /*
  1475   1426   ** This routine is called to report the final ")" that terminates
................................................................................
  2643   2594         zExtra += (sqlite3Strlen30(zColl) + 1);
  2644   2595       }else{
  2645   2596         zColl = pTab->aCol[j].zColl;
  2646   2597         if( !zColl ){
  2647   2598           zColl = db->pDfltColl->zName;
  2648   2599         }
  2649   2600       }
  2650         -    if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl, -1) ){
         2601  +    if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
  2651   2602         goto exit_create_index;
  2652   2603       }
  2653   2604       pIndex->azColl[i] = zColl;
  2654   2605       requestedSortOrder = pListItem->sortOrder & sortOrderMask;
  2655   2606       pIndex->aSortOrder[i] = (u8)requestedSortOrder;
  2656   2607     }
  2657   2608     sqlite3DefaultRowEst(pIndex);
................................................................................
  3580   3531       reindexDatabases(pParse, 0);
  3581   3532       return;
  3582   3533     }else if( pName2==0 || pName2->z==0 ){
  3583   3534       char *zColl;
  3584   3535       assert( pName1->z );
  3585   3536       zColl = sqlite3NameFromToken(pParse->db, pName1);
  3586   3537       if( !zColl ) return;
  3587         -    pColl = sqlite3FindCollSeq(db, ENC(db), zColl, -1, 0);
         3538  +    pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);
  3588   3539       if( pColl ){
  3589   3540         if( zColl ){
  3590   3541           reindexDatabases(pParse, zColl);
  3591   3542           sqlite3DbFree(db, zColl);
  3592   3543         }
  3593   3544         return;
  3594   3545       }
................................................................................
  3636   3587     if( pKey ){
  3637   3588       pKey->db = pParse->db;
  3638   3589       pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]);
  3639   3590       assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) );
  3640   3591       for(i=0; i<nCol; i++){
  3641   3592         char *zColl = pIdx->azColl[i];
  3642   3593         assert( zColl );
  3643         -      pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl, -1);
         3594  +      pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
  3644   3595         pKey->aSortOrder[i] = pIdx->aSortOrder[i];
  3645   3596       }
  3646   3597       pKey->nField = (u16)nCol;
  3647   3598     }
  3648   3599   
  3649   3600     if( pParse->nErr ){
  3650   3601       sqlite3DbFree(db, pKey);
  3651   3602       pKey = 0;
  3652   3603     }
  3653   3604     return pKey;
  3654   3605   }

Changes to src/callback.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   **
    13     13   ** This file contains functions used to access the internal hash tables
    14     14   ** of user defined functions and collation sequences.
    15     15   **
    16         -** $Id: callback.c,v 1.39 2009/05/03 20:23:53 drh Exp $
           16  +** $Id: callback.c,v 1.40 2009/05/11 20:53:29 drh Exp $
    17     17   */
    18     18   
    19     19   #include "sqliteInt.h"
    20     20   
    21     21   /*
    22     22   ** Invoke the 'collation needed' callback to request a collation sequence
    23     23   ** in the database text encoding of name zName, length nName.
    24     24   ** If the collation sequence
    25     25   */
    26         -static void callCollNeeded(sqlite3 *db, const char *zName, int nName){
           26  +static void callCollNeeded(sqlite3 *db, const char *zName){
    27     27     assert( !db->xCollNeeded || !db->xCollNeeded16 );
    28         -  if( nName<0 ) nName = sqlite3Strlen30(zName);
    29     28     if( db->xCollNeeded ){
    30         -    char *zExternal = sqlite3DbStrNDup(db, zName, nName);
           29  +    char *zExternal = sqlite3DbStrDup(db, zName);
    31     30       if( !zExternal ) return;
    32     31       db->xCollNeeded(db->pCollNeededArg, db, (int)ENC(db), zExternal);
    33     32       sqlite3DbFree(db, zExternal);
    34     33     }
    35     34   #ifndef SQLITE_OMIT_UTF16
    36     35     if( db->xCollNeeded16 ){
    37     36       char const *zExternal;
    38     37       sqlite3_value *pTmp = sqlite3ValueNew(db);
    39         -    sqlite3ValueSetStr(pTmp, nName, zName, SQLITE_UTF8, SQLITE_STATIC);
           38  +    sqlite3ValueSetStr(pTmp, -1, zName, SQLITE_UTF8, SQLITE_STATIC);
    40     39       zExternal = sqlite3ValueText(pTmp, SQLITE_UTF16NATIVE);
    41     40       if( zExternal ){
    42     41         db->xCollNeeded16(db->pCollNeededArg, db, (int)ENC(db), zExternal);
    43     42       }
    44     43       sqlite3ValueFree(pTmp);
    45     44     }
    46     45   #endif
................................................................................
    52     51   ** of this collation function (for other text encodings) available. Use one
    53     52   ** of these instead if they exist. Avoid a UTF-8 <-> UTF-16 conversion if
    54     53   ** possible.
    55     54   */
    56     55   static int synthCollSeq(sqlite3 *db, CollSeq *pColl){
    57     56     CollSeq *pColl2;
    58     57     char *z = pColl->zName;
    59         -  int n = sqlite3Strlen30(z);
    60     58     int i;
    61     59     static const u8 aEnc[] = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 };
    62     60     for(i=0; i<3; i++){
    63         -    pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, n, 0);
           61  +    pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, 0);
    64     62       if( pColl2->xCmp!=0 ){
    65     63         memcpy(pColl, pColl2, sizeof(CollSeq));
    66     64         pColl->xDel = 0;         /* Do not copy the destructor */
    67     65         return SQLITE_OK;
    68     66       }
    69     67     }
    70     68     return SQLITE_ERROR;
................................................................................
    78     76   ** 
    79     77   ** If it is not NULL, then pColl must point to the database native encoding 
    80     78   ** collation sequence with name zName, length nName.
    81     79   **
    82     80   ** The return value is either the collation sequence to be used in database
    83     81   ** db for collation type name zName, length nName, or NULL, if no collation
    84     82   ** sequence can be found.
           83  +**
           84  +** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
    85     85   */
    86     86   CollSeq *sqlite3GetCollSeq(
    87         -  sqlite3* db, 
    88         -  CollSeq *pColl, 
    89         -  const char *zName, 
    90         -  int nName
           87  +  sqlite3* db,          /* The database connection */
           88  +  CollSeq *pColl,       /* Collating sequence with native encoding, or NULL */
           89  +  const char *zName     /* Collating sequence name */
    91     90   ){
    92     91     CollSeq *p;
    93     92   
    94     93     p = pColl;
    95     94     if( !p ){
    96         -    p = sqlite3FindCollSeq(db, ENC(db), zName, nName, 0);
           95  +    p = sqlite3FindCollSeq(db, ENC(db), zName, 0);
    97     96     }
    98     97     if( !p || !p->xCmp ){
    99     98       /* No collation sequence of this type for this encoding is registered.
   100     99       ** Call the collation factory to see if it can supply us with one.
   101    100       */
   102         -    callCollNeeded(db, zName, nName);
   103         -    p = sqlite3FindCollSeq(db, ENC(db), zName, nName, 0);
          101  +    callCollNeeded(db, zName);
          102  +    p = sqlite3FindCollSeq(db, ENC(db), zName, 0);
   104    103     }
   105    104     if( p && !p->xCmp && synthCollSeq(db, p) ){
   106    105       p = 0;
   107    106     }
   108    107     assert( !p || p->xCmp );
   109    108     return p;
   110    109   }
................................................................................
   119    118   ** request a definition of the collating sequence. If this doesn't work, 
   120    119   ** an equivalent collating sequence that uses a text encoding different
   121    120   ** from the main database is substituted, if one is available.
   122    121   */
   123    122   int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){
   124    123     if( pColl ){
   125    124       const char *zName = pColl->zName;
   126         -    CollSeq *p = sqlite3GetCollSeq(pParse->db, pColl, zName, -1);
          125  +    CollSeq *p = sqlite3GetCollSeq(pParse->db, pColl, zName);
   127    126       if( !p ){
   128    127         if( pParse->nErr==0 ){
   129    128           sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
   130    129         }
   131    130         pParse->nErr++;
   132    131         return SQLITE_ERROR;
   133    132       }
................................................................................
   148    147   ** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be.
   149    148   **
   150    149   ** Stored immediately after the three collation sequences is a copy of
   151    150   ** the collation sequence name. A pointer to this string is stored in
   152    151   ** each collation sequence structure.
   153    152   */
   154    153   static CollSeq *findCollSeqEntry(
   155         -  sqlite3 *db,
   156         -  const char *zName,
   157         -  int nName,
   158         -  int create
          154  +  sqlite3 *db,          /* Database connection */
          155  +  const char *zName,    /* Name of the collating sequence */
          156  +  int create            /* Create a new entry if true */
   159    157   ){
   160    158     CollSeq *pColl;
   161         -  if( nName<0 ) nName = sqlite3Strlen30(zName);
          159  +  int nName = sqlite3Strlen30(zName);
   162    160     pColl = sqlite3HashFind(&db->aCollSeq, zName, nName);
   163    161   
   164    162     if( 0==pColl && create ){
   165    163       pColl = sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName + 1 );
   166    164       if( pColl ){
   167    165         CollSeq *pDel = 0;
   168    166         pColl[0].zName = (char*)&pColl[3];
................................................................................
   198    196   ** If the entry specified is not found and 'create' is true, then create a
   199    197   ** new entry.  Otherwise return NULL.
   200    198   **
   201    199   ** A separate function sqlite3LocateCollSeq() is a wrapper around
   202    200   ** this routine.  sqlite3LocateCollSeq() invokes the collation factory
   203    201   ** if necessary and generates an error message if the collating sequence
   204    202   ** cannot be found.
          203  +**
          204  +** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()
   205    205   */
   206    206   CollSeq *sqlite3FindCollSeq(
   207    207     sqlite3 *db,
   208    208     u8 enc,
   209    209     const char *zName,
   210         -  int nName,
   211    210     int create
   212    211   ){
   213    212     CollSeq *pColl;
   214    213     if( zName ){
   215         -    pColl = findCollSeqEntry(db, zName, nName, create);
          214  +    pColl = findCollSeqEntry(db, zName, create);
   216    215     }else{
   217    216       pColl = db->pDfltColl;
   218    217     }
   219    218     assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
   220    219     assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );
   221    220     if( pColl ) pColl += enc-1;
   222    221     return pColl;

Changes to src/expr.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 routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.433 2009/05/09 00:18:38 drh Exp $
           15  +** $Id: expr.c,v 1.434 2009/05/11 20:53:29 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Return the 'affinity' of the expression pExpr if any.
    21     21   **
    22     22   ** If pExpr is a column, a reference to a column via an 'AS' alias,
................................................................................
    65     65   */
    66     66   Expr *sqlite3ExprSetColl(Parse *pParse, Expr *pExpr, Token *pCollName){
    67     67     char *zColl = 0;            /* Dequoted name of collation sequence */
    68     68     CollSeq *pColl;
    69     69     sqlite3 *db = pParse->db;
    70     70     zColl = sqlite3NameFromToken(db, pCollName);
    71     71     if( pExpr && zColl ){
    72         -    pColl = sqlite3LocateCollSeq(pParse, zColl, -1);
           72  +    pColl = sqlite3LocateCollSeq(pParse, zColl);
    73     73       if( pColl ){
    74     74         pExpr->pColl = pColl;
    75     75         pExpr->flags |= EP_ExpCollate;
    76     76       }
    77     77     }
    78     78     sqlite3DbFree(db, zColl);
    79     79     return pExpr;
................................................................................
    95     95         /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally
    96     96         ** a TK_COLUMN but was previously evaluated and cached in a register */
    97     97         const char *zColl;
    98     98         int j = p->iColumn;
    99     99         if( j>=0 ){
   100    100           sqlite3 *db = pParse->db;
   101    101           zColl = p->pTab->aCol[j].zColl;
   102         -        pColl = sqlite3FindCollSeq(db, ENC(db), zColl, -1, 0);
          102  +        pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);
   103    103           pExpr->pColl = pColl;
   104    104         }
   105    105         break;
   106    106       }
   107    107       if( op!=TK_CAST && op!=TK_UPLUS ){
   108    108         break;
   109    109       }
................................................................................
  1373   1373         ** it is not, it is not possible to use any index.
  1374   1374         */
  1375   1375         char aff = comparisonAffinity(pX);
  1376   1376         int affinity_ok = (pTab->aCol[iCol].affinity==aff||aff==SQLITE_AFF_NONE);
  1377   1377   
  1378   1378         for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){
  1379   1379           if( (pIdx->aiColumn[0]==iCol)
  1380         -         && (pReq==sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], -1, 0))
         1380  +         && (pReq==sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], 0))
  1381   1381            && (!mustBeUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None))
  1382   1382           ){
  1383   1383             int iMem = ++pParse->nMem;
  1384   1384             int iAddr;
  1385   1385             char *pKey;
  1386   1386     
  1387   1387             pKey = (char *)sqlite3IndexKeyinfo(pParse, pIdx);

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.550 2009/05/09 18:59:42 drh Exp $
           17  +** $Id: main.c,v 1.551 2009/05/11 20:53:29 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   
    21     21   #ifdef SQLITE_ENABLE_FTS3
    22     22   # include "fts3.h"
    23     23   #endif
    24     24   #ifdef SQLITE_ENABLE_RTREE
................................................................................
  1357   1357     int enc, 
  1358   1358     void* pCtx,
  1359   1359     int(*xCompare)(void*,int,const void*,int,const void*),
  1360   1360     void(*xDel)(void*)
  1361   1361   ){
  1362   1362     CollSeq *pColl;
  1363   1363     int enc2;
  1364         -  int nName;
         1364  +  int nName = sqlite3Strlen30(zName);
  1365   1365     
  1366   1366     assert( sqlite3_mutex_held(db->mutex) );
  1367   1367   
  1368   1368     /* If SQLITE_UTF16 is specified as the encoding type, transform this
  1369   1369     ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
  1370   1370     ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
  1371   1371     */
................................................................................
  1379   1379       return SQLITE_MISUSE;
  1380   1380     }
  1381   1381   
  1382   1382     /* Check if this call is removing or replacing an existing collation 
  1383   1383     ** sequence. If so, and there are active VMs, return busy. If there
  1384   1384     ** are no active VMs, invalidate any pre-compiled statements.
  1385   1385     */
  1386         -  nName = sqlite3Strlen30(zName);
  1387         -  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, nName, 0);
         1386  +  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0);
  1388   1387     if( pColl && pColl->xCmp ){
  1389   1388       if( db->activeVdbeCnt ){
  1390   1389         sqlite3Error(db, SQLITE_BUSY, 
  1391   1390           "unable to delete/modify collation sequence due to active statements");
  1392   1391         return SQLITE_BUSY;
  1393   1392       }
  1394   1393       sqlite3ExpirePreparedStatements(db);
................................................................................
  1410   1409             }
  1411   1410             p->xCmp = 0;
  1412   1411           }
  1413   1412         }
  1414   1413       }
  1415   1414     }
  1416   1415   
  1417         -  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, nName, 1);
         1416  +  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 1);
  1418   1417     if( pColl ){
  1419   1418       pColl->xCmp = xCompare;
  1420   1419       pColl->pUser = pCtx;
  1421   1420       pColl->xDel = xDel;
  1422   1421       pColl->enc = (u8)(enc2 | (enc & SQLITE_UTF16_ALIGNED));
  1423   1422     }
  1424   1423     sqlite3Error(db, SQLITE_OK, 0);
................................................................................
  1599   1598     createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc, 0);
  1600   1599     createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc, 0);
  1601   1600     createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc, 0);
  1602   1601     createCollation(db, "RTRIM", SQLITE_UTF8, (void*)1, binCollFunc, 0);
  1603   1602     if( db->mallocFailed ){
  1604   1603       goto opendb_out;
  1605   1604     }
  1606         -  db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 6, 0);
         1605  +  db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0);
  1607   1606     assert( db->pDfltColl!=0 );
  1608   1607   
  1609   1608     /* Also add a UTF-8 case-insensitive collation sequence. */
  1610   1609     createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);
  1611   1610   
  1612   1611     /* Set flags on the built-in collating sequences */
  1613   1612     db->pDfltColl->type = SQLITE_COLL_BINARY;
  1614         -  pColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "NOCASE", 6, 0);
         1613  +  pColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "NOCASE", 0);
  1615   1614     if( pColl ){
  1616   1615       pColl->type = SQLITE_COLL_NOCASE;
  1617   1616     }
  1618   1617   
  1619   1618     /* Open the backend database driver */
  1620   1619     db->openFlags = flags;
  1621   1620     rc = sqlite3BtreeFactory(db, zFilename, 0, SQLITE_DEFAULT_CACHE_SIZE, 

Changes to src/prepare.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains the implementation of the sqlite3_prepare()
    13     13   ** interface, and routines that contribute to loading the database schema
    14     14   ** from disk.
    15     15   **
    16         -** $Id: prepare.c,v 1.117 2009/04/20 17:43:03 drh Exp $
           16  +** $Id: prepare.c,v 1.118 2009/05/11 20:53:29 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   
    20     20   /*
    21     21   ** Fill the InitData structure with an error message that indicates
    22     22   ** that the database is corrupt.
    23     23   */
................................................................................
   254    254     ** For an attached db, it is an error if the encoding is not the same
   255    255     ** as sqlite3.enc.
   256    256     */
   257    257     if( meta[4] ){  /* text encoding */
   258    258       if( iDb==0 ){
   259    259         /* If opening the main database, set ENC(db). */
   260    260         ENC(db) = (u8)meta[4];
   261         -      db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 6, 0);
          261  +      db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0);
   262    262       }else{
   263    263         /* If opening an attached database, the encoding much match ENC(db) */
   264    264         if( meta[4]!=ENC(db) ){
   265    265           sqlite3SetString(pzErrMsg, db, "attached databases must use the same"
   266    266               " text encoding as main database");
   267    267           rc = SQLITE_ERROR;
   268    268           goto initone_error_out;

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.512 2009/05/03 20:23:54 drh Exp $
           15  +** $Id: select.c,v 1.513 2009/05/11 20:53:29 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.
................................................................................
  1219   1219     memset(&sNC, 0, sizeof(sNC));
  1220   1220     sNC.pSrcList = pSelect->pSrc;
  1221   1221     a = pSelect->pEList->a;
  1222   1222     for(i=0, pCol=aCol; i<nCol; i++, pCol++){
  1223   1223       p = a[i].pExpr;
  1224   1224       pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p, 0, 0, 0));
  1225   1225       pCol->affinity = sqlite3ExprAffinity(p);
         1226  +    if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;
  1226   1227       pColl = sqlite3ExprCollSeq(pParse, p);
  1227   1228       if( pColl ){
  1228   1229         pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
  1229   1230       }
  1230   1231     }
  1231   1232   }
  1232   1233   

Changes to src/sqliteInt.h.

     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   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.869 2009/05/07 14:11:52 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.870 2009/05/11 20:53:29 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** Include the configuration header output by 'configure' if we're using the
    21     21   ** autoconf-based build
................................................................................
  2637   2637   char sqlite3ExprAffinity(Expr *pExpr);
  2638   2638   int sqlite3Atoi64(const char*, i64*);
  2639   2639   void sqlite3Error(sqlite3*, int, const char*,...);
  2640   2640   void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
  2641   2641   int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
  2642   2642   const char *sqlite3ErrStr(int);
  2643   2643   int sqlite3ReadSchema(Parse *pParse);
  2644         -CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char *,int,int);
  2645         -CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName, int nName);
         2644  +CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
         2645  +CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
  2646   2646   CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
  2647   2647   Expr *sqlite3ExprSetColl(Parse *pParse, Expr *, Token *);
  2648   2648   int sqlite3CheckCollSeq(Parse *, CollSeq *);
  2649   2649   int sqlite3CheckObjectName(Parse *, const char *);
  2650   2650   void sqlite3VdbeSetChanges(sqlite3 *, int);
  2651   2651   
  2652   2652   const void *sqlite3ValueText(sqlite3_value*, u8);
................................................................................
  2676   2676   void sqlite3SelectPrep(Parse*, Select*, NameContext*);
  2677   2677   int sqlite3ResolveExprNames(NameContext*, Expr*);
  2678   2678   void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
  2679   2679   int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
  2680   2680   void sqlite3ColumnDefault(Vdbe *, Table *, int);
  2681   2681   void sqlite3AlterFinishAddColumn(Parse *, Token *);
  2682   2682   void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
  2683         -CollSeq *sqlite3GetCollSeq(sqlite3*, CollSeq *, const char *, int);
         2683  +CollSeq *sqlite3GetCollSeq(sqlite3*, CollSeq *, const char*);
  2684   2684   char sqlite3AffinityType(const Token*);
  2685   2685   void sqlite3Analyze(Parse*, Token*, Token*);
  2686   2686   int sqlite3InvokeBusyHandler(BusyHandler*);
  2687   2687   int sqlite3FindDb(sqlite3*, Token*);
  2688   2688   int sqlite3FindDbName(sqlite3 *, const char *);
  2689   2689   int sqlite3AnalysisLoad(sqlite3*,int iDB);
  2690   2690   void sqlite3DefaultRowEst(Index*);

Changes to test/table.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the CREATE TABLE statement.
    13     13   #
    14         -# $Id: table.test,v 1.51 2009/04/28 15:43:45 drh Exp $
           14  +# $Id: table.test,v 1.52 2009/05/11 20:53:29 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a basic table and verify it is added to sqlite_master
    20     20   #
    21     21   do_test table-1.1 {
................................................................................
   333    333     }
   334    334   } {desc a asc b key 9 14_vac 0 fuzzy_dog_12 xyz begin hi end y'all}
   335    335   do_test table-8.1.1 {
   336    336     execsql {
   337    337       SELECT sql FROM sqlite_master WHERE name='t2';
   338    338     }
   339    339   } {{CREATE TABLE t2(
   340         -  "desc" text,
   341         -  "asc" text,
   342         -  "key" int,
   343         -  "14_vac" boolean,
   344         -  fuzzy_dog_12 varchar(10),
   345         -  "begin" blob,
   346         -  "end" clob
          340  +  "desc" TEXT,
          341  +  "asc" TEXT,
          342  +  "key" INT,
          343  +  "14_vac" NUM,
          344  +  fuzzy_dog_12 TEXT,
          345  +  "begin",
          346  +  "end" TEXT
   347    347   )}}
   348    348   do_test table-8.2 {
   349    349     execsql {
   350    350       CREATE TABLE "t3""xyz"(a,b,c);
   351    351       INSERT INTO [t3"xyz] VALUES(1,2,3);
   352    352       SELECT * FROM [t3"xyz];
   353    353     }
................................................................................
   402    402   
   403    403   do_test table-8.9 {
   404    404     execsql {
   405    405       CREATE TABLE t10("col.1" [char.3]);
   406    406       CREATE TABLE t11 AS SELECT * FROM t10;
   407    407       SELECT sql FROM sqlite_master WHERE name = 't11';
   408    408     }
   409         -} {{CREATE TABLE t11("col.1" "char.3")}}
          409  +} {{CREATE TABLE t11("col.1" TEXT)}}
   410    410   do_test table-8.10 {
   411    411     execsql {
   412    412       CREATE TABLE t12(
   413    413         a INTEGER,
   414    414         b VARCHAR(10),
   415    415         c VARCHAR(1,10),
   416    416         d VARCHAR(+1,-10),
................................................................................
   418    418         f "VARCHAR (+1,-10, 5)",
   419    419         g BIG INTEGER
   420    420       );
   421    421       CREATE TABLE t13 AS SELECT * FROM t12;
   422    422       SELECT sql FROM sqlite_master WHERE name = 't13';
   423    423     }
   424    424   } {{CREATE TABLE t13(
   425         -  a INTEGER,
   426         -  b VARCHAR(10),
   427         -  c VARCHAR(1,10),
   428         -  d VARCHAR(+1,-10),
   429         -  e VARCHAR (+1,-10),
   430         -  f "VARCHAR (+1,-10, 5)",
   431         -  g "BIG INTEGER"
          425  +  a INT,
          426  +  b TEXT,
          427  +  c TEXT,
          428  +  d TEXT,
          429  +  e TEXT,
          430  +  f TEXT,
          431  +  g INT
   432    432   )}}
   433    433   
   434    434   # Make sure we cannot have duplicate column names within a table.
   435    435   #
   436    436   do_test table-9.1 {
   437    437     catchsql {
   438    438       CREATE TABLE t6(a,b,a);
................................................................................
   581    581       }
   582    582     }
   583    583   } {}
   584    584   do_test table-12.2 {
   585    585     execsql {
   586    586       SELECT sql FROM sqlite_master WHERE tbl_name = 't8'
   587    587     }
   588         -} {{CREATE TABLE t8(b number(5,10),h,i integer,j BLOB)}}
          588  +} {{CREATE TABLE t8(b NUM,h,i INT,j)}}
   589    589   
   590    590   #--------------------------------------------------------------------
   591    591   # Test cases table-13.*
   592    592   #
   593    593   # Test the ability to have default values of CURRENT_TIME, CURRENT_DATE
   594    594   # and CURRENT_TIMESTAMP.
   595    595   #