Changeset: 080a24a98646 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=080a24a98646 Modified Files: common/stream/stream.c gdk/gdk_aggr.c gdk/gdk_atoms.c gdk/gdk_calc.c geom/monetdb5/geom.h monetdb5/modules/kernel/batmmath.h monetdb5/modules/kernel/mmath.h monetdb5/modules/mal/batcalc.c monetdb5/modules/mal/calc.c sql/backends/monet5/Tests/pyloader01.sql sql/backends/monet5/Tests/pyloader01.stable.out sql/backends/monet5/UDF/pyapi/emit.c sql/backends/monet5/generator/generator.c sql/test/BugTracker-2017/Tests/python_loader_clobbers_default_with_null.Bug-6464.stable.err sql/test/BugTracker-2017/Tests/python_loader_clobbers_default_with_null.Bug-6464.stable.out Branch: default Log Message:
Merge with Jul2017 branch. diffs (truncated from 424 to 300 lines): diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -1299,6 +1299,7 @@ open_bzstream(const char *filename, cons stream *s; int err; struct bz *bzp; + char fl[3]; if ((bzp = malloc(sizeof(struct bz))) == NULL) return NULL; @@ -1306,10 +1307,13 @@ open_bzstream(const char *filename, cons free(bzp); return NULL; } + fl[0] = flags[0]; /* 'r' or 'w' */ + fl[1] = 'b'; /* always binary */ + fl[2] = '\0'; #ifdef HAVE__WFOPEN { wchar_t *wfname = utf8towchar(filename); - wchar_t *wflags = utf8towchar(flags); + wchar_t *wflags = utf8towchar(fl); if (wfname != NULL && wflags != NULL) bzp->f = _wfopen(wfname, wflags); else @@ -1323,7 +1327,7 @@ open_bzstream(const char *filename, cons { char *fname = cvfilename(filename); if (fname) { - bzp->f = fopen(fname, flags); + bzp->f = fopen(fname, fl); free(fname); } else bzp->f = NULL; @@ -1601,11 +1605,10 @@ open_xzstream(const char *filename, cons stream *s; xz_stream *xz; uint32_t preset = 0; - - if ((xz = malloc(sizeof(struct xz_stream))) == NULL) + char fl[3]; + + if ((xz = calloc(1, sizeof(struct xz_stream))) == NULL) return NULL; - if (xz) - memset(xz, 0, sizeof(xz_stream)); if (((flags[0] == 'r' && lzma_stream_decoder(&xz->strm, UINT64_MAX, LZMA_CONCATENATED) != LZMA_OK)) || (flags[0] == 'w' && @@ -1617,10 +1620,13 @@ open_xzstream(const char *filename, cons free(xz); return NULL; } + fl[0] = flags[0]; /* 'r' or 'w' */ + fl[1] = 'b'; /* always binary */ + fl[2] = '\0'; #ifdef HAVE__WFOPEN { wchar_t *wfname = utf8towchar(filename); - wchar_t *wflags = utf8towchar(flags); + wchar_t *wflags = utf8towchar(fl); if (wfname != NULL) xz->fp = _wfopen(wfname, wflags); else @@ -1634,7 +1640,7 @@ open_xzstream(const char *filename, cons { char *fname = cvfilename(filename); if (fname) { - xz->fp = fopen(fname, flags); + xz->fp = fopen(fname, fl); free(fname); } else xz->fp = NULL; diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -10,11 +10,7 @@ #include "gdk.h" #include "gdk_private.h" #include "gdk_calc_private.h" -#if defined(_MSC_VER) && defined(__INTEL_COMPILER) -#include <mathimf.h> -#else #include <math.h> -#endif /* grouped aggregates * diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c --- a/gdk/gdk_atoms.c +++ b/gdk/gdk_atoms.c @@ -23,10 +23,7 @@ #include "monetdb_config.h" #include "gdk.h" #include "gdk_private.h" - -#ifndef NAN -#define NAN ((float)(((float)(1e300 * 1e300)) * 0.0F)) -#endif +#include <math.h> /* the *Cmp functions return a value less than zero if the first * argument is less than the second; they return zero if the two diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c --- a/gdk/gdk_calc.c +++ b/gdk/gdk_calc.c @@ -10,11 +10,7 @@ #include "gdk.h" #include "gdk_private.h" #include "gdk_calc_private.h" -#if defined(_MSC_VER) && defined(__INTEL_COMPILER) -#include <mathimf.h> -#else #include <math.h> -#endif /* Define symbol FULL_IMPLEMENTATION to get implementations for all * sensible output types for +, -, *, /. Without the symbol, all diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h --- a/geom/monetdb5/geom.h +++ b/geom/monetdb5/geom.h @@ -22,11 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#if defined(_MSC_VER) && defined(__INTEL_COMPILER) -#include <mathimf.h> -#else #include <math.h> -#endif #include <time.h> #include <gdk_logger.h> diff --git a/monetdb5/modules/kernel/batmmath.h b/monetdb5/modules/kernel/batmmath.h --- a/monetdb5/modules/kernel/batmmath.h +++ b/monetdb5/modules/kernel/batmmath.h @@ -9,7 +9,7 @@ #ifndef _BATMATH_H #define _BATMATH_H #include "gdk.h" -#include "math.h" +#include <math.h> #include "mal_exception.h" #define radians(x) ((x) * 3.14159265358979323846 / 180.0) diff --git a/monetdb5/modules/mal/batcalc.c b/monetdb5/modules/mal/batcalc.c --- a/monetdb5/modules/mal/batcalc.c +++ b/monetdb5/modules/mal/batcalc.c @@ -8,7 +8,7 @@ #include "monetdb_config.h" #include "gdk.h" -#include "math.h" +#include <math.h> #include "mal_exception.h" #include "mal_interpreter.h" diff --git a/monetdb5/modules/mal/calc.c b/monetdb5/modules/mal/calc.c --- a/monetdb5/modules/mal/calc.c +++ b/monetdb5/modules/mal/calc.c @@ -8,7 +8,7 @@ #include "monetdb_config.h" #include "gdk.h" -#include "math.h" +#include <math.h> #include "mal_exception.h" #include "mal_interpreter.h" diff --git a/sql/backends/monet5/Tests/pyloader01.sql b/sql/backends/monet5/Tests/pyloader01.sql --- a/sql/backends/monet5/Tests/pyloader01.sql +++ b/sql/backends/monet5/Tests/pyloader01.sql @@ -1,7 +1,7 @@ START TRANSACTION; -CREATE TABLE mytable(a DOUBLE, d int, s STRING DEFAULT 'hello'); +CREATE TABLE mytable(a DOUBLE, d int, s STRING); CREATE LOADER myfunc() LANGUAGE PYTHON { _emit.emit({'a':42,'d':1}) diff --git a/sql/backends/monet5/Tests/pyloader01.stable.out b/sql/backends/monet5/Tests/pyloader01.stable.out --- a/sql/backends/monet5/Tests/pyloader01.stable.out +++ b/sql/backends/monet5/Tests/pyloader01.stable.out @@ -52,11 +52,11 @@ Ready. % sys.mytable, sys.mytable, sys.mytable # table_name % a, d, s # name % double, int, clob # type -% 24, 1, 7 # length -[ 42, 1, "'hello'" ] +% 24, 1, 5 # length +[ 42, 1, NULL ] [ 46, 4, "hello" ] -[ 45, 3, "'hello'" ] -[ 44, 2, "'hello'" ] +[ 45, 3, NULL ] +[ 44, 2, NULL ] #DROP TABLE mytable; #DROP ALL LOADER myfunc; #CREATE LOADER myfunc() LANGUAGE PYTHON { diff --git a/sql/backends/monet5/UDF/pyapi/emit.c b/sql/backends/monet5/UDF/pyapi/emit.c --- a/sql/backends/monet5/UDF/pyapi/emit.c +++ b/sql/backends/monet5/UDF/pyapi/emit.c @@ -352,21 +352,19 @@ PyObject *PyEmit_Emit(PyEmitObject *self self->cols[i].b->tnonil = 1 - self->cols[i].b->tnil; } } else { - void* nill_value = ATOMnil(self->cols[i].b->ttype); - void* default_value = self->cols[i].def ? - self->cols[i].def : - nill_value; + if (self->cols[i].def != NULL) { + msg = GDKstrdup("Inserting into columns with default values is not supported currently."); + goto wrapup; + } for (ai = 0; ai < (size_t)el_count; ai++) { if (BUNappend(self->cols[i].b, - default_value, + ATOMnil(self->cols[i].b->ttype), 0) != GDK_SUCCEED) { goto wrapup; } } - if (BATatoms[self->cols[i].b->ttype].atomCmp(default_value, nill_value) == 0) { - self->cols[i].b->tnil = 1; - self->cols[i].b->tnonil = 0; - } + self->cols[i].b->tnil = 1; + self->cols[i].b->tnonil = 0; } BATsetcount(self->cols[i].b, self->nvals + el_count); } diff --git a/sql/backends/monet5/generator/generator.c b/sql/backends/monet5/generator/generator.c --- a/sql/backends/monet5/generator/generator.c +++ b/sql/backends/monet5/generator/generator.c @@ -16,7 +16,7 @@ #include "algebra.h" #include "generator.h" #include "mtime.h" -#include "math.h" +#include <math.h> #define IDENTITY(x) (x) diff --git a/sql/test/BugTracker-2017/Tests/python_loader_clobbers_default_with_null.Bug-6464.stable.err b/sql/test/BugTracker-2017/Tests/python_loader_clobbers_default_with_null.Bug-6464.stable.err --- a/sql/test/BugTracker-2017/Tests/python_loader_clobbers_default_with_null.Bug-6464.stable.err +++ b/sql/test/BugTracker-2017/Tests/python_loader_clobbers_default_with_null.Bug-6464.stable.err @@ -56,6 +56,102 @@ ERROR = !INSERT INTO: NOT NULL constrain MAPI = (monetdb) /var/tmp/mtest-17575/.s.monetdb.32655 QUERY = insert into t (a) values (-1); ERROR = !INSERT INTO: PRIMARY KEY constraint 't.t_a_pkey' violated +MAPI = (monetdb) /var/tmp/mtest-80053/.s.monetdb.38101 +QUERY = COPY LOADER INTO t FROM myloader(-30,'abcdeg'); +ERROR = !Python exception + ! 6. if j in y: + ! 7. z[j] = x - i + !> 8. _emit.emit(z) + ! 9. + !Failed conversion: Inserting into columns with default values is not supported currently. +MAPI = (monetdb) /var/tmp/mtest-80053/.s.monetdb.38101 +QUERY = COPY LOADER INTO t FROM myloader(-40,'abcdfg'); +ERROR = !Python exception + ! 6. if j in y: + ! 7. z[j] = x - i + !> 8. _emit.emit(z) + ! 9. + !Failed conversion: Inserting into columns with default values is not supported currently. +MAPI = (monetdb) /var/tmp/mtest-80053/.s.monetdb.38101 +QUERY = COPY LOADER INTO t FROM myloader(-50,'abcefg'); +ERROR = !Python exception + ! 6. if j in y: + ! 7. z[j] = x - i + !> 8. _emit.emit(z) + ! 9. + !Failed conversion: Inserting into columns with default values is not supported currently. +MAPI = (monetdb) /var/tmp/mtest-80053/.s.monetdb.38101 +QUERY = COPY LOADER INTO t FROM myloader(-60,'abdefg'); +ERROR = !Python exception + ! 6. if j in y: + ! 7. z[j] = x - i + !> 8. _emit.emit(z) + ! 9. + !Failed conversion: Inserting into columns with default values is not supported currently. +MAPI = (monetdb) /var/tmp/mtest-80053/.s.monetdb.38101 +QUERY = COPY LOADER INTO t FROM myloader(-70,'acdefg'); +ERROR = !Python exception + ! 6. if j in y: + ! 7. z[j] = x - i + !> 8. _emit.emit(z) + ! 9. + !Failed conversion: Inserting into columns with default values is not supported currently. +MAPI = (monetdb) /var/tmp/mtest-80053/.s.monetdb.38101 +QUERY = COPY LOADER INTO t FROM myloader(-80,'bcdefg'); +ERROR = !Python exception + ! 6. if j in y: + ! 7. z[j] = x - i + !> 8. _emit.emit(z) + ! 9. + !Failed conversion: Inserting into columns with default values is not supported currently. _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list