Changeset: 29e3e20eee99 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=29e3e20eee99
Modified Files:
clients/mapiclient/Tests/mclient--help.stable.err
clients/mapiclient/Tests/mclient--help.stable.err.Windows
clients/mapiclient/mclient.1
clients/mapiclient/mclient.c
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_listing.c
monetdb5/modules/mal/inspect.c
monetdb5/modules/mal/mdb.c
sql/backends/monet5/sql.c
sql/storage/bat/bat_storage.c
sql/storage/bat/bat_utils.c
Branch: default
Log Message:
Merged with Mar2018 branch.
diffs (truncated from 831 to 300 lines):
diff --git a/clients/mapiclient/Tests/mclient--help.stable.err
b/clients/mapiclient/Tests/mclient--help.stable.err
--- a/clients/mapiclient/Tests/mclient--help.stable.err
+++ b/clients/mapiclient/Tests/mclient--help.stable.err
@@ -22,7 +22,7 @@ Options are:
-f kind | --format=kind specify output format
{csv,tab,raw,sql,xml,trash}
-H | --history load/save cmdline history (default off)
-i | --interactive interpret `\' commands on stdin
- -t | --timer=format use time formatting
{clock,minutes,seconds,milliseconds,microseconds,none}
+ -t | --timer=format use time formatting {clock,performance,none}
-l language | --language=lang {sql,mal}
-L logfile | --log=logfile save client/server interaction
-s stmt | --statement=stmt run single statement
diff --git a/clients/mapiclient/Tests/mclient--help.stable.err.Windows
b/clients/mapiclient/Tests/mclient--help.stable.err.Windows
--- a/clients/mapiclient/Tests/mclient--help.stable.err.Windows
+++ b/clients/mapiclient/Tests/mclient--help.stable.err.Windows
@@ -22,7 +22,7 @@ Options are:
-f kind | --format=kind specify output format
{csv,tab,raw,sql,xml,trash}
-H | --history load/save cmdline history (default off)
-i | --interactive interpret `\' commands on stdin
- -t | --timer=format use time formatting
{clock,minutes,seconds,milliseconds,microseconds,none}
+ -t | --timer=format use time formatting {clock,performance,none}
-l language | --language=lang {sql,mal}
-L logfile | --log=logfile save client/server interaction
-s stmt | --statement=stmt run single statement
diff --git a/clients/mapiclient/mclient.1 b/clients/mapiclient/mclient.1
--- a/clients/mapiclient/mclient.1
+++ b/clients/mapiclient/mclient.1
@@ -148,17 +148,23 @@ these are supported.
Specify the portnumber of the server (default:
.BR 50000 ).
.TP
-\fB\-\-interactive\fP
+\fB\-\-interactive\fP (\fB\-i\fP)
When reading from standard input, interpret lines starting with
.B \e
(backslash) specially.
See the section BACKSLASH COMMANDS below.
-
-\fB\-\-timer\fP[\fB=\fP\fItimermode\fP]
+.TP
+\fB\-\-timer\fP\fB=\fP\fItimermode\fP (\fB\-t\fP \fItimermode\fP)
The \fItimer\fP command controls the format of the time reported for queries.
The default mode is \fBclock\fP which reports on the wall-clock time in a
human friendly way.
The timer mode \fBnone\fP turns off timing reporting.
The timer mode \fBperformance\fP shows the timing components in millisecond
resolution.
+.br
+\fBNote\fP that Timermode \fBnone\fP (\fB--timer=none\fP) should be used with
formatting options
+.B csv,
+.B tab,
+.B xml,
+in order to not have the output(-format) compromized/invalidated by the extra
timing output.
.TP
\fB\-\-user\fP\fB=\fP\fIuser\fP (\fB\-u\fP \fIuser\fP)
Specify the user to connect as.
@@ -197,6 +203,12 @@ In addition to plain \fBcsv\fP, two othe
\fBcsv=\fP\fIc\fP uses \fIc\fP as column separator; \fBcsv+\fP\fIc\fP
uses \fIc\fP as column separator and produces a single header line in
addition to the data.
+.br
+\fBNote\fP that Timermode \fBnone\fP (\fB--timer=none\fP) should be used with
formatting options
+.B csv,
+.B tab,
+.B xml,
+in order to not have the output(-format) compromized/invalidated by the extra
timing output.
.TP
\fB\-\-echo\fP (\fB\-e\fP)
Echo the query.
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1696,7 +1696,7 @@ setFormatter(const char *s)
} else
separator = strdup(s + 4);
csvheader = 1;
- } else if (strcmp(s, "tsv") == 0) {
+ } else if (strcmp(s, "tab") == 0) {
formatter = CSVformatter;
separator = strdup("\t");
} else if (strcmp(s, "raw") == 0) {
@@ -2164,7 +2164,7 @@ showCommands(void)
mnstr_printf(toConsole, "\\a - disable auto commit\n");
}
mnstr_printf(toConsole, "\\e - echo the query in sql formatting
mode\n");
- mnstr_printf(toConsole, "\\t - set the timer
{clock,minutes,seconds,milliseconds,microseconds,none}\n");
+ mnstr_printf(toConsole, "\\t - set the timer
{clock,performance,none}\n");
mnstr_printf(toConsole, "\\f - format using a built-in renderer
{csv,tab,raw,sql,xml,trash}\n");
mnstr_printf(toConsole, "\\w# - set maximal page width
(-1=unlimited, 0=terminal width, >0=limit to num)\n");
mnstr_printf(toConsole, "\\r# - set maximum rows per page
(-1=raw)\n");
@@ -2950,7 +2950,7 @@ usage(const char *prog, int xit)
fprintf(stderr, " -f kind | --format=kind specify output
format {csv,tab,raw,sql,xml,trash}\n");
fprintf(stderr, " -H | --history load/save cmdline
history (default off)\n");
fprintf(stderr, " -i | --interactive interpret `\\'
commands on stdin\n");
- fprintf(stderr, " -t | --timer=format use time formatting
{clock,minutes,seconds,milliseconds,microseconds,none}\n");
+ fprintf(stderr, " -t | --timer=format use time formatting
{clock,performance,none}\n");
fprintf(stderr, " -l language | --language=lang {sql,mal}\n");
fprintf(stderr, " -L logfile | --log=logfile save client/server
interaction\n");
fprintf(stderr, " -s stmt | --statement=stmt run single
statement\n");
@@ -3013,7 +3013,7 @@ main(int argc, char **argv)
{"history", 0, 0, 'H'},
{"host", 1, 0, 'h'},
{"interactive", 0, 0, 'i'},
- {"timer", 2, 0, 't'},
+ {"timer", 1, 0, 't'},
{"language", 1, 0, 'l'},
{"log", 1, 0, 'L'},
{"null", 1, 0, 'n'},
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -792,8 +792,12 @@ str runMALsequence(Client cntxt, MalBlkP
break;
}
w= instruction2str(mb, 0, pci, FALSE);
- ret = createException(MAL,"interpreter", "unkown
operation:%s", w);
- GDKfree(w);
+ if(w) {
+ ret = createException(MAL,"interpreter",
"unkown operation:%s", w);
+ GDKfree(w);
+ } else {
+ ret = createException(MAL,"interpreter",
"failed instruction2str");
+ }
if (cntxt->qtimeout && GDKusec()- mb->starttime >
cntxt->qtimeout){
ret= createException(MAL, "mal.interpreter",
RUNTIME_QRY_TIMEOUT);
break;
diff --git a/monetdb5/mal/mal_listing.c b/monetdb5/mal/mal_listing.c
--- a/monetdb5/mal/mal_listing.c
+++ b/monetdb5/mal/mal_listing.c
@@ -546,7 +546,7 @@ str
mal2str(MalBlkPtr mb, int first, int last)
{
str ps = NULL, *txt;
- int i, *len, totlen = 0;
+ int i, *len, totlen = 0, j;
txt = GDKmalloc(sizeof(str) * mb->stop);
len = GDKmalloc(sizeof(int) * mb->stop);
@@ -568,11 +568,21 @@ mal2str(MalBlkPtr mb, int first, int las
if ( txt[i])
totlen += len[i] = (int)strlen(txt[i]);
+ else {
+ addMalException(mb,"mal2str: " MAL_MALLOC_FAIL);
+ GDKfree(len);
+ for (j = first; j < i; j++)
+ GDKfree(txt[j]);
+ GDKfree(txt);
+ return NULL;
+ }
}
ps = GDKmalloc(totlen + mb->stop + 1);
if( ps == NULL){
addMalException(mb,"mal2str: " MAL_MALLOC_FAIL);
GDKfree(len);
+ for (i = first; i < last; i++)
+ GDKfree(txt[i]);
GDKfree(txt);
return NULL;
}
@@ -604,6 +614,8 @@ printInstruction(stream *fd, MalBlkPtr m
if ( ps ){
mnstr_printf(fd, "%s%s", (flg & LIST_MAL_MAPI ? "=" : ""), ps);
GDKfree(ps);
+ } else {
+ mnstr_printf(fd,"#failed instruction2str()");
}
mnstr_printf(fd, "\n");
}
@@ -620,6 +632,8 @@ fprintInstruction(FILE *fd, MalBlkPtr mb
if ( ps ){
fprintf(fd, "%s%s", (flg & LIST_MAL_MAPI ? "=" : ""), ps);
GDKfree(ps);
+ } else {
+ fprintf(fd,"#failed instruction2str()");
}
fprintf(fd, "\n");
}
@@ -660,6 +674,8 @@ void showMalBlkHistory(stream *out, MalB
mnstr_printf(out,"%s.%s[%2d] %s\n",
getModuleId(sig),
getFunctionId(sig),j++,msg+3);
GDKfree(msg);
+ } else {
+ mnstr_printf(out,"#failed instruction2str()\n");
}
}
m= m->history;
diff --git a/monetdb5/modules/mal/inspect.c b/monetdb5/modules/mal/inspect.c
--- a/monetdb5/modules/mal/inspect.c
+++ b/monetdb5/modules/mal/inspect.c
@@ -280,7 +280,8 @@ INSPECTgetDefinition(Client cntxt, MalBl
str ps;
for (i = 0; i < s->def->stop; i++) {
- ps = instruction2str(s->def,0, getInstrPtr(s->def, i),
0);
+ if((ps = instruction2str(s->def,0, getInstrPtr(s->def,
i), 0)) == NULL)
+ goto bailout;
if (BUNappend(b, ps + 1, FALSE) != GDK_SUCCEED) {
GDKfree(ps);
goto bailout;
@@ -321,6 +322,9 @@ INSPECTgetSignature(Client cntxt, MalBlk
char *c, *w;
ps = instruction2str(s->def, 0, getSignature(s), 0);
+ if (ps == 0) {
+ continue;
+ }
c = strchr(ps, '(');
if (c == 0) {
GDKfree(ps);
@@ -461,7 +465,10 @@ INSPECTgetSource(Client cntxt, MalBlkPtr
str ps;
for (i = 0; i < s->def->stop; i++) {
- ps = instruction2str(s->def, 0, getInstrPtr(s->def, i),
LIST_MAL_NAME );
+ if((ps = instruction2str(s->def, 0, getInstrPtr(s->def,
i), LIST_MAL_NAME )) == NULL) {
+ GDKfree(buf);
+ throw(MAL, "inspect.getSource", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
+ }
if( strlen(ps) >= lim-len){
/* expand the buffer */
char *bn;
diff --git a/monetdb5/modules/mal/mdb.c b/monetdb5/modules/mal/mdb.c
--- a/monetdb5/modules/mal/mdb.c
+++ b/monetdb5/modules/mal/mdb.c
@@ -399,6 +399,7 @@ MDBStkTrace(Client cntxt, MalBlkPtr m, M
(void) cntxt;
if ((msg = instruction2str(s->blk, s, p, LIST_MAL_DEBUG)) == NULL) {
BBPreclaim(b);
+ BBPreclaim(bn);
throw(MAL, "mdb.getStackTrace", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
}
len = strlen(msg);
@@ -406,6 +407,7 @@ MDBStkTrace(Client cntxt, MalBlkPtr m, M
if ( buf == NULL){
GDKfree(msg);
BBPreclaim(b);
+ BBPreclaim(bn);
throw(MAL,"mdb.setTrace", SQLSTATE(HY001) MAL_MALLOC_FAIL);
}
snprintf(buf,len+1024,"%s at %s.%s[%d]", msg,
@@ -416,12 +418,17 @@ MDBStkTrace(Client cntxt, MalBlkPtr m, M
GDKfree(msg);
GDKfree(buf);
BBPreclaim(b);
+ BBPreclaim(bn);
throw(MAL,"mdb.setTrace", SQLSTATE(HY001) MAL_MALLOC_FAIL);
}
GDKfree(msg);
for (s = s->up, k++; s != NULL; s = s->up, k++) {
- msg = instruction2str(s->blk, s,
getInstrPtr(s->blk,s->pcup),LIST_MAL_DEBUG);
+ if ((msg = instruction2str(s->blk, s,
getInstrPtr(s->blk,s->pcup),LIST_MAL_DEBUG)) == NULL){
+ BBPunfix(b->batCacheid);
+ BBPunfix(bn->batCacheid);
+ throw(MAL,"mdb.setTrace", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
+ }
l = strlen(msg);
if (l>len){
GDKfree(buf);
@@ -562,7 +569,10 @@ MDBgetDefinition(Client cntxt, MalBlkPtr
throw(MAL, "mdb.getDefinition", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
for (i = 0; i < m->stop; i++) {
- ps = instruction2str(m,0, getInstrPtr(m, i), 1);
+ if((ps = instruction2str(m,0, getInstrPtr(m, i), 1)) == NULL) {
+ BBPreclaim(b);
+ throw(MAL, "mdb.getDefinition", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
+ }
if (BUNappend(b, ps, FALSE) != GDK_SUCCEED) {
GDKfree(ps);
BBPreclaim(b);
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -1430,7 +1430,11 @@ DELTAbat(bat *result, const bat *col, co
BBPunfix(res->batCacheid);
throw(MAL, "sql.delta", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
}
- u_id = BATdescriptor(*uid);
+ if ((u_id = BATdescriptor(*uid)) == NULL) {
+ BBPunfix(u_val->batCacheid);
+ BBPunfix(res->batCacheid);
+ throw(MAL, "sql.delta", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
+ }
assert(BATcount(u_id) == BATcount(u_val));
if (BATcount(u_id) &&
BATreplace(res, u_id, u_val, TRUE) != GDK_SUCCEED) {
@@ -1443,7 +1447,10 @@ DELTAbat(bat *result, const bat *col, co
BBPunfix(u_val->batCacheid);
if (i && BATcount(i)) {
- i = BATdescriptor(*ins);
+ if ((i = BATdescriptor(*ins)) == NULL) {
+ BBPunfix(res->batCacheid);
+ throw(MAL, "sql.delta", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
+ }
if (BATappend(res, i, NULL, TRUE) != GDK_SUCCEED) {
BBPunfix(res->batCacheid);
BBPunfix(i->batCacheid);
@@ -2855,7 +2862,10 @@ zero_or_one(ptr ret, const bat *bid)
memcpy(*(ptr *) ret, p, _s);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list