Re: My first PL/pgSQL function

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Dane Foster <studdugie(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: My first PL/pgSQL function
Date: 2015-10-21 15:44:15
Message-ID: CAHyXU0yL+LW_idf835syitRjvP1GM_+fVqEXFtXvGN1pkmYRnw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Oct 21, 2015 at 10:24 AM, Dane Foster <studdugie(at)gmail(dot)com> wrote:
> For posterity here is the final version. I ran it through PostgreSQL
> 9.5beta1 this morning so it's at least syntactically valid. Additionally I
> went w/ a list of INTO targets instead of a RECORD because it's a more
> elegant solution in that it made the code a little less verbose and a little
> less repetitive. The fact that in some cases it's faster is a serendipitous
> bonus.

*) I really dislike your formatting relative to what it was. In fact,
it's a mess. You went to four spaces vs two, which causes a lot of
issues IMO. SQL relative to other languages requires a lot of nested
indentation and this makes things challenging to format well. This
is opinion I guess but I think it's a regression.

aside: do not use tabs in sql, ever -- I dislike tabs generally but in
postgres .sql it breaks pasting to psql.

*) your indent spacing is not regular (meaning, not always exactly 4).
For example,

END CASE;
END IF;

Irregular indentation leads directly to:
*) lots of extra work and irrelevant-to-the-actual-change whitespace adjustments
*) coding difficulty locating the end of the block in the face of
indentation changes. At the bottom portion of your function, I'm not
easily finding the matching END IF to the:

ELSE
-- This should NEVER happen!
IF danglingvoucher

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message anj patnaik 2015-10-21 15:57:38 Re: trouble downloading postgres 9.4 for RHEL 6.x
Previous Message Pavel Stehule 2015-10-21 15:41:42 Re: My first PL/pgSQL function