/ Check-in [c6ea353b]
Login

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

Overview
Comment:Modifications so that compilation and testing with the various OMIT macros defined works. (CVS 3276)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c6ea353bd9f5fe6c9cc3349d2034ada283f9c80e
User & Date: danielk1977 2006-06-20 11:01:07
Context
2006-06-20
13:07
Fix some problems with virtual tables and joins in where.c. (CVS 3277) check-in: 3e19a7d8 user: danielk1977 tags: trunk
11:01
Modifications so that compilation and testing with the various OMIT macros defined works. (CVS 3276) check-in: c6ea353b user: danielk1977 tags: trunk
00:22
Update the news column on the homepage. (CVS 3275) check-in: 24a94bb0 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
....
1714
1715
1716
1717
1718
1719
1720
1721
1722

1723
1724
1725
1726
1727
1728
1729
....
1899
1900
1901
1902
1903
1904
1905

1906
1907
1908

1909
1910
1911
1912
1913
1914
1915
....
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.404 2006/06/19 05:33:45 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
................................................................................
      pTable->nCol = 0;
      nErr++;
    }
    sqlite3SelectDelete(pSel);
  } else {
    nErr++;
  }
  return nErr;  
#endif /* SQLITE_OMIT_VIEW */

}
#endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */

#ifndef SQLITE_OMIT_VIEW
/*
** Clear the column names from every VIEW in database idx.
*/
................................................................................
    }
    if( isView ){
      if( !OMIT_TEMPDB && iDb==1 ){
        code = SQLITE_DROP_TEMP_VIEW;
      }else{
        code = SQLITE_DROP_VIEW;
      }

    }else if( IsVirtual(pTab) ){
      code = SQLITE_DROP_VTABLE;
      zArg2 = pTab->pMod->zName;

    }else{
      if( !OMIT_TEMPDB && iDb==1 ){
        code = SQLITE_DROP_TEMP_TABLE;
      }else{
        code = SQLITE_DROP_TABLE;
      }
    }
................................................................................
    ** dropped. Triggers are handled seperately because a trigger can be
    ** created in the temp database that refers to a table in another
    ** database.
    */
    sqlite3NestedParse(pParse, 
        "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'",
        pDb->zName, SCHEMA_TABLE(iDb), pTab->zName);
    if( !isView ){
      destroyTable(pParse, pTab);
    }

    /* Remove the table entry from SQLite's internal schema and modify
    ** the schema cookie.
    */
    if( IsVirtual(pTab) ){







|







 







<

>







 







>



>







 







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
....
1714
1715
1716
1717
1718
1719
1720

1721
1722
1723
1724
1725
1726
1727
1728
1729
....
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
....
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.405 2006/06/20 11:01:07 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
................................................................................
      pTable->nCol = 0;
      nErr++;
    }
    sqlite3SelectDelete(pSel);
  } else {
    nErr++;
  }

#endif /* SQLITE_OMIT_VIEW */
  return nErr;  
}
#endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */

#ifndef SQLITE_OMIT_VIEW
/*
** Clear the column names from every VIEW in database idx.
*/
................................................................................
    }
    if( isView ){
      if( !OMIT_TEMPDB && iDb==1 ){
        code = SQLITE_DROP_TEMP_VIEW;
      }else{
        code = SQLITE_DROP_VIEW;
      }
#ifndef SQLITE_OMIT_VIRTUALTABLE
    }else if( IsVirtual(pTab) ){
      code = SQLITE_DROP_VTABLE;
      zArg2 = pTab->pMod->zName;
#endif
    }else{
      if( !OMIT_TEMPDB && iDb==1 ){
        code = SQLITE_DROP_TEMP_TABLE;
      }else{
        code = SQLITE_DROP_TABLE;
      }
    }
................................................................................
    ** dropped. Triggers are handled seperately because a trigger can be
    ** created in the temp database that refers to a table in another
    ** database.
    */
    sqlite3NestedParse(pParse, 
        "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'",
        pDb->zName, SCHEMA_TABLE(iDb), pTab->zName);
    if( !isView && !IsVirtual(pTab) ){
      destroyTable(pParse, pTab);
    }

    /* Remove the table entry from SQLite's internal schema and modify
    ** the schema cookie.
    */
    if( IsVirtual(pTab) ){

Changes to src/loadext.c.

30
31
32
33
34
35
36







































37
38
39
40
41
42
43
# define sqlite3_column_database_name16 0
# define sqlite3_column_table_name      0
# define sqlite3_column_table_name16    0
# define sqlite3_column_origin_name     0
# define sqlite3_column_origin_name16   0
# define sqlite3_table_column_metadata  0
#endif








































/*
** The following structure contains pointers to all SQLite API routines.
** A pointer to this structure is passed into extensions when they are
** loaded so that the extension can make calls back into the SQLite
** library.
**







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







30
31
32
33
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# define sqlite3_column_database_name16 0
# define sqlite3_column_table_name      0
# define sqlite3_column_table_name16    0
# define sqlite3_column_origin_name     0
# define sqlite3_column_origin_name16   0
# define sqlite3_table_column_metadata  0
#endif

#ifdef SQLITE_OMIT_AUTHORIZATION
# define sqlite3_set_authorizer     0
#endif

#ifdef SQLITE_OMIT_UTF16
# define sqlite3_bind_text16        0
# define sqlite3_collation_needed16 0
# define sqlite3_column_decltype16  0
# define sqlite3_column_name16      0
# define sqlite3_column_text16      0
# define sqlite3_complete16         0
# define sqlite3_create_collation16 0
# define sqlite3_create_function16  0
# define sqlite3_errmsg16           0
# define sqlite3_open16             0
# define sqlite3_prepare16          0
# define sqlite3_result_error16     0
# define sqlite3_result_text16      0
# define sqlite3_result_text16be    0
# define sqlite3_result_text16le    0
# define sqlite3_value_text16       0
# define sqlite3_value_text16be     0
# define sqlite3_value_text16le     0
#endif

#ifdef SQLITE_OMIT_COMPLETE
# define sqlite3_complete 0
# define sqlite3_complete16 0
#endif

#ifdef SQLITE_OMIT_PROGRESS_CALLBACK
# define sqlite3_progress_handler 0
#endif

#ifdef SQLITE_OMIT_VIRTUALTABLE
# define sqlite3_create_module 0
# define sqlite3_declare_vtab 0
#endif

/*
** The following structure contains pointers to all SQLite API routines.
** A pointer to this structure is passed into extensions when they are
** loaded so that the extension can make calls back into the SQLite
** library.
**

Changes to src/select.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
...
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
**    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 SELECT statements in SQLite.
**
** $Id: select.c,v 1.315 2006/06/16 21:13:22 drh Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
        ** a segfault.  See ticket #1229.
        */
        zType = "TEXT";
        break;
      }

      assert( pTab );
