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
65
pglablib/PgConstraintContainer.cpp
Normal file
65
pglablib/PgConstraintContainer.cpp
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#include "PgConstraintContainer.h"
|
||||
#include "Pgsql_Col.h"
|
||||
#include <algorithm>
|
||||
|
||||
std::string PgConstraintContainer::getLoadQuery() const
|
||||
{
|
||||
std::string q = R"__(
|
||||
SELECT oid, conname, connamespace, contype, condeferrable,
|
||||
condeferred, convalidated, conrelid, contypid, conindid,
|
||||
confrelid, confupdtype, confdeltype, confmatchtype,
|
||||
conislocal, coninhcount, connoinherit, conkey, confkey,
|
||||
conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc,
|
||||
pg_get_constraintdef(oid)
|
||||
FROM pg_constraint)__";
|
||||
|
||||
// auto cat = m_catalogue.lock();
|
||||
// if (cat && cat->serverVersion() >= 90400)
|
||||
// q += ", indisreplident ";
|
||||
// q += "\nFROM pg_index";
|
||||
return q;
|
||||
}
|
||||
|
||||
//void operator<<(std::vector<int16_t> &s, const Pgsql::Value &v)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//void operator<<(std::vector<Oid> &s, const Pgsql::Value &v)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
PgConstraint PgConstraintContainer::loadElem(const Pgsql::Row &row)
|
||||
{
|
||||
Pgsql::Col col(row);
|
||||
PgConstraint v;
|
||||
col >> v.oid >> v.name >> v.connamespace >> v.type >> v.deferrable
|
||||
>> v.deferred >> v.validated >> v.relid >> v.typid >> v.indid
|
||||
>> v.frelid >> v.fupdtype >> v.fdeltype >> v.fmatchtype
|
||||
>> v.islocal >> v.inhcount >> v.noinherit;
|
||||
col.getAsArray<int16_t>(std::back_inserter(v.key));
|
||||
col.getAsArray<int16_t>(std::back_inserter(v.fkey));
|
||||
col.getAsArray<Oid>(std::back_inserter(v.pfeqop));
|
||||
col.getAsArray<Oid>(std::back_inserter(v.ppeqop));
|
||||
col.getAsArray<Oid>(std::back_inserter(v.ffeqop));
|
||||
col.getAsArray<Oid>(std::back_inserter(v.exclop));
|
||||
col >> v.bin >> v.src >> v.definition;
|
||||
return v;
|
||||
}
|
||||
|
||||
const PgConstraint* PgConstraintContainer::getFKeyForTableColumn(Oid relid, int16_t attnum) const
|
||||
{
|
||||
const PgConstraint *result = nullptr;
|
||||
// WHat do we want to find here? On ly single column constraints or all contstraints.
|
||||
// auto res = std::find_if(m_container.begin(), m_container.end(),
|
||||
// [relid, attnum] (const auto &c) {
|
||||
// // the find on v.key may not look super efficient but remember it in general only has one or two elements.
|
||||
// return relid == c.relid &&
|
||||
// (std::find(attnum.begin(), attnum.end(), v.key) != attnum.end());
|
||||
// });
|
||||
return result;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue