blob: 20e142057da9f334d996fe24914b99ad6a4086bc (
plain)
1
2
3
4
5
6
7
8
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
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
|
# 2010 September 30
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# 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. Specifically,
# it tests that ticket [8454a207b9fd2243c4c6b7a73f67ea0315717c1a]. Verify
# that a negative default value on an added text column actually comes
# out negative.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {
finish_test
return
}
do_test tkt-8454a207b9.1 {
db eval {
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(1);
ALTER TABLE t1 ADD COLUMN b TEXT DEFAULT -123.0;
SELECT b, typeof(b) FROM t1;
}
} {-123.0 text}
do_test tkt-8454a207b9.2 {
db eval {
ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT -123.5;
SELECT c, typeof(c) FROM t1;
}
} {-123.5 text}
do_test tkt-8454a207b9.3 {
db eval {
ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT -'hello';
SELECT d, typeof(d) FROM t1;
}
} {0 text}
do_test tkt-8454a207b9.4 {
db eval {
ALTER TABLE t1 ADD COLUMN e DEFAULT -123.0;
SELECT e, typeof(e) FROM t1;
}
} {-123 integer}
do_test tkt-8454a207b9.5 {
db eval {
ALTER TABLE t1 ADD COLUMN f DEFAULT -123.5;
SELECT f, typeof(f) FROM t1;
}
} {-123.5 real}
do_test tkt-8454a207b9.6 {
db eval {
ALTER TABLE t1 ADD COLUMN g DEFAULT -9223372036854775808;
SELECT g, typeof(g) FROM t1;
}
} {-9223372036854775808 integer}
do_test tkt-8454a207b9.7 {
db eval {
ALTER TABLE t1 ADD COLUMN h DEFAULT 9223372036854775807;
SELECT h, typeof(h) FROM t1;
}
} {9223372036854775807 integer}
finish_test
|