What does "LANGUAGE" plpgsql "VOLATILE" mean?

When I create or update a function or procedure in the Postgres database, I see LANGUAGE 'plpgsql' VOLATILE at the end of the function.
What does this mean and what is its purpose?

+4
source share
2 answers

From Postgres Docs :

VOLATILE indicates that the value of a function can vary even within a single-slope scan, so optimization cannot be performed. Relatively few database functions are unstable in this sense; some examples are random (), currval (), timeofday (). Note that any function that has side effects should be classified as unstable, even if its result is quite predictable to prevent call optimization; an example is SETVAL ().

+14
source

Last but not least, LANGUAGE 'plpgsql' VOLATILE means that someone did not receive the note.

The language name in CREATE FUNCTION is an identifier and should not be specified. Must be:

 LANGUAGE plpgsql VOLATILE 

Little practice can lead to confusing errors. More on this answer:
PostgreSQL procedural language "C" not found

+4
source

Source: https://habr.com/ru/post/1436066/


All Articles