Обсуждение: Call to build-in operator from new operator
Greetings, I don't really know if this is the correct place to ask this question, if not please direct me to the correct mailing list. I'm trying to develop a new operator for PostGreSQL (actually for TelegraphCQ, which is an extension of PSQL). Part of the operator's procedure is the @-operator. So now my question is: How do I call the on_pb function from inside my own function?. The on_pb of course takes the argument 'PG_FUNCTION_ARGS' which is defined in fmgr.h as 'FunctionCallInfo fcinfo' which is defined as pointer to 'struct FunctionCallInfoData', so my question boils down to: What do I put into this struct to call 'on_pb' with two arguments from the call to my function? Further, is there a way to access data in tables in the database other than those given as arguments to the function? And how? Sincerely Kim Bille Department of Computer Science Aalborg University Denmark -- "Mind are like parachutes --- they only work when open"
On Mon, Apr 18, 2005 at 02:39:52PM +0200, kim@billes.dk wrote: > > I'm trying to develop a new operator for PostGreSQL (actually for TelegraphCQ, which > is an extension of PSQL). Part of the operator's procedure is the @-operator. So now > my question is: How do I call the on_pb function from inside my own function?. You could use DirectFunctionCall2(). See src/backend/utils/adt/geo_ops.c for examples: the source for close_pb() has a call to on_pb(). > Further, is there a way to access data in tables in the database other than those > given as arguments to the function? And how? See the "Server Programming Interface" chapter in the documentation: http://www.postgresql.org/docs/8.0/interactive/spi.html -- Michael Fuhr http://www.fuhr.org/~mfuhr/
kim@billes.dk writes: > I'm trying to develop a new operator for PostGreSQL (actually for TelegraphCQ, which > is an extension of PSQL). Part of the operator's procedure is the @-operator. So now > my question is: How do I call the on_pb function from inside my own function?. DirectFunctionCall2 is probably the least painful way to do it. You need to convert the arguments and result to and from Datum, but the other gruntwork is taken care of by that function. Look at existing uses for examples. > Further, is there a way to access data in tables in the database other than those > given as arguments to the function? And how? Only if you do your own query. regards, tom lane