Re: Out-of-memory error reports in libpq
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Peter Smith <smithpb2250@gmail.com>, Ranier Vilela <ranier.vf@gmail.com>,
Andres Freund <andres@anarazel.de>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Michael Paquier <michael@paquier.xyz>,
Alvaro Herrera <alvherre@alvh.no-ip.org>, Peter Geoghegan <pg@bowt.ie>
Date: 2021-07-29T13:57:12Z
Lists: pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes: > On 7/29/21 3:01 AM, Peter Smith wrote: >> I've seen lots of code like this where I may have been tempted to use >> a ternary operator for readability, so I was wondering is there a PG >> convention to avoid such ternary operator assignments, or is it simply >> a personal taste thing, or is there some other reason? > A simple grep on the sources should disabuse you of any idea that there > is such a convention. The code is littered with examples of the ?: operator. Yeah. I happened not to write it that way here, but if I'd been reviewing someone else's code and they'd done it that way, I'd not have objected. In the case at hand, I'd personally avoid a ternary op for the first assignment because then the line would run over 80 characters, and you'd have to make decisions about where to break it. (We don't have a standardized convention about that, and none of the alternatives look very good to my eye.) Then it seemed to make sense to also write the second step as an "if" not a ternary op. regards, tom lane
Commits
-
Improve libpq's handling of OOM during error message construction.
- 514b4c11d247 15.0 landed
- 43f1d2ab361c 14.0 landed
-
In libpq, always append new error messages to conn->errorMessage.
- ffa2e4670123 14.0 cited