SQLite

Check-in [9ddfe1e413]
Login

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

Overview
Comment:Disable the xfer optimization if "PRAGMA count_changes=1" is configured. Ticket [c48d99d690].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9ddfe1e41300413bc9af7e5ce0ec9d1daf9136b1
User & Date: dan 2011-09-30 12:01:01.579
References
2011-09-30
12:19 Closed ticket [c48d99d690]: Crash in "INSERT INTO ... SELECT" when "PRAGMA count_changes=1" is configured plus 2 other changes (artifact: 9fbd73a1b8 user: dan)
Context
2011-10-02
05:23
Update MSVC makefile to allow targets to be built with support for ICU. (check-in: eb5da5e1db user: mistachkin tags: trunk)
2011-09-30
12:01
Disable the xfer optimization if "PRAGMA count_changes=1" is configured. Ticket [c48d99d690]. (check-in: 9ddfe1e413 user: dan tags: trunk)
2011-09-28
01:10
In the shell, allow arbitrary table names on the ".import" command. Ticket [d1d84037b90a449]. (check-in: f4dd32d30e user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/insert.c.
1743
1744
1745
1746
1747
1748
1749



1750
1751
1752
1753
1754
1755
1756
  ** the extra complication to make this rule less restrictive is probably
  ** not worth the effort.  Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
  */
  if( (pParse->db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){
    return 0;
  }
#endif




  /* If we get this far, it means either:
  **
  **    *   We can always do the transfer if the table contains an
  **        an integer primary key
  **
  **    *   We can conditionally do the transfer if the destination







>
>
>







1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
  ** the extra complication to make this rule less restrictive is probably
  ** not worth the effort.  Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
  */
  if( (pParse->db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){
    return 0;
  }
#endif
  if( (pParse->db->flags & SQLITE_CountRows)!=0 ){
    return 0;
  }

  /* If we get this far, it means either:
  **
  **    *   We can always do the transfer if the table contains an
  **        an integer primary key
  **
  **    *   We can conditionally do the transfer if the destination
Changes to src/vacuum.c.
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    return SQLITE_NOMEM;
  }
  if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){
    sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db));
    return sqlite3_errcode(db);
  }
  VVA_ONLY( rc = ) sqlite3_step(pStmt);
  assert( rc!=SQLITE_ROW );
  return vacuumFinalize(db, pStmt, pzErrMsg);
}

/*
** Execute zSql on database db. The statement returns exactly
** one column. Execute this as SQL on the same database.
*/







|







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    return SQLITE_NOMEM;
  }
  if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){
    sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db));
    return sqlite3_errcode(db);
  }
  VVA_ONLY( rc = ) sqlite3_step(pStmt);
  assert( rc!=SQLITE_ROW || (db->flags&SQLITE_CountRows) );
  return vacuumFinalize(db, pStmt, pzErrMsg);
}

/*
** Execute zSql on database db. The statement returns exactly
** one column. Execute this as SQL on the same database.
*/
Added test/tkt-c48d99d690.test.




















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

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

set ::testprefix tkt-c48d99d690

do_test 1.0 {
  execsql {
    CREATE TABLE t1(a, b);
    CREATE TABLE t2(a, b);
    INSERT INTO t1 VALUES('one'  , 1);
    INSERT INTO t1 VALUES('two'  , 5);
    INSERT INTO t1 VALUES('two'  , 2);
    INSERT INTO t1 VALUES('three', 3);
    PRAGMA count_changes = 1;
  }
} {}

do_test 1.1 {
  execsql { INSERT INTO t2 SELECT * FROM t1 }
} {4}

do_test 1.2 { execsql VACUUM } {}

finish_test

Changes to test/vacuum.test.
380
381
382
383
384
385
386
















387
388
      VACUUM;
    }
    cksum
  } $::cksum
}

forcedelete {a'z.db}

















finish_test







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


380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
      VACUUM;
    }
    cksum
  } $::cksum
}

forcedelete {a'z.db}

# Test that "PRAGMA count_changes" does not interfere with VACUUM or cause
# it to return any rows to the user.
#
do_test vacuum-10.1 {
  db close
  forcedelete test.db
  sqlite3 db test.db
  execsql {
    CREATE TABLE t8(a, b);
    INSERT INTO t8 VALUES('a', 'b');
    INSERT INTO t8 VALUES('c', 'd');
    PRAGMA count_changes = 1;
  }
} {}
do_test vacuum-10.2 { execsql VACUUM } {}

finish_test