pgLab/pglablib/PgTrigger.h

62 lines
1.6 KiB
C
Raw Normal View History

2018-09-23 10:43:32 +02:00
#ifndef PGTRIGGER_H
#define PGTRIGGER_H
#include "Pgsql_Value.h"
#include <QString>
#include <libpq-fe.h>
class PgDatabaseCatalog;
2018-09-23 10:43:32 +02:00
class PgTrigger {
public:
Oid oid = InvalidOid;
Oid relid;
QString name;
Oid foid;
int16_t type;
char enabled;
bool isinternal;
Oid constrrelid;
Oid constrindid;
Oid constraint;
bool deferrable;
bool initdeferred;
int16_t nargs;
QString attr;
QString args;
QString qual;
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 PgTrigger &rhs) const { return oid < rhs.oid; }
static constexpr int TriggerTypeRow = (1 << 0);
static constexpr int TriggerTypeBefore = (1 << 1);
static constexpr int TriggerTypeInsert = (1 << 2);
static constexpr int TriggerTypeDelete = (1 << 3);
static constexpr int TriggerTypeUpdate = (1 << 4);
static constexpr int TriggerTypeTruncate = (1 << 5);
static constexpr int TriggerTypeInstead = (1 << 6);
QString dropSql(const PgDatabaseCatalog &catalog);
QString createSql(const PgDatabaseCatalog &catalog);
bool isRow() const { return type & TriggerTypeRow; }
bool isBefore() const { return type & TriggerTypeBefore; }
QString typeFireWhen() const;
QString eventAbbr() const;
QString event() const;
QString forEach() const;
//wxString pgTrigger::GetForEach() const
//{
// return (triggerType & TRIGGER_TYPE_ROW) ? wxT("ROW") : wxT("STATEMENT");
//}
2018-09-23 10:43:32 +02:00
private:
mutable QString m_dropSql; // cache
mutable QString m_createSql; // cache
2018-09-23 10:43:32 +02:00
};
#endif // PGTRIGGER_H