Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBI::dbIsValid does not seem to work with postgres #264

Open
ablack3 opened this issue Jan 17, 2024 · 0 comments
Open

DBI::dbIsValid does not seem to work with postgres #264

ablack3 opened this issue Jan 17, 2024 · 0 comments

Comments

@ablack3
Copy link
Collaborator

ablack3 commented Jan 17, 2024

Expectation:
DBI::dbIsValid(connection) should return false if the connection is closed.

Actual behavior: DBI::dbIsValid(connection) returns true when the connection is closed in this postgres example.

con <- DBI::dbConnect(DatabaseConnector::DatabaseConnectorDriver(),
               dbms = "postgresql",
               server = Sys.getenv("CDM5_POSTGRESQL_SERVER"),
               user = Sys.getenv("CDM5_POSTGRESQL_USER"),
               password = Sys.getenv("CDM5_POSTGRESQL_PASSWORD"))


DBI::dbIsValid(con)
#> TRUE
DBI::dbDisconnect(con)
# this returns true
DBI::dbIsValid(con)
#> TRUE
# even though the connection is closed
DBI::dbListTables(con)
#> Error in rJava::.jcall(conn@jConnection, "Ljava/sql/DatabaseMetaData;",  : 
  org.postgresql.util.PSQLException: This connection has been closed.

I can run this code interactively but when I run it using the reprex package it crashes R on my machine which is why I'm not able to provide an actual reprex.

image
> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.0

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Amsterdam
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.7.5             DatabaseConnector_6.3.2 usethis_2.2.2           testthat_3.2.0         

loaded via a namespace (and not attached):
 [1] xfun_0.40         bslib_0.5.1       processx_3.8.2    rJava_1.0-6       gargle_1.5.2     
 [6] callr_3.7.3       vctrs_0.6.5       odbc_1.3.5        tools_4.3.1       ps_1.7.5         
[11] generics_0.1.3    tibble_3.2.1      fansi_1.0.6       RSQLite_2.3.2     blob_1.2.4       
[16] pkgconfig_2.0.3   R.oo_1.25.0       checkmate_2.3.0   dbplyr_2.4.0      assertthat_0.2.1 
[21] lifecycle_1.0.4   R.cache_0.16.0    compiler_4.3.1    brio_1.1.3        bigrquery_1.4.2  
[26] httpuv_1.6.11     sass_0.4.7        htmltools_0.5.6   yaml_2.3.7        jquerylib_0.1.4  
[31] pillar_1.9.0      later_1.3.1       ellipsis_0.3.2    R.utils_2.12.2    cachem_1.0.8     
[36] RPostgres_1.4.6   mime_0.12         styler_1.10.2     tidyselect_1.2.0  digest_0.6.33    
[41] dplyr_1.1.4       duckdb_0.8.1-3    purrr_1.0.2       fastmap_1.1.1     cli_3.6.2        
[46] magrittr_2.0.3    triebeard_0.4.1   utf8_1.2.4        clipr_0.8.0       withr_2.5.2      
[51] promises_1.2.1    backports_1.4.1   bit64_4.0.5       rmarkdown_2.24    httr_1.4.7       
[56] bit_4.0.5         R.methodsS3_1.8.2 hms_1.1.3         memoise_2.0.1     evaluate_0.23    
[61] knitr_1.44        miniUI_0.1.1.1    rlang_1.1.2       urltools_1.7.3    Rcpp_1.0.11      
[66] xtable_1.8-4      glue_1.6.2        DBI_1.2.0         reprex_2.0.2      rstudioapi_0.15.0
[71] jsonlite_1.8.7    R6_2.5.1          fs_1.6.3   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant