diff --git a/docs/references/transactions.rst b/docs/references/transactions.rst index 1fc43360d..dc3777725 100644 --- a/docs/references/transactions.rst +++ b/docs/references/transactions.rst @@ -59,10 +59,29 @@ Modifying the database inside READ ONLY transactions is not possible. PostgREST The :ref:`options_requests` method doesn't start a transaction, so it's not relevant here. +.. _isolation_lvl: + Isolation Level --------------- -Every transaction uses the PostgreSQL default isolation level: READ COMMITTED. +Every transaction uses the PostgreSQL default isolation level: READ COMMITTED. Unless you modify `default_transaction_isolation `_ for an impersonated role or function. + +Using :ref:`impersonated_settings`, change the isolation level for all the role's requests with: + +.. code-block:: postgresql + + ALTER ROLE webuser SET default_transaction_isolation TO 'repeatable read'; + +Or to change the isolation level per function call. + +.. code-block:: postgresql + + CREATE OR REPLACE FUNCTION myfunc() + RETURNS text as $$ + SELECT 'hello'; + $$ + LANGUAGE SQL + SET default_transaction_isolation TO 'serializable'; .. _tx_settings: @@ -87,34 +106,6 @@ And you can set them with ``set_config`` SELECT set_config('response.', 'value1' ,true); -Request Role and Search Path -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Because of :ref:`user_impersonation`, PostgREST sets the standard ``role``. You can get this in different ways: - -.. code-block:: postgresql - - SELECT current_role; - - SELECT current_user; - - SELECT current_setting('role', true); - -Additionally it also sets the ``search_path`` based on :ref:`db-schemas` and :ref:`db-extra-search-path`. - -.. _impersonated_settings: - -Impersonated Role Settings -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The :ref:`Impersonated Role ` settings are applied. For example, if you do: - -.. code-block:: postgresql - - ALTER ROLE webuser SET statement_timeout TO '5s'; - -Every ``webuser`` request gets its queries executed with a ``statement_timeout`` of 5 seconds. - .. _guc_req_headers_cookies_claims: Request Headers, Cookies and JWT claims @@ -153,6 +144,34 @@ The path and method are stored as ``text``. SELECT current_setting('request.method', true); +Request Role and Search Path +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Because of :ref:`user_impersonation`, PostgREST sets the standard ``role``. You can get this in different ways: + +.. code-block:: postgresql + + SELECT current_role; + + SELECT current_user; + + SELECT current_setting('role', true); + +Additionally it also sets the ``search_path`` based on :ref:`db-schemas` and :ref:`db-extra-search-path`. + +.. _impersonated_settings: + +Impersonated Role Settings +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The :ref:`Impersonated Role ` settings are applied. For example, if you do: + +.. code-block:: postgresql + + ALTER ROLE webuser SET statement_timeout TO '5s'; + +Every ``webuser`` request gets its queries executed with a ``statement_timeout`` of 5 seconds. + .. _guc_resp_hdrs: Response Headers diff --git a/docs/releases/v11.0.0.rst b/docs/releases/v11.0.0.rst index bdccd0b0f..d8b04ffbb 100644 --- a/docs/releases/v11.0.0.rst +++ b/docs/releases/v11.0.0.rst @@ -8,6 +8,7 @@ Transactions ~~~~~~~~~~~~ - New :ref:`impersonated_settings`. +- New configurable :ref:`isolation_lvl`. Inserts ~~~~~~~