I wonder if there's any way to extract the nature of a command from the execution plan returned by SPI_prepare. If not, would it be very difficult to add? It doesn't feel optimal to add a home brewed parser that parses the statements prior to prepare just to find out if I they should prevented.
One approach could be to extend the CmdType enum. Perhaps something like this:
typedef enum CmdType
{
CMD_UNKNOWN,
CMD_SELECT, /* select stmt (formerly retrieve) */
CMD_UPDATE, /* update stmt (formerly replace) */
CMD_INSERT, /* insert stmt (formerly append) */
CMD_DELETE,
CMD_TRANSACTION, /* begin, commit, rollback */
CMD_SAVEPOINT, /* savepoint, rollback to savepoint, release savepoint */
CMD_UTILITY, /* cmds like create, destroy, copy,
* vacuum, etc. */
CMD_NOTHING /* dummy command for instead nothing rules
* with qual */
} CmdType;
and then add a SPI function
CmdType SPI_get_command_type(void* executionPlan)
What do you think? It would certanly help PL/Java add safe and efficient savepoint management and the other PL's are likely to share my concerns.
Regards, Thomas Hallgren
---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives?
http://archives.postgresql.org