Hi,
Another patch to handle the 9.4 MOVE clause of ALTER TABLESPACE. It
brings a new dialog to do the move.
Patch attached, comments welcome.
--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com
From e1bd9f1f660f8bef10964b6d566547e2db8fbffb Mon Sep 17 00:00:00 2001
From: Guillaume Lelarge guilla...@lelarge.info
Date: Fri, 9 May 2014 21:29:44 +0200
Subject: [PATCH] Handle the 9.4 MOVE clause of ALTER TABLESPACE
---
pgadmin/dlg/dlgMoveTablespace.cpp | 119
pgadmin/dlg/module.mk | 1 +
pgadmin/frm/frmMain.cpp | 2 +
pgadmin/include/dlg/dlgMoveTablespace.h | 44
pgadmin/include/dlg/module.mk | 1 +
pgadmin/include/schema/pgTablespace.h | 9 +++
pgadmin/schema/pgTablespace.cpp | 40 +++
pgadmin/ui/dlgMoveTablespace.xrc| 95 +
pgadmin/ui/module.mk| 1 +
9 files changed, 312 insertions(+)
create mode 100644 pgadmin/dlg/dlgMoveTablespace.cpp
create mode 100644 pgadmin/include/dlg/dlgMoveTablespace.h
create mode 100644 pgadmin/ui/dlgMoveTablespace.xrc
diff --git a/pgadmin/dlg/dlgMoveTablespace.cpp b/pgadmin/dlg/dlgMoveTablespace.cpp
new file mode 100644
index 000..90a4472
--- /dev/null
+++ b/pgadmin/dlg/dlgMoveTablespace.cpp
@@ -0,0 +1,119 @@
+//
+//
+// pgAdmin III - PostgreSQL Tools
+//
+// Copyright (C) 2002 - 2014, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dlgMoveTablespace.cpp - Reassign or drop owned objects
+//
+//
+
+#include pgAdmin3.h
+
+// wxWindows headers
+#include wx/wx.h
+
+// App headers
+#include pgAdmin3.h
+#include utils/pgDefs.h
+#include frm/frmMain.h
+#include dlg/dlgMoveTablespace.h
+#include utils/misc.h
+#include schema/pgTablespace.h
+
+
+// pointer to controls
+#define cbMoveTo CTRL_COMBOBOX(cbMoveTo)
+#define cbKindCTRL_COMBOBOX(cbKind)
+#define cbOwner CTRL_COMBOBOX(cbOwner)
+#define btnOK CTRL_BUTTON(wxID_OK)
+
+
+BEGIN_EVENT_TABLE(dlgMoveTablespace, pgDialog)
+ EVT_BUTTON(wxID_OK, dlgMoveTablespace::OnOK)
+END_EVENT_TABLE()
+
+
+dlgMoveTablespace::dlgMoveTablespace(frmMain *win, pgConn *conn, pgTablespace *tblspc)
+{
+ wxString query;
+
+ connection = conn;
+ parent = win;
+
+ SetFont(settings-GetSystemFont());
+ LoadResource(win, wxT(dlgMoveTablespace));
+ RestorePosition();
+
+ cbKind-Clear();
+ cbKind-Append(_(All));
+ cbKind-Append(_(Tables));
+ cbKind-Append(_(Indexes));
+ cbKind-Append(_(Materialized views));
+ cbKind-SetSelection(0);
+
+ cbMoveTo-Clear();
+ query = wxT(SELECT spcname FROM pg_tablespace WHERE spcname) + conn-qtDbString(tblspc-GetName()) + wxT( ORDER BY spcname);
+ pgSetIterator tblspcs(connection, query);
+ while (tblspcs.RowsLeft())
+ {
+ cbMoveTo-Append(tblspcs.GetVal(wxT(spcname)));
+ }
+ cbMoveTo-SetSelection(0);
+
+ cbOwner-Clear();
+ cbOwner-Append(wxEmptyString);
+ query = wxT(SELECT rolname FROM pg_roles ORDER BY rolname);
+ pgSetIterator roles(connection, query);
+ while (roles.RowsLeft())
+ {
+ cbOwner-Append(roles.GetVal(wxT(rolname)));
+ }
+ cbOwner-SetSelection(0);
+ cbOwner-Enable(cbOwner-GetStrings().Count() 0);
+
+ SetSize(330, 160);
+}
+
+dlgMoveTablespace::~dlgMoveTablespace()
+{
+ SavePosition();
+}
+
+
+void dlgMoveTablespace::OnOK(wxCommandEvent ev)
+{
+ EndModal(wxID_OK);
+}
+
+
+void dlgMoveTablespace::OnCancel(wxCommandEvent ev)
+{
+ EndModal(wxID_CANCEL);
+}
+
+wxString dlgMoveTablespace::GetTablespace()
+{
+ return cbMoveTo-GetValue();
+}
+
+wxString dlgMoveTablespace::GetKind()
+{
+wxString kind;
+
+ if (cbKind-GetValue().Cmp(_(Tables)) == 0)
+return wxT(TABLES);
+ if (cbKind-GetValue().Cmp(_(Indexes)) == 0)
+return wxT(INDEXES);
+ if (cbKind-GetValue().Cmp(_(Materialized views)) == 0)
+return wxT(MATERIALIZED VIEWS);
+
+return wxT(ALL);
+}
+
+wxString dlgMoveTablespace::GetOwner()
+{
+ return cbOwner-GetValue();
+}
+
diff --git a/pgadmin/dlg/module.mk b/pgadmin/dlg/module.mk
index 70d83f5..46f4209 100644
--- a/pgadmin/dlg/module.mk
+++ b/pgadmin/dlg/module.mk
@@ -37,6 +37,7 @@ pgadmin3_SOURCES += \
dlg/dlgLanguage.cpp \
dlg/dlgMainConfig.cpp \
dlg/dlgManageFavourites.cpp \
+ dlg/dlgMoveTablespace.cpp \
dlg/dlgOperator.cpp \
dlg/dlgPackage.cpp \
dlg/dlgPgpassConfig.cpp \
diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cpp
index b9c7c64..c8d65c0 100644
--- a/pgadmin/frm/frmMain.cpp
+++ b/pgadmin/frm/frmMain.cpp
@@ -79,6 +79,7 @@
#include schema/pgRole.h
#include schema/pgRule.h
#include schema/pgServer.h
+#include schema/pgTablespace.h
#include slony/slCluster.h
#include slony/slSet.h
#include schema/pgForeignKey.h
@@ -382,6 +383,7 @@ void frmMain::CreateMenus()
new resetTableStatsFactory(menuFactories,