From 066c574709a2b1eb6dc6d695bd90924afe6b5447 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Tue, 11 Oct 2016 17:52:11 +0200 Subject: [PATCH] Fix: cdb_conf table is not accessible to regular users --- scripts-available/CDB_AnalysisCheck.sql | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts-available/CDB_AnalysisCheck.sql b/scripts-available/CDB_AnalysisCheck.sql index ff30f2f..c8dddf3 100644 --- a/scripts-available/CDB_AnalysisCheck.sql +++ b/scripts-available/CDB_AnalysisCheck.sql @@ -1,3 +1,15 @@ +-- Read configuration parameter analysis_quota_factor, making it +-- accessible to regular users (which don't have access to cdb_conf) +CREATE OR REPLACE FUNCTION _CDB_GetConfAnalysisQuotaFactor() +RETURNS float8 AS +$$ +BEGIN + RETURN CDB_Conf_GetConf('analysis_quota_factor')::text::float8; +END; +$$ +LANGUAGE 'plpgsql' STABLE SECURITY DEFINER; + + -- Get the factor (fraction of the quota) for Camshaft cached analysis tables CREATE OR REPLACE FUNCTION _CDB_AnalysisQuotaFactor() RETURNS float8 AS @@ -6,7 +18,7 @@ DECLARE factor float8; BEGIN -- We use a floating point cdb_conf parameter - SELECT cdb_conf_getconf::text::float8 INTO factor FROM CDB_Conf_GetConf('analysis_cache_factor'); + factor := _CDB_GetConfAnalysisQuotaFactor(); -- With a default value IF factor IS NULL THEN factor := 0.2;