Hi Dave,

Please find the patch for (TOAST-TABLE) autovacuum settings.

Patch contains changes for:
* Moved the code related to fetching the (Toast-Table) AutoVaccum settings from dlgTable to pgTable. * Showing AV settings (also the Toast-Table AV settings, if present) in the properties listview.
* pgTable::GetSql() will now show custom AV settings for toast tables.

Dave Page wrote:
On Mon, Feb 23, 2009 at 2:01 PM, Ashesh Vashi
<[email protected]> wrote:
Hi All,

Please find the patch for the "Update autovacuum (for TOAST-TABLE) to use
reloptions, instead of a system catalog.

Thanks Ashesh - I've committed what's there as it works as is,
however, the custom AV settings for toast tables are not reflected in
the output from pgTable::GetSql(). Could you fix that please?

We should also add the AV settings to the properties listview (in
pgTable::ShowTreeDetail), like we do with variables on databases and
roles. Can you also look at that please?

Thanks!


--
Thanks & Regards,
Ashesh Vashi

EnterpriseDB INDIA: http://www.enterprisedb.com
Index: include/schema/pgTable.h
===================================================================
--- include/schema/pgTable.h	(revision 7607)
+++ include/schema/pgTable.h	(working copy)
@@ -96,31 +96,57 @@
     wxString GetFillFactor() { return fillFactor; }
     void iSetFillFactor(const wxString& s) { fillFactor = s; }
 
-    void iSetCustomAutoVacuumEnabled(bool b) { custom_autovacuum_enabled = b; }
-    bool GetCustomAutoVacuumEnabled() { return custom_autovacuum_enabled; }
-    bool GetAutoVacuumEnabled() { return autovacuum_enabled; }
-    void iSetAutoVacuumEnabled(bool b) { autovacuum_enabled = b; }
+    bool GetCustomAutoVacuumEnabled() { return !reloptions.IsEmpty(); }
+    wxString GetRelOptions() { return reloptions; }
+    void iSetRelOptions(const wxString& s) { reloptions = s; }
+    int GetAutoVacuumEnabled() { return autovacuum_enabled; }
+    void iSetAutoVacuumEnabled(int i) { autovacuum_enabled = i; }
     wxString GetAutoVacuumVacuumThreshold() { return autovacuum_vacuum_threshold; }
-    void iSetAutoVacuumVacuumThreshold(const wxString& s) { custom_autovacuum_enabled |= !s.IsEmpty(); autovacuum_vacuum_threshold = s; }
+    void iSetAutoVacuumVacuumThreshold(const wxString& s) { autovacuum_vacuum_threshold = s; }
     wxString GetAutoVacuumVacuumScaleFactor() { return autovacuum_vacuum_scale_factor; }
-    void iSetAutoVacuumVacuumScaleFactor(const wxString& s) { custom_autovacuum_enabled |= !s.IsEmpty(); autovacuum_vacuum_scale_factor = s; }
+    void iSetAutoVacuumVacuumScaleFactor(const wxString& s) { autovacuum_vacuum_scale_factor = s; }
     wxString GetAutoVacuumAnalyzeThreshold() { return autovacuum_analyze_threshold; }
-    void iSetAutoVacuumAnalyzeThreshold(const wxString& s) { custom_autovacuum_enabled |= !s.IsEmpty(); autovacuum_analyze_threshold = s; }
+    void iSetAutoVacuumAnalyzeThreshold(const wxString& s) { autovacuum_analyze_threshold = s; }
     wxString GetAutoVacuumAnalyzeScaleFactor() { return autovacuum_analyze_scale_factor; }
-    void iSetAutoVacuumAnalyzeScaleFactor(const wxString& s) { custom_autovacuum_enabled |= !s.IsEmpty(); autovacuum_analyze_scale_factor = s; }
+    void iSetAutoVacuumAnalyzeScaleFactor(const wxString& s) { autovacuum_analyze_scale_factor = s; }
     wxString GetAutoVacuumVacuumCostDelay() { return autovacuum_vacuum_cost_delay; }
