I found the numbers in `quote_literal_cstr` palloc quite magical. So I've added a comment clarifying what they mean. The change is small:
/* We make a worst-case result area; wasting a little space is OK */ - result = palloc(len * 2 + 3 + 1); + result = palloc( + (len * 2) /* worst-case doubling for every character if each one is a quote */ + + 3 /* two outer quotes + possibly 'E' if needed */ + + 1 /* null terminator */ + );
From:
Álvaro Herrera Date: Subject:
Re: getting "shell command argument contains a newline or carriage return:" error with pg_dumpall when db name have new line in double quote