Changeset: f03ca4748e7d for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f03ca4748e7d Modified Files: Branch: default Log Message:
Merged from Dec2011 diffs (193 lines): diff --git a/tools/merovingian/ChangeLog.Dec2011 b/tools/merovingian/ChangeLog.Dec2011 --- a/tools/merovingian/ChangeLog.Dec2011 +++ b/tools/merovingian/ChangeLog.Dec2011 @@ -1,6 +1,10 @@ # ChangeLog file for sql/src/backends/monet5/merovingian # This file is updated with mchangelog +* Tue Dec 27 2011 Fabian Groffen <[email protected]> +- Fixed crash in monetdb when an invalid property was retrieved using + the get command, bug #2953. + * Sat Oct 8 2011 Fabian Groffen <[email protected]> - monetdb get output is now grouped by database instead of by property diff --git a/tools/merovingian/client/monetdb.c b/tools/merovingian/client/monetdb.c --- a/tools/merovingian/client/monetdb.c +++ b/tools/merovingian/client/monetdb.c @@ -86,10 +86,12 @@ command_help(int argc, char *argv[]) printf(" -P pass password to use to login at remote merovingian\n"); printf(" use the help command to get help for a particular command\n"); } else if (strcmp(argv[1], "create") == 0) { - printf("Usage: monetdb create database [database ...]\n"); - printf(" Initialises a new database in the MonetDB Server. A\n"); + printf("Usage: monetdb create [-m pattern] database [database ...]\n"); + printf(" Initialises a new database or multiplexfunnel in the MonetDB Server. A\n"); printf(" database created with this command makes it available\n"); printf(" for use, however in maintenance mode (see monetdb lock).\n"); + printf("Options:\n"); + printf(" -m create a multiplex funnel for pattern.\n"); } else if (strcmp(argv[1], "destroy") == 0) { printf("Usage: monetdb destroy [-f] database [database ...]\n"); printf(" Removes the given database, including all its data and\n"); @@ -1180,7 +1182,7 @@ command_get(int argc, char *argv[]) orig = stats; } - /* suppress header when there are no results */ + /* avoid work when there are no results */ if (orig == NULL) { free(props); return; @@ -1207,7 +1209,6 @@ command_get(int argc, char *argv[]) if (twidth < 6) twidth = 6; value = malloc(sizeof(char) * twidth + 1); - printf(" name prop source value\n"); stats = orig; while (stats != NULL) { e = control_send(&buf, mero_host, mero_port, @@ -1225,42 +1226,61 @@ command_get(int argc, char *argv[]) free(buf); if (propall == 1) { - kv = findConfKey(props, "type"); - if (kv != NULL && kv->val != NULL && - strcmp(kv->val, "mfunnel") == 0) - { - snprintf(vbuf, sizeof(vbuf), "name,type,mfunnel,shared"); - } else { - size_t off = 0; - kv = props; - off += snprintf(vbuf, sizeof(vbuf), "name"); - while (kv->key != NULL) { - if (strcmp(kv->key, "mfunnel") != 0 && - strcmp(kv->key, "type") != 0) - off += snprintf(vbuf + off, sizeof(vbuf) - off, - ",%s", kv->key); - kv++; + size_t off = 0; + kv = props; + off += snprintf(vbuf, sizeof(vbuf), "name"); + while (kv->key != NULL) { + off += snprintf(vbuf + off, sizeof(vbuf) - off, + ",%s", kv->key); + kv++; + } + } else { + /* check validity of properties before printing them */ + if (stats == orig) { + snprintf(vbuf, sizeof(vbuf), "%s", property); + buf = vbuf; + while ((p = strtok(buf, ",")) != NULL) { + buf = NULL; + if (strcmp(p, "name") == 0) + continue; + kv = findConfKey(props, p); + if (kv == NULL) + fprintf(stderr, "get: no such property: %s\n", p); } } - } else { snprintf(vbuf, sizeof(vbuf), "%s", property); } buf = vbuf; + /* print header after errors */ + if (stats == orig) + printf(" name prop source value\n"); while ((p = strtok(buf, ",")) != NULL) { buf = NULL; + /* filter properties based on object type */ + kv = findConfKey(props, "type"); + if (kv != NULL && kv->val != NULL) { + if (strcmp(kv->val, "mfunnel") == 0) { + if (strcmp(p, "name") != 0 && + strcmp(p, "type") != 0 && + strcmp(p, "mfunnel") != 0 && + strcmp(p, "shared") != 0) + continue; + } + } else { /* no type == database (default) */ + if (strcmp(p, "mfunnel") == 0) + continue; + } + /* special virtual case */ if (strcmp(p, "name") == 0) { source = "-"; abbreviateString(value, stats->dbname, twidth); } else { kv = findConfKey(props, p); - if (kv == NULL) { - fprintf(stderr, "get: no such property: %s\n", p); - stats = NULL; + if (kv == NULL) continue; - } if (kv->val == NULL) { kv = findConfKey(defprops, p); source = "default"; diff --git a/tools/merovingian/daemon/forkmserver.c b/tools/merovingian/daemon/forkmserver.c --- a/tools/merovingian/daemon/forkmserver.c +++ b/tools/merovingian/daemon/forkmserver.c @@ -224,6 +224,8 @@ forkMserver(char *database, sabdb** stat mydoproxy = strcmp(getConfVal(_mero_props, "forward"), "proxy") == 0; kv = findConfKey(ckv, "nthreads"); + if (kv->val == NULL) + kv = findConfKey(_mero_db_props, "nthreads"); if (kv->val != NULL) { snprintf(nthreads, sizeof(nthreads), "gdk_nr_threads=%s", kv->val); } else { @@ -240,6 +242,8 @@ forkMserver(char *database, sabdb** stat } kv = findConfKey(ckv, "optpipe"); + if (kv->val == NULL) + kv = findConfKey(_mero_db_props, "optpipe"); if (kv->val != NULL) { snprintf(pipeline, sizeof(pipeline), "sql_optimizer=%s", kv->val); } else { diff --git a/tools/merovingian/daemon/merovingian.c b/tools/merovingian/daemon/merovingian.c --- a/tools/merovingian/daemon/merovingian.c +++ b/tools/merovingian/daemon/merovingian.c @@ -628,6 +628,37 @@ main(int argc, char *argv[]) kv->val = strdup("64"); kv = findConfKey(_mero_db_props, "type"); kv->val = strdup("database"); + kv = findConfKey(_mero_db_props, "optpipe"); + kv->val = strdup("default_pipe"); + { /* nrthreads */ + int ncpus = -1; + char cnt[8]; + +#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) + /* this works on Linux, Solaris and AIX */ + ncpus = sysconf(_SC_NPROCESSORS_ONLN); +#elif defined(HAVE_SYS_SYSCTL_H) && defined(HW_NCPU) /* BSD */ + size_t len = sizeof(int); + int mib[3]; + + /* Everyone should have permission to make this call, + * if we get a failure something is really wrong. */ + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + mib[2] = -1; + sysctl(mib, 3, &ncpus, &len, NULL, 0); +#elif defined(WIN32) + SYSTEM_INFO sysinfo; + + GetSystemInfo(&sysinfo); + ncpus = sysinfo.dwNumberOfProcessors; +#endif + if (ncpus > 0) { + snprintf(cnt, sizeof(cnt), "%d", ncpus); + kv = findConfKey(_mero_db_props, "nthreads"); + kv->val = strdup(cnt); + } + } *dbfarm = '\0'; if (argc > 1) { _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
