Changeset: 4961237f0348 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4961237f0348
Modified Files:
clients/Tests/exports.stable.out
clients/mapiclient/ReadlineTools.c
clients/mapiclient/dotmonetdb.c
common/options/monet_options.c
gdk/gdk_bbp.c
gdk/gdk_hash.c
gdk/gdk_imprints.c
gdk/gdk_logger.c
gdk/gdk_orderidx.c
gdk/gdk_storage.c
gdk/gdk_system.c
gdk/gdk_system.h
gdk/gdk_utils.c
monetdb5/extras/rapi/rapi.c
monetdb5/mal/mal_client.c
monetdb5/mal/mal_client.h
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_exception.c
monetdb5/mal/mal_linker.c
monetdb5/mal/mal_profiler.c
monetdb5/modules/mal/bbp.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/tokenizer.c
monetdb5/modules/mal/wlc.c
monetdb5/tools/Tests/mserver5--help.stable.err
monetdb5/tools/Tests/mserver5--help.stable.err.Windows
sql/backends/monet5/UDF/pyapi/pyapi.c
sql/backends/monet5/vaults/bam/bam_loader.c
sql/backends/monet5/wlr.c
tools/mserver/mserver5.1.in
tools/mserver/mserver5.c
tools/mserver/shutdowntest.c
Branch: default
Log Message:
Merge with Apr2019 branch.
diffs (truncated from 1575 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -277,8 +277,10 @@ void GDKregister(MT_Id pid);
gdk_return GDKreleasemmap(void *ptr, size_t size, size_t id);
gdk_return GDKreleasesem(int sem_id);
void GDKreset(int status);
+void GDKsetdebug(int debug);
gdk_return GDKsetenv(const char *name, const char *value);
void GDKsetmallocsuccesscount(lng count);
+void GDKsetverbose(int verbosity);
ssize_t GDKstrFromStr(unsigned char *restrict dst, const unsigned char
*restrict src, ssize_t len);
str GDKstrdup(const char *s) __attribute__((__warn_unused_result__));
str GDKstrndup(const char *s, size_t n)
__attribute__((__warn_unused_result__));
@@ -286,6 +288,7 @@ void GDKsyserror(_In_z_ _Printf_format_s
size_t GDKuniqueid(size_t offset);
gdk_return GDKupgradevarheap(BAT *b, var_t v, bool copyall, bool mayshare)
__attribute__((__warn_unused_result__));
lng GDKusec(void);
+int GDKverbose;
const char *GDKversion(void);
size_t GDKvm_cursize(void);
void *GDKzalloc(size_t size) __attribute__((__malloc__))
__attribute__((__alloc_size__(1))) __attribute__((__warn_unused_result__));
@@ -301,7 +304,7 @@ size_t HEAPvmsize(Heap *h);
void IMPSdestroy(BAT *b);
lng IMPSimprintsize(BAT *b);
int MT_check_nr_cores(void);
-int MT_create_thread(MT_Id *t, void (*function)(void *), void *arg, enum
MT_thr_detach d);
+int MT_create_thread(MT_Id *t, void (*function)(void *), void *arg, enum
MT_thr_detach d, const char *threadname);
void MT_exiting_thread(void);
MT_Id MT_getpid(void);
size_t MT_getrss(void);
@@ -312,6 +315,9 @@ void *MT_mmap(const char *path, int mode
int MT_munmap(void *p, size_t len);
bool MT_path_absolute(const char *path);
void MT_sleep_ms(unsigned int ms);
+bool MT_thread_init(void);
+const char *MT_thread_name(void);
+void MT_thread_setname(const char *name);
void OIDXdestroy(BAT *b);
ssize_t OIDfromStr(const char *src, size_t *len, oid **dst, bool external);
ssize_t OIDtoStr(str *dst, size_t *len, const oid *src, bool external);
diff --git a/clients/mapiclient/ReadlineTools.c
b/clients/mapiclient/ReadlineTools.c
--- a/clients/mapiclient/ReadlineTools.c
+++ b/clients/mapiclient/ReadlineTools.c
@@ -321,18 +321,25 @@ init_readline(Mapi mid, char *lang, int
}
if (save_history) {
+ int len;
#ifndef NATIVE_WIN32
if (getenv("HOME") != NULL) {
- snprintf(_history_file, FILENAME_MAX,
+ len = snprintf(_history_file, FILENAME_MAX,
"%s/.mapiclient_history_%s",
getenv("HOME"), language);
- _save_history = 1;
+ if (len == -1 || len >= FILENAME_MAX)
+ fprintf(stderr, "Warning: history filename path
is too large\n");
+ else
+ _save_history = 1;
}
#else
- snprintf(_history_file, FILENAME_MAX,
+ len = snprintf(_history_file, FILENAME_MAX,
"%s%c_mapiclient_history_%s",
mo_find_option(NULL, 0, "prefix"), DIR_SEP, language);
- _save_history = 1;
+ if (len == -1 || len >= FILENAME_MAX)
+ fprintf(stderr, "Warning: history filename path is too
large\n");
+ else
+ _save_history = 1;
#endif
if (_save_history) {
FILE *f;
diff --git a/clients/mapiclient/dotmonetdb.c b/clients/mapiclient/dotmonetdb.c
--- a/clients/mapiclient/dotmonetdb.c
+++ b/clients/mapiclient/dotmonetdb.c
@@ -15,18 +15,22 @@ parse_dotmonetdb(char **user, char **pas
{
char *cfile;
FILE *config = NULL;
- char buf[1024];
+ char buf[FILENAME_MAX];
if ((cfile = getenv("DOTMONETDBFILE")) == NULL) {
/* no environment variable: use a default */
if ((config = fopen(".monetdb", "r")) == NULL) {
if ((cfile = getenv("HOME")) != NULL) {
- snprintf(buf, sizeof(buf), "%s%c.monetdb",
cfile, DIR_SEP);
- config = fopen(buf, "r");
- if (config)
- cfile = strdup(buf);
- else
+ int len = snprintf(buf, sizeof(buf),
"%s%c.monetdb", cfile, DIR_SEP);
+ if (len == -1 || len >= FILENAME_MAX) {
cfile = NULL;
+ } else {
+ config = fopen(buf, "r");
+ if (config)
+ cfile = strdup(buf);
+ else
+ cfile = NULL;
+ }
}
} else {
cfile = strdup(".monetdb");
diff --git a/common/options/monet_options.c b/common/options/monet_options.c
--- a/common/options/monet_options.c
+++ b/common/options/monet_options.c
@@ -219,7 +219,7 @@ mo_builtin_settings(opt **Set)
if (Set == NULL)
return 0;
-#define N_OPTIONS 9 /*MUST MATCH # OPTIONS BELOW */
+#define N_OPTIONS 8 /*MUST MATCH # OPTIONS BELOW */
set = malloc(sizeof(opt) * N_OPTIONS);
if (set == NULL)
return 0;
@@ -230,10 +230,6 @@ mo_builtin_settings(opt **Set)
"dbfarm" DIR_SEP_STR "demo");
i++;
set[i].kind = opt_builtin;
- set[i].name = strdup("gdk_debug");
- set[i].value = strdup("0");
- i++;
- set[i].kind = opt_builtin;
set[i].name = strdup("monet_prompt");
set[i].value = strdup(">");
i++;
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -540,6 +540,7 @@ fixfloatbats(void)
char filename[FILENAME_MAX];
FILE *fp;
size_t len;
+ int written;
for (bid = 1; bid < (bat) ATOMIC_GET(BBPsize, BBPsizeLock); bid++) {
if ((b = BBP_desc(bid)) == NULL) {
@@ -554,10 +555,13 @@ fixfloatbats(void)
* logger that it also needs to do a
* conversion. That is done by creating a
* file here based on the name of this BAT. */
- snprintf(filename, sizeof(filename),
+ written = snprintf(filename, sizeof(filename),
"%s/%.*s_nil-nan-convert",
BBPfarms[0].dirname,
(int) (len - 12), BBP_logical(bid));
+ if (written == -1 || written >= FILENAME_MAX)
+ GDKfatal("fixfloatbats: cannot create file %s
has a very large pathname\n",
+ filename);
fp = fopen(filename, "w");
if (fp == NULL) {
GDKsyserror("fixfloatbats: cannot create file
%s\n",
@@ -1807,7 +1811,7 @@ BBPinsert(BAT *bn)
bool lock = locked_by == 0 || locked_by != pid;
char dirname[24];
bat i;
- int idx = threadmask(pid);
+ int idx = threadmask(pid), len = 0;
/* critical section: get a new BBP entry */
if (lock) {
@@ -1873,7 +1877,9 @@ BBPinsert(BAT *bn)
#endif
if (*BBP_bak(i) == 0)
- snprintf(BBP_bak(i), sizeof(BBP_bak(i)), "tmp_%o", (unsigned)
i);
+ len = snprintf(BBP_bak(i), sizeof(BBP_bak(i)), "tmp_%o",
(unsigned) i);
+ if (len == -1 || len >= FILENAME_MAX)
+ return 0;
BBP_logical(i) = BBP_bak(i);
/* Keep the physical location around forever */
@@ -1881,11 +1887,13 @@ BBPinsert(BAT *bn)
BBPgetsubdir(dirname, i);
if (*dirname) /* i.e., i >= 0100 */
- snprintf(BBP_physical(i), sizeof(BBP_physical(i)),
+ len = snprintf(BBP_physical(i), sizeof(BBP_physical(i)),
"%s%c%o", dirname, DIR_SEP, (unsigned) i);
else
- snprintf(BBP_physical(i), sizeof(BBP_physical(i)),
+ len = snprintf(BBP_physical(i), sizeof(BBP_physical(i)),
"%o", (unsigned) i);
+ if (len == -1 || len >= FILENAME_MAX)
+ return 0;
BATDEBUG fprintf(stderr, "#%d = new %s(%s)\n", (int) i,
BBPname(i), ATOMname(bn->ttype));
}
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -586,7 +586,8 @@ BAThash(BAT *b)
MT_Id tid;
BBPfix(b->batCacheid);
if (MT_create_thread(&tid, BAThashsync, b,
- MT_THR_DETACHED) < 0) {
+ MT_THR_DETACHED,
+ "BAThashsync") < 0) {
/* couldn't start thread: clean up */
BBPunfix(b->batCacheid);
}
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -528,7 +528,8 @@ BATimprints(BAT *b)
!b->theap.dirty) {
MT_Id tid;
BBPfix(b->batCacheid);
- if (MT_create_thread(&tid, BATimpsync, b,
MT_THR_DETACHED) < 0)
+ if (MT_create_thread(&tid, BATimpsync, b,
+ MT_THR_DETACHED, "BATimpsync") < 0)
BBPunfix(b->batCacheid);
}
}
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -434,12 +434,24 @@ log_read_updates(logger *lg, trans *tr,
tt = TYPE_void;
}
break;
+ } else if (tr->changes[i].type == LOG_USE &&
strcmp(tr->changes[i].name, name) == 0) {
+ log_bid bid = (log_bid) tr->changes[i].nr;
+ BAT *b = BATdescriptor(bid);
+
+ if (b) {
+ ht = TYPE_void;
+ tt = b->ttype;
+ }
+ break;
}
}
assert(i < tr->nr); /* found one */
}
assert((ht == TYPE_void && l->flag == LOG_INSERT) ||
((ht == TYPE_oid || !ht) && l->flag == LOG_UPDATE));
+ if ((ht != TYPE_void && l->flag == LOG_INSERT) ||
+ ((ht != TYPE_void && ht != TYPE_oid) && l->flag == LOG_UPDATE))
+ return LOG_ERR;
if (ht >= 0 && tt >= 0) {
BAT *uid = NULL;
BAT *r;
@@ -1207,6 +1219,7 @@ logger_readlogs(logger *lg, FILE *fp, ch
{
gdk_return res = GDK_SUCCEED;
char id[BUFSIZ];
+ int len;
if (lg->debug & 1) {
fprintf(stderr, "#logger_readlogs logger id is " LLFMT "\n",
lg->id);
@@ -1225,7 +1238,9 @@ logger_readlogs(logger *lg, FILE *fp, ch
lg->id = lid;
while (res == GDK_SUCCEED && !filemissing) {
- snprintf(log_filename, sizeof(log_filename),
"%s." LLFMT, filename, lg->id);
+ len = snprintf(log_filename,
sizeof(log_filename), "%s." LLFMT, filename, lg->id);
+ if (len == -1 || len >= FILENAME_MAX)
+ GDKerror("Logger filename path is too
large\n");
res = logger_readlog(lg, log_filename,
&filemissing);
if (!filemissing)
lg->id++;
@@ -1233,7 +1248,9 @@ logger_readlogs(logger *lg, FILE *fp, ch
} else {
bool filemissing = false;
while (lid >= lg->id && res == GDK_SUCCEED) {
- snprintf(log_filename, sizeof(log_filename),
"%s." LLFMT, filename, lg->id);
+ len = snprintf(log_filename,
sizeof(log_filename), "%s." LLFMT, filename, lg->id);
+ if (len == -1 || len >= FILENAME_MAX)
+ GDKerror("Logger filename path is too
large\n");
res = logger_readlog(lg, log_filename,
&filemissing);
/* Increment the id only at the end,
* since we want to re-read the last
@@ -1530,6 +1547,7 @@ bm_subcommit(logger *lg, BAT *list_bid,
static gdk_return
logger_load(int debug, const char *fn, char filename[FILENAME_MAX], logger *lg)
{
+ int len;
FILE *fp = NULL;
char bak[FILENAME_MAX];
str filenamestr = NULL;
@@ -1542,8 +1560,12 @@ logger_load(int debug, const char *fn, c
if(!(filenamestr = GDKfilepath(farmid, lg->dir, LOGFILE, NULL)))
goto error;
snprintf(filename, FILENAME_MAX, "%s", filenamestr);
- snprintf(bak, sizeof(bak), "%s.bak", filename);
+ len = snprintf(bak, sizeof(bak), "%s.bak", filename);
GDKfree(filenamestr);
+ if (len == -1 || len >= FILENAME_MAX) {
+ GDKerror("Logger filename path is too large\n");
+ goto error;
+ }
lg->catalog_bid = NULL;
lg->catalog_nme = NULL;
@@ -1992,11 +2014,19 @@ logger_load(int debug, const char *fn, c
{
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list