#ifndef SQLITE_OMIT_SUBQUERY
      if( pS ){
        /* The "table" is actually a sub-select or a view in the FROM clause
        ** of the SELECT statement. Return the declaration type and origin
        ** data for the result-set column of the sub-select.
        */
        if( iCol>=0 && iCol<pS->pEList->nExpr ){
          /* If iCol is less than zero, then the expression requests the
................................................................................
          NameContext sNC;
          Expr *p = pS->pEList->a[iCol].pExpr;
          sNC.pSrcList = pS->pSrc;
          sNC.pNext = 0;
          sNC.pParse = pNC->pParse;
          zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol); 
        }
      }else
#endif
      if( pTab->pSchema ){
        /* A real table */
        assert( !pS );
        if( iCol<0 ) iCol = pTab->iPKey;
        assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
        if( iCol<0 ){
          zType = "INTEGER";
          zOriginCol = "rowid";







|







 







<







 







<
<
|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
837
838
839
840
841
842
843

844
845
846
847
848
849
850
...
854
855
856
857
858
859
860


861
862
863
864
865
866
867
868
**    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 SELECT statements in SQLite.
**
** $Id: select.c,v 1.316 2006/06/20 11:01:08 danielk1977 Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
        ** a segfault.  See ticket #1229.
        */
        zType = "TEXT";
        break;
      }

      assert( pTab );

      if( pS ){
        /* The "table" is actually a sub-select or a view in the FROM clause
        ** of the SELECT statement. Return the declaration type and origin
        ** data for the result-set column of the sub-select.
        */
        if( iCol>=0 && iCol<pS->pEList->nExpr ){
          /* If iCol is less than zero, then the expression requests the
................................................................................
          NameContext sNC;
          Expr *p = pS->pEList->a[iCol].pExpr;
          sNC.pSrcList = pS->pSrc;
          sNC.pNext = 0;
          sNC.pParse = pNC->pParse;
          zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol); 
        }


      }else if( pTab->pSchema ){
        /* A real table */
        assert( !pS );
        if( iCol<0 ) iCol = pTab->iPKey;
        assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
        if( iCol<0 ){
          zType = "INTEGER";
          zOriginCol = "rowid";

Changes to src/test1.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
3794
3795
3796
3797
3798
3799
3800

3801
3802

3803
3804
3805
3806
3807
3808
3809
**    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.211 2006/06/14 10:38:03 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
      (char*)&sqlite3_open_file_count, TCL_LINK_INT);
  Tcl_LinkVar(interp, "sqlite_current_time", 
      (char*)&sqlite3_current_time, TCL_LINK_INT);
  Tcl_LinkVar(interp, "sqlite_os_trace",
      (char*)&sqlite3_os_trace, TCL_LINK_INT);
  Tcl_LinkVar(interp, "sqlite3_tsd_count",
      (char*)&sqlite3_tsd_count, TCL_LINK_INT);

  Tcl_LinkVar(interp, "unaligned_string_counter",
      (char*)&unaligned_string_counter, TCL_LINK_INT);

#if OS_UNIX && defined(SQLITE_TEST) && defined(THREADSAFE) && THREADSAFE
  Tcl_LinkVar(interp, "threadsOverrideEachOthersLocks",
      (char*)&threadsOverrideEachOthersLocks, TCL_LINK_INT);
#endif
#ifndef SQLITE_OMIT_UTF16
  Tcl_LinkVar(interp, "sqlite_last_needed_collation",
      (char*)&pzNeededCollation, TCL_LINK_STRING|TCL_LINK_READ_ONLY);







|







 







>


>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
**    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.212 2006/06/20 11:01:08 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
      (char*)&sqlite3_open_file_count, TCL_LINK_INT);
  Tcl_LinkVar(interp, "sqlite_current_time", 
      (char*)&sqlite3_current_time, TCL_LINK_INT);
  Tcl_LinkVar(interp, "sqlite_os_trace",
      (char*)&sqlite3_os_trace, TCL_LINK_INT);
  Tcl_LinkVar(interp, "sqlite3_tsd_count",
      (char*)&sqlite3_tsd_count, TCL_LINK_INT);
#ifndef SQLITE_OMIT_UTF16
  Tcl_LinkVar(interp, "unaligned_string_counter",
      (char*)&unaligned_string_counter, TCL_LINK_INT);
#endif
#if OS_UNIX && defined(SQLITE_TEST) && defined(THREADSAFE) && THREADSAFE
  Tcl_LinkVar(interp, "threadsOverrideEachOthersLocks",
      (char*)&threadsOverrideEachOthersLocks, TCL_LINK_INT);
#endif
#ifndef SQLITE_OMIT_UTF16
  Tcl_LinkVar(interp, "sqlite_last_needed_collation",
      (char*)&pzNeededCollation, TCL_LINK_STRING|TCL_LINK_READ_ONLY);

Changes to src/test8.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
318
319
320
321
322
323
324



325
326
327
328
329
330
331
...
355
356
357
358
359
360
361

362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
...
392
393
394
395
396
397
398
399



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
...
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test8.c,v 1.26 2006/06/19 12:02:59 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................

  return rc;
}

static int echoColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
  int iCol = i + 1;
  sqlite3_stmt *pStmt = ((echo_cursor *)cur)->pStmt;




  assert( sqlite3_data_count(pStmt)>iCol );
  sqlite3_result_value(ctx, sqlite3_column_value(pStmt, iCol));
  return SQLITE_OK;
}

static int echoRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
................................................................................

static int echoFilter(
  sqlite3_vtab_cursor *pVtabCursor, 
  int idxNum, const char *idxStr,
  int argc, sqlite3_value **argv
){
  int rc;

  int i;

  echo_cursor *pCur = (echo_cursor *)pVtabCursor;
  echo_vtab *pVtab = (echo_vtab *)pVtabCursor->pVtab;
  sqlite3 *db = pVtab->db;

  assert( idxNum==hashString(idxStr) );
  sqlite3_finalize(pCur->pStmt);
  pCur->pStmt = 0;
  rc = sqlite3_prepare(db, idxStr, -1, &pCur->pStmt, 0);
  for(i=0; i<argc; i++){
    switch( sqlite3_value_type(argv[i]) ){
      case SQLITE_INTEGER: {
        sqlite3_bind_int64(pCur->pStmt, i+1, sqlite3_value_int64(argv[i]));
        break;
      }
      case SQLITE_FLOAT: {
        sqlite3_bind_double(pCur->pStmt, i+1, sqlite3_value_double(argv[i]));
................................................................................
        sqlite3_bind_blob(pCur->pStmt, i+1, sqlite3_value_blob(argv[i]),
                          sqlite3_value_bytes(argv[i]), SQLITE_TRANSIENT);
        break;
      }
    }
  }
  if( rc==SQLITE_OK ){
    rc = echoNext(pVtabCursor);



  }

  appendToEchoModule(pVtab->interp, "xFilter");
  appendToEchoModule(pVtab->interp, idxStr);
  for(i=0; i<argc; i++){
    appendToEchoModule(pVtab->interp, sqlite3_value_text(argv[i]));
  }

  return rc;
}

/*
** The echo module implements the subset of query constraints and sort
** orders that may take advantage of SQLite indices on the underlying
** real table. For example, if the real table is declared as:
**
................................................................................

  /* If the first argument is NULL and there are more than two args, INSERT */
  else if( nData>2 && sqlite3_value_type(apData[0])==SQLITE_NULL ){
    int ii;
    char *zInsert = 0;
    char *zValues = 0;
  
    zInsert = sqlite3_mprintf("INSERT OR REPLACE INTO %Q (", pVtab->zTableName);
    if( sqlite3_value_type(apData[1])==SQLITE_INTEGER ){
      bindArgOne = 1;
      zValues = sqlite3_mprintf("?");
      string_concat(&zInsert, "rowid", 0);
    }

    assert((pVtab->nCol+2)==nData);







|







 







>
>
>







 







>










|







 







|
>
>
>








|







 







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
...
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
...
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test8.c,v 1.27 2006/06/20 11:01:08 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................

  return rc;
}

static int echoColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
  int iCol = i + 1;
  sqlite3_stmt *pStmt = ((echo_cursor *)cur)->pStmt;
  if( ((echo_cursor *)cur)->errcode ){
    return ((echo_cursor *)cur)->errcode;
  }

  assert( sqlite3_data_count(pStmt)>iCol );
  sqlite3_result_value(ctx, sqlite3_column_value(pStmt, iCol));
  return SQLITE_OK;
}

static int echoRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
................................................................................

static int echoFilter(
  sqlite3_vtab_cursor *pVtabCursor, 
  int idxNum, const char *idxStr,
  int argc, sqlite3_value **argv
){
  int rc;
  int ret;
  int i;

  echo_cursor *pCur = (echo_cursor *)pVtabCursor;
  echo_vtab *pVtab = (echo_vtab *)pVtabCursor->pVtab;
  sqlite3 *db = pVtab->db;

  assert( idxNum==hashString(idxStr) );
  sqlite3_finalize(pCur->pStmt);
  pCur->pStmt = 0;
  rc = sqlite3_prepare(db, idxStr, -1, &pCur->pStmt, 0);
  for(i=0; rc==SQLITE_OK && i<argc; i++){
    switch( sqlite3_value_type(argv[i]) ){
      case SQLITE_INTEGER: {
        sqlite3_bind_int64(pCur->pStmt, i+1, sqlite3_value_int64(argv[i]));
        break;
      }
      case SQLITE_FLOAT: {
        sqlite3_bind_double(pCur->pStmt, i+1, sqlite3_value_double(argv[i]));
................................................................................
        sqlite3_bind_blob(pCur->pStmt, i+1, sqlite3_value_blob(argv[i]),
                          sqlite3_value_bytes(argv[i]), SQLITE_TRANSIENT);
        break;
      }
    }
  }
  if( rc==SQLITE_OK ){
    ret = echoNext(pVtabCursor);
  }else{
    ret = 0;
    pCur->errcode = rc;
  }

  appendToEchoModule(pVtab->interp, "xFilter");
  appendToEchoModule(pVtab->interp, idxStr);
  for(i=0; i<argc; i++){
    appendToEchoModule(pVtab->interp, sqlite3_value_text(argv[i]));
  }

  return ret;
}

/*
** The echo module implements the subset of query constraints and sort
** orders that may take advantage of SQLite indices on the underlying
** real table. For example, if the real table is declared as:
**
................................................................................

  /* If the first argument is NULL and there are more than two args, INSERT */
  else if( nData>2 && sqlite3_value_type(apData[0])==SQLITE_NULL ){
    int ii;
    char *zInsert = 0;
    char *zValues = 0;
  
    zInsert = sqlite3_mprintf("INSERT INTO %Q (", pVtab->zTableName);
    if( sqlite3_value_type(apData[1])==SQLITE_INTEGER ){
      bindArgOne = 1;
      zValues = sqlite3_mprintf("?");
      string_concat(&zInsert, "rowid", 0);
    }

    assert((pVtab->nCol+2)==nData);

Changes to src/test_schema.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
88
89
90
91
92
93
94

95

96
97
98
99
100
101
102
...
334
335
336
337
338
339
340

341

342
343
344
345
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test_schema.c,v 1.4 2006/06/17 13:21:33 drh Exp $
*/

/* The code in this file defines a sqlite3 virtual-table module that
** provides a read-only view of the current database schema. There is one
** row in the schema table for each column in the database schema.
*/
#define SCHEMA \
................................................................................
  sqlite3_vtab **ppVtab
){
  int rc = SQLITE_NOMEM;
  schema_vtab *pVtab = MALLOC(sizeof(schema_vtab));
  if( pVtab ){
    memset(pVtab, 0, sizeof(schema_vtab));
    pVtab->db = db;

    rc = sqlite3_declare_vtab(db, SCHEMA);

  }
  *ppVtab = (sqlite3_vtab *)pVtab;
  return rc;
}

/*
** Open a new cursor on the schema table.
................................................................................
*/
int sqlite3_extension_init(
  sqlite3 *db, 
  char **pzErrMsg, 
  const sqlite3_api_routines *pApi
){
  SQLITE_EXTENSION_INIT2(pApi);

  sqlite3_create_module(db, "schema", &schemaModule, 0);

  return 0;
}

#endif







|







 







>

>







 







>

>




9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
336
337
338
339
340
341
342
343
344
345
346
347
348
349
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test_schema.c,v 1.5 2006/06/20 11:01:08 danielk1977 Exp $
*/

/* The code in this file defines a sqlite3 virtual-table module that
** provides a read-only view of the current database schema. There is one
** row in the schema table for each column in the database schema.
*/
#define SCHEMA \
................................................................................
  sqlite3_vtab **ppVtab
){
  int rc = SQLITE_NOMEM;
  schema_vtab *pVtab = MALLOC(sizeof(schema_vtab));
  if( pVtab ){
    memset(pVtab, 0, sizeof(schema_vtab));
    pVtab->db = db;
#ifndef SQLITE_OMIT_VIRTUALTABLE
    rc = sqlite3_declare_vtab(db, SCHEMA);
#endif
  }
  *ppVtab = (sqlite3_vtab *)pVtab;
  return rc;
}

/*
** Open a new cursor on the schema table.
................................................................................
*/
int sqlite3_extension_init(
  sqlite3 *db, 
  char **pzErrMsg, 
  const sqlite3_api_routines *pApi
){
  SQLITE_EXTENSION_INIT2(pApi);
#ifndef SQLITE_OMIT_VIRTUALTABLE
  sqlite3_create_module(db, "schema", &schemaModule, 0);
#endif
  return 0;
}

