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
|
||||
- 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 schema cache dump missing RPC transaction isolation level by @taimoorzaeem in #5079
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE StandaloneDeriving #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module PostgREST.SchemaCache.Routine
|
||||
( PgType(..)
|
||||
@@ -20,7 +22,6 @@ module PostgREST.SchemaCache.Routine
|
||||
, MediaHandler(..)
|
||||
) where
|
||||
|
||||
import Data.Aeson ((.=))
|
||||
import qualified Data.Aeson as JSON
|
||||
import qualified Data.HashMap.Strict as HM
|
||||
import qualified Hasql.Transaction.Sessions as SQL
|
||||
@@ -30,7 +31,6 @@ import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..),
|
||||
RelIdentifier (..), Schema,
|
||||
TableName)
|
||||
|
||||
|
||||
import Protolude
|
||||
|
||||
data PgType
|
||||
@@ -62,20 +62,11 @@ data Routine = Function
|
||||
, pdIsoLvl :: Maybe SQL.IsolationLevel
|
||||
, pdFuncSettings :: FuncSettings
|
||||
}
|
||||
deriving (Eq, Show, Generic)
|
||||
-- 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
|
||||
toJSON (Function sch nam desc params ret vol hasVar _ sets) = JSON.object
|
||||
[
|
||||
"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
|
||||
]
|
||||
deriving (Eq, Show, Generic, JSON.ToJSON)
|
||||
|
||||
-- SQL.IsolationLevel doesn't have a default ToJSON instance, so we derive it.
|
||||
deriving instance Generic SQL.IsolationLevel
|
||||
deriving instance JSON.ToJSON SQL.IsolationLevel
|
||||
|
||||
data RoutineParam = RoutineParam
|
||||
{ ppName :: Text
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
- - statement_timeout
|
||||
- 10s
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: rpc_with_two_hoisted
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -23,6 +24,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: terminate_pgrst
|
||||
pdParams:
|
||||
- ppName: appname
|
||||
@@ -45,6 +47,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: default_isolation_level
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -62,6 +65,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: change_db_schema_and_full_reload
|
||||
pdParams:
|
||||
- ppName: schemas
|
||||
@@ -84,6 +88,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: set_statement_timeout
|
||||
pdParams:
|
||||
- ppName: role
|
||||
@@ -111,6 +116,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: notify_pgrst
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -128,6 +134,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: migrate_function
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -145,6 +152,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: change_role_statement_timeout
|
||||
pdParams:
|
||||
- ppName: timeout
|
||||
@@ -167,6 +175,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: reset_max_rows_config
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -184,6 +193,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: reset_invalid_role_claim_key
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -201,6 +211,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: get_postgres_version
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -218,6 +229,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: do_nothing
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -235,6 +247,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: get_guc_value
|
||||
pdParams:
|
||||
- ppName: name
|
||||
@@ -259,6 +272,7 @@
|
||||
- - statement_timeout
|
||||
- 1s
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: one_sec_timeout
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -276,6 +290,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: reload_pgrst_config
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -295,6 +310,7 @@
|
||||
- - statement_timeout
|
||||
- 7s
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: rpc_with_one_hoisted
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -313,6 +329,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: hello
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -330,6 +347,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: change_db_schemas_config
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -347,6 +365,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: sleep
|
||||
pdParams:
|
||||
- ppName: seconds
|
||||
@@ -371,6 +390,7 @@
|
||||
- - default_transaction_isolation
|
||||
- serializable
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: Serializable
|
||||
pdName: serializable_isolation_level
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -388,6 +408,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: drop_change_cats
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -405,6 +426,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: change_max_rows_config
|
||||
pdParams:
|
||||
- ppName: val
|
||||
@@ -432,6 +454,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: invalid_role_claim_key_reload
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -449,6 +472,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: reset_db_schemas_config
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -466,6 +490,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: root
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -483,6 +508,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: create_function
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -500,6 +526,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: get_pgrst_version
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -512,6 +539,26 @@
|
||||
pdSchema: public
|
||||
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
|
||||
qiSchema: public
|
||||
- - pdDescription: null
|
||||
@@ -519,6 +566,7 @@
|
||||
- - default_transaction_isolation
|
||||
- REPEATABLE READ
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: RepeatableRead
|
||||
pdName: repeatable_read_isolation_level
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -536,6 +584,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: get_work_mem
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -553,6 +602,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: notify_do_nothing
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -570,6 +620,7 @@
|
||||
- - pdDescription: null
|
||||
pdFuncSettings: []
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: rpc_work_mem
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
@@ -590,6 +641,7 @@
|
||||
- - statement_timeout
|
||||
- 4s
|
||||
pdHasVariadic: false
|
||||
pdIsoLvl: null
|
||||
pdName: four_sec_timeout
|
||||
pdParams: []
|
||||
pdReturnType:
|
||||
|
||||
@@ -165,6 +165,12 @@ returns text as $$
|
||||
$$
|
||||
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 $_$
|
||||
drop function if exists mult_them(int, int);
|
||||
create or replace function mult_them(a int, b int) returns int as $$
|
||||
|
||||
Reference in New Issue
Block a user