SPI error with non-volatile functions

Поиск
Список
Период
Сортировка
От Tom Mercha
Тема SPI error with non-volatile functions
Дата
Msg-id VI1PR02MB37123D4AF993B4288A395652F4760@VI1PR02MB3712.eurprd02.prod.outlook.com
обсуждение исходный текст
Ответы Re: SPI error with non-volatile functions
Список pgsql-hackers
Dear Hackers

I've been using SPI to execute some queries and this time I've tried to 
issue CREATE TABLE commands through SPI. I've been getting the message 
"ERROR: CREATE TABLE AS is not allowed in a non-volatile function".

I'm a bit confused because my functions are set as volatile when I got 
that result. I was sure I'd be able to issue CREATE TABLE through SPI 
because a possible return value of SPI_execute is SPI_OK_UTILITY if a 
utility command such as CREATE TABLE was executed.

Maybe the caveat is the following. I am actually invoking my function 
through CREATE LANGUAGE's inline handler using an anonymous do block. So 
maybe I need to take some additional considerations for this reason?

The following is what my functions look like:

CREATE FUNCTION myLanguage.myLanguage_function_call_handler()
RETURNS language_handler
AS 'MODULE_PATHNAME','myLanguage_function_call_handler'
LANGUAGE C VOLATILE;

CREATE FUNCTION myLanguage.myLanguage_inline_function_handler(internal)
RETURNS void
AS 'MODULE_PATHNAME','myLanguage_inline_function_handler'
LANGUAGE C VOLATILE;

CREATE LANGUAGE myLanguage
HANDLER myLanguage.myLanguage_function_call_handler
INLINE myLanguage.myLanguage_inline_function_handler;
COMMENT ON LANGUAGE myLanguage IS 'My Language';


Have I correctly approached the issue? Maybe there is a workaround?

Best regards
Tom

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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: [PATCH][DOC] Fix for PREPARE TRANSACTION doc and postgres_fdwmessage.
Следующее
От: Andres Freund
Дата:
Сообщение: Re: SPI error with non-volatile functions