From: | Thomas Hallgren <thhal(at)mailblocks(dot)com> |
---|---|
To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Preventing some SQL commands |
Date: | 2004-11-21 15:55:37 |
Message-ID: | thhal-0+lJ8Aqvgby4YqmNapOByL5YXzg+B4W@mailblocks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
In a PL language it's sometimes desirable to prevent execution of some
commands. I would like to prevent the commands "begin [work or
transaction]", "commit", and "rollback", completely and I would like to
force the user to use explicit methods for the savepoint methods.
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
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Hallgren | 2004-11-21 16:05:48 | Re: How to check the postgresql version |
Previous Message | Joe Conway | 2004-11-21 15:38:35 | Re: How to check the postgresql version |