@@ -238,6 +238,7 @@ bool MtmDoReplication;
238238char * MtmDatabaseName ;
239239char * MtmDatabaseUser ;
240240Oid MtmDatabaseId ;
241+ bool MtmBackgroundWorker ;
241242
242243int MtmNodes ;
243244int MtmNodeId ;
@@ -902,7 +903,7 @@ MtmIsUserTransaction()
902903 IsNormalProcessingMode () &&
903904 MtmDoReplication &&
904905 !am_walsender &&
905- !IsBackgroundWorker &&
906+ !MtmBackgroundWorker &&
906907 !IsAutoVacuumWorkerProcess ();
907908}
908909
@@ -4924,7 +4925,7 @@ static void MtmGucInit(void)
49244925 */
49254926 oldcontext = MemoryContextSwitchTo (TopMemoryContext );
49264927 current_role = GetConfigOptionByName ("session_authorization" , NULL , false);
4927- if (strcmp (MtmDatabaseUser , current_role ) != 0 )
4928+ if (current_role && * current_role && strcmp (MtmDatabaseUser , current_role ) != 0 )
49284929 MtmGucUpdate ("session_authorization" , current_role );
49294930 MemoryContextSwitchTo (oldcontext );
49304931}
@@ -5018,13 +5019,20 @@ char* MtmGucSerialize(void)
50185019{
50195020 StringInfo serialized_gucs ;
50205021 dlist_iter iter ;
5021- int nvars = 0 ;
5022+ const char * search_path ;
50225023
50235024 if (!MtmGucHash )
50245025 MtmGucInit ();
50255026
50265027 serialized_gucs = makeStringInfo ();
50275028
5029+ /*
5030+ * Crutch for scheduler. It sets search_path through SetConfigOption()
5031+ * so our callback do not react on that.
5032+ */
5033+ search_path = GetConfigOption ("search_path" , false, true);
5034+ appendStringInfo (serialized_gucs , "SET search_path TO %s; " , search_path );
5035+
50285036 dlist_foreach (iter , & MtmGucList )
50295037 {
50305038 MtmGucEntry * cur_entry = dlist_container (MtmGucEntry , list_node , iter .cur );
@@ -5045,7 +5053,6 @@ char* MtmGucSerialize(void)
50455053 appendStringInfoString (serialized_gucs , cur_entry -> value );
50465054 }
50475055 appendStringInfoString (serialized_gucs , "; " );
5048- nvars ++ ;
50495056 }
50505057
50515058 return serialized_gucs -> data ;
@@ -5163,6 +5170,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
51635170 case T_CheckPointStmt :
51645171 case T_ReindexStmt :
51655172 case T_ExplainStmt :
5173+ case T_AlterSystemStmt :
51665174 skipCommand = true;
51675175 break ;
51685176
@@ -5374,7 +5382,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
53745382 if (!skipCommand && !MtmTx .isReplicated && (context == PROCESS_UTILITY_TOPLEVEL || MtmUtilityProcessedInXid != GetCurrentTransactionId ()))
53755383 {
53765384 MtmUtilityProcessedInXid = GetCurrentTransactionId ();
5377- if (context == PROCESS_UTILITY_TOPLEVEL ) {
5385+ if (context == PROCESS_UTILITY_TOPLEVEL || ! ActivePortal ) {
53785386 MtmProcessDDLCommand (queryString , true);
53795387 } else {
53805388 MtmProcessDDLCommand (ActivePortal -> sourceText , true);
0 commit comments