pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feed(no subject)
10+ messages / 6 participants
[nested] [flat]
* (no subject)
@ 2009-04-06 12:51 eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:07 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: eehab hamzeh @ 2009-04-06 12:51 UTC (permalink / raw)
To: pgsql-committers
Hello
I am trying to build some functions using C language. these functions are mentioned in the postgresql documentation.
http://www.postgresql.org/docs/8.3/interactive/xfunc-c.html
Datum
add_one_float8(PG_FUNCTION_ARGS)
{
/* The macros for FLOAT8 hide its pass-by-reference nature. */
float8 arg = PG_GETARG_FLOAT8(0);
PG_RETURN_FLOAT8(arg + 1.0);
}
PG_FUNCTION_INFO_V1(makepoint);
Datum
makepoint(PG_FUNCTION_ARGS)
{
/* Here, the pass-by-reference nature of Point is not hidden. */
Point *pointx = PG_GETARG_POINT_P(0);
Point *pointy = PG_GETARG_POINT_P(1);
Point *new_point = (Point *) palloc(sizeof(Point));
new_point->x = pointx->x;
new_point->y = pointy->y;
PG_RETURN_POINT_P(new_point);
}
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
kind regards
ihab
_________________________________________________________________
Show them the way! Add maps and directions to your party invites.
http://www.microsoft.com/windows/windowslive/products/events.aspx
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: [COMMITTERS]
2009-04-06 12:51 (no subject) eehab hamzeh <eehab40@hotmail.com>
@ 2009-04-06 13:07 ` Emanuel Calvo Franco <postgres.arg@gmail.com>
2009-04-06 13:36 ` Re: eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:36 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
2009-04-06 13:46 ` compiling c function using MinGW eehab hamzeh <eehab40@hotmail.com>
2009-04-06 15:56 ` writing c functions for postgres eehab hamzeh <eehab40@hotmail.com>
0 siblings, 4 replies; 10+ messages in thread
From: Emanuel Calvo Franco @ 2009-04-06 13:07 UTC (permalink / raw)
To: eehab hamzeh <eehab40@hotmail.com>; +Cc: General PostgreSQL List <pgsql-general@postgresql.org>
2009/4/6 eehab hamzeh <eehab40@hotmail.com>:
> Hello
>
> I am trying to build some functions using C language. these functions are
> mentioned in the postgresql documentation.
>
> http://www.postgresql.org/docs/8.3/interactive/xfunc-c.html
>
> Datum
> add_one_float8(PG_FUNCTION_ARGS)
> {
> /* The macros for FLOAT8 hide its pass-by-reference nature. */
> float8 arg = PG_GETARG_FLOAT8(0);
>
> PG_RETURN_FLOAT8(arg + 1.0);
> }
>
> PG_FUNCTION_INFO_V1(makepoint);
>
> Datum
> makepoint(PG_FUNCTION_ARGS)
> {
> /* Here, the pass-by-reference nature of Point is not hidden. */
> Point *pointx = PG_GETARG_POINT_P(0);
> Point *pointy = PG_GETARG_POINT_P(1);
> Point *new_point = (Point *) palloc(sizeof(Point));
>
> new_point->x = pointx->x;
> new_point->y = pointy->y;
>
> PG_RETURN_POINT_P(new_
> point);
> }
>
> 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
>
>
> kind regards
> ihab
Re-send to pgsql-general.
Can you paste these errors and how you're compiling this?
--
Emanuel Calvo Franco
Sumate al ARPUG !
(www.postgres-arg.org -
www.arpug.com.ar)
ArPUG / AOSUG Member
Postgresql Support & Admin
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re:
2009-04-06 12:51 (no subject) eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:07 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
@ 2009-04-06 13:36 ` eehab hamzeh <eehab40@hotmail.com>
2009-04-06 16:27 ` Re: Robert Haas <robertmhaas@gmail.com>
3 siblings, 1 reply; 10+ messages in thread
From: eehab hamzeh @ 2009-04-06 13:36 UTC (permalink / raw)
To: pgsql-committers
here are the code and the error , i compile them using vc++ 6 and VC++ 2008 and minGW the example below are for minGW
THANKS
#include "postgres.h"
#include <string.h>
#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)
{
int32 arg = PG_GETARG_INT32(0);
PG_RETURN_INT32(arg + 1);
}
/* by reference, fixed length */
PG_FUNCTION_INFO_V1(add_one_float8);
Datum
add_one_float8(PG_FUNCTION_ARGS)
{
/* The macros for FLOAT8 hide its pass-by-reference nature. */
float8 arg = PG_GETARG_FLOAT8(0);
PG_RETURN_FLOAT8(arg + 1.0);
}
PG_FUNCTION_INFO_V1(makepoint);
Datum
makepoint(PG_FUNCTION_ARGS)
{
/* Here, the pass-by-reference nature of Point is not hidden. */
Point *pointx = PG_GETARG_POINT_P(0);
Point *pointy = PG_GETARG_POINT_P(1);
Point *new_point = (Point *) palloc(sizeof(Point));
new_point->x = pointx->x;
new_point->y = pointy->y;
PG_RETURN_POINT_P(new_point);
}
/* by reference, variable length */
PG_FUNCTION_INFO_V1(copytext);
Datum
copytext(PG_FUNCTION_ARGS)
{
text *t = PG_GETARG_TEXT_P(0);
/*
* VARSIZE is the total size of the struct in bytes.
*/
text *new_t = (text *) palloc(VARSIZE(t));
VARATT_SIZEP(new_t) = VARSIZE(t);
/*
* VARDATA is a pointer to the data region of the struct.
*/
memcpy((void *) VARDATA(new_t), /* destination */
(void *) VARDATA(t), /* source */
VARSIZE(t)-VARHDRSZ); /* how many bytes */
PG_RETURN_TEXT_P(new_t);
}
PG_FUNCTION_INFO_V1(concat_text);
Datum
concat_text(PG_FUNCTION_ARGS)
{
text *arg1 = PG_GETARG_TEXT_P(0);
text *arg2 = PG_GETARG_TEXT_P(1);
int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ;
text *new_text = (text *) palloc(new_text_size);
VARATT_SIZEP(new_text) = new_text_size;
memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ);
memcpy(VARDATA(new_text) + (VARSIZE(arg1)-VARHDRSZ),
VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ);
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 ´this 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
thanks
_________________________________________________________________
More than messagescheck out the rest of the Windows Live.
http://www.microsoft.com/windows/windowslive/
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re:
2009-04-06 12:51 (no subject) eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:07 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
2009-04-06 13:36 ` Re: eehab hamzeh <eehab40@hotmail.com>
@ 2009-04-06 16:27 ` Robert Haas <robertmhaas@gmail.com>
0 siblings, 0 replies; 10+ messages in thread
From: Robert Haas @ 2009-04-06 16:27 UTC (permalink / raw)
To: eehab hamzeh <eehab40@hotmail.com>; +Cc: pgsql-committers
You are posting to the wrong mailing list.
Please see:
http://www.postgresql.org/community/lists/
...Robert
2009/4/6 eehab hamzeh <eehab40@hotmail.com>:
>
> here are the code and the error , i compile them using vc++ 6 and VC++ 2008
> and minGW the example below are for minGW
> THANKS
>
> #include "postgres.h"
> #include <string.h>
> #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)
> {
> int32 arg = PG_GETARG_INT32(0);
>
> PG_RETURN_INT32(arg + 1);
> }
>
> /* by reference, fixed length */
>
> PG_FUNCTION_INFO_V1(add_one_float8);
>
> Datum
> add_one_float8(PG_FUNCTION_ARGS)
> {
> &nb sp; /* The macros for FLOAT8 hide its pass-by-reference nature. */
> float8 arg = PG_GETARG_FLOAT8(0);
>
> PG_RETURN_FLOAT8(arg + 1.0);
> }
>
> PG_FUNCTION_INFO_V1(makepoint);
>
> Datum
> makepoint(PG_FUNCTION_ARGS)
> {
> /* Here, the pass-by-reference nature of Point is not hidden. */
> Point *pointx = PG_GETARG_POINT_P(0);
> Point *pointy = PG_GETARG_POINT_P(1);
> Point *new_point = (Point *) palloc(sizeof(Point));
>
> new_point->x = pointx->x;
> new_point->y = pointy->y;
>
> PG_RETURN_POINT_P(new_point);
> }
>
> /* by reference, variable length */
>
> PG_FUNCTION_INFO_V1(copytext);
>
> Datum
> copytext(PG_FUNCTION_ARGS)
> {
> text *t = PG_GETARG_TEXT_P(0);
> /*
> * VARSIZE is the total size of the struct in bytes.
> */
> text *new_t = (text *) palloc(VARSIZE(t));
> VARATT_SIZEP(new_t) = VARSIZE(t);
> /*
> * VARDATA is a pointer to the data region of the struct.
> */
> memcpy((void *) VARDATA(new_t), /* destination */
> (void *) VARDATA(t), /* source */
> VARSIZE(t)-VARHDRSZ); /* how many bytes */
> PG_RETURN_TEXT_P(new_t);
> }
>
> PG_FUNCTION_INFO_V1(concat_text);
>
> Datum
> concat_text(PG_FUNCTION_ARGS)
> {
> text *arg1 = PG_GETARG_TEXT_P(0);
> text *arg2 = PG_GETARG_TEXT_P(1);
> int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ;
> text *new_text = (text *) palloc(new_text_size);
>
> VARATT_SIZEP(new_text) = new_text_size;
> memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ);
> memcpy(VARDATA(new_text) + (VARSIZE(arg1)-VARHDRSZ),
> VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ);
> &n bsp; 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 ´this 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
>
> thanks
>
> < img alt="">
>
>
>
> ________________________________
> check out the rest of the Windows Live™. More than mail–Windows Live™ goes
> way beyond your inbox. More than messages
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: [COMMITTERS]
2009-04-06 12:51 (no subject) eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:07 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
@ 2009-04-06 13:36 ` Emanuel Calvo Franco <postgres.arg@gmail.com>
3 siblings, 0 replies; 10+ messages in thread
From: Emanuel Calvo Franco @ 2009-04-06 13:36 UTC (permalink / raw)
To: eehab hamzeh <eehab40@hotmail.com>; General PostgreSQL List <pgsql-general@postgresql.org>
2009/4/6 eehab hamzeh <eehab40@hotmail.com>:
> here are the code and the error , i compile them using vc++ 6 and VC++ 2008
> and minGW the example below are for minGW
> THANKS
>
> #include "postgres.h"
> #include <string.h>
> #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)
> {
> int32 arg = PG_GETARG_INT32(0);
>
> PG_RETURN_INT32(arg + 1);
> }
>
> /* by reference, fixed length */
>
> PG_FUNCTION_INFO_V1(add_one_float8);
>
> Datum
> add_one_float8(PG_FUNCTION_ARGS)
> {
> /* The macros for FLOAT8 hide its pass-by-reference nature. */
> float8 arg = PG_GETARG_FLOAT8(0);
>
> PG_RETURN_FLOAT8(arg + 1.0);
> }
>
> PG_FUNCTION_INFO_V1(makepoint);
>
> Datum
> makepoint(PG_FUNCTION_ARGS)
> {
> /* Here, the pass-by-reference nature of Point is not hidden. */
> Point *pointx = PG_GETARG_POINT_P(0);
> Point *pointy = PG_GETARG_POINT_P(1);
> Point *new_point = (Point *) palloc(sizeof(Point));
>
> new_point->x = pointx->x;
> new_point->y = pointy->y;
>
> PG_RETURN_POINT_P(new_point);
> }
>
> /* by reference, variable length */
>
> PG_FUNCTION_INFO_V1(copytext);
>
> Datum
> copytext(PG_FUNCTION_ARGS)
> {
> text *t = PG_GETARG_TEXT_P(0);
> /*
> * VARSIZE is the total size of the struct in bytes.
> */
> text *new_t = (text *) palloc(VARSIZE(t));
> VARATT_SIZEP(new_t) = VARSIZE(t);
> /*
> * VARDATA is a pointer to the data region of the struct.
> */
> memcpy((void *) VARDATA(new_t), /* destination */
> (void *) VARDATA(t), /* source */
> VARSIZE(t)-VARHDRSZ); /* how many bytes */
> PG_RETURN_TEXT_P(new_t);
> }
>
> PG_FUNCTION_INFO_V1(concat_text);
>
> Datum
> concat_text(PG_FUNCTION_ARGS)
> {
> text *arg1 = PG_GETARG_TEXT_P(0);
> text *arg2 = PG_GETARG_TEXT_P(1);
> int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ;
> text *new_text = (text *) palloc(new_text_size);
>
> VARATT_SIZEP(new_text) = new_text_size;
> memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ);
> memcpy(VARDATA(new_text) + (VARSIZE(arg1)-VARHDRSZ),
> VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ);
> 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 ´this 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
>
> thanks
>
>
You aren't including the path of the libs when you compiling (option -I).
don't send to comitters please, send into pgsql-general.
Thanks.
--
Emanuel Calvo Franco
Sumate al ARPUG !
(www.postgres-arg.org -
www.arpug.com.ar)
ArPUG / AOSUG Member
Postgresql Support & Admin
^ permalink raw reply [nested|flat] 10+ messages in thread
* compiling c function using MinGW
2009-04-06 12:51 (no subject) eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:07 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
@ 2009-04-06 13:46 ` eehab hamzeh <eehab40@hotmail.com>
3 siblings, 0 replies; 10+ messages in thread
From: eehab hamzeh @ 2009-04-06 13:46 UTC (permalink / raw)
To: pgsql-general@postgresql.org
this is how i write the command in MinGW any more direction about I. I am a new user for MinGW
gcc -shared -o hamzeh.dll tt1.o -L "c:/programme/postgresql/8.3/lib" -lpostgres
Thanks
Ihab
>
> 2009/4/6 eehab hamzeh <eehab40@hotmail.com>:
> > Hello
> >
> > I am trying to build some functions using C language. these functions are
> > mentioned in the postgresql documentation.
> >
> > http://www.postgresql.org/docs/8.3/interactive/xfunc-c.html
> >
> > Datum
> > add_one_float8(PG_FUNCTION_ARGS)
> > {
> > /* The macros for FLOAT8 hide its pass-by-reference nature. */
> > float8 arg = PG_GETARG_FLOAT8(0);
> >
> > PG_RETURN_FLOAT8(arg + 1.0);
> > }
> >
> > PG_FUNCTION_INFO_V1(makepoint);
> >
> > Datum
> > makepoint(PG_FUNCTION_ARGS)
> > {
> > /* Here, the pass-by-reference nature of Point is not hidden. */
> > Point *pointx = PG_GETARG_POINT_P(0);
> > Point *pointy = PG_GETARG_POINT_P(1);
> > Point *new_point = (Point *) palloc(sizeof(Point));
> >
> > new_point->x = pointx->x;
> > new_point->y = pointy->y;
> >
> > PG_RETURN_POINT_P(new_
> > point);
> > }
> >
> > 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
> >
> >
> > kind regards
> > ihab
>
> Re-send to pgsql-general.
>
> Can you paste these errors and how you're compiling this?
>
> --
> Emanuel Calvo Franco
> Sumate al ARPUG !
> (www.postgres-arg.org -
> www.arpug.com.ar)
> ArPUG / AOSUG Member
> Postgresql Support & Admin
_________________________________________________________________
Show them the way! Add maps and directions to your party invites.
http://www.microsoft.com/windows/windowslive/products/events.aspx
^ permalink raw reply [nested|flat] 10+ messages in thread
* writing c functions for postgres
2009-04-06 12:51 (no subject) eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:07 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
@ 2009-04-06 15:56 ` eehab hamzeh <eehab40@hotmail.com>
2009-04-07 06:48 ` Re: writing c functions for postgres Albe Laurenz <laurenz.albe@wien.gv.at>
3 siblings, 1 reply; 10+ messages in thread
From: eehab hamzeh @ 2009-04-06 15:56 UTC (permalink / raw)
To: pgsql-general@postgresql.org
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++ 2008 and minGW the example below are for minGW
THANKS
#include "postgres.h"
#include <string.h>
#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)
{
int32 arg = PG_GETARG_INT32(0);
PG_RETURN_INT32(arg + 1);
}
/* by reference, fixed length */
PG_FUNCTION_INFO_V1(add_one_float8);
Datum
add_one_float8(PG_FUNCTION_ARGS)
{
/* The macros for FLOAT8 hide its pass-by-reference nature. */
float8 arg = PG_GETARG_FLOAT8(0);
PG_RETURN_FLOAT8(arg + 1.0);
}
PG_FUNCTION_INFO_V1(makepoint);
Datum
makepoint(PG_FUNCTION_ARGS)
{
/* Here, the pass-by-reference nature of Point is not hidden. */
Point *pointx = PG_GETARG_POINT_P(0);
Point *pointy = PG_GETARG_POINT_P(1);
Point *new_point = (Point *) palloc(sizeof(Point));
new_point->x = pointx->x;
new_point->y = pointy->y;
PG_RETURN_POINT_P(new_point);
}
/* by reference, variable length */
PG_FUNCTION_INFO_V1(copytext);
Datum
copytext(PG_FUNCTION_ARGS)
{
text *t = PG_GETARG_TEXT_P(0);
/*
* VARSIZE is the total size of the struct in bytes.
*/
text *new_t = (text *) palloc(VARSIZE(t));
VARATT_SIZEP(new_t) = VARSIZE(t);
/*
* VARDATA is a pointer to the data region of the struct.
*/
memcpy((void *) VARDATA(new_t), /* destination */
(void *) VARDATA(t), /* source */
VARSIZE(t)-VARHDRSZ); /* how many bytes */
PG_RETURN_TEXT_P(new_t);
}
PG_FUNCTION_INFO_V1(concat_text);
Datum
concat_text(PG_FUNCTION_ARGS)
{
text *arg1 = PG_GETARG_TEXT_P(0);
text *arg2 = PG_GETARG_TEXT_P(1);
int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ;
text *new_text = (text *) palloc(new_text_size);
VARATT_SIZEP(new_text) = new_text_size;
memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ);
memcpy(VARDATA(new_text) + (VARSIZE(arg1)-VARHDRSZ),
VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ);
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 ´this 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
thanks
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: writing c functions for postgres
2009-04-06 12:51 (no subject) eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:07 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
2009-04-06 15:56 ` writing c functions for postgres eehab hamzeh <eehab40@hotmail.com>
@ 2009-04-07 06:48 ` Albe Laurenz <laurenz.albe@wien.gv.at>
2009-04-07 08:35 ` Re: writing c functions for postgres Glyn Astill <glynastill@yahoo.co.uk>
0 siblings, 1 reply; 10+ messages in thread
From: Albe Laurenz @ 2009-04-07 06:48 UTC (permalink / raw)
To: eehab hamzeh *EXTERN* <eehab40@hotmail.com>; pgsql-general@postgresql.org
eehab hamzeh wrote:
> 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
>
> #include "postgres.h"
> #include <string.h>
> #include "fmgr.h"
>
> #ifdef PG_MODULE_MAGIC
> PG_MODULE_MAGIC;
> #endif
>
[...]
>
> PG_FUNCTION_INFO_V1(makepoint);
>
> Datum
> makepoint(PG_FUNCTION_ARGS)
> {
> /* Here, the pass-by-reference nature of Point is not hidden. */
> Point *pointx = PG_GETARG_POINT_P(0);
> Point *pointy = PG_GETARG_POINT_P(1);
> Point *new_point = (Point *) palloc(sizeof(Point));
>
[...]
>
> PG_FUNCTION_INFO_V1(copytext);
>
> Datum
> copytext(PG_FUNCTION_ARGS)
> {
[...]
> VARATT_SIZEP(new_t) = VARSIZE(t);
[...]
> }
>
> PG_FUNCTION_INFO_V1(concat_text);
>
> Datum
> concat_text(PG_FUNCTION_ARGS)
> {
[...]
> VARATT_SIZEP(new_text) = new_text_size;
[...]
> }
>
>
> 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 ´this 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
These error messages are certainly not what you saw on the screen.
It is best to copy and paste error messages!
If you want to have Point, you'll have to
#include "utils/geo_decls.h"
The "invalid lvalue" errors are generated because gcc does not
know VARATT_SIZEP and assumes it is a function returning int.
I recommend that you always use gcc with -Wall to see warnings!
I can find no VARATT_SIZEP in the PostgreSQL 8.3 headers.
Where did you get that from?
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: writing c functions for postgres
2009-04-06 12:51 (no subject) eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:07 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
2009-04-06 15:56 ` writing c functions for postgres eehab hamzeh <eehab40@hotmail.com>
2009-04-07 06:48 ` Re: writing c functions for postgres Albe Laurenz <laurenz.albe@wien.gv.at>
@ 2009-04-07 08:35 ` Glyn Astill <glynastill@yahoo.co.uk>
0 siblings, 0 replies; 10+ messages in thread
From: Glyn Astill @ 2009-04-07 08:35 UTC (permalink / raw)
To: eehab hamzeh *EXTERN* <eehab40@hotmail.com>; pgsql-general@postgresql.org, Albe Laurenz <laurenz.albe@wien.gv.at>
--- On Tue, 7/4/09, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
> I can find no VARATT_SIZEP in the PostgreSQL 8.3 headers.
> Where did you get that from?
>
> Yours,
> Laurenz Albe
>
I think it's depreciated and he should be using SET_VARSIZE instead ...
^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix lost Windows socket EOF events.
@ 2024-07-13 04:14 Thomas Munro <tmunro@postgresql.org>
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Munro @ 2024-07-13 04:14 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix lost Windows socket EOF events.
Winsock only signals an FD_CLOSE event once if the other end of the
socket shuts down gracefully. Because each WaitLatchOrSocket() call
constructs and destroys a new event handle every time, with unlucky
timing we can lose it and hang. We get away with this only if the other
end disconnects non-gracefully, because FD_CLOSE is repeatedly signaled
in that case.
To fix this design flaw in our Windows socket support fundamentally,
we'd probably need to rearchitect it so that a single event handle
exists for the lifetime of a socket, or switch to completely different
multiplexing or async I/O APIs. That's going to be a bigger job
and probably wouldn't be back-patchable.
This brute force kludge closes the race by explicitly polling with
MSG_PEEK before sleeping.
Back-patch to all supported releases. This should hopefully clear up
some random build farm and CI hang failures reported over the years. It
might also allow us to try using graceful shutdown in more places again
(reverted in commit 29992a6) to fix instability in the transmission of
FATAL error messages, but that isn't done by this commit.
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Tested-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/176008.1715492071%40sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a8458f508a7a441242e148f008293128676df003
Modified Files
--------------
src/backend/storage/ipc/latch.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2024-07-13 04:14 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-04-06 12:51 eehab hamzeh <eehab40@hotmail.com>
2009-04-06 13:07 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
2009-04-06 13:36 ` Re: eehab hamzeh <eehab40@hotmail.com>
2009-04-06 16:27 ` Re: Robert Haas <robertmhaas@gmail.com>
2009-04-06 13:36 ` Re: [COMMITTERS] Emanuel Calvo Franco <postgres.arg@gmail.com>
2009-04-06 13:46 ` compiling c function using MinGW eehab hamzeh <eehab40@hotmail.com>
2009-04-06 15:56 ` writing c functions for postgres eehab hamzeh <eehab40@hotmail.com>
2009-04-07 06:48 ` Re: writing c functions for postgres Albe Laurenz <laurenz.albe@wien.gv.at>
2009-04-07 08:35 ` Re: writing c functions for postgres Glyn Astill <glynastill@yahoo.co.uk>
2024-07-13 04:14 pgsql: Fix lost Windows socket EOF events. Thomas Munro <tmunro@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox