Re: A minor correction in comment in heaptuple.c

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>, "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
Cc: Amit Langote <amitlangote09(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: A minor correction in comment in heaptuple.c
Date: 2013-06-18 16:47:33
Message-ID: 1371574053.13790.YahooMailNeo@web162902.mail.bf1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> On 2013-06-18 05:21:15 -0400, D'Arcy J.M. Cain wrote:
>> On Tue, 18 Jun 2013 11:01:28 +0200
>> Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
>> > > /*
>> > >  * return true if attnum is out of range according to the tupdesc
>> > >  */
>> > > if (attnum > tupleDesc->natts)
>> > > return true;
>> >
>> > I think the comment is more meaningfull before the change since it
>> > tells us how nonexisting columns are interpreted.
>>
>> I think that the comment is bad either way.  Comments should explain
>> the code, not repeat it.  The above is not far removed from...
>>
>>   return 5; /* return the number 5 */

I agree with this -- the comment as it stands adds no information
to what is obvious from a glance at the code, and may waste the
time it takes to mentally resolve the discrepancy between "return
NULL" in the comment and "return true;" in the statement.  Unless
it adds information, we'd be better off deleting the comment.

>> How about "check if attnum is out of range according to the
>> tupdesc" instead?
>
> I can't follow. Minus the word 'NULL' - which carries meaning - your
> suggested comment pretty much is the same as the existing comment except
> that you use 'check' instead of 'return'.

The word "indicate" might waste a few milliseconds less in the
double-take; but better would be some explanation of why you might
have an attnum value greater than the maximum, and why the right
thing to do is indicate NULL rather than throwing an error.

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hitoshi Harada 2013-06-18 17:13:39 Re: extensible external toast tuple support
Previous Message Jeff Davis 2013-06-18 16:42:16 Re: pg_filedump 9.3: checksums (and a few other fixes)