pgLab/pglablib/catalog/PgClass.h
eelke 3158a4364b Show SQL for database
Also improvements to the SQL for tables and views.
2022-01-20 20:13:56 +01:00

65 lines
1.2 KiB
C++

#ifndef PGCLASS_H
#define PGCLASS_H
#include "Pgsql_Value.h"
#include "PgNamespaceObject.h"
#include <QString>
#include <libpq-fe.h>
enum class RelPersistence {
Permanent, // p
Unlogged, // u
Temporary // t
};
void operator<<(RelPersistence &s, const Pgsql::Value &v);
enum class RelKind {
Table, // r
Index, // i
Sequence, // S
View, // v
MaterializedView, // m
Composite, // c
Toast, // t
ForeignTable // f
};
void operator<<(RelKind &s, const Pgsql::Value &v);
class PgClass: public PgNamespaceObject {
public:
Oid type = InvalidOid;
Oid oftype = InvalidOid;
Oid am = InvalidOid;
Oid filenode = InvalidOid;
Oid tablespace = InvalidOid;
int32_t pages_est = 0;
float tuples_est = 0.0f;
Oid toastrelid = InvalidOid;
bool isshared = false;
RelPersistence persistence;
RelKind kind;
bool hasoids = false;
bool ispopulated;
int frozenxid;
int minmxid;
std::vector<QString> options;
QString viewdef;
using PgNamespaceObject::PgNamespaceObject;
QString kindString() const;
QString createSql() const override;
QString typeName() const override;
QString aclAllPattern() const override;
private:
mutable QString createSqlCache;
QString createTableSql() const;
QString createViewSql() const;
};
#endif // PGCLASS_H