2018-11-17 19:38:07 +01:00
|
|
|
|
#ifndef PGPROC_H
|
|
|
|
|
|
#define PGPROC_H
|
|
|
|
|
|
|
2018-11-25 19:45:06 +01:00
|
|
|
|
#include "PgNamespaceObject.h"
|
2018-12-17 21:51:14 +01:00
|
|
|
|
#include "PgOwnedObject.h"
|
2018-11-17 19:38:07 +01:00
|
|
|
|
#include <QString>
|
|
|
|
|
|
#include <libpq-fe.h>
|
|
|
|
|
|
#include "Pgsql_Value.h"
|
2018-11-25 09:06:01 +01:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
class Arg {
|
|
|
|
|
|
public:
|
|
|
|
|
|
enum Mode {
|
|
|
|
|
|
In, Out, InOut, Variadic, Table
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Oid type;
|
|
|
|
|
|
Mode mode;
|
|
|
|
|
|
QString name;
|
|
|
|
|
|
QString def;
|
|
|
|
|
|
|
|
|
|
|
|
Arg(Oid t, Mode m, QString n, QString d)
|
|
|
|
|
|
: type(t), mode(m), name(n), def(d)
|
|
|
|
|
|
{}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2018-11-17 19:38:07 +01:00
|
|
|
|
|
2018-12-17 21:51:14 +01:00
|
|
|
|
class PgProc: public PgNamespaceObject, public PgOwnedObject {
|
2018-11-17 19:38:07 +01:00
|
|
|
|
public:
|
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
|
|
|
|
// Oid oid = InvalidOid; // oid
|
|
|
|
|
|
// QString name; // name
|
2018-11-18 19:30:45 +01:00
|
|
|
|
// Oid pronamespace = InvalidOid; // oid, namespace
|
2018-12-17 21:51:14 +01:00
|
|
|
|
// Oid owner = InvalidOid; // oid
|
2018-11-18 19:30:45 +01:00
|
|
|
|
Oid lang = InvalidOid; // oid
|
|
|
|
|
|
float cost = 0.f; // float4
|
|
|
|
|
|
float rows = 0.f; // float4
|
|
|
|
|
|
Oid variadic = InvalidOid; // oid
|
|
|
|
|
|
QString transform; // regproc
|
|
|
|
|
|
bool isagg = false; // bool
|
|
|
|
|
|
bool iswindow = false; // bool
|
|
|
|
|
|
bool secdef = false; // bool
|
|
|
|
|
|
bool leakproof = false; // bool
|
|
|
|
|
|
bool isstrict = false; // bool
|
|
|
|
|
|
bool retset = false; // bool
|
2018-11-17 19:38:07 +01:00
|
|
|
|
char provolatile = '\0'; // char
|
2018-11-18 19:30:45 +01:00
|
|
|
|
char parallel = '\0'; // char, version >= 9.6
|
|
|
|
|
|
int16_t nargs = 0; // int2
|
2018-11-25 09:06:01 +01:00
|
|
|
|
int16_t nargdefaults; // = 0; // int2
|
2018-11-18 19:30:45 +01:00
|
|
|
|
Oid rettype = InvalidOid; // oid
|
|
|
|
|
|
std::vector<Oid> trftypes; // oid[], version >= 9.5
|
|
|
|
|
|
QString src; // text
|
|
|
|
|
|
QString bin; // text
|
|
|
|
|
|
std::vector<QString> config; // text[]
|
2018-11-25 09:06:01 +01:00
|
|
|
|
QString acl; // aclitem[]
|
|
|
|
|
|
|
|
|
|
|
|
/// Converts the collection of arrays about the arguments to a single list of arguments
|
|
|
|
|
|
/// making it much easier to work with them correctly
|
|
|
|
|
|
void setArgs(
|
|
|
|
|
|
std::vector<Oid> argtypes,
|
|
|
|
|
|
std::vector<Oid> allargtypes,
|
|
|
|
|
|
std::vector<char> argmodes,
|
|
|
|
|
|
std::vector<QString> argnames,
|
|
|
|
|
|
std::optional<QString> argdefaults
|
|
|
|
|
|
);
|
|
|
|
|
|
const std::vector<Arg>& args() const;
|
2018-11-17 19:38:07 +01: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 PgProc &rhs) const { return oid < rhs.oid; }
|
2018-11-25 09:06:01 +01:00
|
|
|
|
|
|
|
|
|
|
QString createSql() const;
|
|
|
|
|
|
QString argListWithNames(bool multiline = false) const;
|
|
|
|
|
|
QString argSigList(const bool forScript = false) const;
|
|
|
|
|
|
|
|
|
|
|
|
// bool isTrigger() const
|
|
|
|
|
|
// {
|
|
|
|
|
|
// return typname == wxT("\"trigger\"") || typname == wxT("trigger") || typname == wxT("event_trigger") || typname == wxT("\"event_trigger\""))
|
|
|
|
|
|
// }
|
|
|
|
|
|
private:
|
|
|
|
|
|
mutable QString createSqlCache;
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<Arg> m_args;
|
2018-11-17 19:38:07 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // PGPROC_H
|