Reorganize files in pglablib

The enitities and containers of the catalog now go into catalog subfolder
Models go into model
This commit is contained in:
eelke 2018-12-16 10:17:59 +01:00
parent 56cbeea183
commit f0c1035378
121 changed files with 226 additions and 183 deletions

View file

@ -1,44 +0,0 @@
#include "PgAttributeContainer.h"
#include "Pgsql_Col.h"
#include "PgDatabaseCatalog.h"
//SELECT attname, pg_get_expr(adbin, adrelid) AS def_value
//FROM pg_attribute
// JOIN pg_attrdef ON attrelid=adrelid AND attnum=adnum
//WHERE atthasdef=true
std::string PgAttributeContainer::getLoadQuery() const
{
std::string q = R"__(
SELECT attrelid, attname, atttypid, attstattarget,
attnum, attndims, atttypmod, attnotnull, atthasdef, attisdropped,
attislocal, attcollation, attacl, attoptions, pg_get_expr(adbin, adrelid) AS def_value)__";
if (m_catalog.serverVersion() >= 100000)
q += ", attidentity";
q +=
"\n FROM pg_catalog.pg_attribute \n"
" LEFT JOIN pg_attrdef ON attrelid=adrelid AND attnum=adnum";
return q;
}
PgAttribute PgAttributeContainer::loadElem(const Pgsql::Row &row)
{
Pgsql::Col col(row);
PgAttribute v;
col >> v.relid >> v.name >> v.typid >> v.stattarget
>> v.num >> v.ndims >> v.typmod >> v.notnull >> v.hasdef >> v.isdropped
>> v.islocal >> v.collation >> v.acl >> v.options >> v.defaultValue;
if (m_catalog.serverVersion() >= 100000)
col >> v.identity;
return v;
}
std::vector<PgAttribute> PgAttributeContainer::getColumnsForRelation(Oid oid) const
{
std::vector<PgAttribute> result;
for (const auto &e : m_container)
if (e.relid == oid)
result.push_back(e);
return result;
}