diff --git a/src/gausskernel/storage/replication/walsender.cpp b/src/gausskernel/storage/replication/walsender.cpp index dc7aa3fb4..e183a0e0b 100644 --- a/src/gausskernel/storage/replication/walsender.cpp +++ b/src/gausskernel/storage/replication/walsender.cpp @@ -1977,6 +1977,7 @@ static void HandleWalReplicationCommand(const char *cmd_string, ReplicationCxt* cmd_context = AllocSetContextCreate(CurrentMemoryContext, "Replication command context", ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE); + old_context = MemoryContextSwitchTo(cmd_context); yyscanner = replication_scanner_init(cmd_string); parse_rc = replication_yyparse(yyscanner); @@ -1987,8 +1988,6 @@ static void HandleWalReplicationCommand(const char *cmd_string, ReplicationCxt* (errcode(ERRCODE_SYNTAX_ERROR), (errmsg_internal("replication command parser returned %d", parse_rc)))); } - old_context = MemoryContextSwitchTo(cmd_context); - cmd_node = t_thrd.replgram_cxt.replication_parse_result; IdentifyCommand(cmd_node, repCxt, cmd_string);