/ Check-in [f58bbdc0]
Login

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

Overview
Comment:Fixes for OMIT_UTF16 and OMIT_COMPOUND (CVS 2993)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f58bbdc0ac6e618686c598aaafb3a41b972e078e
User & Date: danielk1977 2006-01-23 07:52:38
Context
2006-01-23
13:00
Fix additional compiler warnings. Tickets #1615, #1616, #1627 (CVS 2994) check-in: 6385628e user: drh tags: trunk
07:52
Fixes for OMIT_UTF16 and OMIT_COMPOUND (CVS 2993) check-in: f58bbdc0 user: danielk1977 tags: trunk
05:50
Improve coverage of expr.c and btree.c slightly. (CVS 2992) check-in: cc2e8e87 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/test1.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
574
575
576
577
578
579
580

581
582
583

584
585
586
587
588
589
590
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the printf() interface to SQLite.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.201 2006/01/20 15:45:36 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0]) ) && p ){
    p->n++;
  }
  if( argc>0 ){
    int v = sqlite3_value_int(argv[0]);
    if( v==40 ){
      sqlite3_result_error(context, "value of 40 handed to x_count", -1);

    }else if( v==41 ){
      const char zUtf16ErrMsg[] = { 0, 0x61, 0, 0x62, 0, 0x63, 0, 0, 0};
      sqlite3_result_error16(context, &zUtf16ErrMsg[1-SQLITE_BIGENDIAN], -1);

    }
  }
}   
static void countFinalize(sqlite3_context *context){
  CountCtx *p;
  p = sqlite3_aggregate_context(context, sizeof(*p));
  if( p ){







|







 







>



>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the printf() interface to SQLite.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.202 2006/01/23 07:52:38 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0]) ) && p ){
    p->n++;
  }
  if( argc>0 ){
    int v = sqlite3_value_int(argv[0]);
    if( v==40 ){
      sqlite3_result_error(context, "value of 40 handed to x_count", -1);
#ifndef SQLITE_OMIT_UTF16
    }else if( v==41 ){
      const char zUtf16ErrMsg[] = { 0, 0x61, 0, 0x62, 0, 0x63, 0, 0, 0};
      sqlite3_result_error16(context, &zUtf16ErrMsg[1-SQLITE_BIGENDIAN], -1);
#endif
    }
  }
}   
static void countFinalize(sqlite3_context *context){
  CountCtx *p;
  p = sqlite3_aggregate_context(context, sizeof(*p));
  if( p ){

Changes to src/vdbeapi.c.

91
92
93
94
95
96
97

98
99
100
101

102
103
104
105
106
107
108
void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
  sqlite3VdbeMemSetDouble(&pCtx->s, rVal);
}
void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
  pCtx->isError = 1;
  sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
}

void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
  pCtx->isError = 1;
  sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
}

void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
  sqlite3VdbeMemSetInt64(&pCtx->s, (i64)iVal);
}
void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
  sqlite3VdbeMemSetInt64(&pCtx->s, iVal);
}
void sqlite3_result_null(sqlite3_context *pCtx){







>




>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
  sqlite3VdbeMemSetDouble(&pCtx->s, rVal);
}
void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
  pCtx->isError = 1;
  sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
}
#ifndef SQLITE_OMIT_UTF16
void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
  pCtx->isError = 1;
  sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
}
#endif
void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
  sqlite3VdbeMemSetInt64(&pCtx->s, (i64)iVal);
}
void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
  sqlite3VdbeMemSetInt64(&pCtx->s, iVal);
}
void sqlite3_result_null(sqlite3_context *pCtx){

Changes to test/aggerror.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60

61
62
63
64
65
66
67
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for calling sqlite3_result_error()
# from within an aggregate function implementation.
#
# $Id: aggerror.test,v 1.1 2006/01/20 15:45:37 drh Exp $

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


# Add the x_count aggregate function to the database handle.
# x_count will error out if its input is 40 or 41 or if its
................................................................................
  }
} {40}
do_test aggfunc-1.3 {
  catchsql {
    SELECT x_count(a) FROM t1;
  }
} {1 {value of 40 handed to x_count}}

do_test aggfunc-1.4 {
  execsql {
    UPDATE t1 SET a=41 WHERE a=40
  }
  catchsql {
    SELECT x_count(a) FROM t1;
  }
} {1 abc}

