On 9/22/15 6:27 PM, Jim Nasby wrote:
+ ereport(LOG,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory attempting to pg_stat_statement
file"),
+ errdetail("file \"%s\": size %lld", PGSS_TEXT_FILE,
stat.st_size)));
Uh, what?
Oops. I'll fix that and address David's concern tomorrow.
New patch attached. I stripped the size reporting out and simplified the
conditionals a bit as well.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c
b/contrib/pg_stat_statements/pg_stat_statements.c
index 59b8a2e..c9dcd89 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -1892,15 +1892,24 @@ qtext_load_file(Size *buffer_size)
}
/* Allocate buffer; beware that off_t might be wider than size_t */
- if (stat.st_size <= MaxAllocSize)
- buf = (char *) malloc(stat.st_size);
- else
- buf = NULL;
+ if (stat.st_size > MaxAllocSize)
+ {
+ ereport(LOG,
+ /* Is there a better code to use? IE: SQLSTATE
53000, 53400 or 54000 */
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("pg_stat_statement file is too large to
process"),
+ errdetail("file \"%s\"",
PGSS_TEXT_FILE.st_size)));
+ CloseTransientFile(fd);
+ return NULL;
+ }
+
+ buf = (char *) malloc(stat.st_size);
+
if (buf == NULL)
{
ereport(LOG,
(errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory")));
+ errmsg("out of memory attempting to read
pg_stat_statement file")));
CloseTransientFile(fd);
return NULL;
}
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers