Re: Syntax for partitioning

Peter Eisentraut <peter_e@gmx.net>

From: Peter Eisentraut <peter_e@gmx.net>
To: Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp>
Cc: Marko Tiikkaja <marko.tiikkaja@cs.helsinki.fi>, pgsql-hackers@postgresql.org
Date: 2009-11-19T22:33:55Z
Lists: pgsql-hackers
On ons, 2009-11-18 at 13:52 +0900, Itagaki Takahiro wrote:
> > partinfo = (PartitionInfo *) malloc(ntups * sizeof(PartitionInfo));
> 
> Oops, it should be "p"alloc. Thanks.

A very low-level comment:

1) Please stop casting the results of palloc and malloc.  We are not
writing C++ here.

2) I would prefer that you apply sizeof on the variable, not on the
type.  That way, the expression is independent of any type changes of
the variable, and can be reviewed without having to scroll around for
the variable definition.

So how about,

partinfo = palloc(ntups * sizeof(*partinfo));