Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7dff726

Browse files
committed
Fix dblink to treat connection names longer than NAMEDATALEN-2 (62 bytes).
Now long names are adjusted with truncate_identifier() and NOTICE messagesare raised if names are actually truncated.Backported to release 8.0.
1 parentd561430 commit7dff726

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

‎contrib/dblink/dblink.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Darko Prenosil <Darko.Prenosil@finteh.hr>
99
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
1010
*
11-
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.91 2010/02/26 02:00:32 momjian Exp $
11+
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.92 2010/06/03 09:38:33 itagaki Exp $
1212
* Copyright (c) 2001-2010, PostgreSQL Global Development Group
1313
* ALL RIGHTS RESERVED;
1414
*
@@ -54,6 +54,7 @@
5454
#include"nodes/nodes.h"
5555
#include"nodes/pg_list.h"
5656
#include"parser/parse_type.h"
57+
#include"parser/scansup.h"
5758
#include"utils/acl.h"
5859
#include"utils/array.h"
5960
#include"utils/builtins.h"
@@ -2193,13 +2194,13 @@ static remoteConn *
21932194
getConnectionByName(constchar*name)
21942195
{
21952196
remoteConnHashEnt*hentry;
2196-
charkey[NAMEDATALEN];
2197+
char*key;
21972198

21982199
if (!remoteConnHash)
21992200
remoteConnHash=createConnHash();
22002201

2201-
MemSet(key,0,NAMEDATALEN);
2202-
snprintf(key,NAMEDATALEN-1,"%s",name);
2202+
key=pstrdup(name);
2203+
truncate_identifier(key,strlen(key), true);
22032204
hentry= (remoteConnHashEnt*)hash_search(remoteConnHash,
22042205
key,HASH_FIND,NULL);
22052206

@@ -2225,13 +2226,13 @@ createNewConnection(const char *name, remoteConn *rconn)
22252226
{
22262227
remoteConnHashEnt*hentry;
22272228
boolfound;
2228-
charkey[NAMEDATALEN];
2229+
char*key;
22292230

22302231
if (!remoteConnHash)
22312232
remoteConnHash=createConnHash();
22322233

2233-
MemSet(key,0,NAMEDATALEN);
2234-
snprintf(key,NAMEDATALEN-1,"%s",name);
2234+
key=pstrdup(name);
2235+
truncate_identifier(key,strlen(key), true);
22352236
hentry= (remoteConnHashEnt*)hash_search(remoteConnHash,key,
22362237
HASH_ENTER,&found);
22372238

@@ -2249,14 +2250,13 @@ deleteConnection(const char *name)
22492250
{
22502251
remoteConnHashEnt*hentry;
22512252
boolfound;
2252-
charkey[NAMEDATALEN];
2253+
char*key;
22532254

22542255
if (!remoteConnHash)
22552256
remoteConnHash=createConnHash();
22562257

2257-
MemSet(key,0,NAMEDATALEN);
2258-
snprintf(key,NAMEDATALEN-1,"%s",name);
2259-
2258+
key=pstrdup(name);
2259+
truncate_identifier(key,strlen(key), true);
22602260
hentry= (remoteConnHashEnt*)hash_search(remoteConnHash,
22612261
key,HASH_REMOVE,&found);
22622262

@@ -2390,10 +2390,12 @@ get_connect_string(const char *servername)
23902390
StringInfobuf=makeStringInfo();
23912391
ForeignDataWrapper*fdw;
23922392
AclResultaclresult;
2393+
char*srvname;
23932394

23942395
/* first gather the server connstr options */
2395-
if (strlen(servername)<NAMEDATALEN)
2396-
foreign_server=GetForeignServerByName(servername, true);
2396+
srvname=pstrdup(servername);
2397+
truncate_identifier(srvname,strlen(srvname), true);
2398+
foreign_server=GetForeignServerByName(srvname, true);
23972399

23982400
if (foreign_server)
23992401
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp