Changeset: 375033d6e4bd for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=375033d6e4bd Modified Files: Branch: default Log Message:
Merged from Apr2011 diffs (truncated from 346 to 300 lines): diff --git a/clients/mapiclient/ReadlineTools.c b/clients/mapiclient/ReadlineTools.c --- a/clients/mapiclient/ReadlineTools.c +++ b/clients/mapiclient/ReadlineTools.c @@ -73,7 +73,7 @@ if (!state) { seekpos = 0; len = strlen(text); - if ((table_hdl = mapi_query(_mid, "SELECT \"name\" FROM \"sys\".\"tables\"")) == NULL || mapi_error(_mid)) { + if ((table_hdl = mapi_query(_mid, "SELECT t.\"name\", s.\"name\" FROM \"sys\".\"tables\" t, \"sys\".\"schemas\" s where t.schema_id = s.id")) == NULL || mapi_error(_mid)) { if (table_hdl) { mapi_explain_query(table_hdl, stderr); mapi_close_handle(table_hdl); @@ -89,8 +89,17 @@ mapi_seek_row(table_hdl, seekpos++, MAPI_SEEK_SET); mapi_fetch_row(table_hdl); name = mapi_fetch_field(table_hdl, 0); - if (strncmp(name, text, len) == 0) - return strdup(name); + if (strncmp(name, text, len) == 0) { + char *s, *schema = mapi_fetch_field(table_hdl, 1); + int l1 = strlen(name), l2 = strlen(schema); + + s = malloc(l1 + l2 + 2); + s[0] = 0; + strcat(s, schema); + strcat(s, "."); + strcat(s, name); + return s; + } } return NULL; diff --git a/monetdb5/modules/atoms/mtime.mx b/monetdb5/modules/atoms/mtime.mx --- a/monetdb5/modules/atoms/mtime.mx +++ b/monetdb5/modules/atoms/mtime.mx @@ -581,6 +581,12 @@ command batmtime.seconds(d:bat[:any_1,:daytime]):bat[:any_1,:int] address MTIMEdaytime_extract_seconds_bulk; +command sql_seconds(d:daytime) :int +address MTIMEdaytime_extract_sql_seconds +comment "extracts seconds (with fractional milliseconds) from daytime"; +command batmtime.sql_seconds(d:bat[:any_1,:daytime]):bat[:any_1,:int] +address MTIMEdaytime_extract_sql_seconds_bulk; + command milliseconds(d:daytime) :int address MTIMEdaytime_extract_milliseconds comment "extracts milliseconds from daytime"; @@ -771,6 +777,8 @@ address MTIMEtimestamp_minutes; command seconds(t:timestamp):int address MTIMEtimestamp_seconds; +command sql_seconds(t:timestamp):int +address MTIMEtimestamp_sql_seconds; command milliseconds(t:timestamp):int address MTIMEtimestamp_milliseconds; @@ -986,6 +994,7 @@ 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); +mtime_export str MTIMEdaytime_extract_sql_seconds(int *ret, daytime *v); mtime_export str MTIMEdaytime_extract_milliseconds(int *ret, daytime *v); mtime_export str MTIMEtimestamp_extract_daytime(daytime *ret, timestamp *t, tzone *z); mtime_export str MTIMEtimestamp_extract_daytime_default(daytime *ret, timestamp *t); @@ -1012,6 +1021,7 @@ mtime_export str MTIMEtimestamp_hours(int *ret, timestamp *t); mtime_export str MTIMEtimestamp_minutes(int *ret, timestamp *t); mtime_export str MTIMEtimestamp_seconds(int *ret, timestamp *t); +mtime_export str MTIMEtimestamp_sql_seconds(int *ret, timestamp *t); mtime_export str MTIMEtimestamp_milliseconds(int *ret, timestamp *t); mtime_export str MTIMEsql_year(int *ret, int *t); mtime_export str MTIMEsql_month(int *ret, int *t); @@ -1093,6 +1103,7 @@ @:ExtractExport(daytime,hours)@ @:ExtractExport(daytime,minutes)@ @:ExtractExport(daytime,seconds)@ +@:ExtractExport(daytime,sql_seconds)@ @:ExtractExport(daytime,milliseconds)@ @@ -2302,6 +2313,20 @@ return GDK_SUCCEED; } +/* extracts (milli) seconds from daytime (value between 0 and 59000) */ +static inline int +daytime_extract_sql_seconds(int *ret, daytime *v) +{ + int sec, milli; + if (*v == daytime_nil) { + *ret = int_nil; + } else { + fromtime((int) *v, &dummy, &dummy, &sec, &milli); + *ret = sec* 1000 + milli; + } + return GDK_SUCCEED; +} + /* extracts milliseconds from daytime (value between 0 and 999) */ static inline int daytime_extract_milliseconds(int *ret, daytime *v) @@ -3303,6 +3328,13 @@ } str +MTIMEdaytime_extract_sql_seconds(int *ret, daytime *v) +{ + daytime_extract_sql_seconds(ret, v); + return MAL_SUCCEED; +} + +str MTIMEdaytime_extract_milliseconds(int *ret, daytime *v) { daytime_extract_milliseconds(ret, v); @@ -3955,6 +3987,14 @@ return MAL_SUCCEED; } str +MTIMEtimestamp_sql_seconds(int *ret, timestamp *t) +{ + daytime d; + timestamp_extract_daytime(&d, t, &tzone_local); + daytime_extract_sql_seconds(ret, &d); + return MAL_SUCCEED; +} +str MTIMEtimestamp_milliseconds(int *ret, timestamp *t) { daytime d; @@ -4052,6 +4092,7 @@ @:Extract(daytime,hours,int)@ @:Extract(daytime,minutes,int)@ @:Extract(daytime,seconds,int)@ +@:Extract(daytime,sql_seconds,int)@ @:Extract(daytime,milliseconds,int)@ str 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 @@ -1423,7 +1423,7 @@ sql_create_func("day", "mtime", "day", DTE, NULL, INT, SCALE_FIX); sql_create_func("hour", "mtime", "hours", TME, NULL, INT, SCALE_FIX); sql_create_func("minute", "mtime", "minutes", TME, NULL, INT, SCALE_FIX); - f = sql_create_func("second", "mtime", "milliseconds", TME, NULL, DEC, SCALE_NONE); + f = sql_create_func("second", "mtime", "sql_seconds", TME, NULL, DEC, SCALE_NONE); /* fix result type */ f->res.scale = 3; @@ -1432,7 +1432,7 @@ sql_create_func("day", "mtime", "day", TMESTAMP, NULL, INT, SCALE_FIX); sql_create_func("hour", "mtime", "hours", TMESTAMP, NULL, INT, SCALE_FIX); sql_create_func("minute", "mtime", "minutes", TMESTAMP, NULL, INT, SCALE_FIX); - f = sql_create_func("second", "mtime", "milliseconds", TMESTAMP, NULL, DEC, SCALE_NONE); + f = sql_create_func("second", "mtime", "sql_seconds", TMESTAMP, NULL, DEC, SCALE_NONE); /* fix result type */ f->res.scale = 3; diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c --- a/sql/storage/bat/bat_logger.c +++ b/sql/storage/bat/bat_logger.c @@ -27,15 +27,30 @@ bl_preversion( int oldversion, int newversion) { #define CATALOG_FEB2010 50000 +#define CATALOG_OCT2010 51000 (void)newversion; if (oldversion == CATALOG_FEB2010) { catalog_version = oldversion; return 0; } + if (oldversion == CATALOG_OCT2010) { + catalog_version = oldversion; + return 0; + } return -1; } +static char * +N( char *buf, char *pre, char *schema, char *post) +{ + if (pre) + snprintf(buf, 64, "%s_%s_%s", pre, schema, post); + else + snprintf(buf, 64, "%s_%s", schema, post); + return buf; +} + static void bl_postversion( void *lg) { @@ -94,6 +109,50 @@ /* mark that the rest is fixed on sql level */ } + if (catalog_version == CATALOG_OCT2010) { + BAT *b; + char *s = "sys", n[64]; + + fprintf(stdout, "# upgrading catalog from Oct2010\n"); + fflush(stdout); + + /* rename table 'keycolumns' into 'objects' + * and remove trunc column */ + while(s) { + b = temp_descriptor(logger_find_bat(lg, N(n, "D", s, "keycolumns"))); + if (!b) return ; + logger_del_bat(lg, b->batCacheid); + logger_add_bat(lg, b, N(n, "D", s, "objects")); + bat_destroy(b); + + b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s, "keycolumns_id"))); + if (!b) return ; + logger_del_bat(lg, b->batCacheid); + logger_add_bat(lg, b, N(n, NULL, s, "objects_id")); + bat_destroy(b); + + b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s, "keycolumns_column"))); + if (!b) return ; + logger_del_bat(lg, b->batCacheid); + logger_add_bat(lg, b, N(n, NULL, s, "objects_name")); + bat_destroy(b); + + b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s, "keycolumns_nr"))); + if (!b) return ; + logger_del_bat(lg, b->batCacheid); + logger_add_bat(lg, b, N(n, NULL, s, "objects_nr")); + bat_destroy(b); + + b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s, "keycolumns_trunc"))); + if (!b) return ; + logger_del_bat(lg, b->batCacheid); + bat_destroy(b); + if (strcmp(s,"sys") == 0) + s = "tmp"; + else + s = NULL; + } + } } static int diff --git a/sql/test/BugTracker-2011/Tests/All b/sql/test/BugTracker-2011/Tests/All --- a/sql/test/BugTracker-2011/Tests/All +++ b/sql/test/BugTracker-2011/Tests/All @@ -1,3 +1,4 @@ correlated-update.Bug-2771 double_erange.Bug-2774 view_avg_incorrect_result.Bug-2790 +extract_seconds.Bug-2793 diff --git a/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.sql b/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.sql @@ -0,0 +1,1 @@ +select extract(second from timestamp '2011-3-10 9:30:42.246'); diff --git a/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.stable.err b/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.stable.err @@ -0,0 +1,39 @@ +stderr of test 'extract_seconds.Bug-2793` in directory 'test/BugTracker-2011` itself: + + +# 11:57:21 > +# 11:57:21 > mserver5 --debug=10 --set gdk_nr_threads=0 --set "gdk_dbfarm=/ufs/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB" --set mapi_open=true --set mapi_port=36602 --set monet_prompt= --trace --forcemito --set mal_listing=2 "--dbname=mTests_test_BugTracker-2011" --set mal_listing=0 ; echo ; echo Over.. +# 11:57:21 > + +# builtin opt gdk_dbname = demo +# builtin opt gdk_dbfarm = /ufs/niels/scratch/rc-clean/Linux-x86_64/var/monetdb5/dbfarm +# builtin opt gdk_debug = 0 +# builtin opt gdk_alloc_map = no +# builtin opt gdk_vmtrim = yes +# builtin opt monet_prompt = > +# builtin opt monet_daemon = no +# builtin opt mapi_port = 50000 +# builtin opt mapi_open = false +# builtin opt mapi_autosense = false +# builtin opt default_pipe = inline,remap,evaluate,costModel,coercions,emptySet,aliases,mitosis,mergetable,deadcode,commonTerms,joinPath,reorder,deadcode,reduce,dataflow,history,multiplex,garbageCollector +# builtin opt minimal_pipe = inline,remap,deadcode,multiplex,garbageCollector +# builtin opt sql_optimizer = default_pipe +# builtin opt sql_debug = 0 +# cmdline opt gdk_nr_threads = 0 +# cmdline opt gdk_dbfarm = /ufs/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB +# cmdline opt mapi_open = true +# cmdline opt mapi_port = 36602 +# cmdline opt monet_prompt = +# cmdline opt mal_listing = 2 +# cmdline opt gdk_dbname = mTests_test_BugTracker-2011 +# cmdline opt mal_listing = 0 + +# 11:57:21 > +# 11:57:21 > mclient -lsql -ftest -i -e --host=alf --port=36602 +# 11:57:21 > + + +# 11:57:21 > _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list