diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index fd7c8e6..0dc1098 100644 *** a/contrib/dblink/dblink.c --- b/contrib/dblink/dblink.c *************** static void dblink_res_error(const char *** 102,107 **** --- 102,108 ---- static char *get_connect_string(const char *servername); static char *escape_param_str(const char *from); static int get_nondropped_natts(Oid relid); + static void namembcpy(char name[NAMEDATALEN], const char *s); /* Global */ static remoteConn *pconn = NULL; *************** getConnectionByName(const char *name) *** 2198,2205 **** if (!remoteConnHash) remoteConnHash = createConnHash(); ! MemSet(key, 0, NAMEDATALEN); ! snprintf(key, NAMEDATALEN - 1, "%s", name); hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key, HASH_FIND, NULL); --- 2199,2205 ---- if (!remoteConnHash) remoteConnHash = createConnHash(); ! namembcpy(key, name); hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key, HASH_FIND, NULL); *************** createNewConnection(const char *name, re *** 2230,2237 **** if (!remoteConnHash) remoteConnHash = createConnHash(); ! MemSet(key, 0, NAMEDATALEN); ! snprintf(key, NAMEDATALEN - 1, "%s", name); hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key, HASH_ENTER, &found); --- 2230,2236 ---- if (!remoteConnHash) remoteConnHash = createConnHash(); ! namembcpy(key, name); hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key, HASH_ENTER, &found); *************** deleteConnection(const char *name) *** 2254,2262 **** if (!remoteConnHash) remoteConnHash = createConnHash(); ! MemSet(key, 0, NAMEDATALEN); ! snprintf(key, NAMEDATALEN - 1, "%s", name); ! hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key, HASH_REMOVE, &found); --- 2253,2259 ---- if (!remoteConnHash) remoteConnHash = createConnHash(); ! namembcpy(key, name); hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key, HASH_REMOVE, &found); *************** get_nondropped_natts(Oid relid) *** 2484,2486 **** --- 2481,2495 ---- relation_close(rel, AccessShareLock); return nondropped_natts; } + + static void + namembcpy(char name[NAMEDATALEN], const char *s) + { + int len; + + len = strlen(s); + len = pg_mbcliplen(s, len, NAMEDATALEN - 1); + + memcpy(name, s, len); + memset(name + len, 0, NAMEDATALEN - len); + }