From 021d922d843581fc91f5c572fa001fc0b9044b99 Mon Sep 17 00:00:00 2001 From: Kartones Date: Fri, 4 Jul 2014 10:57:55 +0200 Subject: [PATCH] CDB-3304 Method cdb_userdatasize now has schema_name param, and added backwards-compatible version without it --- scripts-available/CDB_Quota.sql | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts-available/CDB_Quota.sql b/scripts-available/CDB_Quota.sql index 4b5ca0b..bff1774 100644 --- a/scripts-available/CDB_Quota.sql +++ b/scripts-available/CDB_Quota.sql @@ -1,5 +1,5 @@ -- Return the estimated size of user data. Used for quota checking. -CREATE OR REPLACE FUNCTION CDB_UserDataSize() +CREATE OR REPLACE FUNCTION CDB_UserDataSize(schema_name TEXT) RETURNS bigint AS $$ -- TODO: double check this query. Maybe use CDB_TableMetadata for lookup ? @@ -10,13 +10,24 @@ $$ SELECT coalesce(int8(sum(pg_total_relation_size(quote_ident(table_name))) / 2), 0) AS quota FROM information_schema.tables - WHERE table_catalog = current_database() AND table_schema = 'public' - AND table_name != 'spatial_ref_sys' - AND table_name != 'cdb_tablemetadata' - AND table_type = 'BASE TABLE'; + WHERE table_catalog = current_database() AND table_schema = schema_name + AND table_name != 'spatial_ref_sys' + AND table_name != 'cdb_tablemetadata' + AND table_type = 'BASE TABLE'; $$ LANGUAGE 'sql' VOLATILE; + +-- Return the estimated size of user data. Used for quota checking. +-- Implicit schema version for backwards compatibility +CREATE OR REPLACE FUNCTION CDB_UserDataSize() +RETURNS bigint AS +$$ + SELECT public.CDB_UserDataSize('public'); +$$ +LANGUAGE 'sql' VOLATILE; + + CREATE OR REPLACE FUNCTION CDB_CheckQuota() RETURNS trigger AS $$