pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: stan <stanb@panix.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: And I thought I had this solved.
Date: Fri, 22 Nov 2019 15:58:59 -0800
Message-ID: <3763f66e-c200-2f7b-31fe-8709c07f314a@aklaver.com> (raw)
In-Reply-To: <20191122235216.GA7008@panix.com>
References: <20191122235216.GA7008@panix.com>

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





view thread (4+ messages)  latest in thread

Message-ID: <3763f66e-c200-2f7b-31fe-8709c07f314a@aklaver.com>
Permalink:  ../3763f66e-c200-2f7b-31fe-8709c07f314a@aklaver.com/
Also on:    postgresql.org/message-id/3763f66e-c200-2f7b-31fe-8709c07f314a@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, stanb@panix.com
  Subject: Re: And I thought I had this solved.
  In-Reply-To: <3763f66e-c200-2f7b-31fe-8709c07f314a@aklaver.com>
  References: <20191122235216.GA7008@panix.com> <3763f66e-c200-2f7b-31fe-8709c07f314a@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox