mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +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:
parent
b723b17008
commit
472f2dc87e
@ -8,7 +8,7 @@
|
|||||||
* Darko Prenosil <Darko.Prenosil@finteh.hr>
|
* Darko Prenosil <Darko.Prenosil@finteh.hr>
|
||||||
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
|
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.60.2.5 2010/02/03 23:01:47 joe Exp $
|
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.60.2.6 2010/06/03 09:43:04 itagaki Exp $
|
||||||
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
|
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
|
||||||
* ALL RIGHTS RESERVED;
|
* ALL RIGHTS RESERVED;
|
||||||
*
|
*
|
||||||
@ -50,6 +50,7 @@
|
|||||||
#include "nodes/nodes.h"
|
#include "nodes/nodes.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/array.h"
|
#include "utils/array.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
@ -2243,13 +2244,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);
|
||||||
|
|
||||||
@ -2275,13 +2276,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);
|
||||||
|
|
||||||
@ -2299,14 +2300,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);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user