Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 54526475D3F for ; Thu, 9 Jan 2003 23:53:39 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id BDB91475D20 for ; Thu, 9 Jan 2003 23:53:38 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0A4rg0U027959; Thu, 9 Jan 2003 23:53:42 -0500 (EST) To: Ron Peterson Cc: pgsql-sql@postgresql.org Subject: Re: insert rule doesn't see id field In-reply-to: <20030110020707.GA9048@mtholyoke.edu> References: <20030107145422.GE12245@mtholyoke.edu> <13558.1041955268@sss.pgh.pa.us> <20030108181303.GA23456@mtholyoke.edu> <20030109191258.GA6739@mtholyoke.edu> <2930.192.168.1.16.1042142044.squirrel@mainbox.archonet.com> <20030109215056.GA7798@mtholyoke.edu> <20030110020707.GA9048@mtholyoke.edu> Comments: In-reply-to Ron Peterson message dated "Thu, 09 Jan 2003 21:07:07 -0500" Date: Thu, 09 Jan 2003 23:53:42 -0500 Message-ID: <27958.1042174422@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/146 X-Sequence-Number: 11011 Ron Peterson 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