mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
When doing a text-affinity comparison between two values where one or both
have both a text and a numeric type, make sure the numeric type does not confuse the answer. This is a deeper fix to the problem observed by [forum:/forumpost/3776b48e71|forum pose 3776b48e71]. The problem bisects to [25f2246be404f38b] on 2014-08-24, prior to version 3.8.7. FossilOrigin-Name: 709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21
This commit is contained in:
@ -38,6 +38,24 @@ static void noopfunc(
|
||||
sqlite3_result_value(context, argv[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of the multitype_text() function.
|
||||
**
|
||||
** The function returns its argument. The result will always have a
|
||||
** TEXT value. But if the original input is numeric, it will also
|
||||
** have that numeric value.
|
||||
*/
|
||||
static void multitypeTextFunc(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
assert( argc==1 );
|
||||
(void)argc;
|
||||
(void)sqlite3_value_text(argv[0]);
|
||||
sqlite3_result_value(context, argv[0]);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
@ -64,5 +82,9 @@ int sqlite3_noop_init(
|
||||
rc = sqlite3_create_function(db, "noop_nd", 1,
|
||||
SQLITE_UTF8,
|
||||
0, noopfunc, 0, 0);
|
||||
if( rc ) return rc;
|
||||
rc = sqlite3_create_function(db, "multitype_text", 1,
|
||||
SQLITE_UTF8,
|
||||
0, multitypeTextFunc, 0, 0);
|
||||
return rc;
|
||||
}
|
||||
|
Reference in New Issue
Block a user