Re: [GENERAL] Geometric, getting x and y co-ordinates GOING MAD!!!!!
От | selkovjr@mcs.anl.gov |
---|---|
Тема | Re: [GENERAL] Geometric, getting x and y co-ordinates GOING MAD!!!!! |
Дата | |
Msg-id | 199906041650.LAA15591@antares.mcs.anl.gov обсуждение исходный текст |
Ответ на | Re: [GENERAL] Geometric, getting x and y co-ordinates GOING MAD!!!!! (Stuart Rison <stuart@ludwig.ucl.ac.uk>) |
Ответы |
Re: [GENERAL] Geometric, getting x and y co-ordinates GOING MAD!!!!!
|
Список | pgsql-general |
> I have no training in C so I've reached this far by trial and error. I > have however discovered that if write a function such as > > /* pants.c > weird of what! */ > #include "postgres.h" > #include "utils/geo_decls.h" > double > pants(Point *pt) > { > return 2.0; > } > > and compile it as above and make it a function I get: > > brecard10=> select id,pos,pants(pos) from points; > id|pos |pants > --+-----------+----- > 1|(1,2) | 1 > 2|(-1.3,4.77)| -1.3 > 3|(0,-3) | 0 > (3 rows) > > HELP! > WHAT'S GOING ON!!! > Why can't I get to pt->y? > Why does function pants behave just like get_x (and get_y)? If you write your function as double, you can't declare it as float in sql. What you wanted is probably this: #include "postgres.h" #include "utils/geo_decls.h" float32 x(Point *pt); float32 y(Point *pt); float32 x(Point *pt) { float32 result = (float32) palloc(sizeof(float32data)); *result = (float)pt->x; return (result); } float32 y(Point *pt) { float32 result = (float32) palloc(sizeof(float32data)); *result = (float)pt->y; return (result); } (note that float32 is a pointer type) Then, in sql, CREATE FUNCTION x(point) RETURNS float4 AS '/home/postgres/src/point_adts/point_adts.so' <- this is where the above x() and y() functions live LANGUAGE 'c'; CREATE FUNCTION y(point) RETURNS float4 AS '/home/postgres/src/point_adts/point_adts.so' LANGUAGE 'c'; --Gene ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here's the complete working code: begin 644 point_adts.tgz M'XL(`&4!6#<``^V5\6^:0!3'_;7W5[QH$\$I@@IN-BZQ%AL7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