#endif

Changes to src/vdbeaux.c.

247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
  Op *pOp;
  int *aLabel = p->aLabel;
  int doesStatementRollback = 0;
  int hasStatementBegin = 0;
  for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
    u8 opcode = pOp->opcode;

    if( opcode==OP_Function || opcode==OP_AggStep ||
#ifndef SQLITE_OMIT_VIRTUALTABLE
        opcode==OP_VUpdate
#endif
    ){
      if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
    }else if( opcode==OP_Halt ){
      if( pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort ){
        doesStatementRollback = 1;
      }







|

|







247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
  Op *pOp;
  int *aLabel = p->aLabel;
  int doesStatementRollback = 0;
  int hasStatementBegin = 0;
  for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
    u8 opcode = pOp->opcode;

    if( opcode==OP_Function || opcode==OP_AggStep 
#ifndef SQLITE_OMIT_VIRTUALTABLE
        || opcode==OP_VUpdate
#endif
    ){
      if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
    }else if( opcode==OP_Halt ){
      if( pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort ){
        doesStatementRollback = 1;
      }

Changes to test/attach3.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
248
249
250
251
252
253
254






255
256
257
258
259
260
261
...
328
329
330
331
332
333
334
335


336
#    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 ATTACH and DETACH commands
# and schema changes to attached databases.
#
# $Id: attach3.test,v 1.16 2006/05/25 11:52:38 drh Exp $
#


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

# Create tables t1 and t2 in the main database
................................................................................
  set x [execsql {
    PRAGMA database_list;
  }]
  set y {}
  foreach {n id file} $x {lappend y $id}
  return $y
}







# Ticket #1825
#
do_test attach3-12.1 {
  db_list
} {main temp aux}
do_test attach3-12.2 {
................................................................................
} {main temp {}}
do_test attach3-12.14 {
  execsql {
    DETACH '';
  }
  db_list
} {main temp}



finish_test







|







 







>
>
>
>
>
>







 








>
>

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
...
334
335
336
337
338
339
340
341
342
343
344
#    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 ATTACH and DETACH commands
# and schema changes to attached databases.
#
# $Id: attach3.test,v 1.17 2006/06/20 11:01:09 danielk1977 Exp $
#


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

# Create tables t1 and t2 in the main database
................................................................................
  set x [execsql {
    PRAGMA database_list;
  }]
  set y {}
  foreach {n id file} $x {lappend y $id}
  return $y
}

ifcapable schema_pragmas&&tempdb {

ifcapable !trigger {
  execsql {create temp table dummy(dummy)}
}

# Ticket #1825
#
do_test attach3-12.1 {
  db_list
} {main temp aux}
do_test attach3-12.2 {
................................................................................
} {main temp {}}
do_test attach3-12.14 {
  execsql {
    DETACH '';
  }
  db_list
} {main temp}

} ;# ifcapable pragma

finish_test

Changes to test/autovacuum.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
521
522
523
524
525
526
527


528
529
530
531
532
533
534
535
536
537
538
539


540
541
542
543
544
545
546
547
548
549
550
551
552


553
554
555
556
557
558
559
...
566
567
568
569
570
571
572
573


574
#    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 SELECT statement.
#
# $Id: autovacuum.test,v 1.22 2006/03/24 03:36:26 drh Exp $

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

# If this build of the library does not support auto-vacuum, omit this
# whole file.
ifcapable {!autovacuum || !pragma} {
................................................................................
} {5049}
do_test autovacuum-4.4 {
  execsql {
    COMMIT;
  }
} {}



# Ticket #1727
do_test autovacuum-5.1 {
  db close
  sqlite3 db :memory:
  db eval {
    PRAGMA auto_vacuum=1;
    CREATE TABLE t1(a);
    CREATE TABLE t2(a);
    DROP TABLE t1;
    PRAGMA integrity_check;
  }
} ok



# Ticket #1728.
#
# In autovacuum mode, when tables or indices are deleted, the rootpage
# values in the symbol table have to be updated.  There was a bug in this
# logic so that if an index/table was moved twice, the second move might
# not occur.  This would leave the internal symbol table in an inconsistent
# state causing subsequent statements to fail.
#
# The problem is difficult to reproduce.  The sequence of statements in
# the following test are carefully designed make it occur and thus to
# verify that this very obscure bug has been resolved.
# 


do_test autovacuum-6.1 {
  db close
  sqlite3 db :memory:
  db eval {
    PRAGMA auto_vacuum=1;
    CREATE TABLE t1(a, b);
    CREATE INDEX i1 ON t1(a);
................................................................................
    PRAGMA integrity_check;
    DROP TABLE t2;
    PRAGMA integrity_check;
    DROP TABLE t1;
    PRAGMA integrity_check;
  }
} {ok ok ok}



finish_test







|







 







>
>












>
>













>
>







 








>
>

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
...
572
573
574
575
576
577
578
579
580
581
582
#    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 SELECT statement.
#
# $Id: autovacuum.test,v 1.23 2006/06/20 11:01:09 danielk1977 Exp $

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

# If this build of the library does not support auto-vacuum, omit this
# whole file.
ifcapable {!autovacuum || !pragma} {
................................................................................
} {5049}
do_test autovacuum-4.4 {
  execsql {
    COMMIT;
  }
} {}

ifcapable integrityck {

# Ticket #1727
do_test autovacuum-5.1 {
  db close
  sqlite3 db :memory:
  db eval {
    PRAGMA auto_vacuum=1;
    CREATE TABLE t1(a);
    CREATE TABLE t2(a);
    DROP TABLE t1;
    PRAGMA integrity_check;
  }
} ok

}

# Ticket #1728.
#
# In autovacuum mode, when tables or indices are deleted, the rootpage
# values in the symbol table have to be updated.  There was a bug in this
# logic so that if an index/table was moved twice, the second move might
# not occur.  This would leave the internal symbol table in an inconsistent
# state causing subsequent statements to fail.
#
# The problem is difficult to reproduce.  The sequence of statements in
# the following test are carefully designed make it occur and thus to
# verify that this very obscure bug has been resolved.
# 
ifcapable integrityck&&memorydb {

do_test autovacuum-6.1 {
  db close
  sqlite3 db :memory:
  db eval {
    PRAGMA auto_vacuum=1;
    CREATE TABLE t1(a, b);
    CREATE INDEX i1 ON t1(a);
................................................................................
    PRAGMA integrity_check;
    DROP TABLE t2;
    PRAGMA integrity_check;
    DROP TABLE t1;
    PRAGMA integrity_check;
  }
} {ok ok ok}

}

finish_test

Changes to test/check.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
291
292
293
294
295
296
297


298
299
300
301
302
303
304
...
340
341
342
343
344
345
346
347
348
349
#    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 CHECK constraints
#
# $Id: check.test,v 1.9 2006/03/15 16:26:10 drh Exp $

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

