2018-09-23 10:43:32 +02:00
|
|
|
|
#ifndef PGTRIGGER_H
|
|
|
|
|
|
#define PGTRIGGER_H
|
|
|
|
|
|
|
2018-11-25 19:45:06 +01:00
|
|
|
|
#include "PgNamespaceObject.h"
|
2018-09-23 10:43:32 +02:00
|
|
|
|
#include "Pgsql_Value.h"
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
#include <libpq-fe.h>
|
|
|
|
|
|
|
2018-10-07 19:40:06 +02:00
|
|
|
|
class PgDatabaseCatalog;
|
|
|
|
|
|
|
2018-11-25 19:45:06 +01:00
|
|
|
|
class PgTrigger: public PgNamespaceObject {
|
2018-09-23 10:43:32 +02:00
|
|
|
|
public:
|
2018-11-25 19:45:06 +01:00
|
|
|
|
// Oid oid = InvalidOid;
|
2018-10-07 19:40:06 +02:00
|
|
|
|
Oid relid;
|
2018-11-25 19:45:06 +01:00
|
|
|
|
// QString name;
|
2018-10-07 19:40:06 +02:00
|
|
|
|
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;
|
2018-11-18 19:30:45 +01:00
|
|
|
|
QString whenclause;
|
|
|
|
|
|
QString oldtable; // >= 10.0
|
|
|
|
|
|
QString newtable; // >= 10.0
|
|
|
|
|
|
|
2018-11-25 19:45:06 +01:00
|
|
|
|
using PgNamespaceObject::PgNamespaceObject;
|
2018-11-18 19:30:45 +01:00
|
|
|
|
|
2018-11-25 19:45:06 +01:00
|
|
|
|
// virtual QString objectName() const override;
|
2018-11-18 19:30:45 +01:00
|
|
|
|
|
2018-10-07 19:40:06 +02:00
|
|
|
|
|
2018-11-25 19:45:06 +01:00
|
|
|
|
// 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; }
|
2018-10-07 19:40:06 +02:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
2019-02-09 09:49:27 +01:00
|
|
|
|
QString dropSql() const override;
|
|
|
|
|
|
QString createSql() const override;
|
2018-10-07 19:40:06 +02:00
|
|
|
|
bool isRow() const { return type & TriggerTypeRow; }
|
|
|
|
|
|
bool isBefore() const { return type & TriggerTypeBefore; }
|
|
|
|
|
|
QString typeFireWhen() const;
|
|
|
|
|
|
QString eventAbbr() const;
|
|
|
|
|
|
QString event() const;
|
|
|
|
|
|
QString forEach() const;
|
2018-11-18 19:30:45 +01:00
|
|
|
|
QString procedure() const;
|
2018-10-07 19:40:06 +02:00
|
|
|
|
|
|
|
|
|
|
//wxString pgTrigger::GetForEach() const
|
|
|
|
|
|
//{
|
|
|
|
|
|
// return (triggerType & TRIGGER_TYPE_ROW) ? wxT("ROW") : wxT("STATEMENT");
|
|
|
|
|
|
//}
|
2018-09-23 10:43:32 +02:00
|
|
|
|
|
2018-11-18 19:30:45 +01:00
|
|
|
|
QString arguments() const;
|
2018-12-24 11:31:56 +01:00
|
|
|
|
|
|
|
|
|
|
QString typeName() const override;
|
2018-10-07 19:40:06 +02:00
|
|
|
|
private:
|
|
|
|
|
|
mutable QString m_dropSql; // cache
|
|
|
|
|
|
mutable QString m_createSql; // cache
|
2018-09-23 10:43:32 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // PGTRIGGER_H
|