do_test aggfunc-1.5 {
  execsql {
    SELECT x_count(*) FROM t1
  }
} 40
do_test aggfunc-1.6 {
  execsql {







|







 







>
|
|
|
|
|
|
|
|
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for calling sqlite3_result_error()
# from within an aggregate function implementation.
#
# $Id: aggerror.test,v 1.2 2006/01/23 07:52:41 danielk1977 Exp $

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


# Add the x_count aggregate function to the database handle.
# x_count will error out if its input is 40 or 41 or if its
................................................................................
  }
} {40}
do_test aggfunc-1.3 {
  catchsql {
    SELECT x_count(a) FROM t1;
  }
} {1 {value of 40 handed to x_count}}
ifcapable utf16 {
  do_test aggfunc-1.4 {
    execsql {
      UPDATE t1 SET a=41 WHERE a=40
    }
    catchsql {
      SELECT x_count(a) FROM t1;
    }
  } {1 abc}
}
do_test aggfunc-1.5 {
  execsql {
    SELECT x_count(*) FROM t1
  }
} 40
do_test aggfunc-1.6 {
  execsql {

Changes to test/malloc3.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
#
#***********************************************************************
#
# This file contains tests to ensure that the library handles malloc() failures
# correctly. The emphasis of these tests are the _prepare(), _step() and
# _finalize() calls.
#
# $Id: malloc3.test,v 1.8 2006/01/20 16:32:04 danielk1977 Exp $

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

# Only run these tests if memory debugging is turned on.
if {[info command sqlite_malloc_stat]==""} {
   puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
................................................................................
# if {$iFail > ($iFailStart+1)} return
  }
}

# Turn of the Tcl interface's prepared statement caching facility.
db cache size 0

run_test $::run_test_script
# run_test [lrange $::run_test_script 0 3] 0 63
sqlite_malloc_fail 0
db close

pp_check_for_leaks

finish_test








|







 







|








9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
#
#***********************************************************************
#
# This file contains tests to ensure that the library handles malloc() failures
# correctly. The emphasis of these tests are the _prepare(), _step() and
# _finalize() calls.
#
# $Id: malloc3.test,v 1.9 2006/01/23 07:52:41 danielk1977 Exp $

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

# Only run these tests if memory debugging is turned on.
if {[info command sqlite_malloc_stat]==""} {
   puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
................................................................................
# if {$iFail > ($iFailStart+1)} return
  }
}

# Turn of the Tcl interface's prepared statement caching facility.
db cache size 0

run_test $::run_test_script 9 1
# run_test [lrange $::run_test_script 0 3] 0 63
sqlite_malloc_fail 0
db close

pp_check_for_leaks

finish_test

Changes to test/malloc4.test.

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





35
36
37
38
39
40
41
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains tests to ensure that the library handles malloc() failures
# correctly. The emphasis in this file is on sqlite3_column_XXX() APIs.
#
# $Id: malloc4.test,v 1.2 2005/12/09 14:25:12 danielk1977 Exp $

#---------------------------------------------------------------------------
# NOTES ON EXPECTED BEHAVIOUR
#
# [193] When a memory allocation failure occurs during sqlite3_column_name(),
#       sqlite3_column_name16(), sqlite3_column_decltype(), or
#       sqlite3_column_decltype16() the function shall return NULL.
................................................................................

# Only run these tests if memory debugging is turned on.
if {[info command sqlite_malloc_stat]==""} {
   puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
   finish_test
   return
}






