diff options
author | dan <Dan Kennedy> | 2024-01-20 18:41:13 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2024-01-20 18:41:13 +0000 |
commit | f28bff745c778598ef1740e4cbb1a44b176aac83 (patch) | |
tree | 9de200af80f685ecaf033161c02137dae548a0d1 /src | |
parent | 514bf99b6aa18f05f78d02b9b3afddc51d006eca (diff) | |
download | sqlite-f28bff745c778598ef1740e4cbb1a44b176aac83.tar.gz sqlite-f28bff745c778598ef1740e4cbb1a44b176aac83.zip |
Ensure that values generated by DEFAULT clauses that specify real numbers that can be expressed as 64-bit integers (e.g. -1234.0) are not silently converted to integers.
FossilOrigin-Name: 298d6977285c71be917896bc875a8a26d985dcf0a74069b7c4d290e8ff0ac618
Diffstat (limited to 'src')
-rw-r--r-- | src/vdbemem.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/vdbemem.c b/src/vdbemem.c index 2d10cda8d..cbc6712bf 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1662,8 +1662,17 @@ static int valueFromExpr( sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); } } - if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_BLOB ){ - sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); + if( affinity==SQLITE_AFF_BLOB ){ + if( op==TK_FLOAT ){ + assert( pVal && pVal->z && pVal->flags==(MEM_Str|MEM_Term) ); + sqlite3AtoF(pVal->z, &pVal->u.r, pVal->n, SQLITE_UTF8); + pVal->flags = MEM_Real; + }else if( op==TK_INTEGER ){ + /* This case is required by -9223372036854775808 and other strings + ** that look like integers but cannot be handled by the + ** sqlite3DecOrHexToI64() call above. */ + sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); + } }else{ sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8); } |