Changeset: 48e07a7e89b5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/48e07a7e89b5
Modified Files:
        ctest/tools/monetdbe/backup.c
        monetdb5/modules/mal/tokenizer.c
        tools/monetdbe/monetdbe_mapi.c
Branch: Jul2021
Log Message:

Close descriptors and give more detailed error messages


diffs (64 lines):

diff --git a/ctest/tools/monetdbe/backup.c b/ctest/tools/monetdbe/backup.c
--- a/ctest/tools/monetdbe/backup.c
+++ b/ctest/tools/monetdbe/backup.c
@@ -41,13 +41,16 @@ main(void)
 
        /* open file stream */
        stream *fd = open_wastream("/tmp/backup");
-
-       if (dump_database(mid, fd, 0, 0, false)) {
-               if (mid->msg)
-                       error(mid->msg)
-               fprintf(stderr, "database backup failed\n");
+       if (fd) {
+               if (dump_database(mid, fd, 0, 0, false)) {
+                       if (mid->msg)
+                               error(mid->msg)
+                       error("database backup failed\n");
+               }
+               close_stream(fd);
+       } else {
+               fprintf(stderr, "Failure: unable to open file /tmp/backup: %s", 
mnstr_peek_error(NULL));
        }
-       close_stream(fd);
 
        if ((mid->msg = monetdbe_close(mid->mdbe)) != NULL)
                error(mid->msg);
diff --git a/monetdb5/modules/mal/tokenizer.c b/monetdb5/modules/mal/tokenizer.c
--- a/monetdb5/modules/mal/tokenizer.c
+++ b/monetdb5/modules/mal/tokenizer.c
@@ -405,8 +405,10 @@ TKNZRdepositFile(void *r, str *fnme)
                throw(MAL, "tokenizer.depositFile", "%s", 
mnstr_peek_error(NULL));
        }
        bs = bstream_create(fs, SIZE);
-       if (bs == NULL)
+       if (bs == NULL) {
+               close_stream(fs);
                throw(MAL, "tokenizer.depositFile", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+       }
        while (bstream_read(bs, bs->size - (bs->len - bs->pos)) != 0 &&
                   !mnstr_errnr(bs->s))
        {
diff --git a/tools/monetdbe/monetdbe_mapi.c b/tools/monetdbe/monetdbe_mapi.c
--- a/tools/monetdbe/monetdbe_mapi.c
+++ b/tools/monetdbe/monetdbe_mapi.c
@@ -295,9 +295,8 @@ monetdbe_mapi_dump_database(monetdbe_dat
                }
                close_stream(fd);
        } else {
-               return createException(MAL, "embedded.monetdbe_dump_database", 
"Unable to open file %s", filename);
+               return createException(MAL, "embedded.monetdbe_dump_database", 
"Unable to open file %s: %s", filename, mnstr_peek_error(NULL));
        }
-
        return msg;
 }
 
@@ -316,7 +315,7 @@ monetdbe_mapi_dump_table(monetdbe_databa
                }
                close_stream(fd);
        } else {
-               return createException(MAL, "embedded.monetdbe_dump_table", 
"Unable to open file %s", filename);
+               return createException(MAL, "embedded.monetdbe_dump_table", 
"Unable to open file %s: %s", filename, mnstr_peek_error(NULL));
        }
        return msg;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to