Changeset: b1f208f17f0e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b1f208f17f0e
Modified Files:
monetdb5/modules/atoms/str.c
monetdb5/modules/kernel/batstr.c
monetdb5/optimizer/opt_support.c
sql/scripts/49_strings.sql
Branch: Jun2023
Log Message:
need more space during asciify
diffs (79 lines):
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -4997,10 +4997,8 @@ STRasciify(str *r, const str *s)
iconv_t cd;
const str f = "UTF8", t = "ASCII//TRANSLIT";
str in = *s, out;
- /* Output string length LEN+1 when converting from UTF-8 TO ASCII
- should be enough. If for some reason LEN is needed is totality,
- +1 safeguards the \0.*/
- size_t in_len = strlen(in), out_len = in_len + 1;
+ size_t in_len = strlen(in), out_len = in_len * 4; /* oversized as a
single utf8 char could change into multiple
+
ascii char */
/* man iconv; /TRANSLIT */
if ((cd = iconv_open(t, f)) == (iconv_t)(-1))
throw(MAL, "str.asciify", "ICONV: cannot convert from (%s) to
(%s).", f, t);
diff --git a/monetdb5/modules/kernel/batstr.c b/monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.c
+++ b/monetdb5/modules/kernel/batstr.c
@@ -5080,6 +5080,11 @@ BATSTRasciify(bat *ret, bat *bid)
throw(MAL, "batstr.asciify", GDK_EXCEPTION);
}
bi = bat_iterator(b);
+ if ((s = out = GDKmalloc(64*1024)) == NULL) {
+ msg = createException(MAL,"batstr.asciify", MAL_MALLOC_FAIL);
+ goto exit;
+ }
+ prev_out_len = 64*1024;
BATloop(b, p, q) {
in = (str) BUNtail(bi, p);
if (strNil(in)) {
@@ -5090,15 +5095,8 @@ BATSTRasciify(bat *ret, bat *bid)
nils = true;
continue;
}
- in_len = strlen(in), out_len = in_len + 1;
- if (out == NULL) {
- if ((s = out = GDKmalloc(out_len)) == NULL) {
- msg = createException(MAL,"batstr.asciify",
MAL_MALLOC_FAIL);
- goto exit;
- }
- prev_out_len = out_len;
- }
- else if (out_len > prev_out_len) {
+ in_len = strlen(in), out_len = in_len*4; /* over sized as
single utf8 symbols change into multiple ascii characters */
+ if (out_len > prev_out_len) {
if ((out = GDKrealloc(s, out_len)) == NULL) {
msg = createException(MAL,"batstr.asciify",
MAL_MALLOC_FAIL);
goto exit;
diff --git a/monetdb5/optimizer/opt_support.c b/monetdb5/optimizer/opt_support.c
--- a/monetdb5/optimizer/opt_support.c
+++ b/monetdb5/optimizer/opt_support.c
@@ -434,6 +434,7 @@ inline int isMapOp(InstrPtr p){
((getModuleId(p) == malRef && getFunctionId(p) == multiplexRef)
||
(getModuleId(p) == malRef && getFunctionId(p) == manifoldRef)
||
(getModuleId(p) == batcalcRef) ||
+ (getModuleId(p) == batstrRef) ||
(getModuleId(p) != batcalcRef && getModuleId(p) != batRef &&
strncmp(getModuleId(p), "bat", 3) == 0) ||
(getModuleId(p) == batmkeyRef)) && !isOrderDepenent(p) &&
getModuleId(p) != batrapiRef &&
@@ -448,6 +449,7 @@ inline int isMap2Op(InstrPtr p){
((getModuleId(p) == malRef && getFunctionId(p) == multiplexRef)
||
(getModuleId(p) == malRef && getFunctionId(p) == manifoldRef)
||
(getModuleId(p) == batcalcRef) ||
+ (getModuleId(p) == batstrRef) ||
(getModuleId(p) != batcalcRef && getModuleId(p) != batRef &&
strncmp(getModuleId(p), "bat", 3) == 0) ||
(getModuleId(p) == batmkeyRef)) && !isOrderDepenent(p) &&
getModuleId(p) != batrapiRef &&
diff --git a/sql/scripts/49_strings.sql b/sql/scripts/49_strings.sql
--- a/sql/scripts/49_strings.sql
+++ b/sql/scripts/49_strings.sql
@@ -8,6 +8,7 @@
create function asciify(x string)
returns string external name str."asciify";
+grant execute on function asciify(string) to public;
create function sys.startswith(x string, y string)
returns boolean external name str."startsWith";
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]