summaryrefslogtreecommitdiff
path: root/android/sqlite3_android.cpp
diff options
context:
space:
mode:
authorTaesu Lee <taesu82.lee@samsung.com>2019-08-04 01:42:56 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-08-04 01:42:56 -0700
commitb9f84b9b6629286202e4571f5888a39f3ab878e3 (patch)
tree4a606738c1197e4125534bac5ebe4e37db3b05dc /android/sqlite3_android.cpp
parent334a6f93f691b723def50948c245f4d64e670763 (diff)
parent588bff02507312f1d658b90c1f1bd3d47b19817e (diff)
Support loose comparison using minimum matched chars am: 33fdf2ebea am: 9e93fe299d
am: 588bff0250 Change-Id: Iaaeea811978e21f297da869c5c4b58f38332e639
Diffstat (limited to 'android/sqlite3_android.cpp')
-rw-r--r--android/sqlite3_android.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/android/sqlite3_android.cpp b/android/sqlite3_android.cpp
index 659ee6c..d2f1802 100644
--- a/android/sqlite3_android.cpp
+++ b/android/sqlite3_android.cpp
@@ -79,7 +79,7 @@ static int collate8(void *p, int n1, const void *v1, int n2, const void *v2)
static void phone_numbers_equal(sqlite3_context * context, int argc, sqlite3_value ** argv)
{
- if (argc != 2 && argc != 3) {
+ if (argc != 2 && argc != 3 && argc != 4) {
sqlite3_result_int(context, 0);
return;
}
@@ -88,8 +88,12 @@ static void phone_numbers_equal(sqlite3_context * context, int argc, sqlite3_val
char const * num2 = (char const *)sqlite3_value_text(argv[1]);
bool use_strict = false;
- if (argc == 3) {
+ int min_match = 0;
+ if (argc == 3 || argc == 4) {
use_strict = (sqlite3_value_int(argv[2]) != 0);
+ if (!use_strict && argc == 4) {
+ min_match = sqlite3_value_int(argv[3]);
+ }
}
if (num1 == NULL || num2 == NULL) {
@@ -98,9 +102,11 @@ static void phone_numbers_equal(sqlite3_context * context, int argc, sqlite3_val
}
bool equal =
- (use_strict ?
- android::phone_number_compare_strict(num1, num2) :
- android::phone_number_compare_loose(num1, num2));
+ (use_strict ? android::phone_number_compare_strict(num1, num2)
+ : ((min_match > 0)
+ ? android::phone_number_compare_loose_with_minmatch(
+ num1, num2, min_match)
+ : android::phone_number_compare_loose(num1, num2)));
if (equal) {
sqlite3_result_int(context, 1);
@@ -543,6 +549,14 @@ extern "C" int register_android_functions(sqlite3 * handle, int utf16Storage __a
return err;
}
+ // Register the PHONE_NUM_EQUALS function with additional arguments "use_strict" and "min_match"
+ err = sqlite3_create_function(
+ handle, "PHONE_NUMBERS_EQUAL", 4,
+ SQLITE_UTF8, NULL, phone_numbers_equal, NULL, NULL);
+ if (err != SQLITE_OK) {
+ return err;
+ }
+
// Register the _DELETE_FILE function
err = sqlite3_create_function(handle, "_DELETE_FILE", 1, SQLITE_UTF8, NULL, delete_file, NULL, NULL);
if (err != SQLITE_OK) {