MonetDB: wlcr - Added a replicate stop command.
Changeset: 84db3ebd9b79 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=84db3ebd9b79 Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out monetdb5/modules/mal/wlcr.c monetdb5/modules/mal/wlcr.h monetdb5/modules/mal/wlcr.mal sql/backends/monet5/sql_wlcr.c sql/scripts/60_wlcr.sql Branch: wlcr Log Message: Added a replicate stop command. diffs (137 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -8793,6 +8793,7 @@ Ready. [ "wlcr", "revoke_function", "pattern wlcr.revoke_function(sname:str, fcnid:int, grantee:str, privs:int, grant:int, grantor:int):void ", "WLCRgeneric;", "Catalog operation revoke_function" ] [ "wlcr", "revoke_roles", "pattern wlcr.revoke_roles(sname:str, auth:str, grantor:int, admin:int):void ", "WLCRgeneric;", "Catalog operation revoke_roles"] [ "wlcr", "rollback", "pattern wlcr.rollback():void ", "WLCRcommitCmd;", "Rollback the workload-capture-replay record" ] +[ "wlcr", "stop", "pattern wlcr.stop():void ","WLCRstop;", "Terminate keeping a log on this branch"] [ "wlcr", "transaction", "pattern wlcr.transaction():void ", "WLCRgeneric;", "Start an autocommit transaction" ] [ "wlcr", "transaction_begin","pattern wlcr.transaction_begin(chain:int, name:str):void ","WLCRgeneric;", "A transaction statement (type can be commit,release,rollback or start)"] [ "wlcr", "transaction_commit", "pattern wlcr.transaction_commit(chain:int, name:str):void ", "WLCRgeneric;", "A transaction statement (type can be commit,release,rollback or start)"] diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -11158,6 +11158,7 @@ Ready. [ "wlcr", "revoke_function", "pattern wlcr.revoke_function(sname:str, fcnid:int, grantee:str, privs:int, grant:int, grantor:int):void ", "WLCRgeneric;", "Catalog operation revoke_function" ] [ "wlcr", "revoke_roles", "pattern wlcr.revoke_roles(sname:str, auth:str, grantor:int, admin:int):void ", "WLCRgeneric;", "Catalog operation revoke_roles"] [ "wlcr", "rollback", "pattern wlcr.rollback():void ", "WLCRcommitCmd;", "Rollback the workload-capture-replay record" ] +[ "wlcr", "stop", "pattern wlcr.stop():void ","WLCRstop;", "Terminate keeping a log on this branch"] [ "wlcr", "transaction", "pattern wlcr.transaction():void ", "WLCRgeneric;", "Start an autocommit transaction" ] [ "wlcr", "transaction_begin","pattern wlcr.transaction_begin(chain:int, name:str):void ","WLCRgeneric;", "A transaction statement (type can be commit,release,rollback or start)"] [ "wlcr", "transaction_commit", "pattern wlcr.transaction_commit(chain:int, name:str):void ", "WLCRgeneric;", "A transaction statement (type can be commit,release,rollback or start)"] 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 @@ -1896,6 +1896,7 @@ str WLCRmaster(Client cntxt, MalBlkPtr m str WLCRquery(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str WLCRrollback(Client cntxt); str WLCRrollbackCmd(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); +str WLCRstop(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str WLCRupdate(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str XMLattribute(xml *ret, str *name, str *val); str XMLcomment(xml *x, str *s); diff --git a/monetdb5/modules/mal/wlcr.c b/monetdb5/modules/mal/wlcr.c --- a/monetdb5/modules/mal/wlcr.c +++ b/monetdb5/modules/mal/wlcr.c @@ -142,14 +142,16 @@ WLCRinit(Client cntxt) if (dbname){ dir = GDKfilepath(0,0,"master",0); snprintf(path, PATHLENGTH,"%s%cwlcr",dir, DIR_SEP); -#ifdef _WLCR_DEBUG_ - mnstr_printf(cntxt->fdout,"#Testing WLCR %s\n", path); -#endif wlcr_start = 0; fd = fopen(path,"r"); if( fd){ // database is in master tracking mode if( fscanf(fd,"%d %d", _batch, _threshold) == 2){ + if( wlcr_batch < 0){ + // logging was stopped + (void) fclose(fd); + return MAL_SUCCEED; + } wlcr_dir = dir; #ifdef
MonetDB: wlcr - Update the documentation
Changeset: f3db94220e3d for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f3db94220e3d Modified Files: monetdb5/modules/mal/wlcr.c Branch: wlcr Log Message: Update the documentation diffs (84 lines): diff --git a/monetdb5/modules/mal/wlcr.c b/monetdb5/modules/mal/wlcr.c --- a/monetdb5/modules/mal/wlcr.c +++ b/monetdb5/modules/mal/wlcr.c @@ -11,56 +11,56 @@ * This module collects the workload-capture-replay statements during transaction execution. * It is used primarilly for replication management and workload replay * - * The goal is to create and use a replica of a master database. All data of the master + * The goal is to easily clone a master database. All data of the master * is basically only available for read only access. Accidental corruption of this * data is avoided by setting ownership and access properties at the SQL level in the replica. * * * IMPLEMENTATION * - * A database can be set into 'master' mode only once. - * As default we use dbfarm/master to collect the necessary information. + * A database can be set into 'master' mode only once using the SQL command: + * CALL master() * - * The binary dump for the database snapshot should be stored there in master/bat. + * It creates directory .../dbfarm/dbname/master to hold all necessary information + * for the creation and maintenance of replicas. + * + * Every replica should start off with a copy of binary snapshot stored + * in .../dbfarm/dbname/master/bat or an empty database. * The associated log files are stored as master/wlcr. - * Creation and restore of a snapshot should be a monetdb option. TODO - * - * Replication management start when you run the command - * CALL wlcr.master() - * It can also be activated as a command line parameter - * --set wlcr=yes * * Each wlcr log file contains a serial log for a transaction batch. * Each job is identified by the owner of the query, - * commit/rollback, its starting time and runtime (in ms). + * commit/rollback status, its starting time and runtime (in ms). * * Logging of queries can be further limited to those that satisfy a threshold. - * CALL wlcr.master(threshold) + * CALL master(threshold) * The threshold is given in milliseconds. A negative threshold leads to ignoring all queries. * * A replica server should issue the matching call - * CALL wlcr.synchronize("dbname") + * CALL clone("dbname") + * It (should) leads to taking a copy of the snapshot following by server restart[TODO] + * and processing of the log files starts in the background. + * Queries are simply ignored unless needed as replacement for catalog actions. + * [TODO] the user might wait until the database is fresh + * [TODO] the user might want to take a time-stamped version only, ignoring all actions afterwards. * - * During synchronization only updates are executed. - * Queries are simply ignored unless needed as replacement for update actions. + * The alternative is to replay the complete log + * CALL replay("dbname") + * In this mode all queries are executed under the credentials of the query owner[TODO], + * including those that lead to updates. * - * The alternative is to replay the log - * CALL wlcr.replay("dbname") - * In this mode all queries are executed under the credentials of the query owner, including those that lead to updates. + * Any failure encountered during a log replay terminates the process, + * leaving a message in the merovingian log. * - * Any failure encountered terminates the synchronization process, leaving a message in the merovingian log. - * - * The replay progress can be inspected using the function wlcr.synced(). + * [TODO]The progress can be inspected using the boolean function wlcr.synced(). * The latter is true if all accessible log files have been processed. * * The wlcr files purposely have a textual format derived from the MAL statements. - * It creates some overhead for copy into situations. + * Simplicity and ease of control has been the driving argument here. * * The integrity of the wlcr directories is critical. For now we assume that all batches are available. * We should detect that wlcr.master() is issued after updates have taken place on the snapshot TODO. * - * The WLCR logs are always private a given thread - * */ #include "monetdb_config.h" #include ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: wlcr - merge with default
Changeset: fa99b99c33bf for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fa99b99c33bf Added Files: sql/test/BugTracker-2017/Tests/all_dates.csv.gz sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.sql sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.stable.err sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.stable.out sql/test/BugTracker-2017/Tests/heapextend.Bug-6134.sql.in Modified Files: gdk/gdk_cross.c gdk/gdk_select.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_statement.c sql/storage/bat/bat_table.c sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.out sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out sql/test/BugTracker-2017/Tests/All Branch: wlcr Log Message: merge with default diffs (truncated from 2124 to 300 lines): diff --git a/gdk/gdk_cross.c b/gdk/gdk_cross.c --- a/gdk/gdk_cross.c +++ b/gdk/gdk_cross.c @@ -9,49 +9,7 @@ #include "monetdb_config.h" #include "gdk.h" #include "gdk_private.h" - -static gdk_return -BATcross1(BAT **r1p, BAT **r2p, BAT *l, BAT *r) -{ - BAT *bn1, *bn2; - BUN i, j; - oid *restrict p1, *restrict p2; - - bn1 = COLnew(0, TYPE_oid, BATcount(l) * BATcount(r), TRANSIENT); - bn2 = COLnew(0, TYPE_oid, BATcount(l) * BATcount(r), TRANSIENT); - if (bn1 == NULL || bn2 == NULL) { - BBPreclaim(bn1); - BBPreclaim(bn2); - return GDK_FAIL; - } - p1 = (oid *) Tloc(bn1, 0); - p2 = (oid *) Tloc(bn2, 0); - for (i = 0; i < BATcount(l); i++) { - for (j = 0; j < BATcount(r); j++) { - *p1++ = i + l->hseqbase; - *p2++ = j + r->hseqbase; - } - } - BATsetcount(bn1, BATcount(l) * BATcount(r)); - BATsetcount(bn2, BATcount(l) * BATcount(r)); - bn1->tsorted = 1; - bn1->trevsorted = BATcount(l) <= 1; - bn1->tkey = BATcount(r) <= 1; - bn1->tdense = bn1->tkey != 0; - bn1->tnil = 0; - bn1->tnonil = 1; - bn2->tsorted = BATcount(l) <= 1; - bn2->trevsorted = BATcount(bn2) <= 1; - bn2->tkey = BATcount(l) <= 1; - bn2->tdense = bn2->tkey != 0; - bn2->tnil = 0; - bn2->tnonil = 1; - BATtseqbase(bn1, l->hseqbase); - BATtseqbase(bn2, r->hseqbase); - *r1p = bn1; - *r2p = bn2; - return GDK_SUCCEED; -} +#include "gdk_cand.h" /* Calculate a cross product between bats l and r with optional * candidate lists sl for l and sr for r. @@ -60,28 +18,75 @@ BATcross1(BAT **r1p, BAT **r2p, BAT *l, gdk_return BATsubcross(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr) { - BAT *bn1, *bn2, *t; + BAT *bn1, *bn2; + BUN start1, start2; + BUN end1, end2; + BUN cnt1, cnt2; + const oid *restrict lcand, *restrict rcand; + const oid *lcandend, *rcandend; + oid seq; + oid *restrict p; + BUN i, j; - if (BATcross1(, , sl ? sl : l, sr ? sr : r) != GDK_SUCCEED) + CANDINIT(l, sl, start1, end1, cnt1, lcand, lcandend); + CANDINIT(r, sr, start2, end2, cnt2, rcand, rcandend); + if (lcand) + cnt1 = lcandend - lcand; + if (rcand) + cnt2 = rcandend - rcand; + + bn1 = COLnew(0, TYPE_oid, cnt1 * cnt2, TRANSIENT); + if (bn1 == NULL) return GDK_FAIL; - if (sl) { - t = BATproject(bn1, sl); - BBPunfix(bn1->batCacheid); - if (t == NULL) { - BBPunfix(bn2->batCacheid); - return GDK_FAIL; - } - bn1 = t; + BATsetcount(bn1, cnt1 * cnt2); + bn1->tsorted = 1; + bn1->trevsorted = cnt1 <= 1; + bn1->tkey = cnt2 <= 1; + bn1->tnil = 0; + bn1->tnonil = 1; + p = (oid *) Tloc(bn1, 0); + if (lcand) { + for (i = 0; i < cnt1; i++) + for (j = 0; j < cnt2; j++) + *p++ = lcand[i]; + bn1->tdense = 0; + } else { + seq = l->hseqbase + start1; + for (i = 0; i < cnt1; i++) + for (j = 0; j < cnt2; j++) + *p++ = i + seq; + bn1->tdense = bn1->tkey != 0; + if (bn1->tdense) + BATtseqbase(bn1, seq); } - if (sr) { - t = BATproject(bn2, sr); - BBPunfix(bn2->batCacheid); - if (t == NULL) { - BBPunfix(bn1->batCacheid); - return GDK_FAIL; - } - bn2 = t; + + bn2 = COLnew(0, TYPE_oid, cnt1 * cnt2, TRANSIENT); + if (bn2 == NULL) { +
monetdb-java: embedded - Added the directory property for the em...
Changeset: 64530632dc2a for monetdb-java URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=64530632dc2a Modified Files: src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in Branch: embedded Log Message: Added the directory property for the embedded connection again. diffs (52 lines): diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @@ -1113,7 +1113,7 @@ public abstract class MonetConnection ex if (name.equals("host") || name.equals("port") || name.equals("user") || name.equals("password") || name.equals("database") || name.equals("language") || name.equals("so_timeout") || name.equals("hash") || name.equals("treat_blob_as_binary") || name.equals("follow_redirects") || -name.equals("treat_clob_as_longvarchar") || name.equals("embedded")) { +name.equals("treat_clob_as_longvarchar") || name.equals("embedded") || name.equals("directory")) { conn_props.setProperty(name, value); } else { addWarning("setClientInfo: " + name + "is not a recognised property", "01M07"); diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in @@ -193,6 +193,11 @@ final public class MonetDriver implement prop.description = "Whether or not to use an embedded MonetDB connection"; props.add(prop); + prop = new DriverPropertyInfo("directory", ""); + prop.required = false; + prop.description = "Sets the directory to set the database in a embedded connection (Embedded connection only)"; + props.add(prop); + DriverPropertyInfo[] dpi = new DriverPropertyInfo[props.size()]; return props.toArray(dpi); } @@ -421,15 +426,19 @@ final public class MonetDriver implement if(isEmbedded) { //instantiate the connection try { +String directory = props.getProperty("directory"); +if (directory == null || directory.trim().isEmpty()) +throw new IllegalArgumentException("directory should not be null or empty"); + if(EmbeddedConnectionClass == null) { EmbeddedConnectionClass = Class.forName("nl.cwi.monetdb.embedded.jdbc.EmbeddedConnection"); +if(EmbeddedConnectionClass == null) { //if it's still null then there is a problem +throw new SQLException("EmbeddedConnection Class not found! Please load the MonetDBJavaEmbedded JAR!"); +} } - if(EmbeddedConnectionClass == null) { //if it's still null then there is a problem - throw new SQLException("EmbeddedConnection Class not found!"); - } res = (MonetConnection) EmbeddedConnectionClass -.getDeclaredConstructor(Properties.class, String.class, String.class) -.newInstance(props, hash, language); +.getDeclaredConstructor(Properties.class, String.class, String.class, String.class) +.newInstance(props, hash, language, directory); } catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException e) { throw new SQLException(e); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
monetdb-java: embedded - Added the remaining documentation.
Changeset: 1dcb51573c89 for monetdb-java URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=1dcb51573c89 Removed Files: src/main/java/nl/cwi/monetdb/mcl/protocol/newmapi/NewMapiProtocol.java Modified Files: src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java src/main/java/nl/cwi/monetdb/mcl/connection/ControlCommands.java src/main/java/nl/cwi/monetdb/mcl/connection/IMonetDBLanguage.java src/main/java/nl/cwi/monetdb/mcl/connection/MCLException.java src/main/java/nl/cwi/monetdb/mcl/connection/SenderThread.java src/main/java/nl/cwi/monetdb/mcl/connection/helpers/BufferReallocator.java src/main/java/nl/cwi/monetdb/mcl/connection/helpers/ChannelSecurity.java src/main/java/nl/cwi/monetdb/mcl/connection/helpers/GregorianCalendarParser.java src/main/java/nl/cwi/monetdb/mcl/connection/mapi/AbstractSocket.java src/main/java/nl/cwi/monetdb/mcl/connection/mapi/MapiConnection.java src/main/java/nl/cwi/monetdb/mcl/connection/mapi/MapiLanguage.java src/main/java/nl/cwi/monetdb/mcl/connection/mapi/OldMapiSocket.java src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java src/main/java/nl/cwi/monetdb/mcl/protocol/ProtocolException.java src/main/java/nl/cwi/monetdb/mcl/protocol/ServerResponses.java src/main/java/nl/cwi/monetdb/mcl/protocol/StarterHeaders.java src/main/java/nl/cwi/monetdb/mcl/protocol/TableResultHeaders.java src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiServerResponseParser.java src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiStartOfHeaderParser.java src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTableHeaderParser.java src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParser.java src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParserHelper.java src/main/java/nl/cwi/monetdb/mcl/responses/AutoCommitResponse.java src/main/java/nl/cwi/monetdb/mcl/responses/DataBlockResponse.java src/main/java/nl/cwi/monetdb/mcl/responses/IIncompleteResponse.java src/main/java/nl/cwi/monetdb/mcl/responses/IResponse.java src/main/java/nl/cwi/monetdb/mcl/responses/ResultSetResponse.java src/main/java/nl/cwi/monetdb/mcl/responses/SchemaResponse.java src/main/java/nl/cwi/monetdb/mcl/responses/UpdateResponse.java Branch: embedded Log Message: Added the remaining documentation. diffs (truncated from 1862 to 300 lines): diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @@ -51,7 +51,7 @@ public abstract class MonetConnection ex return SeqCounter; } -/** the successful processed input properties */ +/** The successful processed input properties */ protected final Properties conn_props; /** The language to connect with */ protected IMonetDBLanguage language; @@ -110,8 +110,7 @@ public abstract class MonetConnection ex } /** - * Connects to the given host and port, logging in as the given user. If followRedirect is false, a - * RedirectionException is thrown when a redirect is encountered. + * Connects to the server, authenticating the user. * * @return A List with informational (warning) messages. If this list is empty; then there are no warnings. * @throws IOException if an I/O error occurs when creating the socket @@ -120,20 +119,67 @@ public abstract class MonetConnection ex */ public abstract List connect(String user, String pass) throws IOException, ProtocolException, MCLException; +/** + * Gets the underlying connection block size length. + * + * @return The block size length + */ public abstract int getBlockSize(); +/** + * Gets the underlying connection default fetch size for DataBlock responses. + * + * @return The default fetch size + */ public abstract int getDefFetchsize(); +/** + * Gets the underlying connection socket timeout. + * + * @return The underlying connection socket timeout + */ public abstract int getSoTimeout(); -public abstract void setSoTimeout(int s); +/** + * Sets the underlying connection socket timeout. + * + * @param timeout The specified timeout, in milliseconds. A timeout of zero is interpreted as an infinite timeout + */ +public abstract void setSoTimeout(int timeout); +/** + * Closes the underlying connection implementation. + * + * @throws IOException if an I/O error occurs while closing the connection + */ public abstract void closeUnderlyingConnection() throws
MonetDB: default - Merge with Dec2016 branch.
Changeset: 933363b389f7 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=933363b389f7 Added Files: sql/test/BugTracker-2017/Tests/all_dates.csv.gz sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.sql sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.stable.err sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.stable.out sql/test/BugTracker-2017/Tests/heapextend.Bug-6134.sql.in Modified Files: gdk/gdk_cross.c gdk/gdk_select.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_statement.c sql/storage/bat/bat_table.c sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.out sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out sql/test/BugTracker-2017/Tests/All Branch: default Log Message: Merge with Dec2016 branch. diffs (truncated from 2363 to 300 lines): diff --git a/gdk/gdk_cross.c b/gdk/gdk_cross.c --- a/gdk/gdk_cross.c +++ b/gdk/gdk_cross.c @@ -9,49 +9,7 @@ #include "monetdb_config.h" #include "gdk.h" #include "gdk_private.h" - -static gdk_return -BATcross1(BAT **r1p, BAT **r2p, BAT *l, BAT *r) -{ - BAT *bn1, *bn2; - BUN i, j; - oid *restrict p1, *restrict p2; - - bn1 = COLnew(0, TYPE_oid, BATcount(l) * BATcount(r), TRANSIENT); - bn2 = COLnew(0, TYPE_oid, BATcount(l) * BATcount(r), TRANSIENT); - if (bn1 == NULL || bn2 == NULL) { - BBPreclaim(bn1); - BBPreclaim(bn2); - return GDK_FAIL; - } - p1 = (oid *) Tloc(bn1, 0); - p2 = (oid *) Tloc(bn2, 0); - for (i = 0; i < BATcount(l); i++) { - for (j = 0; j < BATcount(r); j++) { - *p1++ = i + l->hseqbase; - *p2++ = j + r->hseqbase; - } - } - BATsetcount(bn1, BATcount(l) * BATcount(r)); - BATsetcount(bn2, BATcount(l) * BATcount(r)); - bn1->tsorted = 1; - bn1->trevsorted = BATcount(l) <= 1; - bn1->tkey = BATcount(r) <= 1; - bn1->tdense = bn1->tkey != 0; - bn1->tnil = 0; - bn1->tnonil = 1; - bn2->tsorted = BATcount(l) <= 1; - bn2->trevsorted = BATcount(bn2) <= 1; - bn2->tkey = BATcount(l) <= 1; - bn2->tdense = bn2->tkey != 0; - bn2->tnil = 0; - bn2->tnonil = 1; - BATtseqbase(bn1, l->hseqbase); - BATtseqbase(bn2, r->hseqbase); - *r1p = bn1; - *r2p = bn2; - return GDK_SUCCEED; -} +#include "gdk_cand.h" /* Calculate a cross product between bats l and r with optional * candidate lists sl for l and sr for r. @@ -60,28 +18,75 @@ BATcross1(BAT **r1p, BAT **r2p, BAT *l, gdk_return BATsubcross(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr) { - BAT *bn1, *bn2, *t; + BAT *bn1, *bn2; + BUN start1, start2; + BUN end1, end2; + BUN cnt1, cnt2; + const oid *restrict lcand, *restrict rcand; + const oid *lcandend, *rcandend; + oid seq; + oid *restrict p; + BUN i, j; - if (BATcross1(, , sl ? sl : l, sr ? sr : r) != GDK_SUCCEED) + CANDINIT(l, sl, start1, end1, cnt1, lcand, lcandend); + CANDINIT(r, sr, start2, end2, cnt2, rcand, rcandend); + if (lcand) + cnt1 = lcandend - lcand; + if (rcand) + cnt2 = rcandend - rcand; + + bn1 = COLnew(0, TYPE_oid, cnt1 * cnt2, TRANSIENT); + if (bn1 == NULL) return GDK_FAIL; - if (sl) { - t = BATproject(bn1, sl); - BBPunfix(bn1->batCacheid); - if (t == NULL) { - BBPunfix(bn2->batCacheid); - return GDK_FAIL; - } - bn1 = t; + BATsetcount(bn1, cnt1 * cnt2); + bn1->tsorted = 1; + bn1->trevsorted = cnt1 <= 1; + bn1->tkey = cnt2 <= 1; + bn1->tnil = 0; + bn1->tnonil = 1; + p = (oid *) Tloc(bn1, 0); + if (lcand) { + for (i = 0; i < cnt1; i++) + for (j = 0; j < cnt2; j++) + *p++ = lcand[i]; + bn1->tdense = 0; + } else { + seq = l->hseqbase + start1; + for (i = 0; i < cnt1; i++) + for (j = 0; j < cnt2; j++) + *p++ = i + seq; + bn1->tdense = bn1->tkey != 0; + if (bn1->tdense) + BATtseqbase(bn1, seq); } - if (sr) { - t = BATproject(bn2, sr); - BBPunfix(bn2->batCacheid); - if (t == NULL) { - BBPunfix(bn1->batCacheid); - return GDK_FAIL; - } - bn2 = t; + + bn2 = COLnew(0, TYPE_oid, cnt1 * cnt2, TRANSIENT); + if (bn2 == NULL) { +
MonetDB: Dec2016 - Approvals after changeset 1ba49a99910f.
Changeset: 9f6f9e7e0d3e for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9f6f9e7e0d3e Modified Files: sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.out Branch: Dec2016 Log Message: Approvals after changeset 1ba49a99910f. diffs (12 lines): diff --git a/sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.out b/sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.out --- a/sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.out +++ b/sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.out @@ -57,7 +57,7 @@ function user.s6_1():void; X_3 := sql.mvc(); X_7:bat[:int] := sql.bind(X_3,"sys","test","value",0:int); C_4:bat[:oid] := sql.tid(X_3,"sys","test"); -C_18 := algebra.subselect(X_7,C_4,1:int,1:int,true,false,false); +C_18 := algebra.subselect(X_7,C_4,1:int,1:int,true,true,false); X_22 := algebra.projection(C_18,X_7); sql.resultSet(X_31,X_33,X_34,X_36,X_38,X_22); end user.s6_1; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Dec2016 - Approvals after changeset 1ba49a99910f.
Changeset: 2522e00678cd for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2522e00678cd Modified Files: sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out Branch: Dec2016 Log Message: Approvals after changeset 1ba49a99910f. diffs (273 lines): diff --git a/sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out b/sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out --- a/sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out +++ b/sql/test/BugTracker-2012/Tests/rewrite_like_into_likesubselect.Bug-3179.stable.out @@ -300,36 +300,36 @@ end user.s10_1; % 140 # length function user.s20_1():void; X_0:void := querylog.define("explain select name,func from functions where contains(name, \\'optimizers\\');","sequential_pipe",31:int); -X_36 := bat.new(nil:str); -X_43 := bat.append(X_36,"sys.functions"); -X_53 := bat.append(X_43,"sys.functions"); +X_35 := bat.new(nil:str); +X_42 := bat.append(X_35,"sys.functions"); +X_52 := bat.append(X_42,"sys.functions"); +X_37 := bat.new(nil:str); +X_44 := bat.append(X_37,"name"); +X_53 := bat.append(X_44,"func"); X_38 := bat.new(nil:str); -X_45 := bat.append(X_38,"name"); -X_54 := bat.append(X_45,"func"); -X_39 := bat.new(nil:str); -X_47 := bat.append(X_39,"varchar"); -X_55 := bat.append(X_47,"varchar"); -X_40 := bat.new(nil:int); -X_49 := bat.append(X_40,256:int); -X_56 := bat.append(X_49,8196:int); -X_42 := bat.new(nil:int); -X_51 := bat.append(X_42,0:int); -X_58 := bat.append(X_51,0:int); +X_46 := bat.append(X_38,"varchar"); +X_54 := bat.append(X_46,"varchar"); +X_39 := bat.new(nil:int); +X_48 := bat.append(X_39,256:int); +X_55 := bat.append(X_48,8196:int); +X_41 := bat.new(nil:int); +X_50 := bat.append(X_41,0:int); +X_57 := bat.append(X_50,0:int); X_3 := sql.mvc(); C_4:bat[:oid] := sql.tid(X_3,"sys","functions"); X_7:bat[:str] := sql.bind(X_3,"sys","functions","name",0:int); (C_10:bat[:oid],r1_12:bat[:str]) := sql.bind(X_3,"sys","functions","name",2:int); X_13:bat[:str] := sql.bind(X_3,"sys","functions","name",1:int); X_16 := sql.projectdelta(C_4,X_7,C_10,r1_12,X_13); -X_75:bat[:bit] := batalgebra.like(X_16,"%optimizers%":str); -C_23 := algebra.subselect(X_75,true,true,true,false,false); -X_26 := algebra.projection(C_23,X_16); -X_27:bat[:str] := sql.bind(X_3,"sys","functions","func",0:int); -(C_29:bat[:oid],r1_31:bat[:str]) := sql.bind(X_3,"sys","functions","func",2:int); -X_31:bat[:str] := sql.bind(X_3,"sys","functions","func",1:int); -X_33 := sql.projectdelta(C_4,X_27,C_29,r1_31,X_31); -X_34 := algebra.projection(C_23,X_33); -sql.resultSet(X_53,X_54,X_55,X_56,X_58,X_26,X_34); +X_74:bat[:bit] := batalgebra.like(X_16,"%optimizers%":str); +C_23 := algebra.subselect(X_74,true,true,true,true,false); +X_25 := algebra.projection(C_23,X_16); +X_26:bat[:str] := sql.bind(X_3,"sys","functions","func",0:int); +(C_28:bat[:oid],r1_30:bat[:str]) := sql.bind(X_3,"sys","functions","func",2:int); +X_30:bat[:str] := sql.bind(X_3,"sys","functions","func",1:int); +X_32 := sql.projectdelta(C_4,X_26,C_28,r1_30,X_30); +X_33 := algebra.projection(C_23,X_32); +sql.resultSet(X_52,X_53,X_54,X_55,X_57,X_25,X_33); end user.s20_1; #inline actions= 0 time=12 usec #remapactions= 1 time=100 usec @@ -361,36 +361,36 @@ end user.s20_1; % 144 # length function user.s22_1():void; X_0:void := querylog.define("explain select name,func from functions where not_contains(name, \\'optimizers\\');","sequential_pipe",31:int); -X_36 := bat.new(nil:str); -X_43 := bat.append(X_36,"sys.functions"); -X_53 := bat.append(X_43,"sys.functions"); +X_35 := bat.new(nil:str); +X_42 := bat.append(X_35,"sys.functions"); +X_52 := bat.append(X_42,"sys.functions"); +X_37 := bat.new(nil:str); +X_44 := bat.append(X_37,"name"); +X_53 := bat.append(X_44,"func"); X_38 := bat.new(nil:str); -X_45 := bat.append(X_38,"name"); -X_54 := bat.append(X_45,"func"); -X_39 := bat.new(nil:str); -X_47 := bat.append(X_39,"varchar"); -X_55 := bat.append(X_47,"varchar"); -X_40 := bat.new(nil:int); -X_49 := bat.append(X_40,256:int); -X_56 := bat.append(X_49,8196:int); -X_42 := bat.new(nil:int); -X_51 := bat.append(X_42,0:int); -X_58 := bat.append(X_51,0:int); +X_46 := bat.append(X_38,"varchar"); +X_54 := bat.append(X_46,"varchar"); +X_39 := bat.new(nil:int); +X_48 := bat.append(X_39,256:int); +X_55 := bat.append(X_48,8196:int); +X_41 := bat.new(nil:int); +X_50 := bat.append(X_41,0:int); +X_57 := bat.append(X_50,0:int); X_3 := sql.mvc();
MonetDB: Dec2016 - Fix select for (half) open interval where lef...
Changeset: 1ba49a99910f for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1ba49a99910f Added Files: sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.sql sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.stable.err sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.stable.out Modified Files: gdk/gdk_select.c sql/backends/monet5/sql_gencode.c sql/storage/bat/bat_table.c sql/test/BugTracker-2017/Tests/All Branch: Dec2016 Log Message: Fix select for (half) open interval where left and right the same. According to the comments near BATselect, this should give an empty result, and now it does. Some incorrect usage was also fixed. This fixes bug 6184. diffs (241 lines): diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1257,6 +1257,20 @@ BATselect(BAT *b, BAT *s, const void *tl /* can we use the base type? */ t = ATOMbasetype(t); lnil = ATOMcmp(t, tl, nil) == 0; /* low value = nil? */ + + if (!lnil && th != NULL && (!li || !hi) && !anti && ATOMcmp(t, tl, th) == 0) { + /* upper and lower bound of range are equal and we +* want an interval that's open on at least one +* side */ + ALGODEBUG fprintf(stderr, "#BATselect(b=%s#" BUNFMT + ",s=%s%s,li=%d,hi=%d,anti=%d): empty interval\n", + BATgetId(b), BATcount(b), + s ? BATgetId(s) : "NULL", + s && BATtdense(s) ? "(dense)" : "", + li, hi, anti); + return newempty(); + } + lval = !lnil || th == NULL; /* low value used for comparison */ equi = th == NULL || (lval && ATOMcmp(t, tl, th) == 0); /* point select? */ if (equi) { diff --git a/sql/backends/monet5/sql_gencode.c b/sql/backends/monet5/sql_gencode.c --- a/sql/backends/monet5/sql_gencode.c +++ b/sql/backends/monet5/sql_gencode.c @@ -1531,7 +1531,7 @@ static int q = pushArgument(mb, q, r); q = pushArgument(mb, q, r); q = pushBit(mb, q, TRUE); - q = pushBit(mb, q, FALSE); + q = pushBit(mb, q, TRUE); q = pushBit(mb, q, FALSE); if (q == NULL) return -1; diff --git a/sql/storage/bat/bat_table.c b/sql/storage/bat/bat_table.c --- a/sql/storage/bat/bat_table.c +++ b/sql/storage/bat/bat_table.c @@ -261,7 +261,8 @@ rids_select( sql_trans *tr, sql_column * BAT *b = NULL, *r = NULL, *s = NULL; rids *rs = ZNEW(rids); const void *kvl = key_value_low, *kvh = key_value_high; - int hi = 0; + /* if pointers are equal, make it an inclusive select */ + int hi = key_value_low == key_value_high; s = delta_cands(tr, key->t); b = full_column(tr, key); diff --git a/sql/test/BugTracker-2017/Tests/All b/sql/test/BugTracker-2017/Tests/All --- a/sql/test/BugTracker-2017/Tests/All +++ b/sql/test/BugTracker-2017/Tests/All @@ -2,3 +2,4 @@ shutdown.Bug-6182 avggroupbysq.Bug-6178 semijoinunion.Bug-6150 HAVE_LIBZ?heapextend.Bug-6134 +empty-interval.Bug-6184 diff --git a/sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.sql b/sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.sql @@ -0,0 +1,25 @@ +START TRANSACTION; + +CREATE TABLE "sys"."unitTestDontDelete" ( + "A" VARCHAR(255), + "B" BIGINT, + "C" DOUBLE, + "D" TIMESTAMP +); +COPY 10 RECORDS INTO "sys"."unitTestDontDelete" FROM stdin USING DELIMITERS '\t','\n','"'; +NULL NULLNULLNULL +"Cat1" 0 0.5 2013-06-10 11:10:10.00 +"Cat2" 1 1.5 2013-06-11 12:11:11.00 +"Cat1" 2 2.5 2013-06-12 13:12:12.00 +"Cat2" 3 3.5 2013-06-13 14:13:13.00 +"Cat1" 4 4.5 2013-06-14 15:14:14.00 +"Cat2" 5 5.5 2013-06-15 16:15:15.00 +"Cat1" 6 6.5 2013-06-16 17:16:16.00 +"Cat2" 7 7.5 2013-06-17 18:17:17.00 +"Cat1" 8 8.5 2013-06-18 19:18:18.00 + +select * from "unitTestDontDelete" where "B" < 5 AND "B" >= 5; +select * from "unitTestDontDelete" where "A" < 'Cat2' AND "A" >= 'Cat2'; +select * from "unitTestDontDelete" where "C" < 5.5 AND "C" >= 5.5; + +ROLLBACK; diff --git a/sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.stable.err b/sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2017/Tests/empty-interval.Bug-6184.stable.err @@ -0,0 +1,36 @@ +stderr of test