By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,301 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,301 IT Pros & Developers. It's quick & easy.

Examples for writing own c functions in postgres

P: n/a
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/' 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
gcc -O0 -g3 -Wall -I /usr/local/src/postgresql-7.2.1/src/include -c
gcc -O0 -g3 -Wall -I /usr/local/src/postgresql-7.2.1/src/include
-shared -o 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

ram 'at'
Nov 11 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.