mirror of
https://github.com/sqlite/sqlite.git
synced 2026-10-23 21:49:02 +03:00
Cap constraint values on constraints to the amatch virtual table so
that they fit into a 32-bit signed integer. [bugs:/info/2026-08-02T13:01:25Z|Bug 2026-08-02T13:01:25Z] FossilOrigin-Name: 092b87164aa7d097287ad0fee4be8b66cf840043dc3091193824d74f2d54a833
This commit is contained in:
@@ -557,6 +557,17 @@ static amatch_rule *amatchMergeRules(amatch_rule *pA, amatch_rule *pB){
|
||||
return head.pNext;
|
||||
}
|
||||
|
||||
/*
|
||||
** Truncate an integer so that it fits in 32 bits.
|
||||
*/
|
||||
static int amatchTruncateInt(sqlite3_int64 i){
|
||||
if( i>=-2147483647 && i<=2147483646 ){
|
||||
return (int)i;
|
||||
}else{
|
||||
return i<0 ? -2147483648 : 2147483647;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Statement pStmt currently points to a row in the amatch data table. This
|
||||
** function allocates and populates a amatch_rule structure according to
|
||||
@@ -575,7 +586,8 @@ static int amatchLoadOneRule(
|
||||
sqlite3_int64 iLang = sqlite3_column_int64(pStmt, 0);
|
||||
const char *zFrom = (const char *)sqlite3_column_text(pStmt, 1);
|
||||
const char *zTo = (const char *)sqlite3_column_text(pStmt, 2);
|
||||
amatch_cost rCost = sqlite3_column_int(pStmt, 3);
|
||||
sqlite3_int64 iCost = sqlite3_column_int64(pStmt, 3);
|
||||
amatch_cost rCost = amatchTruncateInt(iCost);
|
||||
|
||||
int rc = SQLITE_OK; /* Return code */
|
||||
int nFrom; /* Size of string zFrom, in bytes */
|
||||
@@ -1269,11 +1281,13 @@ static int amatchFilter(
|
||||
idx++;
|
||||
}
|
||||
if( idxNum & 2 ){
|
||||
pCur->rLimit = (amatch_cost)sqlite3_value_int(argv[idx]);
|
||||
sqlite3_int64 ii = sqlite3_value_int64(argv[idx]);
|
||||
pCur->rLimit = (amatch_cost)amatchTruncateInt(ii);
|
||||
idx++;
|
||||
}
|
||||
if( idxNum & 4 ){
|
||||
pCur->iLang = (amatch_cost)sqlite3_value_int(argv[idx]);
|
||||
sqlite3_int64 ii = sqlite3_value_int64(argv[idx]);
|
||||
pCur->iLang = (amatch_cost)amatchTruncateInt(ii);
|
||||
idx++;
|
||||
}
|
||||
pCur->zInput = sqlite3_mprintf("%s", zWord);
|
||||
|
||||
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
||||
C Update\sthe\sheader\scomment\son\sthe\szipfile\sextension\sto\sstate\sclearly\sthat\nwrites\sto\sthe\sZIP\sarchive\sare\snon-transaction.\s\sNo\scode\schanges.\n[bugs:/info/2026-08-02T14:03:49Z|Bug\s2026-08-02T14:03:49Z].
|
||||
D 2026-08-02T20:17:53.285
|
||||
C Cap\sconstraint\svalues\son\sconstraints\sto\sthe\samatch\svirtual\stable\sso\nthat\sthey\sfit\sinto\sa\s32-bit\ssigned\sinteger.\n[bugs:/info/2026-08-02T13:01:25Z|Bug\s2026-08-02T13:01:25Z]
|
||||
D 2026-08-02T21:59:03.804
|
||||
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
@@ -361,7 +361,7 @@ F ext/jni/src/tests/000-000-sanity.test c3427a0e0ac84d7cbe4c95fdc1cd4b61f9ddcf43
|
||||
F ext/jni/src/tests/000-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70
|
||||
F ext/jni/src/tests/900-001-fts.test bf0ce17a8d082773450e91f2388f5bbb2dfa316d0b676c313c637a91198090f0
|
||||
F ext/misc/README.md 6243cdc4d7eb791c41ef0716f3980b8b5f6aa8c61ff76a3958cbf0031c6ebfa7
|
||||
F ext/misc/amatch.c 04d0f3d0e6206adaec93369e82c45d40e8f6f42c2b3701741c1197e4327b079d
|
||||
F ext/misc/amatch.c 765106f2ade2ab6a2834719d7fdb5779a94f3628214b69af0d1771269a9079f4
|
||||
F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb
|
||||
F ext/misc/appendvfs.c 7ad2cdf861399bff503f7e510bfbbc18a4529752255d9766f3a24ced67cb68c5
|
||||
F ext/misc/base64.c 1445761667c16356e827fc6418294c869468be934429aaa8315035e76dd58acf
|
||||
@@ -861,7 +861,7 @@ F test/altertab.test 8a2712f9076da5012a002d0b5cc0a421398a5bf61c25bab41b77c427586
|
||||
F test/altertab2.test 0889ba0700cc1cdb7bc7d25975aa61fece34f621de963d0886e2395716b38576
|
||||
F test/altertab3.test 575e771e2f02b13eb98798dc92eabacd187d6dbcf596e70f11d699b0b6b5d0b2
|
||||
F test/altertrig.test b1590647076add5a47aea0f2236c609ca0bc8a7a2462463edd3e5882c7894802
|
||||
F test/amatch1.test d276ddadc1874dacd3bb0b90c0f243455f30782c0a7d59b33362fea35b30e900
|
||||
F test/amatch1.test 3e186b7baa88109d59009086a9df723776528222a8d9f2a372a8312fd3bec372
|
||||
F test/analyze.test 2fb21d7d64748636384e6cb8998dbf83968caf644c07fcb4f76c18f2e7ede94b
|
||||
F test/analyze3.test 42adfaedaddca1d93d9f4ac38465791e25a2e4b7a261a5278e92f554ac1e15f1
|
||||
F test/analyze4.test 68bd069f3ac7ac1e652ddd9f04f57d5606ddb4208450f5297005db7aa0dd707d
|
||||
@@ -2218,8 +2218,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
|
||||
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
|
||||
P 1c95c741ca01be4241657f27e5e8697afb46dbc2ca4764a3de5080b04ffa3750
|
||||
R 73bf4368cf006adcf9ad8f8e17cc4dc9
|
||||
P 1b623a6064427e81dffc2897e017accc98243ecaf23c5f4df752d3da91b51be6
|
||||
R 740cb170217d66f4150da7baf3c46ad1
|
||||
U drh
|
||||
Z 9afe29b2c2552c2dd0a726ad10e84fe2
|
||||
Z 08dc212a3315cb5ee144d1adba1172c3
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
@@ -1 +1 @@
|
||||
1b623a6064427e81dffc2897e017accc98243ecaf23c5f4df752d3da91b51be6
|
||||
092b87164aa7d097287ad0fee4be8b66cf840043dc3091193824d74f2d54a833
|
||||
|
||||
@@ -148,4 +148,27 @@ do_catchsql_test amatch1-4.1 {
|
||||
);
|
||||
} {1 {approximate_match: cost must be between 1 and 1000}}
|
||||
|
||||
# Bug 2026-08-02T13:01:25Z
|
||||
do_execsql_test amatch1-5.0 {
|
||||
CREATE TABLE vocab(w);
|
||||
INSERT INTO vocab VALUES('abc');
|
||||
CREATE TABLE costs(a,b,c,d);
|
||||
INSERT INTO costs VALUES(0,'?','',97),(0,'','?',98);
|
||||
CREATE VIRTUAL TABLE t USING approximate_match(
|
||||
vocabulary_table=vocab,
|
||||
vocabulary_word=w,
|
||||
edit_distances=costs
|
||||
);
|
||||
}
|
||||
do_execsql_test amatch1-5.1 {
|
||||
SELECT word, distance FROM t WHERE word MATCH 'abc';
|
||||
} {abc 0}
|
||||
do_execsql_test amatch1-5.2 {
|
||||
SELECT word, distance FROM t WHERE word MATCH 'abc'
|
||||
AND distance<9223372036854775807;
|
||||
} {abc 0}
|
||||
do_execsql_test amatch1-5.3 {
|
||||
SELECT word, distance FROM t WHERE word MATCH 'abc' AND distance<10;
|
||||
} {abc 0}
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user