Changeset: 4e2aaf9d1179 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4e2aaf9d1179
Added Files:
        sql/test/miscellaneous/Tests/blobs.SQL.py
        sql/test/miscellaneous/Tests/blobs.stable.out
Modified Files:
        clients/mapiclient/dump.c
        sql/test/miscellaneous/Tests/All
Branch: Jan2022
Log Message:

Dump blobs between double quotes, so empty blobs are correctly dumped


diffs (85 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1773,11 +1773,11 @@ dump_table_data(Mapi mid, const char *sc
                }
 
                for (i = 0; i < cnt; i++) {
+                       const char *tp = mapi_get_type(hdl, i);
                        s = mapi_fetch_field(hdl, i);
                        if (s == NULL)
                                mnstr_printf(toConsole, "NULL");
                        else if (useInserts) {
-                               const char *tp = mapi_get_type(hdl, i);
                                if (strlen(tp) > 4 && strcmp(tp+3, "_interval") 
== 0) {
                                        const char *p = strchr(s, '.');
                                        if (p == NULL)
@@ -1809,6 +1809,10 @@ dump_table_data(Mapi mid, const char *sc
                                /* write double-quoted string with
                                   certain characters escaped */
                                squoted_print(toConsole, s, '"', noescape);
+                       } else if (strcmp(tp, "blob") == 0) {
+                               /* inside blobs, special characters 
+                                  don't occur */
+                               mnstr_printf(toConsole, "\"%s\"", s);
                        } else
                                mnstr_printf(toConsole, "%s", s);
 
diff --git a/sql/test/miscellaneous/Tests/All b/sql/test/miscellaneous/Tests/All
--- a/sql/test/miscellaneous/Tests/All
+++ b/sql/test/miscellaneous/Tests/All
@@ -24,3 +24,4 @@ rel_push_count_down
 NOT_ASSERT?sqlfuncnames
 sequences
 analyze_test
+blobs
diff --git a/sql/test/miscellaneous/Tests/blobs.SQL.py 
b/sql/test/miscellaneous/Tests/blobs.SQL.py
new file mode 100644
--- /dev/null
+++ b/sql/test/miscellaneous/Tests/blobs.SQL.py
@@ -0,0 +1,13 @@
+from MonetDBtesting.sqltest import SQLTestCase
+
+with SQLTestCase() as tc:
+    tc.execute('''
+    START TRANSACTION;
+    CREATE TABLE myt(c0 BINARY LARGE OBJECT,c1 INTEGER);
+    INSERT INTO myt VALUES
+    (BINARY LARGE OBJECT '', 1),(BINARY LARGE OBJECT '', 1),
+    (BINARY LARGE OBJECT 'AB', 1),(BINARY LARGE OBJECT 'A1EFD3', 1),
+    (NULL, NULL),(NULL, 1),(BINARY LARGE OBJECT '', NULL);
+    COMMIT;''').assertSucceeded()
+    tc.sqldump().assertMatchStableOut(fout='blobs.stable.out')
+    tc.execute('drop table myt;').assertSucceeded()
diff --git a/sql/test/miscellaneous/Tests/blobs.stable.out 
b/sql/test/miscellaneous/Tests/blobs.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/miscellaneous/Tests/blobs.stable.out
@@ -0,0 +1,27 @@
+stdout of test 'blobs` in directory 'sql/test/sql_dump` itself:
+
+
+# 10:39:12 >  
+# 10:39:12 >  "/usr/bin/python3" "blobs.SQL.py" "blobs"
+# 10:39:12 >  
+
+START TRANSACTION;
+SET SCHEMA "sys";
+CREATE TABLE "sys"."myt" (
+       "c0" BINARY LARGE OBJECT,
+       "c1" INTEGER
+);
+COPY 7 RECORDS INTO "sys"."myt" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+""     1
+""     1
+"AB"   1
+"A1EFD3"       1
+NULL   NULL
+NULL   1
+""     NULL
+COMMIT;
+
+# 10:39:14 >  
+# 10:39:14 >  "Done."
+# 10:39:14 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to