Changeset: e7839ae6a6b0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e7839ae6a6b0
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        monetdb5/ChangeLog.Apr2019
        monetdb5/mal/Tests/tst016.malC
        monetdb5/mal/Tests/tst016.stable.out
        monetdb5/modules/atoms/blob.c
        monetdb5/modules/atoms/blob.mal
Branch: Apr2019
Log Message:

Removed function blob.tostring().


diffs (162 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -9128,8 +9128,6 @@ Ready.
 [ "blob",      "nitems",       "command blob.nitems(b:blob):int ",     
"BLOBnitems;",  "get the number of bytes in this blob." ]
 [ "blob",      "prelude",      "command blob.prelude():void ", "BLOBprelude;", 
""      ]
 [ "blob",      "toblob",       "command blob.toblob(v:str):blob ",     
"BLOBtoblob;",  "store a string as a blob."     ]
-[ "blob",      "tostring",     "command blob.tostring(v:blob):str ",   
"BLOBfromblob;",        "get the bytes from blob as a string, till\n\tthe first 
0 byte or the end of the blob"  ]
-[ "blob",      "tostring",     "command blob.tostring(v:blob, index:int):str 
",        "BLOBfromidx;", "get the bytes from blob as a string,\n\t starting at 
byte 'index' till the first\n\t0 byte or the end of the blob."    ]
 [ "bstream",   "create",       "unsafe command bstream.create(s:streams, 
bufsize:int):bstream ",       "bstream_create_wrapwrap;",     "create a 
buffered stream"      ]
 [ "bstream",   "destroy",      "unsafe command bstream.destroy(s:bstream):void 
",      "bstream_destroy_wrapwrap;",    "destroy bstream"       ]
 [ "bstream",   "read", "unsafe command bstream.read(s:bstream, size:int):int 
",        "bstream_read_wrapwrap;",       "read at least size bytes into the 
buffer of s" ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -12874,8 +12874,6 @@ Ready.
 [ "blob",      "nitems",       "command blob.nitems(b:blob):int ",     
"BLOBnitems;",  "get the number of bytes in this blob." ]
 [ "blob",      "prelude",      "command blob.prelude():void ", "BLOBprelude;", 
""      ]
 [ "blob",      "toblob",       "command blob.toblob(v:str):blob ",     
"BLOBtoblob;",  "store a string as a blob."     ]
-[ "blob",      "tostring",     "command blob.tostring(v:blob):str ",   
"BLOBfromblob;",        "get the bytes from blob as a string, till\n\tthe first 
0 byte or the end of the blob"  ]
-[ "blob",      "tostring",     "command blob.tostring(v:blob, index:int):str 
",        "BLOBfromidx;", "get the bytes from blob as a string,\n\t starting at 
byte 'index' till the first\n\t0 byte or the end of the blob."    ]
 [ "bstream",   "create",       "unsafe command bstream.create(s:streams, 
bufsize:int):bstream ",       "bstream_create_wrapwrap;",     "create a 
buffered stream"      ]
 [ "bstream",   "destroy",      "unsafe command bstream.destroy(s:bstream):void 
",      "bstream_destroy_wrapwrap;",    "destroy bstream"       ]
 [ "bstream",   "read", "unsafe command bstream.read(s:bstream, size:int):int 
",        "bstream_read_wrapwrap;",       "read at least size bytes into the 
buffer of s" ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -851,8 +851,6 @@ str BLOBblob_blob(blob **d, blob **s);
 str BLOBblob_fromstr(blob **b, const char **d);
 int BLOBcmp(const blob *l, const blob *r);
 void BLOBdel(Heap *h, var_t *index);
-str BLOBfromblob(str *retval, blob **b);
-str BLOBfromidx(str *retval, blob **binp, int *index);
 ssize_t BLOBfromstr(const char *instr, size_t *l, blob **val, bool external);
 int BLOBget(Heap *h, int *bun, int *l, blob **val);
 BUN BLOBhash(const blob *b);
diff --git a/monetdb5/ChangeLog.Apr2019 b/monetdb5/ChangeLog.Apr2019
--- a/monetdb5/ChangeLog.Apr2019
+++ b/monetdb5/ChangeLog.Apr2019
@@ -1,6 +1,10 @@
 # ChangeLog file for MonetDB5
 # This file is updated with Maddlog
 
+* Wed Jan 23 2019 Sjoerd Mullender <[email protected]>
+- Removed function blob.tostring() since it cannot guarantee that the
+  resulting string is properly encoded in UTF-8.
+
 * Tue Jan 22 2019 Sjoerd Mullender <[email protected]>
 - Removed the type "sqlblob", changed the external format of the type
   "blob" to be like what "sqlblob" used to be.  In other words, the
diff --git a/monetdb5/mal/Tests/tst016.malC b/monetdb5/mal/Tests/tst016.malC
--- a/monetdb5/mal/Tests/tst016.malC
+++ b/monetdb5/mal/Tests/tst016.malC
@@ -1,11 +1,12 @@
 # handling basic strings
 a:= "Dit is een test\n";
 b:= blob.toblob(a);
-c:= blob.tostring(b);
+# blob.tostring has been removed since it cannot guarantee UTF-8.
+#c:= blob.tostring(b);
 
 io.print(a);
 io.print(b);
-io.print(c);
+#io.print(c);
 
 
 
diff --git a/monetdb5/mal/Tests/tst016.stable.out 
b/monetdb5/mal/Tests/tst016.stable.out
--- a/monetdb5/mal/Tests/tst016.stable.out
+++ b/monetdb5/mal/Tests/tst016.stable.out
@@ -32,7 +32,6 @@ Ready.
 #io.print(a);
 [ "Dit is een test\n" ]
 [ "4469742069732065656E20746573740A00" ]
-[ "Dit is een test\n" ]
 
 # 20:08:53 >  
 # 20:08:53 >  Done.
diff --git a/monetdb5/modules/atoms/blob.c b/monetdb5/modules/atoms/blob.c
--- a/monetdb5/modules/atoms/blob.c
+++ b/monetdb5/modules/atoms/blob.c
@@ -44,8 +44,6 @@ mal_export void BLOBdel(Heap *h, var_t *
 mal_export size_t BLOBlength(const blob *p);
 mal_export void BLOBheap(Heap *heap, size_t capacity);
 mal_export str BLOBtoblob(blob **retval, str *s);
-mal_export str BLOBfromblob(str *retval, blob **b);
-mal_export str BLOBfromidx(str *retval, blob **binp, int *index);
 mal_export str BLOBnitems(int *ret, blob **b);
 mal_export int BLOBget(Heap *h, int *bun, int *l, blob **val);
 mal_export blob * BLOBread(blob *a, stream *s, size_t cnt);
@@ -77,25 +75,6 @@ static blob nullval = {
 
 static char hexit[] = "0123456789ABCDEF";
 
-static str
-fromblob_idx(str *retval, blob *b, int *idx)
-{
-       str s, p = b->data + *idx;
-       str r, q = b->data + b->nitems;
-
-       for (r = p; r < q; r++) {
-               if (*r == 0)
-                       break;
-       }
-       *retval = s = (str) GDKmalloc(1 + r - p);
-       if( *retval == NULL)
-               throw(MAL, "blob.tostring", SQLSTATE(HY001) MAL_MALLOC_FAIL);
-       for (; p < r; p++, s++)
-               *s = *p;
-       *s = 0;
-       return MAL_SUCCEED;
-}
-
 /*
  * @- Wrapping section
  * This section contains the wrappers to re-use the implementation
@@ -202,20 +181,6 @@ BLOBnitems(int *ret, blob **b)
 }
 
 str
-BLOBfromidx(str *retval, blob **binp, int *idx)
-{
-       return fromblob_idx(retval, *binp, idx);
-}
-
-str
-BLOBfromblob(str *retval, blob **b)
-{
-       int zero = 0;
-
-       return fromblob_idx(retval, *b, &zero);
-}
-
-str
 BLOBtoblob(blob **retval, str *s)
 {
        size_t len = strLen(*s);
diff --git a/monetdb5/modules/atoms/blob.mal b/monetdb5/modules/atoms/blob.mal
--- a/monetdb5/modules/atoms/blob.mal
+++ b/monetdb5/modules/atoms/blob.mal
@@ -28,17 +28,10 @@ command blob(s:str):blob
 address BLOBblob_fromstr;
 
 # @+ string functions
-# Manipulation functions to extract strings from blobs and vice versa.
+# Manipulation function to convert strings to blobs.
 # Not to be confused with blob parsing and printing.
-command tostring(v:blob) :str
-address BLOBfromblob
-comment "get the bytes from blob as a string, till
-       the first 0 byte or the end of the blob";
-command tostring(v:blob, index:int ) :str
-address BLOBfromidx
-comment "get the bytes from blob as a string,
-        starting at byte 'index' till the first
-       0 byte or the end of the blob.";
+# Note, a function tostring(b:blob):str is not possible since the
+# string would not be guaranteed UTF-8 encoded.
 command toblob(v:str) :blob
 address BLOBtoblob
 comment "store a string as a blob.";
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to