/ Check-in [53894988]
Login

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

Overview
Comment:Ensure tests pass when SQLITE_OMIT_TRIGGER is defined. (CVS 2137)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 53894988ac1ad44ec65a1e1c420e2a26eb4c2efd
User & Date: danielk1977 2004-11-22 11:51:13
Context
2004-11-22
13:35
Ensure tests pass when SQLITE_OMIT_COMPOUND_SELECT is defined. (CVS 2138) check-in: 007be591 user: danielk1977 tags: trunk
11:51
Ensure tests pass when SQLITE_OMIT_TRIGGER is defined. (CVS 2137) check-in: 53894988 user: danielk1977 tags: trunk
10:20
Fix a test-suite error made in check-in (2132) (CVS 2136) check-in: 48c7eb7f user: danielk1977 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
....
3013
3014
3015
3016
3017
3018
3019
3020



3021
3022
3023
3024
3025
3026
3027
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.285 2004/11/20 18:13:10 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Check to see if the schema for the database needs
................................................................................
          "tbl_name = %Q, "
          "name = CASE "
            "WHEN type='table' THEN %Q "
            "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "
              "'sqlite_autoindex_' || %Q || substr(name, %d+18,10) "
            "ELSE name END "
      "WHERE tbl_name=%Q AND type IN ('table', 'index', 'trigger');", 
      zDb, SCHEMA_TABLE(iDb), zName, zName, zName, zName, 



      zName, strlen(pTab->zName), pTab->zName
  );

#ifndef SQLITE_OMIT_AUTOINCREMENT
  /* If the sqlite_sequence table exists in this database, then update 
  ** it with the new table name.
  */







|







 







|
>
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
....
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.286 2004/11/22 11:51:13 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Check to see if the schema for the database needs
................................................................................
          "tbl_name = %Q, "
          "name = CASE "
            "WHEN type='table' THEN %Q "
            "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "
              "'sqlite_autoindex_' || %Q || substr(name, %d+18,10) "
            "ELSE name END "
      "WHERE tbl_name=%Q AND type IN ('table', 'index', 'trigger');", 
      zDb, SCHEMA_TABLE(iDb), zName, zName, zName, 
#ifndef SQLITE_OMIT_TRIGGER
zName,
#endif
      zName, strlen(pTab->zName), pTab->zName
  );

#ifndef SQLITE_OMIT_AUTOINCREMENT
  /* If the sqlite_sequence table exists in this database, then update 
  ** it with the new table name.
  */

Changes to test/auth.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
...
807
808
809
810
811
812
813




814
815
816
817
818
819
820
....
1163
1164
1165
1166
1167
1168
1169

1170
1171
1172
1173
1174
1175
1176
....
1884
1885
1886
1887
1888
1889
1890

1891
1892
1893
1894
1895
1896
1897
....
1910
1911
1912
1913
1914
1915
1916

1917
1918
1919

1920
1921
1922
1923
1924
1925
1926
....
1933
1934
1935
1936
1937
1938
1939
1940

1941
1942
1943
1944
1945
1946
1947
1948
....
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
#    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 related functionality.
#
# $Id: auth.test,v 1.22 2004/11/22 08:43:32 danielk1977 Exp $
#

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

# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is
# defined during compilation.
................................................................................
  }
  catchsql {DROP TABLE t1}
} {0 {}}
do_test auth-1.78 {
  execsql {SELECT name FROM sqlite_temp_master}
} {t1}

# Test cases auth-1.79 to auth-1.123 test creating and dropping views.
# Omit these if the library was compiled with views omitted.
ifcapable view {
do_test auth-1.79 {
  proc auth {code arg1 arg2 arg3 arg4} {
    if {$code=="SQLITE_CREATE_VIEW"} {
      set ::authargs [list $arg1 $arg2 $arg3 $arg4] 
      return SQLITE_DENY
................................................................................
  set ::authargs
} {v1 {} temp {}}
do_test auth-1.124 {
  execsql {SELECT name FROM sqlite_temp_master}
} {t1}
} ;# ifcapable view





do_test auth-1.125 {
  proc auth {code arg1 arg2 arg3 arg4} {
    if {$code=="SQLITE_CREATE_TRIGGER"} {
      set ::authargs [list $arg1 $arg2 $arg3 $arg4]
      return SQLITE_DENY
    }
    return SQLITE_OK
................................................................................
} {0 {}}
do_test auth-1.175 {
  set ::authargs
} {r1 t1 temp {}}
do_test auth-1.176 {
  execsql {SELECT name FROM sqlite_temp_master}
} {t1}


do_test auth-1.177 {
  proc auth {code arg1 arg2 arg3 arg4} {
    if {$code=="SQLITE_CREATE_INDEX"} {
      set ::authargs [list $arg1 $arg2 $arg3 $arg4]
      return SQLITE_DENY
    }
................................................................................
    return SQLITE_OK
  }
  catchsql {SELECT * FROM t2, t3}
} {0 {11 2 33 {} 55 66 7 8 9 {} 55 66}}

# Make sure the OLD and NEW pseudo-tables of a trigger get authorized.
#

do_test auth-3.1 {
  proc auth {code arg1 arg2 arg3 arg4} {
    return SQLITE_OK
  }
  execsql {
    CREATE TABLE tx(a1,a2,b1,b2,c1,c2);
    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN
................................................................................
  }
  execsql {
    DELETE FROM tx;
    UPDATE t2 SET a=a+100;
    SELECT * FROM tx;
  }
} {12 112 2 2 {} {} 8 108 8 8 {} {}}


# Make sure the names of views and triggers are passed on on arg4.
#

do_test auth-4.1 {
  proc auth {code arg1 arg2 arg3 arg4} {
    lappend ::authargs $code $arg1 $arg2 $arg3 $arg4
    return SQLITE_OK
  }
  set authargs {}
  execsql {
................................................................................
  SQLITE_INSERT tx {} main r1 \
  SQLITE_READ   t2 a  main r1 \
  SQLITE_READ   t2 a  main r1 \
  SQLITE_READ   t2 b  main r1 \
  SQLITE_READ   t2 b  main r1 \
  SQLITE_READ   t2 c  main r1 \
  SQLITE_READ   t2 c  main r1]


ifcapable view {
do_test auth-4.2 {
  execsql {
    CREATE VIEW v1 AS SELECT a+b AS x FROM t2;
    CREATE TABLE v1chng(x1,x2);
    CREATE TRIGGER r2 INSTEAD OF UPDATE ON v1 BEGIN
      INSERT INTO v1chng VALUES(OLD.x,NEW.x);
    END;
................................................................................
  SQLITE_READ   v1     x  main {} \
  SQLITE_SELECT {}     {} {}   v1 \
  SQLITE_READ   t2     a  main v1 \
  SQLITE_READ   t2     b  main v1 \
  SQLITE_INSERT v1chng {} main r3 \
  SQLITE_READ   v1     x  main r3]

} ;# ifcapable view

finish_test







|







 







|







 







>
>
>
>







 







>







 







>







 







>



>







 







|
>
|







 







|


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
...
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
....
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
....
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
....
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
....
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
....
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
#    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 related functionality.
#
# $Id: auth.test,v 1.23 2004/11/22 11:51:14 danielk1977 Exp $
#

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

# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is
# defined during compilation.
................................................................................
  }
  catchsql {DROP TABLE t1}
} {0 {}}
do_test auth-1.78 {
  execsql {SELECT name FROM sqlite_temp_master}
} {t1}

# Test cases auth-1.79 to auth-1.124 test creating and dropping views.
# Omit these if the library was compiled with views omitted.
ifcapable view {
do_test auth-1.79 {
  proc auth {code arg1 arg2 arg3 arg4} {
    if {$code=="SQLITE_CREATE_VIEW"} {
      set ::authargs [list $arg1 $arg2 $arg3 $arg4] 
      return SQLITE_DENY
................................................................................
  set ::authargs
} {v1 {} temp {}}
do_test auth-1.124 {
  execsql {SELECT name FROM sqlite_temp_master}
} {t1}
} ;# ifcapable view

# Test cases auth-1.125 to auth-1.176 test creating and dropping triggers.
# Omit these if the library was compiled with triggers omitted.
#
ifcapable trigger {
do_test auth-1.125 {
  proc auth {code arg1 arg2 arg3 arg4} {
    if {$code=="SQLITE_CREATE_TRIGGER"} {
      set ::authargs [list $arg1 $arg2 $arg3 $arg4]
      return SQLITE_DENY
    }
    return SQLITE_OK
................................................................................
} {0 {}}
do_test auth-1.175 {
  set ::authargs
} {r1 t1 temp {}}
do_test auth-1.176 {
  execsql {SELECT name FROM sqlite_temp_master}
} {t1}
} ;# ifcapable trigger

do_test auth-1.177 {
  proc auth {code arg1 arg2 arg3 arg4} {
    if {$code=="SQLITE_CREATE_INDEX"} {
      set ::authargs [list $arg1 $arg2 $arg3 $arg4]
      return SQLITE_DENY
    }
................................................................................
    return SQLITE_OK
  }
  catchsql {SELECT * FROM t2, t3}
} {0 {11 2 33 {} 55 66 7 8 9 {} 55 66}}

# Make sure the OLD and NEW pseudo-tables of a trigger get authorized.
#
ifcapable trigger {
do_test auth-3.1 {
  proc auth {code arg1 arg2 arg3 arg4} {
    return SQLITE_OK
  }
  execsql {
    CREATE TABLE tx(a1,a2,b1,b2,c1,c2);
    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN
................................................................................
  }
  execsql {
    DELETE FROM tx;
    UPDATE t2 SET a=a+100;
    SELECT * FROM tx;
  }
} {12 112 2 2 {} {} 8 108 8 8 {} {}}
} ;# ifcapable trigger

# Make sure the names of views and triggers are passed on on arg4.
#
ifcapable trigger {
do_test auth-4.1 {
  proc auth {code arg1 arg2 arg3 arg4} {
    lappend ::authargs $code $arg1 $arg2 $arg3 $arg4
    return SQLITE_OK
  }
  set authargs {}
  execsql {
................................................................................
  SQLITE_INSERT tx {} main r1 \
  SQLITE_READ   t2 a  main r1 \
  SQLITE_READ   t2 a  main r1 \
  SQLITE_READ   t2 b  main r1 \
  SQLITE_READ   t2 b  main r1 \
  SQLITE_READ   t2 c  main r1 \
  SQLITE_READ   t2 c  main r1]
}

ifcapable {view && trigger} {
do_test auth-4.2 {
  execsql {
    CREATE VIEW v1 AS SELECT a+b AS x FROM t2;
    CREATE TABLE v1chng(x1,x2);
    CREATE TRIGGER r2 INSTEAD OF UPDATE ON v1 BEGIN
      INSERT INTO v1chng VALUES(OLD.x,NEW.x);
    END;
................................................................................
  SQLITE_READ   v1     x  main {} \
  SQLITE_SELECT {}     {} {}   v1 \
  SQLITE_READ   t2     a  main v1 \
  SQLITE_READ   t2     b  main v1 \
  SQLITE_INSERT v1chng {} main r3 \
  SQLITE_READ   v1     x  main r3]

} ;# ifcapable view && trigger

finish_test

Changes to test/vacuum.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

101
102
103



104
105
106
107
108
109
110
#    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 VACUUM statement.
#
# $Id: vacuum.test,v 1.31 2004/11/22 08:43:32 danielk1977 Exp $

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

# If the VACUUM statement is disabled in the current build, skip all
# the tests in this file.
#
................................................................................
}
do_test vacuum-1.4 {
  set sql_script {
    BEGIN;
    CREATE TABLE t2 AS SELECT * FROM t1;
    CREATE TABLE t3 AS SELECT * FROM t1;
    CREATE VIEW v1 AS SELECT b, c FROM t3;
    CREATE TRIGGER r1 AFTER DELETE ON t2 BEGIN
      SELECT 1;
    END;
    COMMIT;
    DROP TABLE t2;
  }
  # If the library was compiled to omit view support, comment out the
  # create view in the script $sql_script before executing it.

  ifcapable !view {
    regsub {CREATE VIEW} $sql_script {-- CREATE VIEW} sql_script
  }



  execsql $sql_script
  set ::size1 [file size test.db]
  set ::cksum [cksum]
  expr {$::cksum!=""}
} {1}
do_test vacuum-1.5 {
  execsql {







|







 







|
<
<




|
>



>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
86
87
88
89
90
91
92
93


94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#    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 VACUUM statement.
#
# $Id: vacuum.test,v 1.32 2004/11/22 11:51:14 danielk1977 Exp $

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

# If the VACUUM statement is disabled in the current build, skip all
# the tests in this file.
#
................................................................................
}
do_test vacuum-1.4 {
  set sql_script {
    BEGIN;
    CREATE TABLE t2 AS SELECT * FROM t1;
    CREATE TABLE t3 AS SELECT * FROM t1;
    CREATE VIEW v1 AS SELECT b, c FROM t3;
    CREATE TRIGGER r1 AFTER DELETE ON t2 BEGIN SELECT 1; END;


    COMMIT;
    DROP TABLE t2;
  }
  # If the library was compiled to omit view support, comment out the
  # create view in the script $sql_script before executing it. Similarly,
  # if triggers are not supported, comment out the trigger definition.
  ifcapable !view {
    regsub {CREATE VIEW} $sql_script {-- CREATE VIEW} sql_script
  }
  ifcapable !trigger {
    regsub {CREATE TRIGGER} $sql_script {-- CREATE TRIGGER} sql_script
  }
  execsql $sql_script
  set ::size1 [file size test.db]
  set ::cksum [cksum]
  expr {$::cksum!=""}
} {1}
do_test vacuum-1.5 {
  execsql {