Re: Coding style question

From: imad <immaad(at)gmail(dot)com>
To: "Gregory Stark" <stark(at)enterprisedb(dot)com>
Cc: korryd(at)enterprisedb(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Coding style question
Date: 2006-11-02 19:12:51
Message-ID: 1f30b80c0611021112l1282157ejb43c140b45edccf2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/2/06, Gregory Stark <stark(at)enterprisedb(dot)com> wrote:
> <korryd(at)enterprisedb(dot)com> writes:
>
> > I would probably write that as:
> >
> > ________________________________________________________________________
> >
> > static TransactionId
> > _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel,
> > Buffer buf, ScanKey itup_scankey)
> > {
> > TupleDesc itupdesc = RelationGetDescr(rel);
> > int natts = rel->rd_rel->relnatts;
> > Page page = BufferGetPage(buf);
> > OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
> > BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page);
> > OffsetNumber offset = _bt_binsrch(rel, buf, natts, itup_scankey, false);
> > Buffer nbuf = InvalidBuffer;
>
>
> The disadvantage of using initializers is that you end up contorting the code
> to allow you to squeeze things into the initializers and it limits what you
> can do later to the code without undoing them.
>
> For example, if later you find out you have to, say, lock a table before the
> itupdesc initializer then all of the sudden you have to rip out all the
> initializers and rewrite them as assignments after the statement acquiring the
> table lock.

Well, its about the coding style. And I doubt there exists a data type
which may not have
an initializer. A NULL / Zero is an option in all cases and you can do
whatever you want to assign it a value immediately after the
initialization section. My two cents!

--Imad
www.EnterpriseDB.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message korryd 2006-11-02 19:14:08 Re: Coding style question
Previous Message Andrew Dunstan 2006-11-02 19:08:05 Re: Coding style question