@@ -235,6 +235,7 @@ bool MtmDoReplication;
235235char * MtmDatabaseName ;
236236char * MtmDatabaseUser ;
237237Oid MtmDatabaseId ;
238+ bool MtmBackgroundWorker ;
238239
239240int MtmNodes ;
240241int MtmNodeId ;
@@ -898,7 +899,7 @@ MtmIsUserTransaction()
898899 IsNormalProcessingMode () &&
899900 MtmDoReplication &&
900901 !am_walsender &&
901- !IsBackgroundWorker &&
902+ !MtmBackgroundWorker &&
902903 !IsAutoVacuumWorkerProcess ();
903904}
904905
@@ -4865,7 +4866,7 @@ static void MtmGucInit(void)
48654866 */
48664867 oldcontext = MemoryContextSwitchTo (TopMemoryContext );
48674868 current_role = GetConfigOptionByName ("session_authorization" , NULL , false);
4868- if (strcmp (MtmDatabaseUser , current_role ) != 0 )
4869+ if (current_role && * current_role && strcmp (MtmDatabaseUser , current_role ) != 0 )
48694870 MtmGucUpdate ("session_authorization" , current_role );
48704871 MemoryContextSwitchTo (oldcontext );
48714872}
@@ -4959,13 +4960,20 @@ char* MtmGucSerialize(void)
49594960{
49604961 StringInfo serialized_gucs ;
49614962 dlist_iter iter ;
4962- int nvars = 0 ;
4963+ const char * search_path ;
49634964
49644965 if (!MtmGucHash )
49654966 MtmGucInit ();
49664967
49674968 serialized_gucs = makeStringInfo ();
49684969
4970+ /*
4971+ * Crutch for scheduler. It sets search_path through SetConfigOption()
4972+ * so our callback do not react on that.
4973+ */
4974+ search_path = GetConfigOption ("search_path" , false, true);
4975+ appendStringInfo (serialized_gucs , "SET search_path TO %s; " , search_path );
4976+
49694977 dlist_foreach (iter , & MtmGucList )
49704978 {
49714979 MtmGucEntry * cur_entry = dlist_container (MtmGucEntry , list_node , iter .cur );
@@ -4986,7 +4994,6 @@ char* MtmGucSerialize(void)
49864994 appendStringInfoString (serialized_gucs , cur_entry -> value );
49874995 }
49884996 appendStringInfoString (serialized_gucs , "; " );
4989- nvars ++ ;
49904997 }
49914998
49924999 return serialized_gucs -> data ;
@@ -5007,7 +5014,7 @@ static void MtmProcessDDLCommand(char const* queryString, bool transactional)
50075014 {
50085015 char * gucCtx = MtmGucSerialize ();
50095016 if (* gucCtx )
5010- queryString = psprintf ("RESET SESSION AUTHORIZATION; reset all; %s; %s" , gucCtx , queryString );
5017+ queryString = psprintf ("RESET SESSION AUTHORIZATION; reset all; %s %s" , gucCtx , queryString );
50115018 else
50125019 queryString = psprintf ("RESET SESSION AUTHORIZATION; reset all; %s" , queryString );
50135020
@@ -5318,7 +5325,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
53185325 if (!skipCommand && !MtmTx .isReplicated && (context == PROCESS_UTILITY_TOPLEVEL || MtmUtilityProcessedInXid != GetCurrentTransactionId ()))
53195326 {
53205327 MtmUtilityProcessedInXid = GetCurrentTransactionId ();
5321- if (context == PROCESS_UTILITY_TOPLEVEL ) {
5328+ if (context == PROCESS_UTILITY_TOPLEVEL || ! ActivePortal ) {
53225329 MtmProcessDDLCommand (queryString , true);
53235330 } else {
53245331 MtmProcessDDLCommand (ActivePortal -> sourceText , true);
0 commit comments