1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Omit the SQLITE_AFF_INTEGER type affinity. All numeric values are now

of type real, though an integer representation is still sometimes used
internally for efficiency. (CVS 2753)

FossilOrigin-Name: e0d6f61c7de2c03b8fd17ef37cf1a0add36ee618
This commit is contained in:
drh
2005-11-01 15:48:24 +00:00
parent b127612933
commit 8df447f0e6
24 changed files with 162 additions and 154 deletions

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the CAST operator.
#
# $Id: cast.test,v 1.2 2005/06/25 19:31:48 drh Exp $
# $Id: cast.test,v 1.3 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -38,10 +38,10 @@ do_test cast-1.4 {
} text
do_test cast-1.5 {
execsql {SELECT CAST(x'616263' AS numeric)}
} 0.0
} 0
do_test cast-1.6 {
execsql {SELECT typeof(CAST(x'616263' AS numeric))}
} real
} integer
do_test cast-1.7 {
execsql {SELECT CAST(x'616263' AS blob)}
} abc
@@ -158,10 +158,10 @@ do_test cast-1.44 {
} text
do_test cast-1.45 {
execsql {SELECT CAST('123abc' AS numeric)}
} 123.0
} 123
do_test cast-1.46 {
execsql {SELECT typeof(CAST('123abc' AS numeric))}
} real
} integer
do_test cast-1.47 {
execsql {SELECT CAST('123abc' AS blob)}
} {123abc}

View File

@@ -12,7 +12,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem.
#
# $Id: collate1.test,v 1.3 2004/08/20 18:34:20 drh Exp $
# $Id: collate1.test,v 1.4 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -214,7 +214,7 @@ do_test collate1-4.3 {
execsql {
SELECT c2+0 FROM collate1t1 ORDER BY 1;
}
} {{} 1.0 12.0 101.0}
} {{} 1 12 101}
do_test collate1-4.4 {
execsql {
SELECT c1||'' FROM collate1t1 ORDER BY 1;

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing expressions.
#
# $Id: expr.test,v 1.46 2005/10/29 15:48:32 drh Exp $
# $Id: expr.test,v 1.47 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -29,8 +29,7 @@ proc test_expr {name settings expr result} {
test_expr expr-1.1 {i1=10, i2=20} {i1+i2} 30
test_expr expr-1.2 {i1=10, i2=20} {i1-i2} -10
test_expr expr-1.3 {i1=10, i2=20} {i1*i2} 200
# update for sqlite3 v3: Change 0.5 to 0 in expr1.4 due to manifest types.
test_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0
test_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0.5
test_expr expr-1.5 {i1=10, i2=20} {i2/i1} 2
test_expr expr-1.6 {i1=10, i2=20} {i2<i1} 0
test_expr expr-1.7 {i1=10, i2=20} {i2<=i1} 0
@@ -48,8 +47,8 @@ test_expr expr-1.18 {i1=20, i2=20} {i2!=i1} 0
test_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1
test_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0
test_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1
test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7.0}
test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9.0}
test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7}
test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9}
test_expr expr-1.24 {i1=1, i2=2} {min(i1,i2,i1+i2,i1-i2)} {-1}
test_expr expr-1.25 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
test_expr expr-1.26 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
@@ -161,8 +160,8 @@ test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0
test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1
test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11}
test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}
test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3.0
test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0
test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3
test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99
test_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1
test_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing built-in functions.
#
# $Id: func.test,v 1.40 2005/09/08 20:37:44 drh Exp $
# $Id: func.test,v 1.41 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -511,7 +511,7 @@ do_test func-18.2 {
INSERT INTO t5 VALUES(0.0);
SELECT sum(x) FROM t5;
}
} {9902.0}
} {9902}
# The sum of nothing is NULL. But the sum of all NULLs is NULL.
#

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the CREATE INDEX statement.
#
# $Id: index.test,v 1.37 2005/01/21 03:12:16 danielk1977 Exp $
# $Id: index.test,v 1.38 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -372,38 +372,38 @@ do_test index-12.1 {
INSERT INTO t4 VALUES('00000',7);
SELECT a FROM t4 ORDER BY b;
}
} {0.0 0.0 abc -1.0 1.0 0 0}
} {0 0 abc -1 1 0 0}
do_test index-12.2 {
execsql {
SELECT a FROM t4 WHERE a==0 ORDER BY b
}
} {0.0 0.0 0 0}
} {0 0 0 0}
do_test index-12.3 {
execsql {
SELECT a FROM t4 WHERE a<0.5 ORDER BY b
}
} {0.0 0.0 -1.0 0 0}
} {0 0 -1 0 0}
do_test index-12.4 {
execsql {
SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
}
} {0.0 0.0 abc 1.0 0 0}
} {0 0 abc 1 0 0}
do_test index-12.5 {
execsql {
CREATE INDEX t4i1 ON t4(a);
SELECT a FROM t4 WHERE a==0 ORDER BY b
}
} {0.0 0.0 0 0}
} {0 0 0 0}
do_test index-12.6 {
execsql {
SELECT a FROM t4 WHERE a<0.5 ORDER BY b
}
} {0.0 0.0 -1.0 0 0}
} {0 0 -1 0 0}
do_test index-12.7 {
execsql {
SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
}
} {0.0 0.0 abc 1.0 0 0}
} {0 0 abc 1 0 0}
integrity_check index-12.8
# Make sure we cannot drop an automatically created index.

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is exercising the code in main.c.
#
# $Id: main.test,v 1.22 2005/10/23 11:29:40 drh Exp $
# $Id: main.test,v 1.23 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -302,7 +302,7 @@ do_test main-3.3 {
insert into T1 values(5.0E+03);
select x*10 from T1 order by x*5;
}
} {-0.51 -0.5 0.05 0.5 5.0 500.0 500.0 500.0 5000.0 50000.0}
} {-0.51 -0.5 0.05 0.5 5 500 500 500 5000 50000}
do_test main-3.4 {
set v [catch {execsql {create bogus}} msg]
lappend v $msg

View File

@@ -13,7 +13,7 @@
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc1.test,v 1.38 2005/09/08 10:37:01 drh Exp $
# $Id: misc1.test,v 1.39 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -316,13 +316,13 @@ do_test misc1-10.7 {
} {0 {}}
do_test misc1-10.8 {
execsql {SELECT x1 FROM manycol WHERE x0=100}
} {102.0}
} {102}
do_test misc1-10.9 {
catchsql "UPDATE manycol SET x1=x1+1 $::where AND rowid>0"
} {0 {}}
do_test misc1-10.10 {
execsql {SELECT x1 FROM manycol WHERE x0=100}
} {103.0}
} {103}
# Make sure the initialization works even if a database is opened while
# another process has the database locked.
@@ -408,7 +408,7 @@ do_test misc1-12.9 {
# catchsql {
# SELECT * FROM t6 ORDER BY a COLLATE unknown;
# }
#} {0 {0 0.0 y 0}}
#} {0 {0 0 y 0}}
do_test misc1-12.11 {
execsql {
CREATE TABLE t8(x TEXT COLLATE numeric, y INTEGER COLLATE text, z);
@@ -572,7 +572,7 @@ do_test misc1-17.1 {
COMMIT;
SELECT TestString FROM RealTable ORDER BY 1;
}
} {2.0 3.0}
} {2 3}
}
finish_test

