Commit Graph

24 Commits

Author SHA1 Message Date
drh
00d6b2755f 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
2022-12-15 20:03:08 +00:00
drh
a8b5c8739c Back out the part of the change in [88a05141c28e5ff1] that adds affinity to
the materialization of a view, as the affinity can be undefined for a compound
query.  This passes all TCL tests, but shows failures in the TH3 tests derived
from [forum:/forumpost/6f842bc5b2dadcb2|forum post 6f842bc5b2dadcb2], presumably
because the WHERE clause of the query uses constraints of the form
"source_crs_code='8675'" instead of "source_crs_code=8675".  Perhaps further
changes on this branch should reimplement affinity on joins in cases where
the affinity is unambiguous.

FossilOrigin-Name: fe5a77bcc4de8f49cc4fe6bd2e2e1f31da8d3bc84120daaa99eb853b06291d15
2022-12-14 09:06:45 +00:00
drh
7ca4312ff2 Further fix for ticket [57c47526c34f01e8]. If a subquery has a result set
column of the form "CAST(expr AS NUMERIC)" do not give that column NUMERIC
affinity.  NUMERIC affinity always goes to an integer if able, but a CAST
to numeric is a no-op if the input is a number.  So the two are not equivalent.

FossilOrigin-Name: f0325359d5795237b79f90f21b42d7d942c7e918137cb0231d404365d3041e81
2022-12-12 21:22:23 +00:00
drh
89e160a96a If a subquery has a result column of the form "CAST(... AS NUMERIC)" then
give that column no affinity rather than NUMERIC affinity.  This is because
casting to numeric preserves real values that could be integers but numeric
affinity does not.  By using no affinity on the column, we make the behavior
consistent if the subquery is implemented as a co-routine or is materialized.

FossilOrigin-Name: ece07d091c2ef3367a914187e0b6512c1f2390b8c34844536ad50e88c7e8c2f2
2022-12-12 18:58:53 +00:00
drh
5fdb9a352c Enforce column affinity on the materialization of a subquery or view.
FossilOrigin-Name: b6692de374d7f489d8cf8877bdfef19501bc5ecb0781d42750807eeb58f2e7cd
2022-11-01 00:52:22 +00:00
dan
a344ad47f3 Do not apply affinities when creating entries for automatic indexes on views. Fix for [95302bdb].
FossilOrigin-Name: df12f097224ebc9473d9e2a8933bd7efed6490d09af2c012c9b59a7892369b7f
2020-10-03 19:16:36 +00:00
dan
9f3e6fadde Handle blobs that are the return values of functions being cast to text in utf16 databases in the same way as blobs read directly from the database. Fix for [771fe617].
FossilOrigin-Name: e782096aa06fcf410c3a0a6ee26a9e4f44333da39b28b2efe675814a8652911a
2020-01-02 16:24:22 +00:00
drh
0ce974d122 Adjust requirements marks and add new requirements tests.
FossilOrigin-Name: ebb81dad1f43dac4636cd44d4055d1d4b198c675f73e23c5a2d8d992ae27fe1f
2019-06-12 22:46:04 +00:00
drh
13d0402077 As a special case, casting '-0.0' into numeric should yield 0.
Fix for ticket [674385aeba91c774].

FossilOrigin-Name: 491f0f9bbddb6302536d99abd1ea481fd747ddcf6c6eaaacc0338d147b119081
2019-06-12 20:51:38 +00:00
drh
378a7d356b A string consisting of a single '.' is not a floating point literal with extra
text at the end.  Fix for ticket [412bba9b22c677da]

FossilOrigin-Name: 57050162294efec90caa5cc3c2f8c1a85215526adcf57b284ce2d2e799286b78
2019-06-10 23:45:10 +00:00
drh
c285ded26c Make sure a CAST to "NUMERIC" results in an integer if the value can be
losslessly expressed as an integer, as the documentation requires.
Ticket [dd6bffbfb6e61db9].

FossilOrigin-Name: c0c90961b4fa1c1185772d04fe1915bc1a1af27ed8ddb8db1c524bf90d68ccbf
2019-06-10 18:33:16 +00:00
drh
9a2782293c When casting string values into numeric and the string has a prefix that looks
like a number but total string is not a well-formed number, then take extra
care that the result is either integer or real depending on what the prefix
looks like.  Fix for tickets [e8bedb2a184001] and [4c2d7639f076aa].

FossilOrigin-Name: 67a68af5578f08d2be2e48cf4fd12a6cf35a09c47d259deda81950f7ee1f02f7
2019-06-07 22:26:08 +00:00
drh
4eb57ceffc Improve text-to-integer conversion in boundary cases. The
sqlite3Atoi64() function always returns the minimum or maximum integer
if the magnitude of the text value is too large.  Trailing whitespace is
now ignored.

FossilOrigin-Name: ace0644a1a2a42a3ea42d44f00a31915b8a7e56c9ba90f90a6c02001f89f9c86
2018-01-26 18:37:34 +00:00
dan
33f5379c43 Changes to various test scripts so that they pass on windows.
FossilOrigin-Name: 1586244b6d86d5a98af8c6f7a8324672e02df9c3
2011-05-05 19:44:22 +00:00
drh
1735fa8892 Fix a bug in the CAST operator associated with the column cache. (CVS 5866)
FossilOrigin-Name: 1b6a5140446da896f69fddc8d1ea076815bb45e3
2008-11-06 15:33:03 +00:00
drh
91fd4d46ad Miscellaneous code simplifications and cleanup and test coverage
enhancements. (CVS 4730)

FossilOrigin-Name: af129b6d158cc90ce9752dd6383c1de47f7b3e43
2008-01-19 20:11:25 +00:00
drh
a7fba4b055 Disable tests that require 80-bit long doubles when the host only
provides 64-bit long doubles.  Ticket #2570. (CVS 4215)

FossilOrigin-Name: 4f4f8ef416394b7e54e8894f7a0d067d64636fc4
2007-08-13 15:18:27 +00:00
danielk1977
5b159dc312 Fix a problem with casting blobs to numeric types. (CVS 4021)
FossilOrigin-Name: f2ce727c4d798c666e95876a2b67e8a305d82e3a
2007-05-17 16:34:43 +00:00
drh
cd7b46db84 Keep the full precision of integers if possible when casting to "numeric".
Ticket #2364. (CVS 4012)

FossilOrigin-Name: 2ac985a38034da87b0fa3837976e1f2164b22672
2007-05-16 11:55:56 +00:00
drh
57bacb2282 Ignore leading spaces on text to numeric conversions. Ticket #1662.
Fixes to test cases broken by the recent changes to round(). (CVS 3118)

FossilOrigin-Name: cdca3383c54b33aeafbbdbbb4ae7c90796cf66e5
2006-03-03 19:12:29 +00:00
danielk1977
ff890793fc Test file fixes for libaries compiled with various SQLITE_OMIT_ macros. (CVS 2961)
FossilOrigin-Name: c058f483a52c8043178b6329aa5e58bedf0c8277
2006-01-16 16:24:25 +00:00
drh
8df447f0e6 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
2005-11-01 15:48:24 +00:00
drh
df0bddaef3 The TCL interface binds variables as BLOB only if they have a bytearray
representation but no text representation. Ticket #1287. (CVS 2528)

FossilOrigin-Name: 8c99dca60aebee0ec5de9ed11350de864bc76584
2005-06-25 19:31:48 +00:00
drh
487e262f44 Remove the blob(), text() and numeric() functions added in (2524) and
replace them with the standard CAST operator.
Ticket #1287. (CVS 2527)

FossilOrigin-Name: 17631785f9ee8ab280c82677eb53886912e085bc
2005-06-25 18:42:14 +00:00