User built functions? - Mailing list pgsql-general

From Rick Dearman
Subject User built functions?
Date
Msg-id 37008182.F0DE7087@gameszone.net
Whole thread Raw
List pgsql-general
I want to create a C funtion for my postgresql database which is passed
an int4 type and returns a string?

I attempted to do:

create function to_string(int4) returns varchar as 'to_stardate($1)'
language 'C';

and a function like this:

#include "executor/executor.h"  /* for GetAttributeByName() */
#include <string.h>
#include <stdio.h>
#include "postgres.h"   /* for char16, etc. */
#include "utils/palloc.h"  /* for palloc */
#include "libpq-fe.h"

char *
#ifdef __STDC__
to_string (int integer_type, char *string)
#else    /* __STDC__ */
to_string (interger_type)
     int integer_type;
     char *stardate;
#endif /* __STDC__ */
{

    string = palloc(255);
    sprintf( string, "[%d]", integer_type);
    return string;

}

However this gives me an error like this:
ERROR:  stat failed on file to_string($1)

I looked in my pg_language table and have

C listed under /bin/cc however the only compiler on my machine is in
/usr/local/bin/gcc could this be the problem?




pgsql-general by date:

Previous
From: pete collins
Date:
Subject: Re: [GENERAL] backing up pgsql
Next
From: Ralf Weidemann
Date:
Subject: sorting by date & time in descending order ??