aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItagaki Takahiro <itagaki.takahiro@gmail.com>2010-06-03 09:45:47 +0000
committerItagaki Takahiro <itagaki.takahiro@gmail.com>2010-06-03 09:45:47 +0000
commit9d1f44113dd82773e95f15061ad4bf2ad7acf4ce (patch)
tree95e5fb55c12f387abd07be0f8ee80c8e94563fbb
parentde57ea162c781314352da9daea27e01face1490c (diff)
downloadpostgresql-9d1f44113dd82773e95f15061ad4bf2ad7acf4ce.tar.gz
postgresql-9d1f44113dd82773e95f15061ad4bf2ad7acf4ce.zip
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.
-rw-r--r--contrib/dblink/dblink.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 256bcad41cd..b239ba33163 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -48,6 +48,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"
@@ -2075,13 +2076,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);
@@ -2107,13 +2108,13 @@ createNewConnection(const char *name, remoteConn * con)
{
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);
@@ -2136,14 +2137,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);