File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -402,3 +402,34 @@ LANGUAGE sql STRICT PARALLEL SAFE
402402BEGIN ATOMIC
403403 RETURN NULL ;
404404END;
405+
406+ DROP FUNCTION IF EXISTS cs_config();
407+
408+ --
409+ -- A convenience function to return the configuration in a tabular format, allowing for easier filtering, and querying.
410+ -- Query using `SELECT * FROM cs_config();`
411+ --
412+ CREATE FUNCTION cs_config () RETURNS TABLE (
413+ state cs_configuration_state_v1,
414+ relation text ,
415+ col_name text ,
416+ decrypts_as text ,
417+ indexes jsonb
418+ )
419+ AS $$
420+ BEGIN
421+ RETURN QUERY
422+ WITH tables AS (
423+ SELECT config .state , tables .key AS table, tables .value AS config
424+ FROM cs_configuration_v1 config, jsonb_each(data- > ' tables' ) tables
425+ WHERE config .data - >> ' v' = ' 1'
426+ )
427+ SELECT
428+ tables .state ,
429+ tables .table ,
430+ column_config .key ,
431+ column_config .value - >> ' cast_as' ,
432+ column_config .value - > ' indexes'
433+ FROM tables, jsonb_each(tables .config ) column_config;
434+ END;
435+ $$ LANGUAGE plpgsql;
You can’t perform that action at this time.
0 commit comments