Changeset: f77e7647187c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f77e7647187c Modified Files: clients/mapiclient/dump.c gdk/gdk_aggr.c gdk/gdk_atoms.h gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_orderidx.c gdk/gdk_private.h gdk/gdk_project.c monetdb5/extras/rapi/converters.c.h sql/backends/monet5/sql_result.c sql/common/sql_string.c sql/common/sql_string.h sql/server/sql_atom.c Branch: default Log Message:
Merge with Jul2017 branch. diffs (truncated from 369 to 300 lines): diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -116,10 +116,11 @@ has_hugeint(Mapi mid) { MapiHdl hdl; int ret; - static int answer = -1; + static int hashge = -1; - if (answer >= 0) - return answer; + if (hashge >= 0) + return hashge; + if ((hdl = mapi_query(mid, "SELECT id " "FROM sys.types " @@ -134,7 +135,7 @@ has_hugeint(Mapi mid) if (mapi_error(mid)) goto bailout; mapi_close_handle(hdl); - answer = ret; + hashge = ret; return ret; bailout: diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -704,7 +704,7 @@ dosum(const void *restrict values, int n #ifdef HAVE_HGE case TYPE_hge: { hge *sums = (hge *) results; - switch (ATOMstorage(tp1)) { + switch (tp1) { case TYPE_bte: AGGR_SUM(bte, hge); break; @@ -1207,7 +1207,7 @@ doprod(const void *restrict values, oid #ifdef HAVE_HGE case TYPE_lng: { lng *prods = (lng *) results; - switch (ATOMstorage(tp1)) { + switch (tp1) { case TYPE_bte: AGGR_PROD(bte, lng, hge); break; @@ -1227,7 +1227,7 @@ doprod(const void *restrict values, oid } case TYPE_hge: { hge *prods = (hge *) results; - switch (ATOMstorage(tp1)) { + switch (tp1) { case TYPE_bte: AGGR_PROD_HGE(bte); break; diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h --- a/gdk/gdk_atoms.h +++ b/gdk/gdk_atoms.h @@ -203,9 +203,9 @@ gdk_export const ptr ptr_nil; #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) -/* The base type is the storage type if the comparison function and - * nil values are the same as those of the storage type; otherwise it - * is the type itself. */ +/* 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 + * storage type; otherwise it is the type itself. */ #define ATOMbasetype(t) ((t) != ATOMstorage(t) && \ ATOMnilptr(t) == ATOMnilptr(ATOMstorage(t)) && \ ATOMcompare(t) == ATOMcompare(ATOMstorage(t)) && \ diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -1711,6 +1711,8 @@ HEAPcommitpersistence(Heap *hp, bool wri } +#define ATOMappendpriv(t, h) (ATOMstorage(t) != TYPE_str || GDK_ELIMDOUBLES(h)) + /* change the heap modes at a commit */ gdk_return BATcheckmodes(BAT *b, bool existing) @@ -2009,6 +2011,11 @@ BATassertProps(BAT *b) assert(!b->tvarsized); /* shift and width have a particular relationship */ assert(b->tshift >= 0); + if (ATOMstorage(b->ttype) == TYPE_str) + assert(b->twidth >= 1 && b->twidth <= ATOMsize(b->ttype)); + else + assert(b->twidth == ATOMsize(b->ttype)); + assert(b->tseqbase <= oid_nil); /* only oid/void columns can be dense */ assert(!b->tdense || b->ttype == TYPE_oid || b->ttype == TYPE_void); if (b->ttype == TYPE_oid && b->tdense) { @@ -2021,7 +2028,6 @@ BATassertProps(BAT *b) } /* a column cannot both have and not have NILs */ assert(!b->tnil || !b->tnonil); - assert(b->tseqbase <= oid_nil); if (b->ttype == TYPE_void) { assert(b->tshift == 0); assert(b->twidth == 0); @@ -2039,10 +2045,6 @@ BATassertProps(BAT *b) } return; } - if (ATOMstorage(b->ttype) == TYPE_str) - assert(b->twidth >= 1 && b->twidth <= ATOMsize(b->ttype)); - else - assert(b->twidth == ATOMsize(b->ttype)); assert(1 << b->tshift == b->twidth); /* only linear atoms can be sorted */ assert(!b->tsorted || ATOMlinear(b->ttype)); diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -519,7 +519,18 @@ BATappend(BAT *b, BAT *n, BAT *s, bit fo assert(b->theap.parentid == 0); ALIGNapp(b, "BATappend", force, GDK_FAIL); - BATcompatible(b, n, GDK_FAIL, "BATappend"); + + if (ATOMstorage(ATOMtype(b->ttype)) != ATOMstorage(ATOMtype(n->ttype))) { + GDKerror("Incompatible operands.\n"); + return GDK_FAIL; + } + CHECKDEBUG { + if (BATttype(b) != BATttype(n) && + ATOMtype(b->ttype) != ATOMtype(n->ttype)) { + fprintf(stderr,"#Interpreting %s as %s.\n", + ATOMname(BATttype(n)), ATOMname(BATttype(b))); + } + } if (BATcount(b) == 0) BAThseqbase(b, s ? s->hseqbase : n->hseqbase); @@ -859,15 +870,6 @@ BATdel(BAT *b, BAT *d) return GDK_SUCCEED; } -#define TYPEcheck(t1,t2,func) \ - do { \ - if (TYPEerror(t1, t2)) { \ - GDKerror("%s: Incompatible types %s and %s.\n", \ - func, ATOMname(t2), ATOMname(t1)); \ - return GDK_FAIL; \ - } \ - } while (0) - /* * The last in this series is a BATreplace, which replaces all the * buns mentioned. diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c --- a/gdk/gdk_orderidx.c +++ b/gdk/gdk_orderidx.c @@ -312,7 +312,7 @@ GDKmergeidx(BAT *b, BAT**a, int n_ar) if (BATcheckorderidx(b)) return GDK_SUCCEED; - switch (ATOMstorage(b->ttype)) { + switch (ATOMbasetype(b->ttype)) { case TYPE_bte: case TYPE_sht: case TYPE_int: @@ -378,7 +378,7 @@ GDKmergeidx(BAT *b, BAT**a, int n_ar) q0 = p0 + BATcount(a[0]); q1 = p1 + BATcount(a[1]); - switch (ATOMstorage(b->ttype)) { + switch (ATOMbasetype(b->ttype)) { case TYPE_bte: BINARY_MERGE(bte); break; case TYPE_sht: BINARY_MERGE(sht); break; case TYPE_int: BINARY_MERGE(int); break; @@ -420,7 +420,7 @@ GDKmergeidx(BAT *b, BAT**a, int n_ar) q[i] = p[i] + BATcount(a[i]); } - switch (ATOMstorage(b->ttype)) { + switch (ATOMbasetype(b->ttype)) { case TYPE_bte: NWAY_MERGE(bte); break; case TYPE_sht: NWAY_MERGE(sht); break; case TYPE_int: NWAY_MERGE(int); break; diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h --- a/gdk/gdk_private.h +++ b/gdk/gdk_private.h @@ -277,8 +277,6 @@ extern MT_Lock GDKthreadLock; extern MT_Lock GDKtmLock; extern MT_Lock MT_system_lock; -#define ATOMappendpriv(t, h) (ATOMstorage(t) != TYPE_str || GDK_ELIMDOUBLES(h)) - #define BBPdirty(x) (BBP_dirty=(x)) #define BATcheck(tst, msg, err) \ @@ -298,21 +296,6 @@ extern MT_Lock MT_system_lock; return (err); \ } \ } while (0) -#define BATcompatible(P1,P2,E,F) \ - do { \ - ERRORcheck((P1) == NULL, F ": BAT required\n", E); \ - ERRORcheck((P2) == NULL, F ": BAT required\n", E); \ - if (TYPEerror(BATttype(P1),BATttype(P2))) { \ - GDKerror("Incompatible operands.\n"); \ - return (E); \ - } \ - if (BATttype(P1) != BATttype(P2) && \ - ATOMtype((P1)->ttype) != ATOMtype((P2)->ttype)) { \ - CHECKDEBUG fprintf(stderr,"#Interpreting %s as %s.\n", \ - ATOMname(BATttype(P2)), ATOMname(BATttype(P1))); \ - } \ - } while (0) -#define TYPEerror(t1,t2) (ATOMstorage(ATOMtype(t1)) != ATOMstorage(ATOMtype(t2))) #define GDKswapLock(x) GDKbatLock[(x)&BBP_BATMASK].swap #define GDKhashLock(x) GDKbatLock[(x)&BBP_BATMASK].hash diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c --- a/gdk/gdk_project.c +++ b/gdk/gdk_project.c @@ -256,11 +256,11 @@ BATproject(BAT *l, BAT *r) lcount > (rcount >> 3) || r->batRestricted == BAT_READ)) { /* insert strings as ints, we need to copy the string - * heap whole sale; we can not do this if there are - * nils in the left column, and we will not do it if - * the left is much smaller than the right and the - * right is writable (meaning we have to actually copy - * the right string heap) */ + * heap whole sale; we can't do this if there are nils + * in the left column, and we won't do it if the left + * is much smaller than the right and the right is + * writable (meaning we have to actually copy the + * right string heap) */ tpe = r->twidth == 1 ? TYPE_bte : (r->twidth == 2 ? TYPE_sht : (r->twidth == 4 ? TYPE_int : TYPE_lng)); /* int's nil representation is a valid offset, so * don't check for nils */ diff --git a/monetdb5/extras/rapi/converters.c.h b/monetdb5/extras/rapi/converters.c.h --- a/monetdb5/extras/rapi/converters.c.h +++ b/monetdb5/extras/rapi/converters.c.h @@ -62,7 +62,7 @@ static SEXP bat_to_sexp(BAT* b) { SEXP varvalue = NULL; // TODO: deal with SQL types (DECIMAL/DATE) - switch (ATOMstorage(getBatType(b->ttype))) { + switch (ATOMstorage(b->ttype)) { case TYPE_void: { size_t i = 0; varvalue = PROTECT(NEW_LOGICAL(BATcount(b))); diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c --- a/sql/backends/monet5/sql_result.c +++ b/sql/backends/monet5/sql_result.c @@ -1677,7 +1677,7 @@ mvc_export_table_prot10(backend *b, stre } else { size_t atom_size = ATOMsize(mtype); if (c->type.type->eclass == EC_DEC) { - atom_size = ATOMsize(ATOMstorage(mtype)); + atom_size = ATOMsize(mtype); } if (c->type.type->eclass == EC_TIMESTAMP) { // convert timestamp values to epoch @@ -1708,40 +1708,40 @@ mvc_export_table_prot10(backend *b, stre } else { if (mnstr_byteorder(s) != 1234) { size_t j = 0; - switch(ATOMstorage(mtype)) { - case TYPE_sht: { - short *bufptr = (short*) buf; - short *exported_values = (short*) Tloc(iterators[i].b, srow); - for(j = 0; j < (row - srow); j++) { - bufptr[j] = short_int_SWAP(exported_values[j]); - } - break; + switch (ATOMstorage(mtype)) { + case TYPE_sht: { + short *bufptr = (short*) buf; + short *exported_values = (short*) Tloc(iterators[i].b, srow); + for(j = 0; j < (row - srow); j++) { + bufptr[j] = short_int_SWAP(exported_values[j]); } - case TYPE_int: { - int *bufptr = (int*) buf; - int *exported_values = (int*) Tloc(iterators[i].b, srow); - for(j = 0; j < (row - srow); j++) { - bufptr[j] = normal_int_SWAP(exported_values[j]); - } - break; + break; + } + case TYPE_int: { + int *bufptr = (int*) buf; + int *exported_values = (int*) Tloc(iterators[i].b, srow); + for(j = 0; j < (row - srow); j++) { + bufptr[j] = normal_int_SWAP(exported_values[j]); } - case TYPE_lng: { - lng *bufptr = (lng*) buf; - lng *exported_values = (lng*) Tloc(iterators[i].b, srow); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list