*/
if (attribute->attgenerated == ATTRIBUTE_GENERATED_STORED)
{
- newval = (NewColumnValue *) palloc0(sizeof(NewColumnValue));
+ newval = palloc0_object(NewColumnValue);
newval->attnum = num;
newval->expr = expression_planner((Expr *) def);
newval->is_generated = (attribute->attgenerated != '\0');
{
NewConstraint *newcon;
- newcon = (NewConstraint *) palloc0(sizeof(NewConstraint));
+ newcon = palloc0_object(NewConstraint);
newcon->name = ccon->name;
newcon->contype = CONSTR_CHECK;
newcon->qual = qual;
{
SplitPartitionContext *pc;
- pc = (SplitPartitionContext *) palloc0(sizeof(SplitPartitionContext));
+ pc = palloc0_object(SplitPartitionContext);
pc->partRel = partRel;
/*
int nparts = list_length(partOids);
List *bounds = NIL;
- lower_bounds = (PartitionRangeBound **)
- palloc0(nparts * sizeof(PartitionRangeBound *));
+ lower_bounds = palloc0_array(PartitionRangeBound *, nparts);
/*
* Create an array of lower bounds and a list of
* Make an array new_parts with new partitions except the DEFAULT
* partition.
*/
- new_parts = (SinglePartitionSpec **)
- palloc0(list_length(partlist) * sizeof(SinglePartitionSpec *));
+ new_parts = palloc0_array(SinglePartitionSpec *, list_length(partlist));
/* isSplitPartDefault flag: is split partition a DEFAULT partition? */
isSplitPartDefault = (defaultPartOid == splitPartOid);
* all partitions in ascending order of their bounds (we compare the
* lower bound only).
*/
- lower_bounds = (PartitionRangeBound **)
- palloc0(nparts * sizeof(PartitionRangeBound *));
+ lower_bounds = palloc0_array(PartitionRangeBound *, nparts);
/* Create an array of lower bounds. */
for (i = 0; i < nparts; i++)
/* Reorder the array of partitions. */
tmp_new_parts = new_parts;
- new_parts = (SinglePartitionSpec **)
- palloc0(nparts * sizeof(SinglePartitionSpec *));
+ new_parts = palloc0_array(SinglePartitionSpec *, nparts);
for (i = 0; i < nparts; i++)
new_parts[i] = tmp_new_parts[lower_bounds[i]->index];