Changeset: 1e7af0c1cb4c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1e7af0c1cb4c
Added Files:
        monetdb5/modules/mal/Tests/pqueue3.mal
        sql/benchmarks/tpch/drop.sql
        sql/test/BugTracker-2014/Tests/integer-cast.Bug-3424.sql
        sql/test/BugTracker-2014/Tests/integer-cast.Bug-3424.stable.err
        sql/test/BugTracker-2014/Tests/integer-cast.Bug-3424.stable.out
        sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.SQL.py
        sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.stable.err
        sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.stable.out
        sql/test/BugTracker-2014/Tests/temporary.Bug-3430.stable.err
        sql/test/BugTracker-2014/Tests/temporary.Bug-3430.stable.out
        sql/test/Tests/alastair_udf_mergetable_bug.py
        sql/test/Tests/alastair_udf_mergetable_bug.stable.err
        sql/test/Tests/alastair_udf_mergetable_bug.stable.out
Modified Files:
        clients/R/MonetDB.R/DESCRIPTION
        clients/R/MonetDB.R/NAMESPACE
        clients/R/MonetDB.R/NEWS
        clients/R/MonetDB.R/R/control.R
        clients/R/MonetDB.R/R/monetdb.R
        clients/R/MonetDB.R/man/mc.Rd
        clients/R/MonetDB.R/src/mapi.c
        clients/R/db.tests/monetdb.test.R
        clients/R/db.tests/monetframe.test.R
        clients/R/db.tests/sqlsurvey.test.R
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures_gsl.stable.out
        clients/Tests/MAL-signatures_nocfitsio.stable.out
        clients/Tests/MAL-signatures_sphinxclient.stable.out
        clients/Tests/SQL-dump.stable.out
        clients/Tests/SQL-dump.stable.out.64bit.oid32
        clients/Tests/SQL-dump_gsl.stable.out
        clients/Tests/SQL-dump_gsl.stable.out.oid32
        clients/Tests/SQL-dump_nogeom.stable.out
        clients/Tests/exports.stable.out
        clients/mapiclient/dump.c
        clients/mapiclient/mclient.c
        clients/python2/monetdb/sql/pythonize.py
        clients/python3/monetdb/sql/pythonize.py
        common/stream/stream.c
        common/utils/msabaoth.c
        common/utils/mutils.c
        configure.ag
        gdk/gdk_atoms.c
        gdk/gdk_bbp.c
        gdk/gdk_calc.c
        gdk/gdk_heap.c
        gdk/gdk_posix.c
        gdk/gdk_storage.c
        gdk/gdk_utils.c
        java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
        monetdb5/extras/sphinx/sphinx.c
        monetdb5/mal/Tests/tst013.stable.out
        monetdb5/mal/Tests/tst036.stable.out
        monetdb5/mal/Tests/tst050.stable.out
        monetdb5/mal/Tests/tst070.stable.out
        monetdb5/mal/Tests/tst105.stable.out
        monetdb5/mal/Tests/tst106.stable.out
        monetdb5/mal/Tests/tst150.stable.out
        monetdb5/mal/Tests/tst2504.mal
        monetdb5/mal/Tests/tst2504.stable.out
        monetdb5/mal/Tests/tst611.stable.out
        monetdb5/mal/mal_atom.c
        monetdb5/mal/mal_builder.c
        monetdb5/mal/mal_factory.c
        monetdb5/mal/mal_import.c
        monetdb5/mal/mal_instruction.c
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_linker.c
        monetdb5/mal/mal_module.c
        monetdb5/mal/mal_namespace.c
        monetdb5/mal/mal_parser.c
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_readline.c
        monetdb5/mal/mal_resolve.c
        monetdb5/mal/mal_session.c
        monetdb5/modules/atoms/inet.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/atoms/json.h
        monetdb5/modules/atoms/json.mal
        monetdb5/modules/atoms/str.c
        monetdb5/modules/mal/Tests/All
        monetdb5/modules/mal/Tests/pqueue.stable.out
        monetdb5/modules/mal/Tests/pqueue2.mal
        monetdb5/modules/mal/bbp.c
        monetdb5/modules/mal/manifold.c
        monetdb5/modules/mal/pqueue.c
        monetdb5/modules/mal/pqueue.h
        monetdb5/modules/mal/pqueue.mal
        monetdb5/modules/mal/sample.mal
        monetdb5/optimizer/Tests/inline08.stable.out
        monetdb5/optimizer/opt_accumulators.c
        monetdb5/optimizer/opt_aliases.c
        monetdb5/optimizer/opt_centipede.c
        monetdb5/optimizer/opt_dataflow.c
        monetdb5/optimizer/opt_macro.c
        monetdb5/optimizer/opt_mapreduce.c
        monetdb5/optimizer/opt_mergetable.c
        monetdb5/optimizer/opt_octopus.c
        monetdb5/optimizer/opt_pushselect.c
        monetdb5/optimizer/opt_support.c
        monetdb5/scheduler/run_octopus.c
        monetdb5/scheduler/srvpool.c
        
monetdb5/tests/BugDay_2005-10-06_4.9.3/Tests/ADT_not_available.SF-850137.stable.out
        monetdb5/tests/BugReports/Tests/lngssaretruncated.stable.out
        monetdb5/tests/BugTracker/Tests/parser.SF-2051309.stable.out
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql.h
        sql/backends/monet5/sql.mal
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_scenario.c
        sql/backends/monet5/sql_statement.c
        sql/backends/monet5/sql_statement.h
        sql/benchmarks/ssbm/Tests/02-explain.stable.out
        sql/benchmarks/ssbm/Tests/02-plan.stable.out
        sql/benchmarks/ssbm/Tests/03-explain.stable.out
        sql/benchmarks/ssbm/Tests/03-plan.stable.out
        sql/benchmarks/ssbm/Tests/07-explain.stable.out
        sql/benchmarks/ssbm/Tests/07-plan.stable.out
        sql/benchmarks/ssbm/Tests/08-explain.stable.out
        sql/benchmarks/ssbm/Tests/08-plan.stable.out
        sql/benchmarks/tpch/Tests/01-explain.stable.out
        sql/benchmarks/tpch/Tests/01-plan.stable.out
        sql/benchmarks/tpch/Tests/02-explain.stable.out
        sql/benchmarks/tpch/Tests/03-explain.stable.out
        sql/benchmarks/tpch/Tests/03-plan.stable.out
        sql/benchmarks/tpch/Tests/08-explain.stable.out
        sql/benchmarks/tpch/Tests/08-plan.stable.out
        sql/benchmarks/tpch/Tests/10-explain.stable.out
        sql/benchmarks/tpch/Tests/18-explain.stable.out
        sql/benchmarks/tpch/Tests/21-explain.stable.out
        sql/common/sql_string.c
        sql/common/sql_types.c
        sql/scripts/40_json.sql
        sql/server/rel_distribute.c
        sql/server/rel_dump.c
        sql/server/rel_optimizer.c
        sql/server/rel_psm.c
        sql/server/sql_mvc.c
        sql/storage/bat/bat_storage.c
        sql/storage/restrict/restrict_storage.c
        sql/storage/sql_storage.h
        sql/test/ADT2006/bram.sql
        
sql/test/BugTracker-2009/Tests/old_views_incorrectly_reused.SF-2863804.stable.out
        
sql/test/BugTracker-2010/Tests/LIMIT_OFFSET_big-endian.Bug-2622.stable.out
        
sql/test/BugTracker-2010/Tests/group-by_ordered_column.Bug-2564.stable.out
        
