Changeset: 88bab5d405e0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=88bab5d405e0
Modified Files:
        clients/mapiclient/dump.c
        clients/mapiclient/msqldump.c
        gdk/gdk_utils.c
Branch: default
Log Message:

In database dump, record both client and server version/revision.


diffs (115 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2798,7 +2798,7 @@ void
 dump_version(Mapi mid, stream *toConsole, const char *prefix)
 {
        MapiHdl hdl;
-       char *dbname = NULL, *uri = NULL, *dbver = NULL, *dbrel = NULL;
+       char *dbname = NULL, *uri = NULL, *dbver = NULL, *dbrel = NULL, *dbrev 
= NULL;
        const char *name, *val;
 
        if ((hdl = mapi_query(mid,
@@ -2807,7 +2807,8 @@ dump_version(Mapi mid, stream *toConsole
                              "WHERE name IN ('gdk_dbname', "
                                        "'monet_version', "
                                        "'monet_release', "
-                                       "'merovingian_uri')")) == NULL ||
+                                       "'merovingian_uri', "
+                                       "'revision')")) == NULL ||
                        mapi_error(mid))
                goto cleanup;
 
@@ -2831,6 +2832,9 @@ dump_version(Mapi mid, stream *toConsole
                        } else if (strcmp(name, "merovingian_uri") == 0) {
                                assert(uri == NULL);
                                uri = strdup(val);
+                       } else if (strcmp(name, "revision") == 0) {
+                               assert(dbrev == NULL);
+                               dbrev = strdup(val);
                        }
                }
        }
@@ -2840,15 +2844,16 @@ dump_version(Mapi mid, stream *toConsole
                dbname = uri;
                uri = NULL;
        }
-       if (dbname != NULL && dbver != NULL) {
-               mnstr_printf(toConsole, "%s MonetDB v%s%s%s%s, '%s'\n",
-                            prefix,
-                                dbver,
-                                dbrel != NULL ? " (" : "",
-                                dbrel != NULL ? dbrel : "",
-                                dbrel != NULL ? ")" : "",
-                                dbname);
-       }
+       mnstr_printf(toConsole, "%s MonetDB", prefix);
+       if (dbver)
+               mnstr_printf(toConsole, " v%s", dbver);
+       if (dbrel && strcmp(dbrel, "unreleased") != 0)
+               mnstr_printf(toConsole, " (%s)", dbrel);
+       else if (dbrev && strcmp(dbrev, "Unknown") != 0)
+               mnstr_printf(toConsole, " (hg id: %s)", dbrev);
+       if (dbname)
+               mnstr_printf(toConsole, ", '%s'", dbname);
+       mnstr_printf(toConsole, "\n");
 
   cleanup:
        if (dbname != NULL)
@@ -2859,6 +2864,8 @@ dump_version(Mapi mid, stream *toConsole
                free(dbrel);
        if (uri != NULL)
                free(uri);
+       if (dbrev != NULL)
+               free(dbrev);
        if (hdl)
                mapi_close_handle(hdl);
 }
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -197,6 +197,7 @@ main(int argc, char **argv)
                char buf[27];
                time_t t = time(0);
                char *p;
+               const char *rev = mercurial_revision();
 
 #ifdef HAVE_CTIME_R3
                ctime_r(&t, buf, sizeof(buf));
@@ -209,11 +210,21 @@ main(int argc, char **argv)
 #endif
                if ((p = strrchr(buf, '\n')) != NULL)
                        *p = 0;
-               mnstr_printf(out, "-- msqldump %s %s%s %s\n",
+
+               mnstr_printf(out,
+                            "-- msqldump version %s", VERSION);
+               /* coverity[pointless_string_compare] */
+               if (strcmp(MONETDB_RELEASE, "unreleased") != 0)
+                       mnstr_printf(out, " (%s)",
+                                    MONETDB_RELEASE);
+               else if (strcmp(rev, "Unknown") != 0)
+                       mnstr_printf(out, " (hg id: %s)", rev);
+               mnstr_printf(out, " %s %s%s\n",
                             describe ? "describe" : "dump",
                             functions ? "functions" : table ? "table " : 
"database",
-                            table ? table : "", buf);
-               dump_version(mid, out, "--");
+                            table ? table : "");
+               dump_version(mid, out, "-- server:");
+               mnstr_printf(out, "-- %s\n", buf);
        }
        if (functions)
                c = dump_functions(mid, out, true, NULL, NULL, NULL);
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -641,6 +641,8 @@ GDKinit(opt *set, int setlen)
                if (GDKsetenv("monet_pid", buf) != GDK_SUCCEED)
                        GDKfatal("GDKinit: GDKsetenv failed");
        }
+       if (GDKsetenv("revision", mercurial_revision()) != GDK_SUCCEED)
+               GDKfatal("GDKinit: GDKsetenv failed");
 
        return 1;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to