# Only run these tests if the build includes support for CHECK constraints
ifcapable !check {
  finish_test
................................................................................
  catchsql {
    CREATE TABLE t5(x, y,
      CHECK( x*y<? )
    );
  }
} {1 {parameters prohibited in CHECK constraints}}



do_test check-6.1 {
  execsql {SELECT * FROM t1}
} {4 11.0}
do_test check-6.2 {
  execsql {
    UPDATE OR IGNORE t1 SET x=5;
    SELECT * FROM t1;
................................................................................
} {1 {cannot commit - no transaction is active}}
do_test check-6.9 {
  execsql {
    SELECT * FROM t1
  }
} {3 12.0 2 20.0}



finish_test







|







 







>
>







 







|


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
...
342
343
344
345
346
347
348
349
350
351
#    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 CHECK constraints
#
# $Id: check.test,v 1.10 2006/06/20 11:01:09 danielk1977 Exp $

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

# Only run these tests if the build includes support for CHECK constraints
ifcapable !check {
  finish_test
................................................................................
  catchsql {
    CREATE TABLE t5(x, y,
      CHECK( x*y<? )
    );
  }
} {1 {parameters prohibited in CHECK constraints}}

ifcapable conflict {

do_test check-6.1 {
  execsql {SELECT * FROM t1}
} {4 11.0}
do_test check-6.2 {
  execsql {
    UPDATE OR IGNORE t1 SET x=5;
    SELECT * FROM t1;
................................................................................
} {1 {cannot commit - no transaction is active}}
do_test check-6.9 {
  execsql {
    SELECT * FROM t1
  }
} {3 12.0 2 20.0}

}

finish_test

Changes to test/func.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
577
578
579
580
581
582
583



584
585
586
587
588
589
590
...
625
626
627
628
629
630
631


632
633
634
635
636
637
638
#    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 built-in functions.
#
# $Id: func.test,v 1.52 2006/06/13 17:39:01 drh Exp $

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

# Create a table to work with.
#
do_test func-0.0 {
................................................................................
  }
} 0.0
do_test func-18.14 {
  execsql {
    SELECT sum(-9223372036854775805);
  }
} -9223372036854775805



do_test func-18.15 {
  catchsql {
    SELECT sum(x) FROM 
       (SELECT 9223372036854775807 AS x UNION ALL
        SELECT 10 AS x);
  }
} {1 {integer overflow}}
................................................................................
  }
} {0 -1}
do_test func-18.22 {
  catchsql {
    SELECT sum(x) FROM (SELECT 10 AS x UNION ALL SELECT -9 AS x);
  }
} {0 1}



# Integer overflow on abs()
#
do_test func-18.31 {
  catchsql {
    SELECT abs(-9223372036854775807);
  }







|







 







>
>
>







 







>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
...
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
#    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 built-in functions.
#
# $Id: func.test,v 1.53 2006/06/20 11:01:09 danielk1977 Exp $

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

# Create a table to work with.
#
do_test func-0.0 {
................................................................................
  }
} 0.0
do_test func-18.14 {
  execsql {
    SELECT sum(-9223372036854775805);
  }
} -9223372036854775805

ifcapable compound&&subquery {

do_test func-18.15 {
  catchsql {
    SELECT sum(x) FROM 
       (SELECT 9223372036854775807 AS x UNION ALL
        SELECT 10 AS x);
  }
} {1 {integer overflow}}
................................................................................
  }
} {0 -1}
do_test func-18.22 {
  catchsql {
    SELECT sum(x) FROM (SELECT 10 AS x UNION ALL SELECT -9 AS x);
  }
} {0 1}

} ;# ifcapable compound&&subquery

# Integer overflow on abs()
#
do_test func-18.31 {
  catchsql {
    SELECT abs(-9223372036854775807);
  }

Changes to test/join.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
442
443
444
445
446
447
448

449
450
451
452
453
454
455
456
457

458
459
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for joins, including outer joins.
#
# $Id: join.test,v 1.21 2006/03/02 04:44:24 drh Exp $

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

do_test join-1.1 {
  execsql {
    CREATE TABLE t1(a,b,c);
................................................................................
  } {}
} ;# ifcapable view
} ;# ifcapable compound

# Ticket #1697:  Left Join WHERE clause terms that contain an
# aggregate subquery.
#

do_test join-10.1 {
  execsql {
    CREATE TABLE t21(a,b,c);
    CREATE TABLE t22(p,q);
    CREATE INDEX i22 ON t22(q);
    SELECT a FROM t21 LEFT JOIN t22 ON b=p WHERE q=
       (SELECT max(m.q) FROM t22 m JOIN t21 n ON n.b=m.p WHERE n.c=1);
  }  
} {}


finish_test







|







 







>









>


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for joins, including outer joins.
#
# $Id: join.test,v 1.22 2006/06/20 11:01:09 danielk1977 Exp $

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

do_test join-1.1 {
  execsql {
    CREATE TABLE t1(a,b,c);
................................................................................
  } {}
} ;# ifcapable view
} ;# ifcapable compound

# Ticket #1697:  Left Join WHERE clause terms that contain an
# aggregate subquery.
#
ifcapable subquery {
do_test join-10.1 {
  execsql {
    CREATE TABLE t21(a,b,c);
    CREATE TABLE t22(p,q);
    CREATE INDEX i22 ON t22(q);
    SELECT a FROM t21 LEFT JOIN t22 ON b=p WHERE q=
       (SELECT max(m.q) FROM t22 m JOIN t21 n ON n.b=m.p WHERE n.c=1);
  }  
} {}
} ;# ifcapable subquery

finish_test

Changes to test/limit.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
433
434
435
436
437
438
439

440
441
442
443
444

445
446
#    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 LIMIT ... OFFSET ... clause
#  of SELECT statements.
#
# $Id: limit.test,v 1.29 2006/04/26 17:39:34 drh Exp $

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

# Build some test data
#
execsql {
................................................................................
  set rc [catch {
  db eval {
    SELECT x FROM t1 WHERE x<10 LIMIT :limit;
  } } msg]
  list $rc $msg
} {1 {datatype mismatch}}


do_test limit-11.1 {
  db eval {
     SELECT x FROM (SELECT x FROM t1 ORDER BY x LIMIT 0) ORDER BY x
  }
} {}


finish_test







|







 







>





>


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
#    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 LIMIT ... OFFSET ... clause
#  of SELECT statements.
#
# $Id: limit.test,v 1.30 2006/06/20 11:01:09 danielk1977 Exp $

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

# Build some test data
#
execsql {
................................................................................
  set rc [catch {
  db eval {
    SELECT x FROM t1 WHERE x<10 LIMIT :limit;
  } } msg]
  list $rc $msg
} {1 {datatype mismatch}}

