Column Privileges: NULL instead of permission denied

From: Matthew Hawn <matthewh(at)donaanacounty(dot)org>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Column Privileges: NULL instead of permission denied
Date: 2011-09-19 20:39:53
Message-ID: DF0C87D105B235419E2D9E5066CCCF510B72B0@gcmxbe02.dac.int
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table with privileged data that is restricted using column level
permissions. I would like to have single query that returns data from the
table. If the user has permission, it should return the data but return
NULL if the user does not have permission. I do not want to create
separate queries in my application for different users.

Ex:

Table people: Name, SSN

If I try:

Select name, ssn from people;

I get if the user does not have permission:

**ERROR: permission denied for relation people **

I would like to get:

No Permission:

Dave, NULL

Bill, NULL

Steve, NULL

Permission:

Dave, 456

Bill, 789

Steve, 123

I have tried:

Select name, case when has_column_permission('people','ssn','select') then
ssn else NULL end as ssn;

But I still get a permission denied.

Any Ideas?

Matthew Hawn

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2011-09-19 21:13:38 Re: Column Privileges: NULL instead of permission denied
Previous Message Venkat Balaji 2011-09-19 16:37:04 Calculate Vacuum Metrics