Clear debug_query_string in proc_exit to avoid crash
Backport following commit from PostgreSQL:
commit
Author: Tom Lane
Date:   Sat Mar 20 00:58:21 2010 +0000
Report from Xiaowen Zheng
#include <sys/stat.h>
#include "cdb/cdbdisp.h"
+#include "libpq/pqsignal.h"
#include "miscadmin.h"
#ifdef PROFILE_PID_DIR
#include "postmaster/autovacuum.h"
#endif
#include "storage/ipc.h"
-#include "libpq/pqsignal.h"
+#include "tcop/tcopprot.h"
/*
* This flag is set during proc_exit() to change ereport()'s behavior,
@@ -183,6 +184,9 @@ proc_exit_prepare(int code)
*/
error_context_stack = NULL;
+ /* For the same reason, reset debug_query_string before it's clobbered */
+ debug_query_string = NULL;
+
/*
* Make sure interconnect thread quit before shmem_exit() in FATAL case.
* Otherwise, shmem_exit() may free MemoryContex of MotionConns in connHtab unexpectedly;
