void pgView::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids) { expandedKids = true; browser->RemoveDummyChild(this); browser->AppendCollection(this, columnFactory); pgCollection *collection = browser->AppendCollection(this, ruleFactory); collection->iSetOid(GetOid()); collection->ShowTreeDetail(browser); treeObjectIterator colIt(browser, collection); pgRule *rule; while (!hasInsertRule && !hasUpdateRule && !hasDeleteRule && (rule = (pgRule *)colIt.GetNextObject()) != 0) { if (rule->GetEvent().Find(wxT("INSERT")) >= 0) hasInsertRule = true; if (rule->GetEvent().Find(wxT("UPDATE")) >= 0) hasUpdateRule = true; if (rule->GetEvent().Find(wxT("DELETE")) >= 0) hasDeleteRule = true; } if (GetConnection()->BackendMinimumVersion(9, 1)) browser->AppendCollection(this, triggerFactory); } if (properties) { CreateListColumns(properties); wxString def = GetDefinition().Left(250); def.Replace(wxT("\n"), wxT(" ")); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("ACL"), GetAcl()); properties->AppendItem(_("Definition"), def); properties->AppendYesNoItem(_("System view?"), GetSystemObject()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); if (GetConnection()->BackendMinimumVersion(9, 2) && GetSecurityBarrier().Length() > 0) properties->AppendItem(_("Security barrier?"), GetSecurityBarrier()); if (!GetLabels().IsEmpty()) { wxArrayString seclabels = GetProviderLabelArray(); if (seclabels.GetCount() > 0) { for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2) { properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1)); } } } } }
void BackendStatsContext::Reset() { txn_latencies_.Reset(); for (auto& database_item : database_metrics_) { database_item.second->Reset(); } for (auto& table_item : table_metrics_) { table_item.second->Reset(); } for (auto id : index_ids_) { std::shared_ptr<IndexMetric> index_metric; index_metrics_.Find(id, index_metric); index_metric->Reset(); } oid_t num_databases = catalog::Catalog::GetInstance()->GetDatabaseCount(); for (oid_t i = 0; i < num_databases; ++i) { auto database = catalog::Catalog::GetInstance()->GetDatabaseWithOffset(i); oid_t database_id = database->GetOid(); // Reset database metrics if (database_metrics_.find(database_id) == database_metrics_.end()) { database_metrics_[database_id] = std::unique_ptr<DatabaseMetric>( new DatabaseMetric{DATABASE_METRIC, database_id}); } // Reset table metrics oid_t num_tables = database->GetTableCount(); for (oid_t j = 0; j < num_tables; ++j) { auto table = database->GetTable(j); oid_t table_id = table->GetOid(); if (table_metrics_.find(table_id) == table_metrics_.end()) { table_metrics_[table_id] = std::unique_ptr<TableMetric>( new TableMetric{TABLE_METRIC, database_id, table_id}); } // Reset indexes metrics oid_t num_indexes = table->GetIndexCount(); for (oid_t k = 0; k < num_indexes; ++k) { auto index = table->GetIndex(k); oid_t index_id = index->GetOid(); if (index_metrics_.Contains(index_id) == false) { std::shared_ptr<IndexMetric> index_metric( new IndexMetric{INDEX_METRIC, database_id, table_id, index_id}); index_metrics_.Insert(index_id, index_metric); index_ids_.insert(index_id); } } } } }
void Database::UpdateStats() const { LOG_INFO("Update All Stats in Database(%lu)", database_oid); for (oid_t table_offset = 0; table_offset < GetTableCount(); table_offset++) { auto table = GetTable(table_offset); bridge::Bridge::SetNumberOfTuples(table->GetOid(), table->GetNumberOfTuples()); for (oid_t index_offset = 0; index_offset < table->GetIndexCount(); index_offset++) { auto index = table->GetIndex(index_offset); bridge::Bridge::SetNumberOfTuples(index->GetOid(), index->GetNumberOfTuples()); } } }
void pgForeignServer::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids) { expandedKids = true; browser->RemoveDummyChild(this); // Log wxLogInfo(wxT("Adding child object to foreign server %s"), GetIdentifier().c_str()); if (settings->GetDisplayOption(_("User Mappings"))) browser->AppendCollection(this, userMappingFactory); } if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("ACL"), GetAcl()); properties->AppendItem(_("Type"), GetType()); properties->AppendItem(_("Version"), GetVersion()); properties->AppendItem(_("Options"), GetOptions()); } }
TEST_F(LoggingTests, BasicDeleteTest) { auto recovery_table = ExecutorTestsUtil::CreateTable(1024); auto &manager = catalog::Manager::GetInstance(); storage::Database db(DEFAULT_DB_ID); manager.AddDatabase(&db); db.AddTable(recovery_table); EXPECT_EQ(recovery_table->GetNumberOfTuples(), 0); EXPECT_EQ(recovery_table->GetTileGroupCount(), 1); logging::WriteAheadFrontendLogger fel(true); cid_t test_commit_id = 10; auto curr_rec = new logging::TupleRecord( LOGRECORD_TYPE_TUPLE_UPDATE, test_commit_id, recovery_table->GetOid(), INVALID_ITEMPOINTER, ItemPointer(100, 4), nullptr, DEFAULT_DB_ID); fel.DeleteTuple(curr_rec); delete curr_rec; auto tg_header = recovery_table->GetTileGroupById(100)->GetHeader(); EXPECT_EQ(tg_header->GetEndCommitId(4), test_commit_id); // EXPECT_EQ(recovery_table->GetNumberOfTuples(), 1); EXPECT_EQ(recovery_table->GetTileGroupCount(), 2); }
void edbPackage::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids) { expandedKids=true; browser->RemoveDummyChild(this); // Log wxLogInfo(wxT("Adding child object to package %s"), GetIdentifier().c_str()); browser->AppendCollection(this, packageFunctionFactory); browser->AppendCollection(this, packageProcedureFactory); browser->AppendCollection(this, packageVariableFactory); } if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("Header"), firstLineOnly(GetHeader())); properties->AppendItem(_("Body"), firstLineOnly(GetBody())); properties->AppendItem(_("ACL"), GetAcl()); properties->AppendItem(_("System package?"), GetSystemObject()); if (GetConnection()->EdbMinimumVersion(8, 2)) properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void StatsAggregator::UpdateTableMetrics(storage::Database *database, int64_t time_stamp, concurrency::Transaction *txn) { // Get the target table metrics table auto database_oid = database->GetOid(); auto table_metrics_table = GetMetricTable(TABLE_METRIC_NAME); // Update table metrics table for each of the indices auto table_count = database->GetTableCount(); for (oid_t table_offset = 0; table_offset < table_count; table_offset++) { auto table = database->GetTable(table_offset); auto table_oid = table->GetOid(); auto table_metrics = aggregated_stats_.GetTableMetric(database_oid, table_oid); auto table_access = table_metrics->GetTableAccess(); auto reads = table_access.GetReads(); auto updates = table_access.GetUpdates(); auto deletes = table_access.GetDeletes(); auto inserts = table_access.GetInserts(); // Generate and insert the tuple auto table_tuple = catalog::GetTableMetricsCatalogTuple( table_metrics_table->GetSchema(), database_oid, table_oid, reads, updates, deletes, inserts, time_stamp); catalog::InsertTuple(table_metrics_table, std::move(table_tuple), txn); LOG_TRACE("Table Metric Tuple inserted"); UpdateIndexMetrics(database, table, time_stamp, txn); } }
void pgLanguage::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); if (GetConnection()->BackendMinimumVersion(8, 3)) properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("ACL"), GetAcl()); properties->AppendYesNoItem(_("Trusted?"), GetTrusted()); properties->AppendItem(_("Handler function"), GetHandlerProc()); if (GetConnection()->BackendMinimumVersion(9, 0)) properties->AppendItem(_("Inline function"), GetInlineProc()); properties->AppendItem(_("Validator function"), GetValidatorProc()); properties->AppendYesNoItem(_("System language?"), GetSystemObject()); if (GetConnection()->BackendMinimumVersion(7, 5)) properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); if (!GetLabels().IsEmpty()) { wxArrayString seclabels = GetProviderLabelArray(); if (seclabels.GetCount() > 0) { for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2) { properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1)); } } } } }
void StatsAggregator::UpdateIndexMetrics(storage::Database *database, storage::DataTable *table, int64_t time_stamp, concurrency::Transaction *txn) { // Get the target index metrics table auto index_metrics_table = GetMetricTable(INDEX_METRIC_NAME); // Update index metrics table for each of the indices auto database_oid = database->GetOid(); auto table_oid = table->GetOid(); auto index_count = table->GetIndexCount(); for (oid_t index_offset = 0; index_offset < index_count; index_offset++) { auto index = table->GetIndex(index_offset); auto index_oid = index->GetOid(); auto index_metric = aggregated_stats_.GetIndexMetric(database_oid, table_oid, index_oid); auto index_access = index_metric->GetIndexAccess(); auto reads = index_access.GetReads(); auto deletes = index_access.GetDeletes(); auto inserts = index_access.GetInserts(); // Generate and insert the tuple auto index_tuple = catalog::GetIndexMetricsCatalogTuple( index_metrics_table->GetSchema(), database_oid, table_oid, index_oid, reads, deletes, inserts, time_stamp); catalog::InsertTuple(index_metrics_table, std::move(index_tuple), txn); } }
void pgSequence::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { UpdateValues(); if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("ACL"), GetAcl()); properties->AppendItem(_("Current value"), GetLastValue()); properties->AppendItem(_("Next value"), GetNextValue()); properties->AppendItem(_("Minimum"), GetMinValue()); properties->AppendItem(_("Maximum"), GetMaxValue()); properties->AppendItem(_("Increment"), GetIncrement()); properties->AppendItem(_("Cache"), GetCacheValue()); properties->AppendYesNoItem(_("Cycled?"), GetCycled()); properties->AppendYesNoItem(_("Called?"), GetCalled()); properties->AppendYesNoItem(_("System sequence?"), GetSystemObject()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); if (!GetLabels().IsEmpty()) { wxArrayString seclabels = GetProviderLabelArray(); if (seclabels.GetCount() > 0) { for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2) { properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1)); } } } } }
void pgOperator::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("Kind"), GetKind()); if (!leftType.IsNull()) properties->AppendItem(_("Left type"), GetLeftType()); if (!rightType.IsNull()) properties->AppendItem(_("Right type"), GetRightType()); properties->AppendItem(_("Result type"), GetResultType()); properties->AppendItem(_("Operator function"), GetOperatorFunction()); properties->AppendItem(_("Commutator"), GetCommutator()); properties->AppendItem(_("Negator"), GetNegator()); properties->AppendItem(_("Join function"), GetJoinFunction()); properties->AppendItem(_("Restrict function"), GetRestrictFunction()); if (!GetDatabase()->BackendMinimumVersion(8, 3)) { properties->AppendItem(_("Left Sort operator"), GetLeftSortOperator()); properties->AppendItem(_("Right Sort operator"), GetRightSortOperator()); properties->AppendItem(_("Less Than operator"), GetLessOperator()); properties->AppendItem(_("Greater than operator"), GetGreaterOperator()); } properties->AppendYesNoItem(_("Supports hash?"), GetHashJoins()); properties->AppendYesNoItem(_("Supports merge?"), GetMergeJoins()); properties->AppendYesNoItem(_("System operator?"), GetSystemObject()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void pgRule::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); wxString def = GetFormattedDefinition(); if (!def.IsEmpty()) { int doPos = def.Find(wxT(" DO INSTEAD ")); if (doPos > 0) def = def.Mid(doPos + 12).Strip(wxString::both); else { doPos = def.Find(wxT(" DO ")); if (doPos > 0) def = def.Mid(doPos + 4).Strip(wxString::both); } } properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Event"), GetEvent()); properties->AppendItem(_("Condition"), GetCondition()); properties->AppendYesNoItem(_("Do instead?"), GetDoInstead()); properties->AppendItem(_("Definition"), firstLineOnly(def)); if (this->GetDatabase()->connection()->BackendMinimumVersion(8, 3)) properties->AppendYesNoItem(_("Enabled?"), GetEnabled()); properties->AppendYesNoItem(_("System rule?"), GetSystemObject()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void SimpleCheckpoint::DoCheckpoint() { // TODO split checkpoint file into multiple files in the future // Create a new file for checkpoint CreateFile(); auto &log_manager = LogManager::GetInstance(); if (logger_ == nullptr) { logger_.reset(BackendLogger::GetBackendLogger(LOGGING_TYPE_NVM_WAL)); } start_commit_id_ = log_manager.GetGlobalMaxFlushedCommitId(); if (start_commit_id_ == INVALID_CID) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); start_commit_id_ = txn_manager.GetMaxCommittedCid(); } LOG_TRACE("DoCheckpoint cid = %lu", start_commit_id_); // Add txn begin record std::shared_ptr<LogRecord> begin_record(new TransactionRecord( LOGRECORD_TYPE_TRANSACTION_BEGIN, start_commit_id_)); CopySerializeOutput begin_output_buffer; begin_record->Serialize(begin_output_buffer); records_.push_back(begin_record); auto &catalog_manager = catalog::Manager::GetInstance(); auto database_count = catalog_manager.GetDatabaseCount(); // loop all databases for (oid_t database_idx = 0; database_idx < database_count; database_idx++) { auto database = catalog_manager.GetDatabase(database_idx); auto table_count = database->GetTableCount(); auto database_oid = database->GetOid(); // loop all tables for (oid_t table_idx = 0; table_idx < table_count; table_idx++) { // Get the target table storage::DataTable *target_table = database->GetTable(table_idx); PL_ASSERT(target_table); LOG_TRACE("SeqScan: database idx %u table idx %u: %s", database_idx, table_idx, target_table->GetName().c_str()); Scan(target_table, database_oid); } } // Add txn commit record std::shared_ptr<LogRecord> commit_record(new TransactionRecord( LOGRECORD_TYPE_TRANSACTION_COMMIT, start_commit_id_)); CopySerializeOutput commit_output_buffer; commit_record->Serialize(commit_output_buffer); records_.push_back(commit_record); // TODO Add delimiter record for checkpoint recovery as well Persist(); Cleanup(); most_recent_checkpoint_cid = start_commit_id_; }
void pgView::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids) { expandedKids = true; browser->RemoveDummyChild(this); browser->AppendCollection(this, columnFactory); pgCollection *collection = browser->AppendCollection(this, ruleFactory); collection->iSetOid(GetOid()); collection->ShowTreeDetail(browser); treeObjectIterator colIt(browser, collection); pgRule *rule; while (!hasInsertRule && !hasUpdateRule && !hasDeleteRule && (rule = (pgRule *)colIt.GetNextObject()) != 0) { if (rule->GetEvent().Find(wxT("INSERT")) >= 0) hasInsertRule = true; if (rule->GetEvent().Find(wxT("UPDATE")) >= 0) hasUpdateRule = true; if (rule->GetEvent().Find(wxT("DELETE")) >= 0) hasDeleteRule = true; } if (GetConnection()->BackendMinimumVersion(9, 1)) browser->AppendCollection(this, triggerFactory); } if (properties) { CreateListColumns(properties); wxString def = GetDefinition().Left(250); def.Replace(wxT("\n"), wxT(" ")); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("ACL"), GetAcl()); properties->AppendItem(_("Definition"), def); properties->AppendYesNoItem(_("System view?"), GetSystemObject()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void edbPackageVariable::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Data type"), GetDataType()); properties->AppendItem(_("Visibility"), GetVisibility()); } }
void pgFunction::ShowStatistics(frmMain *form, ctlListView *statistics) { if (GetConnection()->BackendMinimumVersion(8, 4)) { wxString sql = wxT("SELECT calls AS ") + qtIdent(_("Number of calls")) + wxT(", total_time AS ") + qtIdent(_("Total Time")) + wxT(", self_time AS ") + qtIdent(_("Self Time")) + wxT(" FROM pg_stat_user_functions") + wxT(" WHERE funcid = ") + NumToStr(GetOid()); DisplayStatistics(statistics, sql); } }
void pgTextSearchConfiguration::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("Parser"), GetParser()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
TEST_F(LoggingTests, OutOfOrderCommitTest) { auto recovery_table = ExecutorTestsUtil::CreateTable(1024); auto &manager = catalog::Manager::GetInstance(); storage::Database db(DEFAULT_DB_ID); manager.AddDatabase(&db); db.AddTable(recovery_table); auto tuples = BuildLoggingTuples(recovery_table, 1, false, false); EXPECT_EQ(recovery_table->GetNumberOfTuples(), 0); EXPECT_EQ(recovery_table->GetTileGroupCount(), 1); EXPECT_EQ(tuples.size(), 1); logging::WriteAheadFrontendLogger fel(true); // auto bel = logging::WriteAheadBackendLogger::GetInstance(); cid_t test_commit_id = 10; auto curr_rec = new logging::TupleRecord( LOGRECORD_TYPE_TUPLE_UPDATE, test_commit_id + 1, recovery_table->GetOid(), INVALID_ITEMPOINTER, ItemPointer(100, 5), nullptr, DEFAULT_DB_ID); fel.DeleteTuple(curr_rec); delete curr_rec; EXPECT_EQ(recovery_table->GetTileGroupCount(), 2); curr_rec = new logging::TupleRecord( LOGRECORD_TYPE_TUPLE_INSERT, test_commit_id, recovery_table->GetOid(), ItemPointer(100, 5), INVALID_ITEMPOINTER, tuples[0], DEFAULT_DB_ID); curr_rec->SetTuple(tuples[0]); fel.InsertTuple(curr_rec); delete curr_rec; auto tg_header = recovery_table->GetTileGroupById(100)->GetHeader(); EXPECT_EQ(tg_header->GetEndCommitId(5), test_commit_id + 1); EXPECT_EQ(recovery_table->GetNumberOfTuples(), 0); EXPECT_EQ(recovery_table->GetTileGroupCount(), 2); }
void pgOperatorFamily::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("Access method"), GetAccessMethod()); properties->AppendItem(_("System operator family?"), GetSystemObject()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void gpResQueue::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids) { expandedKids = true; wxString queuesquery; queuesquery = wxT("SELECT rolname,\n") wxT(" pg_catalog.shobj_description(r.oid, 'pg_authid') AS description\n"); queuesquery += wxT(" FROM pg_roles r\n") wxT(" JOIN pg_resqueue q ON rolresqueue=q.oid\n") wxT(" WHERE rolresqueue=") + GetOidStr() + wxT("\n") wxT(" ORDER BY rolname"); pgSetIterator queues(GetConnection(), queuesquery); while (queues.RowsLeft()) { wxString queue = queues.GetVal(wxT("rolname")); queuesIn.Add(queue); } } if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Active threshold"), GetCountLimit()); properties->AppendItem(_("Cost threshold"), GetCostLimit()); properties->AppendItem(_("Ignore threshold"), GetIgnoreCostLimit()); properties->AppendItem(_("Over commit?"), BoolToYesNo(GetOvercommit())); wxString roleList; size_t index; for (index = 0 ; index < queuesIn.GetCount() ; index++) { if (!roleList.IsEmpty()) roleList += wxT(", "); roleList += queuesIn.Item(index); } properties->AppendItem(_("Roles using this"), roleList); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void pgExtension::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("Schema"), GetSchemaStr()); properties->AppendYesNoItem(_("Relocatable?"), GetIsRelocatable()); properties->AppendItem(_("Version"), GetVersion()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void pgTextSearchParser::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Start"), GetStart()); properties->AppendItem(_("Gettoken"), GetGettoken()); properties->AppendItem(_("End"), GetEnd()); properties->AppendItem(_("Lextypes"), GetLextypes()); properties->AppendItem(_("Headline"), GetHeadline()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void pgTrigger::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids && GetLanguage() != wxT("edbspl")) { ReadColumnDetails(); if (browser) { // if no browser present, function will not be appended to tree expandedKids = true; } if (triggerFunction) delete triggerFunction; // append function here triggerFunction = functionFactory.AppendFunctions(this, GetSchema(), browser, wxT( "WHERE pr.oid=") + NumToStr(functionOid) + wxT("::oid\n")); if (triggerFunction) { iSetFunction(triggerFunction->GetQuotedFullIdentifier()); } } if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); if (GetConnection()->BackendMinimumVersion(8, 2)) properties->AppendYesNoItem(_("Constraint?"), GetIsConstraint()); properties->AppendItem(_("Fires"), GetFireWhen()); properties->AppendItem(_("Event"), GetEvent()); if (!GetQuotedColumns().IsEmpty()) { properties->AppendItem(_("Columns"), GetColumns()); } properties->AppendItem(_("For each"), GetForEach()); if (GetLanguage() != wxT("edbspl")) properties->AppendItem(_("Function"), GetFunction() + wxT("(") + GetArguments() + wxT(")")); if (GetConnection()->BackendMinimumVersion(8, 5)) properties->AppendItem(_("When?"), GetWhen()); properties->AppendYesNoItem(_("Enabled?"), GetEnabled()); properties->AppendYesNoItem(_("System trigger?"), GetSystemObject()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void pgTablespace::ShowDependents(frmMain *form, ctlListView *referencedBy, const wxString &where) { form->StartMsg(_(" Retrieving tablespace usage")); referencedBy->ClearAll(); referencedBy->AddColumn(_("Type"), 60); referencedBy->AddColumn(_("Database"), 80); referencedBy->AddColumn(_("Name"), 300); wxArrayString dblist; pgSet *set = GetConnection()->ExecuteSet( wxT("SELECT datname, datallowconn, dattablespace\n") wxT(" FROM pg_database db\n") wxT(" ORDER BY datname")); if (set) { while (!set->Eof()) { wxString datname = set->GetVal(wxT("datname")); if (set->GetBool(wxT("datallowconn"))) dblist.Add(datname); OID oid = set->GetOid(wxT("dattablespace")); if (oid == GetOid()) referencedBy->AppendItem(databaseFactory.GetIconId(), _("Database"), datname); set->MoveNext(); } delete set; } FillOwned(form->GetBrowser(), referencedBy, dblist, wxT("SELECT cl.relkind, COALESCE(cin.nspname, cln.nspname) as nspname, COALESCE(ci.relname, cl.relname) as relname, cl.relname as indname\n") wxT(" FROM pg_class cl\n") wxT(" JOIN pg_namespace cln ON cl.relnamespace=cln.oid\n") wxT(" LEFT OUTER JOIN pg_index ind ON ind.indexrelid=cl.oid\n") wxT(" LEFT OUTER JOIN pg_class ci ON ind.indrelid=ci.oid\n") wxT(" LEFT OUTER JOIN pg_namespace cin ON ci.relnamespace=cin.oid,\n") wxT(" pg_database\n") wxT(" WHERE datname = current_database()\n") wxT(" AND (cl.reltablespace = ") + GetOidStr() + wxT("\n") wxT(" OR (cl.reltablespace=0 AND dattablespace = ") + GetOidStr() + wxT("))\n") wxT(" ORDER BY 1,2,3")); form->EndMsg(set != 0); }
void edbPackageFunction::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Argument count"), GetArgCount()); properties->AppendItem(_("Arguments"), GetArgListWithNames()); properties->AppendItem(_("Signature arguments"), GetArgSigList()); if (!GetIsProcedure()) properties->AppendItem(_("Return type"), GetReturnType()); properties->AppendItem(_("Visibility"), GetVisibility()); properties->AppendItem(_("Source"), firstLineOnly(GetSource())); } }
void pgConversion::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("From"), GetForEncoding()); properties->AppendItem(_("To"), GetToEncoding()); properties->AppendItem(_("Function"), GetSchemaPrefix(GetProcNamespace()) + GetProc()); properties->AppendItem(_("Default?"), GetDefaultConversion()); properties->AppendItem(_("System conversion?"), GetSystemObject()); if (GetConnection()->BackendMinimumVersion(7, 5)) properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } }
void pgDomain::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids) { expandedKids = true; browser->RemoveDummyChild(this); // Log wxLogInfo(wxT("Adding child object to domain %s"), GetIdentifier().c_str()); if (GetConnection()->BackendMinimumVersion(7, 4)) browser->AppendCollection(this, constraintFactory); } if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("Base type"), GetBasetype()); if (GetDimensions()) properties->AppendItem(_("Dimensions"), GetDimensions()); if (GetCollationOid() > 0) properties->AppendItem(_("Collation"), GetQuotedCollation()); properties->AppendItem(_("Default"), GetDefault()); properties->AppendYesNoItem(_("Not NULL?"), GetNotNull()); properties->AppendYesNoItem(_("System domain?"), GetSystemObject()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); if (!GetLabels().IsEmpty()) { wxArrayString seclabels = GetProviderLabelArray(); if (seclabels.GetCount() > 0) { for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2) { properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1)); } } } } }
TEST_F(LoggingTests, BasicUpdateTest) { auto recovery_table = ExecutorTestsUtil::CreateTable(1024); auto &manager = catalog::Manager::GetInstance(); storage::Database db(DEFAULT_DB_ID); manager.AddDatabase(&db); db.AddTable(recovery_table); auto tuples = BuildLoggingTuples(recovery_table, 1, false, false); EXPECT_EQ(recovery_table->GetNumberOfTuples(), 0); EXPECT_EQ(recovery_table->GetTileGroupCount(), 1); EXPECT_EQ(tuples.size(), 1); logging::WriteAheadFrontendLogger fel(true); // auto bel = logging::WriteAheadBackendLogger::GetInstance(); cid_t test_commit_id = 10; Value val0 = tuples[0]->GetValue(0); Value val1 = tuples[0]->GetValue(1); Value val2 = tuples[0]->GetValue(2); Value val3 = tuples[0]->GetValue(3); auto curr_rec = new logging::TupleRecord( LOGRECORD_TYPE_TUPLE_UPDATE, test_commit_id, recovery_table->GetOid(), ItemPointer(100, 5), ItemPointer(100, 4), tuples[0], DEFAULT_DB_ID); curr_rec->SetTuple(tuples[0]); fel.UpdateTuple(curr_rec); delete curr_rec; auto tg_header = recovery_table->GetTileGroupById(100)->GetHeader(); EXPECT_TRUE(tg_header->GetBeginCommitId(5) <= test_commit_id); EXPECT_EQ(tg_header->GetEndCommitId(5), MAX_CID); EXPECT_EQ(tg_header->GetEndCommitId(4), test_commit_id); EXPECT_TRUE( val0.Compare(recovery_table->GetTileGroupById(100)->GetValue(5, 0)) == 0); EXPECT_TRUE( val1.Compare(recovery_table->GetTileGroupById(100)->GetValue(5, 1)) == 0); EXPECT_TRUE( val2.Compare(recovery_table->GetTileGroupById(100)->GetValue(5, 2)) == 0); EXPECT_TRUE( val3.Compare(recovery_table->GetTileGroupById(100)->GetValue(5, 3)) == 0); EXPECT_EQ(recovery_table->GetNumberOfTuples(), 0); EXPECT_EQ(recovery_table->GetTileGroupCount(), 2); }
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 pgCatalogObject::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (!expandedKids) { expandedKids = true; browser->AppendCollection(this, columnFactory); } if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("Comment"), GetComment()); } }