Changeset: 1d32081ed15b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1d32081ed15b
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/dbi.R
Branch: embedded
Log Message:
R Connector: Moving towards next release
diffs (181 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: 1.0.0
+Version: 1.0.1
Title: Connect MonetDB to R
Authors@R: c(person("Hannes Muehleisen", role = c("aut", "cre"),email =
"[email protected]"),
person("Anthony Damico", role = "aut"),
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
@@ -16,6 +16,8 @@ export(monetdb.server.start)
export(monetdb.server.stop)
export(monetdbd.liststatus)
export(monetdb.liststatus)
+export(monetdb.server.shutdown)
+export(monetdb.server.getpid)
# dplyr.R
export(src_monetdb)
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
@@ -23,7 +23,7 @@ 1.0.0
- Support for running MonetDB in embedded mode (MonetDBLite)
- Support for monetdblite:/some/path URLs in dbConnect()
- Fixed an off-by-one error in type conversion (Thanks, Kirill)
-- Not force-killing mserver when calling monetdb.server.stop on windows and
wait support
+- Wait support for monetdb.server.stop on Windows
- dbWriteTable now invokes monetdb.read.csv when called with a character
vector as value argument
0.9.7
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
@@ -69,6 +69,10 @@ monetdb.server.start <-
# oh the humanity
monetdb.server.stop <- function(correct.pid, wait=TRUE ){
+ .Deprecated("monetdb.server.shutdown")
+ if (getOption('monetdb.debug.control', F)) {
+ message('Killing process ', correct.pid)
+ }
correct.pid <- as.integer(correct.pid)
if (.Platform$OS.type == "windows")
system(paste0("taskkill /F /PID ", correct.pid))
@@ -111,7 +115,7 @@ monetdb.server.setup <-
){
# switch all slashes to match windows
- monetdb.program.path <- normalizePath( monetdb.program.path , mustWork =
FALSE )
+ monetdb.program.path <-
normalizePath(getOption("monetdb.programpath.override", monetdb.program.path),
mustWork = FALSE)
# remove trailing slash from paths, otherwise the server won't start
monetdb.program.path <- gsub("\\\\$|/$", "", monetdb.program.path)
database.directory <- normalizePath( database.directory , mustWork = FALSE
)
@@ -145,7 +149,7 @@ monetdb.server.setup <-
# create the dbfarm's directory
dir.create( dbfl )
if ( .Platform$OS.type == "windows" ) {
- bfl <- paste0(bfl,".bat")
+ bfl <- paste0(bfl, ".bat")
# first find the alleged path of mclient.exe
mcl <- file.path( monetdb.program.path , "bin" )
@@ -157,63 +161,23 @@ monetdb.server.setup <-
bat.contents <-
c(
'@echo off' ,
-
'setlocal' ,
-
- 'rem figure out the folder name' ,
paste0( 'set MONETDB=' , monetdb.program.path ) ,
-
- 'rem extend the search path with our EXE and DLL folders' ,
- 'rem we depend on pthreadVC2.dll having been copied to the lib
folder' ,
'set
PATH=%MONETDB%\\bin;%MONETDB%\\lib;%MONETDB%\\lib\\MonetDB5;%PATH%' ,
-
- 'rem prepare the arguments to mserver5 to tell it where to put the
dbfarm' ,
-
- 'if "%APPDATA%" == "" goto usevar' ,
- 'rem if the APPDATA variable does exist, put the database there' ,
- paste0( 'set MONETDBDIR=' , database.directory , '\\' ) ,
- paste0( 'set MONETDBFARM="--dbpath=' , dbfl , '"' ) ,
- 'goto skipusevar' ,
- ':usevar' ,
- 'rem if the APPDATA variable does not exist, put the database in
the' ,
- 'rem installation folder (i.e. default location, so no command line
argument)' ,
- 'set MONETDBDIR=%MONETDB%\\var\\MonetDB5' ,
- 'set MONETDBFARM=' ,
- ':skipusevar' ,
-
- 'rem the SQL log directory used to be in %MONETDBDIR%, but we now' ,
- 'rem prefer it inside the dbfarm, so move it there' ,
-
- 'if not exist "%MONETDBDIR%\\sql_logs" goto skipmove' ,
paste0(
- 'for /d %%i in ("%MONETDBDIR%"\\sql_logs\\*) do move "%%i"
"%MONETDBDIR%\\' ,
- dbname ,
- '"\\%%~ni\\sql_logs'
- ) ,
- 'rmdir "%MONETDBDIR%\\sql_logs"' ,
- ':skipmove' ,
-
- 'rem start the real server' ,
- paste0(
- '"%MONETDB%\\bin\\mserver5.exe" --set "prefix=%MONETDB%" --set
"exec_prefix=%MONETDB%" %MONETDBFARM% %* --set mapi_port=' ,
- dbport
- ) ,
-
+ '"%MONETDB%\\bin\\mserver5.exe" --daemon=yes --set
"prefix=%MONETDB%" --set "exec_prefix=%MONETDB%" --dbpath=',dbfl,' %* --set
mapi_port=' , dbport) ,
'if ERRORLEVEL 1 pause' ,
-
'endlocal'
-
- )
-
+ )
}
if ( .Platform$OS.type == "unix" ) { # create shell script
bfl <- paste0(bfl,".sh")
bat.contents <- c('#!/bin/sh',
- paste0(
ifelse(monetdb.program.path=="","",paste0(monetdb.program.path,"/")) ,
- 'mserver5 --set
prefix=',monetdb.program.path,' --set exec_prefix=',monetdb.program.path,'
--dbpath ',paste0(database.directory,"/",dbname),' --set mapi_port=' ,
- dbport, " --daemon yes > /dev/null &"
- ),paste0("echo $! >
",database.directory,"/mserver5.started.from.R.pid"))
+ paste0(
ifelse(monetdb.program.path=="","",paste0(monetdb.program.path,"/")) ,
+ 'mserver5 --set prefix=',monetdb.program.path,' --set
exec_prefix=',monetdb.program.path,' --dbpath
',paste0(database.directory,"/",dbname),' --set mapi_port=' ,
+ dbport, " --daemon yes > /dev/null &"
+ ),paste0("echo $! >
",database.directory,"/mserver5.started.from.R.pid"))
}
# write the .bat contents to a file on the local disk
@@ -226,8 +190,7 @@ monetdb.server.setup <-
}
-monetdbd.liststatus <- monetdb.liststatus <- function(passphrase,
host="localhost", port=50000L,
- timeout=86400L) {
+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
@@ -268,3 +231,19 @@ monetdbd.liststatus <- monetdb.liststatu
return(dbdf[order(dbdf$dbname), ])
}
+
+monetdb.server.getpid <- function (con) {
+ as.integer(dbGetQuery(con, "select value from env() where
name='monet_pid'")[[1]])
+}
+
+# this is somewhat evil, no admin rights required to kill server. Even works
on closed connections.
+monetdb.server.shutdown <- function(con) {
+ stopifnot(inherits(con, "MonetDBConnection"))
+ # reconnect with MAL scenario
+ newparms <- con@connenv$params
+ newparms$language <- "mal"
+ newconn <- do.call("dbConnect", newparms)
+ # construct and call MAL function that calls mal_exit()
+ .mapiWrite(newconn@connenv$socket, "pattern exit():void address mal_exit;
user.exit();\n")
+ invisible(TRUE)
+}
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
@@ -175,9 +175,10 @@ setMethod("dbDisconnect", "MonetDBConnec
invisible(TRUE)
})
-setMethod("dbDisconnect", "MonetDBEmbeddedConnection", def=function(conn, ...)
{
+setMethod("dbDisconnect", "MonetDBEmbeddedConnection", def=function(conn,
shutdown=FALSE, ...) {
conn@connenv$open <- FALSE
MonetDBLite::monetdb_embedded_disconnect(conn@connenv$conn)
+ if (shutdown) MonetDBLite::monetdb_embedded_shutdown()
invisible(TRUE)
})
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list