From: | Thomas Hallgren <thhal(at)mailblocks(dot)com> |
---|---|
To: | James William Pye <flaw(at)rhid(dot)com> |
Cc: | Hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: Preventing some SQL commands |
Date: | 2004-11-22 13:28:46 |
Message-ID: | thhal-0EIJ9Aofnby4k/ZpIQNZVgQL4K0JgQk@mailblocks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Matt | 2004-11-22 13:40:29 | Re: patch: plpgsql - access records with rec.(expr) |
Previous Message | Andrew Dunstan | 2004-11-22 12:37:46 | another plperl bug |