2017-12-09 10:45:13 +01:00
|
|
|
|
#include "PgDatabaseContainer.h"
|
2017-08-26 11:45:50 +02:00
|
|
|
|
#include "Pgsql_Connection.h"
|
2017-12-09 10:45:13 +01:00
|
|
|
|
#include "Pgsql_Col.h"
|
2017-02-12 14:03:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string PgDatabaseContainer::getLoadQuery() const
|
|
|
|
|
|
{
|
2017-02-13 19:51:19 +01:00
|
|
|
|
return "SELECT oid,datname,datdba,encoding,datcollate,datctype,datistemplate,datallowconn,"
|
2017-02-12 14:03:42 +01:00
|
|
|
|
"datconnlimit,dattablespace,datacl FROM pg_database";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PgDatabaseContainer::load(const Pgsql::Result &res)
|
|
|
|
|
|
{
|
2017-02-18 12:05:48 +01:00
|
|
|
|
const int n_rows = res.rows();
|
2017-02-12 14:03:42 +01:00
|
|
|
|
m_container.clear();
|
|
|
|
|
|
m_container.reserve(n_rows);
|
|
|
|
|
|
for (auto row : res) {
|
2017-12-09 10:45:13 +01:00
|
|
|
|
Pgsql::Col col(row);
|
2017-02-12 14:03:42 +01:00
|
|
|
|
PgDatabase v;
|
2017-12-09 10:45:13 +01:00
|
|
|
|
col >> v.oid >> v.name >> v.dba >> v.encoding >> v.collate >> v.ctype >> v.isTemplate
|
|
|
|
|
|
>> v.allowConn >> v.connLimit >> v.tablespace >> v.acl;
|
2017-02-12 14:03:42 +01:00
|
|
|
|
m_container.push_back(v);
|
|
|
|
|
|
}
|
|
|
|
|
|
std::sort(m_container.begin(), m_container.end());
|
|
|
|
|
|
}
|
|
|
|
|
|
|