@@ -236,6 +236,7 @@ bool MtmDoReplication;
236236char * MtmDatabaseName ;
237237char * MtmDatabaseUser ;
238238Oid MtmDatabaseId ;
239+ bool MtmBackgroundWorker ;
239240
240241int MtmNodes ;
241242int MtmNodeId ;
@@ -898,7 +899,7 @@ MtmIsUserTransaction()
898899 IsNormalProcessingMode () &&
899900 MtmDoReplication &&
900901 !am_walsender &&
901- !IsBackgroundWorker &&
902+ !MtmBackgroundWorker &&
902903 !IsAutoVacuumWorkerProcess ();
903904}
904905
@@ -4538,7 +4539,7 @@ static void MtmGucInit(void)
45384539 */
45394540 oldcontext = MemoryContextSwitchTo (TopMemoryContext );
45404541 current_role = GetConfigOptionByName ("session_authorization" , NULL , false);
4541- if (strcmp (MtmDatabaseUser , current_role ) != 0 )
4542+ if (current_role && * current_role && strcmp (MtmDatabaseUser , current_role ) != 0 )
45424543 MtmGucUpdate ("session_authorization" , current_role );
45434544 MemoryContextSwitchTo (oldcontext );
45444545}
@@ -4632,13 +4633,20 @@ char* MtmGucSerialize(void)
46324633{
46334634 StringInfo serialized_gucs ;
46344635 dlist_iter iter ;
4635- int nvars = 0 ;
4636+ const char * search_path ;
46364637
46374638 if (!MtmGucHash )
46384639 MtmGucInit ();
46394640
46404641 serialized_gucs = makeStringInfo ();
46414642
4643+ /*
4644+ * Crutch for scheduler. It sets search_path through SetConfigOption()
4645+ * so our callback do not react on that.
4646+ */
4647+ search_path = GetConfigOption ("search_path" , false, true);
4648+ appendStringInfo (serialized_gucs , "SET search_path TO %s; " , search_path );
4649+
46424650 dlist_foreach (iter , & MtmGucList )
46434651 {
46444652 MtmGucEntry * cur_entry = dlist_container (MtmGucEntry , list_node , iter .cur );
@@ -4659,7 +4667,6 @@ char* MtmGucSerialize(void)
46594667 appendStringInfoString (serialized_gucs , cur_entry -> value );
46604668 }
46614669 appendStringInfoString (serialized_gucs , "; " );
4662- nvars ++ ;
46634670 }
46644671
46654672 return serialized_gucs -> data ;
@@ -4680,7 +4687,7 @@ static void MtmProcessDDLCommand(char const* queryString, bool transactional)
46804687 {
46814688 char * gucCtx = MtmGucSerialize ();
46824689 if (* gucCtx )
4683- queryString = psprintf ("RESET SESSION AUTHORIZATION; reset all; %s; %s" , gucCtx , queryString );
4690+ queryString = psprintf ("RESET SESSION AUTHORIZATION; reset all; %s %s" , gucCtx , queryString );
46844691 else
46854692 queryString = psprintf ("RESET SESSION AUTHORIZATION; reset all; %s" , queryString );
46864693
@@ -4991,7 +4998,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
49914998 if (!skipCommand && !MtmTx .isReplicated && (context == PROCESS_UTILITY_TOPLEVEL || MtmUtilityProcessedInXid != GetCurrentTransactionId ()))
49924999 {
49935000 MtmUtilityProcessedInXid = GetCurrentTransactionId ();
4994- if (context == PROCESS_UTILITY_TOPLEVEL ) {
5001+ if (context == PROCESS_UTILITY_TOPLEVEL || ! ActivePortal ) {
49955002 MtmProcessDDLCommand (queryString , true);
49965003 } else {
49975004 MtmProcessDDLCommand (ActivePortal -> sourceText , true);
0 commit comments