Thread: Identifying ALTER TABLE "sub-command"

Identifying ALTER TABLE "sub-command"

From
Jeremy Finzel
Date:
Hello -

I have found that in leveraging the parser code to decode DDL SQL, it is very easy to get which type of general command is being issued with CreateCommandTag(parsetree).  However, is there a way (or a starting point) to identify the sub-command as well i.e. ENABLE TRIGGER, ADD FOREIGN KEY, etc.?

Any direction is much appreciated.

Thanks,
Jeremy

Re: Identifying ALTER TABLE "sub-command"

From
Alvaro Herrera
Date:
Jeremy Finzel wrote:
> Hello -
> 
> I have found that in leveraging the parser code to decode DDL SQL, it is
> very easy to get which type of general command is being issued with
> CreateCommandTag(parsetree).  However, is there a way (or a starting point)
> to identify the sub-command as well i.e. ENABLE TRIGGER, ADD FOREIGN KEY,
> etc.?

Hi Jeremy,

See the test code in src/test/modules/test_ddl_deparse/test_ddl_deparse.c
It might give you some ideas.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services