Changeset: 7d5b16062dd1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7d5b16062dd1 Modified Files: gdk/ChangeLog.Jun2020 gdk/gdk.h gdk/gdk_atoms.c gdk/gdk_atoms.h gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_bbp.c gdk/gdk_delta.c gdk/gdk_project.c monetdb5/mal/mal_atom.c monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_stack.c sql/backends/monet5/rel_bin.c sql/server/rel_optimizer.c sql/server/rel_psm.c sql/server/rel_select.c sql/test/BugTracker-2008/Tests/is_distinct_broken.SF-2430201.sql sql/test/BugTracker-2008/Tests/is_distinct_broken.SF-2430201.stable.err sql/test/BugTracker-2008/Tests/is_distinct_broken.SF-2430201.stable.out sql/test/miscellaneous/Tests/groupby_error.sql sql/test/miscellaneous/Tests/groupby_error.stable.out sql/test/subquery/Tests/subquery4.sql sql/test/subquery/Tests/subquery4.stable.err sql/test/subquery/Tests/subquery4.stable.out Branch: scoping Log Message:
Merged with default diffs (truncated from 917 to 300 lines): diff --git a/gdk/ChangeLog.Jun2020 b/gdk/ChangeLog.Jun2020 --- a/gdk/ChangeLog.Jun2020 +++ b/gdk/ChangeLog.Jun2020 @@ -1,6 +1,10 @@ # ChangeLog file for GDK # This file is updated with Maddlog +* Fri Mar 20 2020 Sjoerd Mullender <[email protected]> +- Changed the interface of the atom "fix" and "unfix" functions. + They now return a value of type gdk_return to indicater success/failure. + * Tue Dec 3 2019 Sjoerd Mullender <[email protected]> - Removed the tunique property. The tunique property indicated that all values in the column had to be distinct. It was removed because diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1512,7 +1512,7 @@ Tputvalue(BAT *b, BUN p, const void *v, #endif } } else { - ATOMputFIX(b->ttype, Tloc(b, p), v); + return ATOMputFIX(b->ttype, Tloc(b, p), v); } return GDK_SUCCEED; } diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c --- a/gdk/gdk_atoms.c +++ b/gdk/gdk_atoms.c @@ -118,16 +118,24 @@ hgeHash(const hge *v) /* * @+ Standard Atoms */ -static int +static gdk_return batFix(const bat *b) { - return BBPretain(*b); + if (!is_bat_nil(*b) && BBPretain(*b) == 0) { + GDKerror("batFix failed\n"); + return GDK_FAIL; + } + return GDK_SUCCEED; } -static int +static gdk_return batUnfix(const bat *b) { - return BBPrelease(*b); + if (!is_bat_nil(*b) && BBPrelease(*b) < 0) { + GDKerror("batUnfix failed\n"); + return GDK_FAIL; + } + return GDK_SUCCEED; } /* @@ -1232,8 +1240,8 @@ atomDesc BATatoms[MAXATOMS] = { .atomWrite = (gdk_return (*)(const void *, stream *, size_t)) batWrite, .atomCmp = (int (*)(const void *, const void *)) intCmp, .atomHash = (BUN (*)(const void *)) intHash, - .atomFix = (int (*)(const void *)) batFix, - .atomUnfix = (int (*)(const void *)) batUnfix, + .atomFix = (gdk_return (*)(const void *)) batFix, + .atomUnfix = (gdk_return (*)(const void *)) batUnfix, }, [TYPE_int] = { .name = "int", diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h --- a/gdk/gdk_atoms.h +++ b/gdk/gdk_atoms.h @@ -50,8 +50,8 @@ typedef struct { int (*atomCmp) (const void *v1, const void *v2); BUN (*atomHash) (const void *v); /* optional functions */ - int (*atomFix) (const void *atom); - int (*atomUnfix) (const void *atom); + gdk_return (*atomFix) (const void *atom); + gdk_return (*atomUnfix) (const void *atom); /* varsized atom-only ADT functions */ var_t (*atomPut) (Heap *, var_t *off, const void *src); @@ -266,8 +266,8 @@ gdk_export const ptr ptr_nil; #define ATOMvarsized(t) (BATatoms[t].atomPut != NULL) #define ATOMlinear(t) BATatoms[t].linear #define ATOMtype(t) ((t) == TYPE_void ? TYPE_oid : (t)) -#define ATOMfix(t,v) do if (BATatoms[t].atomFix) BATatoms[t].atomFix(v); while (0) -#define ATOMunfix(t,v) do if (BATatoms[t].atomUnfix) BATatoms[t].atomUnfix(v); while (0) +#define ATOMfix(t,v) (BATatoms[t].atomFix ? BATatoms[t].atomFix(v) : GDK_SUCCEED) +#define ATOMunfix(t,v) (BATatoms[t].atomUnfix ? BATatoms[t].atomUnfix(v) : GDK_SUCCEED) /* The base type is the storage type if the comparison function, the * hash function, and the nil value are the same as those of the @@ -296,11 +296,15 @@ ATOMputVAR(int type, Heap *heap, var_t * } -static inline void +static inline gdk_return __attribute__((__warn_unused_result__)) ATOMputFIX(int type, void *dst, const void *src) { + gdk_return rc; + assert(BATatoms[type].atomPut == NULL); - ATOMfix(type, src); + rc = ATOMfix(type, src); + if (rc != GDK_SUCCEED) + return rc; switch (ATOMsize(type)) { case 0: /* void */ break; @@ -325,6 +329,7 @@ ATOMputFIX(int type, void *dst, const vo memcpy(dst, src, ATOMsize(type)); break; } + return GDK_SUCCEED; } static inline gdk_return __attribute__((__warn_unused_result__)) @@ -335,11 +340,11 @@ ATOMreplaceVAR(int type, Heap *heap, var assert(BATatoms[type].atomPut != NULL); if ((*BATatoms[type].atomPut)(heap, &loc, src) == 0) return GDK_FAIL; - ATOMunfix(type, dst); + if (ATOMunfix(type, dst) != GDK_SUCCEED) + return GDK_FAIL; ATOMdel(type, heap, dst); *dst = loc; - ATOMfix(type, src); - return GDK_SUCCEED; + return ATOMfix(type, src); } /* string heaps: diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -1129,7 +1129,8 @@ BUNdelete(BAT *b, oid o) && ATOMcmp(b->ttype, VALptr(&prop->v), val) <= 0) BATrmprop(b, GDK_MIN_VALUE); } - ATOMunfix(b->ttype, val); + if (ATOMunfix(b->ttype, val) != GDK_SUCCEED) + return GDK_FAIL; ATOMdel(b->ttype, b->tvheap, (var_t *) BUNtloc(bi, p)); if (p != BUNlast(b) - 1 && (b->ttype != TYPE_void || BATtdense(b))) { @@ -1314,8 +1315,10 @@ BUNinplace(BAT *b, BUN p, const void *t, } } else { assert(BATatoms[b->ttype].atomPut == NULL); - ATOMfix(b->ttype, t); - ATOMunfix(b->ttype, BUNtloc(bi, p)); + if (ATOMfix(b->ttype, t) != GDK_SUCCEED) + return GDK_FAIL; + if (ATOMunfix(b->ttype, BUNtloc(bi, p)) != GDK_SUCCEED) + return GDK_FAIL; switch (ATOMsize(b->ttype)) { case 0: /* void */ break; diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -721,7 +721,7 @@ BATappend(BAT *b, BAT *n, BAT *s, bool f gdk_return BATdel(BAT *b, BAT *d) { - int (*unfix) (const void *) = BATatoms[b->ttype].atomUnfix; + gdk_return (*unfix) (const void *) = BATatoms[b->ttype].atomUnfix; void (*atmdel) (Heap *, var_t *) = BATatoms[b->ttype].atomDel; BATiter bi = bat_iterator(b); @@ -752,8 +752,8 @@ BATdel(BAT *b, BAT *d) BUN p = o - b->hseqbase; BUN q = p + c; while (p < q) { - if (unfix) - (*unfix)(BUNtail(bi, p)); + if (unfix && (*unfix)(BUNtail(bi, p)) != GDK_SUCCEED) + return GDK_FAIL; if (atmdel) (*atmdel)(b->tvheap, (var_t *) BUNtloc(bi, p)); p++; diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -997,8 +997,8 @@ BBPcheckbats(void) if (path == NULL) return GDK_FAIL; if (stat(path, &statb) < 0) { - GDKsyserror("BBPcheckbats: cannot stat file %s\n", - path); + GDKsyserror("BBPcheckbats: cannot stat file %s (expected size %zu)\n", + path, b->theap.free); GDKfree(path); return GDK_FAIL; } @@ -1460,7 +1460,7 @@ vheap_entry(FILE *fp, Heap *h) } static gdk_return -new_bbpentry(FILE *fp, bat i, const char *prefix) +new_bbpentry(FILE *fp, bat i) { #ifndef NDEBUG assert(i > 0); @@ -1476,10 +1476,9 @@ new_bbpentry(FILE *fp, bat i, const char } #endif - if (fprintf(fp, "%s%zd %u %s %s %d " BUNFMT " " - BUNFMT " " OIDFMT, prefix, + if (fprintf(fp, "%d %u %s %s %d " BUNFMT " " BUNFMT " " OIDFMT, /* BAT info */ - (ssize_t) i, + (int) i, BBP_status(i) & BBPPERSISTENT, BBP_logical(i), BBP_physical(i), @@ -1489,24 +1488,11 @@ new_bbpentry(FILE *fp, bat i, const char BBP_desc(i)->hseqbase) < 0 || heap_entry(fp, BBP_desc(i)) < 0 || vheap_entry(fp, BBP_desc(i)->tvheap) < 0 || - (BBP_options(i) && - fprintf(fp, " %s", BBP_options(i)) < 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; } - TRC_DEBUG(IO_, "%s%zd %u %s %s %d " BUNFMT " " - BUNFMT " " OIDFMT " %s\n", prefix, - /* BAT info */ - (ssize_t) i, - BBP_status(i) & BBPPERSISTENT, - BBP_logical(i), - BBP_physical(i), - BBP_desc(i)->batRestricted << 1, - BBP_desc(i)->batCount, - BBP_desc(i)->batCapacity, - BBP_desc(i)->hseqbase, - BBP_options(i) ? BBP_options(i) : ""); return GDK_SUCCEED; } @@ -1592,7 +1578,7 @@ BBPdir_subcommit(int cnt, bat *subcommit bat i = subcommit[j]; /* BBP.dir consists of all persistent bats only */ if (BBP_status(i) & BBPPERSISTENT) { - if (new_bbpentry(nbbpf, i, "") != GDK_SUCCEED) { + if (new_bbpentry(nbbpf, i) != GDK_SUCCEED) { goto bailout; } } @@ -1664,7 +1650,7 @@ BBPdir(int cnt, bat *subcommit) /* write the entry * BBP.dir consists of all persistent bats */ if (BBP_status(i) & BBPPERSISTENT) { - if (new_bbpentry(fp, i, "") != GDK_SUCCEED) { + if (new_bbpentry(fp, i) != GDK_SUCCEED) { goto bailout; } } @@ -2693,14 +2679,15 @@ BBPdestroy(BAT *b) VIEWdestroy(b); } else { /* bats that get destroyed must unfix their atoms */ - int (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix; + gdk_return (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix; BUN p, q; BATiter bi = bat_iterator(b); assert(b->batSharecnt == 0); if (tunfix) { BATloop(b, p, q) { - (*tunfix) (BUNtail(bi, p)); + /* ignore errors */ + (void) (*tunfix)(BUNtail(bi, p)); } } BATdelete(b); /* handles persistent case also (file deletes) */ diff --git a/gdk/gdk_delta.c b/gdk/gdk_delta.c --- a/gdk/gdk_delta.c +++ b/gdk/gdk_delta.c @@ -89,7 +89,7 @@ BATundo(BAT *b) bunlast = BUNlast(b) - 1; if (bunlast >= b->batInserted) { BUN i = bunfirst; - int (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix; + gdk_return (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix; void (*tatmdel) (Heap *, var_t *) = BATatoms[b->ttype].atomDel; if (b->thash) @@ -97,7 +97,7 @@ BATundo(BAT *b) if (tunfix || tatmdel) { for (p = bunfirst; p <= bunlast; p++, i++) { if (tunfix) - (*tunfix) (BUNtail(bi, p)); + (void) (*tunfix) (BUNtail(bi, p)); _______________________________________________ checkin-list mailing list [email protected] https://www.monetdb.org/mailman/listinfo/checkin-list
