I was trying to write a simple function in c and include in postgres
But am not able to do so
I created a function with
CREATE FUNCTION "lower1"(text) RETURNS text AS
'/usr/local/src/ram/mydbilib.so' LANGUAGE 'C'
I looked at the src for a simple function
in $POSTGRES_SRC/src/backend/utils/adt/oracle_compat.c
Copied lower as lower1 function from the postgres src into a c file
and compiled
using
gcc -O0 -g3 -Wall -I /usr/local/src/postgresql-7.2.1/src/include -c
mydbilib.c
gcc -O0 -g3 -Wall -I /usr/local/src/postgresql-7.2.1/src/include
-shared -o mydbilib.so mydbilib.o -lc
This got compiled without problems but when I run the function
select lower1('ABC') ;
I get all junk chars
but select lower('ABC'); works fine
Can Anyone tell me how to compile correctly or give me other examples
of how this is done
I am using redhat linux 7.2 and postgres 7.2.1
Thanks
Ram
ram 'at' netcore.co.in