SQLite

Check-in [02b751fb9d]
Login

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

Overview
Comment:Fix a bug in jrnlTruncate(). And other coverage improvements. (CVS 4367)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 02b751fb9dbc683b1b77a2ed3cdeb4190f7339e0
User & Date: danielk1977 2007-09-01 18:24:55.000
Context
2007-09-02
17:50
Fix function name typo in mem1.c. This bug managed to make it into the tree because the code in mem1.c is only compiled when the -DSQLITE_MEMDEBUG compile-time option is omitted. But pre-checkin tests usually include this option. Ticket #2612. (CVS 4368) (check-in: 59e02db240 user: drh tags: trunk)
2007-09-01
18:24
Fix a bug in jrnlTruncate(). And other coverage improvements. (CVS 4367) (check-in: 02b751fb9d user: danielk1977 tags: trunk)
18:17
Comment changes in sqlite.h.in in order to generate better capi3ref.html documentation. (CVS 4366) (check-in: 2804745956 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/auth.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** This file contains code used to implement the sqlite3_set_authorizer()
** API.  This facility is an optional feature of the library.  Embedded
** systems that do not need this facility may omit it by recompiling
** the library with -DSQLITE_OMIT_AUTHORIZATION=1
**
** $Id: auth.c,v 1.27 2007/08/21 19:33:56 drh Exp $
*/
#include "sqliteInt.h"

/*
** All of the code in this file may be omitted by defining a single
** macro.
*/







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** This file contains code used to implement the sqlite3_set_authorizer()
** API.  This facility is an optional feature of the library.  Embedded
** systems that do not need this facility may omit it by recompiling
** the library with -DSQLITE_OMIT_AUTHORIZATION=1
**
** $Id: auth.c,v 1.28 2007/09/01 18:24:55 danielk1977 Exp $
*/
#include "sqliteInt.h"

/*
** All of the code in this file may be omitted by defining a single
** macro.
*/
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
void sqlite3AuthRead(
  Parse *pParse,        /* The parser context */
  Expr *pExpr,          /* The expression to check authorization on */
  SrcList *pTabList     /* All table that pExpr might refer to */
){
  sqlite3 *db = pParse->db;
  int rc;
  Table *pTab;          /* The table being read */
  const char *zCol;     /* Name of the column of the table */
  int iSrc;             /* Index in pTabList->a[] of table being read */
  const char *zDBase;   /* Name of database being accessed */
  TriggerStack *pStack; /* The stack of current triggers */
  int iDb;              /* The index of the database the expression refers to */

  if( db->xAuth==0 ) return;







|







105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
void sqlite3AuthRead(
  Parse *pParse,        /* The parser context */
  Expr *pExpr,          /* The expression to check authorization on */
  SrcList *pTabList     /* All table that pExpr might refer to */
){
  sqlite3 *db = pParse->db;
  int rc;
  Table *pTab = 0;      /* The table being read */
  const char *zCol;     /* Name of the column of the table */
  int iSrc;             /* Index in pTabList->a[] of table being read */
  const char *zDBase;   /* Name of database being accessed */
  TriggerStack *pStack; /* The stack of current triggers */
  int iDb;              /* The index of the database the expression refers to */

  if( db->xAuth==0 ) return;
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
    pTab = pTabList->a[iSrc].pTab;
  }else if( (pStack = pParse->trigStack)!=0 ){
    /* This must be an attempt to read the NEW or OLD pseudo-tables
    ** of a trigger.
    */
    assert( pExpr->iTable==pStack->newIdx || pExpr->iTable==pStack->oldIdx );
    pTab = pStack->pTab;
  }else{
    return;
  }
  if( pTab==0 ) return;
  if( pExpr->iColumn>=0 ){
    assert( pExpr->iColumn<pTab->nCol );
    zCol = pTab->aCol[pExpr->iColumn].zName;
  }else if( pTab->iPKey>=0 ){
    assert( pTab->iPKey<pTab->nCol );







<
<







131
132
133
134
135
136
137


138
139
140
141
142
143
144
    pTab = pTabList->a[iSrc].pTab;
  }else if( (pStack = pParse->trigStack)!=0 ){
    /* This must be an attempt to read the NEW or OLD pseudo-tables
    ** of a trigger.
    */
    assert( pExpr->iTable==pStack->newIdx || pExpr->iTable==pStack->oldIdx );
    pTab = pStack->pTab;


  }
  if( pTab==0 ) return;
  if( pExpr->iColumn>=0 ){
    assert( pExpr->iColumn<pTab->nCol );
    zCol = pTab->aCol[pExpr->iColumn].zName;
  }else if( pTab->iPKey>=0 ){
    assert( pTab->iPKey<pTab->nCol );
Changes to src/expr.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.311 2007/08/31 17:42:48 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** Return the 'affinity' of the expression pExpr if any.
**







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.312 2007/09/01 18:24:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** Return the 'affinity' of the expression pExpr if any.
**
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
*/
Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){
  if( pLeft==0 ){
    return pRight;
  }else if( pRight==0 ){
    return pLeft;
  }else{
    Expr *p = sqlite3Expr(db, TK_AND, pLeft, pRight, 0);
    if( p==0 ){
      db->mallocFailed = 1;
    }
    return p;
  }
}

/*
** Set the Expr.span field of the given expression to span all
** text between the two given tokens.
*/







|
<
<
<
<







314
315
316
317
318
319
320
321




322
323
324
325
326
327
328
*/
Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){
  if( pLeft==0 ){
    return pRight;
  }else if( pRight==0 ){
    return pLeft;
  }else{
    return sqlite3Expr(db, TK_AND, pLeft, pRight, 0);




  }
}

/*
** Set the Expr.span field of the given expression to span all
** text between the two given tokens.
*/
Changes to src/journal.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
** 2007 August 22
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    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.
**
*************************************************************************
**
** @(#) $Id: journal.c,v 1.4 2007/08/31 18:34:59 drh Exp $
*/

#ifdef SQLITE_ENABLE_ATOMIC_WRITE

/*
** This file implements a special kind of sqlite3_file object used
** by SQLite to create journal files if the atomic-write optimization












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
** 2007 August 22
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    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.
**
*************************************************************************
**
** @(#) $Id: journal.c,v 1.5 2007/09/01 18:24:55 danielk1977 Exp $
*/

#ifdef SQLITE_ENABLE_ATOMIC_WRITE

/*
** This file implements a special kind of sqlite3_file object used
** by SQLite to create journal files if the atomic-write optimization
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
  sqlite_int64 iOfst
){
  int rc = SQLITE_OK;
  JournalFile *p = (JournalFile *)pJfd;
  if( p->pReal ){
    rc = sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);
  }else{
    int n = iAmt;
    memset(zBuf, 0, n);
    if( n+iOfst>p->iSize ){
      rc = SQLITE_IOERR_SHORT_READ;
    }else{
      memcpy(zBuf, &p->zBuf[iOfst], n);
    }
  }
  return rc;
}

/*
** Write data to the file.
*/







<
<
|
<
<
|
<







89
90
91
92
93
94
95


96


97

98
99
100
101
102
103
104
  sqlite_int64 iOfst
){
  int rc = SQLITE_OK;
  JournalFile *p = (JournalFile *)pJfd;
  if( p->pReal ){
    rc = sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);
  }else{


    assert( n+iOfst<=p->iSize );


    memcpy(zBuf, &p->zBuf[iOfst], iAmt);

  }
  return rc;
}

