Re: Preventing some SQL commands
От | Thomas Hallgren |
---|---|
Тема | Re: Preventing some SQL commands |
Дата | |
Msg-id | thhal-0EIJ9Aofnby4k/ZpIQNZVgQL4K0JgQk@mailblocks.com обсуждение исходный текст |
Ответ на | Re: Preventing some SQL commands (James William Pye <flaw@rhid.com>) |
Список | pgsql-hackers |
James William Pye >bool (*SPI_UtilityFilter) (NodeTag aStmt); >To a "void SPI_FilterUtilities(void *execPlan, SPI_UtilityFilter fp)". > >Throwing an error if deemed necessary by the pointed to function. > > After browsing the code a bit more, I realize that the above suggestion is superior to my own. It doesn't require a memory allocation and it's very close to what I'd like to have. I'd like it a bit more generic to allow arbitrary perusal of Query attributes. Like this to be more precise: typedef bool (*QueryVisitor)(Query* query, void *clientData); bool SPI_traverse_query_roots(void *plan, QueryVisitor queryVisitor, void* clientData) { List *query_list_list = ((_SPI_plan*)plan)->qtlist; ListCell *query_list_list_item; foreach(query_list_list_item, query_list_list) { List *query_list = lfirst(query_list_list_item); ListCell*query_list_item; foreach(query_list_item, query_list) { if(!queryVisitor((Query *)lfirst(query_list_item), clientData)) return false; } } return true; } This will allow me to implement a QueryVisitor like so: static bool detectTransactCommands(Query* query, void* clientData) { return !(query->commandType == CMD_UTILITY && IsA(query->utilityStmt, TransactionStmt)); } and then test using: if(!SPI_traverse_query_roots(myPlan, detectTransactCommands, null)) /* Handle error here */ Any chance a patch containing the SPI_traverse_query_roots would be accepted? Regards, Thomas Hallgren
В списке pgsql-hackers по дате отправления: