@@ -612,7 +612,8 @@ struct fmgr_security_definer_cache
612
612
{
613
613
FmgrInfo flinfo ; /* lookup info for target function */
614
614
Oid userid ; /* userid to set, or InvalidOid */
615
- ArrayType * proconfig ; /* GUC values to set, or NULL */
615
+ List * configNames ; /* GUC names to set, or NIL */
616
+ List * configValues ; /* GUC values to set, or NIL */
616
617
Datum arg ; /* passthrough argument for plugin modules */
617
618
};
618
619
@@ -634,6 +635,8 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
634
635
FmgrInfo * save_flinfo ;
635
636
Oid save_userid ;
636
637
int save_sec_context ;
638
+ ListCell * lc1 ;
639
+ ListCell * lc2 ;
637
640
volatile int save_nestlevel ;
638
641
PgStat_FunctionCallUsage fcusage ;
639
642
@@ -666,8 +669,11 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
666
669
& isnull );
667
670
if (!isnull )
668
671
{
672
+ ArrayType * array ;
669
673
oldcxt = MemoryContextSwitchTo (fcinfo -> flinfo -> fn_mcxt );
670
- fcache -> proconfig = DatumGetArrayTypePCopy (datum );
674
+ array = DatumGetArrayTypeP (datum );
675
+ TransformGUCArray (array , & fcache -> configNames ,
676
+ & fcache -> configValues );
671
677
MemoryContextSwitchTo (oldcxt );
672
678
}
673
679
@@ -680,7 +686,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
680
686
681
687
/* GetUserIdAndSecContext is cheap enough that no harm in a wasted call */
682
688
GetUserIdAndSecContext (& save_userid , & save_sec_context );
683
- if (fcache -> proconfig ) /* Need a new GUC nesting level */
689
+ if (fcache -> configNames != NIL ) /* Need a new GUC nesting level */
684
690
save_nestlevel = NewGUCNestLevel ();
685
691
else
686
692
save_nestlevel = 0 ; /* keep compiler quiet */
@@ -689,12 +695,17 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
689
695
SetUserIdAndSecContext (fcache -> userid ,
690
696
save_sec_context | SECURITY_LOCAL_USERID_CHANGE );
691
697
692
- if ( fcache -> proconfig )
698
+ forboth ( lc1 , fcache -> configNames , lc2 , fcache -> configValues )
693
699
{
694
- ProcessGUCArray (fcache -> proconfig ,
695
- (superuser () ? PGC_SUSET : PGC_USERSET ),
696
- PGC_S_SESSION ,
697
- GUC_ACTION_SAVE );
700
+ GucContext context = superuser () ? PGC_SUSET : PGC_USERSET ;
701
+ GucSource source = PGC_S_SESSION ;
702
+ GucAction action = GUC_ACTION_SAVE ;
703
+ char * name = lfirst (lc1 );
704
+ char * value = lfirst (lc2 );
705
+
706
+ (void ) set_config_option (name , value ,
707
+ context , source ,
708
+ action , true, 0 , false);
698
709
}
699
710
700
711
/* function manager hook */
@@ -737,7 +748,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
737
748
738
749
fcinfo -> flinfo = save_flinfo ;
739
750
740
- if (fcache -> proconfig )
751
+ if (fcache -> configNames != NIL )
741
752
AtEOXact_GUC (true, save_nestlevel );
742
753
if (OidIsValid (fcache -> userid ))
743
754
SetUserIdAndSecContext (save_userid , save_sec_context );
0 commit comments