Hi All,
(1) I have written the following test function with
intention to experiment how extending a function works
in postgreSQL.
//func.c
#include "postgres.h"
#include <string.h>
#include "fmgr.h"
PG_FUNCTION_INFO_V1(MyInc);
Datum MyInc(PG_FUNCTION_ARGS)
{int32 arg = PG_GETARG_INT32(0);PG_RETURN_INT32(arg+1);
}
// I compiled it and made a .so file and placed it in
pgsql/lib directory which is my default
dynamic_library_path
(2) Then I made the following entry in pg_proc.h
DATA(insert OID = 4000 ( MyInc PGUID 12 f t t t 1 f
23 "23" 100 0 0 100 MyInc testfunc ));
DESCR("test function ");
(3) I included the pg_proc.h file in
src/include/catalog
and then I executed gmake from
src/backend/catalog
directory
I encountered the following problem
PROBLEM 1:
(4) the compiled postgres.bki file has the entries
with ';' like (I am showing one of the places where
the ';' is placed )
// First
# PostgreSQL 7.2
# 1 "/tmp/genbkitmp.c"
create bootstrap pg_proc(proname;^M = name ,
and like that
//Second
'));' remains from the DATA() entry in pg_proc.h
like
insert OID = 4000 ( MyInc 1 12 f t t t 1 f 23 "23" 100
0 0 100 MyInc func ));
Hence I have to remove these semicolon manually form
postgres.bki file and had to place manually in the
pgsql/share directory from where the initdb reads this
file.
PROBLEM 2:
(5) And when I run the following query
test=# select MyInc(6);
Following error came
ERROR: Function 'myinc(int4)' does not exist Unable to identify a function that satisfies
the given argument types You may need to add explicit typecasts
PROBLEM 3:
I didn't get a way to reflect all the new DATA()
entries in pg_proc.h to pg_proc system table without
deleting the "data" directory and reinitializing it
again by running "initdb".
(6) Kindly guide me how should I rectify these
problem?
Thanks in advance for your help and time
Regards
Amit Khare
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/