Fix CDB_Overviews for cases that require explicit schema name

Fixes #218
This commit is contained in:
Javier Goizueta 2016-04-04 17:02:59 +02:00
parent aff7ae3e2e
commit c0262a05eb
2 changed files with 16 additions and 12 deletions

View File

@ -100,18 +100,21 @@ $$ LANGUAGE PLPGSQL VOLATILE;
CREATE OR REPLACE FUNCTION CDB_Overviews(reloid REGCLASS) CREATE OR REPLACE FUNCTION CDB_Overviews(reloid REGCLASS)
RETURNS TABLE(base_table REGCLASS, z integer, overview_table REGCLASS) RETURNS TABLE(base_table REGCLASS, z integer, overview_table REGCLASS)
AS $$ AS $$
-- FIXME: this will fail if the overview tables DECLARE
-- require a explicit schema name schema_name TEXT;
-- possible solutions: return table names as text instead of regclass table_name TEXT;
-- or add schema of reloid before casting to regclass BEGIN
SELECT -- TODO: review implementation of CDB_UserTables an suitability for this
reloid AS base_table, SELECT * FROM _cdb_split_table_name(reloid) INTO schema_name, table_name;
_CDB_OverviewTableZ(cdb_usertables) AS z, RETURN QUERY SELECT
cdb_usertables::regclass AS overview_table reloid AS base_table,
FROM CDB_UserTables() _CDB_OverviewTableZ(cdb_usertables) AS z,
WHERE _CDB_IsOverviewTableOf((SELECT relname FROM pg_class WHERE oid=reloid), cdb_usertables) (schema_name||'.'||cdb_usertables)::regclass AS overview_table
ORDER BY z; FROM CDB_UserTables()
$$ LANGUAGE SQL; WHERE _CDB_IsOverviewTableOf((SELECT relname FROM pg_class WHERE oid=reloid), cdb_usertables)
ORDER BY z;
END
$$ LANGUAGE PLPGSQL;
-- Return existing overviews (if any) for multiple dataset tables. -- Return existing overviews (if any) for multiple dataset tables.
-- Scope: public -- Scope: public

View File

@ -23,6 +23,7 @@ SELECT CDB_CreateOverviews('polyg_t'::regclass);
SELECT CDB_CreateOverviews('column_types_t'::regclass); SELECT CDB_CreateOverviews('column_types_t'::regclass);
SELECT CDB_Overviews('base_t'::regclass); SELECT CDB_Overviews('base_t'::regclass);
SELECT CDB_Overviews('"public"."base_t"'::regclass);
SELECT CDB_Overviews(ARRAY['base_t'::regclass, 'base_bare_t'::regclass]); SELECT CDB_Overviews(ARRAY['base_t'::regclass, 'base_bare_t'::regclass]);
SELECT CDB_Overviews('polyg_t'::regclass); SELECT CDB_Overviews('polyg_t'::regclass);
SELECT CDB_Overviews('column_types_t'::regclass); SELECT CDB_Overviews('column_types_t'::regclass);