Moved several files from pglab project to pglablib
This commit is contained in:
parent
206d734ff5
commit
f4538069cb
44 changed files with 45 additions and 44 deletions
80
pglablib/PgTypeContainer.cpp
Normal file
80
pglablib/PgTypeContainer.cpp
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#include "PgTypeContainer.h"
|
||||
#include "Pgsql_Connection.h"
|
||||
#include <algorithm>
|
||||
|
||||
//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;
|
||||
|
||||
// return m_invalidType;
|
||||
//}
|
||||
|
||||
//const PgType& PgTypeContainer::getTypeByName(const QString &name) const
|
||||
//{
|
||||
// auto find_res = std::find(m_types.begin(), m_types.end(), name);
|
||||
|
||||
// if (find_res != m_types.end())
|
||||
// return *find_res;
|
||||
|
||||
// return m_invalidType;
|
||||
//}
|
||||
|
||||
//const PgType& PgTypeContainer::getTypeByIdx(int idx) const
|
||||
//{
|
||||
// return m_types.at(idx);
|
||||
//}
|
||||
|
||||
std::string PgTypeContainer::getLoadQuery() const
|
||||
{
|
||||
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)
|
||||
{
|
||||
const int n_rows = res.rows();
|
||||
m_container.clear();
|
||||
m_container.reserve(n_rows);
|
||||
for (auto row : res) {
|
||||
PgType v;
|
||||
v.oid << row.get(0); // InvalidOid;
|
||||
v.name << row.get(1); //. operator QString(); // "name";"NO"
|
||||
v.typnamespace << row.get(2); // InvalidOid;//"oid";"NO"
|
||||
v.owner << row.get(3); // InvalidOid;//"oid";"NO"
|
||||
v.len << row.get(4); // -1;//"smallint";"NO"
|
||||
v.byval << row.get(5); // false;//"boolean";"NO"
|
||||
v.type << row.get(6);//""char"";"NO"
|
||||
v.category << row.get(7);//""char"";"NO"
|
||||
v.ispreferred << row.get(8); //false;//"boolean";"NO"
|
||||
v.isdefined << row.get(9); //false;//"boolean";"NO"
|
||||
v.delim << row.get(10); //""char"";"NO"
|
||||
v.relid << row.get(11); // InvalidOid;//"oid";"NO"
|
||||
v.elem << row.get(12); // InvalidOid;//"oid";"NO"
|
||||
v.array << row.get(13); // InvalidOid;//"oid";"NO"
|
||||
v.input << row.get(14);//regproc";"NO"
|
||||
v.output << row.get(15);//"regproc";"NO"
|
||||
v.receive << row.get(16);//"regproc";"NO"
|
||||
v.send << row.get(17);//"regproc";"NO"
|
||||
v.modin << row.get(18);//"regproc";"NO"
|
||||
v.modout << row.get(19);//"regproc";"NO"
|
||||
v.analyze << row.get(20);//"regproc";"NO"
|
||||
v.align << row.get(21); // //""char"";"NO"
|
||||
v.storage << row.get(22); //""char"";"NO"
|
||||
v.notnull << row.get(23); //"boolean";"NO"
|
||||
v.basetype << row.get(24); //"oid";"NO"
|
||||
v.typmod << row.get(25); //-1;//"integer";"NO"
|
||||
v.ndims << row.get(26); //"integer";"NO"
|
||||
v.collation << row.get(27); //InvalidOid;//"oid";"NO"
|
||||
v.defaultbin << row.get(28);//"pg_node_tree";"YES"
|
||||
v.typdefault << row.get(29);//"text";"YES"
|
||||
v.acl << row.get(30);//"ARRAY";"YES"
|
||||
m_container.push_back(v);
|
||||
}
|
||||
std::sort(m_container.begin(), m_container.end());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue