Changeset: f6ad0d2f1f79 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f6ad0d2f1f79 Added Files: sql/test/BugTracker-2015/Tests/project_rewrite.Bug-3693.sql sql/test/BugTracker-2015/Tests/project_rewrite.Bug-3693.stable.err sql/test/BugTracker-2015/Tests/project_rewrite.Bug-3693.stable.out Removed Files: sql/test/BugTracker-2015/Tests/inf-nan-handling.Bug-3696.sql~ Modified Files: clients/R/MonetDB.R/DESCRIPTION clients/R/MonetDB.R/NEWS clients/R/MonetDB.R/R/dbi.R clients/R/Tests/dbi.R clients/mapiclient/eventparser.c clients/mapiclient/eventparser.h clients/mapiclient/tachograph.c clients/mapiclient/tomograph.c gdk/gdk_atoms.c gdk/gdk_search.c monetdb5/mal/mal_listing.c monetdb5/mal/mal_profiler.c monetdb5/modules/mal/joinpath.c monetdb5/optimizer/opt_joinpath.c sql/backends/monet5/sql_scenario.c sql/benchmarks/tpch/Tests/05-explain.stable.out.32bit sql/server/rel_optimizer.c sql/test/BugTracker-2015/Tests/All Branch: rdf Log Message:
Merge with default + Fix the problem of infinite loop with exp_shares_exps diffs (truncated from 1345 to 300 lines): diff --git a/clients/R/MonetDB.R/DESCRIPTION b/clients/R/MonetDB.R/DESCRIPTION --- a/clients/R/MonetDB.R/DESCRIPTION +++ b/clients/R/MonetDB.R/DESCRIPTION @@ -1,5 +1,5 @@ Package: MonetDB.R -Version: 0.9.7 +Version: 0.9.8 Title: Connect MonetDB to R Authors@R: c(person("Hannes Muehleisen", role = c("aut", "cre"),email = "han...@cwi.nl"), person("Thomas Lumley", role = "ctb"), diff --git a/clients/R/MonetDB.R/NEWS b/clients/R/MonetDB.R/NEWS --- a/clients/R/MonetDB.R/NEWS +++ b/clients/R/MonetDB.R/NEWS @@ -1,3 +1,8 @@ +0.9.8 +- Added support for esoteric data types such as MONTH_INTERVAL (Thanks, Roman) +- Cleaned up SQL to R type mapping (we had this twice) +- Now creating actual R integers if data fits + 0.9.7 - Fixed crash on Windows (Sorry, everyone) diff --git a/clients/R/MonetDB.R/R/dbi.R b/clients/R/MonetDB.R/R/dbi.R --- a/clients/R/MonetDB.R/R/dbi.R +++ b/clients/R/MonetDB.R/R/dbi.R @@ -432,31 +432,29 @@ setMethod("dbSendUpdateAsync", signature ### MonetDBResult setClass("MonetDBResult", representation("DBIResult", env="environment")) +.CT_INT <- 0L .CT_NUM <- 1L .CT_CHR <- 2L .CT_CHRR <- 3L .CT_BOOL <- 4L .CT_RAW <- 5L +# type mapping matrix +monetTypes <- rep(c("integer", "numeric", "character", "character", "logical", "raw"), c(6, 5, 4, 6, 1, 1)) +names(monetTypes) <- c(c("WRD", "TINYINT", "SMALLINT", "INT", "MONTH_INTERVAL"), # month_interval is the diff between date cols, int + c("BIGINT", "HUGEINT", "REAL", "DOUBLE", "DECIMAL", "SEC_INTERVAL"), # sec_interval is the difference between timestamps, float + c("CHAR", "VARCHAR", "CLOB", "STR"), + c("INTERVAL", "DATE", "TIME", "TIMETZ", "TIMESTAMP", "TIMESTAMPTZ"), + c("BOOLEAN"), + c("BLOB")) + monetdbRtype <- function(dbType) { dbType <- toupper(dbType) - - if (dbType %in% c("TINYINT", "SMALLINT", "INT", "BIGINT", "HUGEINT", "REAL", "DOUBLE", "DECIMAL", "WRD")) { - return("numeric") + rtype <- monetTypes[dbType] + if (is.na(rtype)) { + stop("Unknown DB type ", dbType) } - if (dbType %in% c("CHAR", "VARCHAR", "CLOB", "STR")) { - return("character") - } - if (dbType %in% c("INTERVAL", "DATE", "TIME", "TIMESTAMP")) { - return("date") - } - if (dbType == "BOOLEAN") { - return("logical") - } - if (dbType == "BLOB") { - return("raw") - } - stop("Unknown DB type ", dbType) + rtype } setMethod("fetch", signature(res="MonetDBResult", n="numeric"), def=function(res, n, ...) { @@ -491,6 +489,10 @@ setMethod("dbFetch", signature(res="Mone for (i in seq.int(info$cols)) { rtype <- monetdbRtype(info$types[i]) + if (rtype=="integer") { + df[[i]] <- integer() + ct[i] <- .CT_INT + } if (rtype=="numeric") { df[[i]] <- numeric() ct[i] <- .CT_NUM @@ -499,10 +501,6 @@ setMethod("dbFetch", signature(res="Mone df[[i]] <- character() ct[i] <- .CT_CHR } - if (rtype=="date") { - df[[i]] <- character() - ct[i] <- .CT_CHRR - } if (rtype=="logical") { df[[i]] <- logical() ct[i] <- .CT_BOOL @@ -537,6 +535,8 @@ setMethod("dbFetch", signature(res="Mone # convert values column by column for (j in seq.int(info$cols)) { col <- ct[[j]] + if (col == .CT_INT) + df[[j]] <- as.integer(parts[[j]]) if (col == .CT_NUM) df[[j]] <- as.numeric(parts[[j]]) if (col == .CT_CHRR) { @@ -597,17 +597,10 @@ setMethod("dbIsValid", signature(dbObj=" return(invisible(TRUE)) }) -monetTypes <- rep(c("numeric", "character", "character", "logical", "raw"), c(9, 3, 4, 1, 1)) -names(monetTypes) <- c(c("TINYINT", "SMALLINT", "INT", "BIGINT", "HUGEINT", "REAL", "DOUBLE", "DECIMAL", "WRD"), - c("CHAR", "VARCHAR", "CLOB"), - c("INTERVAL", "DATE", "TIME", "TIMESTAMP"), - "BOOLEAN", - "BLOB") - - setMethod("dbColumnInfo", "MonetDBResult", def = function(res, ...) { return(data.frame(field.name=res@env$info$names, field.type=res@env$info$types, - data.type=monetTypes[res@env$info$types])) + data.type=monetTypes[res@env$info$types], r.data.type=monetTypes[res@env$info$types], + monetdb.data.type=res@env$info$types)) }, valueClass = "data.frame") diff --git a/clients/R/Tests/dbi.R b/clients/R/Tests/dbi.R --- a/clients/R/Tests/dbi.R +++ b/clients/R/Tests/dbi.R @@ -41,7 +41,7 @@ dbSendUpdate(con,"CREATE TABLE monetdbte stopifnot(identical(dbExistsTable(con,tname),TRUE)) dbSendUpdate(con,"INSERT INTO monetdbtest VALUES ('one',1,'1111')") dbSendUpdate(con,"INSERT INTO monetdbtest VALUES ('two',2,'22222222')") -stopifnot(identical(dbGetQuery(con,"SELECT count(*) FROM monetdbtest")[[1]],2)) +stopifnot(identical(dbGetQuery(con,"SELECT count(*) FROM monetdbtest")[[1]],2L)) stopifnot(identical(dbReadTable(con,tname)[[3]],list(charToRaw("1111"),charToRaw("22222222")))) dbRemoveTable(con,tname) stopifnot(identical(dbExistsTable(con,tname),FALSE)) @@ -170,6 +170,9 @@ dbSendUpdate(conn, "INSERT INTO monetdbt stopifnot(identical("Роман Mühleisen", dbGetQuery(conn,"SELECT a FROM monetdbtest")$a[[1]])) dbRollback(conn) +# this returns a column with esoteric type MONTH_INTERVAL +stopifnot(identical(1L, as.integer(dbGetQuery(con, "select cast('2015-03-02' as date) - cast('2015-03-01' as date)")[[1]][[1]]))) + stopifnot(dbIsValid(conn)) #thrice to catch null pointer errors stopifnot(identical(dbDisconnect(con),TRUE)) @@ -177,6 +180,8 @@ stopifnot(!dbIsValid(conn)) stopifnot(identical(dbDisconnect(con),TRUE)) stopifnot(identical(dbDisconnect(con),TRUE)) + + #test merovingian control code #cannot really do this in Mtest, sorry #stopifnot(dbname %in% monetdbd.liststatus("monetdb")$dbname) diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c --- a/clients/mapiclient/eventparser.c +++ b/clients/mapiclient/eventparser.c @@ -10,7 +10,7 @@ #include "eventparser.h" -char *statenames[]= {"","start","done","action","ping","wait","iostat","gccollect"}; +char *statenames[]= {"","start","done","action","ping","wait","system"}; char *malarguments[MAXMALARGS]; int malargtop; @@ -148,10 +148,14 @@ eventparser(char *row, EventRecord *ev) return -3; /* skip pc tag */ - { // decode pc + { // decode qry[pc]tag + char *nme = c; c= strchr(c+1,'['); if( c == 0) return -4; + *c = 0; + ev->blk= strdup(nme); + *c = '['; ev->pc = atoi(c+1); c= strchr(c+1,']'); if ( c == 0) @@ -170,19 +174,19 @@ eventparser(char *row, EventRecord *ev) if (c == 0) return -5; if (strncmp(c + 1, "start", 5) == 0) { - ev->state = START; + ev->state = MDB_START; c += 6; } else if (strncmp(c + 1, "done", 4) == 0) { - ev->state = DONE; + ev->state = MDB_DONE; c += 5; } else if (strncmp(c + 1, "ping", 4) == 0) { - ev->state = PING; + ev->state = MDB_PING; c += 5; - } else if (strncmp(c + 1, "stat", 4) == 0) { - ev->state = IOSTAT; - c += 6; + } else if (strncmp(c + 1, "system", 6) == 0) { + ev->state = MDB_SYSTEM; + c += 5; } else if (strncmp(c + 1, "wait", 4) == 0) { - ev->state = WAIT; + ev->state = MDB_WAIT; c += 5; } else { ev->state = 0; diff --git a/clients/mapiclient/eventparser.h b/clients/mapiclient/eventparser.h --- a/clients/mapiclient/eventparser.h +++ b/clients/mapiclient/eventparser.h @@ -58,31 +58,32 @@ #define MAXTHREADS 1048 #define MAXBOX 32678 /* should be > MAXTHREADS */ -#define START 1 -#define DONE 2 -#define ACTION 3 -#define PING 4 -#define WAIT 5 -#define IOSTAT 6 -#define GCOLLECT 7 +#define MDB_START 1 +#define MDB_DONE 2 +#define MDB_PING 3 +#define MDB_WAIT 4 +#define MDB_SYSTEM 5 + extern char *statenames[]; +// the break down of a profiler event message typedef struct { int state; - int pc; - int tag; - lng eventnr; - int thread; + char *blk; // name of MAL block + int pc; // instruction counter in block + int tag; // unique MAL block invocation tag + lng eventnr;// serial event number + int thread; // worker thread involved lng clkticks; lng ticks; lng memory; - lng tmpspace; + lng tmpspace; // size of temporary produced lng inblock; lng oublock; lng majflt; lng swaps; lng csw; - char *stmt; + char *stmt; // MAL statement, cpu loads or commentary char *fcn; char *numa; } EventRecord; diff --git a/clients/mapiclient/tachograph.c b/clients/mapiclient/tachograph.c --- a/clients/mapiclient/tachograph.c +++ b/clients/mapiclient/tachograph.c @@ -511,7 +511,7 @@ update(EventRecord *ev) char number[BUFSIZ]={0}; /* handle a ping event, keep the current instruction in focus */ - if (ev->state >= PING ) { + if (ev->state >= MDB_PING ) { // All state events are ignored return; } @@ -541,7 +541,7 @@ update(EventRecord *ev) } /* monitor top level function brackets, we restrict ourselves to SQL queries */ - if (!capturing && ev->state == START && ev->fcn && strncmp(ev->fcn, "function", 8) == 0) { + if (!capturing && ev->state == MDB_START && ev->fcn && strncmp(ev->fcn, "function", 8) == 0) { if( (i = sscanf(ev->fcn + 9,"user.s%d_%d",&uid,&qid)) != 2){ if( debug) fprintf(stderr,"Start phase parsing %d, uid %d qid %d\n",i,uid,qid); @@ -567,7 +567,7 @@ update(EventRecord *ev) return; /* start of instruction box */ - if (ev->state == START ) { + if (ev->state == MDB_START ) { if(ev->fcn && strstr(ev->fcn,"querylog.define") ){ // extract a string argument currentquery = malarguments[0]; @@ -682,7 +682,7 @@ update(EventRecord *ev) return; } /* end the instruction box */ - if (ev->state == DONE ){ + if (ev->state == MDB_DONE ){ if( ev->tag != currenttag) return; // forget all except one query @@ -720,7 +720,7 @@ update(EventRecord *ev) events[ev->pc].actual= ev->ticks; clearArguments(); } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list