pgLab/pglablib/catalog/PgProc.h
eelke f0c1035378 Reorganize files in pglablib
The enitities and containers of the catalog now go into catalog subfolder
Models go into model
2018-12-16 11:31:33 +01:00

87 lines
2.3 KiB
C++

#ifndef PGPROC_H
#define PGPROC_H
#include "PgNamespaceObject.h"
#include <QString>
#include <libpq-fe.h>
#include "Pgsql_Value.h"
#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)
{}
};
class PgProc: public PgNamespaceObject {
public:
using PgNamespaceObject::PgNamespaceObject;
// Oid oid = InvalidOid; // oid
// QString name; // name
// Oid pronamespace = InvalidOid; // oid, namespace
Oid owner = InvalidOid; // oid
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
char provolatile = '\0'; // char
char parallel = '\0'; // char, version >= 9.6
int16_t nargs = 0; // int2
int16_t nargdefaults; // = 0; // int2
Oid rettype = InvalidOid; // oid
std::vector<Oid> trftypes; // oid[], version >= 9.5
QString src; // text
QString bin; // text
std::vector<QString> config; // text[]
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;
// 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; }
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;
};
#endif // PGPROC_H