470,647 Members | 1,187 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

Examples for writing own c functions in postgres

Hello all,
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
Nov 11 '05 #1
0 1735

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by zerobearing2 | last post: by
4 posts views Thread by phantom | last post: by
3 posts views Thread by Mark Dexter | last post: by
4 posts views Thread by Tk421 | last post: by
1 post views Thread by Korara | last post: by
reply views Thread by warner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.