sqlite3_command_ptr _cmd_attr_tstr;
sqlite3_command_ptr _cmd_attr_num;
sqlite3_command_ptr _cmd_disk_usage;
+ sqlite3_command_ptr _cmd_shared_id;
Impl( const Pathname &dbdir)
: _dbdir(dbdir)
_con.open((dbdir + "zypp.db").asString().c_str());
_con.executenonquery("PRAGMA cache_size=8000;");
+ _cmd_shared_id.reset( new sqlite3_command( _con, "select shared_id from resolvables where id=:rid;") );
+
_cmd_attr_tstr.reset( new sqlite3_command( _con, "select a.text, l.name from text_attributes a,types l,types t where a.weak_resolvable_id=:rid and a.lang_id=l.id and a.attr_id=t.id and l.class=:lclass and t.class=:tclass and t.name=:tname;") );
_cmd_attr_num.reset( new sqlite3_command( _con, "select a.value from numeric_attributes a,types t where a.weak_resolvable_id=:rid and a.attr_id=t.id and t.class=:tclass and t.name=:tname;"));
_cmd_disk_usage.reset( new sqlite3_command( _con, "select d.name,du.size,du.files from resolvable_disk_usage du,dir_names d where du.resolvable_id=:rid and du.dir_name_id=d.id;"));
-
+
MIL << "Creating Resolvable query impl" << endl;
// 0 1 2 3 4 5 6 7 8 9 10 11 12
_fields = "id, name, version, release, epoch, arch, kind, installed_size, archive_size, install_only, build_time, install_time, repository_id";
// see _fields definition above for the getXXX() numbers
ptr->name = reader.getstring(1);
- ptr->edition = Edition( reader.getstring(2), reader.getstring(3), reader.getint(4));
+ ptr->edition = Edition( reader.getstring(2), reader.getstring(3), reader.getint(4) );
ptr->arch = _type_cache.archFor(reader.getint(5));
ptr->kind = _type_cache.kindFor( reader.getint(6) );
ptr->repository = reader.getint( 12 );
return ptr;
}
-
+
void query( const data::RecordId &id,
ProcessResolvable fnc )
{
void query( const std::string &s,
ProcessResolvable fnc )
- {
-
+ {
+
sqlite3_command cmd( _con, "select " + _fields + " from resolvables where name like :name;");
cmd.bind( ":name", regex2sql( s ) );
sqlite3_reader reader = cmd.executereader();
{
return ( queryNumericAttributeInternal( _con, record_id, klass, name, default_value) > 0 );
}
-
+
int queryNumericAttribute( const data::RecordId &record_id,
const std::string &klass,
const std::string &name,
}
return alias;
}
-
+
data::RecordId queryRepositoryId( const std::string &repo_alias )
{
long long id = 0;
}
return id;
}
-
+
void iterateResolvablesByKindsAndStringsAndRepos( const std::vector<zypp::Resolvable::Kind> & kinds,
const std::vector<std::string> &strings, int flags, const std::vector<std::string> repos, ProcessResolvable fnc )
{
//FIXME: Implement MATCH_RESSUMM and MATCH_RESDESC
sqlcmd += " name ";
- if (flags & MATCH_WILDCARDS == 0)
+ if ((flags & MATCH_WILDCARDS) == 0)
{
sqlcmd += "=";
}
sqlite3_reader reader = _cmd_attr_num->executereader();
if ( reader.read() )
return reader.getint(0);
+ else
+ {
+ reader.close();
+ sqlite3_reader idreader = _cmd_shared_id->executereader();
+ if ( idreader.read() )
+ {
+ _cmd_shared_id->bind(":rid", record_id);
+ data::RecordId sid = idreader.getint(0);
+ idreader.close();
+ return queryNumericAttributeInternal(con, sid, klass, name, default_value);
+ }
+ }
return default_value;
}
-
+
TranslatedText queryTranslatedStringAttributeInternal( sqlite3_connection &con,
const data::RecordId &record_id,
const std::string &klass,
TranslatedText result;
sqlite3_reader reader = _cmd_attr_tstr->executereader();
-
+
int c = 0;
while(reader.read())
{
if ( c>0 )
return result;
-
+ else
+ {
+ reader.close();
+ _cmd_shared_id->bind(":rid", record_id);
+ sqlite3_reader idreader = _cmd_shared_id->executereader();
+ if ( idreader.read() )
+ {
+ data::RecordId sid = idreader.getint(0);
+ idreader.close();
+ return queryTranslatedStringAttributeInternal(con, sid, klass, name, default_value);
+ }
+ }
+
return default_value;
}
_cmd_attr_str->bind(":tname", name);
sqlite3_reader reader = _cmd_attr_str->executereader();
-
+
if ( reader.read() )
return reader.getstring(0);
-
+ else
+ {
+ reader.close();
+ _cmd_shared_id->bind(":rid", record_id);
+ sqlite3_reader idreader = _cmd_shared_id->executereader();
+ if ( idreader.read() )
+ {
+ data::RecordId sid = idreader.getint(0);
+ idreader.close();
+ return queryStringAttributeTranslationInternal( con, sid, locale, klass, name, default_value );
+ }
+ }
+
return default_value;
}
};
//////////////////////////////////////////////////////////////////////////////
ResolvableQuery::ResolvableQuery( const Pathname &dbdir)
- : _pimpl(new Impl(dbdir))
+ : _pimpl(/*new Impl(dbdir)*/)
{
//MIL << "Creating Resolvable query" << endl;
}