WIP: Added page showing list of functions.

Only list is shown, still working on details.
This commit is contained in:
eelke 2018-11-25 09:06:01 +01:00
parent 7db859737a
commit 840af1e0a9
19 changed files with 635 additions and 92 deletions

View file

@ -5,6 +5,24 @@
#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 PgSchemaObject {
public:
@ -28,18 +46,24 @@ public:
char provolatile = '\0'; // char
char parallel = '\0'; // char, version >= 9.6
int16_t nargs = 0; // int2
int16_t nargdefaults = 0; // int2
int16_t nargdefaults; // = 0; // int2
Oid rettype = InvalidOid; // oid
std::vector<Oid> argtypes; // oid[]
std::vector<Oid> allargtypes; // oid[]
std::vector<char> argmodes; // char[]
std::vector<QString> argnames; // text[]
std::optional<QString> argdefaults; // pg_node_tree
std::vector<Oid> trftypes; // oid[], version >= 9.5
QString src; // text
QString bin; // text
std::vector<QString> config; // text[]
std::vector<QString> acl; // aclitem[]
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; }
@ -47,6 +71,19 @@ public:
bool operator<(const PgProc &rhs) const { return oid < rhs.oid; }
virtual QString objectName() const override;
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