-    void iSetAutoVacuumVacuumCostDelay(const wxString& s) { custom_autovacuum_enabled |= !s.IsEmpty(); autovacuum_vacuum_cost_delay = s; }
+    void iSetAutoVacuumVacuumCostDelay(const wxString& s) { autovacuum_vacuum_cost_delay = s; }
     wxString GetAutoVacuumVacuumCostLimit() { return autovacuum_vacuum_cost_limit; }
-    void iSetAutoVacuumVacuumCostLimit(const wxString& s) { custom_autovacuum_enabled |= !s.IsEmpty(); autovacuum_vacuum_cost_limit = s; }
+    void iSetAutoVacuumVacuumCostLimit(const wxString& s) { autovacuum_vacuum_cost_limit = s; }
     wxString GetAutoVacuumFreezeMinAge() { return autovacuum_freeze_min_age; }
-    void iSetAutoVacuumFreezeMinAge(const wxString& s) { custom_autovacuum_enabled |= !s.IsEmpty(); autovacuum_freeze_min_age = s; }
+    void iSetAutoVacuumFreezeMinAge(const wxString& s) { autovacuum_freeze_min_age = s; }
     wxString GetAutoVacuumFreezeMaxAge() { return autovacuum_freeze_max_age; }
-    void iSetAutoVacuumFreezeMaxAge(const wxString& s) { custom_autovacuum_enabled |= !s.IsEmpty(); autovacuum_freeze_max_age = s; }
+    void iSetAutoVacuumFreezeMaxAge(const wxString& s) { autovacuum_freeze_max_age = s; }
     wxString GetAutoVacuumFreezeTableAge() { return autovacuum_freeze_table_age; }
-    void iSetAutoVacuumFreezeTableAge(const wxString& s) { custom_autovacuum_enabled |= !s.IsEmpty(); autovacuum_freeze_table_age = s; }
+    void iSetAutoVacuumFreezeTableAge(const wxString& s) { autovacuum_freeze_table_age = s; }
+    bool GetHasToastTable() { return hasToastTable; }
     void iSetHasToastTable(bool b) { hasToastTable = b; }
-    bool GetHasToastTable() { return hasToastTable; }
 
+    /* TOAST TABLE autovacuum settings */
+    bool GetToastCustomAutoVacuumEnabled() { return !toast_reloptions.IsEmpty(); }
+    wxString GetToastRelOptions() { return toast_reloptions; }
+    void iSetToastRelOptions(const wxString& s) { toast_reloptions = s; }
+    int GetToastAutoVacuumEnabled() { return toast_autovacuum_enabled; }
+    void iSetToastAutoVacuumEnabled(int i) { toast_autovacuum_enabled = i; }
+    wxString GetToastAutoVacuumVacuumThreshold() { return toast_autovacuum_vacuum_threshold; }
+    void iSetToastAutoVacuumVacuumThreshold(const wxString& s) { toast_autovacuum_vacuum_threshold = s; }
+    wxString GetToastAutoVacuumVacuumScaleFactor() { return toast_autovacuum_vacuum_scale_factor; }
+    void iSetToastAutoVacuumVacuumScaleFactor(const wxString& s) { toast_autovacuum_vacuum_scale_factor = s; }
+    wxString GetToastAutoVacuumAnalyzeThreshold() { return toast_autovacuum_analyze_threshold; }
+    void iSetToastAutoVacuumAnalyzeThreshold(const wxString& s) { toast_autovacuum_analyze_threshold = s; }
+    wxString GetToastAutoVacuumAnalyzeScaleFactor() { return toast_autovacuum_analyze_scale_factor; }
+    void iSetToastAutoVacuumAnalyzeScaleFactor(const wxString& s) { toast_autovacuum_analyze_scale_factor = s; }
+    wxString GetToastAutoVacuumVacuumCostDelay() { return toast_autovacuum_vacuum_cost_delay; }
+    void iSetToastAutoVacuumVacuumCostDelay(const wxString& s) { toast_autovacuum_vacuum_cost_delay = s; }
+    wxString GetToastAutoVacuumVacuumCostLimit() { return toast_autovacuum_vacuum_cost_limit; }
+    void iSetToastAutoVacuumVacuumCostLimit(const wxString& s) { toast_autovacuum_vacuum_cost_limit = s; }
+    wxString GetToastAutoVacuumFreezeMinAge() { return toast_autovacuum_freeze_min_age; }
+    void iSetToastAutoVacuumFreezeMinAge(const wxString& s) { toast_autovacuum_freeze_min_age = s; }
+    wxString GetToastAutoVacuumFreezeMaxAge() { return toast_autovacuum_freeze_max_age; }
+    void iSetToastAutoVacuumFreezeMaxAge(const wxString& s) { toast_autovacuum_freeze_max_age = s; }
+    wxString GetToastAutoVacuumFreezeTableAge() { return toast_autovacuum_freeze_table_age; }
+    void iSetToastAutoVacuumFreezeTableAge(const wxString& s) { toast_autovacuum_freeze_table_age = s; }
+
     bool HasStats() { return true; }
     bool HasDepends() { return true; }
     bool HasReferences() { return true; }
