49 lines
1.7 KiB
C++
49 lines
1.7 KiB
C++
#include "PgTypeContainer.h"
|
|
#include "Pgsql_Connection.h"
|
|
#include "Pgsql_Col.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, format_type(oid, NULL) AS name, 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";
|
|
}
|
|
|
|
PgType PgTypeContainer::loadElem(const Pgsql::Row &row)
|
|
{
|
|
Pgsql::Col col(row);
|
|
PgType v;
|
|
col >> v.oid >> v.name >> v.typname >> v.typnamespace >> v.owner >> v.len >> v.byval >> v.type >> v.category
|
|
>> v.ispreferred >> v.isdefined >> v.delim >> v.relid >> v.elem >> v.array >> v.input >> v.output
|
|
>> v.receive >> v.send >> v.modin >> v.modout >> v.analyze >> v.align >> v.storage >> v.notnull
|
|
>> v.basetype >> v.typmod >> v.ndims >> v.collation >> v.defaultbin >> v.typdefault >> v.acl;
|
|
return v;
|
|
}
|