Brent
2015-Feb-14 22:06 UTC
[R] RMySQL works inside function, but prints Error output when executed outside a function
On my computer, if I execute this R code inside the console of Rgui.exe
??? execInsideFunction = function() {
??? ??? dbc = dbcLocal
??? ??? conn <- dbConnect(MySQL(), host = dbc$host, dbname = "xxx",
user=dbc$user, password=dbc$password)
??? ??? dbSendQuery(conn, "delete from yyy")
??? ??? dbDisconnect(conn)
??? }
??? execInsideFunction()
It seems to work fine, printing
??? [1] TRUE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
However, if I copy the body of that function
??? dbc = dbcLocal
??? conn <- dbConnect(MySQL(), host = dbc$host, dbname = "goral",
user=dbc$user, password=dbc$password)
??? dbSendQuery(conn, "delete from archive_batches")
??? dbDisconnect(conn)
and paste it the console to execute it, then it prints the Error output
??? Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?
??? Error during wrapup: evaluation nested too deeply: infinite recursion /
options(expressions=)?
What the heck is happening?!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I note that that Error output appears to be bogus: the database action (delete
all rows from a table above) is actually carried out.? Indeed, the 2nd line
("Error during wrapup") indicates that the error only occurred later
on.
Still, it is disturbing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note: I am using Revolution R Open 8.01-Beta 64 bit.
Below is the output when I execute sessionInfo():
??? R version 3.1.2 (2014-10-31)
??? Platform: x86_64-w64-mingw32/x64 (64-bit)
??? locale:
??? [1] LC_COLLATE=English_United States.1252? LC_CTYPE=English_United
States.1252??? LC_MONETARY=English_United States.1252 LC_NUMERIC=C??? ??????????
LC_TIME=English_United States.1252??
??? attached base packages:
??? [1] grDevices datasets? tcltk???? stats???? tools???? utils???? graphics?
methods?? base???
??? other attached packages:
??? [1] timeDate_3011.99 stringr_0.6.2??? RODBC_1.3-10???? quantmod_0.4-3??
quadprog_1.5-5?? gWidgets_0.0-54? debug_1.3.1????? goralSpeedUp_1.0
RMySQL_0.9-3???? DBI_0.3.1??????? bitops_1.0-6???? caTools_1.17.1??
lattice_0.20-29? TTR_0.22-0?????? xts_0.9-7??????? zoo_1.7-11??????
Rcpp_0.11.3????? mvbutils_2.7.4.1
??? [19] Matrix_1.1-4???? inline_0.3.13?
??? loaded via a namespace (and not attached):
??? [1] grid_3.1.2
[[alternative HTML version deleted]]