int pgCheck::GetIconId() { if (!GetDatabase()->BackendMinimumVersion(9, 2) || GetValid()) return checkFactory.GetIconId(); else return checkFactory.GetClosedIconId(); }
int pgForeignKey::GetIconId() { if (!GetDatabase()->BackendMinimumVersion(9, 1) || GetValid()) return foreignKeyFactory.GetIconId(); else return foreignKeyFactory.GetClosedIconId(); }
wxString pgForeignKey::GetDefinition() { wxString sql; sql = wxT("(") + GetQuotedFkColumns() + wxT(")\n REFERENCES ") + GetQuotedSchemaPrefix(GetRefSchema()) + qtIdent(GetReferences()) + wxT(" (") + GetQuotedRefColumns() + wxT(")"); if (GetDatabase()->BackendMinimumVersion(7, 4) || GetMatch() == wxT("FULL")) sql += wxT(" MATCH ") + GetMatch(); sql += wxT("\n ON UPDATE ") + GetOnUpdate() + wxT(" ON DELETE ") + GetOnDelete(); if (GetDeferrable()) { sql += wxT(" DEFERRABLE INITIALLY "); if (GetDeferred()) sql += wxT("DEFERRED"); else sql += wxT("IMMEDIATE"); } if (GetDatabase()->BackendMinimumVersion(9, 1) && !GetValid()) sql += wxT("\n NOT VALID"); return sql; }
wxString pgCheck::GetConstraint() { sql = GetQuotedIdentifier() + wxT(" CHECK "); sql += wxT("(") + GetDefinition() + wxT(")"); if (GetDatabase()->BackendMinimumVersion(9, 2) && GetNoInherit()) sql += wxT(" NO INHERIT"); if (GetDatabase()->BackendMinimumVersion(9, 2) && !GetValid()) sql += wxT(" NOT VALID"); return sql; }
bool LLBBox::IntersectIn( const LLBBox &other ) const { if( !GetValid() || !other.GetValid() ) return false; if((m_maxlat <= other.m_maxlat) || (m_minlat >= other.m_minlat)) return false; double minlon = m_minlon, maxlon = m_maxlon; if(m_maxlon < other.m_minlon) minlon += 360, maxlon += 360; else if(m_minlon > other.m_maxlon) minlon -= 360, maxlon -= 360; return (other.m_minlon > minlon) && (other.m_maxlon < maxlon); }
bool LLBBox::IntersectOutGetBias( const LLBBox &other, double bias ) const { // allow -180 to 180 or 0 to 360 if( !GetValid() || !other.GetValid() ) return true; if((m_maxlat < other.m_minlat) || (m_minlat > other.m_maxlat)) return true; if(m_maxlon < other.m_minlon) bias = 360; else if(m_minlon > other.m_maxlon) bias = -360; else bias = 0; return (m_minlon + bias > other.m_maxlon) || (m_maxlon + bias < other.m_minlon); }
void pgCheck::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Definition"), GetDefinition()); if (GetDatabase()->BackendMinimumVersion(9, 2)) { properties->AppendItem(_("No Inherit?"), BoolToYesNo(GetNoInherit())); properties->AppendItem(_("Valid?"), BoolToYesNo(GetValid())); } // Check constraints on a domain don't have comments if (objectKind.Upper() == wxT("TABLE")) properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void pgForeignKey::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids) { expandedKids = true; wxStringTokenizer c1l(GetConkey(), wxT(",")); wxStringTokenizer c2l(GetConfkey(), wxT(",")); wxString c1, c2; // resolve column names while (c1l.HasMoreTokens()) { c1 = c1l.GetNextToken(); c2 = c2l.GetNextToken(); pgSet *set = ExecuteSet( wxT("SELECT a1.attname as conattname, a2.attname as confattname\n") wxT(" FROM pg_attribute a1, pg_attribute a2\n") wxT(" WHERE a1.attrelid=") + GetTableOidStr() + wxT(" AND a1.attnum=") + c1 + wxT("\n") wxT(" AND a2.attrelid=") + GetRelTableOidStr() + wxT(" AND a2.attnum=") + c2); if (set) { if (!fkColumns.IsNull()) { fkColumns += wxT(", "); refColumns += wxT(", "); quotedFkColumns += wxT(", "); quotedRefColumns += wxT(", "); } fkColumns += set->GetVal(0); refColumns += set->GetVal(1); quotedFkColumns += qtIdent(set->GetVal(0)); quotedRefColumns += qtIdent(set->GetVal(1)); delete set; } } wxTreeItemId item = browser->GetItemParent(GetId()); while (item) { pgTable *table = (pgTable *)browser->GetObject(item); if (table->IsCreatedBy(tableFactory)) { coveringIndex = table->GetCoveringIndex(browser, fkColumns); break; } item = browser->GetItemParent(item); } } if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), NumToStr(GetOid())); properties->AppendItem(_("Child columns"), GetFkColumns()); properties->AppendItem(_("References"), GetReferences() + wxT("(") + GetRefColumns() + wxT(")")); properties->AppendItem(_("Covering index"), GetCoveringIndex()); properties->AppendItem(_("Match type"), GetMatch()); properties->AppendItem(_("On update"), GetOnUpdate()); properties->AppendItem(_("On delete"), GetOnDelete()); properties->AppendItem(_("Deferrable?"), BoolToYesNo(GetDeferrable())); if (GetDeferrable()) properties->AppendItem(_("Initially?"), GetDeferred() ? wxT("DEFERRED") : wxT("IMMEDIATE")); if (GetDatabase()->BackendMinimumVersion(9, 1)) properties->AppendItem(_("Valid?"), BoolToYesNo(GetValid())); properties->AppendItem(_("System foreign key?"), BoolToYesNo(GetSystemObject())); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }