01007
PostgreSQLWARNINGCriticalWarningHIGH confidence

privilege not granted

What this means

SQLSTATE 01007 is raised when a GRANT statement attempts to grant a privilege that the target role already holds, or that cannot be granted due to existing state. The command succeeds without making any change.

Why it happens
  1. 1GRANT statement targeting a role that already has the specified privilege
How to reproduce

Granting a privilege that is already held.

trigger — this will error
trigger — this will error
GRANT SELECT ON employees TO analyst;
GRANT SELECT ON employees TO analyst; -- second GRANT raises 01007

expected output

WARNING:  privilege not granted

Fix

Check existing privileges before granting

WHEN When managing role permissions in scripts.

Check existing privileges before granting
SELECT grantee, privilege_type FROM information_schema.role_table_grants
WHERE table_name = 'employees' AND grantee = 'analyst';

Why this works

Query the privilege catalogue to confirm what is already granted before issuing GRANT.

Sources
Official documentation ↗

Class 01 — Warning

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All PostgreSQL errors