/ Check-in [093467a0]
Login

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

Overview
Comment:Reactivate disabled "alter2" tests. (CVS 3553)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:093467a099bb205897a58c1eeb734e1d13fba405
User & Date: drh 2007-01-04 14:36:02
Context
2007-01-04
14:58
Fix a memory leak introduced by the latest changes to pager.c. (CVS 3554) check-in: 8cad5d67 user: drh tags: trunk
14:36
Reactivate disabled "alter2" tests. (CVS 3553) check-in: 093467a0 user: drh tags: trunk
01:20
Fix for ticket #2141. (CVS 3552) check-in: 70f5f3b8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to test/alter2.test.

     9      9   #
    10     10   #*************************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is testing that SQLite can handle a subtle 
    13     13   # file format change that may be used in the future to implement
    14     14   # "ALTER TABLE ... ADD COLUMN".
    15     15   #
    16         -# $Id: alter2.test,v 1.5 2006/01/03 00:33:50 drh Exp $
           16  +# $Id: alter2.test,v 1.6 2007/01/04 14:36:02 drh Exp $
    17     17   #
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     21   
    22     22   # We have to have pragmas in order to do this test
    23     23   ifcapable {!pragma} return
    24     24   
    25     25   # These tests do not work if there is a codec.  The
    26     26   # btree_open command does not know how to handle codecs.
    27     27   #
    28         -if {[catch {sqlite3 -has_codec} r] || $r} return
           28  +#if {[catch {sqlite3 -has_codec} r] || $r} return
    29     29   
    30     30   # The file format change affects the way row-records stored in tables (but 
    31     31   # not indices) are interpreted. Before version 3.1.3, a row-record for a 
    32     32   # table with N columns was guaranteed to contain exactly N fields. As
    33     33   # of version 3.1.3, the record may contain up to N fields. In this case
    34     34   # the M fields that are present are the values for the left-most M 
    35     35   # columns. The (N-M) rightmost columns contain NULL.
................................................................................
    64     64   # This procedure sets the SQL statement stored for table $tbl in the
    65     65   # sqlite_master table of file 'test.db' to $sql. Also set the file format
    66     66   # to the supplied value. This is 2 if the added column has a default that is
    67     67   # NULL, or 3 otherwise. 
    68     68   #
    69     69   proc alter_table {tbl sql {file_format 2}} {
    70     70     sqlite3 dbat test.db
    71         -puts one
    72     71     dbat eval {
    73     72       PRAGMA writable_schema = 1;
    74     73       UPDATE sqlite_master SET sql = $sql WHERE name = $tbl AND type = 'table';
    75     74       PRAGMA writable_schema = 0;
    76     75     }
    77         -puts two
    78     76     dbat close
    79         -puts three
    80     77     set_file_format 2
    81         -puts four
    82     78   }
    83     79   
    84     80   #-----------------------------------------------------------------------
    85     81   # Some basic tests to make sure short rows are handled.
    86     82   #
    87     83   do_test alter2-1.1 {
    88     84     execsql {
................................................................................
    92     88       INSERT INTO abc VALUES(5, 6);
    93     89     }
    94     90   } {}
    95     91   do_test alter2-1.2 {
    96     92     # ALTER TABLE abc ADD COLUMN c;
    97     93     alter_table abc {CREATE TABLE abc(a, b, c);}
    98     94   } {}
    99         -exit
   100     95   do_test alter2-1.3 {
   101     96     execsql {
   102     97       SELECT * FROM abc;
   103     98     }
   104     99   } {1 2 {} 3 4 {} 5 6 {}}
   105    100   do_test alter2-1.4 {
   106    101     execsql {
................................................................................
   123    118       SELECT * FROM abc WHERE c = 10;
   124    119     }
   125    120   } {1 2 10}
   126    121   do_test alter2-1.8 {
   127    122     execsql {
   128    123       SELECT sum(a), c FROM abc GROUP BY c;
   129    124     }
   130         -} {8.0 {} 1.0 10}
          125  +} {8 {} 1 10}
   131    126   do_test alter2-1.9 {
   132    127     # ALTER TABLE abc ADD COLUMN d;
   133    128     alter_table abc {CREATE TABLE abc(a, b, c, d);}
   134    129     execsql { SELECT * FROM abc; }
   135    130     execsql {
   136    131       UPDATE abc SET d = 11 WHERE c IS NULL AND a<4;
   137    132       SELECT * FROM abc;
................................................................................
   230    225         SELECT * FROM clog;
   231    226       }
   232    227     } {{} 2 {} 6 {} 10}
   233    228   }
   234    229   
   235    230   #---------------------------------------------------------------------
   236    231   # Check that an error occurs if the database is upgraded to a file
   237         -# format that SQLite does not support (in this case 4). Note: The 
          232  +# format that SQLite does not support (in this case 5). Note: The 
   238    233   # file format is checked each time the schema is read, so changing the
   239    234   # file format requires incrementing the schema cookie.
   240    235   #
   241    236   do_test alter2-4.1 {
   242         -  set_file_format 4
          237  +  set_file_format 5
   243    238   } {}
   244    239   do_test alter2-4.2 {
   245    240     catchsql {
   246    241       SELECT * FROM sqlite_master;
   247    242     }
   248    243   } {1 {unsupported file format}}
   249    244   do_test alter2-4.3 {
................................................................................
   337    332   } {1 integer 123 text 123 integer}
   338    333   do_test alter2-7.5 {
   339    334     set sql {CREATE TABLE t1(a, b DEFAULT -123.0, c VARCHAR(10) default 5)}
   340    335     alter_table t1 $sql 3
   341    336     execsql {
   342    337       SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;
   343    338     }
   344         -} {1 integer -123.0 real 5 text}
          339  +} {1 integer -123 integer 5 text}
   345    340   
   346    341   #-----------------------------------------------------------------------
   347    342   # Test that UPDATE trigger tables work with default values, and that when
   348    343   # a row is updated the default values are correctly transfered to the 
   349    344   # new row.
   350    345   # 
   351    346   ifcapable trigger {
................................................................................
   363    358     } {}
   364    359   }
   365    360   do_test alter2-8.2 {
   366    361     execsql {
   367    362       UPDATE t1 SET c = 10 WHERE a = 1;
   368    363       SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;
   369    364     }
   370         -} {1 integer -123.0 real 10 text}
          365  +} {1 integer -123 integer 10 text}
   371    366   ifcapable trigger {
   372    367     do_test alter2-8.3 {
   373    368       set ::val
   374         -  } {-123 real 5 text -123 real 10 text}
          369  +  } {-123 integer 5 text -123 integer 10 text}
   375    370   }
   376    371   
   377    372   #-----------------------------------------------------------------------
   378    373   # Test that DELETE trigger tables work with default values, and that when
   379    374   # a row is updated the default values are correctly transfered to the 
   380    375   # new row.
   381    376   # 
................................................................................
   391    386       list
   392    387     } {}
   393    388     do_test alter2-9.2 {
   394    389       execsql {
   395    390         DELETE FROM t1 WHERE a = 2;
   396    391       }
   397    392       set ::val
   398         -  } {-123 real 5 text}
          393  +  } {-123 integer 5 text}
   399    394   }
   400    395   
   401    396   #-----------------------------------------------------------------------
   402    397   # Test creating an index on a column added with a default value. 
   403    398   #
   404    399   do_test alter2-10.1 {
   405    400     execsql {