pgLab/pglablib/PgClass.h
eelke 0cef509771 Correct tablespace names are now shown in the list of tables.
Slightly more complex then you may expect because the tablespace specified by the tables tends to be oid 0
which means the default tablespace is used. However this does not mean pg_default, it means the tablespace
as defined as standard in the database definition. So we need to know what the current dbname is retrieve
it's details from the catalog and retrieve that tablespace to know what to show for an oid of 0.
2018-08-27 21:14:57 +02:00

65 lines
1.4 KiB
C++

#ifndef PGCLASS_H
#define PGCLASS_H
#include "Pgsql_Value.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:
Oid oid = InvalidOid;
QString name;
Oid relnamespace = InvalidOid;
QString relnamespace_name; // Transient, cached value from relnamespace
bool system_namespace = false; // Transient, cached value from relnamespace
Oid type = InvalidOid;
Oid oftype = InvalidOid;
Oid owner = 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> acl;
std::vector<QString> options;
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 PgClass &rhs) const { return oid < rhs.oid; }
private:
};
#endif // PGCLASS_H