Changeset: 268bcf8991e9 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=268bcf8991e9
Modified Files:
clients/mapiclient/ReadlineTools.c
clients/mapiclient/dump.c
clients/mapiclient/mclient.c
clients/mapiclient/tomograph.c
clients/odbc/driver/ODBCConvert.c
clients/odbc/driver/ODBCUtil.c
common/utils/mcrypt.c
common/utils/msabaoth.c
common/utils/mutils.c
common/utils/mutils.h
gdk/gdk_bat.c
gdk/gdk_bbp.c
gdk/gdk_heap.c
gdk/gdk_join.c
gdk/gdk_logger.c
gdk/gdk_posix.c
gdk/gdk_search.c
monetdb5/mal/mal_debugger.c
monetdb5/mal/mal_function.c
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_linker.c
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_recycle.c
monetdb5/mal/mal_runtime.c
monetdb5/modules/atoms/mcurl.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/xml.c
monetdb5/modules/kernel/aggr.c
monetdb5/modules/mal/batExtensions.c
monetdb5/modules/mal/cluster.c
monetdb5/modules/mal/groupby.c
monetdb5/modules/mal/language.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/mat.c
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/tablet.c
monetdb5/optimizer/opt_pushselect.c
monetdb5/optimizer/opt_querylog.c
monetdb5/optimizer/opt_statistics.c
monetdb5/optimizer/opt_wrapper.c
monetdb5/scheduler/srvpool.c
sql/backends/monet5/sql_scenario.c
sql/common/sql_list.c
sql/common/sql_types.c
sql/server/rel_select.c
sql/server/sql_mvc.c
tools/mserver/monet_version.c.in
tools/mserver/mserver5.c
Branch: default
Log Message:
Merge with Jan2014 branch.
diffs (truncated from 2281 to 300 lines):
diff --git a/clients/mapiclient/ReadlineTools.c
b/clients/mapiclient/ReadlineTools.c
--- a/clients/mapiclient/ReadlineTools.c
+++ b/clients/mapiclient/ReadlineTools.c
@@ -160,50 +160,6 @@ sql_completion(const char *text, int sta
return (matches);
}
-static char *
-mil_batname_generator(const char *text, int state)
-{
-
- static int seekpos, len, rowcount;
- static MapiHdl table_hdl;
- char *name;
-
- if (!state) {
- seekpos = 0;
- len = strlen(text);
- if ((table_hdl = mapi_query(_mid, "ls();")) == NULL ||
mapi_error(_mid)) {
- if (table_hdl) {
- mapi_explain_query(table_hdl, stderr);
- mapi_close_handle(table_hdl);
- } else
- mapi_explain(_mid, stderr);
- return NULL;
- }
- mapi_fetch_all_rows(table_hdl);
- rowcount = mapi_get_row_count(table_hdl);
- }
-
- while (seekpos < rowcount) {
- mapi_seek_row(table_hdl, seekpos++, MAPI_SEEK_SET);
- mapi_fetch_row(table_hdl);
- name = mapi_fetch_field(table_hdl, 0);
- if (strncmp(name, text, len) == 0)
- return strdup(name);
- }
-
- return NULL;
-}
-
-static char **
-mil_completion(const char *text, int start, int end)
-{
- (void) start;
- (void) end;
-
- /* FIXME: Nice, context-sensitive completion strategy should go here */
- return rl_completion_matches(text, mil_batname_generator);
-}
-
/* The MAL completion help */
static char *mal_commands[] = {
@@ -256,8 +212,9 @@ mal_help(int cnt, int key)
printf("\n");
while (seekpos < rowcount) {
- mapi_seek_row(table_hdl, seekpos++, MAPI_SEEK_SET);
- mapi_fetch_row(table_hdl);
+ if (mapi_seek_row(table_hdl, seekpos++, MAPI_SEEK_SET) != MOK ||
+ mapi_fetch_row(table_hdl) <= 0)
+ continue;
name = mapi_fetch_field(table_hdl, 0);
if (name)
printf("%s\n", name);
@@ -323,8 +280,9 @@ mal_command_generator(const char *text,
}
while (seekpos < rowcount) {
- mapi_seek_row(table_hdl, seekpos++, MAPI_SEEK_SET);
- mapi_fetch_row(table_hdl);
+ if (mapi_seek_row(table_hdl, seekpos++, MAPI_SEEK_SET) != MOK ||
+ mapi_fetch_row(table_hdl) <= 0)
+ continue;
name = mapi_fetch_field(table_hdl, 0);
if (name)
return strdup(name);
@@ -370,8 +328,6 @@ init_readline(Mapi mid, char *lang, int
* before std completion (filename) kicks in. */
if (strcmp(language, "sql") == 0) {
rl_attempted_completion_function = sql_completion;
- } else if (strcmp(language, "mil") == 0) {
- rl_attempted_completion_function = mil_completion;
} else if (strcmp(language, "mal") == 0) {
/* recognize the help function, should react to <FCN2> */
#ifdef illegal_ESC_binding
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1136,6 +1136,8 @@ dump_table_data(Mapi mid, char *schema,
goto bailout;
cnt = mapi_get_field_count(hdl);
+ if (cnt < 1 || cnt >= 1 << 29)
+ goto bailout; /* ridiculous number of columns */
string = malloc(sizeof(int) * cnt);
for (i = 0; i < cnt; i++) {
string[i] = 0;
@@ -1831,6 +1833,8 @@ dump_database(Mapi mid, stream *toConsol
return rc;
bailout:
+ if( curschema )
+ free(curschema);
if (hdl) {
if (mapi_result_error(hdl))
mapi_explain_result(hdl, stderr);
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -668,8 +668,7 @@ CSVrenderer(MapiHdl hdl)
s = mapi_get_name(hdl, i);
if (s == NULL)
s = "";
- mnstr_printf(toConsole, "%s%s",
- i == 0 ? "" : sep, s ? s : "");
+ mnstr_printf(toConsole, "%s%s", i == 0 ? "" : sep, s);
}
mnstr_printf(toConsole, "\n");
}
@@ -1540,6 +1539,7 @@ format_result(Mapi mid, MapiHdl hdl, cha
"execute prepared statement "
"using: EXEC %d(...)\n",
mapi_get_tableid(hdl));
+ /* fall through */
case Q_TABLE:
timerHumanStop();
break;
@@ -1643,7 +1643,7 @@ doRequest(Mapi mid, const char *buf)
return 0;
}
-#define CHECK_RESULT(mid, hdl, buf, break_or_continue,freebuf)
\
+#define CHECK_RESULT(mid, hdl, buf, break_or_continue, freebuf)
\
switch (mapi_error(mid)) { \
case MOK: \
/* everything A OK */ \
@@ -1678,7 +1678,8 @@ doRequest(Mapi mid, const char *buf)
mapi_explain(mid, stderr); \
errseen = 1; \
timerEnd(); \
- if( freebuf) free(freebuf);
\
+ if (freebuf) \
+ free(freebuf); \
return 1; \
}
diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -618,7 +618,7 @@ fixed_colors[] = {
};
/* initial mod.fcn list for adaptive colormap */
Color
-base_colors[] = {
+base_colors[NUM_COLORS] = {
/* reserve (base_)colors[0] for generic "*.*" */
/* 99999 */ { 0, 0, "*", "*", 0 },
/* arbitrarily ordered by descending frequency in TPCH SF-100 with 32 threads
*/
@@ -832,6 +832,10 @@ dumpboxes(void)
snprintf(buf, BUFSIZ, "%s_cpu.dat", filename);
fcpu = fopen(buf, "w");
}
+ if( fcpu == NULL){
+ fprintf(stderr,"Can not create/open the trace file\n");
+ return;
+ }
for (i = 0; i < topbox; i++)
if (box[i].clkend && box[i].fcn) {
@@ -1414,7 +1418,8 @@ static void createTomogram(void)
printf("ERROR in creation of %s\n", buf);
exit(-1);
}
- *strchr(buf, '.') = 0;
+ if( strchr(buf,'.'))
+ *strchr(buf, '.') = 0;
gnuplotheader(buf);
dumpboxes();
showio();
@@ -1739,7 +1744,7 @@ static int
parser(char *row)
{
#ifdef HAVE_STRPTIME
- char *c, *cc;
+ char *c, *cc, *v;
struct tm stm;
lng clkticks = 0;
int thread = 0;
@@ -1855,13 +1860,13 @@ parser(char *row)
} else {
fcn = strchr(fcn, '"');
if (fcn) {
- fcn++;
- *strchr(fcn, '"') = 0;
+ v= strchr(fcn+1,'"');
+ if ( v ) *v = 0;
}
}
- if (fcn && strchr(fcn, '('))
- *strchr(fcn, '(') = 0;
+ if (fcn && (v=strchr(fcn, '(')))
+ *v = 0;
#ifdef FOOTPRINT
wrapup:
diff --git a/clients/odbc/driver/ODBCConvert.c
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -2871,6 +2871,7 @@ ODBCStore(ODBCStmt *stmt,
case SQL_C_WCHAR:
slen = strlen_or_ind_ptr ? *strlen_or_ind_ptr : SQL_NTS;
fixWcharIn((SQLWCHAR *) ptr, slen, char, sval, addStmtError,
stmt, return SQL_ERROR);
+ slen = strlen(sval);
break;
case SQL_C_BIT:
nval.precision = 1;
@@ -3103,7 +3104,9 @@ ODBCStore(ODBCStmt *stmt,
for (i = 0; i < slen; i++) {
unsigned char c = (unsigned char) sval[i];
- if (c < 0x20 /* || c >= 0x7F */) {
+ if (c == 0) {
+ break;
+ } else if (c < 0x20 /* || c >= 0x7F */) {
assign(buf, bufpos, buflen, '\\', stmt);
assign(buf, bufpos, buflen, '0' + (c >>
6), stmt);
assign(buf, bufpos, buflen, '0' + ((c
>> 3) & 0x7), stmt);
diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -124,7 +124,7 @@ ODBCwchar2utf8(const SQLWCHAR *s, SQLLEN
e = s + length;
/* count necessary length */
l = 1; /* space for NULL byte */
- for (s1 = s; s1 < e; s1++) {
+ for (s1 = s; s1 < e && *s1; s1++) {
c = *s1;
if (0xD800 <= c && c <= 0xDBFF) {
/* high surrogate, must be followed by low surrogate */
@@ -159,7 +159,7 @@ ODBCwchar2utf8(const SQLWCHAR *s, SQLLEN
*errmsg = "Memory allocation error";
return NULL;
}
- for (s1 = s, p = buf; s1 < e; s1++) {
+ for (s1 = s, p = buf; s1 < e && *s1; s1++) {
c = *s1;
if (0xD800 <= c && c <= 0xDBFF) {
/* high surrogate followed by low surrogate */
diff --git a/common/utils/mcrypt.c b/common/utils/mcrypt.c
--- a/common/utils/mcrypt.c
+++ b/common/utils/mcrypt.c
@@ -250,18 +250,25 @@ mcrypt_RIPEMD160Sum(const char *string,
char *
mcrypt_BackendSum(const char *string, size_t len)
{
+ /* coverity[pointless_string_compare] */
if (strcmp(MONETDB5_PASSWDHASH, "RIPEMD160") == 0)
return mcrypt_RIPEMD160Sum(string, len);
+ /* coverity[pointless_string_compare] */
if (strcmp(MONETDB5_PASSWDHASH, "SHA512") == 0)
return mcrypt_SHA512Sum(string, len);
+ /* coverity[pointless_string_compare] */
if (strcmp(MONETDB5_PASSWDHASH, "SHA384") == 0)
return mcrypt_SHA384Sum(string, len);
+ /* coverity[pointless_string_compare] */
if (strcmp(MONETDB5_PASSWDHASH, "SHA256") == 0)
return mcrypt_SHA256Sum(string, len);
+ /* coverity[pointless_string_compare] */
if (strcmp(MONETDB5_PASSWDHASH, "SHA224") == 0)
return mcrypt_SHA224Sum(string, len);
+ /* coverity[pointless_string_compare] */
if (strcmp(MONETDB5_PASSWDHASH, "SHA1") == 0)
return mcrypt_SHA1Sum(string, len);
+ /* coverity[pointless_string_compare] */
if (strcmp(MONETDB5_PASSWDHASH, "MD5") == 0)
return mcrypt_MD5Sum(string, len);
assert(0); /* should never get reached, backend would be unsupported */
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -292,15 +292,17 @@ msab_retreatScenario(const char *lang)
unlink(path);
return(NULL);
}
- } else if (len == 0) {
+ } else {
+ if (ferror(f)) {
+ /* some error */
+ snprintf(buf, sizeof(buf), "failed to write: %s
(%s)",
+ strerror(errno), path);
+ (void)fclose(f);
+ return strdup(buf);
+ } else
+ unlink(path); /* empty file? try to remove */
(void)fclose(f);
- unlink(path); /* empty file? try to remove */
return(NULL);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list