SQLite

Check-in [791761ebac]
Login

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

Overview
Comment:Fix the column name uniquifier so that it works with zero-length column names.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 791761ebac26c82ab67bdf867117ec5b5d8b20b0
User & Date: drh 2015-11-15 11:13:49.647
Context
2015-11-16
08:54
In the shell tool, avoid testing if (sqlite3_vfs.xGetCurrentInt64) is NULL for a version 1 VFS. This field is only defined for version 2 and greater. (check-in: ad5fcaa583 user: dan tags: trunk)
2015-11-15
11:13
Fix the column name uniquifier so that it works with zero-length column names. (check-in: 791761ebac user: drh tags: trunk)
2015-11-14
22:04
Code simplification in sqlite3ColumnsFromExprList(). Update the %z format code so that it works with buffers obtained from sqlite3DbMalloc(). Add a testcase for the slow column name uniquifier. (check-in: 9272426057 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/select.c.
1647
1648
1649
1650
1651
1652
1653

1654
1655

1656
1657
1658
1659
1660
1661
1662

    /* Make sure the column name is unique.  If the name is not unique,
    ** append an integer to the name so that it becomes unique.
    */
    cnt = 0;
    while( zName && sqlite3HashFind(&ht, zName)!=0 ){
      nName = sqlite3Strlen30(zName);

      for(j=nName-1; j>0 && sqlite3Isdigit(zName[j]); j--){}
      if( zName[j]==':' ) nName = j;

      zName = sqlite3MPrintf(db, "%.*z:%u", nName, zName, ++cnt);
      if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);
    }
    pCol->zName = zName;
    if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){
      db->mallocFailed = 1;
    }







>
|
|
>







1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664

    /* Make sure the column name is unique.  If the name is not unique,
    ** append an integer to the name so that it becomes unique.
    */
    cnt = 0;
    while( zName && sqlite3HashFind(&ht, zName)!=0 ){
      nName = sqlite3Strlen30(zName);
      if( nName>0 ){
        for(j=nName-1; j>0 && sqlite3Isdigit(zName[j]); j--){}
        if( zName[j]==':' ) nName = j;
      }
      zName = sqlite3MPrintf(db, "%.*z:%u", nName, zName, ++cnt);
      if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);
    }
    pCol->zName = zName;
    if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){
      db->mallocFailed = 1;
    }