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

Commite20dd6a

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 parent911e623 commite20dd6a

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
@@ -56,6 +56,7 @@ CreateStatistics(CreateStatsStmt *stmt)
5656
int16attnums[STATS_MAX_DIMENSIONS];
5757
intnumcols=0;
5858
char*namestr;
59+
NameDatastxname;
5960
Oidstatoid;
6061
OidnamespaceId;
6162
Oidstxowner=GetUserId();
@@ -134,7 +135,8 @@ CreateStatistics(CreateStatsStmt *stmt)
134135
* object in the same namespace as the relation, and cons up a name for it.
135136
*/
136137
if (stmt->defnames)
137-
namespaceId=QualifiedNameGetCreationNamespace(stmt->defnames,&namestr);
138+
namespaceId=QualifiedNameGetCreationNamespace(stmt->defnames,
139+
&namestr);
138140
else
139141
{
140142
namespaceId=RelationGetNamespace(rel);
@@ -143,6 +145,7 @@ CreateStatistics(CreateStatsStmt *stmt)
143145
"stat",
144146
namespaceId);
145147
}
148+
namestrcpy(&stxname,namestr);
146149

147150
/*
148151
* Deal with the possibility that the statistics object already exists.
@@ -306,7 +309,7 @@ CreateStatistics(CreateStatsStmt *stmt)
306309
memset(values,0,sizeof(values));
307310
memset(nulls, false,sizeof(nulls));
308311
values[Anum_pg_statistic_ext_stxrelid-1]=ObjectIdGetDatum(relid);
309-
values[Anum_pg_statistic_ext_stxname-1]=CStringGetDatum(namestr);
312+
values[Anum_pg_statistic_ext_stxname-1]=NameGetDatum(&stxname);
310313
values[Anum_pg_statistic_ext_stxnamespace-1]=ObjectIdGetDatum(namespaceId);
311314
values[Anum_pg_statistic_ext_stxowner-1]=ObjectIdGetDatum(stxowner);
312315
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
@@ -2255,7 +2255,8 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
22552255
* transformExtendedStatistics
22562256
* Handle extended statistic objects
22572257
*
2258-
* Right now, there's nothing to do here, so we just copy the list.
2258+
* Right now, there's nothing to do here, so we just append the list to
2259+
* the existing "after" list.
22592260
*/
22602261
staticvoid
22612262
transformExtendedStatistics(CreateStmtContext*cxt)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp