Re: Postgesql lib

From: "Lukas" <lukas(at)fmf(dot)vtu(dot)lt>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Postgesql lib
Date: 2009-01-12 12:38:15
Message-ID: 15970.217.117.29.29.1231763895.squirrel@fmf.vgtu.lt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello,

Yes, you was right about VARDATA (working code below, maybe it will help
others), the problem was that I could not find documentation for VARDATA,
maybe you can point to it?

Also, about the
ats = pclose (sendmail);
PG_RETURN_TEXT_P( ats );

Yes, ats is integer, so what is wrong here? actually it is working
normally, or I should know something more?

Code is here:

text *To, *Subject, *Body;

To = PG_GETARG_TEXT_P(0);

char *cTo = (char *) calloc(VARSIZE(To) - VARHDRSZ, sizeof(char));
strncpy(cTo, VARDATA(To), VARSIZE(To)-VARHDRSZ);

and latter:

fprintf (sendmail, "To: %s\n", cTo);

--
Lukas
UAB nSoft
http://www.nsoft.lt
Lukas at nsoft.lt
+370 655 10 655

> "Lukas" <lukas(at)fmf(dot)vtu(dot)lt> writes:
>> I am trying to write simple PG Lib on C (on Linux), it is working, bus
>> I
>> have some problem with data types, maybe someone can explain me a little
>> bit:
>
> You're assuming that VARDATA() produces a null-terminated string.
> It doesn't. You either need to call textout to get a null-terminated
> string, or fix the fprintf calls to pay attention to the actual
> string length.
>
>> ats = pclose (sendmail);
>> PG_RETURN_TEXT_P( ats );
>
> ... and this part is even less likely to work. pclose returns an
> integer.
>
> regards, tom lane
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>
> --
> This message has been scanned for viruses and
> dangerous content by OpenProtect(http://www.openprotect.com), and is
> believed to be clean.
>
>

--
This message has been scanned for viruses and
dangerous content by OpenProtect(http://www.openprotect.com), and is
believed to be clean.

In response to

Responses

  • IN vs = at 2009-01-26 20:48:08 from Lukas

Browse pgsql-novice by date

  From Date Subject
Next Message Wright, George 2009-01-12 14:18:28 debugging plpgsql functions
Previous Message Peter Jackson 2009-01-11 22:51:59 Re: Foreign Keys