mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
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.
This commit is contained in:
@ -47,6 +47,7 @@
|
|||||||
#include "nodes/execnodes.h"
|
#include "nodes/execnodes.h"
|
||||||
#include "nodes/pg_list.h"
|
#include "nodes/pg_list.h"
|
||||||
#include "parser/parse_type.h"
|
#include "parser/parse_type.h"
|
||||||
|
#include "parser/scansup.h"
|
||||||
#include "tcop/tcopprot.h"
|
#include "tcop/tcopprot.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "utils/fmgroids.h"
|
#include "utils/fmgroids.h"
|
||||||
@ -2107,13 +2108,13 @@ static remoteConn *
|
|||||||
getConnectionByName(const char *name)
|
getConnectionByName(const char *name)
|
||||||
{
|
{
|
||||||
remoteConnHashEnt *hentry;
|
remoteConnHashEnt *hentry;
|
||||||
char key[NAMEDATALEN];
|
char *key;
|
||||||
|
|
||||||
if (!remoteConnHash)
|
if (!remoteConnHash)
|
||||||
remoteConnHash = createConnHash();
|
remoteConnHash = createConnHash();
|
||||||
|
|
||||||
MemSet(key, 0, NAMEDATALEN);
|
key = pstrdup(name);
|
||||||
snprintf(key, NAMEDATALEN - 1, "%s", name);
|
truncate_identifier(key, strlen(key), true);
|
||||||
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash,
|
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash,
|
||||||
key, HASH_FIND, NULL);
|
key, HASH_FIND, NULL);
|
||||||
|
|
||||||
@ -2139,13 +2140,13 @@ createNewConnection(const char *name, remoteConn * rconn)
|
|||||||
{
|
{
|
||||||
remoteConnHashEnt *hentry;
|
remoteConnHashEnt *hentry;
|
||||||
bool found;
|
bool found;
|
||||||
char key[NAMEDATALEN];
|
char *key;
|
||||||
|
|
||||||
if (!remoteConnHash)
|
if (!remoteConnHash)
|
||||||
remoteConnHash = createConnHash();
|
remoteConnHash = createConnHash();
|
||||||
|
|
||||||
MemSet(key, 0, NAMEDATALEN);
|
key = pstrdup(name);
|
||||||
snprintf(key, NAMEDATALEN - 1, "%s", name);
|
truncate_identifier(key, strlen(key), true);
|
||||||
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key,
|
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key,
|
||||||
HASH_ENTER, &found);
|
HASH_ENTER, &found);
|
||||||
|
|
||||||
@ -2163,14 +2164,13 @@ deleteConnection(const char *name)
|
|||||||
{
|
{
|
||||||
remoteConnHashEnt *hentry;
|
remoteConnHashEnt *hentry;
|
||||||
bool found;
|
bool found;
|
||||||
char key[NAMEDATALEN];
|
char *key;
|
||||||
|
|
||||||
if (!remoteConnHash)
|
if (!remoteConnHash)
|
||||||
remoteConnHash = createConnHash();
|
remoteConnHash = createConnHash();
|
||||||
|
|
||||||
MemSet(key, 0, NAMEDATALEN);
|
key = pstrdup(name);
|
||||||
snprintf(key, NAMEDATALEN - 1, "%s", name);
|
truncate_identifier(key, strlen(key), true);
|
||||||
|
|
||||||
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash,
|
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash,
|
||||||
key, HASH_REMOVE, &found);
|
key, HASH_REMOVE, &found);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user