fix: schema cache dump missing RPC transaction isolation level
Fixes #5079. Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file. From versio
|
|||||||
- If the schema cache fails to reload, PostgREST will no longer stop serving requests and will continue doing so in a "best effort" basis by @mkleczek in #4873 #4869
|
- If the schema cache fails to reload, PostgREST will no longer stop serving requests and will continue doing so in a "best effort" basis by @mkleczek in #4873 #4869
|
||||||
- Stop reporting 503s errors unnecessarily while the schema cache is loading at startup by @mkleczek in #4880
|
- Stop reporting 503s errors unnecessarily while the schema cache is loading at startup by @mkleczek in #4880
|
||||||
- Fix responding with `Something went wrong` on Admin server when under EMFILE by @mkleczek in #5077
|
- Fix responding with `Something went wrong` on Admin server when under EMFILE by @mkleczek in #5077
|
||||||
|
- Fix schema cache dump missing RPC transaction isolation level by @taimoorzaeem in #5079
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{-# LANGUAGE DeriveAnyClass #-}
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
{-# LANGUAGE DeriveGeneric #-}
|
{-# LANGUAGE DeriveGeneric #-}
|
||||||
|
{-# LANGUAGE StandaloneDeriving #-}
|
||||||
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||||
|
|
||||||
module PostgREST.SchemaCache.Routine
|
module PostgREST.SchemaCache.Routine
|
||||||
( PgType(..)
|
( PgType(..)
|
||||||
@@ -20,7 +22,6 @@ module PostgREST.SchemaCache.Routine
|
|||||||
, MediaHandler(..)
|
, MediaHandler(..)
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Aeson ((.=))
|
|
||||||
import qualified Data.Aeson as JSON
|
import qualified Data.Aeson as JSON
|
||||||
import qualified Data.HashMap.Strict as HM
|
import qualified Data.HashMap.Strict as HM
|
||||||
import qualified Hasql.Transaction.Sessions as SQL
|
import qualified Hasql.Transaction.Sessions as SQL
|
||||||
@@ -30,7 +31,6 @@ import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..),
|
|||||||
RelIdentifier (..), Schema,
|
RelIdentifier (..), Schema,
|
||||||
TableName)
|
TableName)
|
||||||
|
|
||||||
|
|
||||||
import Protolude
|
import Protolude
|
||||||
|
|
||||||
data PgType
|
data PgType
|
||||||
@@ -62,20 +62,11 @@ data Routine = Function
|
|||||||
, pdIsoLvl :: Maybe SQL.IsolationLevel
|
, pdIsoLvl :: Maybe SQL.IsolationLevel
|
||||||
, pdFuncSettings :: FuncSettings
|
, pdFuncSettings :: FuncSettings
|
||||||
}
|
}
|
||||||
deriving (Eq, Show, Generic)
|
deriving (Eq, Show, Generic, JSON.ToJSON)
|
||||||
-- need to define JSON manually bc SQL.IsolationLevel doesn't have a JSON instance(and we can't define one for that type without getting a compiler error)
|
|
||||||
instance JSON.ToJSON Routine where
|
-- SQL.IsolationLevel doesn't have a default ToJSON instance, so we derive it.
|
||||||
toJSON (Function sch nam desc params ret vol hasVar _ sets) = JSON.object
|
deriving instance Generic SQL.IsolationLevel
|
||||||
[
|
deriving instance JSON.ToJSON SQL.IsolationLevel
|
||||||
"pdSchema" .= sch
|
|
||||||
, "pdName" .= nam
|
|
||||||
, "pdDescription" .= desc
|
|
||||||
, "pdParams" .= JSON.toJSON params
|
|
||||||
, "pdReturnType" .= JSON.toJSON ret
|
|
||||||
, "pdVolatility" .= JSON.toJSON vol
|
|
||||||
, "pdHasVariadic" .= JSON.toJSON hasVar
|
|
||||||
, "pdFuncSettings" .= JSON.toJSON sets
|
|
||||||
]
|
|
||||||
|
|
||||||
data RoutineParam = RoutineParam
|
data RoutineParam = RoutineParam
|
||||||
{ ppName :: Text
|
{ ppName :: Text
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
- - statement_timeout
|
- - statement_timeout
|
||||||
- 10s
|
- 10s
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: rpc_with_two_hoisted
|
pdName: rpc_with_two_hoisted
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: terminate_pgrst
|
pdName: terminate_pgrst
|
||||||
pdParams:
|
pdParams:
|
||||||
- ppName: appname
|
- ppName: appname
|
||||||
@@ -45,6 +47,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: default_isolation_level
|
pdName: default_isolation_level
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -62,6 +65,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: change_db_schema_and_full_reload
|
pdName: change_db_schema_and_full_reload
|
||||||
pdParams:
|
pdParams:
|
||||||
- ppName: schemas
|
- ppName: schemas
|
||||||
@@ -84,6 +88,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: set_statement_timeout
|
pdName: set_statement_timeout
|
||||||
pdParams:
|
pdParams:
|
||||||
- ppName: role
|
- ppName: role
|
||||||
@@ -111,6 +116,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: notify_pgrst
|
pdName: notify_pgrst
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -128,6 +134,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: migrate_function
|
pdName: migrate_function
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -145,6 +152,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: change_role_statement_timeout
|
pdName: change_role_statement_timeout
|
||||||
pdParams:
|
pdParams:
|
||||||
- ppName: timeout
|
- ppName: timeout
|
||||||
@@ -167,6 +175,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: reset_max_rows_config
|
pdName: reset_max_rows_config
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -184,6 +193,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: reset_invalid_role_claim_key
|
pdName: reset_invalid_role_claim_key
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -201,6 +211,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: get_postgres_version
|
pdName: get_postgres_version
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -218,6 +229,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: do_nothing
|
pdName: do_nothing
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -235,6 +247,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: get_guc_value
|
pdName: get_guc_value
|
||||||
pdParams:
|
pdParams:
|
||||||
- ppName: name
|
- ppName: name
|
||||||
@@ -259,6 +272,7 @@
|
|||||||
- - statement_timeout
|
- - statement_timeout
|
||||||
- 1s
|
- 1s
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: one_sec_timeout
|
pdName: one_sec_timeout
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -276,6 +290,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: reload_pgrst_config
|
pdName: reload_pgrst_config
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -295,6 +310,7 @@
|
|||||||
- - statement_timeout
|
- - statement_timeout
|
||||||
- 7s
|
- 7s
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: rpc_with_one_hoisted
|
pdName: rpc_with_one_hoisted
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -313,6 +329,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: hello
|
pdName: hello
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -330,6 +347,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: change_db_schemas_config
|
pdName: change_db_schemas_config
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -347,6 +365,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: sleep
|
pdName: sleep
|
||||||
pdParams:
|
pdParams:
|
||||||
- ppName: seconds
|
- ppName: seconds
|
||||||
@@ -371,6 +390,7 @@
|
|||||||
- - default_transaction_isolation
|
- - default_transaction_isolation
|
||||||
- serializable
|
- serializable
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: Serializable
|
||||||
pdName: serializable_isolation_level
|
pdName: serializable_isolation_level
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -388,6 +408,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: drop_change_cats
|
pdName: drop_change_cats
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -405,6 +426,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: change_max_rows_config
|
pdName: change_max_rows_config
|
||||||
pdParams:
|
pdParams:
|
||||||
- ppName: val
|
- ppName: val
|
||||||
@@ -432,6 +454,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: invalid_role_claim_key_reload
|
pdName: invalid_role_claim_key_reload
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -449,6 +472,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: reset_db_schemas_config
|
pdName: reset_db_schemas_config
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -466,6 +490,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: root
|
pdName: root
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -483,6 +508,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: create_function
|
pdName: create_function
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -500,6 +526,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: get_pgrst_version
|
pdName: get_pgrst_version
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -512,6 +539,26 @@
|
|||||||
pdSchema: public
|
pdSchema: public
|
||||||
pdVolatility: Volatile
|
pdVolatility: Volatile
|
||||||
|
|
||||||
|
- - qiName: read_committed_isolation_level
|
||||||
|
qiSchema: public
|
||||||
|
- - pdDescription: null
|
||||||
|
pdFuncSettings:
|
||||||
|
- - default_transaction_isolation
|
||||||
|
- read committed
|
||||||
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: ReadCommitted
|
||||||
|
pdName: read_committed_isolation_level
|
||||||
|
pdParams: []
|
||||||
|
pdReturnType:
|
||||||
|
contents:
|
||||||
|
contents:
|
||||||
|
qiName: text
|
||||||
|
qiSchema: pg_catalog
|
||||||
|
tag: Scalar
|
||||||
|
tag: Single
|
||||||
|
pdSchema: public
|
||||||
|
pdVolatility: Volatile
|
||||||
|
|
||||||
- - qiName: repeatable_read_isolation_level
|
- - qiName: repeatable_read_isolation_level
|
||||||
qiSchema: public
|
qiSchema: public
|
||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
@@ -519,6 +566,7 @@
|
|||||||
- - default_transaction_isolation
|
- - default_transaction_isolation
|
||||||
- REPEATABLE READ
|
- REPEATABLE READ
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: RepeatableRead
|
||||||
pdName: repeatable_read_isolation_level
|
pdName: repeatable_read_isolation_level
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -536,6 +584,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: get_work_mem
|
pdName: get_work_mem
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -553,6 +602,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: notify_do_nothing
|
pdName: notify_do_nothing
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -570,6 +620,7 @@
|
|||||||
- - pdDescription: null
|
- - pdDescription: null
|
||||||
pdFuncSettings: []
|
pdFuncSettings: []
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: rpc_work_mem
|
pdName: rpc_work_mem
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
@@ -590,6 +641,7 @@
|
|||||||
- - statement_timeout
|
- - statement_timeout
|
||||||
- 4s
|
- 4s
|
||||||
pdHasVariadic: false
|
pdHasVariadic: false
|
||||||
|
pdIsoLvl: null
|
||||||
pdName: four_sec_timeout
|
pdName: four_sec_timeout
|
||||||
pdParams: []
|
pdParams: []
|
||||||
pdReturnType:
|
pdReturnType:
|
||||||
|
|||||||
@@ -165,6 +165,12 @@ returns text as $$
|
|||||||
$$
|
$$
|
||||||
language sql set default_transaction_isolation = 'REPEATABLE READ';
|
language sql set default_transaction_isolation = 'REPEATABLE READ';
|
||||||
|
|
||||||
|
create function read_committed_isolation_level()
|
||||||
|
returns text as $$
|
||||||
|
select current_setting('transaction_isolation', true);
|
||||||
|
$$
|
||||||
|
language sql set default_transaction_isolation = 'read committed';
|
||||||
|
|
||||||
create or replace function create_function() returns void as $_$
|
create or replace function create_function() returns void as $_$
|
||||||
drop function if exists mult_them(int, int);
|
drop function if exists mult_them(int, int);
|
||||||
create or replace function mult_them(a int, b int) returns int as $$
|
create or replace function mult_them(a int, b int) returns int as $$
|
||||||
|
|||||||
Reference in New Issue
Block a user