Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iYIwR-0007Tk-U4 for pgsql-general@arkaria.postgresql.org; Sat, 23 Nov 2019 00:06:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iYIwQ-00043f-BH for pgsql-general@arkaria.postgresql.org; Sat, 23 Nov 2019 00:06:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iYIwP-00041H-TQ for pgsql-general@lists.postgresql.org; Sat, 23 Nov 2019 00:06:22 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iYIwL-00038v-SC for pgsql-general@lists.postgresql.org; Sat, 23 Nov 2019 00:06:20 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id EC331EC2; Fri, 22 Nov 2019 19:06:15 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 22 Nov 2019 19:06:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=7 OVUdcDE6OdBCyGR2nXSRgSRluutHvqgBq/BOICp/5A=; b=cKgAttEgFikxdr/9M nY1HaTrU62tRvJ7mtgIsY6UgzdcVV/DpJdk/ekfwC5QcDlZR9FpIldII1pK8hTwk rpaQBHUEcyC2CCQHmOoEx8DfyJhL2rSwT4XQ0a+oO6r82spNlYl9yat7cVhgyzfQ woHvBy4RF8QAkZ4Em68QOwLWhlwql3afwFSRVoZG9JrBBJuKclMAAydugP9Uvmou dbWHXXgjpq5aaT25lWeDbx58K+VrCR82BjCArXu6MJloXOt5oP/wuaj4oi5R2lGc d648+i43+ReWbZlRwg+C6IMtLz92uNXDBhF3ik2cBjJtYgV9l/0v0Ihn7f7UVFE2 vcWGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=7OVUdcDE6OdBCyGR2nXSRgSRluutHvqgBq/BOICp/ 5A=; b=R6LMy8pGKwh/rmyQn5miwCsPI0+HV4oZ99dWnnnfglxrgWPPVePYTbnUd 410BnKbHkzwS/0vbuM6YnuG+omMEfwj5ErojRElfsksSdKIkLE/UGX/3reMn06p3 PaaJJjXN1YC41vfsnI4PjGoVp5WwL8m9ANIWu1Gc7ml9SpzPQw3k8B3jGcL2RHJo V/Ut5kt0ypa/ZP3uRwE+aEswrTGBNCGI3NcRqNhuI9e29/2n5Zgn0Jf6TPQADX0L saxxsi1cbDtOvnX9bvW7SvHuR+G0vhPQG102zBqLEu7LDzBT/xabLLg1oghFoUuZ yplIuPQ/IqfyaCkz0S3TeVA79LJQw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudehhedgudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtje ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuffhomhgrihhnpehpohhsthhgrhgvsh hqlhdrohhrghenucfkphepjedurddvuddvrddufeefrdduudeknecurfgrrhgrmhepmhgr ihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuve hluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.2] (unknown [71.212.133.118]) by mail.messagingengine.com (Postfix) with ESMTPA id E3CC78005C; Fri, 22 Nov 2019 19:06:14 -0500 (EST) Subject: Re: And I thought I had this solved. To: stan , pgsql-general@lists.postgresql.org References: <20191122235216.GA7008@panix.com> From: Adrian Klaver Message-ID: <458e074e-386b-c2ef-a9a7-9b1d25088872@aklaver.com> Date: Fri, 22 Nov 2019 16:06:14 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20191122235216.GA7008@panix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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? I thought I was missing something. Third option. As example: https://www.postgresql.org/docs/11/sql-createfunction.html Writing SECURITY DEFINER Functions Safely ... $$ LANGUAGE plpgsql SECURITY DEFINER -- Set a secure search_path: trusted schema(s), then 'pg_temp'. SET search_path = admin, pg_temp; Put the SET outside the function body. -- Adrian Klaver adrian.klaver@aklaver.com