sql/test/BugTracker-2012/Tests/table_function_with_column_subselects.Bug-3172.stable.err
        sql/test/BugTracker-2013/Tests/qualified_aggrname.Bug-3332.stable.out
        sql/test/BugTracker-2014/Tests/All
        sql/test/BugTracker-2014/Tests/crash_on_or_with_in.Bug-3461.stable.out
        sql/test/BugTracker-2014/Tests/in_incorrect_multi.Bug-3462.stable.out
        sql/test/Tests/orderby_non_selection_column.stable.out
        sql/test/Tests/systemfunctions.stable.out
        sql/test/json/Tests/parsing.stable.err
        sql/test/leaks/Tests/check1.stable.out
        sql/test/leaks/Tests/check1_gsl.stable.out
        sql/test/leaks/Tests/check1_nogeom.stable.out
        sql/test/leaks/Tests/check2.stable.out
        sql/test/leaks/Tests/check2_gsl.stable.out
        sql/test/leaks/Tests/check2_nogeom.stable.out
        sql/test/leaks/Tests/check3.stable.out
        sql/test/leaks/Tests/check3_gsl.stable.out
        sql/test/leaks/Tests/check3_nogeom.stable.out
        sql/test/leaks/Tests/check4.stable.out
        sql/test/leaks/Tests/check4_gsl.stable.out
        sql/test/leaks/Tests/check4_nogeom.stable.out
        sql/test/leaks/Tests/check5.stable.out
        sql/test/leaks/Tests/check5_gsl.stable.out
        sql/test/leaks/Tests/check5_nogeom.stable.out
        testing/process.py
        tools/merovingian/daemon/argvcmds.c
        tools/merovingian/daemon/merovingian.c
        tools/mserver/mserver5.c
Branch: multifarm
Log Message:

Merge with default branch.


