Add function to obtain existing overviews of a table

This commit is contained in:
Javier Goizueta
2016-01-11 14:50:10 +01:00
parent 496f079b1c
commit 6ea63af974
2 changed files with 48 additions and 0 deletions

View File

@@ -1,3 +1,20 @@
-- Return existing overviews (if any) for a given dataset table
-- Scope: public
-- Parameters
-- reloid: oid of the input table.
-- Return relation of overviews for the table with
-- z level of the overview and overview table, ordered by z.
CREATE OR REPLACE FUNCTION CDB_Overviews(reloid REGCLASS)
RETURNS TABLE(z integer, overview_table REGCLASS)
AS $$
SELECT
substring(cdb_usertables from '\d+$')::integer as z,
cdb_usertables::regclass as overview_table
FROM CDB_UserTables()
WHERE cdb_usertables SIMILAR TO reloid::text || '_ov[0-9]+'
ORDER BY z;
$$ LANGUAGE SQL;
-- Calculate the estimated extent of a cartodbfy'ed table.
-- Scope: private.
-- Parameters