Index: CHANGELOG.txt
===================================================================
RCS file: /projects/pgadmin3/CHANGELOG.txt,v
retrieving revision 1.201
retrieving revision 1.202
diff -LCHANGELOG.txt -LCHANGELOG.txt -u -w -r1.201 -r1.202
--- CHANGELOG.txt
+++ CHANGELOG.txt
@@ -17,6 +17,7 @@
+ - 2005-04-07 AP VACUUM hint
- 2005-04-04 AP Control dependent win32 services
- 2005-04-01 AP Speed up of column property retrieval
- 2005-04-01 DP 1.2.2 Fix changing of view ownership
Index: pgServer.h
===================================================================
RCS file: /projects/pgadmin3/src/include/pgServer.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -Lsrc/include/pgServer.h -Lsrc/include/pgServer.h -u -w -r1.44 -r1.45
--- src/include/pgServer.h
+++ src/include/pgServer.h
@@ -117,6 +117,7 @@
#ifdef WIN32
SC_HANDLE scmHandle;
SC_HANDLE serviceHandle;
+ wxArrayString GetDependentServices(SC_HANDLE handle);
#endif
};
Index: frmHint.h
===================================================================
RCS file: /projects/pgadmin3/src/include/frmHint.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lsrc/include/frmHint.h -Lsrc/include/frmHint.h -u -w -r1.3 -r1.4
--- src/include/frmHint.h
+++ src/include/frmHint.h
@@ -18,6 +18,7 @@
#define HINT_MISSINGIDENT wxT("conn-ident")
#define HINT_PRIMARYKEY wxT("pk")
#define HINT_FKINDEX wxT("fki")
+#define HINT_VACUUM wxT("vacuum")
class frmMain;
class frmHint : public DialogWithHelp
Index: pgTable.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgTable.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -Lsrc/schema/pgTable.cpp -Lsrc/schema/pgTable.cpp -u -w -r1.63 -r1.64
--- src/schema/pgTable.cpp
+++ src/schema/pgTable.cpp
@@ -15,6 +15,7 @@
// App headers
#include "pgAdmin3.h"
#include "misc.h"
+#include "frmHint.h"
#include "pgObject.h"
#include "pgTable.h"
#include "pgCollection.h"
@@ -405,6 +406,24 @@
properties->AppendItem(_("Has OIDs?"), GetHasOids());
properties->AppendItem(_("System table?"), GetSystemObject());
properties->AppendItem(_("Comment"), GetComment());
+
+ bool showHint=false;
+ if (rowsCounted)
+ {
+ if (!estimatedRows || (estimatedRows == 1000 && rows != 1000))
+ showHint = (rows >= 20);
+ else
+ {
+ wxULongLong quot = rows*10 / estimatedRows;
+ showHint = ((quot > 12 || quot < 8) && (rows+20 < estimatedRows || rows > estimatedRows+20));
+ }
+ }
+ else if (estimatedRows == 1000)
+ {
+ showHint = true;
+ }
+ if (form && showHint)
+ frmHint::ShowHint((wxWindow*)form, HINT_VACUUM, GetFullIdentifier());
}
}
Index: pgServer.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgServer.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -Lsrc/schema/pgServer.cpp -Lsrc/schema/pgServer.cpp -u -w -r1.60 -r1.61
--- src/schema/pgServer.cpp
+++ src/schema/pgServer.cpp
@@ -135,6 +135,40 @@
#define SERVICEBUFSIZE 10000
+#define QUERYBUFSIZE 256
+
+#ifdef WIN32
+wxArrayString pgServer::GetDependentServices(SC_HANDLE handle)
+{
+ wxArrayString services;
+ LPENUM_SERVICE_STATUS sbuf = (LPENUM_SERVICE_STATUS) new char[SERVICEBUFSIZE];
+
+ DWORD servicesReturned=0, bytesNeeded;
+ ::EnumDependentServices(handle, SERVICE_STATE_ALL, sbuf, SERVICEBUFSIZE, &bytesNeeded, &servicesReturned);
+
+
+ DWORD i;
+ for (i=0 ; i < servicesReturned ; i++)
+ {
+ SC_HANDLE h=::OpenService(scmHandle, sbuf[i].lpServiceName, SERVICE_QUERY_CONFIG);
+ if (h)
+ {
+ char buffer[QUERYBUFSIZE];
+ LPQUERY_SERVICE_CONFIG qsc=(LPQUERY_SERVICE_CONFIG)buffer;
+ if(::QueryServiceConfig(h, qsc, QUERYBUFSIZE, &bytesNeeded))
+ {
+ if (qsc->dwStartType != SERVICE_DISABLED)
+ services.Add(sbuf[i].lpServiceName);
+ }
+
+ ::CloseServiceHandle(h);
+ }
+ }
+ delete[] sbuf;
+
+ return services;
+}
+#endif
bool pgServer::StartService()
@@ -160,25 +194,24 @@
{
GetServerRunning(); // ignore result, just to wait for startup
- LPENUM_SERVICE_STATUS sbuf = (LPENUM_SERVICE_STATUS) new char[SERVICEBUFSIZE];
- DWORD bytesNeeded, servicesReturned=0;
- ::EnumDependentServices(serviceHandle, SERVICE_INACTIVE, sbuf, SERVICEBUFSIZE, &bytesNeeded, &servicesReturned);
- if (servicesReturned > 0)
+ wxArrayString services=GetDependentServices(serviceHandle);
+
+ if (services.GetCount() > 0)
{
- DWORD i;
- wxString services;
- for (i=0 ; i < servicesReturned ; i++)
- services += wxT(" ") + wxString(sbuf[i].lpDisplayName) + wxT("\n");
+ size_t i;
+ wxString serviceString;
+ for (i=0 ; i < services.GetCount() ; i++)
+ serviceString += wxT(" ") + services.Item(i) + wxT("\n");
wxMessageDialog msg(0, _("There are dependent services configured:\n\n")
- + services + _("\nStart dependent services too?"), _("Dependent services running"),
+ + serviceString + _("\nStart dependent services too?"), _("Dependent services"),
wxICON_EXCLAMATION | wxYES_NO | wxYES_DEFAULT);
if (msg.ShowModal() == wxID_YES)
{
- for (i=0 ; i < servicesReturned ; i++)
+ for (i=0 ; i < services.GetCount() ; i++)
{
- SC_HANDLE h=::OpenService(scmHandle, sbuf[i].lpServiceName, GENERIC_EXECUTE|GENERIC_READ);
+ SC_HANDLE h=::OpenService(scmHandle, services.Item(i), GENERIC_EXECUTE|GENERIC_READ);
if (h)
{
if (!::StartService(h, 0, 0))
@@ -234,7 +267,7 @@
services += wxT(" ") + wxString(sbuf[i].lpDisplayName) + wxT("\n");
wxMessageDialog msg(0, _("There are dependent services running:\n\n")
- + services + _("\nStop dependent services?"), _("Dependent services running"),
+ + services + _("\nStop dependent services?"), _("Dependent services"),
wxICON_EXCLAMATION | wxYES_NO | wxYES_DEFAULT);
if (msg.ShowModal() != wxID_YES)
return false;
Index: frmHint.cpp
===================================================================
RCS file: /projects/pgadmin3/src/ui/frmHint.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lsrc/ui/frmHint.cpp -Lsrc/ui/frmHint.cpp -u -w -r1.3 -r1.4
--- src/ui/frmHint.cpp
+++ src/ui/frmHint.cpp
@@ -67,6 +67,11 @@
wxT("ddl-constraints#ddl-constraints-fk"),
HINT_CANSUPPRESS|HINT_CANABORT
},
+ { HINT_VACUUM,
+ __("Running VACUUM recommended"),
+ wxT("maintenance#routine-vacuuming"),
+ HINT_CANSUPPRESS
+ },
{ 0,0,0,0 }
};