Re: [SQL] simple "select / if found" isn't - Mailing list pgsql-sql

From Karsten Hilbert
Subject Re: [SQL] simple "select / if found" isn't
Date
Msg-id 20161216111212.edknff56d52bgrjl@hermes.hilbert.loc
Whole thread Raw
In response to [SQL] simple "select / if found" isn't  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Responses Re: [SQL] simple "select / if found" isn't
List pgsql-sql
On Fri, Dec 16, 2016 at 11:02:37AM +0000, Gary Stainburn wrote:

> All I want to do is return 'found' based on the select but I can't get it to 
> work.  
> 
> If I run 
> 
> select 1 from user_previous_passwords 
>     where u_id=25 and 
>     crypt('MyPaSSword',u_previous_password) = u_previous_password;
> 
> then it returns the matching row(s)
> 
> If I run my function
> 
> create or replace function check_previous_passwords (ID int4, PASS varchar) 
> returns boolean as $$

It just _might_ have to do with permissions to
user_previous_passwords.

If the function somehow got installed as "security definer"
and definer does not have RLS-based (!) permissions on
user_previous_passwords then it won't find rows.

A shot in the dark...

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



pgsql-sql by date:

Previous
From: Gary Stainburn
Date:
Subject: [SQL] simple "select / if found" isn't
Next
From: Gary Stainburn
Date:
Subject: Re: [SQL] simple "select / if found" isn't