/ Check-in [62667129]
Login

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

Overview
Comment:Use randomness to prevent slowness in the generated-column-name uniqueness checking.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6266712968a2cdcd6f5a3007d60c2cf1b3faf912
User & Date: drh 2015-11-14 16:47:23
Original Comment: Use randomness to prevent showness in the generated-column-name uniqueness checking.
Context
2015-11-14
20:52
Use a hash table to improve the preformance of column name uniqueness checking. check-in: 5b08f29f user: drh tags: trunk
16:47
Use randomness to prevent slowness in the generated-column-name uniqueness checking. check-in: 62667129 user: drh tags: trunk
2015-11-13
20:52
Fix a memory leak in the fuzzcheck utility. check-in: dfd6d9f4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  1592   1592     Parse *pParse,          /* Parsing context */
  1593   1593     ExprList *pEList,       /* Expr list from which to derive column names */
  1594   1594     i16 *pnCol,             /* Write the number of columns here */
  1595   1595     Column **paCol          /* Write the new column list here */
  1596   1596   ){
  1597   1597     sqlite3 *db = pParse->db;   /* Database connection */
  1598   1598     int i, j;                   /* Loop counters */
  1599         -  int cnt;                    /* Index added to make the name unique */
         1599  +  u32 cnt;                    /* Index added to make the name unique */
  1600   1600     Column *aCol, *pCol;        /* For looping over result columns */
  1601   1601     int nCol;                   /* Number of columns in the result set */
  1602   1602     Expr *p;                    /* Expression for a single result column */
  1603   1603     char *zName;                /* Column name */
  1604   1604     int nName;                  /* Size of name in zName[] */
  1605   1605   
  1606   1606     if( pEList ){
................................................................................
  1655   1655       for(j=cnt=0; j<i; j++){
  1656   1656         if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
  1657   1657           char *zNewName;
  1658   1658           int k;
  1659   1659           for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}
  1660   1660           if( k>=0 && zName[k]==':' ) nName = k;
  1661   1661           zName[nName] = 0;
  1662         -        zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt);
         1662  +        zNewName = sqlite3MPrintf(db, "%s:%u", zName, ++cnt);
  1663   1663           sqlite3DbFree(db, zName);
  1664   1664           zName = zNewName;
  1665   1665           j = -1;
  1666   1666           if( zName==0 ) break;
         1667  +        if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);
  1667   1668         }
  1668   1669       }
  1669   1670       pCol->zName = zName;
  1670   1671     }
  1671   1672     if( db->mallocFailed ){
  1672   1673       for(j=0; j<i; j++){
  1673   1674         sqlite3DbFree(db, aCol[j].zName);