Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TfWEX-00040u-O1 for pgsql-www@arkaria.postgresql.org; Mon, 03 Dec 2012 13:38:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TfWEX-00032c-8i for pgsql-www@arkaria.postgresql.org; Mon, 03 Dec 2012 13:38:53 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TfWEW-00032U-Of; Mon, 03 Dec 2012 13:38:52 +0000 Received: from 173-164-140-181-sfba.hfc.comcastbusiness.net ([173.164.140.181] helo=fetter.org) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TfWEV-0002Eb-7m; Mon, 03 Dec 2012 13:38:52 +0000 Received: by fetter.org (Postfix, from userid 500) id 91BB5300DC3; Mon, 3 Dec 2012 05:38:50 -0800 (PST) Date: Mon, 3 Dec 2012 05:38:50 -0800 From: David Fetter To: Alvaro Herrera Cc: rk204885@gmail.com, pgsql-general@postgresql.org, w^3 Subject: Re: MODERATOR WARNING Re: [GENERAL] Exception Handling in C-Language Functions? Message-ID: <20121203133850.GB1254@fetter.org> References: <1354511937712-5734656.post@n5.nabble.com> <20121203061454.GB4601@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20121203061454.GB4601@alvh.no-ip.org> User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: 0.2 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-www Precedence: bulk Sender: pgsql-www-owner@postgresql.org OK :) Is there a way to do this automatically? Cheers, David. On Mon, Dec 03, 2012 at 03:14:54AM -0300, Alvaro Herrera wrote: > MODERATOR WARNING >=20 > I noticed that this guy Rahul seems to be reinjecting old list emails > somehow. Please don't approve anything coming from him. Observe this > example: >=20 > http://postgresql.1045698.n5.nabble.com/Re-GENERAL-MS-Access-and-Stored-p= rocedures-td1843848.html > http://postgresql.1045698.n5.nabble.com/Re-GENERAL-MS-Access-and-Stored-p= rocedures-td5734652.html > The original message was posted in 2005! >=20 > The message here is this one (also in 2005): > http://postgresql.1045698.n5.nabble.com/GENERAL-Exception-Handling-in-C-L= anguage-Functions-td1843896.html >=20 > I have no idea what's going on. Maybe it's something to do with Nabble. > There are others pending moderation in pgsql-admin and pgsql-hackers too. >=20 > rahul143 wrote: > > I have the created a C-Language function (code is below). Now, I=20 > > wonder: How do I handle exceptions, for example if malloc cannot assign= =20 > > the necessary memory? Do "palloc" and "pfree" handle such a case=20 > > cleanly? Should I simply use an "assert"?=20 > >=20 > > #include "postgres.h"=20 > > #include =20 > > #include =20 > > #include "fmgr.h"=20 > > #include "libinn.h"=20 > >=20 > > PG_FUNCTION_INFO_V1(ffiinews_uwildmat);=20 > >=20 > > /* Wrapper for INN's function uwildmat. Needs parameters in UTF-8. */= =20 > > Datum ffiinews_uwildmat(PG_FUNCTION_ARGS) {=20 > > VarChar *text =3D PG_GETARG_VARCHAR_P(0);=20 > > VarChar *pattern =3D PG_GETARG_VARCHAR_P(1);=20 > > int text_len =3D VARSIZE(text)-VARHDRSZ;=20 > > int pattern_len =3D VARSIZE(pattern)-VARHDRSZ;=20 > > char *tmp_text =3D (char *)malloc(text_len+1);=20 > > if (tmp_text =3D=3D NULL)=20 > > ; /* What now? */=20 > > char *tmp_pattern =3D (char *)malloc(pattern_len+1);=20 > > if (tmp_pattern =3D=3D NULL)=20 > > ; /* What now? */=20 > > strncpy(tmp_text, VARDATA(text), text_len);=20 > > tmp_text[text_len] =3D '\0';=20 > > strncpy(tmp_pattern, VARDATA(pattern), pattern_len);=20 > > tmp_pattern[pattern_len] =3D '\0';=20 > > bool matches =3D uwildmat(tmp_text, tmp_pattern);=20 > >=20 > >=20 > >=20 > > ----- > >=20 > >=20 > >=20 > >=20 > > -- > > View this message in context: http://postgresql.1045698.n5.nabble.com/G= ENERAL-Exception-Handling-in-C-Language-Functions-tp5734656.html > > Sent from the PostgreSQL - general mailing list archive at Nabble.com. > >=20 > >=20 > > --=20 > > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > > To make changes to your subscription: > > http://www.postgresql.org/mailpref/pgsql-general >=20 >=20 > --=20 > =C1lvaro Herrera http://www.2ndQuadrant.com/ > PostgreSQL Development, 24x7 Support, Training & Services --=20 David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate --=20 Sent via pgsql-www mailing list (pgsql-www@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-www