Changeset: 83edeaf10df2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=83edeaf10df2
Modified Files:
gdk/gdk_align.c
gdk/gdk_atoms.c
gdk/gdk_bat.c
gdk/gdk_bbp.c
gdk/gdk_group.c
gdk/gdk_heap.c
gdk/gdk_imprints.c
gdk/gdk_join.c
gdk/gdk_posix.c
gdk/gdk_sample.c
gdk/gdk_search.c
gdk/gdk_select.c
gdk/gdk_ssort.c
gdk/gdk_unique.c
gdk/gdk_utils.c
monetdb5/modules/mal/batExtensions.c
Branch: default
Log Message:
Produce error messages where the error first occurs.
diffs (truncated from 1086 to 300 lines):
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -748,10 +748,8 @@ VIEWbounds(BAT *b, BAT *view, BUN l, BUN
BUN cnt;
BATiter bi = bat_iterator(b);
- if (b == NULL || view == NULL) {
- GDKerror("VIEWbounds: bat argument missing");
+ if (b == NULL || view == NULL)
return;
- }
if (h > BATcount(b))
h = BATcount(b);
if (h < l)
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -315,23 +315,27 @@ int
ATOMprint(int t, const void *p, stream *s)
{
int (*tostr) (str *, int *, const void *);
+ ssize_t res;
if (p && t >= 0 && t < GDKatomcnt && (tostr = BATatoms[t].atomToStr)) {
if (t != TYPE_bat && t < TYPE_str) {
char buf[dblStrlen], *addr = buf; /* use memory
from stack */
int sz = dblStrlen, l = (*tostr) (&addr, &sz, p);
- return (int) mnstr_write(s, buf, l, 1);
+ res = mnstr_write(s, buf, l, 1);
} else {
str buf = 0;
int sz = 0, l = (*tostr) (&buf, &sz, p);
- l = (int) mnstr_write(s, buf, l, 1);
+ res = mnstr_write(s, buf, l, 1);
GDKfree(buf);
- return l;
}
+ } else {
+ res = mnstr_write(s, "nil", 1, 3);
}
- return (int) mnstr_write(s, "nil", 1, 3);
+ if (res < 0)
+ GDKsyserror("ATOMprint: write failure\n");
+ return (int) res;
}
@@ -507,8 +511,10 @@ bitWrite(const bit *a, stream *s, size_t
{
if (mnstr_write(s, (const char *) a, 1, cnt) == (ssize_t) cnt)
return GDK_SUCCEED;
- else
+ else {
+ GDKsyserror("bitWrite: write failure\n");
return GDK_FAIL;
+ }
}
int
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -327,7 +327,7 @@ BATattach(int tt, const char *heapfile,
ERRORcheck(heapfile == 0, "BATattach: bad heapfile name\n", NULL);
ERRORcheck(role < 0 || role >= 32, "BATattach: role error\n", NULL);
if (lstat(heapfile, &st) < 0) {
- GDKerror("BATattach: cannot stat heapfile\n");
+ GDKsyserror("BATattach: cannot stat heapfile\n");
return NULL;
}
ERRORcheck(!S_ISREG(st.st_mode), "BATattach: heapfile must be a regular
file\n", NULL);
@@ -1135,7 +1135,6 @@ BUNins(BAT *b, const void *h, const void
}
if (unshare_string_heap(b) != GDK_SUCCEED) {
- GDKerror("BUNins: failed to unshare string heap\n");
return GDK_FAIL;
}
@@ -1257,7 +1256,6 @@ BUNappend(BAT *b, const void *t, bit for
void_materialize(b, t);
if (unshare_string_heap(b) != GDK_SUCCEED) {
- GDKerror("BUNappend: failed to unshare string heap\n");
return GDK_FAIL;
}
@@ -1834,6 +1832,7 @@ BUNlocate(BAT *b, const void *x, const v
(void) BAThash(BATmirror(v), 0);
if (dohash(v->T))
(void) BAThash(v, 0);
+ GDKclrerr(); /* not interested in BAThash failures */
if (v->H->hash && v->T->hash) { /* we can choose
between two hash tables */
BUN hcnt = 0, tcnt = 0;
BUN i;
@@ -2441,11 +2440,14 @@ backup_new(Heap *hp, int lockbat)
if (batret == 0 && bakret) {
/* no backup yet, so move the existing X.new there out
* of the way */
- ret = rename(batpath, bakpath);
+ if ((ret = rename(batpath, bakpath)) < 0)
+ GDKsyserror("backup_new: rename %s to %s failed\n",
+ batpath, bakpath);
IODEBUG fprintf(stderr, "#rename(%s,%s) = %d\n", batpath,
bakpath, ret);
} else if (batret == 0) {
/* there is a backup already; just remove the X.new */
- ret = unlink(batpath);
+ if ((ret = unlink(batpath)) < 0)
+ GDKsyserror("backup_new: unlink %s failed\n", batpath);
IODEBUG fprintf(stderr, "#unlink(%s) = %d\n", batpath, ret);
}
GDKfree(batpath);
@@ -2565,6 +2567,8 @@ BATsetaccess(BAT *b, int newmode)
if (b->batSharecnt && newmode != BAT_READ) {
BATDEBUG THRprintf(GDKout, "#BATsetaccess: %s has %d
views; try creating a copy\n", BATgetId(b), b->batSharecnt);
+ GDKerror("BATsetaccess: %s has %d views\n",
+ BATgetId(b), b->batSharecnt);
return GDK_FAIL;
}
@@ -2680,7 +2684,6 @@ BATmode(BAT *b, int mode)
if (mode == PERSISTENT && isVIEW(b)) {
if (VIEWreset(b) != GDK_SUCCEED) {
- GDKerror("BATmode: cannot allocate memory.\n");
return GDK_FAIL;
}
}
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1286,23 +1286,19 @@ new_bbpentry(FILE *fp, bat i)
(unsigned char) BBP_desc(i)->S.map_head,
(unsigned char) BBP_desc(i)->S.map_tail,
(unsigned char) BBP_desc(i)->S.map_hheap,
- (unsigned char) BBP_desc(i)->S.map_theap) < 0)
+ (unsigned char) BBP_desc(i)->S.map_theap) < 0 ||
+ heap_entry(fp, &BBP_desc(i)->H) < 0 ||
+ heap_entry(fp, &BBP_desc(i)->T) < 0 ||
+ vheap_entry(fp, BBP_desc(i)->H.vheap) < 0 ||
+ vheap_entry(fp, BBP_desc(i)->T.vheap) < 0 ||
+ (BBP_options(i) &&
+ fprintf(fp, " %s", BBP_options(i)) < 0) ||
+ fprintf(fp, "\n") < 0) {
+ GDKsyserror("new_bbpentry: Writing BBP.dir entry failed\n");
return GDK_FAIL;
- if (heap_entry(fp, &BBP_desc(i)->H) < 0)
- return GDK_FAIL;
- if (heap_entry(fp, &BBP_desc(i)->T) < 0)
- return GDK_FAIL;
-
- if (vheap_entry(fp, BBP_desc(i)->H.vheap) < 0)
- return GDK_FAIL;
- if (vheap_entry(fp, BBP_desc(i)->T.vheap) < 0)
- return GDK_FAIL;
-
- if (BBP_options(i) &&
- fprintf(fp, " %s", BBP_options(i)) < 0)
- return GDK_FAIL;
-
- return fprintf(fp, "\n") < 0 ? GDK_FAIL : GDK_SUCCEED;
+ }
+
+ return GDK_SUCCEED;
}
static gdk_return
@@ -1312,8 +1308,10 @@ BBPdir_header(FILE *f, int n)
GDKLIBRARY, SIZEOF_SIZE_T, SIZEOF_OID, SIZEOF_MAX_INT) < 0
||
OIDwrite(f) < 0 ||
fprintf(f, " BBPsize=%d\n", n) < 0 ||
- ferror(f))
+ ferror(f)) {
+ GDKsyserror("BBPdir_header: Writing BBP.dir header failed\n");
return GDK_FAIL;
+ }
return GDK_SUCCEED;
}
@@ -1328,10 +1326,8 @@ BBPdir_subcommit(int cnt, bat *subcommit
assert(subcommit != NULL);
- if ((nbbpf = GDKfilelocate(0, "BBP", "w", "dir")) == NULL) {
- GDKsyserror("BBPdir_subcommit: Creating new BBP.dir file
failed\n");
+ if ((nbbpf = GDKfilelocate(0, "BBP", "w", "dir")) == NULL)
return GDK_FAIL;
- }
n = (bat) ATOMIC_GET(BBPsize, BBPsizeLock, "BBPdir_subcommit");
@@ -1361,7 +1357,6 @@ BBPdir_subcommit(int cnt, bat *subcommit
}
if (BBPdir_header(nbbpf, n) != GDK_SUCCEED) {
- GDKsyserror("BBPdir_subcommit: Writing BBP.dir header
failed\n");
goto bailout;
}
n = 0;
@@ -1385,7 +1380,6 @@ BBPdir_subcommit(int cnt, bat *subcommit
/* BBP.dir consists of all persistent bats only */
if (BBP_status(i) & BBPPERSISTENT) {
if (new_bbpentry(nbbpf, i) != GDK_SUCCEED) {
- GDKsyserror("BBPdir_subcommit: Writing
BBP.dir entry failed\n");
goto bailout;
}
IODEBUG new_bbpentry(stderr, i);
@@ -1457,12 +1451,10 @@ BBPdir(int cnt, bat *subcommit)
fprintf(stderr, "\n");
}
if ((fp = GDKfilelocate(0, "BBP", "w", "dir")) == NULL) {
- GDKsyserror("BBPdir: Cannor create BBP.dir file\n");
goto bailout;
}
if (BBPdir_header(fp, (bat) ATOMIC_GET(BBPsize, BBPsizeLock, "BBPdir"))
!= GDK_SUCCEED) {
- GDKsyserror("BBPdir: Writing BBP.dir header failed\n");
goto bailout;
}
@@ -1471,7 +1463,6 @@ BBPdir(int cnt, bat *subcommit)
* BBP.dir consists of all persistent bats */
if (BBP_status(i) & BBPPERSISTENT) {
if (new_bbpentry(fp, i) != GDK_SUCCEED) {
- GDKsyserror("BBPdir: Writing BBP.dir entry
failed\n");
goto bailout;
}
IODEBUG new_bbpentry(stderr, i);
@@ -3175,12 +3166,15 @@ file_move(int farmid, const char *srcdir
struct stat st;
path = GDKfilepath(farmid, srcdir, name, ext);
+ if (path == NULL)
+ return GDK_FAIL;
if (stat(path, &st)) {
/* source file does not exist; the best
* recovery is to give an error but continue
* by considering the BAT as not saved; making
* sure that this time it does get saved.
*/
+ GDKsyserror("file_move: cannot stat %s\n", path);
GDKfree(path);
return GDK_FAIL; /* fishy, but not fatal */
}
@@ -3195,12 +3189,14 @@ file_exists(int farmid, const char *dir,
{
char *path;
struct stat st;
- int ret;
+ int ret = -1;
path = GDKfilepath(farmid, dir, name, ext);
- ret = stat(path, &st);
- IODEBUG fprintf(stderr, "#stat(%s) = %d\n", path, ret);
- GDKfree(path);
+ if (path) {
+ ret = stat(path, &st);
+ IODEBUG fprintf(stderr, "#stat(%s) = %d\n", path, ret);
+ GDKfree(path);
+ }
return (ret == 0);
}
@@ -3231,7 +3227,11 @@ heap_move(Heap *hp, const char *srcdir,
snprintf(kill_ext, sizeof(kill_ext), "%s.kill", ext);
path = GDKfilepath(hp->farmid, dstdir, nme, kill_ext);
+ if (path == NULL)
+ return GDK_FAIL;
fp = fopen(path, "w");
+ if (fp == NULL)
+ GDKsyserror("heap_move: cannot open file %s\n", path);
IODEBUG fprintf(stderr, "#open %s = %d\n", path, fp ? 0 : -1);
GDKfree(path);
@@ -3280,16 +3280,20 @@ BBPprepare(bit subcommit)
backup_dir = 0;
ret = BBPrecover(0);
if (ret == GDK_SUCCEED) {
- if (mkdir(BAKDIR, 0755) < 0 && errno != EEXIST)
+ if (mkdir(BAKDIR, 0755) < 0 && errno != EEXIST) {
+ GDKsyserror("BBPprepare: cannot create
directory %s\n", BAKDIR);
ret = GDK_FAIL;
+ }
/* if BAKDIR already exists, don't signal error */
IODEBUG fprintf(stderr, "#mkdir %s = %d\n", BAKDIR,
(int) ret);
}
}
if (ret == GDK_SUCCEED && start_subcommit) {
/* make a new SUBDIR (subdir of BAKDIR) */
- if (mkdir(SUBDIR, 0755) < 0)
+ if (mkdir(SUBDIR, 0755) < 0) {
+ GDKsyserror("BBPprepare: cannot create directory %s\n",
SUBDIR);
ret = GDK_FAIL;
+ }
IODEBUG fprintf(stderr, "#mkdir %s = %d\n", SUBDIR, (int) ret);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list