SQLite

Check-in [9e6beda2c8]
Login

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

Overview
Comment:Make sure the datatype and collating sequence of transients tables are not initialized more than once. Otherwise a memory leak results.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9e6beda2c8d879e438ee933e658f860d6eb42a20
User & Date: drh 2015-04-21 17:07:01.179
Context
2015-04-21
17:17
Alternative fix for the double-initialization of type and collating sequence problem that leaves the estimated table size intact. (check-in: 623ddbdbf4 user: drh tags: trunk)
17:07
Make sure the datatype and collating sequence of transients tables are not initialized more than once. Otherwise a memory leak results. (check-in: 9e6beda2c8 user: drh tags: trunk)
16:38
Ensure that tables names are dequoted exactly once by the trigger logic. (check-in: 9d887b92f8 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/select.c.
1696
1697
1698
1699
1700
1701
1702


1703
1704
1705
1706
1707
1708
1709
  assert( pTab->nCol==pSelect->pEList->nExpr || db->mallocFailed );
  if( db->mallocFailed ) return;
  memset(&sNC, 0, sizeof(sNC));
  sNC.pSrcList = pSelect->pSrc;
  a = pSelect->pEList->a;
  for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
    p = a[i].pExpr;


    pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst));
    szAll += pCol->szEst;
    pCol->affinity = sqlite3ExprAffinity(p);
    if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;
    pColl = sqlite3ExprCollSeq(pParse, p);
    if( pColl ){
      pCol->zColl = sqlite3DbStrDup(db, pColl->zName);







>
>







1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
  assert( pTab->nCol==pSelect->pEList->nExpr || db->mallocFailed );
  if( db->mallocFailed ) return;
  memset(&sNC, 0, sizeof(sNC));
  sNC.pSrcList = pSelect->pSrc;
  a = pSelect->pEList->a;
  for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
    p = a[i].pExpr;
    if( pCol->zType ) break;
    if( pCol->zColl ) break;
    pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst));
    szAll += pCol->szEst;
    pCol->affinity = sqlite3ExprAffinity(p);
    if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;
    pColl = sqlite3ExprCollSeq(pParse, p);
    if( pColl ){
      pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
Changes to test/subquery.test.
579
580
581
582
583
584
585










586
587
} {30101 30102 30103}
do_test subquery-7.11 {
  execsql {
    SELECT (SELECT (SELECT max(c7)+max(c8)+max(c9) FROM t9) FROM t8) FROM t7
  }
} {30303}
}  ;############# Disabled











finish_test







>
>
>
>
>
>
>
>
>
>


579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
} {30101 30102 30103}
do_test subquery-7.11 {
  execsql {
    SELECT (SELECT (SELECT max(c7)+max(c8)+max(c9) FROM t9) FROM t8) FROM t7
  }
} {30303}
}  ;############# Disabled

# 2015-04-21.
# Verify that a memory leak in the table column type and collation analysis
# is plugged.
#
do_execsql_test subquery-8.1 {
  CREATE TABLE t8(a TEXT, b INT);
  SELECT (SELECT 0 FROM (SELECT * FROM t1)) AS x WHERE x;
  SELECT (SELECT 0 FROM (SELECT * FROM (SELECT 0))) AS x WHERE x;
} {}

finish_test