@@ -144,13 +170,30 @@
     void AppendStuff(wxString &sql, ctlTree *browser, pgaFactory &factory);
     wxULongLong rows;
     double estimatedRows;
+
+    bool hasToastTable;
+    /*
+    * Three possible values:
+    * 0 - Disabled
+    * 1 - Enabled
+    * 2 - GUC Setting
+    */
+    int autovacuum_enabled, toast_autovacuum_enabled;
+    wxString reloptions, toast_reloptions;
+
     wxString fillFactor, autovacuum_vacuum_threshold,
              autovacuum_vacuum_scale_factor, autovacuum_analyze_threshold,
              autovacuum_analyze_scale_factor, autovacuum_vacuum_cost_delay,
              autovacuum_vacuum_cost_limit, autovacuum_freeze_min_age,
              autovacuum_freeze_max_age, autovacuum_freeze_table_age;
     bool hasOids, hasSubclass, rowsCounted, isReplicated, showExtendedStatistics;
-    bool autovacuum_enabled, custom_autovacuum_enabled, hasToastTable;
+
+    wxString toast_fillFactor, toast_autovacuum_vacuum_threshold,
+             toast_autovacuum_vacuum_scale_factor, toast_autovacuum_analyze_threshold,
+             toast_autovacuum_analyze_scale_factor, toast_autovacuum_vacuum_cost_delay,
+             toast_autovacuum_vacuum_cost_limit, toast_autovacuum_freeze_min_age,
+             toast_autovacuum_freeze_max_age, toast_autovacuum_freeze_table_age;
+   
     long inheritedTableCount;
     wxString quotedInheritedTables, inheritedTables, primaryKey, quotedPrimaryKey,
              primaryKeyName, primaryKeyColNumbers, tablespace;
