Re: [HACKERS] pl/pgsql exported functions

2016-03-03 Thread Magnus Hagander
On Wed, Mar 2, 2016 at 5:07 PM, Marko Tiikkaja  wrote:

> On 11/02/16 18:29, Magnus Hagander wrote:
>
>> Most of the pl/pgsql functions and variables are prefixed plpgsql_, so
>> they
>> don't risk conflicting with other shared libraries loaded.
>>
>> There are a couple that are not prefixed. Attached patch fixes that. It's
>> mostly a cleanup, but I think it's something we should do since it's only
>> 2
>> variables and 2 functions.
>>
>> AFAICT these are clearly meant to be internal. (the plugin variable is
>> accessed through find_rendezvous_variable)
>>
>> Comments?
>>
>
> Looks good to me.
>
>
Thanks, pushed.


-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


Re: [HACKERS] pl/pgsql exported functions

2016-03-02 Thread Marko Tiikkaja

On 11/02/16 18:29, Magnus Hagander wrote:

Most of the pl/pgsql functions and variables are prefixed plpgsql_, so they
don't risk conflicting with other shared libraries loaded.

There are a couple that are not prefixed. Attached patch fixes that. It's
mostly a cleanup, but I think it's something we should do since it's only 2
variables and 2 functions.

AFAICT these are clearly meant to be internal. (the plugin variable is
accessed through find_rendezvous_variable)

Comments?


Looks good to me.


.m


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pl/pgsql exported functions

2016-02-11 Thread Pavel Stehule
2016-02-11 18:29 GMT+01:00 Magnus Hagander :

> Most of the pl/pgsql functions and variables are prefixed plpgsql_, so
> they don't risk conflicting with other shared libraries loaded.
>
> There are a couple that are not prefixed. Attached patch fixes that. It's
> mostly a cleanup, but I think it's something we should do since it's only 2
> variables and 2 functions.
>
> AFAICT these are clearly meant to be internal. (the plugin variable is
> accessed through find_rendezvous_variable)
>

+1

Pavel


>
> Comments?
>
> --
>  Magnus Hagander
>  Me: http://www.hagander.net/
>  Work: http://www.redpill-linpro.com/
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
>


[HACKERS] pl/pgsql exported functions

2016-02-11 Thread Magnus Hagander
Most of the pl/pgsql functions and variables are prefixed plpgsql_, so they
don't risk conflicting with other shared libraries loaded.

There are a couple that are not prefixed. Attached patch fixes that. It's
mostly a cleanup, but I think it's something we should do since it's only 2
variables and 2 functions.

AFAICT these are clearly meant to be internal. (the plugin variable is
accessed through find_rendezvous_variable)

Comments?

-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/
*** a/src/pl/plpgsql/src/pl_comp.c
--- b/src/pl/plpgsql/src/pl_comp.c
***
*** 51,57  bool		plpgsql_check_syntax = false;
  PLpgSQL_function *plpgsql_curr_compile;
  
  /* A context appropriate for short-term allocs during compilation */
! MemoryContext compile_tmp_cxt;
  
  /* --
   * Hash table for compiled functions
--- 51,57 
  PLpgSQL_function *plpgsql_curr_compile;
  
  /* A context appropriate for short-term allocs during compilation */
