Re: Out-of-memory error reports in libpq - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Out-of-memory error reports in libpq
Date
Msg-id 711012.1627567032@sss.pgh.pa.us
Whole thread Raw
In response to Re: Out-of-memory error reports in libpq  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: Out-of-memory error reports in libpq  (Robert Haas <robertmhaas@gmail.com>)
List 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



pgsql-hackers by date:

Previous
From: Geoff Winkless
Date:
Subject: Re: Replace l337sp34k in comments.
Next
From: Dmitry Dolgov
Date:
Subject: Re: Showing applied extended statistics in explain