Changeset: 0b429c589fd7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0b429c589fd7
Modified Files:
monetdb5/modules/mal/txtsim.c
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.out
Branch: Nov2019
Log Message:
Handeling NULL values at txtsim module.
I'm just making Aris happy.
diffs (63 lines):
diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c
--- a/monetdb5/modules/mal/txtsim.c
+++ b/monetdb5/modules/mal/txtsim.c
@@ -107,6 +107,11 @@ levenshtein_impl(int *result, str *S, st
int sz; /* number of cells in matrix */
int diag2 = 0, cost2 = 0;
+ if (strNil(*S) || strNil(*T)) {
+ *result = int_nil;
+ return MAL_SUCCEED;
+ }
+
/* Step 1 */
n = (int) strlen(s); /* 64bit: assume strings are less than 2 GB */
m = (int) strlen(t);
@@ -812,6 +817,11 @@ fstrcmp_impl(dbl *ret, str *S1, str *S2,
static int *fdiag_buf;
static size_t fdiag_max;
+ if (strNil(*S1) || strNil(*S2) || is_dbl_nil(*minimum)) {
+ *ret = dbl_nil;
+ return MAL_SUCCEED;
+ }
+
/* set the info for each string. */
string[0].data = string1;
string[0].data_length = (int) strlen(string1); /* 64bit: assume string
not too long */
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
@@ -43,6 +43,12 @@ select cast(z as interval second) from x
select cast(z as interval month) from x; --error, cannot cast
drop table x;
+select difference('foobar', 'oobar'), difference(NULL, 'oobar'),
difference('foobar', NULL), difference(NULL, NULL),
+ editdistance('foobar', 'oobar'), editdistance(NULL, 'oobar'),
editdistance('foobar', NULL), editdistance(NULL, NULL),
+ 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 "idontexist"."idontexist"(); --error, it doesn't exist
select "idontexist"."idontexist"(1); --error, it doesn't exist
select "idontexist"."idontexist"(1,2); --error, it doesn't exist
diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.out
b/sql/test/miscellaneous/Tests/simple_selects.stable.out
--- a/sql/test/miscellaneous/Tests/simple_selects.stable.out
+++ b/sql/test/miscellaneous/Tests/simple_selects.stable.out
@@ -172,6 +172,16 @@ stdout of test 'simple_selects` in direc
#insert into x values (null, null, null);
[ 1 ]
#drop table x;
+#select difference('foobar', 'oobar'), difference(NULL, 'oobar'),
difference('foobar', NULL), difference(NULL, NULL),
+# editdistance('foobar', 'oobar'), editdistance(NULL, 'oobar'),
editdistance('foobar', NULL), editdistance(NULL, NULL),
+# 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);
+% .L2, .L4, .L6, .L10, .L12, .L14, .L16, .L20, .L22, .L24,
.L26, .L30, .L32, .L34, .L36, .L40, .L42, .L44, .L46, .L50 #
table_name
+% L2, L4, L6, L10, L12, L14, L16, L20, L22, L24,
L26, L30, L32, L34, L36, L40, L42, L44, L46, L50 #
name
+% int, int, int, int, int, int, int, int, int, int,
int, int, double, double, double, double, int, int, int, int #
type
+% 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 24, 24, 24, 24, 1, 1, 1, 1 #
length
+[ 1, NULL, NULL, NULL, 1, NULL, NULL, NULL, 1, NULL,
NULL, NULL, 0.9090909091, NULL, NULL, NULL, 1, NULL, NULL,
NULL ]
#select substring('abc' from 1 for null);
% .L2 # table_name
% L2 # name
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list