Hi, On 2017-12-21 14:49:28 +0800, Craig Ringer wrote: > +/* > + * Accumulate writes into the buffer in diag_request_buf, > + * for use with functions that expect a printf-like callback. > + */ > +static void > +printwrapper_stringinfo(void *extra, const char * fmt, ...) > +{ > + StringInfo out = extra; > + for (;;) > + { > + va_list args; > + int needed; > + va_start(args, fmt); > + needed = appendStringInfoVA(out, fmt, args); > + va_end(args); > + if (needed == 0) > + break; > + enlargeStringInfo(out, needed); > + } > }
Hm, so I'm not entirely sure it's ok to use something that ERRORs on OOM. There's plenty of scenarios with thousands of memory contexts, making this output fairly large. If we want to make this usable in production, I'm not sure it's ok to introduce additional ERRORs. I wonder if we can change this to emit a static message if collecting the output exhausted memory. Greetings, Andres Freund