Re: insert rule doesn't see id field

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ron Peterson <rpeterso(at)mtholyoke(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: insert rule doesn't see id field
Date: 2003-01-10 04:53:42
Message-ID: 27958.1042174422@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches pgsql-sql

Ron Peterson <rpeterso(at)mtholyoke(dot)edu> writes:
> On Thu, Jan 09, 2003 at 04:50:56PM -0500, Ron Peterson wrote:
>> colindices = (int *) malloc (ncols * sizeof (int));

> Of course we should verify that malloc succeeded...

Actually, the correct answer is "you should not be using malloc() in
backend functions". You should be using palloc, or possibly
MemoryContextAlloc, either of which will elog if it can't get space.

> if (colindices == NULL) {
> elog (ERROR, "noupcol: malloc failed\n");
> SPI_finish();
> return PointerGetDatum (NULL);
> }

This is even more pointless. Control does not return from elog(ERROR),
so the two following lines are dead code.

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Radu-Adrian Popescu 2003-01-10 09:31:04 Re: insert rule doesn't see id field
Previous Message Bruce Momjian 2003-01-10 02:23:24 Re: more adequate usage msg: pg_controldata.diff

Browse pgsql-sql by date

  From Date Subject
Next Message Chad L 2003-01-10 09:08:15 Table Design Questions
Previous Message Ron Peterson 2003-01-10 02:07:07 Re: insert rule doesn't see id field