Commit d6ca510d authored by Joe Conway's avatar Joe Conway

Fix performance regression in dblink connection speed.

Previous commit e5de6012 modified dblink
to ensure client encoding matched the server. However the added
PQsetClientEncoding() call added significant overhead. Restore original
performance in the common case where client encoding already matches
server encoding by doing nothing in that case. Applies to all active
branches.

Issue reported and work sponsored by Zonar Systems.
parent 54aa5ef7
...@@ -209,6 +209,7 @@ typedef struct remoteConnHashEnt ...@@ -209,6 +209,7 @@ typedef struct remoteConnHashEnt
errdetail_internal("%s", msg))); \ errdetail_internal("%s", msg))); \
} \ } \
dblink_security_check(conn, rconn); \ dblink_security_check(conn, rconn); \
if (PQclientEncoding(conn) != GetDatabaseEncoding()) \
PQsetClientEncoding(conn, GetDatabaseEncodingName()); \ PQsetClientEncoding(conn, GetDatabaseEncodingName()); \
freeconn = true; \ freeconn = true; \
} \ } \
...@@ -288,7 +289,8 @@ dblink_connect(PG_FUNCTION_ARGS) ...@@ -288,7 +289,8 @@ dblink_connect(PG_FUNCTION_ARGS)
/* check password actually used if not superuser */ /* check password actually used if not superuser */
dblink_security_check(conn, rconn); dblink_security_check(conn, rconn);
/* attempt to set client encoding to match server encoding */ /* attempt to set client encoding to match server encoding, if needed */
if (PQclientEncoding(conn) != GetDatabaseEncoding())
PQsetClientEncoding(conn, GetDatabaseEncodingName()); PQsetClientEncoding(conn, GetDatabaseEncodingName());
if (connname) if (connname)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment