Changeset: 59a69a3cac1e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=59a69a3cac1e
Modified Files:
        sql/backends/monet5/sql.c
        
sql/test/BugTracker-2016/Tests/wrong-nonil-property-with-copy-binary-into.Bug-3937.sql.in
Branch: Jul2015
Log Message:

Convert internal representation of file names for COPY BINARY INTO.
Also see changeset bbacfc235a00 and bug 3965.


diffs (51 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -3397,12 +3397,23 @@ mvc_bin_import_table_wrap(Client cntxt, 
 
        for (i = pci->retc + 2, n = t->columns.set->h; i < pci->argc && n; i++, 
n = n->next) {
                sql_column *col = n->data;
+               const char *fname = *getArgReference_str(stk, pci, i);
+               size_t flen = strlen(fname);
+               char *fn;
 
                if (ATOMvarsized(col->type.type->localtype) && 
col->type.type->localtype != TYPE_str)
                        throw(SQL, "sql", "Failed to attach file %s", 
*getArgReference_str(stk, pci, i));
-               f = fopen(*getArgReference_str(stk, pci, i), "r");
-               if (f == NULL)
-                       throw(SQL, "sql", "Failed to open file %s", 
*getArgReference_str(stk, pci, i));
+               fn = GDKmalloc(flen + 1);
+               GDKstrFromStr((unsigned char *) fn, (const unsigned char *) 
fname, flen);
+               if (fn == NULL)
+                       throw(SQL, "sql", MAL_MALLOC_FAIL);
+               f = fopen(fn, "r");
+               if (f == NULL) {
+                       msg = createException(SQL, "sql", "Failed to open file 
%s", fn);
+                       GDKfree(fn);
+                       return msg;
+               }
+               GDKfree(fn);
                fclose(f);
        }
 
diff --git 
a/sql/test/BugTracker-2016/Tests/wrong-nonil-property-with-copy-binary-into.Bug-3937.sql.in
 
b/sql/test/BugTracker-2016/Tests/wrong-nonil-property-with-copy-binary-into.Bug-3937.sql.in
--- 
a/sql/test/BugTracker-2016/Tests/wrong-nonil-property-with-copy-binary-into.Bug-3937.sql.in
+++ 
b/sql/test/BugTracker-2016/Tests/wrong-nonil-property-with-copy-binary-into.Bug-3937.sql.in
@@ -2,7 +2,7 @@ start transaction;
 
 
 create table "noNULLtinyint" (x tinyint);
-copy binary into "noNULLtinyint" from ('$TSTTRGDIR/noNULLtinyintBAT.bin');
+copy binary into "noNULLtinyint" from ('$QTSTTRGDIR/noNULLtinyintBAT.bin');
 
 select * from "noNULLtinyint";
 select count(*), count(x) from "noNULLtinyint";
@@ -18,7 +18,7 @@ select * from "noNULLtinyint" where x is
 
 
 create table "NULLtinyint" (x tinyint);
-copy binary into "NULLtinyint" from ('$TSTTRGDIR/NULLtinyintBAT.bin');
+copy binary into "NULLtinyint" from ('$QTSTTRGDIR/NULLtinyintBAT.bin');
 
 select * from "NULLtinyint";
 select count(*), count(x) from "NULLtinyint";
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to