Index: pgadmin/frm/frmQuery.cpp =================================================================== --- pgadmin/frm/frmQuery.cpp (revision 7942) +++ pgadmin/frm/frmQuery.cpp (working copy) @@ -75,6 +75,9 @@ #define CTRLID_CONNECTION 4200 #define CTRLID_DATABASELABEL 4201 +// Initialize execution mutex +wxMutex frmQuery::ms_exeMutex; + BEGIN_EVENT_TABLE(frmQuery, pgFrame) EVT_ERASE_BACKGROUND( frmQuery::OnEraseBackground) EVT_SIZE( frmQuery::OnSize) @@ -1863,6 +1866,12 @@ if (query.IsNull()) return; + if (frmQuery::ms_exeMutex.TryLock() == wxMUTEX_BUSY) + { + wxMessageBox(_("pgScript already running."), _("Concurrent execution of pgScripts is not supported at this time."), wxICON_WARNING); + return; + } + // Clear markers and indicators sqlQuery->MarkerDeleteAll(0); sqlQuery->StartStyling(0, wxSTC_INDICS_MASK); @@ -2235,6 +2244,9 @@ // Reset tools setTools(false); + // Unlock mutex + frmQuery::ms_exeMutex.Unlock(); + // Manage timer elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery; SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS); Index: pgadmin/include/frm/frmQuery.h =================================================================== --- pgadmin/include/frm/frmQuery.h (revision 7942) +++ pgadmin/include/frm/frmQuery.h (working copy) @@ -197,6 +197,8 @@ bool aborted; bool lastFileFormat; + static wxMutex ms_exeMutex; + DECLARE_EVENT_TABLE() };