Index: schema/pgTable.cpp
===================================================================
--- schema/pgTable.cpp	(revision 7607)
+++ schema/pgTable.cpp	(working copy)
@@ -317,47 +317,90 @@
             {
                 if (GetCustomAutoVacuumEnabled())
                 {
-                    if (GetAutoVacuumEnabled())
+                    if (GetAutoVacuumEnabled() == 1)
                         sql += wxT(",\n  autovacuum_enabled=true");
-                    else
+                    else if (GetCustomAutoVacuumEnabled() == 0)
                         sql += wxT(",\n  autovacuum_enabled=false");
+                    if (!GetAutoVacuumVacuumThreshold().IsEmpty())
+                    {
+                        sql += wxT(",\n  autovacuum_vacuum_threshold=") + GetAutoVacuumVacuumThreshold();
+                    }
+                    if (!GetAutoVacuumVacuumScaleFactor().IsEmpty())
+                    {
+                        sql += wxT(",\n  autovacuum_vacuum_scale_factor=") + GetAutoVacuumVacuumScaleFactor();
+                    }
+                    if (!GetAutoVacuumAnalyzeThreshold().IsEmpty())
+                    {
+                        sql += wxT(",\n  autovacuum_analyze_threshold=") + GetAutoVacuumAnalyzeThreshold();
+                    }
+                    if (!GetAutoVacuumAnalyzeScaleFactor().IsEmpty())
+                    {
+                        sql += wxT(",\n  autovacuum_analyze_scale_factor=") + GetAutoVacuumAnalyzeScaleFactor();
+                    }
+                    if (!GetAutoVacuumVacuumCostDelay().IsEmpty())
+                    {
+                        sql += wxT(",\n  autovacuum_vacuum_cost_delay=") + GetAutoVacuumVacuumCostDelay();
+                    }
+                    if (!GetAutoVacuumVacuumCostLimit().IsEmpty())
+                    {
+                        sql += wxT(",\n  autovacuum_vacuum_cost_limit=") + GetAutoVacuumVacuumCostLimit();
+                    }
+                    if (!GetAutoVacuumFreezeMinAge().IsEmpty())
+                    {
+                        sql += wxT(",\n  autovacuum_freeze_min_age=") + GetAutoVacuumFreezeMinAge();
+                    }
+                    if (!GetAutoVacuumFreezeMaxAge().IsEmpty())
+                    {
+                        sql += wxT(",\n  autovacuum_freeze_max_age=") + GetAutoVacuumFreezeMaxAge();
+                    }
+                    if (!GetAutoVacuumFreezeTableAge().IsEmpty())
+                    {
+                        sql += wxT(",\n  autovacuum_freeze_table_age=") + GetAutoVacuumFreezeTableAge();
+                    }
                 }
-                if (!GetAutoVacuumVacuumThreshold().IsEmpty())
+                if (GetHasToastTable() && GetToastCustomAutoVacuumEnabled())
                 {
-                    sql += wxT(",\n  autovacuum_vacuum_threshold=") + GetAutoVacuumVacuumThreshold();
+                    if (GetToastAutoVacuumEnabled() == 1)
+                        sql += wxT(",\n  toast.autovacuum_enabled=true");
+                    else if (GetToastAutoVacuumEnabled() == 0)
+                        sql += wxT(",\n  toast.autovacuum_enabled=false");
+                    if (!GetToastAutoVacuumVacuumThreshold().IsEmpty())
+                    {
+                        sql += wxT(",\n  toast.autovacuum_vacuum_threshold=") + GetToastAutoVacuumVacuumThreshold();
+                    }
+                    if (!GetToastAutoVacuumVacuumScaleFactor().IsEmpty())
+                    {
+                        sql += wxT(",\n  toast.autovacuum_vacuum_scale_factor=") + GetToastAutoVacuumVacuumScaleFactor();
+                    }
+                    if (!GetToastAutoVacuumAnalyzeThreshold().IsEmpty())
+                    {
+                        sql += wxT(",\n  toast.autovacuum_analyze_threshold=") + GetToastAutoVacuumAnalyzeThreshold();
+                    }
+                    if (!GetToastAutoVacuumAnalyzeScaleFactor().IsEmpty())
+                    {
+                        sql += wxT(",\n  toast.autovacuum_analyze_scale_factor=") + GetToastAutoVacuumAnalyzeScaleFactor();
+                    }
+                    if (!GetToastAutoVacuumVacuumCostDelay().IsEmpty())
+                    {
+                        sql += wxT(",\n  toast.autovacuum_vacuum_cost_delay=") + GetToastAutoVacuumVacuumCostDelay();
+                    }
+                    if (!GetToastAutoVacuumVacuumCostLimit().IsEmpty())
+                    {
+                        sql += wxT(",\n  toast.autovacuum_vacuum_cost_limit=") + GetToastAutoVacuumVacuumCostLimit();
+                    }
+                    if (!GetToastAutoVacuumFreezeMinAge().IsEmpty())
+                    {
+                        sql += wxT(",\n  toast.autovacuum_freeze_min_age=") + GetToastAutoVacuumFreezeMinAge();
+                    }
+                    if (!GetToastAutoVacuumFreezeMaxAge().IsEmpty())
+                    {
+                        sql += wxT(",\n  toast.autovacuum_freeze_max_age=") + GetToastAutoVacuumFreezeMaxAge();
+                    }
+                    if (!GetToastAutoVacuumFreezeTableAge().IsEmpty())
+                    {
+                        sql += wxT(",\n  toast.autovacuum_freeze_table_age=") + GetToastAutoVacuumFreezeTableAge();
+                    }
                 }
-                if (!GetAutoVacuumVacuumScaleFactor().IsEmpty())
-                {
-                    sql += wxT(",\n  autovacuum_vacuum_scale_factor=") + GetAutoVacuumVacuumScaleFactor();
-                }
-                if (!GetAutoVacuumAnalyzeThreshold().IsEmpty())
-                {
-                    sql += wxT(",\n  autovacuum_analyze_threshold=") + GetAutoVacuumAnalyzeThreshold();
-                }
-                if (!GetAutoVacuumAnalyzeScaleFactor().IsEmpty())
-                {
-                    sql += wxT(",\n  autovacuum_analyze_scale_factor=") + GetAutoVacuumAnalyzeScaleFactor();
-                }
-                if (!GetAutoVacuumVacuumCostDelay().IsEmpty())
-                {
-                    sql += wxT(",\n  autovacuum_vacuum_cost_delay=") + GetAutoVacuumVacuumCostDelay();
-                }
-                if (!GetAutoVacuumVacuumCostLimit().IsEmpty())
-                {
-                    sql += wxT(",\n  autovacuum_vacuum_cost_limit=") + GetAutoVacuumVacuumCostLimit();
-                }
-                if (!GetAutoVacuumFreezeMinAge().IsEmpty())
-                {
-                    sql += wxT(",\n  autovacuum_freeze_min_age=") + GetAutoVacuumFreezeMinAge();
-                }
-                if (!GetAutoVacuumFreezeMaxAge().IsEmpty())
-                {
-                    sql += wxT(",\n  autovacuum_freeze_max_age=") + GetAutoVacuumFreezeMaxAge();
-                }
-                if (!GetAutoVacuumFreezeTableAge().IsEmpty())
-                {
-                    sql += wxT(",\n  autovacuum_freeze_table_age=") + GetAutoVacuumFreezeTableAge();
-                }
             }
             sql += wxT("\n)");
         }