ifcapable subquery {
do_test limit-11.1 {
  db eval {
     SELECT x FROM (SELECT x FROM t1 ORDER BY x LIMIT 0) ORDER BY x
  }
} {}
} ;# ifcapable subquery

finish_test

Changes to test/pragma.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
798
799
800
801
802
803
804


805
806
807
808
809
810
811
...
820
821
822
823
824
825
826


827
828
829
830
831
832
833
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.42 2006/03/19 13:00:25 drh Exp $

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

# Test organization:
#
# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
    execsql {
      PRAGMA temp.cache_size = 400;
      PRAGMA temp.cache_size;
    } db2
  } {400}
  db2 close
}



do_test pragma-13.1 {
  execsql {
    DROP TABLE IF EXISTS t4;
    PRAGMA vdbe_trace=on;
    PRAGMA vdbe_listing=on;
    PRAGMA sql_trace=on;
................................................................................
  }
  execsql {
    PRAGMA vdbe_trace=off;
    PRAGMA vdbe_listing=off;
    PRAGMA sql_trace=off;
  }
} {}



# Reset the sqlite3_temp_directory variable for the next run of tests:
sqlite3 dbX :memory:
dbX eval {PRAGMA temp_store_directory = ""}
dbX close

finish_test







|







 







>
>







 







>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
...
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.43 2006/06/20 11:01:09 danielk1977 Exp $

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

# Test organization:
#
# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
    execsql {
      PRAGMA temp.cache_size = 400;
      PRAGMA temp.cache_size;
    } db2
  } {400}
  db2 close
}

ifcapable bloblit {

do_test pragma-13.1 {
  execsql {
    DROP TABLE IF EXISTS t4;
    PRAGMA vdbe_trace=on;
    PRAGMA vdbe_listing=on;
    PRAGMA sql_trace=on;
................................................................................
  }
  execsql {
    PRAGMA vdbe_trace=off;
    PRAGMA vdbe_listing=off;
    PRAGMA sql_trace=off;
  }
} {}

} ;# ifcapable bloblit 

# Reset the sqlite3_temp_directory variable for the next run of tests:
sqlite3 dbX :memory:
dbX eval {PRAGMA temp_store_directory = ""}
dbX close

finish_test

Changes to test/select4.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
509
510
511
512
513
514
515


516
517
518
519
520
521
522
...
539
540
541
542
543
544
545


546
547
548
549
550
551
552
...
561
562
563
564
565
566
567


568
569
570
571
572
573
574
575
576
577
578
579
580


581
582
583
584
585
586
587
588
...
598
599
600
601
602
603
604

605


606
#    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 UNION, INTERSECT and EXCEPT operators
# in SELECT statements.
#
# $Id: select4.test,v 1.19 2006/03/26 01:21:23 drh Exp $

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

# Most tests in this file depend on compound-select. But there are a couple
# right at the end that test DISTINCT, so we cannot omit the entire file.
#
................................................................................
    SELECT DISTINCT c FROM t3 ORDER BY c;
  }
} {1.1 1.10 1.2 1.3}

# Make sure the names of columns are takenf rom the right-most subquery
# right in a compound query.  Ticket #1721
#


do_test select4-9.1 {
  execsql2 {
    SELECT x, y FROM t2 UNION SELECT a, b FROM t3 ORDER BY x LIMIT 1
  }
} {x 0 y 1}
do_test select4-9.2 {
  execsql2 {
................................................................................
    UNION
    SELECT 2 AS p, 3 AS q
    UNION
    SELECT 4 AS a, 5 AS b
    ORDER BY x LIMIT 1
  }
} {x 0 y 1}


do_test select4-9.6 {
  execsql2 {
    SELECT * FROM (
      SELECT 0 AS x, 1 AS y
      UNION
      SELECT 2 AS p, 3 AS q
      UNION
................................................................................
      UNION
      SELECT 2 AS p, 3 AS q
      UNION
      SELECT 4 AS a, 5 AS b
    ) ORDER BY x LIMIT 1;
  }
} {x 0 y 1}


do_test select4-9.8 {
  execsql2 {
    SELECT 0 AS x, 1 AS y
    UNION
    SELECT 2 AS y, -3 AS x
    ORDER BY x LIMIT 1;
  }
} {x 0 y 1}
do_test select4-9.9 {
  execsql2 {
    SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a
  }
} {a 1 b 2 a 3 b 4}


do_test select4-9.9 {
  execsql2 {
    SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a)
     WHERE b=3
  }
} {}
do_test select4-9.10 {
  execsql2 {
................................................................................
} {a 1 b 2}
do_test select4-9.12 {
  execsql2 {
    SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS e, 4 AS b)
     WHERE b>0
  }
} {a 1 b 2 a 3 b 4}




finish_test







|







 







>
>







 







>
>







 







>
>








|




>
>
|







 







>

>
>

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
...
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
...
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
...
606
607
608
609
610
611
612
613
614
615
616
617
#    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 UNION, INTERSECT and EXCEPT operators
# in SELECT statements.
#
# $Id: select4.test,v 1.20 2006/06/20 11:01:09 danielk1977 Exp $

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

# Most tests in this file depend on compound-select. But there are a couple
# right at the end that test DISTINCT, so we cannot omit the entire file.
#
................................................................................
    SELECT DISTINCT c FROM t3 ORDER BY c;
  }
} {1.1 1.10 1.2 1.3}

# Make sure the names of columns are takenf rom the right-most subquery
# right in a compound query.  Ticket #1721
#
ifcapable compound {

do_test select4-9.1 {
  execsql2 {
    SELECT x, y FROM t2 UNION SELECT a, b FROM t3 ORDER BY x LIMIT 1
  }
} {x 0 y 1}
do_test select4-9.2 {
  execsql2 {
................................................................................
    UNION
    SELECT 2 AS p, 3 AS q
    UNION
    SELECT 4 AS a, 5 AS b
    ORDER BY x LIMIT 1
  }
} {x 0 y 1}

ifcapable subquery {
do_test select4-9.6 {
  execsql2 {
    SELECT * FROM (
      SELECT 0 AS x, 1 AS y
      UNION
      SELECT 2 AS p, 3 AS q
      UNION
................................................................................
      UNION
      SELECT 2 AS p, 3 AS q
      UNION
      SELECT 4 AS a, 5 AS b
    ) ORDER BY x LIMIT 1;
  }
} {x 0 y 1}
} ;# ifcapable subquery

do_test select4-9.8 {
  execsql2 {
    SELECT 0 AS x, 1 AS y
    UNION
    SELECT 2 AS y, -3 AS x
    ORDER BY x LIMIT 1;
  }
} {x 0 y 1}
do_test select4-9.9.1 {
  execsql2 {
    SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a
  }
} {a 1 b 2 a 3 b 4}

ifcapable subquery {
do_test select4-9.9.2 {
  execsql2 {
    SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a)
     WHERE b=3
  }
} {}
do_test select4-9.10 {
  execsql2 {
................................................................................
} {a 1 b 2}
do_test select4-9.12 {
  execsql2 {
    SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS e, 4 AS b)
     WHERE b>0
  }
} {a 1 b 2 a 3 b 4}
} ;# ifcapable subquery

} ;# ifcapable compound

