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
49
pglablib/PgIndexContainer.cpp
Normal file
49
pglablib/PgIndexContainer.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include "PgIndexContainer.h"
|
||||
#include "PgDatabaseCatalog.h"
|
||||
#include "Pgsql_Col.h"
|
||||
#include <iterator>
|
||||
|
||||
std::string PgIndexContainer::getLoadQuery() const
|
||||
{
|
||||
std::string q = R"__(
|
||||
SELECT indexrelid, indrelid, indnatts, indisunique, indisprimary,
|
||||
indisexclusion, indimmediate, indisclustered, indisvalid,
|
||||
indcheckxmin, indisready, indislive, indkey,
|
||||
indcollation, indclass, indoption, indexprs, indpred,
|
||||
pg_get_indexdef(indexrelid))__";
|
||||
|
||||
auto cat = m_catalogue.lock();
|
||||
if (cat && cat->serverVersion() >= 90400)
|
||||
q += ", indisreplident ";
|
||||
q += "\nFROM pg_index";
|
||||
return q;
|
||||
}
|
||||
|
||||
PgIndex PgIndexContainer::loadElem(const Pgsql::Row &row)
|
||||
{
|
||||
Pgsql::Col col(row);
|
||||
PgIndex v;
|
||||
col >> v.indexrelid >> v.relid >> v.natts >> v.isunique
|
||||
>> v.isprimary >> v.isexclusion >> v.immediate >> v.isclustered
|
||||
>> v.isvalid >> v.checkxmin >> v.isready >> v.islive;
|
||||
col.getAsVector<int16_t>(std::back_inserter(v.key));
|
||||
col.getAsVector<Oid>(std::back_inserter(v.collation));
|
||||
col.getAsVector<Oid>(std::back_inserter(v.indclass));
|
||||
col.getAsVector<int16_t>(std::back_inserter(v.option));
|
||||
col >> v.exprs >> v.pred >> v.definition;
|
||||
auto cat = m_catalogue.lock();
|
||||
if (cat && cat->serverVersion() >= 90400)
|
||||
col >> v.isreplident;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
std::vector<PgIndex> PgIndexContainer::getIndexesForTable(Oid table_oid) const
|
||||
{
|
||||
std::vector<PgIndex> result;
|
||||
for (const auto &e : m_container)
|
||||
if (e.relid == table_oid)
|
||||
result.push_back(e);
|
||||
|
||||
return result;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue