Skip to content

Commit 61ad8da

Browse files
authored
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.
1 parent 98a44bc commit 61ad8da

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

_example/mod_regexp/sqlite3_mod_regexp.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ static void regexp_func(sqlite3_context *context, int argc, sqlite3_value **argv
1313
int vec[500];
1414
int n, rc;
1515
pcre* re = pcre_compile(pattern, 0, &errstr, &erroff, NULL);
16+
if (!re) {
17+
sqlite3_result_error(context, errstr, 0);
18+
return;
19+
}
1620
rc = pcre_exec(re, NULL, target, strlen(target), 0, 0, vec, 500);
1721
if (rc <= 0) {
18-
sqlite3_result_error(context, errstr, 0);
22+
sqlite3_result_int(context, 0);
1923
return;
2024
}
2125
sqlite3_result_int(context, 1);

0 commit comments

Comments
 (0)