Fix for early termination of returned rows (#805)

Once the regex encountered the first instance of a non-match, it would return without processing the rest of the rows in the statement. This change allows it to process the remaining, only setting the sqlite3_result_int to zero then continuing. This worked fine for the example as it only had one item to process.
This commit is contained in:
ShanePerron 2020-05-02 11:42:42 -04:00 committed by GitHub
parent 98a44bcf59
commit 61ad8da9d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -13,9 +13,13 @@ static void regexp_func(sqlite3_context *context, int argc, sqlite3_value **argv
int vec[500];
int n, rc;
pcre* re = pcre_compile(pattern, 0, &errstr, &erroff, NULL);
if (!re) {
sqlite3_result_error(context, errstr, 0);
return;
}
rc = pcre_exec(re, NULL, target, strlen(target), 0, 0, vec, 500);
if (rc <= 0) {
sqlite3_result_error(context, errstr, 0);
sqlite3_result_int(context, 0);
return;
}
sqlite3_result_int(context, 1);