refactor: Simplify funcsSqlQuery
This allows to re-use ANY($$1) in the next commit.
This commit is contained in:
committed by
Wolfgang Walther
parent
735e1edbf6
commit
f31848f2e5
@@ -181,7 +181,7 @@ actionQuery (MaybeDb plan@InspectPlan{ipSchema=tSchema}) AppConfig{..} _ _ sCach
|
|||||||
tableAccess <- SQL.statement [tSchema] (SchemaCache.accessibleTables configDbPreparedStatements)
|
tableAccess <- SQL.statement [tSchema] (SchemaCache.accessibleTables configDbPreparedStatements)
|
||||||
MaybeDbResult plan . Just <$> ((,,)
|
MaybeDbResult plan . Just <$> ((,,)
|
||||||
(HM.filterWithKey (\qi _ -> S.member qi tableAccess) $ SchemaCache.dbTables sCache)
|
(HM.filterWithKey (\qi _ -> S.member qi tableAccess) $ SchemaCache.dbTables sCache)
|
||||||
<$> SQL.statement (tSchema, configDbHoistedTxSettings) (SchemaCache.accessibleFuncs configDbPreparedStatements)
|
<$> SQL.statement ([tSchema], configDbHoistedTxSettings) (SchemaCache.accessibleFuncs configDbPreparedStatements)
|
||||||
<*> SQL.statement tSchema (SchemaCache.schemaDescription configDbPreparedStatements))
|
<*> SQL.statement tSchema (SchemaCache.schemaDescription configDbPreparedStatements))
|
||||||
OAIgnorePriv ->
|
OAIgnorePriv ->
|
||||||
MaybeDbResult plan . Just <$> ((,,)
|
MaybeDbResult plan . Just <$> ((,,)
|
||||||
|
|||||||
@@ -360,21 +360,19 @@ dataRepresentations = SQL.Statement sql mempty decodeRepresentations
|
|||||||
|]
|
|]
|
||||||
|
|
||||||
allFunctions :: Bool -> SQL.Statement AppConfig RoutineMap
|
allFunctions :: Bool -> SQL.Statement AppConfig RoutineMap
|
||||||
allFunctions = SQL.Statement sql params decodeFuncs
|
allFunctions = SQL.Statement funcsSqlQuery params decodeFuncs
|
||||||
where
|
where
|
||||||
params =
|
params =
|
||||||
(toList . configDbSchemas >$< arrayParam HE.text) <>
|
(toList . configDbSchemas >$< arrayParam HE.text) <>
|
||||||
(configDbHoistedTxSettings >$< arrayParam HE.text)
|
(configDbHoistedTxSettings >$< arrayParam HE.text)
|
||||||
sql =
|
|
||||||
funcsSqlQuery <> " AND pn.nspname = ANY($1)"
|
|
||||||
|
|
||||||
accessibleFuncs :: Bool -> SQL.Statement (Schema, [Text]) RoutineMap
|
accessibleFuncs :: Bool -> SQL.Statement ([Schema], [Text]) RoutineMap
|
||||||
accessibleFuncs = SQL.Statement sql params decodeFuncs
|
accessibleFuncs = SQL.Statement sql params decodeFuncs
|
||||||
where
|
where
|
||||||
params =
|
params =
|
||||||
(fst >$< param HE.text) <>
|
(fst >$< arrayParam HE.text) <>
|
||||||
(snd >$< arrayParam HE.text)
|
(snd >$< arrayParam HE.text)
|
||||||
sql = funcsSqlQuery <> " AND pn.nspname = $1 AND has_function_privilege(p.oid, 'execute')"
|
sql = funcsSqlQuery <> " AND has_function_privilege(p.oid, 'execute')"
|
||||||
|
|
||||||
funcsSqlQuery :: SqlQuery
|
funcsSqlQuery :: SqlQuery
|
||||||
funcsSqlQuery = encodeUtf8 [trimming|
|
funcsSqlQuery = encodeUtf8 [trimming|
|
||||||
@@ -465,7 +463,8 @@ funcsSqlQuery = encodeUtf8 [trimming|
|
|||||||
WHERE setting ~ ANY($$2)
|
WHERE setting ~ ANY($$2)
|
||||||
) func_settings ON TRUE
|
) func_settings ON TRUE
|
||||||
WHERE t.oid <> 'trigger'::regtype AND COALESCE(a.callable, true)
|
WHERE t.oid <> 'trigger'::regtype AND COALESCE(a.callable, true)
|
||||||
AND prokind = 'f'|]
|
AND prokind = 'f'
|
||||||
|
AND pn.nspname = ANY($$1) |]
|
||||||
|
|
||||||
schemaDescription :: Bool -> SQL.Statement Schema (Maybe Text)
|
schemaDescription :: Bool -> SQL.Statement Schema (Maybe Text)
|
||||||
schemaDescription =
|
schemaDescription =
|
||||||
|
|||||||
Reference in New Issue
Block a user