finish_test

Changes to test/tkt1667.test.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to verify that ticket #1667 has been
# fixed.  
#
#
# $Id: tkt1667.test,v 1.1 2006/02/10 08:24:21 danielk1977 Exp $

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

ifcapable !autovacuum {
  finish_test
  return
}

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








|




|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to verify that ticket #1667 has been
# fixed.  
#
#
# $Id: tkt1667.test,v 1.2 2006/06/20 11:01:09 danielk1977 Exp $

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

ifcapable !autovacuum||!tclvar {
  finish_test
  return
}

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

Changes to test/trans.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
#    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 script is database locks.
#
# $Id: trans.test,v 1.31 2006/06/04 23:20:10 drh Exp $


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


# Create several tables to work with.
................................................................................
      } 1
      ifcapable pager_pragmas {
        do_test trans-9.$i.5-$cnt {
           expr {$sqlite_fullsync_count>0}
        } [expr {$i%2==0}]
      } else {
        do_test trans-9.$i.5-$cnt {
           expr {$sqlite_fullsync_count>0}
        } {1}
      }
    }
  }
  set ::pager_old_format 0
}
   
finish_test







|







 







|








7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
#    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 script is database locks.
#
# $Id: trans.test,v 1.32 2006/06/20 11:01:09 danielk1977 Exp $


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


# Create several tables to work with.
................................................................................
      } 1
      ifcapable pager_pragmas {
        do_test trans-9.$i.5-$cnt {
           expr {$sqlite_fullsync_count>0}
        } [expr {$i%2==0}]
      } else {
        do_test trans-9.$i.5-$cnt {
          expr {$sqlite_fullsync_count>0}
        } {1}
      }
    }
  }
  set ::pager_old_format 0
}
   
finish_test

Changes to test/vtab1.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
195
196
197
198
199
200
201
202
203
204
205
206


207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#    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 creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.22 2006/06/19 03:05:10 danielk1977 Exp $

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

ifcapable !vtab {
  finish_test
  return
}

#----------------------------------------------------------------------
# Organization of tests in this file:
#
................................................................................
  set echo_module
} {xConnect echo template}

# Drop table t1. This should cause the xDestroy (but not xDisconnect) method 
# to be invoked.
do_test vtab1-2.5 {
  set echo_module ""
  execsql { 
    DROP TABLE t1;
  }
  set echo_module
} {xDestroy}


do_test vtab1-2.6 {
  execsql { 
    PRAGMA table_info(t1); 
  }
} {}
do_test vtab1-2.7 {
  execsql {
    SELECT sql FROM sqlite_master;
  }
} [list {CREATE TABLE template(a, b, c)}]

# Clean up other test artifacts:
do_test vtab1-2.8 {
  execsql { 
    DROP TABLE template;
    SELECT sql FROM sqlite_master;
  }
} [list]







|




|







 







|




>
>










<







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

219
220
221
222
223
224
225
#    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 creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.23 2006/06/20 11:01:09 danielk1977 Exp $

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

ifcapable !vtab||!schema_pragmas {
  finish_test
  return
}

#----------------------------------------------------------------------
# Organization of tests in this file:
#
................................................................................
  set echo_module
} {xConnect echo template}

# Drop table t1. This should cause the xDestroy (but not xDisconnect) method 
# to be invoked.
do_test vtab1-2.5 {
  set echo_module ""
  execsql {
    DROP TABLE t1;
  }
  set echo_module
} {xDestroy}
finish_test

do_test vtab1-2.6 {
  execsql { 
    PRAGMA table_info(t1); 
  }
} {}
do_test vtab1-2.7 {
  execsql {
    SELECT sql FROM sqlite_master;
  }
} [list {CREATE TABLE template(a, b, c)}]

# Clean up other test artifacts:
do_test vtab1-2.8 {
  execsql { 
    DROP TABLE template;
    SELECT sql FROM sqlite_master;
  }
} [list]

Changes to test/vtab2.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
32
33
34
35
36
37
38

39
40
#    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.
#
# $Id: vtab2.test,v 1.2 2006/06/19 03:05:10 danielk1977 Exp $

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

ifcapable !vtab {
  finish_test
  return
}

