Changeset: 6363f5525317 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6363f5525317
Modified Files:
        gdk/gdk_bbp.c
        monetdb5/modules/atoms/json.c
Branch: Dec2023
Log Message:

Cleanup for json upgrade code


diffs (78 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2073,15 +2073,14 @@ BBPinit(bool allow_hge_upgrade)
                         * initialzation with a callback that actually
                         * knows how to perform the upgrade. */
                        int fd = MT_open(jsonupgradestr, O_WRONLY | O_CREAT);
+                       GDKfree(jsonupgradestr);
                        if (fd < 0) {
                                TRC_CRITICAL(GDK, "cannot create signal file 
jsonupgradeneeded");
-                               GDKfree(jsonupgradestr);
                                ATOMIC_SET(&GDKdebug, dbg);
                                return GDK_FAIL;
                        }
 
                        close(fd);
-                       GDKfree(jsonupgradestr);
                }
        }
 #endif
@@ -4570,7 +4569,7 @@ BBPdiskscan(const char *parent, size_t b
                        continue;       /* ignore .dot files and directories (. 
..) */
 
 #ifdef GDKLIBRARY_JSON
-               if (strncmp(dent->d_name, "jsonupgradeneed", 15) == 0) {
+               if (strcmp(dent->d_name, "jsonupgradeneed") == 0) {
                        continue; /* ignore json upgrade signal file  */
                }
 #endif
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -585,7 +585,9 @@ JSONisarray(bit *ret, json *js)
 static gdk_return
 upgradeJSONStorage(char **out, const char **in)
 {
-       if (JSONstr2json(out, in) != MAL_SUCCEED) {
+       str msg;
+       if ((msg = JSONstr2json(out, in)) != MAL_SUCCEED) {
+               freeException(msg);
                return GDK_FAIL;
        }
        return GDK_SUCCEED;
@@ -595,11 +597,13 @@ static str
 jsonRead(str a, size_t *dstlen, stream *s, size_t cnt)
 {
        str out = NULL;
+       str msg;
 
        if (BATatoms[TYPE_str].atomRead(a, dstlen, s, cnt) == NULL)
                return NULL;
 
-       if (upgradeJSONStorage(&out, (const char **) &a) != GDK_SUCCEED) {
+       if ((msg = JSONstr2json(&out, (const char **) &a)) != MAL_SUCCEED) {
+               freeException(msg);
                GDKfree(a);
                return NULL;
        }
@@ -628,10 +632,10 @@ JSONprelude(void)
                throw(MAL, "json.prelude", "cannot allocate filename for json 
upgrade signal file");
        }
        int r = stat(jsonupgrade, &st);
+       GDKfree(jsonupgrade);
        if (r == 0) {
                /* The file exists so we need to run the upgrade code */
                if (BBPjson_upgrade(upgradeJSONStorage) != GDK_SUCCEED) {
-                       GDKfree(jsonupgrade);
                        throw(MAL, "json.prelude", "JSON storage upgrade 
failed");
                }
                /* Change the read function of the json atom so that any values 
in the WAL
@@ -639,7 +643,6 @@ JSONprelude(void)
                 */
                BATatoms[TYPE_json].atomRead = (void *(*)(void *, size_t *, 
stream *, size_t)) jsonRead;
        }
-       GDKfree(jsonupgrade);
 #endif
        return MAL_SUCCEED;
 }
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to