diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b6a065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/RPostgreSQL/.gitignore b/RPostgreSQL/.gitignore new file mode 100644 index 0000000..2f5308e --- /dev/null +++ b/RPostgreSQL/.gitignore @@ -0,0 +1,3 @@ +*.log +*.status +*.dSYM diff --git a/RPostgreSQL/R/PostgreSQL.R b/RPostgreSQL/R/PostgreSQL.R index 8db97c9..8b255e5 100644 --- a/RPostgreSQL/R/PostgreSQL.R +++ b/RPostgreSQL/R/PostgreSQL.R @@ -73,6 +73,11 @@ setMethod("dbConnect", "character", valueClass = "PostgreSQLConnection" ) +setMethod("dbIsValid", "PostgreSQLConnection", + def = function(dbObj, ... ) isPostgresqlIdCurrent(dbObj, ... ), + valueClass = "logical" +) + ## clone a connection setMethod("dbConnect", "PostgreSQLConnection", def = function(drv, ...) postgresqlCloneConnection(drv, ...), @@ -234,6 +239,7 @@ setMethod("dbListFields", flds <- dbGetQuery(conn, paste("select a.attname from pg_attribute a, pg_class c, pg_tables t, pg_namespace nsp", " where a.attrelid = c.oid and c.relname = tablename and c.relnamespace = nsp.oid and a.attnum > 0 and ", + "not a.attisdropped and ", "nspname = current_schema() and schemaname = nspname and ", "tablename = '", postgresqlEscapeStrings(conn, name), "'", sep=""))[,1] } @@ -242,6 +248,7 @@ setMethod("dbListFields", flds <- dbGetQuery(conn, paste("select a.attname from pg_attribute a, pg_class c, pg_tables t, pg_namespace nsp", " where a.attrelid = c.oid and c.relname = t.tablename and c.relnamespace = nsp.oid and a.attnum > 0 and ", + "not a.attisdropped and ", "nspname = schemaname ", "and schemaname = '", postgresqlEscapeStrings(conn, name[1]), "' ", "and tablename = '", postgresqlEscapeStrings(conn, name[2]), "'", sep=""))[,1] diff --git a/RPostgreSQL/R/dbObjectId.R b/RPostgreSQL/R/dbObjectId.R index abf51eb..d8e285e 100644 --- a/RPostgreSQL/R/dbObjectId.R +++ b/RPostgreSQL/R/dbObjectId.R @@ -51,6 +51,7 @@ setMethod("print", "dbObjectId", ## verify that obj refers to a currently open/loaded database isPostgresqlIdCurrent <- function(obj) { + if(is.null(obj)) return(FALSE) obj <- as(obj, "integer") .Call(RS_DBI_validHandle, obj) } diff --git a/RPostgreSQL/src/.gitignore b/RPostgreSQL/src/.gitignore new file mode 100644 index 0000000..aad4fde --- /dev/null +++ b/RPostgreSQL/src/.gitignore @@ -0,0 +1,3 @@ +*.so +*.o +Makevars