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

Commitb8cf89c

Browse files
committed
Avoid unportable usage of sscanf(UINT64_FORMAT).
On Mingw, it seems that scanf() doesn't necessarily accept the same formatcodes that printf() does, and in particular it may fail to recognize %llueven though printf() does. Since configure only probes printf() behaviorwhile setting up the INT64_FORMAT macros, this means it's unsafe to usethose macros with scanf(). We had only one instance of such a codingpattern, in contrib/pg_stat_statements, so change that code to avoidthe problem.Per buildfarm warnings. Back-patch to 9.0 where the troublesome codewas introduced.Michael Paquier
1 parent0266a9c commitb8cf89c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString,
809809
{
810810
instr_timestart;
811811
instr_timeduration;
812-
uint64rows=0;
812+
uint64rows;
813813
BufferUsagebufusage_start,
814814
bufusage;
815815
uint32queryId;
@@ -842,7 +842,15 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString,
842842

843843
/* parse command tag to retrieve the number of affected rows. */
844844
if (completionTag&&
845-
sscanf(completionTag,"COPY "UINT64_FORMAT,&rows)!=1)
845+
strncmp(completionTag,"COPY ",5)==0)
846+
{
847+
#ifdefHAVE_STRTOULL
848+
rows=strtoull(completionTag+5,NULL,10);
849+
#else
850+
rows=strtoul(completionTag+5,NULL,10);
851+
#endif
852+
}
853+
else
846854
rows=0;
847855

848856
/* calc differences of buffer counters. */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp