~ubuntu-branches/ubuntu/maverick/sqlite3/maverick-updates

« back to all changes in this revision

Viewing changes to test/alter3.test

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2007-03-06 08:53:43 UTC
  • mfrom: (3.1.5 feisty)
  • Revision ID: james.westby@ubuntu.com-20070306085343-658sxlyhl4behigh
Tags: 3.3.8-1.1
* NMU
* Revert PRAGMA table_info format change on a minor version release
  (closes: #397531)

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# file format change that may be used in the future to implement
14
14
# "ALTER TABLE ... ADD COLUMN".
15
15
#
16
 
# $Id: alter3.test,v 1.6 2005/03/29 03:11:00 danielk1977 Exp $
 
16
# $Id: alter3.test,v 1.9 2006/01/17 09:35:02 danielk1977 Exp $
17
17
#
18
18
 
19
19
set testdir [file dirname $argv0]
87
87
    SELECT sql FROM sqlite_master WHERE tbl_name = 't1';
88
88
  }
89
89
} {{CREATE TABLE t1(a, b, c, d CHECK (a>d))}}
90
 
do_test alter3-1.6 {
91
 
  execsql {
92
 
    CREATE TABLE t2(a, b, UNIQUE(a, b));
93
 
    ALTER TABLE t2 ADD c REFERENCES t1(c)  ;
94
 
    SELECT sql FROM sqlite_master WHERE tbl_name = 't2' AND type = 'table';
95
 
  }
96
 
} {{CREATE TABLE t2(a, b, c REFERENCES t1(c), UNIQUE(a, b))}}
 
90
ifcapable foreignkey {
 
91
  do_test alter3-1.6 {
 
92
    execsql {
 
93
      CREATE TABLE t2(a, b, UNIQUE(a, b));
 
94
      ALTER TABLE t2 ADD c REFERENCES t1(c)  ;
 
95
      SELECT sql FROM sqlite_master WHERE tbl_name = 't2' AND type = 'table';
 
96
    }
 
97
  } {{CREATE TABLE t2(a, b, c REFERENCES t1(c), UNIQUE(a, b))}}
 
98
}
97
99
do_test alter3-1.7 {
98
100
  execsql {
99
101
    CREATE TABLE t3(a, b, UNIQUE(a, b));
102
104
  }
103
105
} {{CREATE TABLE t3(a, b, c VARCHAR(10, 20), UNIQUE(a, b))}}
104
106
do_test alter3-1.99 {
 
107
  catchsql {
 
108
    # May not exist if foriegn-keys are omitted at compile time.
 
109
    DROP TABLE t2; 
 
110
  }
105
111
  execsql {
106
112
    DROP TABLE abc; 
107
113
    DROP TABLE t1; 
108
 
    DROP TABLE t2; 
109
114
    DROP TABLE t3; 
110
115
  }
111
116
} {}
138
143
    ALTER TABLE t1 ADD c NOT NULL DEFAULT 10;
139
144
  }
140
145
} {0 {}}
141
 
do_test alter3-2.5 {
142
 
  execsql {
143
 
    CREATE VIEW v1 AS SELECT * FROM t1;
144
 
  }
145
 
  catchsql {
146
 
    alter table v1 add column d;
147
 
  }
148
 
} {1 {Cannot add a column to a view}}
 
146
ifcapable view {
 
147
  do_test alter3-2.5 {
 
148
    execsql {
 
149
      CREATE VIEW v1 AS SELECT * FROM t1;
 
150
    }
 
151
    catchsql {
 
152
      alter table v1 add column d;
 
153
    }
 
154
  } {1 {Cannot add a column to a view}}
 
155
}
149
156
do_test alter3-2.6 {
150
157
  catchsql {
151
158
    alter table t1 add column d DEFAULT CURRENT_TIME;
181
188
    get_file_format
182
189
  } {3}
183
190
}
184
 
do_test alter3-3.4 {
185
 
  execsql {
186
 
    PRAGMA schema_version;
187
 
  }
188
 
} {11}
 
191
ifcapable schema_version {
 
192
  do_test alter3-3.4 {
 
193
    execsql {
 
194
      PRAGMA schema_version;
 
195
    }
 
196
  } {11}
 
197
}
189
198
 
190
199
do_test alter3-4.1 {
191
200
  db close
214
223
    get_file_format
215
224
  } {3}
216
225
}
217
 
do_test alter3-4.4 {
218
 
  execsql {
219
 
    PRAGMA schema_version;
220
 
  }
221
 
} {21}
 
226
ifcapable schema_version {
 
227
  do_test alter3-4.4 {
 
228
    execsql {
 
229
      PRAGMA schema_version;
 
230
    }
 
231
  } {21}
 
232
}
222
233
do_test alter3-4.99 {
223
234
  execsql {
224
235
    DROP TABLE t1;
249
260
    SELECT * FROM aux.t1;
250
261
  }
251
262
} {1 one {} 2 two {}}
252
 
do_test alter3-5.4 {
253
 
  execsql {
254
 
    PRAGMA aux.schema_version;
255
 
  }
256
 
} {31}
 
263
ifcapable schema_version {
 
264
  do_test alter3-5.4 {
 
265
    execsql {
 
266
      PRAGMA aux.schema_version;
 
267
    }
 
268
  } {31}
 
269
}
257
270
if {!$has_codec} {
258
271
  do_test alter3-5.5 {
259
272
    list [get_file_format test2.db] [get_file_format]
270
283
    SELECT * FROM aux.t1;
271
284
  }
272
285
} {1 one {} 1000 2 two {} 1000}
273
 
do_test alter3-5.8 {
274
 
  execsql {
275
 
    PRAGMA aux.schema_version;
276
 
  }
277
 
} {32}
 
286
ifcapable schema_version {
 
287
  do_test alter3-5.8 {
 
288
    execsql {
 
289
      PRAGMA aux.schema_version;
 
290
    }
 
291
  } {32}
 
292
}
278
293
do_test alter3-5.9 {
279
294
  execsql {
280
295
    SELECT * FROM t1;
360
375
    CREATE TABLE t4(c1);
361
376
  }
362
377
} {}
 
378
set ::sql ""
363
379
do_test alter3-8.2 {
364
380
  set cols c1
365
381
  for {set i 2} {$i < 100} {incr i} {