/*
** Write data to the file.
*/
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
** Truncate the file.
*/
static int jrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
  int rc = SQLITE_OK;
  JournalFile *p = (JournalFile *)pJfd;
  if( p->pReal ){
    rc = sqlite3OsTruncate(p->pReal, size);
  }else if( size>p->iSize ){
    p->iSize = size;
  }
  return rc;
}

/*
** Sync the file.







|







130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
** Truncate the file.
*/
static int jrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
  int rc = SQLITE_OK;
  JournalFile *p = (JournalFile *)pJfd;
  if( p->pReal ){
    rc = sqlite3OsTruncate(p->pReal, size);
  }else if( size<p->iSize ){
    p->iSize = size;
  }
  return rc;
}

/*
** Sync the file.
Changes to test/altermalloc.test.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the ALTER TABLE statement and
# specifically out-of-memory conditions within that command.
#
# $Id: altermalloc.test,v 1.5 2007/08/27 23:48:24 drh Exp $
#

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

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable||!memdebug {







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the ALTER TABLE statement and
# specifically out-of-memory conditions within that command.
#
# $Id: altermalloc.test,v 1.6 2007/09/01 18:24:55 danielk1977 Exp $
#

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

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable||!memdebug {
34
35
36
37
38
39
40
41
























42
  }
} -sqlbody {
  CREATE TABLE t1(a int);
  ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT NULL;
  ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT 'default-text';
  ALTER TABLE t1 RENAME TO t2;
}

























finish_test








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

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  }
} -sqlbody {
  CREATE TABLE t1(a int);
  ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT NULL;
  ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT 'default-text';
  ALTER TABLE t1 RENAME TO t2;
}

# Test malloc() failure on an ALTER TABLE on a virtual table.
#
ifcapable vtab {
  do_malloc_test altermalloc-vtab -tclprep {
    sqlite3 db2 test.db 
    register_echo_module [sqlite3_connection_pointer db2]
    db2 eval {
      CREATE TABLE t1(a, b VARCHAR, c INTEGER);
      CREATE VIRTUAL TABLE t1echo USING echo(t1);
    }
    db2 close

    register_echo_module [sqlite3_connection_pointer db]
  } -tclbody {
    set rc [catch {db eval { ALTER TABLE t1echo RENAME TO t1_echo }} msg]
    if {$msg eq "vtable constructor failed: t1echo"} {
      set msg "out of memory"
    }
    if {$rc} {
      error $msg
    }
  }
}

finish_test
Changes to test/expr.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    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 implements regression tests for SQLite library.  The
# focus of this file is testing expressions.
#
# $Id: expr.test,v 1.58 2007/09/01 10:01:13 danielk1977 Exp $

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

# Create a table to work with.
#
execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    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 implements regression tests for SQLite library.  The
# focus of this file is testing expressions.
#
# $Id: expr.test,v 1.59 2007/09/01 18:24:55 danielk1977 Exp $

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

# Create a table to work with.
#
execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
268
269
270
271
272
273
274


275
276
277
278
279
280
281
test_expr expr-5.9c {t1='abc', t2='A%_C'} {t1 LIKE t2} $NCSL
test_expr expr-5.9d {t1='ac', t2='A%_C'} {t1 LIKE t2} 0
test_expr expr-5.10a {t1='abxyzzyc', t2='a%_c'} {t1 LIKE t2} 1
test_expr expr-5.10b {t1='abxyzzyc', t2='A%_C'} {t1 LIKE t2} $NCSL
test_expr expr-5.11 {t1='abc', t2='xyz'} {t1 NOT LIKE t2} 1
test_expr expr-5.12a {t1='abc', t2='abc'} {t1 NOT LIKE t2} 0
test_expr expr-5.12b {t1='abc', t2='ABC'} {t1 NOT LIKE t2} $CSL



# The following tests only work on versions of TCL that support Unicode
#
if {"\u1234"!="u1234"} {
  test_expr expr-5.13a "t1='a\u0080c', t2='a_c'" {t1 LIKE t2} 1
  test_expr expr-5.13b "t1='a\u0080c', t2='A_C'" {t1 LIKE t2} $NCSL
  test_expr expr-5.14a "t1='a\u07FFc', t2='a_c'" {t1 LIKE t2} 1







>
>







268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
test_expr expr-5.9c {t1='abc', t2='A%_C'} {t1 LIKE t2} $NCSL
test_expr expr-5.9d {t1='ac', t2='A%_C'} {t1 LIKE t2} 0
test_expr expr-5.10a {t1='abxyzzyc', t2='a%_c'} {t1 LIKE t2} 1
test_expr expr-5.10b {t1='abxyzzyc', t2='A%_C'} {t1 LIKE t2} $NCSL
test_expr expr-5.11 {t1='abc', t2='xyz'} {t1 NOT LIKE t2} 1
test_expr expr-5.12a {t1='abc', t2='abc'} {t1 NOT LIKE t2} 0
test_expr expr-5.12b {t1='abc', t2='ABC'} {t1 NOT LIKE t2} $CSL
test_expr expr-5.13  {t1='A'}  {t1 LIKE 'A%_'} 0
test_expr expr-5.14  {t1='AB'} {t1 LIKE 'A%b' ESCAPE 'b'} 0

# The following tests only work on versions of TCL that support Unicode
#
if {"\u1234"!="u1234"} {
  test_expr expr-5.13a "t1='a\u0080c', t2='a_c'" {t1 LIKE t2} 1
  test_expr expr-5.13b "t1='a\u0080c', t2='A_C'" {t1 LIKE t2} $NCSL
  test_expr expr-5.14a "t1='a\u07FFc', t2='a_c'" {t1 LIKE t2} 1
Changes to test/incrblob.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 2007 May 1
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    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.
#
#***********************************************************************
#
# $Id: incrblob.test,v 1.14 2007/08/22 02:56:44 drh Exp $
#

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

ifcapable {!autovacuum || !pragma || !incrblob} {
  finish_test











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 2007 May 1
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    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.
#
#***********************************************************************
#
# $Id: incrblob.test,v 1.15 2007/09/01 18:24:55 danielk1977 Exp $
#

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

ifcapable {!autovacuum || !pragma || !incrblob} {
  finish_test
322
323
324
325
326
327
328









329
330
331
332
333
334
335
  } msg]
} {0}
do_test incrblob-4.9.2 {
  binary scan [read $::blob] c* c
  close $::blob
  set c
} {1 2 3 4 5 6 7 8 9}










#------------------------------------------------------------------------
# incrblob-5.*: 
#
#     Test that opening a blob in an attached database works.
#
do_test incrblob-5.1 {







>
>
>
>
>
>
>
>
>







322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
  } msg]
} {0}
do_test incrblob-4.9.2 {
  binary scan [read $::blob] c* c
  close $::blob
  set c
} {1 2 3 4 5 6 7 8 9}

do_test incrblob-4.10 {
  set ::blob [db incrblob -readonly blobs k 3]
  set rc [catch { sqlite3_blob_read $::blob 10 100 } msg]
  list $rc $msg
} {1 SQLITE_ERROR}
do_test incrblob-4.11 {
  close $::blob
} {}

#------------------------------------------------------------------------
# incrblob-5.*: 
#
#     Test that opening a blob in an attached database works.
#
do_test incrblob-5.1 {
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
      SELECT d FROM t1;
    }
  } {15}

}

set fd [open [info script]]
set ::data [read $fd]
close $fd

db close
file delete -force test.db test.db-journal
sqlite3 db test.db

do_test incrblob-7.2.1 {







|







522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
      SELECT d FROM t1;
    }
  } {15}

}

set fd [open [info script]]
set ::data [read $fd 14000]
close $fd

db close
file delete -force test.db test.db-journal
sqlite3 db test.db

do_test incrblob-7.2.1 {
Changes to test/io.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
#
# The focus of this file is testing some specific characteristics of the 
# IO traffic generated by SQLite (making sure SQLite is not writing out
# more database pages than it has to, stuff like that).
#
# $Id: io.test,v 1.7 2007/08/29 17:59:42 drh Exp $

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

# Test summary:
#
# io-1.* -  Test that quick-balance does not journal pages unnecessarily.







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
#
# The focus of this file is testing some specific characteristics of the 
# IO traffic generated by SQLite (making sure SQLite is not writing out
# more database pages than it has to, stuff like that).
#
# $Id: io.test,v 1.8 2007/09/01 18:24:55 danielk1977 Exp $

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

# Test summary:
#
# io-1.* -  Test that quick-balance does not journal pages unnecessarily.
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# to the b-tree used to store table abc. It should only be necessary to
# write to 3 pages to do this: the change-counter, the root-page and
# the new leaf page.
do_test io-1.5 {
  execsql { INSERT INTO abc VALUES(9,randstr(230,230)); }
  nWrite db
} {3}


ifcapable atomicwrite {

#----------------------------------------------------------------------
# Test cases io-2.* test the atomic-write optimization.
#
do_test io-2.1 {







<







105
106
107
108
109
110
111

112
113
114
115
116
117
118
# to the b-tree used to store table abc. It should only be necessary to
# write to 3 pages to do this: the change-counter, the root-page and
# the new leaf page.
do_test io-1.5 {
  execsql { INSERT INTO abc VALUES(9,randstr(230,230)); }
  nWrite db
} {3}


ifcapable atomicwrite {

#----------------------------------------------------------------------
# Test cases io-2.* test the atomic-write optimization.
#
do_test io-2.1 {
328
329
330
331
332
333
334
























335
336
337
338
339
340
341
    INSERT INTO abc VALUES(11, 12);
  }
  file exists test.db-journal
} {0}
do_test io-2.10.3 {
  execsql { ROLLBACK }
} {}
























} ;# /* ifcapable atomicwrite */

#----------------------------------------------------------------------
# Test cases io-3.* test the IOCAP_SEQUENTIAL optimization.
#
sqlite3_simulate_device -char sequential -sectorsize 0
do_test io-3.1 {







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







327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
    INSERT INTO abc VALUES(11, 12);
  }
  file exists test.db-journal
} {0}
do_test io-2.10.3 {
  execsql { ROLLBACK }
} {}

do_test io-2.11.0 {
  execsql { 
    PRAGMA locking_mode = exclusive;
    PRAGMA locking_mode;
  }
} {exclusive exclusive}
breakpoint
do_test io-2.11.1 {
  execsql { 
    INSERT INTO abc VALUES(11, 12);
  }
  file exists test.db-journal
} {0}
breakpoint

do_test io-2.11.2 {
  execsql { 
    PRAGMA locking_mode = normal;
    INSERT INTO abc VALUES(13, 14);
  }
  file exists test.db-journal
} {0}

} ;# /* ifcapable atomicwrite */

#----------------------------------------------------------------------
# Test cases io-3.* test the IOCAP_SEQUENTIAL optimization.
#
sqlite3_simulate_device -char sequential -sectorsize 0
do_test io-3.1 {
Changes to test/sqllimits1.test.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains tests to verify that the limits defined in
# sqlite source file limits.h are enforced.
#
# $Id: sqllimits1.test,v 1.14 2007/09/01 16:16:16 danielk1977 Exp $

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

# Test organization:
#
#     sqllimits-1.*:  SQLITE_MAX_LENGTH







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains tests to verify that the limits defined in
# sqlite source file limits.h are enforced.
#
# $Id: sqllimits1.test,v 1.15 2007/09/01 18:24:55 danielk1977 Exp $

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

# Test organization:
#
#     sqllimits-1.*:  SQLITE_MAX_LENGTH
103
104
105
106
107
108
109










110
111
112
113
114
115
116

do_test sqllimits-1.11 {
  set ::str1 [string repeat A [expr {$SQLITE_MAX_LENGTH - 10}]]
  set ::str2 [string repeat B [expr {$SQLITE_MAX_LENGTH - 10}]]
  catchsql { SELECT $::str1 || $::str2 }
} {1 {string or blob too big}}











#--------------------------------------------------------------------
# Test cases sqllimits-2.* test that the SQLITE_MAX_SQL_LENGTH limit
# is enforced.
#
do_test sqllimits-2.1 {
  set    sql "SELECT 1 WHERE 1==1"
  set N [expr {$::SQLITE_MAX_SQL_LENGTH / [string length " AND 1==1"]}]







>
>
>
>
>
>
>
>
>
>







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

do_test sqllimits-1.11 {
  set ::str1 [string repeat A [expr {$SQLITE_MAX_LENGTH - 10}]]
  set ::str2 [string repeat B [expr {$SQLITE_MAX_LENGTH - 10}]]
  catchsql { SELECT $::str1 || $::str2 }
} {1 {string or blob too big}}

do_test sqllimits-1.12 {
  set ::str1 [string repeat ' [expr {$SQLITE_MAX_LENGTH - 10}]]
  catchsql { SELECT quote($::str1) }
} {1 {string or blob too big}}

do_test sqllimits-1.13 {
  set ::str1 [string repeat ' [expr {$SQLITE_MAX_LENGTH - 10}]]
  catchsql { SELECT hex($::str1) }
} {1 {string or blob too big}}

#--------------------------------------------------------------------
# Test cases sqllimits-2.* test that the SQLITE_MAX_SQL_LENGTH limit
# is enforced.
#
do_test sqllimits-2.1 {
  set    sql "SELECT 1 WHERE 1==1"
  set N [expr {$::SQLITE_MAX_SQL_LENGTH / [string length " AND 1==1"]}]
Changes to test/vtab_alter.test.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    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 ALTER TABLE ... RENAME TO
# command on virtual tables.
#
# $Id: vtab_alter.test,v 1.1 2007/06/27 15:53:35 danielk1977 Exp $

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

ifcapable !vtab {
  finish_test
  return







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    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 ALTER TABLE ... RENAME TO
# command on virtual tables.
#
# $Id: vtab_alter.test,v 1.2 2007/09/01 18:24:55 danielk1977 Exp $

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

ifcapable !vtab {
  finish_test
  return
97
98
99
100
101
102
103
104
  catchsql { ALTER TABLE x RENAME TO y }
} {1 {SQL logic error or missing database}}
do_test vtab_alter-3.2 {
  execsql  { SELECT * FROM x }
} {1 2 3}

finish_test








<
97
98
99
100
101
102
103

  catchsql { ALTER TABLE x RENAME TO y }
} {1 {SQL logic error or missing database}}
do_test vtab_alter-3.2 {
  execsql  { SELECT * FROM x }
} {1 2 3}

finish_test