Le jeudi 3 septembre 2009 à 14:08:54, Guillaume Lelarge a écrit : > Le jeudi 3 septembre 2009 à 14:02:24, Dave Page a écrit : > > On Thu, Sep 3, 2009 at 12:57 PM, Magnus Hagander<mag...@hagander.net> wrote: > > > Good question. In general we shouldn't change the default behavior in > > > a backpatch, but I think the use-case for the current behavior is > > > pretty limited. > > > > It's not being back-patched. That code has been there for years, with > > only one complaint that I'm aware of. The complaint is a valid one > > though, which is why I think we should add the option for 1.12. > > I also think this is 1.12 only. > > > > AIUI, nothing at all changes for single-statement queries, right? It > > > would only affect those that explicitly open a transaction. In which > > > case I think it's a reasonable default to behave the same way as psql, > > > which means change the default for pgadmin. > > > > > > Specifically on the patch I don't like an option named "disabled auto > > > rollback". Negations in options suck. It shuold be "Enable auto > > > rollback", and then whatever the default is can be argued. I'd also > > > find it very useful if this was available as a checkbox on the query > > > menu, not just in the options dialog. Thoughts? > > > > Which would do what - override the default for that window only, or > > control the default as well? I prefer the former, but some of the > > other options are stored for all future query windows, so there may be > > some inconsistency there. > > I'll change it to "Enable auto rollback", and preserve the old default > value. Having it on a menu in the query tool would be really useful. I > don't have strong feelings on wether it should override the default. > Actually, I think it would be better to overrid it only for this window.
Done. Here is the new patch. The check menu item behaves the same way than the others, ie it completely controls the option value. I think it is more consistent this way. -- Guillaume. http://www.postgresqlfr.org http://dalibo.com
Index: pgadmin/include/frm/menu.h =================================================================== --- pgadmin/include/frm/menu.h (révision 8028) +++ pgadmin/include/frm/menu.h (copie de travail) @@ -65,6 +65,7 @@ MNU_EXPLAINOPTIONS, MNU_VERBOSE, MNU_ANALYZE, + MNU_AUTOROLLBACK, MNU_CLEARHISTORY, MNU_SAVEHISTORY, MNU_CHECKALIVE, Index: pgadmin/include/frm/frmQuery.h =================================================================== --- pgadmin/include/frm/frmQuery.h (révision 8028) +++ pgadmin/include/frm/frmQuery.h (copie de travail) @@ -134,6 +134,7 @@ void OnUndo(wxCommandEvent& event); void OnRedo(wxCommandEvent& event); void OnSaveHistory(wxCommandEvent& event); + void OnAutoRollback(wxCommandEvent& event); void OnChangeConnection(wxCommandEvent &ev); void OnClearHistory(wxCommandEvent& event); void OnActivate(wxActivateEvent& event); Index: pgadmin/include/utils/sysSettings.h =================================================================== --- pgadmin/include/utils/sysSettings.h (révision 8028) +++ pgadmin/include/utils/sysSettings.h (copie de travail) @@ -110,6 +110,8 @@ void SetIndentSpaces(const long newval) { Write(wxT("IndentSpaces"), newval); } bool GetIndicateNull() const { bool b; Read(wxT("frmQuery/IndicateNull"), &b, false); return b; } void SetIndicateNull(const bool newval) { Write(wxT("frmQuery/IndicateNull"), newval); } + bool GetAutoRollback() const { bool b; Read(wxT("frmQuery/AutoRollback"), &b, true); return b; } + void SetAutoRollback(const bool newval) { Write(wxT("frmQuery/AutoRollback"), newval); } bool GetUnicodeFile() const { bool b; Read(wxT("WriteUnicodeFile"), &b, true); return b; } void SetUnicodeFile(const bool newval) { Write(wxT("WriteUnicodeFile"), newval); } wxFont GetSystemFont(); Index: pgadmin/frm/frmOptions.cpp =================================================================== --- pgadmin/frm/frmOptions.cpp (révision 8028) +++ pgadmin/frm/frmOptions.cpp (copie de travail) @@ -56,6 +56,7 @@ #define cbCopySeparator CTRL_COMBOBOX("cbCopySeparator") #define chkStickySql CTRL_CHECKBOX("chkStickySql") #define chkIndicateNull CTRL_CHECKBOX("chkIndicateNull") +#define chkAutoRollback CTRL_CHECKBOX("chkAutoRollback") #define chkDoubleClickProperties CTRL_CHECKBOX("chkDoubleClickProperties") #define cbLanguage CTRL_COMBOBOX("cbLanguage") #define txtSqlFont CTRL_TEXT("txtSqlFont") @@ -126,6 +127,7 @@ chkStickySql->SetValue(settings->GetStickySql()); chkIndicateNull->SetValue(settings->GetIndicateNull()); + chkAutoRollback->SetValue(settings->GetAutoRollback()); chkDoubleClickProperties->SetValue(settings->GetDoubleClickProperties()); txtPgHelpPath->SetValue(settings->GetPgHelpPath()); @@ -391,6 +393,7 @@ settings->SetStickySql(chkStickySql->GetValue()); settings->SetIndicateNull(chkIndicateNull->GetValue()); + settings->SetAutoRollback(chkAutoRollback->GetValue()); settings->SetDoubleClickProperties(chkDoubleClickProperties->GetValue()); settings->SetUnicodeFile(chkUnicodeFile->GetValue()); settings->SetSystemFont(currentFont); Index: pgadmin/frm/frmQuery.cpp =================================================================== --- pgadmin/frm/frmQuery.cpp (révision 8028) +++ pgadmin/frm/frmQuery.cpp (copie de travail) @@ -47,6 +47,7 @@ #include "schema/pgServer.h" #include "utils/favourites.h" #include "utils/sysLogger.h" +#include "utils/sysSettings.h" #include "utils/utffile.h" #include "pgscript/pgsApplication.h" @@ -105,6 +106,7 @@ EVT_MENU(MNU_EXECFILE, frmQuery::OnExecFile) EVT_MENU(MNU_EXPLAIN, frmQuery::OnExplain) EVT_MENU(MNU_CANCEL, frmQuery::OnCancel) +EVT_MENU(MNU_AUTOROLLBACK, frmQuery::OnAutoRollback) EVT_MENU(MNU_CONTENTS, frmQuery::OnContents) EVT_MENU(MNU_HELP, frmQuery::OnHelp) EVT_MENU(MNU_CLEARHISTORY, frmQuery::OnClearHistory) @@ -240,6 +242,8 @@ queryMenu->Append(MNU_SAVEHISTORY, _("Save history"), _("Save history of executed commands.")); queryMenu->Append(MNU_CLEARHISTORY, _("Clear history"), _("Clear history window.")); queryMenu->AppendSeparator(); + queryMenu->Append(MNU_AUTOROLLBACK, _("&Auto-Rollback"), _("Rollback the current transaction if an error is detected"), wxITEM_CHECK); + queryMenu->AppendSeparator(); queryMenu->Append(MNU_CANCEL, _("&Cancel\tAlt-Break"), _("Cancel query")); menuBar->Append(queryMenu, _("&Query")); @@ -422,6 +426,10 @@ bool bVal; + // Auto-rollback + settings->Read(wxT("frmQuery/AutoRollback"), &bVal, false); + queryMenu->Check(MNU_AUTOROLLBACK, bVal); + // Auto indent settings->Read(wxT("frmQuery/AutoIndent"), &bVal, true); editMenu->Check(MNU_AUTOINDENT, bVal); @@ -659,6 +667,14 @@ } +void frmQuery::OnAutoRollback(wxCommandEvent& event) +{ + queryMenu->Check(MNU_AUTOROLLBACK, event.IsChecked()); + + settings->Write(wxT("frmQuery/AutoRollback"), queryMenu->IsChecked(MNU_AUTOROLLBACK)); +} + + void frmQuery::OnAutoIndent(wxCommandEvent &event) { editMenu->Check(MNU_AUTOINDENT, event.IsChecked()); @@ -2352,7 +2368,7 @@ msgHistory->ShowPosition(0); // If the transaction aborted for some reason, issue a rollback to cleanup. - if (conn->GetTxStatus() == PGCONN_TXSTATUS_INERROR) + if (settings->GetAutoRollback() && conn->GetTxStatus() == PGCONN_TXSTATUS_INERROR) conn->ExecuteVoid(wxT("ROLLBACK;")); setTools(false); Index: pgadmin/ui/frmOptions.xrc =================================================================== --- pgadmin/ui/frmOptions.xrc (révision 8028) +++ pgadmin/ui/frmOptions.xrc (copie de travail) @@ -308,6 +308,16 @@ <pos>175,157d</pos> <size>226,12d</size> </object> + <object class="wxStaticText" name="stAutoRollback"> + <label>Enable Auto ROLLBACK</label> + <pos>5,172d</pos> + </object> + <object class="wxCheckBox" name="chkAutoRollback"> + <label></label> + <checked>0</checked> + <pos>175,172d</pos> + <size>226,12d</size> + </object> </object> </object> <object class="notebookpage"> @@ -390,4 +400,4 @@ <tooltip>Cancel any changes and close the dialogue.</tooltip> </object> </object> -</resource> \ No newline at end of file +</resource>
-- Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-support