SQLite

Check-in [4281a838f2]
Login

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

Overview
Comment:Additional tests for better coverage. (CVS 2602)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4281a838f2f531af24b008d2834e8318798472c5
User & Date: drh 2005-08-19 03:03:52.000
Context
2005-08-19
19:14
Increase test coverage of alter.c to 100%. Fix bugs found in the process. (CVS 2603) (check-in: b550d04d43 user: drh tags: trunk)
03:03
Additional tests for better coverage. (CVS 2602) (check-in: 4281a838f2 user: drh tags: trunk)
02:26
Increased test coverage on trigger.c and printf.c. (CVS 2601) (check-in: 842a80bd8f user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
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.217 2005/08/14 20:47:16 drh 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.218 2005/08/19 03:03:52 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** Return the 'affinity' of the expression pExpr if any.
**
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
*/
void sqlite3DequoteExpr(Expr *p){
  if( ExprHasAnyProperty(p, EP_Dequoted) ){
    return;
  }
  ExprSetProperty(p, EP_Dequoted);
  if( p->token.dyn==0 ){
    if( p->op==TK_BLOB ){
      p->token.n--;
      p->token.z++;
    }
    sqlite3TokenCopy(&p->token, &p->token);
  }
  sqlite3Dequote((char*)p->token.z);
}


/*







<
<
<
<







386
387
388
389
390
391
392




393
394
395
396
397
398
399
*/
void sqlite3DequoteExpr(Expr *p){
  if( ExprHasAnyProperty(p, EP_Dequoted) ){
    return;
  }
  ExprSetProperty(p, EP_Dequoted);
  if( p->token.dyn==0 ){




    sqlite3TokenCopy(&p->token, &p->token);
  }
  sqlite3Dequote((char*)p->token.z);
}


/*
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.44 2005/07/08 13:53:22 drh 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.45 2005/08/19 03:03:52 drh 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)}
614
615
616
617
618
619
620
621










622
# Test an error message that can be generated by the LIKE expression
do_test expr-10.1 {
  catchsql {SELECT 'abc' LIKE 'abc' ESCAPE ''}
} {1 {ESCAPE expression must be a single character}}
do_test expr-10.2 {
  catchsql {SELECT 'abc' LIKE 'abc' ESCAPE 'ab'}
} {1 {ESCAPE expression must be a single character}}











finish_test








>
>
>
>
>
>
>
>
>
>

614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
# Test an error message that can be generated by the LIKE expression
do_test expr-10.1 {
  catchsql {SELECT 'abc' LIKE 'abc' ESCAPE ''}
} {1 {ESCAPE expression must be a single character}}
do_test expr-10.2 {
  catchsql {SELECT 'abc' LIKE 'abc' ESCAPE 'ab'}
} {1 {ESCAPE expression must be a single character}}

# If we specify an integer constant that is bigger than the largest
# possible integer, code the integer as a real number.
#
do_test expr-11.1 {
  execsql {SELECT typeof(9223372036854775807)}
} {integer}
do_test expr-11.2 {
  execsql {SELECT typeof(9223372036854775808)}
} {real}

finish_test
Changes to test/misc1.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc1.test,v 1.36 2005/08/13 12:59:16 drh Exp $

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

# Mimic the SQLite 2 collation type NUMERIC.
db collate numeric numeric_collate
proc numeric_collate {lhs rhs} {







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc1.test,v 1.37 2005/08/19 03:03:52 drh Exp $

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

# Mimic the SQLite 2 collation type NUMERIC.
db collate numeric numeric_collate
proc numeric_collate {lhs rhs} {
489
490
491
492
493
494
495
496
497
498
499
500










501
502
503
504
505
506
507
  execsql {COMMIT}
  file exists ./test.db-journal
} {0}

# A failed create table should not leave the table in the internal
# data structures.  Ticket #238.
#
do_test misc1-15.1 {
  catchsql {
    CREATE TABLE t10 AS SELECT c1;
  }
} {1 {no such column: c1}}










do_test misc1-15.2 {
  catchsql {
    CREATE TABLE t10 AS SELECT 1;
  }
  # The bug in ticket #238 causes the statement above to fail with
  # the error "table t10 alread exists"
} {0 {}}







|




>
>
>
>
>
>
>
>
>
>







489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
  execsql {COMMIT}
  file exists ./test.db-journal
} {0}

# A failed create table should not leave the table in the internal
# data structures.  Ticket #238.
#
do_test misc1-15.1.1 {
  catchsql {
    CREATE TABLE t10 AS SELECT c1;
  }
} {1 {no such column: c1}}
do_test misc1-15.1.2 {
  catchsql {
    CREATE TABLE t10 AS SELECT t9.c1;
  }
} {1 {no such column: t9.c1}}
do_test misc1-15.1.3 {
  catchsql {
    CREATE TABLE t10 AS SELECT main.t9.c1;
  }
} {1 {no such column: main.t9.c1}}
do_test misc1-15.2 {
  catchsql {
    CREATE TABLE t10 AS SELECT 1;
  }
  # The bug in ticket #238 causes the statement above to fail with
  # the error "table t10 alread exists"
} {0 {}}
Changes to test/select5.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 aggregate functions and the
# GROUP BY and HAVING clauses of SELECT statements.
#
# $Id: select5.test,v 1.9 2005/01/26 03:58:36 danielk1977 Exp $

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

# Build some test data
#
execsql {







|







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 aggregate functions and the
# GROUP BY and HAVING clauses of SELECT statements.
#
# $Id: select5.test,v 1.10 2005/08/19 03:03:52 drh Exp $

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

# Build some test data
#
execsql {
45
46
47
48
49
50
51
52
53
54

55
56




57
58
59
60
61
62
63
64
} {9 1 10 1 8 2 7 4 6 8 5 15}
do_test select5-1.3 {
  execsql {SELECT count(*), y FROM t1 GROUP BY y ORDER BY count(*), y}
} {1 9 1 10 2 8 4 7 8 6 15 5}

# Some error messages associated with aggregates and GROUP BY
#
do_test select5-2.1 {
  set v [catch {execsql {
    SELECT y, count(*) FROM t1 GROUP BY z ORDER BY y

  }} msg]
  lappend v $msg




} {1 {no such column: z}}
do_test select5-2.2 {
  set v [catch {execsql {
    SELECT y, count(*) FROM t1 GROUP BY z(y) ORDER BY y
  }} msg]
  lappend v $msg
} {1 {no such function: z}}
do_test select5-2.3 {







|
|

>
|
<
>
>
>
>
|







45
46
47
48
49
50
51
52
53
54
55
56

57
58
59
60
61
62
63
64
65
66
67
68
} {9 1 10 1 8 2 7 4 6 8 5 15}
do_test select5-1.3 {
  execsql {SELECT count(*), y FROM t1 GROUP BY y ORDER BY count(*), y}
} {1 9 1 10 2 8 4 7 8 6 15 5}

# Some error messages associated with aggregates and GROUP BY
#
do_test select5-2.1.1 {
  catchsql {
    SELECT y, count(*) FROM t1 GROUP BY z ORDER BY y
  }
} {1 {no such column: z}}

do_test select5-2.1.2 {
  catchsql {
    SELECT y, count(*) FROM t1 GROUP BY temp.t1.y ORDER BY y
  }
} {1 {no such column: temp.t1.y}}
do_test select5-2.2 {
  set v [catch {execsql {
    SELECT y, count(*) FROM t1 GROUP BY z(y) ORDER BY y
  }} msg]
  lappend v $msg
} {1 {no such function: z}}
do_test select5-2.3 {
149
150
151
152
153
154
155
156
do_test select5-5.5 {
  execsql {
    SELECT a, b FROM t2 GROUP BY a;
  } 
} {1 2 6 4}

finish_test








<
153
154
155
156
157
158
159

do_test select5-5.5 {
  execsql {
    SELECT a, b FROM t2 GROUP BY a;
  } 
} {1 2 6 4}

finish_test