register_schema_module [sqlite3_connection_pointer db]
do_test vtab2-1.1 {
  execsql {
................................................................................
  main schema 2 cid        {} 0 {} 0 \
  main schema 3 name       {} 0 {} 0 \
  main schema 4 type       {} 0 {} 0 \
  main schema 5 not_null   {} 0 {} 0 \
  main schema 6 dflt_value {} 0 {} 0 \
  main schema 7 pk         {} 0 {} 0 \
]

finish_test








|




|







 







>


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
32
33
34
35
36
37
38
39
40
41
#    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.
#
# $Id: vtab2.test,v 1.3 2006/06/20 11:01:09 danielk1977 Exp $

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

ifcapable !vtab||!schema_pragmas {
  finish_test
  return
}

register_schema_module [sqlite3_connection_pointer db]
do_test vtab2-1.1 {
  execsql {
................................................................................
  main schema 2 cid        {} 0 {} 0 \
  main schema 3 name       {} 0 {} 0 \
  main schema 4 type       {} 0 {} 0 \
  main schema 5 not_null   {} 0 {} 0 \
  main schema 6 dflt_value {} 0 {} 0 \
  main schema 7 pk         {} 0 {} 0 \
]

finish_test

Changes to test/vtab3.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#    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 the authorisation callback and virtual tables.
#
# $Id: vtab3.test,v 1.1 2006/06/16 08:01:04 danielk1977 Exp $

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

ifcapable !vtab {
  finish_test
  return
}

set ::auth_fail 0
set ::auth_log [list]
set ::auth_filter [list SQLITE_READ SQLITE_UPDATE SQLITE_SELECT SQLITE_PRAGMA]







|




|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#    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 the authorisation callback and virtual tables.
#
# $Id: vtab3.test,v 1.2 2006/06/20 11:01:09 danielk1977 Exp $

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

ifcapable !vtab||!auth {
  finish_test
  return
}

set ::auth_fail 0
set ::auth_log [list]
set ::auth_filter [list SQLITE_READ SQLITE_UPDATE SQLITE_SELECT SQLITE_PRAGMA]

Changes to test/vtab5.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
98
99
100
101
102
103
104

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

127
128
#    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.
#
# $Id: vtab5.test,v 1.4 2006/06/19 06:32:23 danielk1977 Exp $

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

ifcapable !vtab {
  finish_test
  return
................................................................................
  execsql {
    SELECT str||'' FROM echo_strings ORDER BY 1;
  }
} {ABc2 Abc3 aBc4 abc1}

# Test that it is impossible to create a triggger on a virtual table.
#

do_test vtab5.3.1 {
  catchsql {
    CREATE TRIGGER trig INSTEAD OF INSERT ON echo_strings BEGIN
      SELECT 1, 2, 3;
    END;
  }
} {1 {cannot create triggers on virtual tables}}
do_test vtab5.3.2 {
  catchsql {
    CREATE TRIGGER trig AFTER INSERT ON echo_strings BEGIN
      SELECT 1, 2, 3;
    END;
  }
} {1 {cannot create triggers on virtual tables}}
do_test vtab5.3.2 {
  catchsql {
    CREATE TRIGGER trig BEFORE INSERT ON echo_strings BEGIN
      SELECT 1, 2, 3;
    END;
  }
} {1 {cannot create triggers on virtual tables}}


finish_test








|







 







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


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#    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.
#
# $Id: vtab5.test,v 1.5 2006/06/20 11:01:09 danielk1977 Exp $

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

ifcapable !vtab {
  finish_test
  return
................................................................................
  execsql {
    SELECT str||'' FROM echo_strings ORDER BY 1;
  }
} {ABc2 Abc3 aBc4 abc1}

# Test that it is impossible to create a triggger on a virtual table.
#
ifcapable trigger {
  do_test vtab5.3.1 {
    catchsql {
      CREATE TRIGGER trig INSTEAD OF INSERT ON echo_strings BEGIN
        SELECT 1, 2, 3;
      END;
    }
  } {1 {cannot create triggers on virtual tables}}
  do_test vtab5.3.2 {
    catchsql {
      CREATE TRIGGER trig AFTER INSERT ON echo_strings BEGIN
        SELECT 1, 2, 3;
      END;
    }
  } {1 {cannot create triggers on virtual tables}}
  do_test vtab5.3.2 {
    catchsql {
      CREATE TRIGGER trig BEFORE INSERT ON echo_strings BEGIN
        SELECT 1, 2, 3;
      END;
    }
  } {1 {cannot create triggers on virtual tables}}
}

finish_test

Changes to tool/omittest.tcl.

1
2
3
4
5
6
7
8
9
...
111
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
137
138
139
140

141
142
143
144
145
146






147
148
149
150
151
152
153

set rcsid {$Id: omittest.tcl,v 1.1 2006/01/26 13:11:37 danielk1977 Exp $}

# Documentation for this script. This may be output to stderr
# if the script is invoked incorrectly.
set ::USAGE_MESSAGE {
This Tcl script is used to test the various compile time options 
available for omitting code (the SQLITE_OMIT_xxx options). It
should be invoked as follows:
................................................................................
    }
    set ::MAKEFILE [file normalize $::MAKEFILE]
  }
}

# Main routine.
#

proc main {argv} {
  # List of SQLITE_OMIT_XXX symbols supported by SQLite.
  set ::SYMBOLS [list                  \
    SQLITE_OMIT_COMPLETE               \

    SQLITE_OMIT_ALTERTABLE             \
    SQLITE_OMIT_AUTOVACUUM             \
    SQLITE_OMIT_AUTHORIZATION          \
    SQLITE_OMIT_AUTOINCREMENT          \
    SQLITE_OMIT_BLOB_LITERAL           \
    SQLITE_OMIT_COMPOUND_SELECT        \
    SQLITE_OMIT_CONFLICT_CLAUSE        \
    SQLITE_OMIT_DATETIME_FUNCS         \
    SQLITE_OMIT_EXPLAIN                \
    SQLITE_OMIT_FLOATING_POINT         \
    SQLITE_OMIT_FOREIGN_KEY            \
    SQLITE_OMIT_INTEGRITY_CHECK        \
    SQLITE_OMIT_MEMORYDB               \
    SQLITE_OMIT_PAGER_PRAGMAS          \
    SQLITE_OMIT_PRAGMA                 \
    SQLITE_OMIT_PROGRESS_CALLBACK      \
    SQLITE_OMIT_REINDEX                \
    SQLITE_OMIT_SCHEMA_PRAGMAS         \
    SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \

    SQLITE_OMIT_SUBQUERY               \
    SQLITE_OMIT_TCL_VARIABLE           \
    SQLITE_OMIT_TRIGGER                \
    SQLITE_OMIT_UTF16                  \
    SQLITE_OMIT_VACUUM                 \
    SQLITE_OMIT_VIEW                   \






  ]

  # Process any command line options.
  process_options $argv
  
  # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT 
  # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)

|







 







>



|
>

<
<
<
<
<
<
<











>





|
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
...
111
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

set rcsid {$Id: omittest.tcl,v 1.2 2006/06/20 11:01:09 danielk1977 Exp $}

# Documentation for this script. This may be output to stderr
# if the script is invoked incorrectly.
set ::USAGE_MESSAGE {
This Tcl script is used to test the various compile time options 
available for omitting code (the SQLITE_OMIT_xxx options). It
should be invoked as follows:
................................................................................
    }
    set ::MAKEFILE [file normalize $::MAKEFILE]
  }
}

# Main routine.
#

proc main {argv} {
  # List of SQLITE_OMIT_XXX symbols supported by SQLite.
  set ::SYMBOLS [list                  \
    SQLITE_OMIT_VIEW                   \
    SQLITE_OMIT_VIRTUALTABLE           \
    SQLITE_OMIT_ALTERTABLE             \







    SQLITE_OMIT_EXPLAIN                \
    SQLITE_OMIT_FLOATING_POINT         \
    SQLITE_OMIT_FOREIGN_KEY            \
    SQLITE_OMIT_INTEGRITY_CHECK        \
    SQLITE_OMIT_MEMORYDB               \
    SQLITE_OMIT_PAGER_PRAGMAS          \
    SQLITE_OMIT_PRAGMA                 \
    SQLITE_OMIT_PROGRESS_CALLBACK      \
    SQLITE_OMIT_REINDEX                \
    SQLITE_OMIT_SCHEMA_PRAGMAS         \
    SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
    SQLITE_OMIT_DATETIME_FUNCS         \
    SQLITE_OMIT_SUBQUERY               \
    SQLITE_OMIT_TCL_VARIABLE           \
    SQLITE_OMIT_TRIGGER                \
    SQLITE_OMIT_UTF16                  \
    SQLITE_OMIT_VACUUM                 \
    SQLITE_OMIT_COMPLETE               \
    SQLITE_OMIT_AUTOVACUUM             \
    SQLITE_OMIT_AUTHORIZATION          \
    SQLITE_OMIT_AUTOINCREMENT          \
    SQLITE_OMIT_BLOB_LITERAL           \
    SQLITE_OMIT_COMPOUND_SELECT        \
    SQLITE_OMIT_CONFLICT_CLAUSE        \
  ]

  # Process any command line options.
  process_options $argv
  
  # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT 
  # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)