Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 6FE99632FE6 for ; Mon, 6 Apr 2009 14:35:11 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 15505-04 for ; Mon, 6 Apr 2009 14:35:04 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.31]) by mail.postgresql.org (Postfix) with ESMTP id 3DFB9632B61 for ; Mon, 6 Apr 2009 14:35:05 -0300 (ADT) Received: by yw-out-2324.google.com with SMTP id 3so1525332ywj.73 for ; Mon, 06 Apr 2009 10:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=6bp05nhPz+eCevSWeH80NeizUhCe/m1MIYpT4R+vz7I=; b=ekfECyGnk5SxvB/JI3Pbh8VwOLgBNZj3SaW7C649fTsgLqvCx8PQECL/V79G6ldSoR xFMxC1SZDoMb3woz0FqT5ahGfyPJDM1yg7j40tcnlSdNL3DjwyfZnSrUgESyD7mt+PAo l4mvFk7vz7YGQwvM9OgGe3nP/WmFePSEORTfQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=irknXGbQkbO3N5aD3bU8zYcPeb7fAFGfKdE9eWGyF80j7fBuJEb/4cJmhQggL/nplj ZE4jh+FqZG7vcwjrySXg3+DmaDSR+fEdsaJZXRRbz7TsfenRwZE9Z/osVCGP9JtT0FAy ZLgKbXeoFmEUyNbTCCOKGtoqhAnohFc1/Kujs= MIME-Version: 1.0 Received: by 10.150.147.14 with SMTP id u14mr1366871ybd.43.1239039305029; Mon, 06 Apr 2009 10:35:05 -0700 (PDT) In-Reply-To: References: Date: Mon, 6 Apr 2009 14:35:05 -0300 Message-ID: Subject: Re: [COMMITTERS] From: Emanuel Calvo Franco To: eehab hamzeh Cc: General PostgreSQL List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.159 tagged_above=0 required=5 tests=AWL=-1.075, DEAR_SOMETHING=2.234 X-Spam-Level: * X-Archive-Number: 200904/196 X-Sequence-Number: 146152 2009/4/6 eehab hamzeh : > Dear Sir > > I am trying to build some functions using C language. these functions are > mentioned in the postgresql documentation. > > the only function that are work are the one with int32 variable. > the other function bring errors and are not working > any body can give directions > > here are the code and the error , i compile them using vc++ 6 and VC++ 20= 08 > and minGW the example below are for minGW > > THANKS > > #include "postgres.h" > #include > #include "fmgr.h" > > #ifdef PG_MODULE_MAGIC > PG_MODULE_MAGIC; > #endif > > /* by value */ > > PG_FUNCTION_INFO_V1(add_one); > > Datum > add_one(PG_FUNCTION_ARGS) > { > =A0 =A0 int32 =A0 arg =3D PG_GETARG_INT32(0); > > =A0 =A0 PG_RETURN_INT32(arg + 1); > } > > /* by reference, fixed length */ > > PG_FUNCTION_INFO_V1(add_on e_float8); > > Datum > add_one_float8(PG_FUNCTION_ARGS) > { > =A0 =A0 /* The macros for FLOAT8 hide its pass-by-reference nature. */ > =A0 =A0 float8 =A0 arg =3D PG_GETARG_FLOAT8(0); > > =A0 =A0 PG_RETURN_FLOAT8(arg + 1.0); > } > > PG_FUNCTION_INFO_V1(makepoint); > > Datum > makepoint(PG_FUNCTION_ARGS) > { > =A0 =A0 /* Here, the pass-by-reference nature of Point is not hidden. */ > =A0 =A0 Point =A0 =A0 *pointx =3D PG_GETARG_POINT_P(0); > =A0 =A0 Point =A0 =A0 *pointy =3D PG_GETARG_POINT_P(1); > =A0 =A0 Point =A0 =A0 *new_point =3D (Point *) palloc(sizeof(Point)); > > =A0 =A0 new_point->x =3D pointx->x; > =A0 =A0 new_point->y =3D pointy->y; > > =A0 =A0 PG_RETURN_POINT_P(new_point); > } > > /* by reference, variable length */ > > PG_FUNCTION_INFO_V1(copytext); > > Datum > copytext(PG_FUNCTION_ARGS) > { > =A0 =A0 text =A0 =A0 *t =3D PG_GETARG_TEXT_P(0); > =A0 =A0 /* > =A0 =A0 =A0* VARSIZE is the total size of the struct in bytes. > =A0 =A0 =A0*/ > =A0 =A0 text =A0 =A0 *new_t =3D (text *) palloc(VARSIZE(t)); > =A0 =A0 VARATT_SIZEP(new_t) =3D VARSIZE(t); > =A0 =A0 /* > =A0 =A0 =A0* VARDATA is a pointer to the data region of the struct. > =A0 =A0 =A0*/ > =A0 =A0 memcpy((void *) VARDATA(new_t), /* destination */ > =A0 =A0 =A0 =A0 =A0 =A0(void *) VARDATA(t), =A0 =A0 /* source */ > =A0 =A0 =A0 =A0 =A0 =A0VARSIZE(t)-VARHDRSZ); =A0 =A0/* how many bytes */ > =A0 =A0 PG_RETURN_TEXT_P(new_t); > } > > PG_FUNCTION_INFO_V1(concat_text); > > Datum > concat_text(PG_FUNCTION_ARGS) > { > =A0 =A0 text =A0*arg1 =3D PG_GETARG_TEXT_P(0); > =A0 =A0 text =A0*arg2 =3D PG_GETARG_TEXT_P(1); > =A0 =A0 int32 new_text_size =3D VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ; > =A0 =A0 text *new_text =3D (text *) palloc(new_text_size); > > =A0 =A0 VARATT_SIZEP(new_text) =3D new_text_size; > =A0 =A0 memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ); > =A0 =A0 memcpy(VARDATA(new_text) + (VARSIZE(arg1)-VARHDRSZ ), > =A0 =A0 =A0 =A0 =A0 =A0VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ); > =A0 =A0 PG_RETURN_TEXT_P(new_text); > } > > > the error > > in function 'makepoint': > error: 'Point' undeclared (first use in this function) > error: (each undeclared identifier is reported only one > error: for each function it appears in.) > error: 'pointx' undeclared (first use in =B4this function) > error: 'pointy' undeclared (first use in his fnction) > error 'new_point' undeclared (first use in his function) > error: syntax error befre ')' oken > in function 'copy text': > error: 'invalid lvalue in assinment > In function 'concat_text' > error: invalid lvalue in assignement > warning no new line at end of file > > Please any direction of how to solve the problem > > here is the command i wrote in MinGW > > gcc -shared -o hamzeh.dll tt1.o -L "c:/programme/postgresql/8.3/lib" > -lpostgres > try c:\programme\ .... And try the option -I (include) REPLY TO pgsql-general@portgresql.org,please... Comitters is not a list to make questions :) And please, when you post a question put a description in the subject of the mail. Thanks. --=20 Emanuel Calvo Franco Sumate al ARPUG ! (www.postgres-arg.org - www.arpug.com.ar) ArPUG / AOSUG Member Postgresql Support & Admin