Commits

a4z committed f4f5a4b

adoptions for latest a4sqlt3, the db layer, chagnes

  • Participants
  • Parent commits e2186fd

Comments (0)

Files changed (7)

-Slackware Builds and Binaries Dependencies (Walker)
-
-
+sbbdep (Slack Build Binary Dependencies)
+     
+     
+Slackware Builds and Binaries Dependencies Walker,
 sbbdep is a tool for Slackware and Slackware based distributions that traces 
 binary runtime dependencies of dynamic linked files.
 

File src/cli/featurex.cpp

   using namespace a4sqlt3;
   Dataset rs_cnt, rs_files ;
 
-  Cache::getInstance()->DB().Execute("SELECT COUNT(*) FROM dynlinked;", &rs_cnt);
+  Cache::getInstance()->DB().Execute("SELECT COUNT(*) FROM dynlinked;", rs_cnt);
 
-  Cache::getInstance()->DB().Execute("SELECT filename FROM dynlinked;", &rs_files);
+  Cache::getInstance()->DB().Execute("SELECT filename FROM dynlinked;", rs_files);
 
   int counter = 0;
   for(auto& row : rs_files)

File src/cli/report.cpp

 
 #include <a4sqlt3/sqlcommand.hpp>
 #include <a4sqlt3/dataset.hpp>
-#include <a4sqlt3/columns.hpp>
+
 
 #include <set>
 #include <algorithm>
   ReportSet(const std::vector<std::string> fieldnames)
   {
     for(std::size_t i = 0; i < fieldnames.size(); ++i)
-        m_namemap.insert( NameMap::value_type(fieldnames[i], i) ) ;
+        _namemap.insert( NameMap::value_type(fieldnames[i], i) ) ;
   }
 
   void merge( const a4sqlt3::Dataset& other )
 
   void addFields(a4sqlt3::DbValueList fields)
   {
-    if( fields.size() != m_namemap.size() )
+    if( fields.size() != _namemap.size() )
       throw "TODO"; //TODO
 
-    m_rows.emplace_back(fields);
+    _rows.emplace_back(fields);
   }
 
 } ;
   cmd->Parameters().Nr(1).set(dirname);
 
   Dataset ds;
-  Cache::getInstance()->DB().Execute(cmd, &ds);
+  Cache::getInstance()->DB().Execute(cmd, ds);
   return ds.getField(0).getInt64() > 0 ;
 
 }
   cmd->Parameters().setValues( {DbValue(dirname), DbValue(dirname)} ) ;
 
   Dataset ds;
-  Cache::getInstance()->DB().Execute(cmd, &ds);
+  Cache::getInstance()->DB().Execute(cmd, ds);
   return ds.getField(0).getInt64() > 0 ;
 
 }
   cmd->Parameters().setValues( { fname.Str() }) ;
 
   Dataset ds;
-  Cache::getInstance()->DB().Execute(cmd, &ds);
+  Cache::getInstance()->DB().Execute(cmd, ds);
   return ds;
 }
 
 
 
   ReportSet ds{{}} ;
-  Cache::getInstance()->DB().Execute(sql, &ds) ;
+  Cache::getInstance()->DB().Execute(sql, ds) ;
   return ds;
 
 
 
   cmd->Parameters().setValues({ elf.getName().Str() });
 
-  Cache::getInstance()->DB().Execute(cmd, &ds);
+  Cache::getInstance()->DB().Execute(cmd, ds);
   return ds ;
 }
 //--------------------------------------------------------------------------------------------------
   cmd->Parameters().setValues({ name });
 
   Dataset ds;
-  Cache::getInstance()->DB().Execute(cmd, &ds);
+  Cache::getInstance()->DB().Execute(cmd, ds);
   return ds ;
 
 }

File src/sbbdep/cache.cpp

 #include <sbbdep/log.hpp>
 
 
-#include <a4sqlt3/columns.hpp>
 #include <a4sqlt3/error.hpp>
 
 #include <vector>
 
   StringSet allpkgindb; // all pks in the db
   // get all in the database
