1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Create a new affinity called FLEXNUM that works like NUMERIC except that it

never tries to convert integer to real or real to integer.  The affinity is
only used internally - it is not possible to create a table column with this
affinity.  This affinity is used on subqueries and views that are built off
of a compound SELECT and where the datatype is controlled by a CAST expression.
dbsqlfuzz c9ee6f9a0a8b8fefb02cf69de2a8b67ca39525c8

FossilOrigin-Name: 44135d6ea84f7ba6b36549954b38a8bc048d5ffea5a9779e35950afa4eb2dfb2
This commit is contained in:
drh
2022-12-15 20:03:08 +00:00
parent 118b53bd21
commit 00d6b2755f
8 changed files with 75 additions and 42 deletions

View File

@ -515,4 +515,44 @@ do_execsql_test cast-9.13 {
SELECT x, typeof(x) FROM dual CROSS JOIN (SELECT CAST(4.5 AS NUMERIC) AS x);
} {4.5 real}
# 2022-12-15 dbsqlfuzz c9ee6f9a0a8b8fefb02cf69de2a8b67ca39525c8
#
# Added a new SQLITE_AFF_FLEXNUM that does not try to convert int to real or
# real to int.
#
do_execsql_test cast-10.1 {
VALUES(CAST(44 AS REAL)),(55);
} {44.0 55}
do_execsql_test cast-10.2 {
SELECT CAST(44 AS REAL) AS 'm' UNION ALL SELECT 55;
} {44.0 55}
do_execsql_test cast-10.3 {
SELECT * FROM (VALUES(CAST(44 AS REAL)),(55));
} {44.0 55}
do_execsql_test cast-10.4 {
SELECT * FROM (SELECT CAST(44 AS REAL) AS 'm' UNION ALL SELECT 55);
} {44.0 55}
do_execsql_test cast-10.5 {
SELECT * FROM dual CROSS JOIN (VALUES(CAST(44 AS REAL)),(55));
} {X 44.0 X 55}
do_execsql_test cast-10.6 {
SELECT * FROM dual CROSS JOIN (SELECT CAST(44 AS REAL) AS 'm'
UNION ALL SELECT 55);
} {X 44.0 X 55}
do_execsql_test cast-10.7 {
DROP VIEW v1;
CREATE VIEW v1 AS SELECT CAST(44 AS REAL) AS 'm' UNION ALL SELECT 55;
SELECT name, type FROM pragma_table_info('v1');
} {m NUM}
do_execsql_test cast-10.8 {
CREATE VIEW v2 AS VALUES(CAST(44 AS REAL)),(55);
SELECT type FROM pragma_table_info('v2');
} {NUM}
do_execsql_test cast-10.9 {
SELECT * FROM v1;
} {44.0 55}
do_execsql_test cast-10.10 {
SELECT * FROM v2;
} {44.0 55}
finish_test