! MemoryContext plpgsql_compile_tmp_cxt;
  
  /* --
   * Hash table for compiled functions
***
*** 253,259  recheck:
   * careful about pfree'ing their allocations, it is also wise to
   * switch into a short-term context before calling into the
   * backend. An appropriate context for performing short-term
!  * allocations is the compile_tmp_cxt.
   *
   * NB: this code is not re-entrant.  We assume that nothing we do here could
   * result in the invocation of another plpgsql function.
--- 253,259 
   * careful about pfree'ing their allocations, it is also wise to
   * switch into a short-term context before calling into the
   * backend. An appropriate context for performing short-term
!  * allocations is the plpgsql_compile_tmp_cxt.
   *
   * NB: this code is not re-entrant.  We assume that nothing we do here could
   * result in the invocation of another plpgsql function.
***
*** 343,349  do_compile(FunctionCallInfo fcinfo,
  	 ALLOCSET_DEFAULT_MINSIZE,
  	 ALLOCSET_DEFAULT_INITSIZE,
  	 ALLOCSET_DEFAULT_MAXSIZE);
! 	compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
  
  	function->fn_signature = format_procedure(fcinfo->flinfo->fn_oid);
  	function->fn_oid = fcinfo->flinfo->fn_oid;
--- 343,349 
  	 ALLOCSET_DEFAULT_MINSIZE,
  	 ALLOCSET_DEFAULT_INITSIZE,
  	 ALLOCSET_DEFAULT_MAXSIZE);
! 	plpgsql_compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
  
  	function->fn_signature = format_procedure(fcinfo->flinfo->fn_oid);
  	function->fn_oid = fcinfo->flinfo->fn_oid;
***
*** 387,393  do_compile(FunctionCallInfo fcinfo,
  			 * argument types.  In validation mode we won't be able to, so we
  			 * arbitrarily assume we are dealing with integers.
  			 */
! 			MemoryContextSwitchTo(compile_tmp_cxt);
  
  			numargs = get_func_arg_info(procTup,
  		&argtypes, &argnames, &argmodes);
--- 387,393 
  			 * argument types.  In validation mode we won't be able to, so we
  			 * arbitrarily assume we are dealing with integers.
  			 */
! 			MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
  
  			numargs = get_func_arg_info(procTup,
  		&argtypes, &argnames, &argmodes);
***
*** 774,781  do_compile(FunctionCallInfo fcinfo,
  
  	plpgsql_check_syntax = false;
  
! 	MemoryContextSwitchTo(compile_tmp_cxt);
! 	compile_tmp_cxt = NULL;
  	return function;
  }
  
--- 774,781 
  
  	plpgsql_check_syntax = false;
  
! 	MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
! 	plpgsql_compile_tmp_cxt = NULL;
  	return function;
  }
  
***
*** 833,839  plpgsql_compile_inline(char *proc_source)
  	 ALLOCSET_DEFAULT_MINSIZE,
  	 ALLOCSET_DEFAULT_INITSIZE,
  	 ALLOCSET_DEFAULT_MAXSIZE);
! 	compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
  
  	function->fn_signature = pstrdup(func_name);
  	function->fn_is_trigger = PLPGSQL_NOT_TRIGGER;
--- 833,839 
  	 ALLOCSET_DEFAULT_MINSIZE,
  	 ALLOCSET_DEFAULT_INITSIZE,
  	 ALLOCSET_DEFAULT_MAXSIZE);
! 	plpgsql_compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
  
  	function->fn_signature = pstrdup(func_name);
  	function->fn_is_trigger = PLPGSQL_NOT_TRIGGER;
***
*** 911,918  plpgsql_compile_inline(char *proc_source)
  
  	plpgsql_check_syntax = false;
  
! 	MemoryContextSwitchTo(compile_tmp_cxt);
! 	compile_tmp_cxt = NULL;
  	return function;
  }
  
--- 911,918 
  
  	plpgsql_check_syntax = false;
  
! 	MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
! 	plpgsql_compile_tmp_cxt = NULL;
  	return function;
  }
  
***
*** 1325,1331  make_datum_param(PLpgSQL_expr *expr, int dno, int location)
  	param = makeNode(Param);
  	param->paramkind = PARAM_EXTERN;
  	param->paramid = dno + 1;
! 	exec_get_datum_type_info(estate,
  			 datum,
  			 ¶m->paramtype,
  			 ¶m->paramtypmod,
--- 1325,1331 
  	param = makeNode(Param);
  	param->paramkind = PARAM_E