Preventing some SQL commands

Поиск
Список
Период
Сортировка
От Thomas Hallgren
Тема Preventing some SQL commands
Дата
Msg-id thhal-0+lJ8Aqvgby4YqmNapOByL5YXzg+B4W@mailblocks.com
обсуждение исходный текст
Ответы Re: Preventing some SQL commands  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Preventing some SQL commands  (James William Pye <flaw@rhid.com>)
Список 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




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: How to check the postgresql version
Следующее
От: Thomas Hallgren
Дата:
Сообщение: Re: How to check the postgresql version