aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2019-08-30 23:56:34 +0000
committerdrh <drh@noemail.net>2019-08-30 23:56:34 +0000
commit7314495ff82c0ed4ac6f2776121282e3a8fe566a (patch)
treefd50499b586b20d9c007a30db836138618764bd7 /src
parenta7ce167e5b89e45d203014fc6ad0dbbfa3d44346 (diff)
downloadsqlite-7314495ff82c0ed4ac6f2776121282e3a8fe566a.tar.gz
sqlite-7314495ff82c0ed4ac6f2776121282e3a8fe566a.zip
When the affinity of a table column is INT or REAL, make the affinity of
corresponding index columns NUMERIC. This increases the precision of index lookups for large numbers so that it matches the precision of ordinary comparison operators. Ticket [40812aea1fde9594] FossilOrigin-Name: e0d909c740b774d8a46731696e33342be83206cc4a95d07f42fdb3d8cc2d7a8e
Diffstat (limited to 'src')
-rw-r--r--src/insert.c1
-rw-r--r--src/wherecode.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/src/insert.c b/src/insert.c
index 04d3d580f..d9078b89d 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -99,6 +99,7 @@ const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){
aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
}
if( aff<SQLITE_AFF_BLOB ) aff = SQLITE_AFF_BLOB;
+ if( aff>SQLITE_AFF_NUMERIC) aff = SQLITE_AFF_NUMERIC;
pIdx->zColAff[n] = aff;
}
pIdx->zColAff[n] = 0;
diff --git a/src/wherecode.c b/src/wherecode.c
index 2fbcba17e..22ed905f4 100644
--- a/src/wherecode.c
+++ b/src/wherecode.c
@@ -755,6 +755,7 @@ static int codeAllEqualityTerms(
if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
zAff[j] = SQLITE_AFF_BLOB;
}
+ if( zAff[j]==SQLITE_AFF_REAL ) zAff[j] = SQLITE_AFF_NUMERIC;
}
}
}