diffs (truncated from 36811 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,6 +1,6 @@
 Package: MonetDB.R
 Version: 0.9.2
-Date: 2013-03-18
+Date: 2013-04-22
 Title: Connect MonetDB to R
 Authors@R: c(person("Hannes Muehleisen", role = c("aut", "cre"),email = 
"[email protected]"),
        person("Thomas Lumley", role = "ctb"),
diff --git a/clients/R/MonetDB.R/NAMESPACE b/clients/R/MonetDB.R/NAMESPACE
--- a/clients/R/MonetDB.R/NAMESPACE
+++ b/clients/R/MonetDB.R/NAMESPACE
@@ -12,6 +12,9 @@ export(monetdb_queryinfo)
 # shorthand for db connections
 export(mc)
 
+# shorthand for db queries
+export(mq)
+
 # control.R
 export(monetdb.server.setup)
 export(monetdb.server.start)
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,6 +1,13 @@
 0.9.2
 - monetdb_queryinfo method to find out things about an arbitrary query cheaply
-- new option monetdb.sequential
+- new options monetdb.sequential, monetdb.debug.query and monetdb.debug.mapi
+- debug output now uses the message() function
+- source code cleanup
+- dbListTables() now hides system tables per default, also got options to 
include the
+  schema name and quoting in the result (sys_tables, schema_names and quote)
+- fixed various TODO's in the code to get closer to 1.0 (exciting)
+- fixed a bug when the error identifier sent by MonetDB was non-numeric
+- IPv6 addresses in dbConnect() should now work (another long-standing TODO)
 
 0.9.1
 - dbGetInfo() now supported on MonetDBConnection (dplyr compatibility)
diff --git a/clients/R/MonetDB.R/R/control.R b/clients/R/MonetDB.R/R/control.R
--- a/clients/R/MonetDB.R/R/control.R
+++ b/clients/R/MonetDB.R/R/control.R
@@ -223,4 +223,47 @@ monetdb.server.setup <-
     }
     # return the filepath to the batch file
     bfl
-  }
\ No newline at end of file
+  }
+
+
+monetdbd.liststatus <- monetdb.liststatus <- function(passphrase, 
host="localhost", port=50000L, 
+                                                      timeout=86400L) {
+  
+  rawstr <- .monetdbd.command(passphrase, host, port, timeout)
+  lines <- strsplit(rawstr, "\n", fixed=T)[[1]] # split by newline, first line 
is "=OK", so skip
+  lines <- lines[grepl("^=sabdb:2:", lines)] # make sure we get a db list 
here, protocol v.2
+  lines <- sub("=sabdb:2:", "", lines, fixed=T)
+  # convert value into propert types etc
+  dbdf <- as.data.frame(do.call("rbind", strsplit(lines, ", ", fixed=T)), 
stringsAsFactors=F)
+  names(dbdf) <- c("dbname", "uri", "locked", "state", "scenarios", 
"startCounter", "stopCounter", 
+                   "crashCounter", "avgUptime", "maxUptime", "minUptime", 
"lastCrash", "lastStart", "lastStop", 
+                   "crashAvg1", "crashAvg10", "crashAvg30")
+  
+  dbdf$locked <- dbdf$locked=="1"
+  
+  states <- c("illegal", "running", "crashed", "inactive", "starting")
+  dbdf$state <- factor(states[as.integer(dbdf$state)+1])
+  
+  dbdf$startCounter <- as.numeric(dbdf$startCounter)
+  dbdf$stopCounter <- as.numeric(dbdf$stopCounter)
+  dbdf$crashCounter <- as.numeric(dbdf$crashCounter)
+  
+  dbdf$avgUptime <- as.numeric(dbdf$avgUptime)
+  dbdf$maxUptime <- as.numeric(dbdf$maxUptime)
+  dbdf$minUptime <- as.numeric(dbdf$minUptime)
+  
+  convertts <- function(col) {
+    col[col=="-1"] <- NA
+    return(as.POSIXct(as.numeric(col), origin="1970-01-01"))
+  }
+  dbdf$lastCrash <- convertts(dbdf$lastCrash)
+  dbdf$lastStart <- convertts(dbdf$lastStart)
+  dbdf$lastStop <- convertts(dbdf$lastStop)
+  
+  dbdf$crashAvg1 <- dbdf$crashAvg1=="1"
+  dbdfcrashAvg10 <- as.numeric(dbdf$crashAvg10)
+  dbdf$crashAvg30 <- as.numeric(dbdf$crashAvg30)
+  dbdf$scenarios <- gsub("'", ", ", dbdf$scenarios, fixed=T)
+  
+  return(dbdf[order(dbdf$dbname), ])
+}
\ No newline at end of file
diff --git a/clients/R/MonetDB.R/R/monetdb.R b/clients/R/MonetDB.R/R/monetdb.R
--- a/clients/R/MonetDB.R/R/monetdb.R
+++ b/clients/R/MonetDB.R/R/monetdb.R
@@ -4,343 +4,393 @@ require(digest)
 C_LIBRARY <- "MonetDB.R"
 
 .onLoad <- function(lib, pkg) {
-       library.dynam( C_LIBRARY, pkg, lib )
-       .Call("mapiInit",PACKAGE=C_LIBRARY)
+  library.dynam( C_LIBRARY, pkg, lib )
+  .Call("mapiInit", PACKAGE=C_LIBRARY)
 }
 
-# TODO: make these values configurable in the call to dbConnect
-DEBUG_IO      <- FALSE
-DEBUG_QUERY   <- FALSE
-
 # Make S4 aware of S3 classes
-setOldClass(c("sockconn","connection","monetdb_mapi_conn"))
+setOldClass(c("sockconn", "connection", "monetdb_mapi_conn"))
 
 ### MonetDBDriver
 setClass("MonetDBDriver", representation("DBIDriver"))
 
 # allow instantiation of this driver with MonetDB to allow existing programs 
to work
 MonetR <- MonetDB <- MonetDBR <- MonetDB.R <- function() {
-       new("MonetDBDriver")
+  new("MonetDBDriver")
 }
 
 setMethod("dbGetInfo", "MonetDBDriver", def=function(dbObj, ...)
-                       list(name="MonetDBDriver", 
-                                       driver.version="0.9.1",
-                                       DBI.version="0.2-7",
-                                       client.version=NA,
-                                       max.connections=NA)
+  list(name="MonetDBDriver", 
+       driver.version="0.9.2", 
+       DBI.version="0.2-7", 
+       client.version=NA, 
+       max.connections=NA)
 )
 
 # shorthand for connecting to the DB, very handy, e.g. dbListTables(mc("acs"))
