Changeset: b76485964725 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b76485964725
Modified Files:
gdk/gdk_tracer.c
monetdb5/tools/Tests/mserver5--help.stable.err
monetdb5/tools/Tests/mserver5--help.stable.err.Windows
tools/mserver/mserver5.1.in
tools/mserver/mserver5.c
Branch: Jun2020
Log Message:
Changed --dbtrace option to refer to a file to be used (instead of directory).
Also, documented the option in the manual.
diffs (138 lines):
diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -104,14 +104,24 @@ static gdk_return
const char *trace_path;
trace_path = GDKgetenv("gdk_dbtrace");
- if (trace_path == NULL)
+ if (trace_path == NULL) {
trace_path = GDKgetenv("gdk_dbpath");
- if (trace_path == NULL) {
- active_tracer = stderr;
- return GDK_SUCCEED;
+ if (trace_path == NULL) {
+ active_tracer = stderr;
+ return GDK_SUCCEED;
+ }
+ if (strconcat_len(file_name, sizeof(file_name),
+ trace_path, DIR_SEP_STR, FILE_NAME, NULL)
+ >= sizeof(file_name)) {
+ goto too_long;
+ }
+ } else {
+ if (strcpy_len(file_name, trace_path, sizeof(file_name))
+ >= sizeof(file_name)) {
+ goto too_long;
+ }
}
- snprintf(file_name, sizeof(file_name), "%s%c%s", trace_path, DIR_SEP,
FILE_NAME);
active_tracer = fopen(file_name, "a");
if (active_tracer == NULL) {
@@ -122,6 +132,12 @@ static gdk_return
}
return GDK_SUCCEED;
+
+ too_long:
+ GDK_TRACER_EXCEPTION("path name for dbtrace file too long");
+ file_name[0] = 0; /* uninitialize */
+ active_tracer = stderr;
+ return GDK_FAIL;
}
diff --git a/monetdb5/tools/Tests/mserver5--help.stable.err
b/monetdb5/tools/Tests/mserver5--help.stable.err
--- a/monetdb5/tools/Tests/mserver5--help.stable.err
+++ b/monetdb5/tools/Tests/mserver5--help.stable.err
@@ -13,7 +13,7 @@ stderr of test 'mserver5--help` in direc
Usage: mserver5 [options]
--dbpath=<directory> Specify database location
--dbextra=<directory> Directory for transient BATs
- --dbtrace=<directory> Directory for produced traces
+ --dbtrace=<file> File for produced traces
--in-memory Run database in-memory only
--config=<config_file> Use config_file to read options from
--single-user Allow only one user at a time
diff --git a/monetdb5/tools/Tests/mserver5--help.stable.err.Windows
b/monetdb5/tools/Tests/mserver5--help.stable.err.Windows
--- a/monetdb5/tools/Tests/mserver5--help.stable.err.Windows
+++ b/monetdb5/tools/Tests/mserver5--help.stable.err.Windows
@@ -8,7 +8,7 @@ stderr of test 'mserver5--help` in direc
Usage: mserver5.exe [options]
--dbpath=<directory> Specify database location
--dbextra=<directory> Directory for transient BATs
- --dbtrace=<directory> Directory for produced traces
+ --dbtrace=<file> File for produced traces
--in-memory Run database in-memory only
--config=<config_file> Use config_file to read options from
--single-user Allow only one user at a time
diff --git a/tools/mserver/mserver5.1.in b/tools/mserver/mserver5.1.in
--- a/tools/mserver/mserver5.1.in
+++ b/tools/mserver/mserver5.1.in
@@ -70,6 +70,16 @@ value of the
.B \-\-dbpath
option.
.TP
+\fB\-\-dbtrace=\fP\fIpath\fP
+File name for the trace log file for
+.IR mserver5 .
+Default value is the
+file
+.B mdbtrace.log
+inside the directory specified with the
+.B \-\-dbpath
+option.
+.TP
\fB\-\-config=\fP\fIfile\fP
Config file to read options from.
This file can contain all options as can be set with the --set flag.
diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c
--- a/tools/mserver/mserver5.c
+++ b/tools/mserver/mserver5.c
@@ -89,7 +89,7 @@ usage(char *prog, int xit)
fprintf(stderr, "Usage: %s [options]\n", prog);
fprintf(stderr, " --dbpath=<directory> Specify database
location\n");
fprintf(stderr, " --dbextra=<directory> Directory for transient
BATs\n");
- fprintf(stderr, " --dbtrace=<directory> Directory for produced
traces\n");
+ fprintf(stderr, " --dbtrace=<file> File for produced
traces\n");
fprintf(stderr, " --in-memory Run database in-memory
only\n");
fprintf(stderr, " --config=<config_file> Use config_file to read
options from\n");
fprintf(stderr, " --single-user Allow only one user at a
time\n");
@@ -259,7 +259,6 @@ handler(int sig)
int
main(int argc, char **av)
{
- DIR *dirp;
char *prog = *av;
opt *set = NULL;
int grpdebug = 0, debug = 0, setlen = 0;
@@ -275,7 +274,7 @@ main(int argc, char **av)
{ "config", required_argument, NULL, 'c' },
{ "dbpath", required_argument, NULL, 0 },
{ "dbextra", required_argument, NULL, 0 },
- { "dbtrace", optional_argument, NULL, 0 },
+ { "dbtrace", required_argument, NULL, 0 },
{ "debug", optional_argument, NULL, 'd' },
{ "help", no_argument, NULL, '?' },
{ "version", no_argument, NULL, 0 },
@@ -519,18 +518,6 @@ main(int argc, char **av)
fprintf(stderr, "!ERROR: cannot create directory for
%s\n", dbtrace);
exit(1);
}
- /* create the actual dir for db-trace */
- if (mkdir(dbtrace, MONETDB_DIRMODE) < 0) {
- if (errno != EEXIST) {
- fprintf(stderr, "!ERROR: cannot create
directory for %s\n", dbtrace);
- exit(1);
- }
- if ((dirp = opendir(dbtrace)) == NULL) {
- fprintf(stderr, "!ERROR: cannot create
directory for %s\n", dbtrace);
- exit(1);
- }
- closedir(dirp);
- }
GDKfree(dbtrace);
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list