Postgres errors getting printed twice

49 views
Skip to first unread message

Zach

unread,
Oct 30, 2014, 6:25:16 PM10/30/14
to rpostgr...@googlegroups.com
Hello,

I'm running into an error where all postgres error messages are returned
twice: once in a manner that bypasses all R I/O, and once as an R warning.
I am posting to this list because I am curious if anyone else has encountered
this kind of error, and if so, how might I solve it?

I've tested the below code on:
mac (Platform: x86_64-apple-darwin13.1.0 (64-bit))
redhat server (Platform: x86_64-redhat-linux-gnu (64-bit))
ubuntu server (Platform: x86_64-pc-linux-gnu (64-bit)).
All of them with R 3.1.1, RPostgreSQL_0.4, and DBI_0.3.1.

All 3 platforms generate the exact same result. I do not have access to a
windows machine, but as soon as I figure out how to login to a windows EC2
instance I will test it there as well.

I connect to my database as follows:
library('RPostgreSQL')
con <- dbConnect(PostgreSQL(),
user='me',
password='noonewilleverbelieveyou',
host='myserver',
dbname='mydb',
port = '42')

After connecting, I run a query that generates an error:
dbGetQuery(con, 'bogus query;')

I get the following output:
Error in postgresqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not Retrieve the result :
ERROR: syntax error at or near "bogus"
LINE 1: bogus query;
^
)
NULL
Warning message:
In postgresqlQuickSQL(conn, statement, ...) :
Could not create executebogus query;

There are 2 errors in this result:
"Error in postgresqlExecStatement(conn, statement, ...) : "
"Warning message".

While I can suppress the warning with suppressWarnings(), nothing I do
can suppress the error. Furthermore, it doesn't actually seem to affect
the R process at all. As far as I can tell, R is not even aware that this
error has occurred and been printed to the console.

For example the following code should:
1. Suppress all errors
2. Suppress all warnings
3. Suppress all messages
4. Divert all output to '/dev/null'
capture.output(
suppressMessages(
suppressWarnings(
tryCatch(
dbGetQuery(con, 'bogus query;'), error=function(e) return(NULL)
)
)
), file='/dev/null')

And yet, this code still prints out the error message:
Error in postgresqlExecStatement(conn, statement, ...) :
RS-DBI driver:
(could not Retrieve the result : ERROR: syntax error at or near "bogus"
LINE 1: bogus query;
^
)

Is there something about postgres I don't understand? I'm running on this
on 3 different platforms, with 3 different postgres drivers, and getting
the exact same result on each machine. Has anyone else encountered issues
with superfluous messagesfrom postgress, and if so, how do you squash them?

Thank you for your help— this has been driving me nuts. I'd be happy to
provide any additional information you request. If you'd like to reproduce
the error:
startup a new ubunutu amazon EC2 instance
apt-get install postgresql-dev
apt-get install r
install.packages('RPostgreSQL')
connect to your database
run a bogus query.

Thanks again.

-Zach




Reply all
Reply to author
Forward
0 new messages