Changeset: 4a76ac4a3ff6 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4a76ac4a3ff6 Added Files: sql/benchmarks/tpch/trace.sql sql/test/BugTracker-2013/Tests/binary_copy_into.Bug-3345.SQL.py sql/test/BugTracker-2013/Tests/binary_copy_into.Bug-3345.stable.err sql/test/BugTracker-2013/Tests/binary_copy_into.Bug-3345.stable.out sql/test/BugTracker-2013/Tests/duplicate_column_name.Bug-3349.sql sql/test/BugTracker-2013/Tests/duplicate_column_name.Bug-3349.stable.err sql/test/BugTracker-2013/Tests/duplicate_column_name.Bug-3349.stable.out sql/test/BugTracker-2013/Tests/iso8601_weekofyear.Bug-3232.sql sql/test/BugTracker-2013/Tests/iso8601_weekofyear.Bug-3232.stable.err sql/test/BugTracker-2013/Tests/iso8601_weekofyear.Bug-3232.stable.out sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.sql sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.err sql/test/BugTracker-2013/Tests/like_pcre_or.Bug-3348.stable.out Modified Files: HowToStart.rst clients/mapiclient/mclient.c clients/mapiclient/tomograph.c gdk/gdk_heap.c monetdb5/modules/atoms/mtime.c monetdb5/modules/atoms/mtime.h monetdb5/modules/atoms/mtime.mal monetdb5/modules/mal/pcre.c sql/backends/monet5/sql.mx sql/common/sql_types.c sql/scripts/mtime.sql sql/server/rel_select.c sql/test/BugTracker-2012/Tests/predicate_select.Bug-3090.stable.err sql/test/BugTracker-2012/Tests/predicate_select.Bug-3090.stable.out sql/test/BugTracker-2013/Tests/All sql/test/BugTracker-2013/Tests/qualified_aggrname.Bug-3332.stable.out sql/test/BugTracker/Tests/set_sql_debug_64__breaking_the_DB.SF-1906287.stable.out sql/test/leaks/Tests/check1.stable.out sql/test/leaks/Tests/check2.stable.out sql/test/leaks/Tests/check3.stable.out sql/test/leaks/Tests/check4.stable.out sql/test/leaks/Tests/check5.stable.out sql/test/mapi/Tests/php_monetdb.stable.out Branch: default Log Message:
merged with feb2013 diffs (truncated from 1288 to 300 lines): diff --git a/HowToStart.rst b/HowToStart.rst --- a/HowToStart.rst +++ b/HowToStart.rst @@ -73,6 +73,19 @@ autoconf/automake/libtool Make_ phase. autoconf and automake are not needed when you start with the source distribution. +iconv + A macrofile `iconv.m4` is expected in `/usr/share/aclocal/`. + On Ubuntu, you can search with `apt-file` what provides these + files: + + $ apt-file search iconv.m4 + gettext: /usr/share/aclocal/iconv.m4 + gnulib: /usr/share/gnulib/m4/iconv.m4 + + The .m4 that usually works is in gettext. Simply run, + + $ sudo apt-get install gettext + standard software development tools To compile MonetDB, you also need to have the following standard software development tools installed and ready for diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -2562,6 +2562,7 @@ set_timezone(Mapi mid) tmp = gmtime(&t); gt = mktime(tmp); tmp = localtime(&t); + tmp->tm_isdst=0; /* We need the difference without dst */ lt = mktime(tmp); assert((lng) gt - (lng) lt >= (lng) INT_MIN && (lng) gt - (lng) lt <= (lng) INT_MAX); tzone = (int) (gt - lt); diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c --- a/clients/mapiclient/tomograph.c +++ b/clients/mapiclient/tomograph.c @@ -1144,7 +1144,7 @@ static void showcolormap(char *filename, * "*.*" stays first (colors[0]) */ _clrs_ = (Color*) malloc (sizeof(colors)); if (_clrs_) { - *_clrs_ = *colors; + memcpy (_clrs_, colors, sizeof(colors)); qsort (_clrs_, NUM_COLORS, sizeof(Color), cmp_clr); clrs = _clrs_; } diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c --- a/gdk/gdk_heap.c +++ b/gdk/gdk_heap.c @@ -496,7 +496,7 @@ HEAPextend(Heap *h, size_t size) int HEAPshrink(Heap *h, size_t size) { - char *p; + char *p = NULL; assert(size >= h->free); assert(size <= h->size); @@ -517,6 +517,7 @@ HEAPshrink(Heap *h, size_t size) } /* shrink memory mapped file */ GDKfilepath(path, BATDIR, nme, ext); + size = MAX(size, MT_pagesize()); /* at least one page */ size = (size + MT_pagesize() - 1) & ~(MT_pagesize() - 1); if (size >= h->size) { /* don't grow */ diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c --- a/monetdb5/modules/atoms/mtime.c +++ b/monetdb5/modules/atoms/mtime.c @@ -427,6 +427,7 @@ parse_substr(int *ret, str s, int min, s return j; } +/* Sunday = 1, Saturday = 7 */ static int date_dayofweek(date v) { @@ -434,6 +435,17 @@ date_dayofweek(date v) return v <= 0 ? v + 7 : v; } +/* Monday = 1, Sunday = 7 */ +static int +date_dayofworkweek(date v) +{ + int res = date_dayofweek(v); + + if (res >= 2) + return res -1; + return 7; +} + #define SKIP_DAYS(d,w,i) d += i; w = (w + i)%7; if (w <= 0) w += 7; static date @@ -1310,10 +1322,10 @@ date_extract_weekofyear(int *ret, date * fromdate((int) *v, &dummy, &dummy, &year); year_jan_1 = todate(1, 1, year); - dayofweek = date_dayofweek(year_jan_1); + dayofweek = date_dayofworkweek(year_jan_1); if (dayofweek <= 4) { - /* week of jan 1 belongs to this year */ + /* 4 or more days in first week, ie week of jan 1 belongs to this year */ *ret = (int) (1 + (*v - year_jan_1 + dayofweek - 1) / 7); } else if (*v - year_jan_1 > 7 - dayofweek) { /* week of jan 1 belongs to last year; but this is a later week */ @@ -1340,6 +1352,18 @@ date_extract_dayofweek(int *ret, date *v return MAL_SUCCEED; } +/* Returns the current day of the week where 1=monday, .., 7=sunday */ +static str +date_extract_dayofworkweek(int *ret, date *v) +{ + if (*v == date_nil) { + *ret = int_nil; + } else { + *ret = date_dayofworkweek(*v); + } + return MAL_SUCCEED; +} + /* extracts hour from daytime (value between 0 and 23) */ static str daytime_extract_hours(int *ret, daytime *v) @@ -1959,6 +1983,12 @@ MTIMEdate_extract_dayofweek(int *ret, da } str +MTIMEdate_extract_dayofworkweek(int *ret, date *v) +{ + return date_extract_dayofworkweek(ret, v); +} + +str MTIMEdaytime_extract_hours(int *ret, daytime *v) { return daytime_extract_hours(ret, v); diff --git a/monetdb5/modules/atoms/mtime.h b/monetdb5/modules/atoms/mtime.h --- a/monetdb5/modules/atoms/mtime.h +++ b/monetdb5/modules/atoms/mtime.h @@ -163,6 +163,7 @@ mtime_export str MTIMEdate_extract_day(i mtime_export str MTIMEdate_extract_dayofyear(int *ret, date *v); mtime_export str MTIMEdate_extract_weekofyear(int *ret, date *v); mtime_export str MTIMEdate_extract_dayofweek(int *ret, date *v); +mtime_export str MTIMEdate_extract_dayofworkweek(int *ret, date *v); mtime_export str MTIMEdaytime_extract_hours(int *ret, daytime *v); mtime_export str MTIMEdaytime_extract_minutes(int *ret, daytime *v); mtime_export str MTIMEdaytime_extract_seconds(int *ret, daytime *v); diff --git a/monetdb5/modules/atoms/mtime.mal b/monetdb5/modules/atoms/mtime.mal --- a/monetdb5/modules/atoms/mtime.mal +++ b/monetdb5/modules/atoms/mtime.mal @@ -633,6 +633,10 @@ command dayofweek(d:date) :int address MTIMEdate_extract_dayofweek comment "Returns the current day of the week where 1=sunday, .., 7=saturday"; +command dayofworkweek(d:date) :int +address MTIMEdate_extract_dayofworkweek +comment "Returns the current day of the week + where 1=monday, .., 7=sunday"; command add(v:timestamp, msecs:lng) :timestamp address MTIMEtimestamp_add diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c --- a/monetdb5/modules/mal/pcre.c +++ b/monetdb5/modules/mal/pcre.c @@ -1088,7 +1088,7 @@ sql2pcre(str *r, const char *pat, const * expression. If the user used the "+" char as escape and has "++" * in its pattern, then replacing this with "+" is not correct and * should be "\+" instead. */ - specials = (*esc_str && strchr( ".+*()[]", esc) != NULL); + specials = (*esc_str && strchr( ".+*()[]|", esc) != NULL); *ppat++ = '^'; while ((c = *pat++) != 0) { @@ -1105,7 +1105,7 @@ sql2pcre(str *r, const char *pat, const escaped = 1; } hasWildcard = 1; - } else if (strchr(".?+*()[]\\", c) != NULL) { + } else if (strchr(".?+*()[]|\\", c) != NULL) { /* escape PCRE special chars, avoid double backslash if the * user uses an invalid escape sequence */ if (!escaped) @@ -1157,7 +1157,7 @@ pat2pcre(str *r, const char *pat) while (*pat) { int c = *pat++; - if (strchr( ".+*()\\", c) != NULL) { + if (strchr( ".+*()|\\", c) != NULL) { *ppat++ = '\\'; *ppat++ = c; } else if (c == '%') { diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx --- a/sql/backends/monet5/sql.mx +++ b/sql/backends/monet5/sql.mx @@ -783,6 +783,14 @@ comment "cast @1 to @1 and check for ove @:mal_casttime(timestamp)@ @:mal_casttime(daytime)@ +pattern current_time() :daytime +address SQLcurrent_daytime +comment "Get the clients current daytime"; + +pattern current_timestamp() :timestamp +address SQLcurrent_timestamp +comment "Get the clients current timestamp"; + command calc.date( v:void ) :date address nil_2_date comment "cast to date"; @@ -4383,8 +4391,8 @@ mvc_bin_import_table_wrap(Client cntxt, } else { throw(SQL, "sql", "failed to attach file %s", *(str*)getArgReference(stk, pci, i)); } - if (i!=(pci->retc + 2) && cnt != BATcount(c)) - throw(SQL, "sql", "table %s not found", tname); + if (i!=(pci->retc + 2) && cnt != BATcount(c)) + throw(SQL, "sql", "binary files for table '%s' have inconsistent counts", tname); cnt = BATcount(c); *(int*)getArgReference(stk, pci, i-(2+pci->retc)) = c->batCacheid; BBPkeepref(c->batCacheid); @@ -6385,6 +6393,8 @@ sql5_export str second_interval_daytime( sql5_export str second_interval_2_daytime( daytime *res, lng *s, int *d); sql5_export str timestamp_2_daytime( daytime *res, timestamp *v, int *d); sql5_export str date_2_timestamp( timestamp *res, date *v, int *d); +str SQLcurrent_daytime(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); +str SQLcurrent_timestamp(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); @c str second_interval_daytime( lng *res, daytime *s, int *d, int *sk ) @@ -6419,6 +6429,36 @@ second_interval_daytime( lng *res, dayti return MAL_SUCCEED; } +str SQLcurrent_daytime(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) +{ + mvc *m = NULL; + str msg = getSQLContext(cntxt, mb, &m, NULL); + daytime t, *res = (daytime *) getArgReference(stk, pci, 0); + + if (msg) + return msg; + + if ((msg = MTIMEcurrent_time(&t)) == MAL_SUCCEED) + *res = t+m->timezone; + return msg; +} + +str SQLcurrent_timestamp(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) +{ + mvc *m = NULL; + str msg = getSQLContext(cntxt, mb, &m, NULL); + timestamp t, *res = (timestamp *) getArgReference(stk, pci, 0); + + if (msg) + return msg; + + if ((msg = MTIMEcurrent_timestamp(&t)) == MAL_SUCCEED) { + lng offset = m->timezone; + return MTIMEtimestamp_add(res, &t, &offset); + } + return msg; +} + /* str dump_cache(int *r); */ str dump_cache(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) diff --git a/sql/benchmarks/tpch/trace.sql b/sql/benchmarks/tpch/trace.sql new file mode 100644 --- /dev/null +++ b/sql/benchmarks/tpch/trace.sql @@ -0,0 +1,1 @@ +trace diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c --- a/sql/common/sql_types.c +++ b/sql/common/sql_types.c @@ -1457,8 +1457,8 @@ sqltypeinit( sql_allocator *sa) sql_create_func(sa, "curtime", "mtime", "current_time", NULL, NULL, TMETZ, SCALE_NONE); sql_create_func(sa, "current_time", "mtime", "current_time", NULL, NULL, TMETZ, SCALE_NONE); sql_create_func(sa, "current_timestamp", "mtime", "current_timestamp", NULL, NULL, TMESTAMPTZ, SCALE_NONE); - sql_create_func(sa, "localtime", "mtime", "current_time", NULL, NULL, TME, SCALE_NONE); - sql_create_func(sa, "localtimestamp", "mtime", "current_timestamp", NULL, NULL, TMESTAMP, SCALE_NONE); + sql_create_func(sa, "localtime", "sql", "current_time", NULL, NULL, TME, SCALE_NONE); + sql_create_func(sa, "localtimestamp", "sql", "current_timestamp", NULL, NULL, TMESTAMP, SCALE_NONE); sql_create_func(sa, "sql_sub", "mtime", "date_sub_msec_interval", DTE, SECINT, DTE, SCALE_FIX); sql_create_func(sa, "sql_sub", "mtime", "date_sub_month_interval", DTE, MONINT, DTE, SCALE_FIX); @@ -1470,6 +1470,7 @@ sqltypeinit( sql_allocator *sa) sql_create_func(sa, "sql_sub", "mtime", "diff", DTE, DTE, INT, SCALE_FIX); sql_create_func(sa, "sql_sub", "mtime", "diff", TMESTAMP, TMESTAMP, LNG, SCALE_FIX); + sql_create_func(sa, "sql_sub", "mtime", "diff", TMESTAMPTZ, TMESTAMPTZ, LNG, SCALE_NONE); sql_create_func(sa, "sql_add", "mtime", "date_add_msec_interval", DTE, SECINT, DTE, SCALE_NONE); sql_create_func(sa, "sql_add", "mtime", "addmonths", DTE, MONINT, DTE, SCALE_NONE); @@ -1498,6 +1499,15 @@ sqltypeinit( sql_allocator *sa) /* fix result type */ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list