/ Check-in [554501f1]
Login

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

Overview
Comment:Avoid indexing off the front end of an array when creating a view with two or more blank column names in the SELECT statement that defines the view.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:554501f158534f9c27fd51900589c2ab7cf300d8
User & Date: drh 2014-03-04 21:19:51
Context
2014-03-05
11:22
Do not run corruptI.test with the mmap permutation. check-in: 378b290d user: dan tags: trunk
01:29
Experimental simplification of memory flags/type handling. Closed-Leaf check-in: bac2820e user: mistachkin tags: noMemType
2014-03-04
21:19
Avoid indexing off the front end of an array when creating a view with two or more blank column names in the SELECT statement that defines the view. check-in: 554501f1 user: drh tags: trunk
21:00
Fix a problem with "DEFAULT (-(-9223372036854775808))" clauses in ALTER TABLE ... ADD COLUMN commands. check-in: e072cb3e user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
    */
    nName = sqlite3Strlen30(zName);
    for(j=cnt=0; j<i; j++){
      if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
        char *zNewName;
        int k;
        for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}
        if( zName[k]==':' ) nName = k;
        zName[nName] = 0;
        zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt);
        sqlite3DbFree(db, zName);
        zName = zNewName;
        j = -1;
        if( zName==0 ) break;
      }







|







1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
    */
    nName = sqlite3Strlen30(zName);
    for(j=cnt=0; j<i; j++){
      if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
        char *zNewName;
        int k;
        for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}
        if( k>=0 && zName[k]==':' ) nName = k;
        zName[nName] = 0;
        zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt);
        sqlite3DbFree(db, zName);
        zName = zNewName;
        j = -1;
        if( zName==0 ) break;
      }

Changes to test/view.test.

606
607
608
609
610
611
612
613













614
  do_test view-21.2 {
    db progress 1000 {expr 1}
    catchsql {
      SELECT * FROM v32768;
    }
  } {1 interrupted}
}














finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>

606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
  do_test view-21.2 {
    db progress 1000 {expr 1}
    catchsql {
      SELECT * FROM v32768;
    }
  } {1 interrupted}
}

db close
sqlite3 db :memory:
do_execsql_test view-22.1 {
  CREATE VIEW x1 AS SELECT 123 AS '', 234 AS '', 345 AS '';
  SELECT * FROM x1;
} {123 234 345}
do_test view-22.2 {
  unset -nocomplain x
  db eval {SELECT * FROM x1} x break
  lsort [array names x]
} {{} * :1 :2}


finish_test