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

Using postgresql-simple to connect to Clickhouse #112

Open
jonathangenlambda opened this issue Apr 27, 2023 · 1 comment
Open

Using postgresql-simple to connect to Clickhouse #112

jonathangenlambda opened this issue Apr 27, 2023 · 1 comment

Comments

@jonathangenlambda
Copy link

We are trying to connect to Clickhouse via its "postgres emulation port" 9005 (see).

Unfortunately sending a simple SELECT 1 query fails with
SqlError {sqlState = "", sqlExecStatus = FatalError, sqlErrorMsg = "", sqlErrorDetail = "", sqlErrorHint = ""}

When looking at the error log of Clickhouse we see:

PostgreSQLHandler: DB::Exception: Syntax error: failed at position 15 ('TO'): TO ISO;SET client_encoding TO UTF8;SET standard_conforming_strings TO on. Expected one of: token, Dot, Equals

We checked the code of postgresql-simple and found the corresponding location in Database.PostgreSQL.Simple.Internal which executes "SET datestyle TO ISO;SET client_encoding TO UTF8;SET standard_conforming_strings TO on" eventually.

I assume currently there is no way to prevent this from getting executed? We will fork the repo and remove this execution and see what happens - maybe this could be made optional?

@jonathangenlambda
Copy link
Author

We have removed the corresponding executiong of "SET datestyle TO ISO;SET client_encoding TO UTF8;SET standard_conforming_strings TO on" and are now able to successfully query Clickhouse via postgresql-simple.

Please consider introducing a configuration/argument that allows for disabling these "SET..." commands.

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