void TestBook::testInitDatabasePresentTables() { // simply call init twice and make sure everything goes ok auto dbPath = PublicBook::databasePath(); PublicBook::initDatabse(); PublicBook::initDatabse(); QFileInfo fi(dbPath); QVERIFY(fi.exists()); // use qsql to ensure that the tables are there auto db = com::chancho::system::DatabaseFactory::instance()->addDatabase("QSQLITE", "TESTS"); db->setDatabaseName(dbPath); auto opened = db->open(); QVERIFY(opened); // once the db has been created we need to check that it has the correct version and the required tables auto tables = db->tables(); QCOMPARE(tables.count(), 4); QVERIFY(tables.contains("Accounts", Qt::CaseInsensitive)); QVERIFY(tables.contains("Categories", Qt::CaseInsensitive)); QVERIFY(tables.contains("Transactions", Qt::CaseInsensitive)); QVERIFY(tables.contains("RecurrentTransactions", Qt::CaseInsensitive)); db->close(); }
void TestBook::testInitDatabaseNoPresentTables() { // create a database with no data, then init the database and ensure that the tables are present auto dbPath = PublicBook::databasePath(); QFileInfo fi(dbPath); QVERIFY(!fi.exists()); auto db = com::chancho::system::DatabaseFactory::instance()->addDatabase("QSQLITE", "TESTS"); db->setDatabaseName(dbPath); auto opened = db->open(); QVERIFY(opened); db->close(); QVERIFY(fi.exists()); PublicBook::initDatabse(); // assert that the tables have been created opened = db->open(); QVERIFY(opened); // once the db has been created we need to check that it has the correct version and the required tables auto tables = db->tables(); QCOMPARE(tables.count(), 4); QVERIFY(tables.contains("Accounts", Qt::CaseInsensitive)); QVERIFY(tables.contains("Categories", Qt::CaseInsensitive)); QVERIFY(tables.contains("Transactions", Qt::CaseInsensitive)); QVERIFY(tables.contains("RecurrentTransactions", Qt::CaseInsensitive)); db->close(); }
bool test_interrupt_source_overrides() { BEGIN_TEST; FakeTableProvider provider; provider.AddTable(FakeTable{ACPI_SIG_MADT, 1, (ACPI_TABLE_HEADER*)kEveMadtTable}); AcpiTables tables(&provider); uint32_t num_overrides = 0; EXPECT_EQ(ZX_OK, tables.interrupt_source_overrides_count(&num_overrides), ""); EXPECT_EQ(2u, num_overrides, ""); io_apic_isa_override overrides[2]; EXPECT_EQ(ZX_OK, tables.interrupt_source_overrides(overrides, 2, &num_overrides), ""); ASSERT_EQ(2u, num_overrides, ""); EXPECT_EQ(0u, overrides[0].isa_irq, ""); EXPECT_EQ(true, overrides[0].remapped, ""); EXPECT_EQ(0, overrides[0].tm, ""); EXPECT_EQ(0, overrides[0].pol, ""); EXPECT_EQ(2u, overrides[0].global_irq, ""); EXPECT_EQ(9u, overrides[1].isa_irq, ""); EXPECT_EQ(true, overrides[1].remapped, ""); EXPECT_EQ(1, overrides[1].tm, ""); EXPECT_EQ(0, overrides[1].pol, ""); EXPECT_EQ(9u, overrides[1].global_irq, ""); END_TEST; }
vector<Factor> Factor::readUai10(std::istream& is) { size_t nvar, ncliques, csize, v, nval; char* st; st = new char[20]; is >> st; if ( strcasecmp(st,"MARKOV") ) throw std::runtime_error("Only UAI-2010 Markov-format files are supported currently"); is >> nvar; vector<size_t> dims(nvar); for (size_t i=0;i<nvar;i++) { is>>dims[i]; if (dims[i] == 0) dims[i]=1; } is >> ncliques; std::vector<mex::vector<Var> > cliques(ncliques); std::vector<VarSet > sets(ncliques); for (size_t i=0;i<ncliques;i++) { is >> csize; cliques[i].reserve(csize); for (size_t j=0;j<csize;j++) { is>>v; Var V(v,dims[v]); cliques[i].push_back(V); sets[i] |= V; } } //vector<vector<double> > tables(ncliques); vector<Factor> tables(ncliques); for (size_t i=0;i<ncliques;i++) { is >> nval; assert(nval == sets[i].nrStates()); tables[i] = Factor(sets[i],0.0); // preallocate memory and convert from given order, bigEndian if (nval==1) { is>>tables[i][0]; continue; } // special case for constant factor permuteIndex pi( cliques[i], true); pi=pi.inverse(); // to our order for (size_t j=0;j<nval;j++) is>>tables[i][pi.convert(j)]; }
QObject *DbSchema::table(const QString &table_name) { for(QObject *t : tables()) { if(t->property("name") == table_name) return t; } return nullptr; }
/* Drops all the tables in the database */ void Database::clear() { Statement tables(*this, "SELECT name FROM sqlite_master WHERE type = 'table'"); Statement drop(*this, "DROP TABLE ?"); do { drop.bind(1u, tables.toText(0u)); drop.execute(); drop.reset(); } while (tables.nextRow()); }
void DatabaseManager::slotTables(QString connection, TableProcess process, ErrorProcess error){ QSqlDatabase database(QSqlDatabase::database(connection)); if(database.lastError().isValid()){ error(database.lastError().text()); }else{ QStringList tables(database.tables()); if(database.lastError().isValid()){ error(database.lastError().text()); }else{ process(tables); } } }
bool test_hpet() { BEGIN_TEST; FakeTableProvider provider; provider.AddTable(FakeTable{ACPI_SIG_HPET, 1, (ACPI_TABLE_HEADER*)kEveHpetTable}); AcpiTables tables(&provider); acpi_hpet_descriptor hpet; ASSERT_EQ(ZX_OK, tables.hpet(&hpet), ""); EXPECT_EQ(0xFED00000u, hpet.address, ""); EXPECT_EQ(false, hpet.port_io, ""); EXPECT_EQ(0, hpet.minimum_tick, ""); EXPECT_EQ(0, hpet.sequence, ""); END_TEST; }
bool test_io() { BEGIN_TEST; FakeTableProvider provider; provider.AddTable(FakeTable{ACPI_SIG_MADT, 1, (ACPI_TABLE_HEADER*)kEveMadtTable}); AcpiTables tables(&provider); uint32_t num_io = 0; EXPECT_EQ(ZX_OK, tables.io_apic_count(&num_io), ""); EXPECT_EQ(1u, num_io, ""); io_apic_descriptor io; EXPECT_EQ(ZX_OK, tables.io_apics(&io, 1, &num_io), ""); ASSERT_EQ(1u, num_io, ""); EXPECT_EQ(2u, io.apic_id, ""); EXPECT_EQ(0u, io.global_irq_base, ""); EXPECT_EQ(0xFEC00000u, io.paddr, ""); END_TEST; }
bool test_cpus() { BEGIN_TEST; FakeTableProvider provider; provider.AddTable(FakeTable{ACPI_SIG_MADT, 1, (ACPI_TABLE_HEADER*)kEveMadtTable}); AcpiTables tables(&provider); uint32_t cpus = 0; EXPECT_EQ(ZX_OK, tables.cpu_count(&cpus), ""); EXPECT_EQ(4u, cpus, ""); uint32_t ids[4] = {0}; EXPECT_EQ(ZX_OK, tables.cpu_apic_ids(ids, 4, &cpus), ""); ASSERT_EQ(4u, cpus, ""); EXPECT_EQ(0u, ids[0], ""); EXPECT_EQ(1u, ids[1], ""); EXPECT_EQ(2u, ids[2], ""); EXPECT_EQ(3u, ids[3], ""); END_TEST; }
void TestBook::testUpgradeNoRecurrence() { // create a database with the basic tables (just the names, no need to add the exact fields) and make sure it // is added auto dbPath = PublicBook::databasePath(); auto db = sys::DatabaseFactory::instance()->addDatabase("QSQLITE", QTest::currentTestFunction()); db->setDatabaseName(dbPath); auto opened = db->open(); QVERIFY(opened); // create the required tables and indexes auto query = db->createQuery(); auto success = query->exec("CREATE TABLE IF NOT EXISTS Accounts(id INT)"); QVERIFY(success); success &= query->exec("CREATE TABLE IF NOT EXISTS Categories(id INT)"); QVERIFY(success); success &= query->exec("CREATE TABLE IF NOT EXISTS Transactions(id INT)"); QVERIFY(success); db->close(); //init the db and test that the recurrence is added PublicBook::initDatabse(); opened = db->open(); QVERIFY(opened); // once the db has been created we need to check that it has the correct version and the required tables auto tables = db->tables(); QCOMPARE(tables.count(), 4); QVERIFY(tables.contains("Accounts", Qt::CaseInsensitive)); QVERIFY(tables.contains("Categories", Qt::CaseInsensitive)); QVERIFY(tables.contains("Transactions", Qt::CaseInsensitive)); QVERIFY(tables.contains("RecurrentTransactions", Qt::CaseInsensitive)); db->close(); }
void TreesTables::populateSubMenu(Wt::WMenu *menu) { menu->setInternalBasePath("/trees-tables"); menu->addItem("Tables", tables())->setPathComponent(""); menu->addItem("Trees", deferCreate(boost::bind (&TreesTables::trees, this))); menu->addItem("Tree Tables", deferCreate(boost::bind (&TreesTables::treeTables, this))); menu->addItem("MVC Table Views", deferCreate(boost::bind (&TreesTables::tableViews, this))); menu->addItem("MVC Tree Views", deferCreate(boost::bind (&TreesTables::treeViews, this))); menu->addItem("MVC Item models", deferCreate(boost::bind (&TreesTables::itemModels, this))); // menu->addItem("Proxy item models", proxyModels()); }
void SqliteDriver::Mr_Proper() { #if 0 QString mproperMsg(tr("Este proceso puede tener una larga duración, dependiendo\n" "del tamaño de la base de datos.\n" "Antes de empezar debe asegurarse que durante todo el proceso\n" "no habrá otros usuarios conectados a esta base de datos, de lo\n" "contrario los resultados serán impredecibles. Asegúrese también\n" "de tener una COPIA DE SEGURIDAD actualizada de esta base de datos\n" "antes de empezar.\n\n¿ Quiere continuar ?")); int res = QMessageBox::question(0, tr("Mr. Proper"), mproperMsg, QMessageBox::Yes, QMessageBox::No); if (res != QMessageBox::Yes) return; #endif db_->dbAux()->transaction(); QRegExp rx("^.*[\\d][\\d][\\d][\\d].[\\d][\\d].*[\\d][\\d]$"); QRegExp rx2("^.*alteredtable[\\d][\\d][\\d][\\d].*$"); QSqlQuery qry(QString::null, db_->dbAux()); QSqlQuery qry2(QString::null, db_->dbAux()); int steps = 0; QString item; QRegExp rx3("^.*\\d{6,9}$"); QStringList listOldBks(tables("").grep(rx3)); qry.exec("select nombre from flfiles"); FLUtil::createProgressDialog(tr("Borrando backups"), listOldBks.size() + qry.size() + 5); while (qry.next()) { item = qry.value(0).toString(); if (item.contains(rx) || item.contains(rx2)) { FLUtil::setLabelText(tr("Borrando regisro %1").arg(item)); qry2.exec("delete from flfiles where nombre = '" + item + "'"); #ifdef FL_DEBUG qWarning("delete from flfiles where nombre = '" + item + "'"); #endif if (item.contains("alteredtable")) { if (tables("").contains(item.replace(".mtd", ""))) { FLUtil::setLabelText(tr("Borrando tabla %1").arg(item)); qry2.exec("drop table " + item.replace(".mtd", "")); #ifdef FL_DEBUG qWarning("drop table " + item.replace(".mtd", "")); #endif } } } FLUtil::setProgress(++steps); } for (QStringList::Iterator it = listOldBks.begin(); it != listOldBks.end(); ++it) { item = *it; if (tables("").contains(item)) { FLUtil::setLabelText(tr("Borrando tabla %1").arg(item)); qry2.exec("drop table " + item); #ifdef FL_DEBUG qWarning("drop table " + item); #endif } FLUtil::setProgress(++steps); } FLUtil::setLabelText(tr("Inicializando cachés")); FLUtil::setProgress(++steps); qry.exec("delete from flmetadata"); qry.exec("delete from flvar"); AQ_DISKCACHE_CLR(); db_->manager()->cleanupMetaData(); db_->dbAux()->commit(); FLUtil::setLabelText(tr("Vacunando base de datos")); FLUtil::setProgress(++steps); qry2.exec("vacuum"); FLUtil::setProgress(++steps); #ifdef FL_DEBUG qWarning("vacuum"); #endif FLUtil::destroyProgressDialog(); }
QStringList QSqlDatabase::tables() const { return tables( QSql::Tables ); }
void EclipseIO::Impl::writeINITFile( const data::Solution& simProps, std::map<std::string, std::vector<int> > int_data, const NNC& nnc) const { const auto& units = this->es.getUnits(); const IOConfig& ioConfig = this->es.cfg().io(); std::string initFile( ERT::EclFilename( this->outputDir, this->baseName, ECL_INIT_FILE, ioConfig.getFMTOUT() )); ERT::FortIO fortio( initFile, std::ios_base::out, ioConfig.getFMTOUT(), ECL_ENDIAN_FLIP ); // Write INIT header. Observe that the PORV vector is treated // specially; that is because for this particulat vector we write // a total of nx*ny*nz values, where the PORV vector has been // explicitly set to zero for inactive cells. The convention is // that the active/inactive cell mapping can be inferred by // reading the PORV vector. { const auto& opm_data = this->es.get3DProperties().getDoubleGridProperty("PORV").getData(); auto ecl_data = opm_data; for (size_t global_index = 0; global_index < opm_data.size(); global_index++) if (!this->grid.cellActive( global_index )) ecl_data[global_index] = 0; ecl_init_file_fwrite_header( fortio.get(), this->grid.c_ptr(), NULL, units.getEclType(), this->es.runspec( ).eclPhaseMask( ), this->schedule.posixStartTime( )); units.from_si( UnitSystem::measure::volume, ecl_data ); writeKeyword( fortio, "PORV" , ecl_data ); } // Writing quantities which are calculated by the grid to the INIT file. ecl_grid_fwrite_depth( this->grid.c_ptr() , fortio.get() , units.getEclType( ) ); ecl_grid_fwrite_dims( this->grid.c_ptr() , fortio.get() , units.getEclType( ) ); // Write properties from the input deck. { const auto& properties = this->es.get3DProperties().getDoubleProperties(); using double_kw = std::pair<std::string, UnitSystem::measure>; /* This is a rather arbitrary hardcoded list of 3D keywords which are written to the INIT file, if they are in the current EclipseState. */ std::vector<double_kw> doubleKeywords = {{"PORO" , UnitSystem::measure::identity }, {"PERMX" , UnitSystem::measure::permeability }, {"PERMY" , UnitSystem::measure::permeability }, {"PERMZ" , UnitSystem::measure::permeability }, {"NTG" , UnitSystem::measure::identity }}; // The INIT file should always contain the NTG property, we // therefor invoke the auto create functionality to ensure // that "NTG" is included in the properties container. properties.assertKeyword("NTG"); for (const auto& kw_pair : doubleKeywords) { if (properties.hasKeyword( kw_pair.first)) { const auto& opm_property = properties.getKeyword(kw_pair.first); auto ecl_data = opm_property.compressedCopy( this->grid ); units.from_si( kw_pair.second, ecl_data ); writeKeyword( fortio, kw_pair.first, ecl_data ); } } } // Write properties which have been initialized by the simulator. { for (const auto& prop : simProps) { auto ecl_data = this->grid.compressedVector( prop.second.data ); writeKeyword( fortio, prop.first, ecl_data ); } } // Write tables { Tables tables( this->es.getUnits() ); tables.addPVTO( this->es.getTableManager().getPvtoTables() ); tables.addPVTG( this->es.getTableManager().getPvtgTables() ); tables.addPVTW( this->es.getTableManager().getPvtwTable() ); tables.addDensity( this->es.getTableManager().getDensityTable( ) ); tables.addSatFunc(this->es); fwrite(tables, fortio); } // Write all integer field properties from the input deck. { const auto& properties = this->es.get3DProperties().getIntProperties(); // It seems that the INIT file should always contain these // keywords, we therefor call getKeyword() here to invoke the // autocreation property, and ensure that the keywords exist // in the properties container. properties.assertKeyword("PVTNUM"); properties.assertKeyword("SATNUM"); properties.assertKeyword("EQLNUM"); properties.assertKeyword("FIPNUM"); for (const auto& property : properties) { auto ecl_data = property.compressedCopy( this->grid ); writeKeyword( fortio , property.getKeywordName() , ecl_data ); } } //Write Integer Vector Map { for( const auto& pair : int_data) { const std::string& key = pair.first; const std::vector<int>& int_vector = pair.second; if (key.size() > ECL_STRING8_LENGTH) throw std::invalid_argument("Keyword is too long."); writeKeyword( fortio , key , int_vector ); } } // Write NNC transmissibilities { std::vector<double> tran; for( const NNCdata& nd : nnc.nncdata() ) tran.push_back( nd.trans ); units.from_si( UnitSystem::measure::transmissibility , tran ); writeKeyword( fortio, "TRANNNC" , tran ); } }
static int regression_tests(void) { struct regression_test_case *current = regression_test_cases; const char *error; const char *cpu_info; int i, err_offs; int is_successful, is_ascii_pattern, is_ascii_input; int total = 0; int successful = 0; int counter = 0; #ifdef SUPPORT_PCRE8 pcre *re8; pcre_extra *extra8; int ovector8_1[32]; int ovector8_2[32]; int return_value8_1, return_value8_2; int utf8 = 0, ucp8 = 0; int disabled_flags8 = 0; #endif #ifdef SUPPORT_PCRE16 pcre16 *re16; pcre16_extra *extra16; int ovector16_1[32]; int ovector16_2[32]; int return_value16_1, return_value16_2; int utf16 = 0, ucp16 = 0; int disabled_flags16 = 0; int length16; #endif /* This test compares the behaviour of interpreter and JIT. Although disabling utf or ucp may make tests fail, if the pcre_exec result is the SAME, it is still considered successful from pcre_jit_test point of view. */ #ifdef SUPPORT_PCRE8 pcre_config(PCRE_CONFIG_JITTARGET, &cpu_info); #else pcre16_config(PCRE_CONFIG_JITTARGET, &cpu_info); #endif printf("Running JIT regression tests\n"); printf(" target CPU of SLJIT compiler: %s\n", cpu_info); #ifdef SUPPORT_PCRE8 pcre_config(PCRE_CONFIG_UTF8, &utf8); pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp8); if (!utf8) disabled_flags8 |= PCRE_UTF8; if (!ucp8) disabled_flags8 |= PCRE_UCP; printf(" in 8 bit mode with utf8 %s and ucp %s:\n", utf8 ? "enabled" : "disabled", ucp8 ? "enabled" : "disabled"); #endif #ifdef SUPPORT_PCRE16 pcre16_config(PCRE_CONFIG_UTF16, &utf16); pcre16_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp16); if (!utf16) disabled_flags16 |= PCRE_UTF8; if (!ucp16) disabled_flags16 |= PCRE_UCP; printf(" in 16 bit mode with utf16 %s and ucp %s:\n", utf16 ? "enabled" : "disabled", ucp16 ? "enabled" : "disabled"); #endif while (current->pattern) { /* printf("\nPattern: %s :\n", current->pattern); */ total++; if (current->start_offset & F_PROPERTY) { is_ascii_pattern = 0; is_ascii_input = 0; } else { is_ascii_pattern = check_ascii(current->pattern); is_ascii_input = check_ascii(current->input); } error = NULL; #ifdef SUPPORT_PCRE8 re8 = NULL; if (!(current->start_offset & F_NO8)) re8 = pcre_compile(current->pattern, current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | disabled_flags8), &error, &err_offs, tables(0)); extra8 = NULL; if (re8) { error = NULL; extra8 = pcre_study(re8, PCRE_STUDY_JIT_COMPILE, &error); if (!extra8) { printf("\n8 bit: Cannot study pattern: %s\n", current->pattern); pcre_free(re8); re8 = NULL; } if (!(extra8->flags & PCRE_EXTRA_EXECUTABLE_JIT)) { printf("\n8 bit: JIT compiler does not support: %s\n", current->pattern); pcre_free_study(extra8); pcre_free(re8); re8 = NULL; } } else if (((utf8 && ucp8) || is_ascii_pattern) && !(current->start_offset & F_NO8)) printf("\n8 bit: Cannot compile pattern: %s\n", current->pattern); #endif #ifdef SUPPORT_PCRE16 if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV)) convert_utf8_to_utf16(current->pattern, regtest_buf, NULL, REGTEST_MAX_LENGTH); else copy_char8_to_char16(current->pattern, regtest_buf, REGTEST_MAX_LENGTH); re16 = NULL; if (!(current->start_offset & F_NO16)) re16 = pcre16_compile(regtest_buf, current->flags & ~(PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART | disabled_flags16), &error, &err_offs, tables(0)); extra16 = NULL; if (re16) { error = NULL; extra16 = pcre16_study(re16, PCRE_STUDY_JIT_COMPILE, &error); if (!extra16) { printf("\n16 bit: Cannot study pattern: %s\n", current->pattern); pcre16_free(re16); re16 = NULL; } if (!(extra16->flags & PCRE_EXTRA_EXECUTABLE_JIT)) { printf("\n16 bit: JIT compiler does not support: %s\n", current->pattern); pcre16_free_study(extra16); pcre16_free(re16); re16 = NULL; } } else if (((utf16 && ucp16) || is_ascii_pattern) && !(current->start_offset & F_NO16)) printf("\n16 bit: Cannot compile pattern: %s\n", current->pattern); #endif counter++; if ((counter & 0x3) != 0) { #ifdef SUPPORT_PCRE8 setstack8(NULL); #endif #ifdef SUPPORT_PCRE16 setstack16(NULL); #endif } #ifdef SUPPORT_PCRE8 return_value8_1 = -1000; return_value8_2 = -1000; for (i = 0; i < 32; ++i) ovector8_1[i] = -2; for (i = 0; i < 32; ++i) ovector8_2[i] = -2; if (re8) { setstack8(extra8); return_value8_1 = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK, current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_1, 32); return_value8_2 = pcre_exec(re8, NULL, current->input, strlen(current->input), current->start_offset & OFFSET_MASK, current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_2, 32); } #endif #ifdef SUPPORT_PCRE16 return_value16_1 = -1000; return_value16_2 = -1000; for (i = 0; i < 32; ++i) ovector16_1[i] = -2; for (i = 0; i < 32; ++i) ovector16_2[i] = -2; if (re16) { setstack16(extra16); if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV)) length16 = convert_utf8_to_utf16(current->input, regtest_buf, regtest_offsetmap, REGTEST_MAX_LENGTH); else length16 = copy_char8_to_char16(current->input, regtest_buf, REGTEST_MAX_LENGTH); return_value16_1 = pcre16_exec(re16, extra16, regtest_buf, length16, current->start_offset & OFFSET_MASK, current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector16_1, 32); return_value16_2 = pcre16_exec(re16, NULL, regtest_buf, length16, current->start_offset & OFFSET_MASK, current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector16_2, 32); } #endif /* If F_DIFF is set, just run the test, but do not compare the results. Segfaults can still be captured. */ is_successful = 1; if (!(current->start_offset & F_DIFF)) { #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16 if (utf8 == utf16 && !(current->start_offset & F_FORCECONV)) { /* All results must be the same. */ if (return_value8_1 != return_value8_2 || return_value8_1 != return_value16_1 || return_value8_1 != return_value16_2) { printf("\n8 and 16 bit: Return value differs(%d:%d:%d:%d): [%d] '%s' @ '%s'\n", return_value8_1, return_value8_2, return_value16_1, return_value16_2, total, current->pattern, current->input); is_successful = 0; } else if (return_value8_1 >= 0) { return_value8_1 *= 2; /* Transform back the results. */ if (current->flags & PCRE_UTF8) { for (i = 0; i < return_value8_1; ++i) { if (ovector16_1[i] >= 0) ovector16_1[i] = regtest_offsetmap[ovector16_1[i]]; if (ovector16_2[i] >= 0) ovector16_2[i] = regtest_offsetmap[ovector16_2[i]]; } } for (i = 0; i < return_value8_1; ++i) if (ovector8_1[i] != ovector8_2[i] || ovector8_1[i] != ovector16_1[i] || ovector8_1[i] != ovector16_2[i]) { printf("\n8 and 16 bit: Ovector[%d] value differs(%d:%d:%d:%d): [%d] '%s' @ '%s' \n", i, ovector8_1[i], ovector8_2[i], ovector16_1[i], ovector16_2[i], total, current->pattern, current->input); is_successful = 0; } } } else { #endif /* SUPPORT_PCRE8 && SUPPORT_PCRE16 */ /* Only the 8 bit and 16 bit results must be equal. */ #ifdef SUPPORT_PCRE8 if (return_value8_1 != return_value8_2) { printf("\n8 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n", return_value8_1, return_value8_2, total, current->pattern, current->input); is_successful = 0; } else if (return_value8_1 >= 0) { return_value8_1 *= 2; for (i = 0; i < return_value8_1; ++i) if (ovector8_1[i] != ovector8_2[i]) { printf("\n8 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s'\n", i, ovector8_1[i], ovector8_2[i], total, current->pattern, current->input); is_successful = 0; } } #endif #ifdef SUPPORT_PCRE16 if (return_value16_1 != return_value16_2) { printf("\n16 bit: Return value differs(%d:%d): [%d] '%s' @ '%s'\n", return_value16_1, return_value16_2, total, current->pattern, current->input); is_successful = 0; } else if (return_value16_1 >= 0) { return_value16_1 *= 2; for (i = 0; i < return_value16_1; ++i) if (ovector16_1[i] != ovector16_2[i]) { printf("\n16 bit: Ovector[%d] value differs(%d:%d): [%d] '%s' @ '%s'\n", i, ovector16_1[i], ovector16_2[i], total, current->pattern, current->input); is_successful = 0; } } #endif #if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16 } #endif /* SUPPORT_PCRE8 && SUPPORT_PCRE16 */ } if (is_successful) { #ifdef SUPPORT_PCRE8 if (!(current->start_offset & F_NO8) && ((utf8 && ucp8) || is_ascii_input)) { if (return_value8_1 < 0 && !(current->start_offset & F_NOMATCH)) { printf("8 bit: Test should match: [%d] '%s' @ '%s'\n", total, current->pattern, current->input); is_successful = 0; } if (return_value8_1 >= 0 && (current->start_offset & F_NOMATCH)) { printf("8 bit: Test should not match: [%d] '%s' @ '%s'\n", total, current->pattern, current->input); is_successful = 0; } } #endif #ifdef SUPPORT_PCRE16 if (!(current->start_offset & F_NO16) && ((utf16 && ucp16) || is_ascii_input)) { if (return_value16_1 < 0 && !(current->start_offset & F_NOMATCH)) { printf("16 bit: Test should match: [%d] '%s' @ '%s'\n", total, current->pattern, current->input); is_successful = 0; } if (return_value16_1 >= 0 && (current->start_offset & F_NOMATCH)) { printf("16 bit: Test should not match: [%d] '%s' @ '%s'\n", total, current->pattern, current->input); is_successful = 0; } } #endif } if (is_successful) successful++; #ifdef SUPPORT_PCRE8 if (re8) { pcre_free_study(extra8); pcre_free(re8); } #endif #ifdef SUPPORT_PCRE16 if (re16) { pcre16_free_study(extra16); pcre16_free(re16); } #endif /* printf("[%d-%d|%d-%d]%s", ovector8_1[0], ovector8_1[1], ovector16_1[0], ovector16_1[1], (current->flags & PCRE_CASELESS) ? "C" : ""); */ printf("."); fflush(stdout); current++; } tables(1); #ifdef SUPPORT_PCRE8 setstack8(NULL); #endif #ifdef SUPPORT_PCRE16 setstack16(NULL); #endif if (total == successful) { printf("\nAll JIT regression tests are successfully passed.\n"); return 0; } else { printf("\nSuccessful test ratio: %d%% (%d failed)\n", successful * 100 / total, total - successful); return 1; } }
void Backup::makeRestore() { if (tables().isEmpty()) return; }
void ASTSelectQuery::formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const { frame.current_select = this; frame.need_parens = false; std::string indent_str = s.one_line ? "" : std::string(4 * frame.indent, ' '); if (with()) { s.ostr << (s.hilite ? hilite_keyword : "") << indent_str << "WITH " << (s.hilite ? hilite_none : ""); s.one_line ? with()->formatImpl(s, state, frame) : with()->as<ASTExpressionList &>().formatImplMultiline(s, state, frame); s.ostr << s.nl_or_ws; } s.ostr << (s.hilite ? hilite_keyword : "") << indent_str << "SELECT " << (distinct ? "DISTINCT " : "") << (s.hilite ? hilite_none : ""); s.one_line ? select()->formatImpl(s, state, frame) : select()->as<ASTExpressionList &>().formatImplMultiline(s, state, frame); if (tables()) { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "FROM " << (s.hilite ? hilite_none : ""); tables()->formatImpl(s, state, frame); } if (prewhere()) { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "PREWHERE " << (s.hilite ? hilite_none : ""); prewhere()->formatImpl(s, state, frame); } if (where()) { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "WHERE " << (s.hilite ? hilite_none : ""); where()->formatImpl(s, state, frame); } if (groupBy()) { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "GROUP BY " << (s.hilite ? hilite_none : ""); s.one_line ? groupBy()->formatImpl(s, state, frame) : groupBy()->as<ASTExpressionList &>().formatImplMultiline(s, state, frame); } if (group_by_with_rollup) s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << (s.one_line ? "" : " ") << "WITH ROLLUP" << (s.hilite ? hilite_none : ""); if (group_by_with_cube) s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << (s.one_line ? "" : " ") << "WITH CUBE" << (s.hilite ? hilite_none : ""); if (group_by_with_totals) s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << (s.one_line ? "" : " ") << "WITH TOTALS" << (s.hilite ? hilite_none : ""); if (having()) { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "HAVING " << (s.hilite ? hilite_none : ""); having()->formatImpl(s, state, frame); } if (orderBy()) { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "ORDER BY " << (s.hilite ? hilite_none : ""); s.one_line ? orderBy()->formatImpl(s, state, frame) : orderBy()->as<ASTExpressionList &>().formatImplMultiline(s, state, frame); } if (limitByValue()) { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "LIMIT " << (s.hilite ? hilite_none : ""); limitByValue()->formatImpl(s, state, frame); s.ostr << (s.hilite ? hilite_keyword : "") << " BY " << (s.hilite ? hilite_none : ""); s.one_line ? limitBy()->formatImpl(s, state, frame) : limitBy()->as<ASTExpressionList &>().formatImplMultiline(s, state, frame); } if (limitLength()) { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "LIMIT " << (s.hilite ? hilite_none : ""); if (limitOffset()) { limitOffset()->formatImpl(s, state, frame); s.ostr << ", "; } limitLength()->formatImpl(s, state, frame); } if (settings()) { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "SETTINGS " << (s.hilite ? hilite_none : ""); settings()->formatImpl(s, state, frame); } }
void Restore::execREAD_CONFIG_REQ(Signal* signal) { jamEntry(); const ReadConfigReq * req = (ReadConfigReq*)signal->getDataPtr(); Uint32 ref = req->senderRef; Uint32 senderData = req->senderData; ndbrequire(req->noOfParameters == 0); const ndb_mgm_configuration_iterator * p = m_ctx.m_config.getOwnConfigIterator(); ndbrequire(p != 0); #if 0 Uint32 noBackups = 0, noTables = 0, noAttribs = 0; ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &m_diskless)); ndb_mgm_get_int_parameter(p, CFG_DB_PARALLEL_BACKUPS, &noBackups); // ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_TABLES, &noTables)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DICT_TABLE, &noTables)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_ATTRIBUTES, &noAttribs)); noAttribs++; //RT 527 bug fix c_backupPool.setSize(noBackups); c_backupFilePool.setSize(3 * noBackups); c_tablePool.setSize(noBackups * noTables); c_attributePool.setSize(noBackups * noAttribs); c_triggerPool.setSize(noBackups * 3 * noTables); // 2 = no of replicas c_fragmentPool.setSize(noBackups * NO_OF_FRAG_PER_NODE * noTables); Uint32 szMem = 0; ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_MEM, &szMem); Uint32 noPages = (szMem + sizeof(Page32) - 1) / sizeof(Page32); // We need to allocate an additional of 2 pages. 1 page because of a bug in // ArrayPool and another one for DICTTAINFO. c_pagePool.setSize(noPages + NO_OF_PAGES_META_FILE + 2); Uint32 szDataBuf = (2 * 1024 * 1024); Uint32 szLogBuf = (2 * 1024 * 1024); Uint32 szWrite = 32768; ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_DATA_BUFFER_MEM, &szDataBuf); ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_LOG_BUFFER_MEM, &szLogBuf); ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_WRITE_SIZE, &szWrite); c_defaults.m_logBufferSize = szLogBuf; c_defaults.m_dataBufferSize = szDataBuf; c_defaults.m_minWriteSize = szWrite; c_defaults.m_maxWriteSize = szWrite; { // Init all tables ArrayList<Table> tables(c_tablePool); TablePtr ptr; while(tables.seize(ptr)){ new (ptr.p) Table(c_attributePool, c_fragmentPool); } tables.release(); } { ArrayList<BackupFile> ops(c_backupFilePool); BackupFilePtr ptr; while(ops.seize(ptr)){ new (ptr.p) BackupFile(* this, c_pagePool); } ops.release(); } { ArrayList<BackupRecord> recs(c_backupPool); BackupRecordPtr ptr; while(recs.seize(ptr)){ new (ptr.p) BackupRecord(* this, c_pagePool, c_tablePool, c_backupFilePool, c_triggerPool); } recs.release(); } // Initialize BAT for interface to file system { Page32Ptr p; ndbrequire(c_pagePool.seizeId(p, 0)); c_startOfPages = (Uint32 *)p.p; c_pagePool.release(p); NewVARIABLE* bat = allocateBat(1); bat[0].WA = c_startOfPages; bat[0].nrr = c_pagePool.getSize()*sizeof(Page32)/sizeof(Uint32); } #endif m_file_pool.setSize(1); Uint32 cnt = 2*MAX_ATTRIBUTES_IN_TABLE; cnt += PAGES; cnt += List::getSegmentSize()-1; cnt /= List::getSegmentSize(); cnt += 2; m_databuffer_pool.setSize(cnt); ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtrSend(); conf->senderRef = reference(); conf->senderData = senderData; sendSignal(ref, GSN_READ_CONFIG_CONF, signal, ReadConfigConf::SignalLength, JBB); }
void Backup::execREAD_CONFIG_REQ(Signal* signal) { const ReadConfigReq * req = (ReadConfigReq*)signal->getDataPtr(); Uint32 ref = req->senderRef; Uint32 senderData = req->senderData; ndbrequire(req->noOfParameters == 0); const ndb_mgm_configuration_iterator * p = m_ctx.m_config.getOwnConfigIterator(); ndbrequire(p != 0); c_defaults.m_disk_write_speed = 10 * (1024 * 1024); c_defaults.m_disk_write_speed_sr = 100 * (1024 * 1024); c_defaults.m_disk_synch_size = 4 * (1024 * 1024); c_defaults.m_o_direct = true; Uint32 noBackups = 0, noTables = 0, noAttribs = 0, noFrags = 0; ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &c_defaults.m_diskless)); ndb_mgm_get_int_parameter(p, CFG_DB_O_DIRECT, &c_defaults.m_o_direct); ndb_mgm_get_int_parameter(p, CFG_DB_CHECKPOINT_SPEED_SR, &c_defaults.m_disk_write_speed_sr); ndb_mgm_get_int_parameter(p, CFG_DB_CHECKPOINT_SPEED, &c_defaults.m_disk_write_speed); ndb_mgm_get_int_parameter(p, CFG_DB_DISK_SYNCH_SIZE, &c_defaults.m_disk_synch_size); ndb_mgm_get_int_parameter(p, CFG_DB_COMPRESSED_BACKUP, &c_defaults.m_compressed_backup); ndb_mgm_get_int_parameter(p, CFG_DB_COMPRESSED_LCP, &c_defaults.m_compressed_lcp); m_backup_report_frequency = 0; ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_REPORT_FREQUENCY, &m_backup_report_frequency); /* We adjust the disk speed parameters from bytes per second to rather be words per 100 milliseconds. We convert disk synch size from bytes per second to words per second. */ c_defaults.m_disk_write_speed /= (4 * 10); c_defaults.m_disk_write_speed_sr /= (4 * 10); /* Temporary fix, we divide the speed by number of ldm threads since we now can write in all ldm threads in parallel. Since previously we could write in 2 threads we also multiply by 2 if number of ldm threads is at least 2. The real fix will be to make the speed of writing more adaptable and also to use the real configured value and also add a new max disk speed value that can be used when one needs to write faster. */ Uint32 num_ldm_threads = globalData.ndbMtLqhThreads; if (num_ldm_threads == 0) { /* We are running with ndbd binary */ jam(); num_ldm_threads = 1; } c_defaults.m_disk_write_speed /= num_ldm_threads; c_defaults.m_disk_write_speed_sr /= num_ldm_threads; if (num_ldm_threads > 1) { jam(); c_defaults.m_disk_write_speed *= 2; c_defaults.m_disk_write_speed_sr *= 2; } ndb_mgm_get_int_parameter(p, CFG_DB_PARALLEL_BACKUPS, &noBackups); // ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_TABLES, &noTables)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DICT_TABLE, &noTables)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_ATTRIBUTES, &noAttribs)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DIH_FRAG_CONNECT, &noFrags)); noAttribs++; //RT 527 bug fix c_nodePool.setSize(MAX_NDB_NODES); c_backupPool.setSize(noBackups + 1); c_backupFilePool.setSize(3 * noBackups + 1); c_tablePool.setSize(noBackups * noTables + 1); c_triggerPool.setSize(noBackups * 3 * noTables); c_fragmentPool.setSize(noBackups * noFrags + 1); Uint32 szDataBuf = (2 * 1024 * 1024); Uint32 szLogBuf = (2 * 1024 * 1024); Uint32 szWrite = 32768, maxWriteSize = (256 * 1024); ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_DATA_BUFFER_MEM, &szDataBuf); ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_LOG_BUFFER_MEM, &szLogBuf); ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_WRITE_SIZE, &szWrite); ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_MAX_WRITE_SIZE, &maxWriteSize); if (maxWriteSize < szWrite) { /** * max can't be lower than min */ maxWriteSize = szWrite; } if ((maxWriteSize % szWrite) != 0) { /** * max needs to be a multiple of min */ maxWriteSize = (maxWriteSize + szWrite - 1) / szWrite; maxWriteSize *= szWrite; } /** * add min writesize to buffer size...and the alignment added here and there */ Uint32 extra = szWrite + 4 * (/* align * 512b */ 128); szDataBuf += extra; szLogBuf += extra; c_defaults.m_logBufferSize = szLogBuf; c_defaults.m_dataBufferSize = szDataBuf; c_defaults.m_minWriteSize = szWrite; c_defaults.m_maxWriteSize = maxWriteSize; c_defaults.m_lcp_buffer_size = szDataBuf; Uint32 szMem = 0; ndb_mgm_get_int_parameter(p, CFG_DB_BACKUP_MEM, &szMem); szMem += 3 * extra; // (data+log+lcp); Uint32 noPages = (szMem + sizeof(Page32) - 1) / sizeof(Page32) + (c_defaults.m_lcp_buffer_size + sizeof(Page32) - 1) / sizeof(Page32); // We need to allocate an additional of 2 pages. 1 page because of a bug in // ArrayPool and another one for DICTTAINFO. c_pagePool.setSize(noPages + NO_OF_PAGES_META_FILE + 2, true); { // Init all tables SLList<Table> tables(c_tablePool); TablePtr ptr; while (tables.seizeFirst(ptr)) { new (ptr.p) Table(c_fragmentPool); } while (tables.releaseFirst()); } { SLList<BackupFile> ops(c_backupFilePool); BackupFilePtr ptr; while (ops.seizeFirst(ptr)) { new (ptr.p) BackupFile(* this, c_pagePool); } while (ops.releaseFirst()); } { SLList<BackupRecord> recs(c_backupPool); BackupRecordPtr ptr; while (recs.seizeFirst(ptr)) { new (ptr.p) BackupRecord(* this, c_tablePool, c_backupFilePool, c_triggerPool); } while (recs.releaseFirst()); } // Initialize BAT for interface to file system { Page32Ptr p; ndbrequire(c_pagePool.seizeId(p, 0)); c_startOfPages = (Uint32 *)p.p; c_pagePool.release(p); NewVARIABLE* bat = allocateBat(1); bat[0].WA = c_startOfPages; bat[0].nrr = c_pagePool.getSize()*sizeof(Page32)/sizeof(Uint32); } ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtrSend(); conf->senderRef = reference(); conf->senderData = senderData; sendSignal(ref, GSN_READ_CONFIG_CONF, signal, ReadConfigConf::SignalLength, JBB); }
void Backup::makeBackup() { if (tables().isEmpty()) return; }