Index: pgadmin/include/schema/pgFunction.h
===================================================================
--- pgadmin/include/schema/pgFunction.h	(révision 7971)
+++ pgadmin/include/schema/pgFunction.h	(copie de travail)
@@ -14,7 +14,6 @@
 
 #include "pgSchema.h"
 
-class pgCollection;
 class pgFunction;
 
 class pgFunctionFactory : public pgSchemaObjFactory
@@ -23,6 +22,7 @@
     pgFunctionFactory(const wxChar *tn=0, const wxChar *ns=0, const wxChar *nls=0, const char **img=0);
     virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent);
     virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr=wxEmptyString);
+    virtual pgCollection *CreateCollection(pgObject *obj);
 
     pgFunction *AppendFunctions(pgObject *obj, pgSchema *schema, ctlTree *browser, const wxString &restriction);
 };
@@ -39,6 +39,7 @@
 
     void ShowTreeDetail(ctlTree *browser, frmMain *form=0, ctlListView *properties=0, ctlSQLBox *sqlPane=0);
     bool CanDropCascaded() { return GetSchema()->GetMetaType() != PGM_CATALOG; }
+    void ShowStatistics(frmMain *form, ctlListView *statistics);
 
     virtual bool GetIsProcedure() const {return false; }
 
@@ -112,6 +113,14 @@
 };
 
 
+class pgFunctionCollection : public pgSchemaObjCollection
+{
+public:
+    pgFunctionCollection(pgaFactory *factory, pgSchema *sch);
+    void ShowStatistics(frmMain *form, ctlListView *statistics);
+};
+
+
 class pgTriggerFunctionFactory : public pgFunctionFactory
 {
 public:
Index: pgadmin/schema/pgFunction.cpp
===================================================================
--- pgadmin/schema/pgFunction.cpp	(révision 7971)
+++ pgadmin/schema/pgFunction.cpp	(copie de travail)
@@ -42,6 +42,20 @@
 {
 }
 
+void pgFunction::ShowStatistics(frmMain *form, ctlListView *statistics)
+{
+    if (GetConnection()->BackendMinimumVersion(8, 4))
+    {
+		wxString sql=wxT("SELECT calls AS ") + qtIdent(_("Number of calls")) +
+	      wxT(", total_time AS ") + qtIdent(_("Total Time")) +
+	      wxT(", self_time AS ") + qtIdent(_("Self Time")) +
+          wxT(" FROM pg_stat_user_functions") +
+          wxT(" WHERE schemaname = ") + qtDbString(GetSchema()->GetName()) +
+		  wxT(" AND funcname = ") + qtDbString(GetName());
+		DisplayStatistics(statistics, sql);
+	}
+}
+
 bool pgFunction::IsUpToDate()
 {
     wxString sql = wxT("SELECT xmin FROM pg_proc WHERE oid = ") + this->GetOidStr();
@@ -681,6 +695,11 @@
 }
 
 
+pgCollection *pgFunctionFactory::CreateCollection(pgObject *obj)
+{
+    return new pgFunctionCollection(GetCollectionFactory(), (pgSchema*)obj);
+}
+
 pgObject *pgTriggerFunctionFactory::CreateObjects(pgCollection *collection, ctlTree *browser, const wxString &restr)
 {
     wxString funcRestriction=wxT(
@@ -738,3 +757,46 @@
 
 pgProcedureFactory procedureFactory;
 static pgaCollectionFactory cfp(&procedureFactory, __("Procedures"), procedures_xpm);
+
+pgFunctionCollection::pgFunctionCollection(pgaFactory *factory, pgSchema *sch)
+: pgSchemaObjCollection(factory, sch)
+{
+}
+
+
+void pgFunctionCollection::ShowStatistics(frmMain *form, ctlListView *statistics)
+{
+    if (GetConnection()->BackendMinimumVersion(8, 4))
+    {
+		wxLogInfo(wxT("Displaying statistics for functions on ") + GetSchema()->GetName());
+
+		wxString sql=wxT("SELECT funcname, calls, total_time, self_time")
+                 wxT(" FROM pg_stat_user_functions")
+                 wxT(" WHERE schemaname = ") + qtDbString(GetSchema()->GetName())
+                 + wxT(" ORDER BY funcname");
+
+		// Add the statistics view columns
+		statistics->ClearAll();
+		statistics->AddColumn(_("Function"), 60);
+		statistics->AddColumn(_("Calls"), 50);
+		statistics->AddColumn(_("Total Time"), 60);
+		statistics->AddColumn(_("Self Time"), 60);
+
+		pgSet *stats = GetDatabase()->ExecuteSet(sql);
+		if (stats)
+		{
+			long pos=0;
+			while (!stats->Eof())
+			{
+				statistics->InsertItem(pos, stats->GetVal(wxT("funcname")), PGICON_STATISTICS);
+				statistics->SetItem(pos, 1, stats->GetVal(wxT("calls")));
+				statistics->SetItem(pos, 2, stats->GetVal(wxT("total_time")));
+				statistics->SetItem(pos, 3, stats->GetVal(wxT("self_time")));
+				stats->MoveNext();
+				pos++;
+			}
+
+			delete stats;
+		}
+    }
+}
