diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-05-26 22:23:29 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-05-26 22:23:29 -0400 |
commit | 9d7ded0f4277f5c0063eca8e871a34e2355a8371 (patch) | |
tree | 0dbc4696911056784657bdb67e040590ba5fa136 /contrib/pg_stat_statements/pg_stat_statements.c | |
parent | bf2e70ba6c0175e5a676b6aa37e49915d8918a63 (diff) | |
download | postgresql-9d7ded0f4277f5c0063eca8e871a34e2355a8371.tar.gz postgresql-9d7ded0f4277f5c0063eca8e871a34e2355a8371.zip |
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
Diffstat (limited to 'contrib/pg_stat_statements/pg_stat_statements.c')
-rw-r--r-- | contrib/pg_stat_statements/pg_stat_statements.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index 07f09e1e941..32d16cc5f3e 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -962,7 +962,7 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString, { instr_time start; instr_time duration; - uint64 rows = 0; + uint64 rows; BufferUsage bufusage_start, bufusage; uint32 queryId; @@ -995,7 +995,15 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString, /* parse command tag to retrieve the number of affected rows. */ 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; /* calc differences of buffer counters. */ |