void SQLiteSQLPlugin::detach(const std::string& name) { auto dbc = SQLiteDBManager::get(); if (!dbc->isPrimary()) { return; } detachTableInternal(name, dbc->db()); }
SQLiteDBInstance::~SQLiteDBInstance() { if (!isPrimary()) { sqlite3_close(db_); } else { db_ = nullptr; } }
boolean joinRequired(char *db, char *table, struct slName *fieldList, struct joinerDtf **pDtfList, struct joinerDtf **pFilterTables) /* Given a list of db.table.field values, determine whether a joining query * will be required. Consider not only the tables to be queried but also * the tables to be filtered (which can be a different set). If db.table * is not the primary db.table in the search, no tables are to be filtered. * If pDtfList is not null, make it point to the list of joinerDtfs * derived from fieldList. * If pFilterTables is not null, make it point to the list of joinerDtfs * containing the dbs and tables (but not fields) of tables to be filtered. */ { struct joinerDtf *dtfList = fieldsToDtfs(fieldList); struct joinerDtf *filterTables = filteringTables(); boolean ret = FALSE; /* Ignore filterTables() if this query is not on the primary table. */ if (! isPrimary(db, table)) joinerDtfFreeList(&filterTables); ret = (! allSameTable(dtfList, filterTables)); if (pDtfList != NULL) *pDtfList = dtfList; else joinerDtfFreeList(&dtfList); if (pFilterTables != NULL) *pFilterTables = filterTables; else joinerDtfFreeList(&filterTables); return ret; }
ContactSection ContactSection::add_scope( const std::shared_ptr<ContactItem>& item) const { OT_ASSERT(item); auto scope = item; bool needsPrimary{true}; const auto& groupID = scope->Type(); GroupMap groups = groups_; const auto& group = groups[groupID]; if (group) { needsPrimary = (1 > group->Size()); } if (needsPrimary && false == scope->isPrimary()) { scope.reset(new ContactItem(scope->SetPrimary(true))); } if (false == scope->isActive()) { scope.reset(new ContactItem(scope->SetActive(true))); } groups[groupID].reset(new ContactGroup(nym_, section_, scope)); auto version = proto::RequiredVersion(section_, item->Type(), version_); return ContactSection(nym_, version, version, section_, groups); }
TableAttributes SQLiteDBInstance::getAttributes() const { const SQLiteDBInstance* rdbc = this; if (isPrimary() && !managed_) { // Similarly to clearAffectedTables, the connection may be forwarded. rdbc = SQLiteDBManager::getConnection(true).get(); } TableAttributes attributes = TableAttributes::NONE; for (const auto& table : rdbc->affected_tables_) { attributes = table.second->attributes | attributes; } return attributes; }
void SQLiteDBInstance::clearAffectedTables() { if (isPrimary() && !managed_) { // A primary instance must forward clear requests to the DB manager's // 'connection' instance. This is a temporary primary instance. SQLiteDBManager::getConnection(true)->clearAffectedTables(); return; } for (const auto& table : affected_tables_) { table.second->constraints.clear(); table.second->cache.clear(); } // Since the affected tables are cleared, there are no more affected tables. // There is no concept of compounding tables between queries. affected_tables_.clear(); }
PointerEvent* PointerEventFactory::createPointerCancelEvent( const int pointerId, const WebPointerProperties::PointerType pointerType) { DCHECK(m_pointerIdMapping.contains(pointerId)); m_pointerIdMapping.set( pointerId, PointerAttributes(m_pointerIdMapping.get(pointerId).incomingId, false)); PointerEventInit pointerEventInit; pointerEventInit.setPointerId(pointerId); pointerEventInit.setPointerType( pointerTypeNameForWebPointPointerType(pointerType)); pointerEventInit.setIsPrimary(isPrimary(pointerId)); setEventSpecificFields(pointerEventInit, EventTypeNames::pointercancel); return PointerEvent::create(EventTypeNames::pointercancel, pointerEventInit); }
void P3ReplicationGroup::open() throw (ServiceException&) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::open()()\n"))); m_closed = false; list<QoSEndpoint> qosList; //QoSEndpoint hrt(QoS::HRT, CPUQoS::MED_RT_PRIO); QoSEndpoint hrt(QoS::HRT, CPUQoS::MAX_RT_PRIO); qosList.push_back(hrt); String itf; if (!P3Configuration::instance()->lookupValue("DEFAULT_INTERFACE", itf)) { throw ServiceException(ServiceException::INVALID_ARGUMENT); } m_dataSAP.open(itf, qosList); if (isPrimary()) { //open as primary openPrimary(); } else { //open as replica openReplica(); } }
SQLiteDBInstanceRef SQLiteDBManager::getConnection(bool primary) { auto& self = instance(); std::unique_lock<std::mutex> lock(self.create_mutex_); if (self.db_ == nullptr) { // Create primary SQLite DB instance. openOptimized(self.db_); self.connection_ = SQLiteDBInstanceRef(new SQLiteDBInstance(self.db_)); attachVirtualTables(self.connection_); } // Internal usage may request the primary connection explicitly. if (primary) { return self.connection_; } // Create a 'database connection' for the managed database instance. auto instance = std::make_shared<SQLiteDBInstance>(self.db_, self.mutex_); if (!instance->isPrimary()) { attachVirtualTables(instance); } return instance; }
void PointerEventFactory::setIdTypeButtons( PointerEventInit& pointerEventInit, const WebPointerProperties& pointerProperties, unsigned buttons) { const WebPointerProperties::PointerType pointerType = pointerProperties.pointerType; const IncomingId incomingId(pointerType, pointerProperties.id); int pointerId = addIdAndActiveButtons(incomingId, buttons != 0); // Tweak the |buttons| to reflect pen eraser mode only if the pen is in // active buttons state w/o even considering the eraser button. // TODO(mustaq): Fix when the spec starts supporting hovering erasers. if (pointerType == WebPointerProperties::PointerType::Eraser && buttons != 0) { buttons |= static_cast<unsigned>(WebPointerProperties::Buttons::Eraser); buttons &= ~static_cast<unsigned>(WebPointerProperties::Buttons::Left); } pointerEventInit.setButtons(buttons); pointerEventInit.setPointerId(pointerId); pointerEventInit.setPointerType( pointerTypeNameForWebPointPointerType(pointerType)); pointerEventInit.setIsPrimary(isPrimary(pointerId)); }