Re: And I thought I had this solved. - Mailing list pgsql-general

From Adrian Klaver
Subject Re: And I thought I had this solved.
Date
Msg-id 3763f66e-c200-2f7b-31fe-8709c07f314a@aklaver.com
Whole thread Raw
In response to And I thought I had this solved.  (stan <stanb@panix.com>)
List pgsql-general
On 11/22/19 3:52 PM, stan wrote:
> A while back I ran into problems caused by  security fix related to the
> search path. I wound up adding a line to. for instance, this function:
> 
> REATE FUNCTION
> work_hours
> (
>      start_date date,
>     end_date date
> )
> RETURNS decimal(10,4) stable
> language sql as $$
> 
>     /* workaround for secuirty "feature" */
>     SET search_path TO ica, "user" , public;
> 
>     SELECT
>     sum(case when
>     extract(isodow from d)
>     between 1 and 5 then
>     8.0 else
>     +0.0 end)
>     from
> 
>     generate_series($1,
>     $2, interval
>     '24 hours') d;
> 
> $$;
> 
> And walked away happy, or so I thought. Now I just got this error:
> 
> [local] stan@stan=# select * from ttl_avail_hours_by_project_and_employee ;
> ERROR:  SET is not allowed in a non-volatile function
> CONTEXT:  SQL function "work_hours" during startup
> 
> How can I solve this issue?

If the above is the entire function I am not seeing that you need to SET 
search_path as there is no object that needs schema qualification. I 
would comment it out and run it.

If that fails then set the function volatile.



-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: stan
Date:
Subject: And I thought I had this solved.
Next
From: Adrian Klaver
Date:
Subject: Re: And I thought I had this solved.