@@ -705,6 +748,13 @@
             properties->AppendItem(_("Inherited tables"), GetInheritedTables());
         properties->AppendItem(_("Has OIDs?"), GetHasOids());
         properties->AppendItem(_("System table?"), GetSystemObject());
+        if (GetConnection()->BackendMinimumVersion(8, 4))
+        {
+            properties->AppendItem(_("AutoVacuum setting"), GetRelOptions());
+            properties->AppendItem(_("Has Toast Table?"), GetHasToastTable());
+            if (GetHasToastTable())
+                properties->AppendItem(_("Toast Table - AutoVacuum settings?"), GetToastRelOptions());
+        }
         properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
 
     }
@@ -997,6 +1047,7 @@
                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age \n")
                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age \n")
                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age \n")
+                     wxT(", rel.reloptions AS reloptions \n")
                      wxT(", (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable\n");
         }
 
@@ -1053,20 +1104,70 @@
             }
             if (collection->GetConnection()->BackendMinimumVersion(8, 4))
             {
-                table->iSetCustomAutoVacuumEnabled(false);
-                if (!tables->GetVal(wxT("autovacuum_enabled")).IsEmpty())
-                    table->iSetCustomAutoVacuumEnabled(true);
-                table->iSetAutoVacuumEnabled(tables->GetBool(wxT("autovacuum_enabled")));
-                table->iSetAutoVacuumVacuumThreshold(tables->GetVal(wxT("autovacuum_vacuum_threshold")));
-                table->iSetAutoVacuumVacuumScaleFactor(tables->GetVal(wxT("autovacuum_vacuum_scale_factor")));
-                table->iSetAutoVacuumAnalyzeThreshold(tables->GetVal(wxT("autovacuum_analyze_threshold")));
-                table->iSetAutoVacuumAnalyzeScaleFactor(tables->GetVal(wxT("autovacuum_analyze_scale_factor")));
-                table->iSetAutoVacuumVacuumCostDelay(tables->GetVal(wxT("autovacuum_vacuum_cost_delay")));
-                table->iSetAutoVacuumVacuumCostLimit(tables->GetVal(wxT("autovacuum_vacuum_cost_limit")));
-                table->iSetAutoVacuumFreezeMinAge(tables->GetVal(wxT("autovacuum_freeze_min_age")));
-                table->iSetAutoVacuumFreezeMaxAge(tables->GetVal(wxT("autovacuum_freeze_max_age")));
-                table->iSetAutoVacuumFreezeTableAge(tables->GetVal(wxT("autovacuum_freeze_table_age")));
+                table->iSetRelOptions(tables->GetVal(wxT("reloptions")));
+                if (table->GetCustomAutoVacuumEnabled()) 
+                {
+                    if (tables->GetVal(wxT("autovacuum_enabled")).IsEmpty())
+                        table->iSetAutoVacuumEnabled(2);
+                    else if (tables->GetBool(wxT("autovacuum_enabled")))
+                        table->iSetAutoVacuumEnabled(1);
+                    else
+                        table->iSetAutoVacuumEnabled(0);
+                    table->iSetAutoVacuumVacuumThreshold(tables->GetVal(wxT("autovacuum_vacuum_threshold")));
+                    table->iSetAutoVacuumVacuumScaleFactor(tables->GetVal(wxT("autovacuum_vacuum_scale_factor")));
+                    table->iSetAutoVacuumAnalyzeThreshold(tables->GetVal(wxT("autovacuum_analyze_threshold")));
+                    table->iSetAutoVacuumAnalyzeScaleFactor(tables->GetVal(wxT("autovacuum_analyze_scale_factor")));
+                    table->iSetAutoVacuumVacuumCostDelay(tables->GetVal(wxT("autovacuum_vacuum_cost_delay")));
+                    table->iSetAutoVacuumVacuumCostLimit(tables->GetVal(wxT("autovacuum_vacuum_cost_limit")));
+                    table->iSetAutoVacuumFreezeMinAge(tables->GetVal(wxT("autovacuum_freeze_min_age")));
+                    table->iSetAutoVacuumFreezeMaxAge(tables->GetVal(wxT("autovacuum_freeze_max_age")));
+                    table->iSetAutoVacuumFreezeTableAge(tables->GetVal(wxT("autovacuum_freeze_table_age")));
+                }
                 table->iSetHasToastTable(tables->GetBool(wxT("hastoasttable")));
+                if (table->GetHasToastTable())
+                {
+                    pgSet *set = collection->GetDatabase()->ExecuteSet(
+                      wxT("SELECT \n")
+                      wxT("  substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') AS autovacuum_enabled \n")
+                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold \n")
+                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_vacuum_scale_factor \n")
+                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold \n")
+                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_analyze_scale_factor \n")
+                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay \n")
+                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit \n")
+                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age \n")
+                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age \n")
+                      wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age \n")
+                      wxT(", rel.reloptions AS reloptions \n")
+                      wxT("FROM pg_catalog.pg_class rel \n")
+                      wxT("WHERE rel.oid=(SELECT org_tbl.reltoastrelid FROM pg_catalog.pg_class org_tbl WHERE org_tbl.oid=")
+                      + table->GetOidStr() + wxT(")"));
+                    if (set)
+                    {
+                        table->iSetToastRelOptions(set->GetVal(wxT("reloptions")));
+                        if (table->GetToastCustomAutoVacuumEnabled())
+                        {
+                            if (set->GetVal(wxT("autovacuum_enabled")).IsEmpty())
+                                table->iSetToastAutoVacuumEnabled(2);
+                            else if (set->GetBool(wxT("autovacuum_enabled")))
+                                table->iSetToastAutoVacuumEnabled(1);
+                            else
+                                table->iSetToastAutoVacuumEnabled(0);
+                            table->iSetToastAutoVacuumVacuumThreshold(set->GetVal(wxT("autovacuum_vacuum_threshold")));
+                            table->iSetToastAutoVacuumVacuumScaleFactor(set->GetVal(wxT("autovacuum_vacuum_scale_factor")));
+                            table->iSetToastAutoVacuumAnalyzeThreshold(set->GetVal(wxT("autovacuum_analyze_threshold")));
+                            table->iSetToastAutoVacuumAnalyzeScaleFactor(set->GetVal(wxT("autovacuum_analyze_scale_factor")));
+                            table->iSetToastAutoVacuumVacuumCostDelay(set->GetVal(wxT("autovacuum_vacuum_cost_delay")));
+                            table->iSetToastAutoVacuumVacuumCostLimit(set->GetVal(wxT("autovacuum_vacuum_cost_limit")));
+                            table->iSetToastAutoVacuumFreezeMinAge(set->GetVal(wxT("autovacuum_freeze_min_age")));
+                            table->iSetToastAutoVacuumFreezeMaxAge(set->GetVal(wxT("autovacuum_freeze_max_age")));
+                            table->iSetToastAutoVacuumFreezeTableAge(set->GetVal(wxT("autovacuum_freeze_table_age")));
+
+                        }
+                        delete set;
+                        set = 0;
+                    }
+                }
             }
             table->iSetHasSubclass(tables->GetBool(wxT("relhassubclass")));
             table->iSetPrimaryKeyName(tables->GetVal(wxT("conname")));
