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

Commit1ffb63a

Browse files
committed
Fix bogus Name assignment in CreateStatistics
Apparently, it doesn't work to use a plain cstring as a Name datum: youmay end up having random bytes because of failing to zero the bytesafter the terminating \0, as indicated by valgrind. I introduced thisbug in5564c11, so backpatch this fix to REL_10_STABLE, like thatcommit.While at it, fix a slightly misleading comment, pointed out by DavidRowley.
1 parent4c831ae commit1ffb63a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

‎src/backend/commands/statscmds.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ CreateStatistics(CreateStatsStmt *stmt)
5757
int16attnums[STATS_MAX_DIMENSIONS];
5858
intnumcols=0;
5959
char*namestr;
60+
NameDatastxname;
6061
Oidstatoid;
6162
OidnamespaceId;
6263
Oidstxowner=GetUserId();
@@ -135,7 +136,8 @@ CreateStatistics(CreateStatsStmt *stmt)
135136
* object in the same namespace as the relation, and cons up a name for it.
136137
*/
137138
if (stmt->defnames)
138-
namespaceId=QualifiedNameGetCreationNamespace(stmt->defnames,&namestr);
139+
namespaceId=QualifiedNameGetCreationNamespace(stmt->defnames,
140+
&namestr);
139141
else
140142
{
141143
namespaceId=RelationGetNamespace(rel);
@@ -144,6 +146,7 @@ CreateStatistics(CreateStatsStmt *stmt)
144146
"stat",
145147
namespaceId);
146148
}
149+
namestrcpy(&stxname,namestr);
147150

148151
/*
149152
* Deal with the possibility that the statistics object already exists.
@@ -307,7 +310,7 @@ CreateStatistics(CreateStatsStmt *stmt)
307310
memset(values,0,sizeof(values));
308311
memset(nulls, false,sizeof(nulls));
309312
values[Anum_pg_statistic_ext_stxrelid-1]=ObjectIdGetDatum(relid);
310-
values[Anum_pg_statistic_ext_stxname-1]=CStringGetDatum(namestr);
313+
values[Anum_pg_statistic_ext_stxname-1]=NameGetDatum(&stxname);
311314
values[Anum_pg_statistic_ext_stxnamespace-1]=ObjectIdGetDatum(namespaceId);
312315
values[Anum_pg_statistic_ext_stxowner-1]=ObjectIdGetDatum(stxowner);
313316
values[Anum_pg_statistic_ext_stxkeys-1]=PointerGetDatum(stxkeys);

‎src/backend/parser/parse_utilcmd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,8 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
22502250
* transformExtendedStatistics
22512251
* Handle extended statistic objects
22522252
*
2253-
* Right now, there's nothing to do here, so we just copy the list.
2253+
* Right now, there's nothing to do here, so we just append the list to
2254+
* the existing "after" list.
22542255
*/
22552256
staticvoid
22562257
transformExtendedStatistics(CreateStmtContext*cxt)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp