Changeset: 18396d5a6050 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=18396d5a6050 Modified Files: clients/Tests/exports.stable.out gdk/gdk_select.c java/ChangeLog.Jun2016 java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java monetdb5/mal/mal_instruction.c monetdb5/mal/mal_namespace.c sql/backends/monet5/sql_decimal.mal sql/backends/monet5/sql_decimal.mal.sh sql/backends/monet5/sql_decimal_hge.mal sql/backends/monet5/sql_decimal_hge.mal.sh sql/test/BugTracker-2009/Tests/explain_gives_crash.SF-2741829.stable.out sql/test/BugTracker-2013/Tests/between.Bug-3259.stable.out sql/test/BugTracker-2013/Tests/between.Bug-3259.stable.out.int128 sql/test/BugTracker-2013/Tests/between.Bug-3259.stable.out.int128.single sql/test/BugTracker-2016/Tests/All sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128 testing/Mfilter.py testing/Mtest.py.in Branch: jit Log Message:
Merge with default diffs (truncated from 2853 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -1567,7 +1567,6 @@ int OPTmultiplexImplementation(Client cn str OPTmultiplexSimple(Client cntxt, MalBlkPtr mb); str OPTorcam(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); int OPTorcamImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); -int OPTpostfixImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); int OPTprofilerImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); int OPTprojectionpathImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); int OPTpushselectImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1955,6 +1955,8 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT oid rlval = oid_nil, rhval = oid_nil; int sorted = 0; /* which column is sorted */ BAT *tmp; + int use_orderidx = 0; + oid ll, lh; assert(BAThdense(l)); assert(BAThdense(rl)); @@ -1971,12 +1973,13 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT assert(r2->htype == TYPE_void); assert(r2->ttype == TYPE_oid); - ALGODEBUG fprintf(stderr, "#rangejoin(l=%s#" BUNFMT "[%s]%s%s," + ALGODEBUG fprintf(stderr, "#rangejoin(l=%s#" BUNFMT "[%s]%s%s%s," "rl=%s#" BUNFMT "[%s]%s%s,rh=%s#" BUNFMT "[%s]%s%s," "sl=%s#" BUNFMT "%s%s,sr=%s#" BUNFMT "%s%s)\n", BATgetId(l), BATcount(l), ATOMname(l->ttype), l->tsorted ? "-sorted" : "", l->trevsorted ? "-revsorted" : "", + BATcheckorderidx(l) ? "-orderedidx" : "", BATgetId(rl), BATcount(rl), ATOMname(rl->ttype), rl->tsorted ? "-sorted" : "", rl->trevsorted ? "-revsorted" : "", @@ -2033,7 +2036,17 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT lvars = rlvars = rhvars = NULL; } - if (BATordered(l) || BATordered_rev(l)) { + ll = l->hseqbase; + lh = ll + l->batCount; + if ((!sl || (sl && BATtdense(sl))) && + (BATcheckorderidx(l) || (VIEWtparent(l) && BATcheckorderidx(BBPquickdesc(abs(VIEWtparent(l)), 0))))) { + use_orderidx = 1; + if (VIEWtparent(l) && !BATcheckorderidx(l)) { + l = BBPdescriptor(abs(VIEWtparent(l))); + } + } + + if (BATordered(l) || BATordered_rev(l) || use_orderidx) { /* left column is sorted, use binary search */ const oid *sval = sl ? (const oid *) Tloc(sl, BUNfirst(sl)) : NULL; @@ -2080,18 +2093,19 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT } if (cmp(vrl, nil) == 0 || cmp(vrh, nil) == 0) continue; - if (l->tsorted) { + if (l->tsorted || use_orderidx) { if (li) - low = SORTfndfirst(l, vrl); + low = use_orderidx? ORDERfndfirst(l, vrl): SORTfndfirst(l, vrl); else - low = SORTfndlast(l, vrl); + low = use_orderidx? ORDERfndlast(l, vrl): SORTfndlast(l, vrl); low -= BUNfirst(l); if (hi) - high = SORTfndlast(l, vrh); + high = use_orderidx? ORDERfndlast(l, vrh): SORTfndlast(l, vrh); else - high = SORTfndfirst(l, vrh); + high = use_orderidx? ORDERfndfirst(l, vrh): SORTfndfirst(l, vrh); high -= BUNfirst(l); } else { + assert(l->trevsorted); if (li) low = SORTfndlast(l, vrh); else @@ -2107,14 +2121,20 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT continue; low += l->hseqbase; high += l->hseqbase; - if (sl) { + if (use_orderidx) { + const oid *ord; oid o; + ord = (const oid *) l->torderidx->base + ORDERIDXOFF; - o = (oid) low; - low = SORTfndfirst(sl, &o) - BUNfirst(sl); - o = (oid) high; - high = SORTfndfirst(sl, &o) - BUNfirst(sl); - assert(high >= low); + if (sl) { + assert(BATtdense(sl)); + o = (oid) ((*(ord+low))&BUN_UNMSK); + ll = SORTfndfirst(sl, &o) - BUNfirst(sl); + o = (oid) ((*(ord+high))&BUN_UNMSK); + lh = SORTfndfirst(sl, &o) - BUNfirst(sl); + } + assert(lh >= ll); + if (BATcapacity(r1) < BUNlast(r1) + high - low) { cnt = BUNlast(r1) + high - low + 1024; if (cnt > maxsize) @@ -2128,30 +2148,64 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT dst1 = (oid *) Tloc(r1, BUNfirst(r1)); dst2 = (oid *) Tloc(r2, BUNfirst(r2)); } + + ord += low; while (low < high) { - dst1[r1->batCount++] = sval[low]; - dst2[r2->batCount++] = ro; - low++; + if (ll <= ((*ord)&BUN_UNMSK) && ((*ord)&BUN_UNMSK) < lh) { + dst1[r1->batCount++] = ((*ord)&BUN_UNMSK); + dst2[r2->batCount++] = ro; + low++; + ord++; + } } } else { - /* [low..high) */ - if (BATcapacity(r1) < BUNlast(r1) + high - low) { - cnt = BUNlast(r1) + high - low + 1024; - if (cnt > maxsize) - cnt = maxsize; - BATsetcount(r1, BATcount(r1)); - BATsetcount(r2, BATcount(r2)); - if (BATextend(r1, cnt) != GDK_SUCCEED || - BATextend(r2, cnt) != GDK_SUCCEED) - goto bailout; - assert(BATcapacity(r1) == BATcapacity(r2)); - dst1 = (oid *) Tloc(r1, BUNfirst(r1)); - dst2 = (oid *) Tloc(r2, BUNfirst(r2)); - } - while (low < high) { - dst1[r1->batCount++] = low; - dst2[r2->batCount++] = ro; - low++; + if (sl) { + oid o; + + o = (oid) low; + low = SORTfndfirst(sl, &o) - BUNfirst(sl); + o = (oid) high; + high = SORTfndfirst(sl, &o) - BUNfirst(sl); + assert(high >= low); + + if (BATcapacity(r1) < BUNlast(r1) + high - low) { + cnt = BUNlast(r1) + high - low + 1024; + if (cnt > maxsize) + cnt = maxsize; + BATsetcount(r1, BATcount(r1)); + BATsetcount(r2, BATcount(r2)); + if (BATextend(r1, cnt) != GDK_SUCCEED || + BATextend(r2, cnt) != GDK_SUCCEED) + goto bailout; + assert(BATcapacity(r1) == BATcapacity(r2)); + dst1 = (oid *) Tloc(r1, BUNfirst(r1)); + dst2 = (oid *) Tloc(r2, BUNfirst(r2)); + } + while (low < high) { + dst1[r1->batCount++] = sval[low]; + dst2[r2->batCount++] = ro; + low++; + } + } else { + /* [low..high) */ + if (BATcapacity(r1) < BUNlast(r1) + high - low) { + cnt = BUNlast(r1) + high - low + 1024; + if (cnt > maxsize) + cnt = maxsize; + BATsetcount(r1, BATcount(r1)); + BATsetcount(r2, BATcount(r2)); + if (BATextend(r1, cnt) != GDK_SUCCEED || + BATextend(r2, cnt) != GDK_SUCCEED) + goto bailout; + assert(BATcapacity(r1) == BATcapacity(r2)); + dst1 = (oid *) Tloc(r1, BUNfirst(r1)); + dst2 = (oid *) Tloc(r2, BUNfirst(r2)); + } + while (low < high) { + dst1[r1->batCount++] = low; + dst2[r2->batCount++] = ro; + low++; + } } } } diff --git a/java/ChangeLog.Jun2016 b/java/ChangeLog.Jun2016 --- a/java/ChangeLog.Jun2016 +++ b/java/ChangeLog.Jun2016 @@ -1,6 +1,12 @@ # ChangeLog file for java # This file is updated with Maddlog +* Thu May 19 2016 Martin van Dinther <martin.van.dint...@monetdbsolutions.com> +- Implemented MonetDatabaseMetaData.supportsConvert() and + MonetDatabaseMetaData.supportsConvert(int fromType, int toType) methods. + It used to always return false. Now it returns true for the supported conversions. + This fixes Bug 3460. + * Sun May 8 2016 Jennie Zhang <y.zh...@cwi.nl> - ResultSet.setFetchSize(): added a dummy implementation to get rid of the SQLFeatureNotSupportedException. In MonetDB, it does not diff --git a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java --- a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java @@ -396,48 +396,16 @@ public class MonetDatabaseMetaData exten /** * Get a comma separated list of all a database's SQL keywords that * are NOT also SQL:2003 keywords. - * * * @return a comma separated list of MonetDB keywords */ @Override public String getSQLKeywords() { - StringBuilder sb = new StringBuilder(1000); - Statement st = null; - ResultSet rs = null; - try { - st = con.createStatement(); - rs = st.executeQuery("SELECT \"keyword\" FROM \"sys\".\"keywords\" ORDER BY 1"); - // Fetch the keywords and concatenate them into a StringBuffer separated by comma's - boolean isfirst = true; - while (rs.next()) { - String keyword = rs.getString(1); - if (keyword != null) { - if (isfirst) { - isfirst = false; - } else { - sb.append(","); - } - sb.append(keyword); - } - } - } catch (SQLException e) { - /* This may occur for old (before Jul2015 release) MonetDB servers which do not have the sys.keywords table. */ - } finally { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { /* ignore */ } - } - if (st != null) { - try { - st.close(); - } catch (SQLException e) { /* ignore */ } - } - } - - return (sb.length() > 0) ? sb.toString() : - /* else fallback and return old static list (as returned in clients/odbc/driver/SQLGetInfo.c case SQL_KEYWORDS:) */ + String keywords = getConcatenatedStringFromQuery("SELECT \"keyword\" FROM \"sys\".\"keywords\" ORDER BY 1"); + + /* An old MonetDB server (pre Jul2015 release) will not have a table sys.keywords and return an empty String */ + return (keywords.length() > 0) ? keywords : + /* for old servers return static list (as returned in clients/odbc/driver/SQLGetInfo.c case SQL_KEYWORDS:) */ "ADMIN,AFTER,AGGREGATE,ALWAYS,ASYMMETRIC,ATOMIC," + "AUTO_INCREMENT,BEFORE,BIGINT,BIGSERIAL,BINARY,BLOB," + "CALL,CHAIN,CLOB,COMMITTED,COPY,CORR,CUME_DIST," + @@ -460,68 +428,32 @@ public class MonetDatabaseMetaData exten } /** - * getMonetDBSysFunctions(int kind) - * args: int kind, value must be 1 or 2 or 3 or 4. - * internal utility method to query the MonetDB sys.functions table - * to dynamically get the function names (for a specific kind) and - * concatenate the function names into a comma separated list. + * Internal utility method getConcatenatedStringFromQuery(String query) + * args: query: SQL SELECT query. Only the output of the first column is concatenated. + * @return a String of query result values concatenated into one string, and values separated by comma's */ - private String getMonetDBSysFunctions(int kind) { - // where clause part (for num/str/timedate to match only functions whose 1 arg exists and is of a certain type - String part1 = "WHERE \"id\" IN (SELECT \"func_id\" FROM \"sys\".\"args\" WHERE \"number\" = 1 AND \"name\" = 'arg_1' AND \"type\" IN "; - String whereClause = ""; - switch (kind) { - case 1: /* numeric functions */ - whereClause = part1 + - "('tinyint', 'smallint', 'int', 'bigint', 'decimal', 'real', 'double') )" + - // exclude 2 functions which take an int as arg but returns a char or str - " AND \"name\" NOT IN ('code', 'space')"; - break; - case 2: /* string functions */ - whereClause = part1 + - "('char', 'varchar', 'clob') )" + - // include 2 functions which take an int as arg but returns a char or str - " OR \"name\" IN ('code', 'space')"; - break; - case 3: /* system functions */ - whereClause = "WHERE \"id\" NOT IN (SELECT \"func_id\" FROM \"sys\".\"args\" WHERE \"number\" = 1)" + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list