tomoakin / RPostgreSQL

Automatically exported from code.google.com/p/rpostgresql
64 stars 19 forks source link

dbSendQuery segfault on bad SQL query #120

Closed rmcgehee closed 2 years ago

rmcgehee commented 2 years ago

In RPostgreSQL versions 0.7-2 and 0.7-3, but not in version 0.7, a SQL statement with a syntax error error causes a segfault. For example:

> dbSendQuery(con, "SELECT bad;")

 *** caught segfault ***
address 0xffffffff, cause 'memory not mapped'

Traceback:
 1: postgresqlExecStatement(conn, statement, ...)
 2: dbSendQuery(con, "SELECT bad;")
 3: dbSendQuery(con, "SELECT bad;")

In earlier versions of RPostgreSQL (0.7 and before) I get this error message passed along from Postgres:

> dbFetch(dbSendQuery(con, "SELECT bad;"))
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'res' in selecting a method for function 'dbFetch': RS-DBI driver: (could not Retrieve the result : ERROR:  column "bad" does not exist
LINE 1: SELECT bad;
               ^
)

I'm on Linux/Centos 7.8. The behavior is the same when linking against both Postgres 14.1 and Postgres 12.4 and on R versions 4.0.2 and 4.1.2. Thanks

rmcgehee commented 2 years ago

Ahh, I see this has been fixed in github by #119 , it just hadn't been pushed to CRAN yet. I'll update to get this version from github.