SQLite

Check-in [9e856bab2b]
Login

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

Overview
Comment:Changes to alter3.test to allow it to work with a codec. (CVS 2423)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9e856bab2bbb77004b049827b4a275aa6c48096b
User & Date: drh 2005-03-28 16:50:22.000
Context
2005-03-28
16:56
Increment version number and update documentation in preparation for version 3.2.1. (CVS 2424) (check-in: b0409b9310 user: drh tags: trunk)
16:50
Changes to alter3.test to allow it to work with a codec. (CVS 2423) (check-in: 9e856bab2b user: drh tags: trunk)
08:44
Modifications to reduce memory consumption. (CVS 2422) (check-in: 0fd5ce4eef user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/alter3.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27









28
29
30
31
32
33
34
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing that SQLite can handle a subtle 
# file format change that may be used in the future to implement
# "ALTER TABLE ... ADD COLUMN".
#
# $Id: alter3.test,v 1.4 2005/03/27 01:56:31 danielk1977 Exp $
#

set testdir [file dirname $argv0]

source $testdir/tester.tcl

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {
  finish_test
  return
}










# Test Organisation:
# ------------------
#
# alter3-1.*: Test that ALTER TABLE correctly modifies the CREATE TABLE sql.
# alter3-2.*: Test error messages.
# alter3-3.*: Test adding columns with default value NULL.







|











>
>
>
>
>
>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing that SQLite can handle a subtle 
# file format change that may be used in the future to implement
# "ALTER TABLE ... ADD COLUMN".
#
# $Id: alter3.test,v 1.5 2005/03/28 16:50:22 drh Exp $
#

set testdir [file dirname $argv0]

source $testdir/tester.tcl

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {
  finish_test
  return
}

# Determine if there is a codec available on this test.
#
if {[catch {sqlite3 -has_codec} r] || $r} {
  set has_codec 1
} else {
  set has_codec 0
}


# Test Organisation:
# ------------------
#
# alter3-1.*: Test that ALTER TABLE correctly modifies the CREATE TABLE sql.
# alter3-2.*: Test error messages.
# alter3-3.*: Test adding columns with default value NULL.
163
164
165
166
167
168
169

170
171
172

173
174
175
176
177
178
179
} {}
do_test alter3-3.2 {
  execsql {
    ALTER TABLE t1 ADD c;
    SELECT * FROM t1;
  }
} {1 100 {} 2 300 {}}

do_test alter3-3.3 {
  get_file_format
} {3}

do_test alter3-3.4 {
  execsql {
    PRAGMA schema_version;
  }
} {11}

do_test alter3-4.1 {







>
|
|
|
>







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
} {}
do_test alter3-3.2 {
  execsql {
    ALTER TABLE t1 ADD c;
    SELECT * FROM t1;
  }
} {1 100 {} 2 300 {}}
if {!$has_codec} {
  do_test alter3-3.3 {
    get_file_format
  } {3}
}
do_test alter3-3.4 {
  execsql {
    PRAGMA schema_version;
  }
} {11}

do_test alter3-4.1 {
194
195
196
197
198
199
200

201
202
203

204
205
206
207
208
209
210
} {}
do_test alter3-4.2 {
  execsql {
    ALTER TABLE t1 ADD c DEFAULT 'hello world';
    SELECT * FROM t1;
  }
} {1 100 {hello world} 2 300 {hello world}}

do_test alter3-4.3 {
  get_file_format
} {3}

