[R] sqldf hanging on macintosh - works on windows

GL pflugg at shands.ufl.edu
Mon Nov 1 15:55:18 CET 2010



> 
> library(sqldf)
Loading required package: DBI
Loading required package: RSQLite
Loading required package: RSQLite.extfuns
Loading required package: gsubfn
Loading required package: proto
Loading required package: chron
> debug(sqldf)  
>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
> "df.possible.combos"
+     left join "df.aggregate" using (Hour, Date)')
debugging in: sqldf("select Date, Hour, x as RoomsInUse from
\"df.possible.combos\"\n    left join \"df.aggregate\" using (Hour, Date)")
debug: {
    as.POSIXct.character <- function(x) structure(as.numeric(x), 
        class = c("POSIXt", "POSIXct"))
    as.Date.character <- function(x) structure(as.numeric(x), 
        class = "Date")
    as.Date.numeric <- function(x, origin = "1970-01-01", ...)
base::as.Date.numeric(x, 
        origin = origin, ...)
    as.dates.character <- function(x) structure(as.numeric(x), 
        class = c("dates", "times"))
    as.times.character <- function(x) structure(as.numeric(x), 
        class = "times")
    overwrite <- FALSE
    request.open <- missing(x) && is.null(connection)
    request.close <- missing(x) && !is.null(connection)
    request.con <- !missing(x) && !is.null(connection)
    request.nocon <- !missing(x) && is.null(connection)
    dfnames <- fileobjs <- character(0)
    if (request.close || request.nocon) {
        on.exit({
            dbPreExists <- attr(connection, "dbPreExists")
            dbname <- attr(connection, "dbname")
            if (!missing(dbname) && !is.null(dbname) && dbname == 
                ":memory:") {
                dbDisconnect(connection)
            } else if (!dbPreExists && drv == "sqlite") {
                dbDisconnect(connection)
                file.remove(dbname)
            } else {
                for (nam in dfnames) dbRemoveTable(connection, 
                  nam)
                for (fo in fileobjs) dbRemoveTable(connection, 
                  fo)
                dbDisconnect(connection)
            }
        })
        if (request.close) {
            if (identical(connection, getOption("sqldf.connection"))) 
                options(sqldf.connection = NULL)
            return()
        }
    }
    if (request.open || request.nocon) {
        if (is.null(drv)) {
            drv <- if ("package:RpgSQL" %in% search()) {
                "pgSQL"
            }
            else if ("package:RMySQL" %in% search()) {
                "MySQL"
            }
            else if ("package:RH2" %in% search()) {
                "H2"
            }
            else "SQLite"
        }
        drv <- tolower(drv)
        if (drv == "mysql") {
            m <- dbDriver("MySQL")
            connection <- if (missing(dbname) || dbname == ":memory:") {
                dbConnect(m)
            }
            else dbConnect(m, dbname = dbname)
            dbPreExists <- TRUE
        }
        else if (drv == "pgsql") {
            m <- dbDriver("pgSQL")
            if (missing(dbname) || is.null(dbname)) {
                dbname <- getOption("RpgSQL.dbname")
                if (is.null(dbname)) 
                  dbname <- "test"
            }
            connection <- dbConnect(m, dbname = dbname)
            dbPreExists <- TRUE
        }
        else if (drv == "h2") {
            m <- H2()
            if (missing(dbname) || is.null(dbname)) 
                dbname <- ":memory:"
            dbPreExists <- dbname != ":memory:" && file.exists(dbname)
            connection <- if (missing(dbname) || dbname == ":memory:") {
                dbConnect(m, "jdbc:h2:mem:", "sa", "")
            }
            else {
                jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
                dbConnect(m, jdbc.string)
            }
        }
        else {
            m <- dbDriver("SQLite")
            if (missing(dbname)) 
                dbname <- ":memory:"
            dbPreExists <- dbname != ":memory:" && file.exists(dbname)
            if (is.null(getOption("sqldf.dll"))) {
                dll <- Sys.which("libspatialite-1.dll")
                if (dll != "") 
                  options(sqldf.dll = dll)
                else options(sqldf.dll = FALSE)
            }
            dll <- getOption("sqldf.dll")
            if (length(dll) != 1 || identical(dll, FALSE) || 
                nchar(dll) == 0) {
                dll <- FALSE
            }
            else {
                if (dll == basename(dll)) 
                  dll <- Sys.which(dll)
            }
            options(sqldf.dll = dll)
            if (!identical(dll, FALSE)) {
                connection <- dbConnect(m, dbname = dbname,
loadable.extensions = TRUE)
                s <- sprintf("select load_extension('%s')", dll)
                dbGetQuery(connection, s)
            }
            else connection <- dbConnect(m, dbname = dbname)
            init_extensions(connection)
        }
        attr(connection, "dbPreExists") <- dbPreExists
        if (missing(dbname) && drv == "sqlite") 
            dbname <- ":memory:"
        attr(connection, "dbname") <- dbname
        if (request.open) {
            options(sqldf.connection = connection)
            return(connection)
        }
    }
    if (request.con) {
        drv <- if (inherits(connection, "pgSQLConnection")) 
            "pgSQL"
        else if (inherits(connection, "MySQLConnection")) 
            "MySQL"
        else if (inherits(connection, "H2Connection")) 
            "H2"
        else "SQLite"
        drv <- tolower(drv)
        dbPreExists <- attr(connection, "dbPreExists")
    }
    words. <- words <- strapply(x, "[[:alnum:]._]+")
    if (length(words) > 0) 
        words <- unique(unlist(words))
    is.special <- sapply(mget(words, envir, "any", NA, inherits = TRUE), 
        function(x) is.data.frame(x) + 2 * inherits(x, "file"))
    dfnames <- words[is.special == 1]
    for (i in seq_along(dfnames)) {
        nam <- dfnames[i]
        if (dbPreExists && !overwrite && dbExistsTable(connection, 
            nam)) {
            dfnames <- head(dfnames, i - 1)
            stop(paste("sqldf:", "table", nam, "already in", 
                dbname, "\n"))
        }
        nam2 <- if (drv == "h2") {
            nam
        }
        else if (drv == "pgsql") {
            nam
        }
        else {
            if (regexpr(".", nam, fixed = TRUE)) {
                paste("`", nam, "`", sep = "")
            }
            else nam
        }
        dbWriteTable(connection, nam2, as.data.frame(get(nam, 
            envir)), row.names = row.names)
    }
    fileobjs <- if (is.null(file.format)) {
        character(0)
    }
    else {
        eol <- if (.Platform$OS == "windows") 
            "\r\n"
        else "\n"
        words[is.special == 2]
    }
    for (i in seq_along(fileobjs)) {
        fo <- fileobjs[i]
        Filename <- summary(get(fo, envir))$description
        if (dbPreExists && !overwrite && dbExistsTable(connection, 
            Filename)) {
            fileobjs <- head(fileobjs, i - 1)
            stop(paste("sqldf:", "table", fo, "from file", Filename, 
                "already in", dbname, "\n"))
        }
        args <- c(list(conn = connection, name = fo, value = Filename), 
            modifyList(list(eol = eol), file.format))
        args <- modifyList(args, as.list(attr(get(fo, envir), 
            "file.format")))
        filter <- args$filter
        if (!is.null(filter)) {
            args$filter <- NULL
            Filename.tmp <- tempfile()
            args$value <- Filename.tmp
            cmd <- sprintf("%s < %s > %s", filter, Filename, 
                Filename.tmp)
            if (.Platform$OS == "windows") {
                cmd <- paste("cmd /c", cmd)
                if (FALSE) {
                  key <- "SOFTWARE\\R-core"
                  show.error.messages <- getOption("show.error.message")
                  options(show.error.messages = FALSE)
                  reg <- try(readRegistry(key, maxdepth =
3)$Rtools$InstallPath)
                  reg <- NULL
                  options(show.error.messages = show.error.messages)
                  if (!is.null(reg) && !inherits(reg, "try-error")) {
                    Rtools.path <- file.path(reg, "bin", fsep = "\\")
                    path <- Sys.getenv("PATH")
                    on.exit(Sys.setenv(PATH = path), add = TRUE)
                    path.new <- paste(path, Rtools.path, sep = ";")
                    Sys.setenv(PATH = path.new)
                  }
                }
            }
            system(cmd)
        }
        do.call("dbWriteTable", args)
    }
    if (drv == "sqlite") {
        for (xi in x) rs <- dbGetQuery(connection, xi)
    }
    else {
        for (i in seq_along(x)) {
            if (length(words.[[i]]) > 0) {
                dbGetQueryWords <- c("select", "show", "call", 
                  "explain")
                if (tolower(words.[[i]][1]) %in% dbGetQueryWords) {
                  rs <- dbGetQuery(connection, x[i])
                }
                else {
                  rs <- dbSendUpdate(connection, x[i])
                }
            }
        }
    }
    if (is.null(method)) 
        method <- "auto"
    if (match.arg(method, c("auto", "raw")) == "raw") 
        return(rs)
    rs <- if ("row_names" %in% names(rs)) {
        if (identical(row.names, FALSE)) {
            rs[names(rs) != "row_names"]
        }
        else {
            rn <- rs$row_names
            rs <- rs[names(rs) != "row_names"]
            if (all(regexpr("^[[:digit:]]*$", rn) > 0)) 
                rn <- as.integer(rn)
            rownames(rs) <- rn
            rs
        }
    }
    else rs
    tab <- do.call("rbind", lapply(dfnames, function(dfname) {
        df <- get(dfname, envir)
        cbind(dfname, colnames(df))
    }))
    dup <- tab[, 2][duplicated(tab[, 2])]
    f <- function(i) {
        cn <- colnames(rs)[[i]]
        if (!cn %in% dup && (ix <- match(cn, tab[, 2], nomatch = 0)) > 
            0) {
            df <- get(tab[ix, 1], envir)
            if (inherits(df[[cn]], "ordered")) 
                return(as.ordered(factor(rs[[cn]], levels =
levels(df[[cn]]))))
            else if (inherits(df[[cn]], "factor")) 
                return(factor(rs[[cn]], levels = levels(df[[cn]])))
            else if (inherits(df[[cn]], "POSIXct")) 
                return(as.POSIXct(rs[[cn]]))
            else if (identical(class(df[[cn]]), "times")) 
                return(times(df[[cn]]))
            else {
                asfn <- paste("as", class(df[[cn]]), sep = ".")
                asfn <- match.fun(asfn)
                return(asfn(rs[[cn]]))
            }
        }
        if (stringsAsFactors) 
            if (is.character(rs[[i]])) 
                factor(rs[[i]])
            else rs[[i]]
    }
    rs2 <- lapply(seq_along(rs), f)
    rs[] <- rs2
    rs
}
Browse[2]>    
Browse[2]>    
Browse[2]> 
debug: as.POSIXct.character <- function(x) structure(as.numeric(x), 
    class = c("POSIXt", "POSIXct"))
