Identifying ALTER TABLE "sub-command"
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
<div>Hello</div><div>You can start with functions ATPrepCmd and ATExecCmd in src/backend/commands/tablecmds.c</div><div>Also note, one alter table statement can have multiple different actions.</div><div> </div><div>Regards, Sergei</div><div><br /></div><div><br /></div><div>11.01.2018, 18:56, "Jeremy Finzel" <finzelj@gmail.com>:</div><blockquote type="cite"><div dir="ltr">Hello -<div><br /></div><div>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 <span style="color:rgb(0,0,0);font-family:Menlo;font-size:9pt;">CreateCommandTag(parsetree)</span>. However, is there a way (or a starting point) to identify the sub-command as well i.e. ENABLE TRIGGER, ADD FOREIGN KEY, etc.?</div><div><br /></div><div>Any direction is much appreciated.</div><div><br /></div><div>Thanks,</div><div>Jeremy</div></div>
</blockquote>
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