/ Check-in [533a85ee]
Login

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

Overview
Comment:Fix an assert or memory leak that occurs when trying to EXPLAIN a statement other than a SELECT that outputs results. Examples of such statements include PRAGMA integrity_check or INSERT/DELETE/UPDATE with PRAGMA count_changes=ON. (CVS 2743)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 533a85eee2370aafe204ff3eed50eb7fc0149e83
User & Date: drh 2005-10-05 11:35:09
Context
2005-10-05
11:41
Make sure pragma integrity_check does not report "ok" after first finding a bunch of errors. (CVS 2744) check-in: efec04de user: drh tags: trunk
11:35
Fix an assert or memory leak that occurs when trying to EXPLAIN a statement other than a SELECT that outputs results. Examples of such statements include PRAGMA integrity_check or INSERT/DELETE/UPDATE with PRAGMA count_changes=ON. (CVS 2743) check-in: 533a85ee user: drh tags: trunk
10:40
Changes to support TEA on cygwin. (CVS 2742) check-in: e80fecc9 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

853
854
855
856
857
858
859
860

861
862
863
864
865
866
867
868
869
** statement. This is now set at compile time, rather than during
** execution of the vdbe program so that sqlite3_column_count() can
** be called on an SQL statement before sqlite3_step().
*/
void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
  Mem *pColName;
  int n;
  assert( 0==p->nResColumn );

  p->nResColumn = nResColumn;
  n = nResColumn*2;
  p->aColName = pColName = (Mem*)sqliteMalloc( sizeof(Mem)*n );
  if( p->aColName==0 ) return;
  while( n-- > 0 ){
    (pColName++)->flags = MEM_Null;
  }
}








|
>
|
|







853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
** statement. This is now set at compile time, rather than during
** execution of the vdbe program so that sqlite3_column_count() can
** be called on an SQL statement before sqlite3_step().
*/
void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
  Mem *pColName;
  int n;
  releaseMemArray(p->aColName, p->nResColumn*2);
  sqliteFree(p->aColName);
  n = nResColumn*2;
  p->nResColumn = nResColumn;
  p->aColName = pColName = (Mem*)sqliteMalloc( sizeof(Mem)*n );
  if( p->aColName==0 ) return;
  while( n-- > 0 ){
    (pColName++)->flags = MEM_Null;
  }
}

Changes to test/delete.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
45
46
47
48
49
50
51



52
53
54
55
56
57
58
#    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 the DELETE FROM statement.
#
# $Id: delete.test,v 1.19 2005/05/27 09:41:13 danielk1977 Exp $

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

# Try to delete from a non-existant table.
#
do_test delete-1.1 {
................................................................................
} {}
do_test delete-3.1.3 {
  execsql {SELECT * FROM table1 ORDER BY f1}
} {1 2 2 4 4 16}
do_test delete-3.1.4 {
  execsql {CREATE INDEX index1 ON table1(f1)}
  execsql {PRAGMA count_changes=on}



  execsql {DELETE FROM 'table1' WHERE f1=3}
} {0}
do_test delete-3.1.5 {
  execsql {SELECT * FROM table1 ORDER BY f1}
} {1 2 2 4 4 16}
do_test delete-3.1.6.1 {
  execsql {DELETE FROM table1 WHERE f1=2}







|







 







>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#    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 the DELETE FROM statement.
#
# $Id: delete.test,v 1.20 2005/10/05 11:35:09 drh Exp $

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

# Try to delete from a non-existant table.
#
do_test delete-1.1 {
................................................................................
} {}
do_test delete-3.1.3 {
  execsql {SELECT * FROM table1 ORDER BY f1}
} {1 2 2 4 4 16}
do_test delete-3.1.4 {
  execsql {CREATE INDEX index1 ON table1(f1)}
  execsql {PRAGMA count_changes=on}
  ifcapable explain {
    execsql {EXPLAIN DELETE FROM table1 WHERE f1=3}
  }
  execsql {DELETE FROM 'table1' WHERE f1=3}
} {0}
do_test delete-3.1.5 {
  execsql {SELECT * FROM table1 ORDER BY f1}
} {1 2 2 4 4 16}
do_test delete-3.1.6.1 {
  execsql {DELETE FROM table1 WHERE f1=2}

Changes to test/insert2.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
30
31
32
33
34
35
36







37
38
39
40
41
42
43
...
265
266
267
268
269
270
271
272
#    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 the INSERT statement that takes is
# result from a SELECT.
#
# $Id: insert2.test,v 1.17 2005/05/29 14:23:13 danielk1977 Exp $

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

# Create some tables with data that we can select against
#
do_test insert2-1.0 {
................................................................................

# Insert into a new table from the old one.
#
do_test insert2-1.1.1 {
  execsql {
    CREATE TABLE t1(log int, cnt int);
    PRAGMA count_changes=on;







    INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log;
  }
} {6}
do_test insert2-1.1.2 {
  db changes
} {6}
do_test insert2-1.1.3 {
................................................................................
      INSERT INTO t2 SELECT (SELECT a FROM t2), 4;
      SELECT * FROM t2;
    }
  } {1 2 1 3 1 4}
}

finish_test








|







 







>
>
>
>
>
>
>







 







<
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
272
273
274
275
276
277
278

#    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 the INSERT statement that takes is
# result from a SELECT.
#
# $Id: insert2.test,v 1.18 2005/10/05 11:35:09 drh Exp $

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

# Create some tables with data that we can select against
#
do_test insert2-1.0 {
................................................................................

# Insert into a new table from the old one.
#
do_test insert2-1.1.1 {
  execsql {
    CREATE TABLE t1(log int, cnt int);
    PRAGMA count_changes=on;
  }
  ifcapable explain {
    execsql {
      EXPLAIN INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log;
    }
  }
  execsql {
    INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log;
  }
} {6}
do_test insert2-1.1.2 {
  db changes
} {6}
do_test insert2-1.1.3 {
................................................................................
      INSERT INTO t2 SELECT (SELECT a FROM t2), 4;
      SELECT * FROM t2;
    }
  } {1 2 1 3 1 4}
}

finish_test