Get funcid when create function

Started by 王翔宇over 8 years ago4 messageshackers
Jump to latest
#1王翔宇
wxyucs@gmail.com

I'm developing a extension for pg. Now I have create a event trigger on
ddl_command_end, and this function will be called after I enter create
function statement. In this function I can only get parseTree. In pg source
code, I found a function named "pg_event_trigger_ddl_commands" seems
provide cmds which include funcid. BUT I didn't found any example to call
this function.
who can helps?

--
Clench

#2Robert Haas
robertmhaas@gmail.com
In reply to: 王翔宇 (#1)
Re: Get funcid when create function

On Fri, Aug 10, 2018 at 5:50 AM, 王翔宇 <wxyucs@gmail.com> wrote:

I'm developing a extension for pg. Now I have create a event trigger on
ddl_command_end, and this function will be called after I enter create
function statement. In this function I can only get parseTree. In pg source
code, I found a function named "pg_event_trigger_ddl_commands" seems provide
cmds which include funcid. BUT I didn't found any example to call this
function.
who can helps?

Maybe it would help to read the documentation on that function:

https://www.postgresql.org/docs/current/static/functions-event-triggers.html

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#3王翔宇
wxyucs@gmail.com
In reply to: Robert Haas (#2)
Re: Get funcid when create function

Yes, I had read this document, BUT it's call from PL/PGSQL. I want call it
from c function.

2018-08-13 18:57 GMT+08:00 Robert Haas <robertmhaas@gmail.com>:

Show quoted text

On Fri, Aug 10, 2018 at 5:50 AM, 王翔宇 <wxyucs@gmail.com> wrote:

I'm developing a extension for pg. Now I have create a event trigger on
ddl_command_end, and this function will be called after I enter create
function statement. In this function I can only get parseTree. In pg

source

code, I found a function named "pg_event_trigger_ddl_commands" seems

provide

cmds which include funcid. BUT I didn't found any example to call this
function.
who can helps?

Maybe it would help to read the documentation on that function:

https://www.postgresql.org/docs/current/static/functions-
event-triggers.html

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#4Robert Haas
robertmhaas@gmail.com
In reply to: 王翔宇 (#3)
Re: Get funcid when create function

On Tue, Aug 14, 2018 at 10:04 PM, 王翔宇 <wxyucs@gmail.com> wrote:

Yes, I had read this document, BUT it's call from PL/PGSQL. I want call it
from c function.

You could look up the OID using e.g. LookupFuncWithArgs and then call
it using one of the OidFunctionCall macros, but it might be a bit
awkward. Perhaps it would be better to look at the C code inside that
function and use some of that same logic directly from your C code.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company