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
78
pglablib/PgConstraint.h
Normal file
78
pglablib/PgConstraint.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#ifndef PGCONSTRAINT_H
|
||||
#define PGCONSTRAINT_H
|
||||
|
||||
#include "Pgsql_Value.h"
|
||||
#include <QString>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
enum class ConstraintType {
|
||||
Check, // c
|
||||
ForeignKey, // f
|
||||
PrimaryKey, // p
|
||||
Unique, // u
|
||||
ConstraintTrigger, // t
|
||||
ExclusionConstraint, // x
|
||||
};
|
||||
|
||||
void operator<<(ConstraintType &s, const Pgsql::Value &v);
|
||||
|
||||
|
||||
enum class ForeignKeyAction {
|
||||
NoAction, // a
|
||||
Restrict, // r
|
||||
Cascade, // c
|
||||
SetNull, // n
|
||||
SetDefault // d
|
||||
};
|
||||
|
||||
void operator<<(ForeignKeyAction &s, const Pgsql::Value &v);
|
||||
|
||||
enum class ForeignKeyMatch {
|
||||
Full, // f
|
||||
Partial, // p
|
||||
Simple // s
|
||||
};
|
||||
|
||||
void operator<<(ForeignKeyMatch &s, const Pgsql::Value &v);
|
||||
|
||||
class PgConstraint {
|
||||
public:
|
||||
Oid oid = InvalidOid;
|
||||
QString name;
|
||||
Oid connamespace = InvalidOid;
|
||||
ConstraintType type;
|
||||
bool deferrable;
|
||||
bool deferred;
|
||||
bool validated;
|
||||
Oid relid = InvalidOid; ///< the table this constraint is on
|
||||
Oid typid = InvalidOid;
|
||||
Oid indid = InvalidOid; ///< index supporting the constraint
|
||||
Oid frelid = InvalidOid; ///< only for FK, referenced table pg_class
|
||||
ForeignKeyAction fupdtype; // on update
|
||||
ForeignKeyAction fdeltype; // on delete
|
||||
ForeignKeyMatch fmatchtype; // match type
|
||||
bool islocal;
|
||||
int32_t inhcount;
|
||||
bool noinherit;
|
||||
std::vector<int16_t> key; // list of constraint columns attnum
|
||||
std::vector<int16_t> fkey; // fkey list of referenced columns
|
||||
std::vector<Oid> pfeqop;
|
||||
std::vector<Oid> ppeqop;
|
||||
std::vector<Oid> ffeqop;
|
||||
std::vector<Oid> exclop;
|
||||
QString bin;
|
||||
QString src;
|
||||
|
||||
QString definition;
|
||||
|
||||
PgConstraint();
|
||||
bool operator==(Oid _oid) const { return oid == _oid; }
|
||||
bool operator==(const QString &n) const { return name == n; }
|
||||
bool operator<(Oid _oid) const { return oid < _oid; }
|
||||
bool operator<(const PgConstraint &rhs) const { return oid < rhs.oid; }
|
||||
};
|
||||
|
||||
#endif // PGCONSTRAINT_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue