mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
Avoid unportable usage of sscanf(UINT64_FORMAT).
On Mingw, it seems that scanf() doesn't necessarily accept the same format codes that printf() does, and in particular it may fail to recognize %llu even though printf() does. Since configure only probes printf() behavior while setting up the INT64_FORMAT macros, this means it's unsafe to use those macros with scanf(). We had only one instance of such a coding pattern, in contrib/pg_stat_statements, so change that code to avoid the problem. Per buildfarm warnings. Back-patch to 9.0 where the troublesome code was introduced. Michael Paquier
This commit is contained in:
parent
0266a9c781
commit
b8cf89c041
@ -809,7 +809,7 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString,
|
|||||||
{
|
{
|
||||||
instr_time start;
|
instr_time start;
|
||||||
instr_time duration;
|
instr_time duration;
|
||||||
uint64 rows = 0;
|
uint64 rows;
|
||||||
BufferUsage bufusage_start,
|
BufferUsage bufusage_start,
|
||||||
bufusage;
|
bufusage;
|
||||||
uint32 queryId;
|
uint32 queryId;
|
||||||
@ -842,7 +842,15 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString,
|
|||||||
|
|
||||||
/* parse command tag to retrieve the number of affected rows. */
|
/* parse command tag to retrieve the number of affected rows. */
|
||||||
if (completionTag &&
|
if (completionTag &&
|
||||||
sscanf(completionTag, "COPY " UINT64_FORMAT, &rows) != 1)
|
strncmp(completionTag, "COPY ", 5) == 0)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_STRTOULL
|
||||||
|
rows = strtoull(completionTag + 5, NULL, 10);
|
||||||
|
#else
|
||||||
|
rows = strtoul(completionTag + 5, NULL, 10);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
rows = 0;
|
rows = 0;
|
||||||
|
|
||||||
/* calc differences of buffer counters. */
|
/* calc differences of buffer counters. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user