diff options
author | ShanePerron <35239305+ShanePerron@users.noreply.github.com> | 2020-05-02 11:42:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-03 00:42:42 +0900 |
commit | 61ad8da9d6d4575a65db9815871c561e70db1c01 (patch) | |
tree | fc4453b809612dcd630cc562d6ea71484c75c044 | |
parent | report actual error message if sqlite3_load_extension fails (#800) (diff) | |
download | golite-61ad8da9d6d4575a65db9815871c561e70db1c01.tar.gz golite-61ad8da9d6d4575a65db9815871c561e70db1c01.tar.xz |
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.
-rw-r--r-- | _example/mod_regexp/sqlite3_mod_regexp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/_example/mod_regexp/sqlite3_mod_regexp.c b/_example/mod_regexp/sqlite3_mod_regexp.c index 277764d..d3ad149 100644 --- a/_example/mod_regexp/sqlite3_mod_regexp.c +++ b/_example/mod_regexp/sqlite3_mod_regexp.c @@ -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); |