Column Privileges: NULL instead of permission denied - Mailing list pgsql-general

From Matthew Hawn
Subject Column Privileges: NULL instead of permission denied
Date
Msg-id DF0C87D105B235419E2D9E5066CCCF510B72B0@gcmxbe02.dac.int
Whole thread Raw
Responses Re: Column Privileges: NULL instead of permission denied  (Stephen Frost <sfrost@snowman.net>)
List 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

 

Attachment

pgsql-general by date:

Previous
From: Henry Drexler
Date:
Subject: Re: General guidance if there is an in dadabase solution or should stay as excel vba solution.
Next
From: Stephen Frost
Date:
Subject: Re: Column Privileges: NULL instead of permission denied