do_test alter3-4.4 {
  execsql {
    PRAGMA schema_version;
  }
} {21}
do_test alter3-4.99 {
  execsql {







>
|
|
|
>







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
} {}
do_test alter3-4.2 {
  execsql {
    ALTER TABLE t1 ADD c DEFAULT 'hello world';
    SELECT * FROM t1;
  }
} {1 100 {hello world} 2 300 {hello world}}
if {!$has_codec} {
  do_test alter3-4.3 {
    get_file_format
  } {3}
}
do_test alter3-4.4 {
  execsql {
    PRAGMA schema_version;
  }
} {21}
do_test alter3-4.99 {
  execsql {
237
238
239
240
241
242
243

244
245
246

247
248
249
250
251
252
253
  }
} {1 one {} 2 two {}}
do_test alter3-5.4 {
  execsql {
    PRAGMA aux.schema_version;
  }
} {31}

do_test alter3-5.5 {
  list [get_file_format test2.db] [get_file_format]
} {2 3}

do_test alter3-5.6 {
  execsql {
    ALTER TABLE aux.t1 ADD COLUMN d DEFAULT 1000;
    SELECT sql FROM aux.sqlite_master;
  }
} {{CREATE TABLE t1(a,b, c VARCHAR(128), d DEFAULT 1000)}}
do_test alter3-5.7 {







>
|
|
|
>







250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
  }
} {1 one {} 2 two {}}
do_test alter3-5.4 {
  execsql {
    PRAGMA aux.schema_version;
  }
} {31}
if {!$has_codec} {
  do_test alter3-5.5 {
    list [get_file_format test2.db] [get_file_format]
  } {2 3}
}
do_test alter3-5.6 {
  execsql {
    ALTER TABLE aux.t1 ADD COLUMN d DEFAULT 1000;
    SELECT sql FROM aux.sqlite_master;
  }
} {{CREATE TABLE t1(a,b, c VARCHAR(128), d DEFAULT 1000)}}
do_test alter3-5.7 {
298
299
300
301
302
303
304

305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336

337
338
339
340
341
342
343
      ALTER TABLE t1 ADD COLUMN c DEFAULT 'c';
      INSERT INTO t1(a, b) VALUES(3, 4);
      SELECT * FROM log;
    }
  } {b 1 2 a 1 2 b 3 4 a 3 4}
}


ifcapable vacuum {
  do_test alter3-7.1 {
    execsql {
      VACUUM;
    }
    get_file_format
  } {1}
  do_test alter3-7.2 {
    execsql {
      CREATE TABLE abc(a, b, c);
      ALTER TABLE abc ADD d DEFAULT NULL;
    }
    get_file_format
  } {2}
  do_test alter3-7.3 {
    execsql {
      ALTER TABLE abc ADD e DEFAULT 10;
    }
    get_file_format
  } {3}
  do_test alter3-7.4 {
    execsql {
      ALTER TABLE abc ADD f DEFAULT NULL;
    }
    get_file_format
  } {3}
  do_test alter3-7.5 {
    execsql {
      VACUUM;
    }
    get_file_format
  } {1}

}

# Ticket #1183 - Make sure adding columns to large tables does not cause
# memory corruption (as was the case before this bug was fixed).
do_test alter3-8.1 {
  execsql {
    CREATE TABLE t4(c1);







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







313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
      ALTER TABLE t1 ADD COLUMN c DEFAULT 'c';
      INSERT INTO t1(a, b) VALUES(3, 4);
      SELECT * FROM log;
    }
  } {b 1 2 a 1 2 b 3 4 a 3 4}
}

if {!$has_codec} {
  ifcapable vacuum {
    do_test alter3-7.1 {
      execsql {
        VACUUM;
      }
      get_file_format
    } {1}
    do_test alter3-7.2 {
      execsql {
        CREATE TABLE abc(a, b, c);
        ALTER TABLE abc ADD d DEFAULT NULL;
      }
      get_file_format
    } {2}
    do_test alter3-7.3 {
      execsql {
        ALTER TABLE abc ADD e DEFAULT 10;
      }
      get_file_format
    } {3}
    do_test alter3-7.4 {
      execsql {
        ALTER TABLE abc ADD f DEFAULT NULL;
      }
      get_file_format
    } {3}
    do_test alter3-7.5 {
      execsql {
        VACUUM;
      }
      get_file_format
    } {1}
  }
}

# Ticket #1183 - Make sure adding columns to large tables does not cause
# memory corruption (as was the case before this bug was fixed).
do_test alter3-8.1 {
  execsql {
    CREATE TABLE t4(c1);
357
358
359
360
361
362
363
364
do_test alter3-8.2 {
  execsql {
    SELECT sql FROM sqlite_master WHERE name = 't4';
  }
} [list $::sql]

finish_test








<
374
375
376
377
378
379
380

do_test alter3-8.2 {
  execsql {
    SELECT sql FROM sqlite_master WHERE name = 't4';
  }
} [list $::sql]

finish_test