Re: insert rule doesn't see id field

Поиск
Список
Период
Сортировка
От Ron Peterson
Тема Re: insert rule doesn't see id field
Дата
Msg-id 20030110162737.GA13191@mtholyoke.edu
обсуждение исходный текст
Ответ на Re: insert rule doesn't see id field  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: noupcol code cleanup  (Ron Peterson <rpeterso@mtholyoke.edu>)
Список pgsql-sql
On Thu, Jan 09, 2003 at 11:53:42PM -0500, Tom Lane wrote:
> Ron Peterson <rpeterso@mtholyoke.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.

Thanks.  Didn't know that.

Not that you're obligated to review my code in any way (i.e. ignore
this question if you have better things to do), but does the rest of
my code look o.k.?  I was pretty pleased with myself that I figured
out how to modify a tuple w/ SPI, and might like to do more of the
same.  I'd rather not develop bad habits, though...

-- 
Ron Peterson                          -o)
Network & Systems Manager             /\\
Mount Holyoke College                _\_v
http://www.mtholyoke.edu/~rpeterso   ---- 


В списке pgsql-sql по дате отправления:

Предыдущее
От: dev@archonet.com
Дата:
Сообщение: Re: Table Design Questions
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: Table Design Questions