/ Check-in [cdc7608b]
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:Fix a memory leak introduced by (3842) associated with ticket #2296. (CVS 3848)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cdc7608b8d590b2ca19be37f94f2cd17423ba8ac
User & Date: drh 2007-04-16 17:07:55
Context
2007-04-17
08:32
Avoid reloading the db schema after a failed OP_VerifyCookie if the in-memory schema cookie already matches the database file. (CVS 3849) check-in: 61c1d06d user: danielk1977 tags: trunk
2007-04-16
17:07
Fix a memory leak introduced by (3842) associated with ticket #2296. (CVS 3848) check-in: cdc7608b user: drh tags: trunk
15:49
Add test cases to make sure virtual tables cannot be used in shared-cache mode. (CVS 3847) check-in: 66e468ad user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1417
1418
1419
1420
1421
1422
1423

1424
1425
1426
1427
1428
1429


1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.337 2007/04/16 15:06:25 danielk1977 Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
      }
      if( !mustComplete ) continue;
      iCol--;
    }
    if( iCol<0 && (zLabel = sqlite3NameFromToken(&pE->token))!=0 ){
      for(j=0, pItem=pEList->a; j<pEList->nExpr; j++, pItem++){
        char *zName;

        if( pItem->zName ){
          zName = sqlite3StrDup(pItem->zName);
        }else{
          zName = sqlite3NameFromToken(&pItem->pExpr->token);
        }
        if( zName && sqlite3StrICmp(zName, zLabel)==0 ){


          iCol = j;
          break;
        }
        sqliteFree(zName);
      }
      sqliteFree(zLabel);
    }
    if( iCol>=0 ){
      pE->op = TK_COLUMN;
      pE->iColumn = iCol;
      pE->iTable = iTable;







|







 







>





|
>
>



<







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435

1436
1437
1438
1439
1440
1441
1442
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.338 2007/04/16 17:07:55 drh Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
      }
      if( !mustComplete ) continue;
      iCol--;
    }
    if( iCol<0 && (zLabel = sqlite3NameFromToken(&pE->token))!=0 ){
      for(j=0, pItem=pEList->a; j<pEList->nExpr; j++, pItem++){
        char *zName;
        int isMatch;
        if( pItem->zName ){
          zName = sqlite3StrDup(pItem->zName);
        }else{
          zName = sqlite3NameFromToken(&pItem->pExpr->token);
        }
        isMatch = zName && sqlite3StrICmp(zName, zLabel)==0;
        sqliteFree(zName);
        if( isMatch ){
          iCol = j;
          break;
        }

      }
      sqliteFree(zLabel);
    }
    if( iCol>=0 ){
      pE->op = TK_COLUMN;
      pE->iColumn = iCol;
      pE->iTable = iTable;

Changes to test/all.test.

6
7
8
9
10
11
12
13
14
15
16
17
18


19
20
21
22
23
24
25
..
86
87
88
89
90
91
92







93
94
95
96
97
98
99
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.39 2007/04/02 14:19:16 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test
proc finish_test {} {memleak_check}



if {[file exists ./sqlite_test_count]} {
  set COUNT [exec cat ./sqlite_test_count]
} else {
  set COUNT 3
}

................................................................................
    if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
    source $testfile
    catch {db close}
    if {$sqlite_open_file_count>0} {
      puts "$tail did not close all files: $sqlite_open_file_count"
      incr nErr
      lappend ::failList $tail







    }
  }
  if {[info exists Leak]} {
    lappend LeakList $Leak
  }
}








|




|
>
>







 







>
>
>
>
>
>
>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.40 2007/04/16 17:07:55 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test
proc finish_test {} {
  memleak_check
}

if {[file exists ./sqlite_test_count]} {
  set COUNT [exec cat ./sqlite_test_count]
} else {
  set COUNT 3
}

................................................................................
    if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
    source $testfile
    catch {db close}
    if {$sqlite_open_file_count>0} {
      puts "$tail did not close all files: $sqlite_open_file_count"
      incr nErr
      lappend ::failList $tail
      set sqlite_open_file_count 0
    }
    if {$::sqlite3_tsd_count} {
      puts "Thread-specific data leak: $::sqlite3_tsd_count instances"
      incr nErr
      lappend ::failList $tail
      set ::sqlite3_tsd_count 0
    }
  }
  if {[info exists Leak]} {
    lappend LeakList $Leak
  }
}

