Get role DDL
get_role_ddlGenerate the CREATE ROLE DDL for a specified role using pg_get_roledef, without shelling out to pg_dumpall. Returns whether the role exists and its verbatim DDL statement.
Instructions
Return the CREATE ROLE DDL for a named role using PG 19's pg_get_roledef(oid) function — no shell-out to pg_dumpall --roles-only required. Returns found=false with an empty ddl when the role doesn't exist. Requires PG 19+; raises on older servers (pair with get_pg19_ddl_status to feature-detect). Returns an object with object_type ('role'), object_name, found (bool), and ddl (the verbatim CREATE statement).
Example: get_role_ddl(role_name='app_user')
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. | |
| role_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ddl | Yes | ||
| found | Yes | ||
| object_name | Yes | ||
| object_type | Yes |