On Tue, May 27, 2014 at 1:39 AM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> The best alternative I can think of is to use strncmp() to check for
> whether the head of the string matches "COPY ", and then perform the
> integer conversion using strtoull() #ifdef HAVE_STRTOULL and strtoul()
> otherwise.
What about the attached?
-- 
Michael

diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 07f09e1..ffeb219 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -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. */
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to