/ Check-in [75af7189]
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:Remove an unreachable case from xferOptimization(). Also other minor test coverage improvements. (CVS 4383)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 75af7189c0ed1b24a32cff6960af7f17326cbc17
User & Date: danielk1977 2007-09-03 17:30:07
Context
2007-09-03
17:42
Unix OS interface returns SQLITE_CANTOPEN following a getcwd() failure. (CVS 4384) check-in: ed15db46 user: drh tags: trunk
17:30
Remove an unreachable case from xferOptimization(). Also other minor test coverage improvements. (CVS 4383) check-in: 75af7189 user: danielk1977 tags: trunk
17:09
Fix the open file counter on windows. (CVS 4382) check-in: 40cf0c17 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/insert.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
**    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 INSERT statements in SQLite.
**
** $Id: insert.c,v 1.191 2007/08/29 13:45:59 drh Exp $
*/
#include "sqliteInt.h"

/*
** Set P3 of the most recently inserted opcode to a column affinity
** string for index pIdx. A column affinity string has one character
** for each column in the table, according to the affinity of the column:
................................................................................
#endif
  if( onError==OE_Default ){
    onError = OE_Abort;
  }
  if( onError!=OE_Abort && onError!=OE_Rollback ){
    return 0;   /* Cannot do OR REPLACE or OR IGNORE or OR FAIL */
  }
  if( pSelect->pSrc==0 ){
    return 0;   /* SELECT must have a FROM clause */
  }
  if( pSelect->pSrc->nSrc!=1 ){
    return 0;   /* FROM clause must have exactly one term */
  }
  if( pSelect->pSrc->a[0].pSelect ){
    return 0;   /* FROM clause cannot contain a subquery */
  }
  if( pSelect->pWhere ){







|







 







|
<
<







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


1422
1423
1424
1425
1426
1427
1428
**    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 INSERT statements in SQLite.
**
** $Id: insert.c,v 1.192 2007/09/03 17:30:07 danielk1977 Exp $
*/
#include "sqliteInt.h"

/*
** Set P3 of the most recently inserted opcode to a column affinity
** string for index pIdx. A column affinity string has one character
** for each column in the table, according to the affinity of the column:
................................................................................
#endif
  if( onError==OE_Default ){
    onError = OE_Abort;
  }
  if( onError!=OE_Abort && onError!=OE_Rollback ){
    return 0;   /* Cannot do OR REPLACE or OR IGNORE or OR FAIL */
  }
  assert(pSelect->pSrc);   /* allocated even if there is no FROM clause */


  if( pSelect->pSrc->nSrc!=1 ){
    return 0;   /* FROM clause must have exactly one term */
  }
  if( pSelect->pSrc->a[0].pSelect ){
    return 0;   /* FROM clause cannot contain a subquery */
  }
  if( pSelect->pWhere ){

Changes to src/test1.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
140
141
142
143
144
145
146

147
148
149
150
151
152
153
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing all sorts of SQLite interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.276 2007/09/03 17:02:50 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
#include <string.h>

/*
................................................................................
    case SQLITE_NOLFS:      zName = "SQLITE_NOLFS";       break;
    case SQLITE_AUTH:       zName = "SQLITE_AUTH";        break;
    case SQLITE_FORMAT:     zName = "SQLITE_FORMAT";      break;
    case SQLITE_RANGE:      zName = "SQLITE_RANGE";       break;
    case SQLITE_ROW:        zName = "SQLITE_ROW";         break;
    case SQLITE_DONE:       zName = "SQLITE_DONE";        break;
    case SQLITE_NOTADB:     zName = "SQLITE_NOTADB";      break;

    default:                zName = "SQLITE_Unknown";     break;
  }
  return zName;
}
#define t1ErrorName sqlite3TestErrorName

/*







|







 







>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing all sorts of SQLite interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.277 2007/09/03 17:30:07 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
#include <string.h>

/*
................................................................................
    case SQLITE_NOLFS:      zName = "SQLITE_NOLFS";       break;
    case SQLITE_AUTH:       zName = "SQLITE_AUTH";        break;
    case SQLITE_FORMAT:     zName = "SQLITE_FORMAT";      break;
    case SQLITE_RANGE:      zName = "SQLITE_RANGE";       break;
    case SQLITE_ROW:        zName = "SQLITE_ROW";         break;
    case SQLITE_DONE:       zName = "SQLITE_DONE";        break;
    case SQLITE_NOTADB:     zName = "SQLITE_NOTADB";      break;
    case SQLITE_TOOBIG:     zName = "SQLITE_TOOBIG";      break;
    default:                zName = "SQLITE_Unknown";     break;
  }
  return zName;
}
#define t1ErrorName sqlite3TestErrorName

/*

Changes to test/insert4.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
25
26
27
28
29
30
31

32
33
34
35
36
37
38
...
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

























242
#    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 INSERT transfer optimization.
#
# $Id: insert4.test,v 1.5 2007/04/12 21:25:02 drh Exp $

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

# The sqlite3_xferopt_count variable is incremented whenever the 
# insert transfer optimization applies.
#
................................................................................
proc xferopt_test {testname N} {
  do_test $testname {set ::sqlite3_xferopt_count} $N
}

# Create tables used for testing.
#
execsql {

  CREATE TABLE t1(a int, b int, check(b>a));
  CREATE TABLE t2(x int, y int);
  CREATE VIEW v2 AS SELECT y, x FROM t2;
  CREATE TABLE t3(a int, b int);
}

# Ticket #2252.  Make sure the an INSERT from identical tables
................................................................................
# "int" and "integer" are equivalent so the optimization should
# run here.
#
xfer_check insert4-3.22 1 {1 9} \
    {a int, b int} \
    {x integer, b int}


# Ticket #2291.
#
do_test insert4-4.1 {
  execsql {
    CREATE TABLE t4(a, b, UNIQUE(a,b));
    INSERT INTO t4 VALUES(NULL,0);
    INSERT INTO t4 VALUES(NULL,1);
    INSERT INTO t4 VALUES(NULL,1);
    VACUUM;   
  }
} {}


























finish_test







|







 







>







 







<












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

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
223
224
225
226
227
228
229

230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#    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 INSERT transfer optimization.
#
# $Id: insert4.test,v 1.6 2007/09/03 17:30:07 danielk1977 Exp $

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

# The sqlite3_xferopt_count variable is incremented whenever the 
# insert transfer optimization applies.
#
................................................................................
proc xferopt_test {testname N} {
  do_test $testname {set ::sqlite3_xferopt_count} $N
}

# Create tables used for testing.
#
execsql {
  PRAGMA legacy_file_format = 0;
  CREATE TABLE t1(a int, b int, check(b>a));
  CREATE TABLE t2(x int, y int);
  CREATE VIEW v2 AS SELECT y, x FROM t2;
  CREATE TABLE t3(a int, b int);
}

# Ticket #2252.  Make sure the an INSERT from identical tables
................................................................................
# "int" and "integer" are equivalent so the optimization should
# run here.
#
xfer_check insert4-3.22 1 {1 9} \
    {a int, b int} \
    {x integer, b int}


# Ticket #2291.
#
do_test insert4-4.1 {
  execsql {
    CREATE TABLE t4(a, b, UNIQUE(a,b));
    INSERT INTO t4 VALUES(NULL,0);
    INSERT INTO t4 VALUES(NULL,1);
    INSERT INTO t4 VALUES(NULL,1);
    VACUUM;   
  }
} {}

# Check some error conditions:
#
do_test insert4-5.1 {
  # Table does not exist.
  catchsql { INSERT INTO t2 SELECT * FROM nosuchtable }
} {1 {no such table: nosuchtable}}
do_test insert4-5.2 {
  # Number of columns does not match.
  catchsql { 
    CREATE TABLE t5(a, b, c);
    INSERT INTO t4 SELECT * FROM t5;
  }
} {1 {table t4 has 2 columns but 3 values were supplied}}

do_test insert4-6.1 {
  execsql {
    CREATE INDEX t2_i2 ON t2(x, y COLLATE nocase); 
    CREATE INDEX t2_i1 ON t2(x ASC, y DESC);
    CREATE INDEX t3_i1 ON t3(a, b);
    INSERT INTO t2 SELECT * FROM t3;
  }
} {}



finish_test

Changes to test/sqllimits1.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
112
113
114
115
116
117
118











119
120
121
122
123
124
125
#    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
................................................................................
  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"







|







 







>
>
>
>
>
>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#    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.16 2007/09/03 17:30:07 danielk1977 Exp $

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

# Test organization:
#
#     sqllimits-1.*:  SQLITE_MAX_LENGTH
................................................................................
  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}}

do_test sqllimits-1.14.1 {
  set ::STMT [sqlite3_prepare $::DB "SELECT ?" -1 TAIL]
  sqlite3_bind_zeroblob $::STMT 1 [expr {$SQLITE_MAX_LENGTH + 1}]
} {}
do_test sqllimits-1.14.2 {
  sqlite3_step $::STMT 
} {SQLITE_ERROR}
do_test sqllimits-1.14.3 {
  sqlite3_finalize $::STMT 
} {SQLITE_TOOBIG}

#--------------------------------------------------------------------
# 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"