-  auto rh = [&allpkgindb](a4sqlt3::Columns& cols) -> bool
+  auto rh = [&allpkgindb](a4sqlt3::SqlQueryRow& qrow) -> bool
         {
-          allpkgindb.insert(cols[0].get<std::string>());
+          allpkgindb.insert(qrow[0].getString());
           return true ;
         } ;
 

File src/sbbdep/cachedb.cpp

 
 #include <a4sqlt3/sqlcommand.hpp>
 #include <a4sqlt3/dataset.hpp>
-#include <a4sqlt3/onevalresult.hpp>
+
 #include <a4sqlt3/error.hpp>
 
 #include <a4z/err.hpp>
 : a4sqlt3::Database(std::string(std::getenv("HOME")) + std::string("/sbbdep.cache")) //TODO wenn test vorbei nach .config/.. oder sonst wo
 {
  
-  Path p( m_name );
+  Path p( _name );
   m_isNew = !p.isValid();
 
 }
 // , m_isNew( !Path(name).isValid() ) better readable in body
 {
 
-  Path p( m_name );
+  Path p( _name );
   m_isNew = !p.isValid();
 
 }
   
   if(  a4sqlt3::Database::Open() )
     {
-      CacheSQL::register_own_sql_functions(m_sql3db);
+      CacheSQL::register_own_sql_functions(_sql3db);
 
       checkVersion(
                 sbbdep::MAJOR_VERSION,
 CacheDB::Create()
 {
 
-  LogInfo()<< "create cache " << m_name << std::endl;
+  LogInfo()<< "create cache " << _name << std::endl;
 
   if (a4sqlt3::Database::Create() )
     {
           A4Z_THROW_NESTED("");
         }
 
-      CacheSQL::register_own_sql_functions(m_sql3db);
+      CacheSQL::register_own_sql_functions(_sql3db);
 
       // possible call first sync/creation here and create indexes later..
 
 {
     {
       std::string sql = "select count(*) from sqlite_master where name='version';";
-      a4sqlt3::OneValResult<int> rc;
-      Execute(sql, &rc);
-      if(!rc.isValid())
+
+      a4sqlt3::DbValue rc = this->selectSingleValue(sql);
+
+      if(rc.isNull())
         throw a4z::ErrorTodo();
 
-      if( rc.Val() != 1 )
+      if( rc.getInt64() != 1 )
         {
-          if( rc.Val() > 1 )
+          if( rc.getInt64() > 1 )
             {
               LogError() << "more than one entry in version table, confused and can not continue\n";
               throw a4z::ErrorTodo();
   auto getDbVersion = [calcDbVersion, this]() -> int
     {
       Dataset ds( {DbValueType::Int64, DbValueType::Int64} );
-      this->Execute("SELECT major, minor FROM version", &ds);
+      this->Execute("SELECT major, minor FROM version", ds);
       return calcDbVersion(ds.getField(0).getInt64(), ds.getField(1).getInt64());
     };
   auto getDbAppVersion = [calcFullVersion, this]() -> int
     {
       Dataset ds({DbValueType::Int64, DbValueType::Int64, DbValueType::Int64});
-      this->Execute("SELECT major, minor , patchlevel FROM version", &ds);
+      this->Execute("SELECT major, minor , patchlevel FROM version", ds);
       return calcFullVersion(ds.getField(0).getInt64(),
           ds.getField(1).getInt64(),ds.getField(2).getInt64());
     };
         {
           LogError() << "existing cache db was build with an old version of sbbdep.\n";
           LogError() << "please create a new cache by using the -c option or removing " <<
-              m_name << ".\n";
+              _name << ".\n";
           LogError() << "Sorry for the inconvenience caused.\n\n" ;
           throw a4z::ErrorMessage("old db version in use");
         }
 int64_t
 CacheDB::getLatestPkgTimeStamp()
 {
-  a4sqlt3::OneValResult< int64_t > maxTimeStamp;
-  Execute(CacheSQL::MaxPkgTimeStamp(), &maxTimeStamp);
-  // TODO, if maxTimeStamp is not valid,
-  // throw should never happen or does not matter cause will be 0 and thats ok
 
-  return maxTimeStamp.Val() ;
+  a4sqlt3::DbValue val = selectSingleValue(CacheSQL::MaxPkgTimeStamp());
+
+  return val.isNull() ? 0 : val.getInt64() ;
 
 }
 

File tests/cacheup1_2.cpp

 #include <sbbdep/cachesql.hpp>
 #include <sbbdep/cachedb.hpp>
 
-#include <a4sqlt3/onevalresult.hpp>
 #include <a4sqlt3/dataset.hpp>
 
 #include <iostream>
 
   DB(): CacheDB(":memory:"){}
 
-  sqlite3* getDb() { return m_sql3db; }
+  sqlite3* getDb() { return _sql3db; }
 
   void MakeTestTables()
   {
     std::string sql="ALTER TABLE rrunpath ADD COLUMN lddir TEXT;" ;
     BOOST_REQUIRE_NO_THROW(db.Execute(sql));
     {
-      a4sqlt3::OneValResult<int> cnt;
-      db.Execute("select count(*) from rrunpath;", & cnt);
-      BOOST_CHECK(cnt.isValid() && cnt.Val() == 3 ) ;
+      a4sqlt3::DbValue cnt = db.selectSingleValue("select count(*) from rrunpath;");
+      BOOST_CHECK( cnt.getInt64() == 3 ) ;
     }
 
   }
         ") ;" ;
     BOOST_REQUIRE_NO_THROW(db.Execute(sql));
 
-    a4sqlt3::OneValResult<std::string> wanted;
-    db.Execute("select lddir from rrunpath where id=1;", &wanted);
-    BOOST_CHECK(wanted.isValid() && wanted.Val() == "/usr/lib" ) ;
-    wanted.Reset();
-    db.Execute("select lddir from rrunpath where id=2;", &wanted);
-    BOOST_CHECK(wanted.isValid() && wanted.Val() == "/usr/lib" ) ;
-    wanted.Reset();
-    db.Execute("select lddir from rrunpath where id=3;", &wanted);
-    BOOST_CHECK(wanted.isValid() && wanted.isNull() ) ;
+    a4sqlt3::DbValue wanted = db.selectSingleValue("select lddir from rrunpath where id=1;");
+    BOOST_CHECK( wanted.getString() == "/usr/lib" ) ;
+
+    wanted = db.selectSingleValue("select lddir from rrunpath where id=2;");
+    BOOST_CHECK( wanted.getString() == "/usr/lib" ) ;
+
+    wanted = db.selectSingleValue("select lddir from rrunpath where id=3;");
+    BOOST_CHECK( wanted.isNull() ) ;
   }
 
 };

File tests/replorig.cpp

 
 #include <a4z/testsuitebuilder.hpp>
 #include <a4sqlt3/database.hpp>
-#include <a4sqlt3/onevalresult.hpp>
+
+
 #include <sbbdep/cachesql.hpp>
 
 #include <iostream>
   
   void createExtendedFunctions()
   {
-    CacheSQL::register_own_sql_functions( m_sql3db );
+    CacheSQL::register_own_sql_functions( _sql3db );
   }
   
 };
   db.Open() ;
   db.createExtendedFunctions() ;
   
-  a4sqlt3::OneValResult<std::string> result; 
+  a4sqlt3::DbValue result(a4sqlt3::DbValueType::Text);
   
   std::string c1sql = "SELECT replaceOrigin('$ORIGIN/../lib', '/usr/lib')" ;
   std::string c2sql = "SELECT replaceOrigin('$ORIGIN/local/lib', '/usr')" ;
   
-  db.Execute(c1sql, &result) ;
+  result = db.selectSingleValue(c1sql) ;
   
-  BOOST_REQUIRE_EQUAL( result.Val() , "/usr/lib"  );
+  BOOST_REQUIRE_EQUAL( result.getString() , "/usr/lib"  );
   
-  result.Reset();
-  
-  db.Execute(c2sql, &result) ;
-  BOOST_REQUIRE_EQUAL( result.Val() , "/usr/local/lib"  );
+  result = db.selectSingleValue(c2sql) ;
+  BOOST_REQUIRE_EQUAL( result.getString() , "/usr/local/lib"  );
   
   
 }