-mc <- function(dbname="demo", user="monetdb", password="monetdb", 
host="localhost",port=50000L, timeout=86400L, wait=FALSE,language="sql",...) {
-       
dbConnect(MonetDB.R(),dbname,user,password,host,port,timeout,wait,language,...)
+mc <- function(dbname="demo", user="monetdb", password="monetdb", 
host="localhost", port=50000L, 
+               timeout=86400L, wait=FALSE, language="sql", ...) {
+  
+  dbConnect(MonetDB.R(), dbname, user, password, host, port, timeout, wait, 
language, ...)
 }
 
-# TODO: document, export etc
-mq <- function(db,query,...) {
-  conn <- mc(db,...)
-  res <- dbGetQuery(conn,query)
+mq <- function(dbname, query, ...) {
+  conn <- mc(dbname, ...)
+  res <- dbGetQuery(conn, query)
   dbDisconnect(conn)
   return(res)
 }
 
-setMethod("dbConnect", "MonetDBDriver", def=function(drv,dbname="demo", 
user="monetdb", password="monetdb", host="localhost",port=50000L, 
timeout=86400L, wait=FALSE,language="sql",...,url="") {
-                       if (substring(url,1,10) == "monetdb://") {
-                               dbname <- url
-                       }
-                       port <- as.integer(port)
-                       timeout <- as.integer(timeout)
-                       
-                       if (substring(dbname,1,10) == "monetdb://") {
-                               #warning("MonetDB.R: Using 'monetdb://...' URIs 
in dbConnect() is deprecated. Please switch to dbname, host, port named 
arguments.")
-                               rest <- substring(dbname,11,nchar(dbname))
-                               # split at /, so we get the dbname
-                               slashsplit <- strsplit(rest,"/",fixed=TRUE)
-                               hostport <- slashsplit[[1]][1]
-                               dbname <- slashsplit[[1]][2]
-                               
-                               # TODO: handle IPv6 IPs, they contain : chars, 
later
-                               if (length(grep(":",hostport,fixed=TRUE)) == 1) 
{
-                                       hostportsplit <- 
strsplit(hostport,":",fixed=TRUE)
-                                       host <- hostportsplit[[1]][1]
-                                       port <- hostportsplit[[1]][2]
-                               } else {
-                                       host <- hostport
-                               }
-                       }
-                       
-                       if (DEBUG_QUERY) cat(paste0("II: Connecting to MonetDB 
on host ",host," at port ",port, " to DB ", dbname, " with user ", user," and a 
non-printed password, timeout is ",timeout," seconds.\n"))
-                       socket <- FALSE
-                       if (wait) {
-                               repeat {
-                                       continue <- FALSE
-                                       tryCatch ({
-                                                               # open socket 
with 5-sec timeout so we can check whether everything works
-                                                               socket <- 
socket <<- .Call("mapiConnect",host,port,5,PACKAGE=C_LIBRARY)
-                                                               # authenticate
-                                                               
.monetAuthenticate(socket,dbname,user,password,language=language)
-                                                               # test the 
connection to make sure it works before
-                                                               
.Call("mapiDisconnect",socket,PACKAGE=C_LIBRARY)
-                                                               break
-                                                       }, error = function(e) {
-                                                               if 
("connection" %in% class(socket)) {
-                                                                       
.Call("mapiDisconnect",socket,PACKAGE=C_LIBRARY)
-                                                               }
-                                                               
cat(paste0("Server not ready(",e$message,"), retrying (ESC or CTRL+C to 
abort)\n"))
-                                                               Sys.sleep(1)
-                                                               continue <<- 
TRUE
-                                                       })
-                               }
-                       }
-                       
-                       # make new socket with user-specified timeout
-                       #socket <- socket <<- socketConnection(host = host, 
port = port, 
-                       #       blocking = TRUE, open="r+b",timeout = timeout) 
-                       socket <- 
.Call("mapiConnect",host,port,timeout,PACKAGE=C_LIBRARY)
-                       
.monetAuthenticate(socket,dbname,user,password,language=language)
-                       connenv <- new.env(parent=emptyenv())
-                       connenv$lock <- 0
-                       connenv$deferred <- list()
-                       connenv$exception <- list()
-      
-      conn <- new("MonetDBConnection",socket=socket,connenv=connenv,Id=-1L)
-      if (getOption("monetdb.sequential",F)) {
-        message("MonetDB: Switching to single-threaded query execution")
-        dbSendQuery(conn,"set optimizer='sequential_pipe'")
+setMethod("dbConnect", "MonetDBDriver", def=function(drv, dbname="demo", 
user="monetdb", 
+                                                     password="monetdb", 
host="localhost", port=50000L, timeout=86400L, wait=FALSE, language="sql", 
+                                                     ..., url="") {
+  
+  if (substring(url, 1, 10) == "monetdb://") {
+    dbname <- url
+  }
+  port <- as.integer(port)
+  timeout <- as.integer(timeout)
+  
+  if (substring(dbname, 1, 10) == "monetdb://") {
+    rest <- substring(dbname, 11, nchar(dbname))
+    # split at /, so we get the dbname
+    slashsplit <- strsplit(rest, "/", fixed=TRUE)
+    hostport <- slashsplit[[1]][1]
+    dbname <- slashsplit[[1]][2]
+    
+    # count the number of : in the string
+    ndc <- nchar(hostport) - nchar(gsub(":","",hostport,fixed=T))
+    if (ndc == 0) {
+      host <- hostport
+    }
+    if (ndc == 1) { # ipv4 case, any ipv6 address has more than one :
+      hostportsplit <- strsplit(hostport, ":", fixed=TRUE)
+      host <- hostportsplit[[1]][1]
+      port <- hostportsplit[[1]][2]
+    }
+    if (ndc > 1) { # ipv6 case, now we only need to check for ]:
+      if (length(grep("]:", hostport, fixed=TRUE)) == 1) { # ipv6 with port 
number
+        hostportsplit <- strsplit(hostport, "]:", fixed=TRUE)
+        host <- substring(hostportsplit[[1]][1],2)
+        port <- hostportsplit[[1]][2]
       }
+      else {
+        host <- hostport
+      }
+    }
+  }
+  
+  # validate port number
+  if (length(port) != 1 || port < 1 || port > 65535) {
+    stop("Illegal port number ",port)
+  }
+  
+  if (getOption("monetdb.debug.mapi", F)) message("II: Connecting to MonetDB 
on host ", host, " at "
+                                                  ,"port ", port, " to DB ", 
dbname, " with user ", user, " and a non-printed password, timeout is "
+                                                  , timeout, " seconds.")
+  socket <- FALSE
+  if (wait) {
+    repeat {
+      continue <- FALSE
+      tryCatch ({
+        # open socket with 5-sec timeout so we can check whether everything 
works
+        socket <- socket <<- .Call("mapiConnect", host, port, 5, 
PACKAGE=C_LIBRARY)
+        # authenticate
+        .monetAuthenticate(socket, dbname, user, password, language=language)
+        # test the connection to make sure it works before
+        .Call("mapiDisconnect", socket, PACKAGE=C_LIBRARY)
+        break
+      }, error = function(e) {
+        if ("connection" %in% class(socket)) {
+          .Call("mapiDisconnect", socket, PACKAGE=C_LIBRARY)
+        }
+        message("Server not ready(", e$message, "), retrying (ESC or CTRL+C to 
abort)")
+        Sys.sleep(1)
+        continue <<- TRUE
+      })
+    }
+  }
+  
+  # make new socket with user-specified timeout
+  socket <- .Call("mapiConnect", host, port, timeout, PACKAGE=C_LIBRARY)
+  .monetAuthenticate(socket, dbname, user, password, language=language)
+  connenv <- new.env(parent=emptyenv())
+  connenv$lock <- 0
+  connenv$deferred <- list()
+  connenv$exception <- list()
+  
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to