Changeset: 625a0a70d1e6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=625a0a70d1e6
Modified Files:
        monetdb5/modules/mal/mkey.c
        monetdb5/modules/mal/pcre.c
        sql/test/miscellaneous/Tests/simple_selects.sql
Branch: Nov2019
Log Message:

Added NULL semantics for pcre.patindex and mkey.hash because they can be called 
from SQL


diffs (57 lines):

diff --git a/monetdb5/modules/mal/mkey.c b/monetdb5/modules/mal/mkey.c
--- a/monetdb5/modules/mal/mkey.c
+++ b/monetdb5/modules/mal/mkey.c
@@ -51,6 +51,8 @@ MKEYhash(Client cntxt, MalBlkPtr mb, Mal
        val= getArgReference(stk,p,1);
        switch (ATOMstorage(tpe)) {
        case TYPE_void:
+               *res = lng_nil; /* It can be called from SQL */
+               break;
        case TYPE_bat:
        case TYPE_ptr:
                // illegal types, avoid falling into the default case.
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -1552,7 +1552,6 @@ PCREindex(int *res, const pcre *pattern,
 #endif
 }
 
-
 str
 PCREpatindex(int *ret, const str *pat, const str *val)
 {
@@ -1560,6 +1559,11 @@ PCREpatindex(int *ret, const str *pat, c
        pcre *re = NULL;
        char *ppat = NULL, *msg;
 
+       if (strNil(*pat) || strNil(*val)) {
+               *ret = int_nil;
+               return MAL_SUCCEED;
+       }
+
        if ((msg = pat2pcre(&ppat, *pat)) != MAL_SUCCEED)
                return msg;
        if ((msg = pcre_compile_wrap(&re, ppat, FALSE)) != MAL_SUCCEED) {
@@ -1601,7 +1605,6 @@ PCREquote(str *ret, const str *val)
        return MAL_SUCCEED;
 }
 
-
 str
 PCREsql2pcre(str *ret, const str *pat, const str *esc)
 {
diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql 
b/sql/test/miscellaneous/Tests/simple_selects.sql
--- a/sql/test/miscellaneous/Tests/simple_selects.sql
+++ b/sql/test/miscellaneous/Tests/simple_selects.sql
@@ -48,7 +48,9 @@ select difference('foobar', 'oobar'), di
        editdistance2('foobar', 'oobar'), editdistance2(NULL, 'oobar'), 
editdistance2('foobar', NULL), editdistance2(NULL, NULL),
        similarity('foobar', 'oobar'), similarity(NULL, 'oobar'), 
similarity('foobar', NULL), similarity(NULL, NULL),
        levenshtein('foobar', 'oobar'), levenshtein(NULL, 'oobar'), 
levenshtein('foobar', NULL), levenshtein(NULL, NULL);
-select avg(10), avg(NULL);
+select avg(10), avg(NULL),
+       patindex('o', 'foo'), patindex(NULL, 'foo'), patindex('o', NULL), 
patindex('o', NULL), patindex(NULL, NULL),
+       "hash"(null);
 
 select "idontexist"."idontexist"(); --error, it doesn't exist
 select "idontexist"."idontexist"(1); --error, it doesn't exist
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to