diff --git a/db/pgConn.cpp b/db/pgConn.cpp index 9d27caf..8ecb72d 100644 --- a/db/pgConn.cpp +++ b/db/pgConn.cpp @@ -547,7 +547,7 @@ bool pgConn::HasFeature(int featureNo, bool forceCheck) wxT(" JOIN pg_namespace n ON n.oid=pronamespace\n") wxT(" WHERE proname IN ('pg_tablespace_size', 'pg_file_read', 'pg_logfile_rotate',") wxT( " 'pg_postmaster_starttime', 'pg_terminate_backend', 'pg_reload_conf',") - wxT( " 'pgstattuple', 'pgstatindex')\n") + wxT( " 'pgstattuple', 'pgstatindex','bt_index_parent_check')\n") wxT(" AND nspname IN ('pg_catalog', 'public')"); pgSet *set = ExecuteSet(sql); @@ -577,6 +577,8 @@ bool pgConn::HasFeature(int featureNo, bool forceCheck) features[FEATURE_PGSTATTUPLE] = true; else if (proname == wxT("pgstatindex") && pronargs == 1 && set->GetLong(wxT("arg0")) == 25) features[FEATURE_PGSTATINDEX] = true; + else if (proname == wxT("bt_index_parent_check") && pronargs == 2 ) + features[FEATURE_PGCHECKINDEX] = true; set->MoveNext(); } diff --git a/frm/frmMain.cpp b/frm/frmMain.cpp index c563f42..0a875cb 100644 --- a/frm/frmMain.cpp +++ b/frm/frmMain.cpp @@ -315,6 +315,7 @@ void frmMain::CreateMenus() new refreshConcurrentlyMatViewFactory(menuFactories, viewMenu, 0); new executePgstattupleFactory(menuFactories, viewMenu, 0); new executePgstatindexFactory(menuFactories, viewMenu, 0); + new executePgcheckindexFactory(menuFactories, viewMenu, 0); new enabledisableRuleFactory(menuFactories, toolsMenu, 0); new enabledisableTriggerFactory(menuFactories, toolsMenu, 0); new enabledisableEventTriggerFactory(menuFactories, toolsMenu, 0); diff --git a/include/schema/pgIndex.h b/include/schema/pgIndex.h index 2ee1553..9a56318 100644 --- a/include/schema/pgIndex.h +++ b/include/schema/pgIndex.h @@ -287,6 +287,7 @@ public: return true; } bool HasPgstatindex(); + bool HasPgcheckindex(); protected: void ReadColumnDetails(); @@ -345,6 +346,13 @@ public: bool CheckEnable(pgObject *obj); bool CheckChecked(pgObject *obj); }; +class executePgcheckindexFactory : public contextActionFactory +{ +public: + executePgcheckindexFactory(menuFactoryList* list, wxMenu* mnu, ctlMenuToolbar* toolbar); + wxWindow* StartDialog(frmMain* form, pgObject* obj); + bool CheckEnable(pgObject* obj); +}; #endif diff --git a/include/utils/pgfeatures.h b/include/utils/pgfeatures.h index 0e68e38..d3b2381 100644 --- a/include/utils/pgfeatures.h +++ b/include/utils/pgfeatures.h @@ -24,6 +24,7 @@ enum FEATURE_RELOAD_CONF, FEATURE_PGSTATTUPLE, FEATURE_PGSTATINDEX, + FEATURE_PGCHECKINDEX, FEATURE_FUNCTION_DEFAULTS, FEATURE_LAST }; diff --git a/schema/pgIndex.cpp b/schema/pgIndex.cpp index 47538b2..1e4ff18 100644 --- a/schema/pgIndex.cpp +++ b/schema/pgIndex.cpp @@ -473,6 +473,36 @@ bool pgIndexBase::HasPgstatindex() return GetConnection()->HasFeature(FEATURE_PGSTATINDEX); } +bool pgIndexBase::HasPgcheckindex() +{ + return GetConnection()->HasFeature(FEATURE_PGCHECKINDEX); +} + +executePgcheckindexFactory::executePgcheckindexFactory(menuFactoryList* list, wxMenu* mnu, ctlMenuToolbar* toolbar) : contextActionFactory(list) +{ + mnu->Append(id, _("Check Btree index"), _("Check Btree index function bt_index_parent_check(oid,true)")); +} + + +wxWindow* executePgcheckindexFactory::StartDialog(frmMain* form, pgObject* obj) +{ + pgIndexBase* i = (pgIndexBase*)obj; + form->StartMsg(_("Check Btree index "+i->GetName()+" ")); + wxString sql = "SELECT bt_index_parent_check("+i->GetOidStr()+",true);"; + i->GetConnection()->ExecuteVoid(sql); + form->EndMsg(true); + return 0; +} + + +bool executePgcheckindexFactory::CheckEnable(pgObject* obj) +{ + + return obj && + (obj->IsCreatedBy(indexFactory) || obj->IsCreatedBy(primaryKeyFactory) + || obj->IsCreatedBy(uniqueFactory) || obj->IsCreatedBy(excludeFactory)) && ((pgIndexBase*)obj)->GetIndexType()=="btree" && + ((pgIndexBase*)obj)->HasPgcheckindex(); +} executePgstatindexFactory::executePgstatindexFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar) : contextActionFactory(list) {