postgres.git / summary / log / commit / refs
commit 70165f25bce611ae08b7b69e8779fd6fbe3a36ee
Author: Joe Conway <mail@joeconway.com>
Date: Sun Dec 08 00:59:16 2013 +0000
First released in: 9.4.0, 8.4.20, 9.0.16, 9.1.12, 9.2.7, 9.3.3
Fix performance regression in dblink connection speed.
Previous commit e5de601267d98c5d60df6de8d436685c7105d149 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.
contrib/dblink/dblink.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 5a7bf22304f..98316a93185 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -192,7 +192,8 @@ typedef struct remoteConnHashEnt
errdetail_internal("%s", msg))); \
} \
dblink_security_check(conn, rconn); \
- PQsetClientEncoding(conn, GetDatabaseEncodingName()); \
+ if (PQclientEncoding(conn) != GetDatabaseEncoding()) \
+ PQsetClientEncoding(conn, GetDatabaseEncodingName()); \
freeconn = true; \
} \
} while (0)
@@ -271,8 +272,9 @@ dblink_connect(PG_FUNCTION_ARGS)
/* check password actually used if not superuser */
dblink_security_check(conn, rconn);
- /* attempt to set client encoding to match server encoding */
- PQsetClientEncoding(conn, GetDatabaseEncodingName());
+ /* attempt to set client encoding to match server encoding, if needed */
+ if (PQclientEncoding(conn) != GetDatabaseEncoding())
+ PQsetClientEncoding(conn, GetDatabaseEncodingName());
if (connname)
{
[parent: ad910ccdc70d]