proc do_stmt_test {id sql} {
  set ::sql $sql
  set go 1
  for {set n 1} {$go} {incr n} {
    set testid "malloc4-$id.(iFail $n)"








|







 







>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains tests to ensure that the library handles malloc() failures
# correctly. The emphasis in this file is on sqlite3_column_XXX() APIs.
#
# $Id: malloc4.test,v 1.3 2006/01/23 07:52:41 danielk1977 Exp $

#---------------------------------------------------------------------------
# NOTES ON EXPECTED BEHAVIOUR
#
# [193] When a memory allocation failure occurs during sqlite3_column_name(),
#       sqlite3_column_name16(), sqlite3_column_decltype(), or
#       sqlite3_column_decltype16() the function shall return NULL.
................................................................................

# Only run these tests if memory debugging is turned on.
if {[info command sqlite_malloc_stat]==""} {
   puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
   finish_test
   return
}

ifcapable !utf16 {
  finish_test
  return
}

proc do_stmt_test {id sql} {
  set ::sql $sql
  set go 1
  for {set n 1} {$go} {incr n} {
    set testid "malloc4-$id.(iFail $n)"

Changes to test/select6.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
297
298
299
300
301
302
303
304
305
306
307
308
309
310

311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
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
#    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 SELECT statements that contain
# subqueries in their FROM clause.
#
# $Id: select6.test,v 1.22 2006/01/22 00:14:39 drh Exp $

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

# Omit this whole file if the library is build without subquery support.
ifcapable !subquery {
  finish_test
................................................................................
    WHERE a=b
    ORDER BY a
  }
} {8 5 8 9 6 9 10 7 10}

# Tests of compound sub-selects
#
ifcapable compound {
do_test select5-6.1 {
  execsql {
    DELETE FROM t1 WHERE x>4;
    SELECT * FROM t1
  }
} {1 1 2 2 3 2 4 3}

do_test select6-6.2 {
  execsql {
    SELECT * FROM (
      SELECT x AS 'a' FROM t1 UNION ALL SELECT x+10 AS 'a' FROM t1
    ) ORDER BY a;
  }
} {1 2 3 4 11 12 13 14}
do_test select6-6.3 {
  execsql {
    SELECT * FROM (
      SELECT x AS 'a' FROM t1 UNION ALL SELECT x+1 AS 'a' FROM t1
    ) ORDER BY a;
  }
} {1 2 2 3 3 4 4 5}
do_test select6-6.4 {
  execsql {
    SELECT * FROM (
      SELECT x AS 'a' FROM t1 UNION SELECT x+1 AS 'a' FROM t1
    ) ORDER BY a;
  }
} {1 2 3 4 5}
do_test select6-6.5 {
  execsql {
    SELECT * FROM (
      SELECT x AS 'a' FROM t1 INTERSECT SELECT x+1 AS 'a' FROM t1
    ) ORDER BY a;
  }
} {2 3 4}
do_test select6-6.6 {
  execsql {
    SELECT * FROM (
      SELECT x AS 'a' FROM t1 EXCEPT SELECT x*2 AS 'a' FROM t1
    ) ORDER BY a;
  }
} {1 3}
} ;# ifcapable compound

# Subselects with no FROM clause
#
do_test select6-7.1 {
  execsql {
    SELECT * FROM (SELECT 1)







|







 







<






>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
297
298
299
300
301
302
303

304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
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
#    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 SELECT statements that contain
# subqueries in their FROM clause.
#
# $Id: select6.test,v 1.23 2006/01/23 07:52:41 danielk1977 Exp $

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

# Omit this whole file if the library is build without subquery support.
ifcapable !subquery {
  finish_test
................................................................................
    WHERE a=b
    ORDER BY a
  }
} {8 5 8 9 6 9 10 7 10}

# Tests of compound sub-selects
#

do_test select5-6.1 {
  execsql {
    DELETE FROM t1 WHERE x>4;
    SELECT * FROM t1
  }
} {1 1 2 2 3 2 4 3}
ifcapable compound {
  do_test select6-6.2 {
    execsql {
      SELECT * FROM (
        SELECT x AS 'a' FROM t1 UNION ALL SELECT x+10 AS 'a' FROM t1
      ) ORDER BY a;
    }
  } {1 2 3 4 11 12 13 14}
  do_test select6-6.3 {
    execsql {
      SELECT * FROM (
        SELECT x AS 'a' FROM t1 UNION ALL SELECT x+1 AS 'a' FROM t1
      ) ORDER BY a;
    }
  } {1 2 2 3 3 4 4 5}
  do_test select6-6.4 {
    execsql {
      SELECT * FROM (
        SELECT x AS 'a' FROM t1 UNION SELECT x+1 AS 'a' FROM t1
      ) ORDER BY a;
    }
  } {1 2 3 4 5}
  do_test select6-6.5 {
    execsql {
      SELECT * FROM (
        SELECT x AS 'a' FROM t1 INTERSECT SELECT x+1 AS 'a' FROM t1
      ) ORDER BY a;
    }
  } {2 3 4}
  do_test select6-6.6 {
    execsql {
      SELECT * FROM (
        SELECT x AS 'a' FROM t1 EXCEPT SELECT x*2 AS 'a' FROM t1
      ) ORDER BY a;
    }
  } {1 3}
} ;# ifcapable compound

# Subselects with no FROM clause
#
do_test select6-7.1 {
  execsql {
    SELECT * FROM (SELECT 1)