Comments (18)
Thanks for the detailed report. A Redshift connection works with my M1 Mac, but I never tried sslmode
.
Would you be comfortable cloning the repository and running a tweaked version for debugging?
from rpostgres.
Sure, I'm happy to dig in. Thanks for the quick response.
from rpostgres.
from rpostgres.
It fails here with length(opts) > 0.
if (length(opts) == 0) { ptr <- connection_create(character(), character(), check_interrupts) } else { ptr <- connection_create(names(opts), as.vector(opts), check_interrupts) }
from rpostgres.
Printing opts shows the correct dbname, user, host, and port. client_encoding is also set to "utf8". I tried setting it manually to utf16 and tried using check_interrupts as TRUE and FALSE but same error each time.
from rpostgres.
I've further identified the issue happens in the DbConnection::DbConnection() function in the file DbConnection.cpp at pConn_ = PQconnectdbParams(&c_keys[0], &c_values[0], false);
. This returns CONNECTION_BAD.
from rpostgres.
Thanks. I wonder what RPostgreSQL is doing differently. Perhaps we can slightly change what we do here, to improve matters.
from rpostgres.
I'm happy to try anything. I don't think anything's likely wrong with the package. I imagine I have some symlink issue or something preventing this from working correctly.
from rpostgres.
If you could clone the RPostgreSQL code and take a look what the connection call is looking like there, and with what arguments?
from rpostgres.
The connection call in RPostgreSQL is my_connection = PQsetdbLogin(host, port, options, tty, dbname, user, password);
. I then changed the connection code for RPostgres to use PQsetdbLogin instead of PQconnectdbParams and received the same error as before for Redshift. Also, as before, I was able to successfully connect to an AWS Aurora database. I can't tell any difference between RPostgreSQL and RPostgres when both are using PQsetdbLogin to create the connection. The only question I have now is if RPostgres isn't using the same version of libpq on my system as RPostgreSQL. Any ideas on a good way to test that?
from rpostgres.
Thanks. When I run R CMD INSTALL .
for RPostgres, I'm seeing:
Using PKG_CFLAGS=-I/Users/kirill/git/R/r-dbi/RPostgres/.deps/include
Using PKG_LIBS=-L/Users/kirill/git/R/r-dbi/RPostgres/.deps/lib -lbrewpq -lbrewpgport -lbrewpgcommon -lbrewssl -lbrewcrypto -lldap -dynamic -Wl,-search_paths_first -lkrb5
Using PKG_PLOGR=-DPLOGR_ENABLE
Perhaps RPostgreSQL installation shows similar information?
from rpostgres.
I installed RPostgreSQL from source and noticed this in the install logs.
system -lpq don't appear to work; use internal configure: Using internal package libpq-fe.h checking for "src/libpq/libpq-fe.h"... yes configure: creating ./config.status config.status: creating src/Makevars
Above this, there were other checks that seem like they should have been successful, but weren't. For example, I can run pg_config on in terminal and get information, so checking for pg_config... no
seems odd to me.
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking build system type... aarch64-apple-darwin21.5.0
checking host system type... aarch64-apple-darwin21.5.0
checking target system type... aarch64-apple-darwin21.5.0
checking for pg_config... no
configure: checking for PostgreSQL header files
configure: Checking include /usr/include.
configure: Checking include /usr/include/postgresql.
configure: Checking include /usr/local/include.
configure: Checking include /usr/local/include/postgresql.
configure: Checking include /usr/local/pgsql/include.
configure: Checking include /usr/local/postgresql/include.
configure: Checking lib /usr/lib.
configure: Checking lib /usr/lib/postgresql.
configure: Checking lib /usr/local/lib.
configure: Checking lib /usr/local/lib/postgresql.
configure: Checking lib /usr/local/postgresql/lib.
gcc -g -O2 -I -L conftest.c -lpq -o pqconftest
from rpostgres.
Also when I run DBI::dbGetInfo(RPostgres::Postgres())
, I should get the version of libpq it's using, right? When I run it I get $client.version [1] ‘13.2’
. However, I brew installed version 14.5 which is the one returned by which psql
. Do I have a rogue version of libpq on my machine?
from rpostgres.
Good catch: 13.2 might come from our autobrew script. Can you try setting the DISABLE_AUTOBREW
environment variable to 1, and rerun?
from rpostgres.
Success! I had to set DISABLE_AUTOBREW to 1, and add /opt/homebrew/opt/libpq/bin to my PATH in RStudio, then install from source. RPostgres::dbGetInfo(RPostgres::Postgres())
now shows 14.5 as expected, and I can connect to the Redshift database!
Thanks so much for your patience with this!
from rpostgres.
Thank you for pushing through!
@jeroen: the autobrew version of libpq seems to be too old to support Redshift. What's the best way to proceed?
from rpostgres.
I'll look into this. I upgraded the autobrew versions for MacOS 11.0+ (including arm) to libpq 14.5. So you can test those from:
install.packages("RPostgres", repos = 'https://r-dbi.r-universe.dev')
However CRAN still tarets macos high-sierra (10.13) and I'm having difficulty getting the new libpq to work on there.
from rpostgres.
I've now also updated the other autobrew versions. So when you submit the next version to CRAN, new MacOS binaries will automatically be built with the new version.
from rpostgres.
Related Issues (20)
- `dbListObjects()` does not list empty schemata HOT 4
- INSERT with placeholders via dbExecute does not work HOT 2
- Redshift Scientific Notation Triggers Incorrect Multiple Queries Error HOT 1
- Breaking change to dbQuoteLiteral with NA in 1.4.2 HOT 10
- connection fails with error: view 'pg_type' not found HOT 3
- Are limitations of select() hurting us? HOT 1
- Unable to create database connection, crashes, produces unprintable characters HOT 7
- List tables in schema with dbListTables HOT 3
- Converting RPostgres backend to cpp11 HOT 4
- Site to test the same database in multiple backends HOT 1
- `dbWriteTable(temporary = TRUE, overwrite = TRUE)` deletes non-temporary table! HOT 1
- Printing of "invalid" `PqConnection` object HOT 1
- binding parameters fails with input from dbQuoteLiteral HOT 2
- Connection closed unexpectedly by server HOT 9
- Encoding issue with identifiers passed via dbWriteTable or copy_to? HOT 4
- Cannot use DBI::dbWriteTable to save temporary table to Redshift HOT 2
- Failure to acquire connections on Mac OS within multicore fork()-ed process HOT 2
- Redshift varchar character length not respected by dplyr::rows_*() HOT 5
- collation warning on Ubuntu 22.04 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rpostgres.