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

Commit785cfee

Browse files
committed
Fix incorrect encoding-aware name truncation in makeArrayTypeName().
truncate_identifier won't do anything if the passed-in strlen is alreadyless than NAMEDATALEN, which it always would be given the strlcpy usage.This has been broken since the arrays-of-composite-types code went in.Arguably truncate_identifier is suffering from excessive optimizationand should always process the string, but for the moment I'll take themore localized patch.Per bug #4987.
1 parenta05a4b4 commit785cfee

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

‎src/backend/catalog/pg_type.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.126 2009/06/1114:48:55 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.127 2009/08/16 18:14:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -686,23 +686,27 @@ RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
686686
char*
687687
makeArrayTypeName(constchar*typeName,OidtypeNamespace)
688688
{
689-
char*arr;
690-
inti;
689+
char*arr= (char*)palloc(NAMEDATALEN);
690+
intnamelen=strlen(typeName);
691691
Relationpg_type_desc;
692+
inti;
692693

693694
/*
694695
* The idea is to prepend underscores as needed until we make a name that
695696
* doesn't collide with anything...
696697
*/
697-
arr=palloc(NAMEDATALEN);
698-
699698
pg_type_desc=heap_open(TypeRelationId,AccessShareLock);
700699

701700
for (i=1;i<NAMEDATALEN-1;i++)
702701
{
703702
arr[i-1]='_';
704-
strlcpy(arr+i,typeName,NAMEDATALEN-i);
705-
truncate_identifier(arr,strlen(arr), false);
703+
if (i+namelen<NAMEDATALEN)
704+
strcpy(arr+i,typeName);
705+
else
706+
{
707+
memcpy(arr+i,typeName,NAMEDATALEN-i);
708+
truncate_identifier(arr,NAMEDATALEN, false);
709+
}
706710
if (!SearchSysCacheExists(TYPENAMENSP,
707711
CStringGetDatum(arr),
708712
ObjectIdGetDatum(typeNamespace),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp