pg_trigger

This commit is contained in:
eelke 2018-09-23 10:43:32 +02:00
parent ae86fef2b4
commit 7c7e72ae14
5 changed files with 90 additions and 2 deletions

6
pglablib/PgTrigger.cpp Normal file
View file

@ -0,0 +1,6 @@
#include "PgTrigger.h"
PgTrigger::PgTrigger()
{
}

28
pglablib/PgTrigger.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef PGTRIGGER_H
#define PGTRIGGER_H
#include "Pgsql_Value.h"
#include <QString>
#include <libpq-fe.h>
class PgTrigger {
public:
Oid tgrelid;
QString tgname;
Oid tgfoid;
int16_t tgtype;
char tgenabled;
bool tgisinternal;
Oid tgconstrrelid;
Oid tgconstrindid;
Oid tgconstraint;
bool tgdeferrable;
bool tginitdeferred;
int16_t tgnargs;
QString tgattr;
QString tgargs;
QString tgqual;
};
#endif // PGTRIGGER_H

View file

@ -0,0 +1,21 @@
#include "PgTriggerContainer.h"
#include "Pgsql_Connection.h"
#include "Pgsql_Col.h"
std::string PgTriggerContainer::getLoadQuery() const
{
return R"(SELECT *
FROM pg_trigger
WHERE NOT tgisinternal)";
}
PgTrigger PgTriggerContainer::loadElem(const Pgsql::Row &row)
{
Pgsql::Col col(row);
PgTrigger v;
col >> v.tgrelid >> v.tgname >> v.tgfoid >> v.tgtype >> v.tgenabled >> v.tgisinternal >> v.tgconstrrelid
>> v.tgconstrindid >> v.tgconstraint >> v.tgdeferrable >> v.tginitdeferred >> v.tgnargs >> v.tgattr
>> v.tgargs >> v.tgqual;
return v;
}

View file

@ -0,0 +1,25 @@
#ifndef PGTRIGGERCONTAINER_H
#define PGTRIGGERCONTAINER_H
#include "PgContainer.h"
#include "PgTrigger.h"
namespace Pgsql {
class Result;
}
class PgTriggerContainer: public PgContainer<PgTrigger> {
public:
using PgContainer<PgTrigger>::PgContainer;
virtual std::string getLoadQuery() const override;
protected:
PgTrigger loadElem(const Pgsql::Row &row) override;
private:
};
#endif // PGTRIGGERCONTAINER_H

View file

@ -61,7 +61,11 @@ codebuilder/DefaultConfigs.cpp \
codebuilder/TypeMappings.cpp \
codebuilder/IndentationConfig.cpp \
codebuilder/StructureTemplate.cpp \
FormatToStream.cpp
FormatToStream.cpp \
codebuilder/StringLiteralRules.cpp \
codebuilder/StringEscapeRule.cpp \
PgTrigger.cpp \
PgTriggerContainer.cpp
HEADERS += \
Pglablib.h \
@ -105,7 +109,11 @@ codebuilder/TypeMappings.h \
codebuilder/IndentationConfig.h \
codebuilder/StructureTemplate.h \
FormatToStream.h \
codebuilder/ResultLoopTemplate.h
codebuilder/ResultLoopTemplate.h \
codebuilder/StringEscapeRule.h \
codebuilder/StringLiteralRules.h \
PgTrigger.h \
PgTriggerContainer.h
unix {
target.path = /usr/lib