Browse[2]> 
debug: as.Date.character <- function(x) structure(as.numeric(x), class =
"Date")
Browse[2]> 
debug: as.Date.numeric <- function(x, origin = "1970-01-01", ...)
base::as.Date.numeric(x, 
    origin = origin, ...)
Browse[2]> 
debug: as.dates.character <- function(x) structure(as.numeric(x), class =
c("dates", 
    "times"))
Browse[2]> 
debug: as.times.character <- function(x) structure(as.numeric(x), class =
"times")
Browse[2]> 
debug: overwrite <- FALSE
Browse[2]> 
debug: request.open <- missing(x) && is.null(connection)
Browse[2]> 
debug: request.close <- missing(x) && !is.null(connection)
Browse[2]> 
debug: request.con <- !missing(x) && !is.null(connection)
Browse[2]> 
debug: request.nocon <- !missing(x) && is.null(connection)
Browse[2]> 
debug: dfnames <- fileobjs <- character(0)
Browse[2]> 
debug: if (request.close || request.nocon) {
    on.exit({
        dbPreExists <- attr(connection, "dbPreExists")
        dbname <- attr(connection, "dbname")
        if (!missing(dbname) && !is.null(dbname) && dbname == 
            ":memory:") {
            dbDisconnect(connection)
        } else if (!dbPreExists && drv == "sqlite") {
            dbDisconnect(connection)
            file.remove(dbname)
        } else {
            for (nam in dfnames) dbRemoveTable(connection, nam)
            for (fo in fileobjs) dbRemoveTable(connection, fo)
            dbDisconnect(connection)
        }
    })
    if (request.close) {
        if (identical(connection, getOption("sqldf.connection"))) 
            options(sqldf.connection = NULL)
        return()
    }
}
Browse[2]> 
debug: {
    on.exit({
        dbPreExists <- attr(connection, "dbPreExists")
        dbname <- attr(connection, "dbname")
        if (!missing(dbname) && !is.null(dbname) && dbname == 
            ":memory:") {
            dbDisconnect(connection)
        } else if (!dbPreExists && drv == "sqlite") {
            dbDisconnect(connection)
            file.remove(dbname)
        } else {
            for (nam in dfnames) dbRemoveTable(connection, nam)
            for (fo in fileobjs) dbRemoveTable(connection, fo)
            dbDisconnect(connection)
        }
    })
    if (request.close) {
        if (identical(connection, getOption("sqldf.connection"))) 
            options(sqldf.connection = NULL)
        return()
    }
}
Browse[2]> 
debug: on.exit({
    dbPreExists <- attr(connection, "dbPreExists")
    dbname <- attr(connection, "dbname")
    if (!missing(dbname) && !is.null(dbname) && dbname == ":memory:") {
        dbDisconnect(connection)
    } else if (!dbPreExists && drv == "sqlite") {
        dbDisconnect(connection)
        file.remove(dbname)
    } else {
        for (nam in dfnames) dbRemoveTable(connection, nam)
        for (fo in fileobjs) dbRemoveTable(connection, fo)
        dbDisconnect(connection)
    }
})
Browse[2]> 
debug: if (request.close) {
    if (identical(connection, getOption("sqldf.connection"))) 
        options(sqldf.connection = NULL)
    return()
}
Browse[2]> 
debug: NULL
Browse[2]> 
debug: if (request.open || request.nocon) {
    if (is.null(drv)) {
        drv <- if ("package:RpgSQL" %in% search()) {
            "pgSQL"
        }
        else if ("package:RMySQL" %in% search()) {
            "MySQL"
        }
        else if ("package:RH2" %in% search()) {
            "H2"
        }
        else "SQLite"
    }
    drv <- tolower(drv)
    if (drv == "mysql") {
        m <- dbDriver("MySQL")
        connection <- if (missing(dbname) || dbname == ":memory:") {
            dbConnect(m)
        }
        else dbConnect(m, dbname = dbname)
        dbPreExists <- TRUE
    }
    else if (drv == "pgsql") {
        m <- dbDriver("pgSQL")
        if (missing(dbname) || is.null(dbname)) {
            dbname <- getOption("RpgSQL.dbname")
            if (is.null(dbname)) 
                dbname <- "test"
        }
        connection <- dbConnect(m, dbname = dbname)
        dbPreExists <- TRUE
    }
    else if (drv == "h2") {
        m <- H2()
        if (missing(dbname) || is.null(dbname)) 
            dbname <- ":memory:"
        dbPreExists <- dbname != ":memory:" && file.exists(dbname)
        connection <- if (missing(dbname) || dbname == ":memory:") {
            dbConnect(m, "jdbc:h2:mem:", "sa", "")
        }
        else {
            jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
            dbConnect(m, jdbc.string)
        }
    }
    else {
        m <- dbDriver("SQLite")
        if (missing(dbname)) 
            dbname <- ":memory:"
        dbPreExists <- dbname != ":memory:" && file.exists(dbname)
        if (is.null(getOption("sqldf.dll"))) {
            dll <- Sys.which("libspatialite-1.dll")
            if (dll != "") 
                options(sqldf.dll = dll)
            else options(sqldf.dll = FALSE)
        }
        dll <- getOption("sqldf.dll")
        if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) == 
            0) {
            dll <- FALSE
        }
        else {
            if (dll == basename(dll)) 
                dll <- Sys.which(dll)
        }
        options(sqldf.dll = dll)
        if (!identical(dll, FALSE)) {
            connection <- dbConnect(m, dbname = dbname, loadable.extensions
= TRUE)
            s <- sprintf("select load_extension('%s')", dll)
            dbGetQuery(connection, s)
        }
        else connection <- dbConnect(m, dbname = dbname)
        init_extensions(connection)
    }
    attr(connection, "dbPreExists") <- dbPreExists
    if (missing(dbname) && drv == "sqlite") 
        dbname <- ":memory:"
    attr(connection, "dbname") <- dbname
    if (request.open) {
        options(sqldf.connection = connection)
        return(connection)
    }
}
Browse[2]> 
debug: {
    if (is.null(drv)) {
        drv <- if ("package:RpgSQL" %in% search()) {
            "pgSQL"
        }
        else if ("package:RMySQL" %in% search()) {
            "MySQL"
        }
        else if ("package:RH2" %in% search()) {
            "H2"
        }
        else "SQLite"
    }
    drv <- tolower(drv)
    if (drv == "mysql") {
        m <- dbDriver("MySQL")
        connection <- if (missing(dbname) || dbname == ":memory:") {
            dbConnect(m)
        }
        else dbConnect(m, dbname = dbname)
        dbPreExists <- TRUE
    }
    else if (drv == "pgsql") {
        m <- dbDriver("pgSQL")
        if (missing(dbname) || is.null(dbname)) {
            dbname <- getOption("RpgSQL.dbname")
            if (is.null(dbname)) 
                dbname <- "test"
        }
        connection <- dbConnect(m, dbname = dbname)
        dbPreExists <- TRUE
    }
    else if (drv == "h2") {
        m <- H2()
        if (missing(dbname) || is.null(dbname)) 
            dbname <- ":memory:"
        dbPreExists <- dbname != ":memory:" && file.exists(dbname)
        connection <- if (missing(dbname) || dbname == ":memory:") {
            dbConnect(m, "jdbc:h2:mem:", "sa", "")
        }
        else {
            jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
            dbConnect(m, jdbc.string)
        }
    }
    else {
        m <- dbDriver("SQLite")
        if (missing(dbname)) 
            dbname <- ":memory:"
        dbPreExists <- dbname != ":memory:" && file.exists(dbname)
        if (is.null(getOption("sqldf.dll"))) {
            dll <- Sys.which("libspatialite-1.dll")
            if (dll != "") 
                options(sqldf.dll = dll)
            else options(sqldf.dll = FALSE)
        }
        dll <- getOption("sqldf.dll")
        if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) == 
            0) {
            dll <- FALSE
        }
        else {
            if (dll == basename(dll)) 
                dll <- Sys.which(dll)
        }
        options(sqldf.dll = dll)
        if (!identical(dll, FALSE)) {
            connection <- dbConnect(m, dbname = dbname, loadable.extensions
= TRUE)
            s <- sprintf("select load_extension('%s')", dll)
            dbGetQuery(connection, s)
        }
        else connection <- dbConnect(m, dbname = dbname)
        init_extensions(connection)
    }
    attr(connection, "dbPreExists") <- dbPreExists
    if (missing(dbname) && drv == "sqlite") 
        dbname <- ":memory:"
    attr(connection, "dbname") <- dbname
    if (request.open) {
        options(sqldf.connection = connection)
        return(connection)
    }
}
Browse[2]> 
debug: if (is.null(drv)) {
    drv <- if ("package:RpgSQL" %in% search()) {
        "pgSQL"
    }
    else if ("package:RMySQL" %in% search()) {
        "MySQL"
    }
    else if ("package:RH2" %in% search()) {
        "H2"
    }
    else "SQLite"
}
Browse[2]> 
debug: {
    drv <- if ("package:RpgSQL" %in% search()) {
        "pgSQL"
    }
    else if ("package:RMySQL" %in% search()) {
        "MySQL"
    }
    else if ("package:RH2" %in% search()) {
        "H2"
    }
    else "SQLite"
}
Browse[2]> 
debug: drv <- if ("package:RpgSQL" %in% search()) {
    "pgSQL"
} else if ("package:RMySQL" %in% search()) {
    "MySQL"
} else if ("package:RH2" %in% search()) {
    "H2"
} else "SQLite"
Browse[2]> 
debug: if ("package:RMySQL" %in% search()) {
    "MySQL"
} else if ("package:RH2" %in% search()) {
    "H2"
} else "SQLite"
Browse[2]> 
debug: if ("package:RH2" %in% search()) {
    "H2"
} else "SQLite"
Browse[2]> 
debug: [1] "SQLite"
Browse[2]> 
debug: drv <- tolower(drv)
Browse[2]> 
debug: if (drv == "mysql") {
    m <- dbDriver("MySQL")
    connection <- if (missing(dbname) || dbname == ":memory:") {
        dbConnect(m)
    }
    else dbConnect(m, dbname = dbname)
    dbPreExists <- TRUE
} else if (drv == "pgsql") {
    m <- dbDriver("pgSQL")
    if (missing(dbname) || is.null(dbname)) {
        dbname <- getOption("RpgSQL.dbname")
        if (is.null(dbname)) 
            dbname <- "test"
    }
    connection <- dbConnect(m, dbname = dbname)
    dbPreExists <- TRUE
} else if (drv == "h2") {
    m <- H2()
    if (missing(dbname) || is.null(dbname)) 
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    connection <- if (missing(dbname) || dbname == ":memory:") {
        dbConnect(m, "jdbc:h2:mem:", "sa", "")
    }
    else {
        jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
        dbConnect(m, jdbc.string)
    }
} else {
    m <- dbDriver("SQLite")
    if (missing(dbname)) 
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    if (is.null(getOption("sqldf.dll"))) {
        dll <- Sys.which("libspatialite-1.dll")
        if (dll != "") 
            options(sqldf.dll = dll)
        else options(sqldf.dll = FALSE)
    }
    dll <- getOption("sqldf.dll")
    if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) == 
        0) {
        dll <- FALSE
    }
    else {
        if (dll == basename(dll)) 
            dll <- Sys.which(dll)
    }
    options(sqldf.dll = dll)
    if (!identical(dll, FALSE)) {
        connection <- dbConnect(m, dbname = dbname, loadable.extensions =
TRUE)
        s <- sprintf("select load_extension('%s')", dll)
        dbGetQuery(connection, s)
    }
    else connection <- dbConnect(m, dbname = dbname)
    init_extensions(connection)
}
Browse[2]> 
debug: if (drv == "pgsql") {
    m <- dbDriver("pgSQL")
    if (missing(dbname) || is.null(dbname)) {
        dbname <- getOption("RpgSQL.dbname")
        if (is.null(dbname)) 
            dbname <- "test"
    }
    connection <- dbConnect(m, dbname = dbname)
    dbPreExists <- TRUE
} else if (drv == "h2") {
    m <- H2()
    if (missing(dbname) || is.null(dbname)) 
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    connection <- if (missing(dbname) || dbname == ":memory:") {
        dbConnect(m, "jdbc:h2:mem:", "sa", "")
    }
    else {
        jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
        dbConnect(m, jdbc.string)
    }
} else {
    m <- dbDriver("SQLite")
    if (missing(dbname)) 
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    if (is.null(getOption("sqldf.dll"))) {
        dll <- Sys.which("libspatialite-1.dll")
        if (dll != "") 
            options(sqldf.dll = dll)
        else options(sqldf.dll = FALSE)
    }
    dll <- getOption("sqldf.dll")
    if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) == 
        0) {
        dll <- FALSE
    }
    else {
        if (dll == basename(dll)) 
            dll <- Sys.which(dll)
    }
    options(sqldf.dll = dll)
    if (!identical(dll, FALSE)) {
        connection <- dbConnect(m, dbname = dbname, loadable.extensions =
TRUE)
        s <- sprintf("select load_extension('%s')", dll)
        dbGetQuery(connection, s)
    }
    else connection <- dbConnect(m, dbname = dbname)
    init_extensions(connection)
}
Browse[2]> 
debug: if (drv == "h2") {
    m <- H2()
    if (missing(dbname) || is.null(dbname)) 
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    connection <- if (missing(dbname) || dbname == ":memory:") {
        dbConnect(m, "jdbc:h2:mem:", "sa", "")
    }
    else {
        jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
        dbConnect(m, jdbc.string)
    }
} else {
    m <- dbDriver("SQLite")
    if (missing(dbname)) 
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    if (is.null(getOption("sqldf.dll"))) {
        dll <- Sys.which("libspatialite-1.dll")
        if (dll != "") 
            options(sqldf.dll = dll)
        else options(sqldf.dll = FALSE)
    }
    dll <- getOption("sqldf.dll")
    if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) == 
        0) {
        dll <- FALSE
    }
    else {
        if (dll == basename(dll)) 
            dll <- Sys.which(dll)
    }
    options(sqldf.dll = dll)
    if (!identical(dll, FALSE)) {
        connection <- dbConnect(m, dbname = dbname, loadable.extensions =
TRUE)
        s <- sprintf("select load_extension('%s')", dll)
        dbGetQuery(connection, s)
    }
    else connection <- dbConnect(m, dbname = dbname)
    init_extensions(connection)
}
Browse[2]> 
debug: {
    m <- dbDriver("SQLite")
    if (missing(dbname)) 
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    if (is.null(getOption("sqldf.dll"))) {
        dll <- Sys.which("libspatialite-1.dll")
        if (dll != "") 
            options(sqldf.dll = dll)
        else options(sqldf.dll = FALSE)
    }
    dll <- getOption("sqldf.dll")
    if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) == 
        0) {
        dll <- FALSE
    }
    else {
        if (dll == basename(dll)) 
            dll <- Sys.which(dll)
    }
    options(sqldf.dll = dll)
    if (!identical(dll, FALSE)) {
        connection <- dbConnect(m, dbname = dbname, loadable.extensions =
TRUE)
        s <- sprintf("select load_extension('%s')", dll)
        dbGetQuery(connection, s)
    }
    else connection <- dbConnect(m, dbname = dbname)
    init_extensions(connection)
}
Browse[2]> 
debug: m <- dbDriver("SQLite")
Browse[2]> 
debug: if (missing(dbname)) dbname <- ":memory:"
Browse[2]> 
debug: dbname <- ":memory:"
Browse[2]> 
debug: dbPreExists <- dbname != ":memory:" && file.exists(dbname)
Browse[2]> 
debug: if (is.null(getOption("sqldf.dll"))) {
    dll <- Sys.which("libspatialite-1.dll")
    if (dll != "") 
        options(sqldf.dll = dll)
    else options(sqldf.dll = FALSE)
}
Browse[2]> 
debug: {
    dll <- Sys.which("libspatialite-1.dll")
    if (dll != "") 
        options(sqldf.dll = dll)
    else options(sqldf.dll = FALSE)
}
Browse[2]> 
debug: dll <- Sys.which("libspatialite-1.dll")
Browse[2]> 
debug: if (dll != "") options(sqldf.dll = dll) else options(sqldf.dll =
FALSE)
Browse[2]> 
debug: options(sqldf.dll = FALSE)
Browse[2]> 
debug: dll <- getOption("sqldf.dll")
Browse[2]> 
debug: if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) == 
    0) {
    dll <- FALSE
} else {
    if (dll == basename(dll)) 
        dll <- Sys.which(dll)
}
Browse[2]> 
debug: {
    dll <- FALSE
}
Browse[2]> 
debug: dll <- FALSE
Browse[2]> 
debug: options(sqldf.dll = dll)
Browse[2]> 
debug: if (!identical(dll, FALSE)) {
    connection <- dbConnect(m, dbname = dbname, loadable.extensions = TRUE)
    s <- sprintf("select load_extension('%s')", dll)
    dbGetQuery(connection, s)
} else connection <- dbConnect(m, dbname = dbname)
Browse[2]> 
debug: connection <- dbConnect(m, dbname = dbname)
Browse[2]> 
debug: init_extensions(connection)
Browse[2]> 
debug: attr(connection, "dbPreExists") <- dbPreExists
Browse[2]> 
debug: if (missing(dbname) && drv == "sqlite") dbname <- ":memory:"
Browse[2]> 
debug: NULL
Browse[2]> 
debug: attr(connection, "dbname") <- dbname
Browse[2]> 
debug: if (request.open) {
    options(sqldf.connection = connection)
    return(connection)
}
Browse[2]> 
debug: NULL
Browse[2]> 
debug: if (request.con) {
    drv <- if (inherits(connection, "pgSQLConnection")) 
        "pgSQL"
    else if (inherits(connection, "MySQLConnection")) 
        "MySQL"
    else if (inherits(connection, "H2Connection")) 
        "H2"
    else "SQLite"
    drv <- tolower(drv)
    dbPreExists <- attr(connection, "dbPreExists")
}
Browse[2]> 
debug: NULL
Browse[2]> 
debug: words. <- words <- strapply(x, "[[:alnum:]._]+")
Browse[2]> 
Loading required package: tcltk
Loading Tcl/Tk interface ... 
+ 
> 
> 
> 
> 
-- 
View this message in context: http://r.789695.n4.nabble.com/sqldf-hanging-on-macintosh-works-on-windows-tp3022193p3022263.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list