postgres.git / summary / log / commit / refs
commit ac14ba5f874a93d3518a4d6feb34c1ce37f64346
Author: Itagaki Takahiro <itagaki.takahiro@gmail.com>
Date: Thu Jun 03 09:44:35 2010 +0000
First released in: 9.0.0, 8.0.26, 8.1.22, 8.2.18, 8.3.12, 8.4.5
Fix dblink to treat connection names longer than NAMEDATALEN-2 (62 bytes).
Now long names are adjusted with truncate_identifier() and NOTICE messages
are raised if names are actually truncated.
Backported to release 8.0.
contrib/dblink/dblink.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 69bf982a1df..16f50200818 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -47,6 +47,7 @@
#include "nodes/execnodes.h"
#include "nodes/pg_list.h"
#include "parser/parse_type.h"
+#include "parser/scansup.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
@@ -2107,13 +2108,13 @@ static remoteConn *
getConnectionByName(const char *name)
{
remoteConnHashEnt *hentry;
- char key[NAMEDATALEN];
+ char *key;
if (!remoteConnHash)
remoteConnHash = createConnHash();
- MemSet(key, 0, NAMEDATALEN);
- snprintf(key, NAMEDATALEN - 1, "%s", name);
+ key = pstrdup(name);
+ truncate_identifier(key, strlen(key), true);
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash,
key, HASH_FIND, NULL);
@@ -2139,13 +2140,13 @@ createNewConnection(const char *name, remoteConn * rconn)
{
remoteConnHashEnt *hentry;
bool found;
- char key[NAMEDATALEN];
+ char *key;
if (!remoteConnHash)
remoteConnHash = createConnHash();
- MemSet(key, 0, NAMEDATALEN);
- snprintf(key, NAMEDATALEN - 1, "%s", name);
+ key = pstrdup(name);
+ truncate_identifier(key, strlen(key), true);
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key,
HASH_ENTER, &found);
@@ -2163,14 +2164,13 @@ deleteConnection(const char *name)
{
remoteConnHashEnt *hentry;
bool found;
- char key[NAMEDATALEN];
+ char *key;
if (!remoteConnHash)
remoteConnHash = createConnHash();
- MemSet(key, 0, NAMEDATALEN);
- snprintf(key, NAMEDATALEN - 1, "%s", name);
-
+ key = pstrdup(name);
+ truncate_identifier(key, strlen(key), true);
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash,
key, HASH_REMOVE, &found);
[parent: dbfa55f73aa3]