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

Avoid sending client encoding query at startup if not necessary #542

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ext/pg_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -4176,8 +4176,11 @@ pgconn_set_default_encoding( VALUE self )

rb_check_frozen(self);
if (( enc = rb_default_internal_encoding() )) {
rb_encoding * conn_encoding = pg_conn_enc_get( conn );
encname = pg_get_rb_encoding_as_pg_encoding( enc );
if ( pgconn_set_client_encoding_async(self, rb_str_new_cstr(encname)) != 0 )
bool ruby_and_conn_encoding_equal = conn_encoding && strcmp(enc->name, conn_encoding->name) == 0;

if ( !ruby_and_conn_encoding_equal && pgconn_set_client_encoding_async(self, rb_str_new_cstr(encname)) != 0 )
rb_warning( "Failed to set the default_internal encoding to %s: '%s'",
encname, PQerrorMessage(conn) );
return rb_enc_from_encoding( enc );
Expand Down
Loading