2017-08-26 11:44:40 +02:00
|
|
|
#include "PgTypeContainer.h"
|
2017-01-25 06:52:02 +01:00
|
|
|
#include "PgsqlConn.h"
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
2017-08-26 11:44:40 +02:00
|
|
|
PgTypeContainer::PgTypeContainer(PgDatabaseCatalogue *cat)
|
2017-02-18 12:05:48 +01:00
|
|
|
: PgContainer<PgType>(cat)
|
|
|
|
|
{}
|
2017-01-25 06:52:02 +01:00
|
|
|
|
|
|
|
|
|
2017-02-12 14:03:42 +01:00
|
|
|
//const PgType& PgTypeContainer::getTypeByOid(Oid oid) const
|
|
|
|
|
//{
|
|
|
|
|
// auto lb_result = std::lower_bound(m_types.begin(), m_types.end(), oid);
|
|
|
|
|
// if (lb_result != m_types.end() && lb_result->oid == oid)
|
|
|
|
|
// return *lb_result;
|
2017-01-25 06:52:02 +01:00
|
|
|
|
2017-02-12 14:03:42 +01:00
|
|
|
// return m_invalidType;
|
|
|
|
|
//}
|
2017-01-25 06:52:02 +01:00
|
|
|
|
2017-02-12 14:03:42 +01:00
|
|
|
//const PgType& PgTypeContainer::getTypeByName(const QString &name) const
|
|
|
|
|
//{
|
|
|
|
|
// auto find_res = std::find(m_types.begin(), m_types.end(), name);
|
2017-01-25 06:52:02 +01:00
|
|
|
|
2017-02-12 14:03:42 +01:00
|
|
|
// if (find_res != m_types.end())
|
|
|
|
|
// return *find_res;
|
2017-01-25 06:52:02 +01:00
|
|
|
|
2017-02-12 14:03:42 +01:00
|
|
|
// return m_invalidType;
|
|
|
|
|
//}
|
2017-01-25 06:52:02 +01:00
|
|
|
|
2017-02-12 14:03:42 +01:00
|
|
|
//const PgType& PgTypeContainer::getTypeByIdx(int idx) const
|
|
|
|
|
//{
|
|
|
|
|
// return m_types.at(idx);
|
|
|
|
|
//}
|
2017-02-04 11:55:49 +01:00
|
|
|
|
2017-01-25 06:52:02 +01:00
|
|
|
std::string PgTypeContainer::getLoadQuery()
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
"SELECT oid, typname, typnamespace, typowner, typlen, typbyval, typtype, typcategory, \n"
|
|
|
|
|
" typispreferred, typisdefined, typdelim, typrelid, typelem, typarray, typinput, typoutput, \n"
|
|
|
|
|
" typreceive, typsend, typmodin, typmodout, typanalyze, typalign, typstorage, typnotnull, \n"
|
|
|
|
|
" typbasetype, typtypmod, typndims, typcollation, typdefaultbin, typdefault, typacl \n"
|
|
|
|
|
"FROM pg_type";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PgTypeContainer::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);
|
2017-01-25 06:52:02 +01:00
|
|
|
for (auto row : res) {
|
|
|
|
|
PgType v;
|
2017-08-22 12:45:45 +02:00
|
|
|
v.oid << row.get(0); // InvalidOid;
|
|
|
|
|
v.typname << row.get(1); //. operator QString(); // "name";"NO"
|
|
|
|
|
v.typnamespace << row.get(2); // InvalidOid;//"oid";"NO"
|
|
|
|
|
v.typowner << row.get(3); // InvalidOid;//"oid";"NO"
|
|
|
|
|
v.typlen << row.get(4); // -1;//"smallint";"NO"
|
|
|
|
|
v.typbyval << row.get(5); // false;//"boolean";"NO"
|
|
|
|
|
v.typtype << row.get(6);//""char"";"NO"
|
|
|
|
|
v.typcategory << row.get(7);//""char"";"NO"
|
|
|
|
|
v.typispreferred << row.get(8); //false;//"boolean";"NO"
|
|
|
|
|
v.typisdefined << row.get(9); //false;//"boolean";"NO"
|
|
|
|
|
v.typdelim << row.get(10); //""char"";"NO"
|
|
|
|
|
v.typrelid << row.get(11); // InvalidOid;//"oid";"NO"
|
|
|
|
|
v.typelem << row.get(12); // InvalidOid;//"oid";"NO"
|
|
|
|
|
v.typarray << row.get(13); // InvalidOid;//"oid";"NO"
|
|
|
|
|
v.typinput << row.get(14);//regproc";"NO"
|
|
|
|
|
v.typoutput << row.get(15);//"regproc";"NO"
|
|
|
|
|
v.typreceive << row.get(16);//"regproc";"NO"
|
|
|
|
|
v.typsend << row.get(17);//"regproc";"NO"
|
|
|
|
|
v.typmodin << row.get(18);//"regproc";"NO"
|
|
|
|
|
v.typmodout << row.get(19);//"regproc";"NO"
|
|
|
|
|
v.typanalyze << row.get(20);//"regproc";"NO"
|
|
|
|
|
v.typalign << row.get(21); // //""char"";"NO"
|
|
|
|
|
v.typstorage << row.get(22); //""char"";"NO"
|
|
|
|
|
v.typnotnull << row.get(23); //"boolean";"NO"
|
|
|
|
|
v.typbasetype << row.get(24); //"oid";"NO"
|
|
|
|
|
v.typtypmod << row.get(25); //-1;//"integer";"NO"
|
|
|
|
|
v.typndims << row.get(26); //"integer";"NO"
|
|
|
|
|
v.typcollation << row.get(27); //InvalidOid;//"oid";"NO"
|
|
|
|
|
v.typdefaultbin << row.get(28);//"pg_node_tree";"YES"
|
|
|
|
|
v.typdefault << row.get(29);//"text";"YES"
|
|
|
|
|
v.typacl << row.get(30);//"ARRAY";"YES"
|
2017-02-12 14:03:42 +01:00
|
|
|
m_container.push_back(v);
|
2017-01-25 06:52:02 +01:00
|
|
|
}
|
2017-02-12 14:03:42 +01:00
|
|
|
std::sort(m_container.begin(), m_container.end());
|
2017-01-25 06:52:02 +01:00
|
|
|
}
|