1 ////////////////////////////////////////////////////////////////////////// 2 // 3 // pgAdmin III - PostgreSQL Tools 4 // 5 // Copyright (C) 2002 - 2016, The pgAdmin Development Team 6 // This software is released under the PostgreSQL Licence 7 // 8 // pgView.h PostgreSQL View 9 // 10 ////////////////////////////////////////////////////////////////////////// 11 12 #ifndef PGVIEW_H 13 #define PGVIEW_H 14 15 #include "pgRule.h" 16 17 class pgCollection; 18 19 class pgViewFactory : public pgSchemaObjFactory 20 { 21 public: 22 pgViewFactory(); 23 virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent); 24 virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr = wxEmptyString); 25 virtual pgCollection *CreateCollection(pgObject *obj); GetMaterializedIconId()26 int GetMaterializedIconId() 27 { 28 return WantSmallIcon() ? smallMaterializedId : materializedId; 29 } 30 31 protected: 32 int materializedId, smallMaterializedId; 33 34 }; 35 extern pgViewFactory viewFactory; 36 37 38 class pgView : public pgRuleObject 39 { 40 public: 41 pgView(pgSchema *newSchema, const wxString &newName = wxT("")); 42 ~pgView(); 43 44 int GetIconId(); 45 46 wxString GetTranslatedMessage(int kindOfMessage) const; 47 void ShowTreeDetail(ctlTree *browser, frmMain *form = 0, ctlListView *properties = 0, ctlSQLBox *sqlPane = 0); CanDropCascaded()48 bool CanDropCascaded() 49 { 50 return !GetSystemObject() && pgSchemaObject::CanDrop(); 51 } 52 53 bool DropObject(wxFrame *frame, ctlTree *browser, bool cascaded); CanCreate()54 bool CanCreate() 55 { 56 return GetSchema()->CanCreate(); 57 } CanView()58 bool CanView() 59 { 60 return true; 61 } WantDummyChild()62 bool WantDummyChild() 63 { 64 return true; 65 } 66 HasInsertRule()67 bool HasInsertRule() 68 { 69 return hasInsertRule; 70 } HasUpdateRule()71 bool HasUpdateRule() 72 { 73 return hasUpdateRule; 74 } HasDeleteRule()75 bool HasDeleteRule() 76 { 77 return hasDeleteRule; 78 } GetSecurityBarrier()79 wxString GetSecurityBarrier() 80 { 81 return security_barrier; 82 } iSetSecurityBarrier(const wxString & s)83 void iSetSecurityBarrier(const wxString &s) 84 { 85 security_barrier = s; 86 } 87 GetTablespace()88 wxString GetTablespace() const 89 { 90 return tablespace; 91 } iSetTablespace(const wxString & newVal)92 void iSetTablespace(const wxString &newVal) 93 { 94 tablespace = newVal; 95 } GetTablespaceOid()96 OID GetTablespaceOid() const 97 { 98 return tablespaceOid; 99 } iSetTablespaceOid(const OID newVal)100 void iSetTablespaceOid(const OID newVal) 101 { 102 tablespaceOid = newVal; 103 } 104 105 wxMenu *GetNewMenu(); 106 wxString GetSql(ctlTree *browser); 107 wxString GetSelectSql(ctlTree *browser); 108 wxString GetInsertSql(ctlTree *browser); 109 wxString GetUpdateSql(ctlTree *browser); 110 pgObject *Refresh(ctlTree *browser, const wxTreeItemId item); 111 void RefreshMatView(bool concurrently); 112 HasStats()113 bool HasStats() 114 { 115 return false; 116 } HasDepends()117 bool HasDepends() 118 { 119 return true; 120 } HasReferences()121 bool HasReferences() 122 { 123 return true; 124 } 125 126 void ShowHint(frmMain *form, bool force); GetCanHint()127 bool GetCanHint() 128 { 129 return true; 130 }; 131 132 bool IsUpToDate(); 133 GetFillFactor()134 wxString GetFillFactor() 135 { 136 return fillFactor; 137 } iSetFillFactor(const wxString & s)138 void iSetFillFactor(const wxString &s) 139 { 140 fillFactor = s; 141 } 142 GetIsPopulated()143 wxString GetIsPopulated() 144 { 145 return isPopulated; 146 } iSetIsPopulated(const wxString & s)147 void iSetIsPopulated(const wxString &s) 148 { 149 isPopulated = s; 150 } 151 GetCheckOption()152 wxString GetCheckOption() 153 { 154 return check_option; 155 } iSetCheckOption(const wxString & s)156 void iSetCheckOption(const wxString &s) 157 { 158 check_option = s; 159 } 160 GetCustomAutoVacuumEnabled()161 bool GetCustomAutoVacuumEnabled() 162 { 163 return !reloptions.IsEmpty(); 164 } GetRelOptions()165 wxString GetRelOptions() 166 { 167 return reloptions; 168 } iSetRelOptions(const wxString & s)169 void iSetRelOptions(const wxString &s) 170 { 171 reloptions = s; 172 } GetAutoVacuumEnabled()173 int GetAutoVacuumEnabled() 174 { 175 return autovacuum_enabled; 176 } iSetAutoVacuumEnabled(int i)177 void iSetAutoVacuumEnabled(int i) 178 { 179 autovacuum_enabled = i; 180 } GetAutoVacuumVacuumThreshold()181 wxString GetAutoVacuumVacuumThreshold() 182 { 183 return autovacuum_vacuum_threshold; 184 } iSetAutoVacuumVacuumThreshold(const wxString & s)185 void iSetAutoVacuumVacuumThreshold(const wxString &s) 186 { 187 autovacuum_vacuum_threshold = s; 188 } GetAutoVacuumVacuumScaleFactor()189 wxString GetAutoVacuumVacuumScaleFactor() 190 { 191 return autovacuum_vacuum_scale_factor; 192 } iSetAutoVacuumVacuumScaleFactor(const wxString & s)193 void iSetAutoVacuumVacuumScaleFactor(const wxString &s) 194 { 195 autovacuum_vacuum_scale_factor = s; 196 } GetAutoVacuumAnalyzeThreshold()197 wxString GetAutoVacuumAnalyzeThreshold() 198 { 199 return autovacuum_analyze_threshold; 200 } iSetAutoVacuumAnalyzeThreshold(const wxString & s)201 void iSetAutoVacuumAnalyzeThreshold(const wxString &s) 202 { 203 autovacuum_analyze_threshold = s; 204 } GetAutoVacuumAnalyzeScaleFactor()205 wxString GetAutoVacuumAnalyzeScaleFactor() 206 { 207 return autovacuum_analyze_scale_factor; 208 } iSetAutoVacuumAnalyzeScaleFactor(const wxString & s)209 void iSetAutoVacuumAnalyzeScaleFactor(const wxString &s) 210 { 211 autovacuum_analyze_scale_factor = s; 212 } GetAutoVacuumVacuumCostDelay()213 wxString GetAutoVacuumVacuumCostDelay() 214 { 215 return autovacuum_vacuum_cost_delay; 216 } iSetAutoVacuumVacuumCostDelay(const wxString & s)217 void iSetAutoVacuumVacuumCostDelay(const wxString &s) 218 { 219 autovacuum_vacuum_cost_delay = s; 220 } GetAutoVacuumVacuumCostLimit()221 wxString GetAutoVacuumVacuumCostLimit() 222 { 223 return autovacuum_vacuum_cost_limit; 224 } iSetAutoVacuumVacuumCostLimit(const wxString & s)225 void iSetAutoVacuumVacuumCostLimit(const wxString &s) 226 { 227 autovacuum_vacuum_cost_limit = s; 228 } GetAutoVacuumFreezeMinAge()229 wxString GetAutoVacuumFreezeMinAge() 230 { 231 return autovacuum_freeze_min_age; 232 } iSetAutoVacuumFreezeMinAge(const wxString & s)233 void iSetAutoVacuumFreezeMinAge(const wxString &s) 234 { 235 autovacuum_freeze_min_age = s; 236 } GetAutoVacuumFreezeMaxAge()237 wxString GetAutoVacuumFreezeMaxAge() 238 { 239 return autovacuum_freeze_max_age; 240 } iSetAutoVacuumFreezeMaxAge(const wxString & s)241 void iSetAutoVacuumFreezeMaxAge(const wxString &s) 242 { 243 autovacuum_freeze_max_age = s; 244 } GetAutoVacuumFreezeTableAge()245 wxString GetAutoVacuumFreezeTableAge() 246 { 247 return autovacuum_freeze_table_age; 248 } iSetAutoVacuumFreezeTableAge(const wxString & s)249 void iSetAutoVacuumFreezeTableAge(const wxString &s) 250 { 251 autovacuum_freeze_table_age = s; 252 } GetHasToastTable()253 bool GetHasToastTable() 254 { 255 return hasToastTable; 256 } iSetHasToastTable(bool b)257 void iSetHasToastTable(bool b) 258 { 259 hasToastTable = b; 260 } 261 262 /* TOAST TABLE autovacuum settings */ GetToastCustomAutoVacuumEnabled()263 bool GetToastCustomAutoVacuumEnabled() 264 { 265 return !toast_reloptions.IsEmpty(); 266 } GetToastRelOptions()267 wxString GetToastRelOptions() 268 { 269 return toast_reloptions; 270 } iSetToastRelOptions(const wxString & s)271 void iSetToastRelOptions(const wxString &s) 272 { 273 toast_reloptions = s; 274 } GetToastAutoVacuumEnabled()275 int GetToastAutoVacuumEnabled() 276 { 277 return toast_autovacuum_enabled; 278 } iSetToastAutoVacuumEnabled(int i)279 void iSetToastAutoVacuumEnabled(int i) 280 { 281 toast_autovacuum_enabled = i; 282 } GetToastAutoVacuumVacuumThreshold()283 wxString GetToastAutoVacuumVacuumThreshold() 284 { 285 return toast_autovacuum_vacuum_threshold; 286 } iSetToastAutoVacuumVacuumThreshold(const wxString & s)287 void iSetToastAutoVacuumVacuumThreshold(const wxString &s) 288 { 289 toast_autovacuum_vacuum_threshold = s; 290 } GetToastAutoVacuumVacuumScaleFactor()291 wxString GetToastAutoVacuumVacuumScaleFactor() 292 { 293 return toast_autovacuum_vacuum_scale_factor; 294 } iSetToastAutoVacuumVacuumScaleFactor(const wxString & s)295 void iSetToastAutoVacuumVacuumScaleFactor(const wxString &s) 296 { 297 toast_autovacuum_vacuum_scale_factor = s; 298 } GetToastAutoVacuumVacuumCostDelay()299 wxString GetToastAutoVacuumVacuumCostDelay() 300 { 301 return toast_autovacuum_vacuum_cost_delay; 302 } iSetToastAutoVacuumVacuumCostDelay(const wxString & s)303 void iSetToastAutoVacuumVacuumCostDelay(const wxString &s) 304 { 305 toast_autovacuum_vacuum_cost_delay = s; 306 } GetToastAutoVacuumVacuumCostLimit()307 wxString GetToastAutoVacuumVacuumCostLimit() 308 { 309 return toast_autovacuum_vacuum_cost_limit; 310 } iSetToastAutoVacuumVacuumCostLimit(const wxString & s)311 void iSetToastAutoVacuumVacuumCostLimit(const wxString &s) 312 { 313 toast_autovacuum_vacuum_cost_limit = s; 314 } GetToastAutoVacuumFreezeMinAge()315 wxString GetToastAutoVacuumFreezeMinAge() 316 { 317 return toast_autovacuum_freeze_min_age; 318 } iSetToastAutoVacuumFreezeMinAge(const wxString & s)319 void iSetToastAutoVacuumFreezeMinAge(const wxString &s) 320 { 321 toast_autovacuum_freeze_min_age = s; 322 } GetToastAutoVacuumFreezeMaxAge()323 wxString GetToastAutoVacuumFreezeMaxAge() 324 { 325 return toast_autovacuum_freeze_max_age; 326 } iSetToastAutoVacuumFreezeMaxAge(const wxString & s)327 void iSetToastAutoVacuumFreezeMaxAge(const wxString &s) 328 { 329 toast_autovacuum_freeze_max_age = s; 330 } GetToastAutoVacuumFreezeTableAge()331 wxString GetToastAutoVacuumFreezeTableAge() 332 { 333 return toast_autovacuum_freeze_table_age; 334 } iSetToastAutoVacuumFreezeTableAge(const wxString & s)335 void iSetToastAutoVacuumFreezeTableAge(const wxString &s) 336 { 337 toast_autovacuum_freeze_table_age = s; 338 } 339 iSetMaterializedView(const bool matView)340 void iSetMaterializedView(const bool matView) 341 { 342 materializedView = matView; 343 } 344 GetMaterializedView()345 bool GetMaterializedView() const 346 { 347 return materializedView; 348 } 349 350 private: 351 wxString GetCols(ctlTree *browser, size_t indent, wxString &QMs, bool withQM); 352 void AppendStuff(wxString &sql, ctlTree *browser, pgaFactory &factory); 353 bool IsMaterializedView(ctlTree *browser); 354 bool hasInsertRule, hasUpdateRule, hasDeleteRule, materializedView; 355 wxString security_barrier; 356 357 int autovacuum_enabled, toast_autovacuum_enabled; 358 wxString reloptions, toast_reloptions; 359 360 wxString fillFactor, autovacuum_vacuum_threshold, 361 autovacuum_vacuum_scale_factor, autovacuum_analyze_threshold, 362 autovacuum_analyze_scale_factor, autovacuum_vacuum_cost_delay, 363 autovacuum_vacuum_cost_limit, autovacuum_freeze_min_age, 364 autovacuum_freeze_max_age, autovacuum_freeze_table_age; 365 366 wxString toast_fillFactor, toast_autovacuum_vacuum_threshold, 367 toast_autovacuum_vacuum_scale_factor, toast_autovacuum_vacuum_cost_delay, 368 toast_autovacuum_vacuum_cost_limit, toast_autovacuum_freeze_min_age, 369 toast_autovacuum_freeze_max_age, toast_autovacuum_freeze_table_age; 370 371 wxString tablespace, isPopulated, check_option; 372 bool hasToastTable; 373 OID tablespaceOid; 374 375 }; 376 377 class pgViewCollection : public pgSchemaObjCollection 378 { 379 public: 380 pgViewCollection(pgaFactory *factory, pgSchema *sch); 381 wxString GetTranslatedMessage(int kindOfMessage) const; 382 }; 383 384 class refreshMatViewFactory : public contextActionFactory 385 { 386 public: 387 refreshMatViewFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar); 388 wxWindow *StartDialog(frmMain *form, pgObject *obj); 389 bool CheckEnable(pgObject *obj); 390 }; 391 392 class refreshConcurrentlyMatViewFactory : public contextActionFactory 393 { 394 public: 395 refreshConcurrentlyMatViewFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar); 396 wxWindow *StartDialog(frmMain *form, pgObject *obj); 397 bool CheckEnable(pgObject *obj); 398 }; 399 400 401 #endif 402