Index: dlg/dlgTable.cpp
===================================================================
--- dlg/dlgTable.cpp	(revision 7607)
+++ dlg/dlgTable.cpp	(working copy)
@@ -513,7 +513,10 @@
         }
         else if (table)
         {
-            tableVacEnabled = table->GetAutoVacuumEnabled();
+            if (table->GetAutoVacuumEnabled() == 2)
+                tableVacEnabled = settingAutoVacuum;
+            else
+                tableVacEnabled = table->GetAutoVacuumEnabled() == 1;
             if (!table->GetAutoVacuumVacuumThreshold().IsEmpty())
                 table->GetAutoVacuumVacuumThreshold().ToLong(&tableVacBaseThr);
             if (!table->GetAutoVacuumAnalyzeThreshold().IsEmpty())
@@ -538,73 +541,40 @@
 
             toastTableVacEnabled = false;
 
-            if (connection->BackendMinimumVersion(8,4))
+            if (!table->GetHasToastTable())
             {
-                if (!table->GetHasToastTable())
-                {
                 nbVaccum->GetPage(1)->Enable(false);
-                }
-                else
-                {
-                    pgSet *set = connection->ExecuteSet(
-                        wxT("SELECT \n")
-                        wxT("  substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') AS autovacuum_enabled \n")
-                        wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold \n")
-                        wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_vacuum_scale_factor \n")
-                        wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold \n")
-                        wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_analyze_scale_factor \n")
-                        wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay \n")
-                        wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit \n")
-                        wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age \n")
-                        wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age \n")
-                        wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age \n")
-                        wxT(", rel.reloptions AS hasautovacuum \n")
-                        wxT("FROM pg_catalog.pg_class rel \n")
-                        wxT("WHERE rel.oid=(SELECT org_tbl.reltoastrelid FROM pg_catalog.pg_class org_tbl WHERE org_tbl.oid=")
-                        + table->GetOidStr() + wxT(")"));
-
-                    if (set)
-                    {
-                        wxString val;
-
-                        val = set->GetVal(wxT("hasautovacuum"));
-                        if (!val.IsEmpty())
-                            toastTableHasVacuum = true;
-
-                        if (toastTableHasVacuum)
-                        {
-                            toastTableVacEnabled = set->GetBool(wxT("autovacuum_enabled"));
-                            val = set->GetVal(wxT("autovacuum_vacuum_threshold"));
-                            if (!val.IsEmpty())
-                                val.ToLong(&toastTableVacBaseThr);
-                            val = set->GetVal(wxT("autovacuum_vacuum_scale_factor"));
-                            if (!val.IsEmpty())
-                                val.ToDouble(&toastTableVacFactor);
-                            val = set->GetVal(wxT("autovacuum_analyze_threshold"));
-                            if (!val.IsEmpty())
-                                val.ToLong(&toastTableAnlBaseThr);
-                            val = set->GetVal(wxT("autovacuum_analyze_scale_factor"));
-                            if (!val.IsEmpty())
-                                val.ToDouble(&toastTableAnlFactor);
-                            val = set->GetVal(wxT("autovacuum_vacuum_cost_delay"));
-                            if (!val.IsEmpty())
-                                val.ToLong(&toastTableCostDelay);
-                            val = set->GetVal(wxT("autovacuum_vacuum_cost_limit"));
-                            if (!val.IsEmpty())
-                                val.ToLong(&toastTableCostLimit);
-                            val = set->GetVal(wxT("autovacuum_freeze_min_age"));
-                            if (!val.IsEmpty())
-                                val.ToLong(&toastTableFreezeMinAge);
-                            val = set->GetVal(wxT("autovacuum_freeze_max_age"));
-                            if (!val.IsEmpty())
-                                val.ToLong(&toastTableFreezeMaxAge);
-                            val = set->GetVal(wxT("autovacuum_freeze_table_age"));
-                            if (!val.IsEmpty())
-                                val.ToLong(&toastTableFreezeTableAge);
-                        }
-                    }
-                }
             }
+            else
+            {
+               toastTableHasVacuum = table->GetToastCustomAutoVacuumEnabled();
+               if (toastTableHasVacuum)
+               {
+                   if (table->GetToastAutoVacuumEnabled() == 2)
+                       toastTableVacEnabled = settingAutoVacuum;
+                   else
+                       toastTableVacEnabled  = table->GetToastAutoVacuumEnabled() == 1;
+                   if (!table->GetToastAutoVacuumVacuumThreshold().IsEmpty())
+                       table->GetToastAutoVacuumVacuumThreshold().ToLong(&toastTableVacBaseThr);
+                   if (!table->GetToastAutoVacuumAnalyzeThreshold().IsEmpty())
+                       table->GetToastAutoVacuumAnalyzeThreshold().ToLong(&toastTableAnlBaseThr);
+                   if (!table->GetToastAutoVacuumVacuumScaleFactor().IsEmpty())
+                       table->GetToastAutoVacuumVacuumScaleFactor().ToDouble(&toastTableVacFactor);
+                   if (!table->GetToastAutoVacuumAnalyzeScaleFactor().IsEmpty())
+                       table->GetToastAutoVacuumAnalyzeScaleFactor().ToDouble(&toastTableAnlFactor);
+                   if (!table->GetToastAutoVacuumVacuumCostDelay().IsEmpty())
+                       table->GetToastAutoVacuumVacuumCostDelay().ToLong(&toastTableCostDelay);
+                   if (!table->GetToastAutoVacuumVacuumCostLimit().IsEmpty())
+                       table->GetToastAutoVacuumVacuumCostLimit().ToLong(&toastTableCostLimit);
+                   if (!table->GetToastAutoVacuumFreezeMinAge().IsEmpty())
+                       table->GetToastAutoVacuumFreezeMinAge().ToLong(&toastTableFreezeMinAge);
+                   if (!table->GetToastAutoVacuumFreezeMaxAge().IsEmpty())
+                       table->GetToastAutoVacuumFreezeMaxAge().ToLong(&toastTableFreezeMaxAge);
+                   if (!table->GetToastAutoVacuumFreezeTableAge().IsEmpty())
+                       table->GetToastAutoVacuumFreezeTableAge().ToLong(&toastTableFreezeTableAge);
+               }
+               chkToastVacEnabled->SetValue(toastTableHasVacuum ? toastTableVacEnabled : settingAutoVacuum);
+            }
         }
         else
         {
-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to