pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15993: "CREATE OR REPLACE FUNCTION" does not clear search_path
3+ messages / 3 participants
[nested] [flat]

* BUG #15993: "CREATE OR REPLACE FUNCTION" does not clear search_path
@ 2019-09-06 20:42  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Bug reporting form @ 2019-09-06 20:42 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: alexander.pavlov.rus@gmail.com

The following bug has been logged on the website:

Bug reference:      15993
Logged by:          Alexander Pavlov
Email address:      alexander.pavlov.rus@gmail.com
PostgreSQL version: 10.9
Operating system:   Debian
Description:        

-- this will correctly create function with empty search_path
CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN
TRUE;END;$$ LANGUAGE PLPGSQL;

-- this will correctly update function to have "PUBLIC, MY_SCHEMA" search
path
CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN
TRUE;END;$$ LANGUAGE PLPGSQL SET SEARCH_PATH TO PUBLIC, MY_SCHEMA;

-- this will correctly update function to have "MY_SCHEMA" search path
CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN
TRUE;END;$$ LANGUAGE PLPGSQL SET SEARCH_PATH TO MY_SCHEMA;

-- this will NOT update function to have empty search path, search path will
remain "MY_SCHEMA", as at previous "create or replace" call
CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN
TRUE;END;$$ LANGUAGE PLPGSQL;



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #15993: "CREATE OR REPLACE FUNCTION" does not clear search_path
@ 2019-09-27 17:32  Bruce Momjian <bruce@momjian.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Bruce Momjian @ 2019-09-27 17:32 UTC (permalink / raw)
  To: alexander.pavlov.rus@gmail.com; pgsql-bugs@lists.postgresql.org

On Fri, Sep  6, 2019 at 08:42:02PM +0000, PG Bug reporting form wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      15993
> Logged by:          Alexander Pavlov
> Email address:      alexander.pavlov.rus@gmail.com
> PostgreSQL version: 10.9
> Operating system:   Debian
> Description:        
> 
> -- this will correctly create function with empty search_path
> CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN
> TRUE;END;$$ LANGUAGE PLPGSQL;
> 
> -- this will correctly update function to have "PUBLIC, MY_SCHEMA" search
> path
> CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN
> TRUE;END;$$ LANGUAGE PLPGSQL SET SEARCH_PATH TO PUBLIC, MY_SCHEMA;
> 
> -- this will correctly update function to have "MY_SCHEMA" search path
> CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN
> TRUE;END;$$ LANGUAGE PLPGSQL SET SEARCH_PATH TO MY_SCHEMA;
> 
> -- this will NOT update function to have empty search path, search path will
> remain "MY_SCHEMA", as at previous "create or replace" call
> CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN
> TRUE;END;$$ LANGUAGE PLPGSQL;

So you are saying that CREATE OR REPLACE FUNCTION should not preserve
the SEARCH_PATH.  Makes sense to me.  Any idea why we coded it this way?
It it part of the "OR REPLACE" goal?

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #15993: "CREATE OR REPLACE FUNCTION" does not clear search_path
@ 2019-09-27 17:56  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2019-09-27 17:56 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: alexander.pavlov.rus@gmail.com; pgsql-bugs@lists.postgresql.org

Bruce Momjian <bruce@momjian.us> writes:
> So you are saying that CREATE OR REPLACE FUNCTION should not preserve
> the SEARCH_PATH.  Makes sense to me.  Any idea why we coded it this way?

We didn't.  For me, it works as expected:

... follow example, \sf after each step
regression=# \sf my_func
CREATE OR REPLACE FUNCTION public.my_func()
 RETURNS boolean
 LANGUAGE plpgsql
 SET search_path TO 'my_schema'
AS $function$ BEGIN RETURN
TRUE;END;$function$
regression=# CREATE OR REPLACE FUNCTION MY_FUNC () RETURNS BOOLEAN AS $$ BEGIN RETURN
regression$# TRUE;END;$$ LANGUAGE PLPGSQL;
CREATE FUNCTION
regression=# \sf my_func
CREATE OR REPLACE FUNCTION public.my_func()
 RETURNS boolean
 LANGUAGE plpgsql
AS $function$ BEGIN RETURN
TRUE;END;$function$

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2019-09-27 17:56 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06 20:42 BUG #15993: "CREATE OR REPLACE FUNCTION" does not clear search_path PG Bug reporting form <noreply@postgresql.org>
2019-09-27 17:32 ` Bruce Momjian <bruce@momjian.us>
2019-09-27 17:56   ` Tom Lane <tgl@sss.pgh.pa.us>

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