Re: simple "select / if found" isn't

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: simple "select / if found" isn't
Date: 2016-12-16 11:12:13
Message-ID: 20161216111212.edknff56d52bgrjl@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gary Stainburn 2016-12-16 11:24:41 Re: simple "select / if found" isn't
Previous Message Gary Stainburn 2016-12-16 11:02:37 simple "select / if found" isn't