Roles are not created anymore, previously private functions for table information extraction (CDB_UserTables, CDB_TableIndexes, CDB_ColumnNames, CDB_ColumnType) will now be callable by anyone while only returning information about tables over which the calling user has SELECT privilege. Closes #36
25 lines
757 B
PL/PgSQL
25 lines
757 B
PL/PgSQL
-- Function returning indexes for a table
|
|
CREATE OR REPLACE FUNCTION CDB_TableIndexes(REGCLASS)
|
|
RETURNS TABLE(index_name name, index_unique bool, index_primary bool, index_keys text array)
|
|
AS $$
|
|
|
|
SELECT pg_class.relname as index_name,
|
|
idx.indisunique as index_unique,
|
|
idx.indisprimary as index_primary,
|
|
ARRAY(
|
|
SELECT pg_get_indexdef(idx.indexrelid, k + 1, true)
|
|
FROM generate_subscripts(idx.indkey, 1) as k
|
|
ORDER BY k
|
|
) as index_keys
|
|
FROM pg_indexes,
|
|
pg_index as idx
|
|
JOIN pg_class
|
|
ON pg_class.oid = idx.indexrelid
|
|
WHERE pg_indexes.tablename = '' || $1 || ''
|
|
AND '' || $1 || '' IN (SELECT CDB_UserTables())
|
|
AND pg_class.relname=pg_indexes.indexname
|
|
;
|
|
|
|
$$ LANGUAGE SQL;
|
|
|