473,554 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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"(te xt) 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
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.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

ram 'at' netcore.co.in
Nov 11 '05 #1
0 1836

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

Similar topics

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 all Postgres functions can only return one thing, even if that one thing is a bunch of similar objects. How can one phrase a stored procedure...
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 defined functions? I've seen the contrib/xml shipped with the distro, as I see it's usefulness, it's not quite what I had in mind (lacks the...
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 write returns a status -1. To elaborate here is the code segment main (... , ...) {
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 observations I've recently made. The core of the problem is that Postgres is filling up my hard drive with swap files at the rate of around 3 to 7 GB per...
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 the prefix "dbo." (e.g., "dbo.Function_Name()"). In experimenting with Postgres, it appears that we can create a schema called "dbo" and then...
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 my english, i'm spanish. Víctor Robador Capel Análisis de Sistemas y Programación www.creativosdolmen.com
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 please explain how to make use of them? In MySQL, the table exists: CREATE TABLE accessright ( accessright_id int(10) unsigned NOT NULL...
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 of its documentation, it is a impeccability. it has or possesses properties of:
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 works for files larger than 8000 Bytes. If a file is less than 1000 Bytes I get the following message: Error message: --invalid input syntax for...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.