473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1830

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jaye Gallagher | last post by:
Hi there, I'm coming from a MS-SQL/MySQL background, and am trying to understand the way Postgres phrases "stored procedure" type stuff. What is mystifying me, in particular, is the fact that...
0
by: zerobearing2 | last post by:
Hi all- I'm migrating to postgres from the MS SQL Server land, as I can see a great potential with postgres, I was wondering if anyone has experimented or started a project with XML inside user...
4
by: phantom | last post by:
Hi All. I am having a problem writing to a file. I can successfully open the file and write the contents using fprintf, however if the writing is not done for a while in the process the file...
18
by: Joe Lester | last post by:
This thread was renamed. It used to be: "shared_buffers Question". The old thread kind of died out. I'm hoping to get some more direction by rephrasing the problem, along with some extra...
3
by: Mark Dexter | last post by:
Our application currently runs in Microsoft SQL Server and we are porting it over to Postgres. When we write enbedded SQL queries for SQL Server, we need to reference user-defined functions with...
4
by: Tk421 | last post by:
I've made some functions, an i want these functions to be used by a specified user, but i don't want this user can see the code of the functions. Does somebody knows how can i do this? Sorry about...
0
by: Scott Chapman | last post by:
The my2pg.pl script creates custom functions that help with the MySQL "set" column type. I can't figure out how to use the functions once I have the database migrated into Postgres. Can someone...
102
by: Xah Lee | last post by:
i had the pleasure to read the PHP's manual today. http://www.php.net/manual/en/ although Pretty Home Page is another criminal hack of the unix lineage, but if we are here to judge the quality...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.