agent-skills/skills/hologres-privileges/SKILL.md
Hologres privilege management using PostgreSQL standard authorization model (expert permission model). Use for creating users, granting/revoking Schema/table/column/view privileges, configuring default privileges for future objects, diagnosing permission issues, and planning role-based access control. Triggers: "hologres权限", "hologres grant", "hologres revoke", "permission denied", "权限管理", "hologres privileges", "hologres authorization", "default privileges", "角色权限", "授权"
npx skillsauth add aliyun/hologres-ai-plugins hologres-privilegesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill requires hologres-cli to be installed first:
pip install hologres-cli
export HOLOGRES_SKILL=hologres-privileges
All SQL execution depends on hologres-cli commands (hologres sql run --write).
Manage fine-grained access control in Hologres using standard PostgreSQL GRANT/REVOKE syntax.
Hologres provides three permission models. This skill focuses on the Expert Model.
| Model | Granularity | Use Case | |-------|------------|----------| | Expert (PostgreSQL Standard) | Table/Column/View level | Fine-grained control, per-table/per-user | | SPM (Simple Permission Model) | Database level | Quick setup, 4 preset role groups | | SLPM (Schema-Level Permission Model) | Schema level | Multi-team isolation with simplified management |
The expert model uses standard PostgreSQL
GRANT/REVOKEsyntax. It only applies to existing objects — useALTER DEFAULT PRIVILEGESfor future objects.
-- 1. Create user (RAM user format: p4_<uid>)
CREATE USER "p4_1822780xxx";
-- 2. Grant Schema access (required for any table query)
GRANT USAGE ON SCHEMA public TO "p4_1822780xxx";
-- 3. Grant table read permission
GRANT SELECT ON TABLE public.orders TO "p4_1822780xxx";
-- 4. Verify permission
SELECT has_table_privilege('p4_1822780xxx', 'public.orders', 'SELECT');
| Type | Format | Example |
|------|--------|---------|
| Alibaba Cloud main account | Numeric UID | 11822780xxx |
| RAM sub-account | p4_ + UID | p4_1822780xxx |
| Custom user (BASIC) | BASIC$ + name | BASIC$dev_user |
-- Create user with login privilege
CREATE USER "p4_1822780xxx";
-- Create user as Superuser
CREATE USER "p4_1822780xxx" SUPERUSER;
-- Create custom user with password
CREATE USER "BASIC$dev_user" WITH PASSWORD 'secure_password';
-- Promote to Superuser
ALTER USER "p4_1822780xxx" SUPERUSER;
-- Demote to normal user
ALTER USER "p4_1822780xxx" NOSUPERUSER;
-- Change custom user password
ALTER USER "BASIC$dev_user" WITH PASSWORD 'new_password';
-- Drop user (no owned objects)
DROP USER "p4_1822780xxx";
-- Drop user with owned objects (transfer first)
REASSIGN OWNED BY "p4_old_uid" TO "p4_new_uid";
DROP USER "p4_old_uid";
-- Grant Schema access (required before any table query)
GRANT USAGE ON SCHEMA schema_name TO "user_id";
-- Grant ability to create tables in Schema
GRANT CREATE ON SCHEMA schema_name TO "user_id";
-- Grant specific privileges on a single table
GRANT SELECT ON TABLE schema_name.table_name TO "user_id";
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE schema_name.table_name TO "user_id";
-- Grant on all existing tables in a Schema
GRANT SELECT ON ALL TABLES IN SCHEMA public TO "user_id";
-- Grant to all users
GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA public TO PUBLIC;
-- Grant SELECT on specific columns only
GRANT SELECT (column1, column2) ON TABLE schema_name.table_name TO "user_id";
GRANT SELECT ON view_name TO "user_id";
-- Allow the grantee to re-grant this privilege to others
GRANT SELECT ON TABLE schema_name.table_name TO "user_id" WITH GRANT OPTION;
Only the table Owner or Superuser can DROP/ALTER a table.
-- Transfer table ownership
ALTER TABLE schema_name.table_name OWNER TO "user_id";
-- Transfer ownership to a role group
ALTER TABLE schema_name.table_name OWNER TO role_name;
GRANT only applies to existing objects. Use ALTER DEFAULT PRIVILEGES so that future tables automatically inherit permissions.
-- All future tables created by user1 in public schema are readable by everyone
ALTER DEFAULT PRIVILEGES FOR ROLE "user1" IN SCHEMA public
GRANT SELECT ON TABLES TO PUBLIC;
-- Only user2 can read future tables created by user1
ALTER DEFAULT PRIVILEGES FOR ROLE "user1" IN SCHEMA public
GRANT SELECT ON TABLES TO "user2";
-- Revoke a default privilege rule
ALTER DEFAULT PRIVILEGES FOR ROLE "user1" IN SCHEMA public
REVOKE SELECT ON TABLES FROM PUBLIC;
-- Check current default privilege settings
SELECT pg_catalog.pg_get_userbyid(d.defaclrole) AS "Owner",
n.nspname AS "Schema",
CASE d.defaclobjtype
WHEN 'r' THEN 'table' WHEN 'S' THEN 'sequence'
WHEN 'f' THEN 'function' WHEN 'T' THEN 'type'
END AS "Type",
pg_catalog.array_to_string(d.defaclacl, E'\n') AS "Access privileges"
FROM pg_catalog.pg_default_acl d
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = d.defaclnamespace
ORDER BY 1, 2, 3;
Important:
ALTER DEFAULT PRIVILEGES FOR ROLE "X"only applies when userXcreates the object. If another user creates tables, the rule does not trigger.
| Scope | SQL |
|-------|-----|
| Single table | REVOKE SELECT ON TABLE schema.table FROM "user_id"; |
| All tables in Schema | REVOKE ALL ON ALL TABLES IN SCHEMA public FROM "user_id"; |
| Schema access | REVOKE USAGE ON SCHEMA schema_name FROM "user_id"; |
| Column privilege | REVOKE SELECT (col1) ON TABLE schema.table FROM "user_id"; |
-- List all roles with key attributes
SELECT rolname, rolsuper, rolcanlogin FROM pg_roles;
-- Check if a user has SELECT on a specific table
SELECT has_table_privilege('user_id', 'schema.table', 'SELECT');
-- List all table grants for a specific role
SELECT table_schema, table_name, privilege_type
FROM information_schema.role_table_grants
WHERE grantee = 'user_id';
-- Find all users with any privilege on a specific table
SELECT rolname FROM pg_roles
WHERE has_table_privilege(rolname, 'schema.table', 'SELECT');
For more diagnostic queries, see diagnostic-queries.md.
| Error | Cause | Solution |
|-------|-------|----------|
| permission denied for table xxx | Missing table privilege | GRANT SELECT ON TABLE xxx TO "user"; |
| must be the owner of table xxx | Non-owner attempting DDL | ALTER TABLE xxx OWNER TO "user"; |
| permission denied for Schema xxx | Missing Schema USAGE | GRANT USAGE ON SCHEMA xxx TO "user"; |
| Document | Content | |----------|---------| | grant-revoke-reference.md | Complete GRANT/REVOKE syntax reference | | diagnostic-queries.md | Permission diagnostic SQL collection | | best-practices.md | Role group planning best practices |
project_dev, project_write, project_view rolesGRANT ON ALL TABLES for existing tablesREASSIGN OWNED BYhg_experimental_enable_catalog_rls)development
Hologres Knowledge Base Management: Build search & RAG knowledge bases on Hologres using full-text inverted index (Tantivy + BM25), HGraph vector index, and holo-search-sdk. Covers create knowledge base → ingest documents (with embeddings) → vector / full-text / hybrid search → Q&A with LLM. Triggers: "知识库", "knowledge base", "RAG", "向量检索", "vector search", "全文检索", "fulltext search", "倒排索引", "BM25", "HGraph", "holo-search-sdk", "embedding", "混合检索", "hybrid search", "Hologres 搜索", "Hologres search", "tantivy", "jieba", "ik 分词", "向量索引"
tools
Hologres 实例内存使用率异常诊断技能。当用户提到内存打满、OOM、内存持续高位、Worker 内存不均、内存泄漏、内存倾斜、内存归因分析等场景时使用。 以 instance_id + 时间窗口为输入,自动完成内存水位形态判定(全局高 / 局部倾斜 / 持续不回落)、业务指标对齐、内存分类初筛(Query vs System/Cache)、 并沿 Query 主线、倾斜主线、Write/后台主线、System/元数据主线四大归因维度自动下钻,输出结构化的 Markdown 诊断报告与治理行动清单。 云监控数据通过 `hologres metric query` / `hologres metric latest` 获取;元仓与 PG 系统表数据通过 `hologres sql run` 获取; 内部工具数据(OOM/Jeprof/Coredump)通过 `holo oncall common` 获取,全程享有 hologres-cli 的安全护栏、JSON 结构化输出与自动错误重试能力。
tools
Hologres 实例 CPU 使用率异常诊断技能。当用户提到 CPU 打满、CPU 持续高位、Worker CPU 不均、负载诊断、CPU 归因分析、后台 Compaction 干扰等场景时使用。 以 instance_id + 时间窗口为输入,自动完成 CPU 状态分级(持续打满 / 持续高位 / 安全平稳)、四象限归因诊断(宏观定性 / 分布定位 / 查询归因 / 后台任务干扰),并输出结构化的 Markdown 诊断报告与治理行动清单。 云监控数据通过 `hologres metric query` / `hologres metric latest` 获取;元仓与 PG 系统表数据通过 `hologres sql run` 获取,全程享有 hologres-cli 的安全护栏、JSON 结构化输出与自动错误重试能力。
data-ai
Hologres 运维诊断日报生成技能。生成一份包含"诊断结论 + 根因解释 + 行动建议"的每日巡检报告, 覆盖实例健康、可用性、计算资源、SQL性能、成本治理、容量预测六大维度。 触发词:日报、每日巡检、daily report、运维日报、诊断日报、实例巡检报告、每日健康报告。