View File

@@ -13,7 +13,7 @@
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc5.test,v 1.5 2005/08/23 11:31:26 drh Exp $
# $Id: misc5.test,v 1.6 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -494,13 +494,13 @@ do_test misc5-5.1 {
} 0.1
do_test misc5-5.2 {
execsql {SELECT 2. }
} 2.0
} 2
do_test misc5-5.3 {
execsql {SELECT 3.e0 }
} 3.0
} 3
do_test misc5-5.4 {
execsql {SELECT .4e+1}
} 4.0
} 4
finish_test

View File

@@ -12,7 +12,7 @@
# focus of this file is the ability to specify table and column names
# as quoted strings.
#
# $Id: quote.test,v 1.5 2005/08/13 18:15:43 drh Exp $
# $Id: quote.test,v 1.6 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -46,7 +46,7 @@ do_test quote-1.3.1 {
catchsql {
SELECT '!pqr', '#xyz'+5 FROM '@abc'
}
} {0 {!pqr 5.0}}
} {0 {!pqr 5}}
do_test quote-1.3.2 {
catchsql {
SELECT "!pqr", "#xyz"+5 FROM '@abc'

View File

@@ -12,7 +12,7 @@
# focus of this file is testing aggregate functions and the
# GROUP BY and HAVING clauses of SELECT statements.
#
# $Id: select3.test,v 1.16 2005/09/08 20:37:44 drh Exp $
# $Id: select3.test,v 1.17 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -57,18 +57,18 @@ do_test select3-2.1 {
do_test select3-2.2 {
execsql {SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log}
} {0 1 1 2 2 3 3 5 4 9 5 17}
do_test select3-2.3 {
do_test select3-2.3.1 {
execsql {SELECT log, avg(n) FROM t1 GROUP BY log ORDER BY log}
} {0 1.0 1 2.0 2 3.5 3 6.5 4 12.5 5 24.0}
do_test select3-2.3 {
do_test select3-2.3.2 {
execsql {SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log}
} {0 2.0 1 3.0 2 4.5 3 7.5 4 13.5 5 25.0}
} {0 2 1 3 2 4.5 3 7.5 4 13.5 5 25}
do_test select3-2.4 {
execsql {SELECT log, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}
} {0 0.0 1 0.0 2 0.5 3 1.5 4 3.5 5 7.0}
} {0 0 1 0 2 0.5 3 1.5 4 3.5 5 7}
do_test select3-2.5 {
execsql {SELECT log*2+1, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}
} {1 0.0 3 0.0 5 0.5 7 1.5 9 3.5 11 7.0}
} {1 0 3 0 5 0.5 7 1.5 9 3.5 11 7}
do_test select3-2.6 {
execsql {
SELECT log*2+1 as x, count(*) FROM t1 GROUP BY x ORDER BY x

View File

@@ -12,7 +12,7 @@
# focus of this file is testing SELECT statements that contain
# subqueries in their FROM clause.
#
# $Id: select6.test,v 1.19 2005/09/07 22:48:16 drh Exp $
# $Id: select6.test,v 1.20 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -186,7 +186,7 @@ do_test select6-3.5 {
execsql {
SELECT x,y,x+y FROM (SELECT avg(a) as 'x', avg(b) as 'y' FROM t2 WHERE a=4)
}
} {4.0 3.0 7.0}
} {4.0 3.0 7}
do_test select6-3.6 {
execsql {
SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)
@@ -217,14 +217,14 @@ do_test select6-3.10 {
SELECT a,b,a+b FROM (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)
ORDER BY a
}
} {1.0 1 2.0 2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23.0}
} {1.0 1 2 2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23}
do_test select6-3.11 {
execsql {
SELECT a,b,a+b FROM
(SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)
WHERE b<4 ORDER BY a
}
} {1.0 1 2.0 2.5 2 4.5 5.5 3 8.5}
} {1.0 1 2 2.5 2 4.5 5.5 3 8.5}
do_test select6-3.12 {
execsql {
SELECT a,b,a+b FROM
@@ -238,7 +238,7 @@ do_test select6-3.13 {
(SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b HAVING a>1)
ORDER BY a
}
} {2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23.0}
} {2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23}
do_test select6-3.14 {
execsql {
SELECT [count(*)],y FROM (SELECT count(*), y FROM t1 GROUP BY y)

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the CREATE TABLE statement.
#
# $Id: sort.test,v 1.23 2005/09/01 17:47:52 drh Exp $
# $Id: sort.test,v 1.24 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -62,10 +62,10 @@ do_test sort-1.4 {
} {2 3 6 7 1 4 5 8}
do_test sort-1.5 {
execsql {SELECT flt FROM t1 ORDER BY flt}
} {-11 -1.6 -0.0013442 0.123 2.15 3.141592653 123.0 4221.0}
} {-11 -1.6 -0.0013442 0.123 2.15 3.141592653 123 4221}
do_test sort-1.6 {
execsql {SELECT flt FROM t1 ORDER BY flt DESC}
} {4221.0 123.0 3.141592653 2.15 0.123 -0.0013442 -1.6 -11}
} {4221 123 3.141592653 2.15 0.123 -0.0013442 -1.6 -11}
do_test sort-1.7 {
execsql {SELECT roman FROM t1 ORDER BY roman}
} {I II III IV V VI VII VIII}
@@ -106,27 +106,27 @@ do_test sort-2.1.1 {
UPDATE t1 SET v='x-2b' where v=='x-0.123';
SELECT v FROM t1 ORDER BY v;
}
} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11}
} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
do_test sort-2.1.2 {
execsql {
SELECT v FROM t1 ORDER BY substr(v,2,999);
}
} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11}
} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
do_test sort-2.1.3 {
execsql {
SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0;
}
} {x-4221.0 x-123.0 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11}
} {x-4221 x-123 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11}
do_test sort-2.1.4 {
execsql {
SELECT v FROM t1 ORDER BY substr(v,2,999) DESC;
}
} {x11 x1.6 x0.0013442 x-4221.0 x-3.141592653 x-2b x-2.15 x-123.0}
} {x11 x1.6 x0.0013442 x-4221 x-3.141592653 x-2b x-2.15 x-123}
do_test sort-2.1.5 {
execsql {
SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0 DESC;
}
} {x11 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123.0 x-4221.0}
} {x11 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123 x-4221}
# This is a bug fix for 2.2.4.
# Strings are normally mapped to upper-case for a caseless comparison.
@@ -196,17 +196,17 @@ do_test sort-4.6 {
execsql {
SELECT v FROM t1 ORDER BY 1;
}
} {x-123.0 x-2.15 x-2b x-3.141592653 x-4.0e9 x-4221.0 x0.0013442 x01234567890123456789 x1.6 x11 x2.7 x5.0e10}
} {x-123 x-2.15 x-2b x-3.141592653 x-4.0e9 x-4221 x0.0013442 x01234567890123456789 x1.6 x11 x2.7 x5.0e10}
do_test sort-4.7 {
execsql {
SELECT v FROM t1 ORDER BY 1 DESC;
}
} {x5.0e10 x2.7 x11 x1.6 x01234567890123456789 x0.0013442 x-4221.0 x-4.0e9 x-3.141592653 x-2b x-2.15 x-123.0}
} {x5.0e10 x2.7 x11 x1.6 x01234567890123456789 x0.0013442 x-4221 x-4.0e9 x-3.141592653 x-2b x-2.15 x-123}
do_test sort-4.8 {
execsql {
SELECT substr(v,2,99) FROM t1 ORDER BY 1;
}
} {-123.0 -2.15 -2b -3.141592653 -4.0e9 -4221.0 0.0013442 01234567890123456789 1.6 11 2.7 5.0e10}
} {-123 -2.15 -2b -3.141592653 -4.0e9 -4221 0.0013442 01234567890123456789 1.6 11 2.7 5.0e10}
#do_test sort-4.9 {
# execsql {
# SELECT substr(v,2,99)+0.0 FROM t1 ORDER BY 1;
@@ -362,7 +362,7 @@ do_test sort-8.1 {
INSERT INTO t5 VALUES(100.0,'A2');
SELECT * FROM t5 ORDER BY a, b;
}
} {100 A1 100.0 A2}
} {100 A1 100 A2}
ifcapable {bloblit} {

View File

@@ -12,7 +12,7 @@
# it tests that the different storage classes (integer, real, text etc.)
# all work correctly.
#
# $Id: types.test,v 1.14 2004/11/14 21:56:31 drh Exp $
# $Id: types.test,v 1.15 2005/11/01 15:48:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -56,11 +56,13 @@ do_test types-1.1.0 {
# literal were inserted into a column with affinity INTEGER, NUMERIC, TEXT
# or NONE, respectively.
set values {
{ 5.0 integer real text real }
{ 5.0 integer integer text integer }
{ 5.1 real real text real }
{ 5 integer integer text integer }
{ '5.0' integer real text text }
{ '-5.0' integer real text text }
{ '-5.0' integer real text text }
{ '5.0' integer integer text text }
{ '5.1' real real text text }
{ '-5.0' integer integer text text }
{ '-5.0' integer integer text text }
{ '5' integer integer text text }
{ 'abc' text text text text }
{ NULL null null null null }
@@ -221,13 +223,13 @@ do_test types-2.2.2 {
execsql {
SELECT a FROM t2;
}
} {0.0 12345.678 -12345.678}
} {0 12345.678 -12345.678}
# Check that all the record sizes are as we expected.
do_test types-2.2.3 {
set root [db eval {select rootpage from sqlite_master where name = 't2'}]
record_sizes $root
} {10 10 10}
} {3 10 10}
# Insert a NULL. This should be a two byte record.
do_test types-2.3.1 {

View File

@@ -12,7 +12,7 @@
# of this file is testing the interaction of SQLite manifest types
# with Tcl dual-representations.
#
# $Id: types3.test,v 1.1 2005/06/25 19:31:48 drh Exp $
# $Id: types3.test,v 1.2 2005/11/01 15:48:25 drh Exp $
#
set testdir [file dirname $argv0]
@@ -68,8 +68,12 @@ do_test types3-2.3 {
set V [db one {SELECT 1234567890123456}]
tcl_variable_type V
} wideInt
do_test types3-2.4 {
set V [db one {SELECT 1234567890123456.0}]
do_test types3-2.4.1 {
set V [db one {SELECT 1234567890123456.1}]
tcl_variable_type V
} wideInt
do_test types3-2.4.2 {
set V [db one {SELECT 1234567890123.456}]
tcl_variable_type V
} double
do_test types3-2.5 {