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