Changes to test/insert3.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165

166
167
168
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing corner cases of the INSERT statement.
#
# $Id: insert3.test,v 1.5 2006/08/25 23:42:53 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# All the tests in this file require trigger support
#
ifcapable {trigger} {
................................................................................
  }
} {1 {no such column: nosuchcol}}

} ;# ifcapable {trigger}

# Tests for the INSERT INTO ... DEFAULT VALUES construct
#
do_test insert4-3.5 {
  execsql {
    CREATE TABLE t5(
      a INTEGER PRIMARY KEY,
      b DEFAULT 'xyz'
    );
    INSERT INTO t5 DEFAULT VALUES;
    SELECT * FROM t5;
  }
} {1 xyz}
do_test insert4-3.6 {
  execsql {
    INSERT INTO t5 DEFAULT VALUES;
    SELECT * FROM t5;
  }
} {1 xyz 2 xyz}
do_test insert4-3.7 {
  execsql {
    CREATE TABLE t6(x,y DEFAULT 4.3, z DEFAULT x'6869');
    INSERT INTO t6 DEFAULT VALUES;
    SELECT * FROM t6;
  }
} {{} 4.3 hi}



finish_test







|







 







|









|





|






>

<

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167

168
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing corner cases of the INSERT statement.
#
# $Id: insert3.test,v 1.6 2007/04/16 17:07:55 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# All the tests in this file require trigger support
#
ifcapable {trigger} {
................................................................................
  }
} {1 {no such column: nosuchcol}}

} ;# ifcapable {trigger}

# Tests for the INSERT INTO ... DEFAULT VALUES construct
#
do_test insert3-3.5 {
  execsql {
    CREATE TABLE t5(
      a INTEGER PRIMARY KEY,
      b DEFAULT 'xyz'
    );
    INSERT INTO t5 DEFAULT VALUES;
    SELECT * FROM t5;
  }
} {1 xyz}
do_test insert3-3.6 {
  execsql {
    INSERT INTO t5 DEFAULT VALUES;
    SELECT * FROM t5;
  }
} {1 xyz 2 xyz}
do_test insert3-3.7 {
  execsql {
    CREATE TABLE t6(x,y DEFAULT 4.3, z DEFAULT x'6869');
    INSERT INTO t6 DEFAULT VALUES;
    SELECT * FROM t6;
  }
} {{} 4.3 hi}
db close


finish_test

Changes to test/quick.test.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
81
82
83
84
85
86
87







88
89
90
91
92
93
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file runs all tests.
#
# $Id: quick.test,v 1.51 2007/03/31 10:00:49 danielk1977 Exp $

proc lshift {lvar} {
  upvar $lvar l
  set ret [lindex $l 0]
  set l [lrange $l 1 end]
  return $ret
}
................................................................................
  if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
  source $testfile
  catch {db close}
  if {$sqlite_open_file_count>0} {
    puts "$tail did not close all files: $sqlite_open_file_count"
    incr nErr
    lappend ::failList $tail







  }
}
source $testdir/misuse.test

set sqlite_open_file_count 0
really_finish_test







|







 







>
>
>
>
>
>
>






2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file runs all tests.
#
# $Id: quick.test,v 1.52 2007/04/16 17:07:55 drh Exp $

proc lshift {lvar} {
  upvar $lvar l
  set ret [lindex $l 0]
  set l [lrange $l 1 end]
  return $ret
}
................................................................................
  if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
  source $testfile
  catch {db close}
  if {$sqlite_open_file_count>0} {
    puts "$tail did not close all files: $sqlite_open_file_count"
    incr nErr
    lappend ::failList $tail
    set sqlite_open_file_count 0
  }
  if {$::sqlite3_tsd_count} {
    puts "Thread-specific data leak: $::sqlite3_tsd_count instances"
    incr nErr
    lappend ::failList $tail
    set ::sqlite3_tsd_count 0
  }
}
source $testdir/misuse.test

set sqlite_open_file_count 0
really_finish_test