Messy commit. Testing suff and some improvements to how data is shown.
36
pglab/BaseTableModel.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "BaseTableModel.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include <QBrush>
|
||||
|
||||
using namespace Pgsql;
|
||||
|
||||
BaseTableModel::BaseTableModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{}
|
||||
|
||||
QVariant BaseTableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
QVariant v;
|
||||
Oid oid = getType(index.column());
|
||||
if (role == Qt::DisplayRole) {
|
||||
v = getData(index);
|
||||
if (oid == BOOLOID) {
|
||||
v = FormatBoolForDisplay(v.toBool());
|
||||
}
|
||||
}
|
||||
else if (role == Qt::TextAlignmentRole) {
|
||||
v = GetDefaultAlignmentForType(oid);
|
||||
}
|
||||
else if (role == Qt::ForegroundRole) {
|
||||
if (oid == BOOLOID) {
|
||||
QVariant d = getData(index);
|
||||
if (d.type() == QVariant::Bool) {
|
||||
v = QBrush(GetDefaultBoolColor(d.toBool()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
v = QBrush(GetDefaultColorForType(oid));
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
21
pglab/BaseTableModel.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef BASETABLEMODEL_H
|
||||
#define BASETABLEMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include "Pgsql_declare.h"
|
||||
|
||||
class BaseTableModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseTableModel(QObject *parent);
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
protected:
|
||||
virtual Oid getType(int column) const = 0;
|
||||
virtual QVariant getData(const QModelIndex &index) const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // BASETABLEMODEL_H
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
#include "DatabasesTableModel.h"
|
||||
#include "DatabasesTableModel.h"
|
||||
#include "PgDatabaseCatalogue.h"
|
||||
#include "PgDatabaseContainer.h"
|
||||
#include "PgAuthIdContainer.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
|
||||
using namespace Pgsql;
|
||||
|
||||
DatabasesTableModel::DatabasesTableModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
: BaseTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +62,7 @@ QVariant DatabasesTableModel::headerData(int section, Qt::Orientation orientatio
|
|||
return v;
|
||||
}
|
||||
|
||||
int DatabasesTableModel::rowCount(const QModelIndex &parent) const
|
||||
int DatabasesTableModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
int result = 0;
|
||||
if (m_databases) {
|
||||
|
|
@ -68,62 +71,79 @@ int DatabasesTableModel::rowCount(const QModelIndex &parent) const
|
|||
return result;
|
||||
}
|
||||
|
||||
int DatabasesTableModel::columnCount(const QModelIndex &parent) const
|
||||
int DatabasesTableModel::columnCount(const QModelIndex &) const
|
||||
{
|
||||
int result = 10;
|
||||
// if (parent.isValid())
|
||||
// return 10;
|
||||
int result = COL_COUNT;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariant DatabasesTableModel::data(const QModelIndex &index, int role) const
|
||||
Oid DatabasesTableModel::getType(int column) const
|
||||
{
|
||||
Oid oid;
|
||||
switch (column) {
|
||||
case AllowConnCol:
|
||||
case IsTemplateCol:
|
||||
oid = BOOLOID;
|
||||
break;
|
||||
case ConnLimitCol:
|
||||
oid = INT4OID;
|
||||
break;
|
||||
case AclCol:
|
||||
case CollateCol:
|
||||
case CTypeCol:
|
||||
case EncodingCol:
|
||||
case DbaCol:
|
||||
case NameCol:
|
||||
case TablespaceCol:
|
||||
oid = VARCHAROID;
|
||||
break;
|
||||
default:
|
||||
oid = InvalidOid;
|
||||
}
|
||||
return oid;
|
||||
}
|
||||
|
||||
QVariant DatabasesTableModel::getData(const QModelIndex &index) const
|
||||
{
|
||||
QVariant v;
|
||||
//if (!index.isValid())
|
||||
if (m_databases) {
|
||||
const PgDatabase &db = m_databases->getByIdx(index.row());
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
case NameCol:
|
||||
v = db.name;
|
||||
break;
|
||||
case DbaCol:
|
||||
// todo lookup role name
|
||||
{
|
||||
const auto& roles = m_catalog->authIds();
|
||||
v = QString("%1 (%2)").arg(roles->getByOid(db.dba).name).arg(db.dba);
|
||||
}
|
||||
break;
|
||||
case EncodingCol:
|
||||
// todo lookup encoding name
|
||||
v = db.encoding;
|
||||
break;
|
||||
case CollateCol:
|
||||
v = db.collate;
|
||||
break;
|
||||
case CTypeCol:
|
||||
v = db.ctype;
|
||||
break;
|
||||
case IsTemplateCol:
|
||||
v = db.isTemplate;
|
||||
break;
|
||||
case AllowConnCol:
|
||||
v = db.allowConn;
|
||||
break;
|
||||
case ConnLimitCol:
|
||||
v = db.connLimit;
|
||||
break;
|
||||
case TablespaceCol:
|
||||
// todo lookup tablespace name
|
||||
v = db.tablespace;
|
||||
break;
|
||||
case AclCol:
|
||||
v = db.acl;
|
||||
break;
|
||||
}
|
||||
switch (index.column()) {
|
||||
case NameCol:
|
||||
v = db.name;
|
||||
break;
|
||||
case DbaCol:
|
||||
v = getRoleDisplayString(m_catalog, db.dba);
|
||||
break;
|
||||
case EncodingCol:
|
||||
// todo lookup encoding name
|
||||
v = db.encoding;
|
||||
break;
|
||||
case CollateCol:
|
||||
v = db.collate;
|
||||
break;
|
||||
case CTypeCol:
|
||||
v = db.ctype;
|
||||
break;
|
||||
case IsTemplateCol:
|
||||
v = db.isTemplate;
|
||||
break;
|
||||
case AllowConnCol:
|
||||
v = db.allowConn;
|
||||
break;
|
||||
case ConnLimitCol:
|
||||
v = db.connLimit;
|
||||
break;
|
||||
case TablespaceCol:
|
||||
// todo lookup tablespace name
|
||||
v = db.tablespace;
|
||||
break;
|
||||
case AclCol:
|
||||
v = db.acl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef DATABASESTABLEMODEL_H
|
||||
#ifndef DATABASESTABLEMODEL_H
|
||||
#define DATABASESTABLEMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include "BaseTableModel.h"
|
||||
|
||||
class PgDatabaseContainer;
|
||||
class PgDatabaseCatalogue;
|
||||
|
|
@ -9,14 +9,14 @@ class PgDatabaseCatalogue;
|
|||
/** Class for displaying the list of databases of a server in a QTableView
|
||||
*
|
||||
*/
|
||||
class DatabasesTableModel : public QAbstractTableModel
|
||||
class DatabasesTableModel : public BaseTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum e_Columns : int { NameCol, DbaCol, EncodingCol, CollateCol,
|
||||
CTypeCol, IsTemplateCol, AllowConnCol, ConnLimitCol,
|
||||
TablespaceCol, AclCol };
|
||||
TablespaceCol, AclCol, COL_COUNT };
|
||||
|
||||
|
||||
|
||||
|
|
@ -31,7 +31,10 @@ public:
|
|||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
virtual Oid getType(int column) const override;
|
||||
virtual QVariant getData(const QModelIndex &index) const override;
|
||||
|
||||
// QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private:
|
||||
const PgDatabaseCatalogue *m_catalog = nullptr;
|
||||
|
|
|
|||
|
|
@ -1,384 +0,0 @@
|
|||
#include "ExplainTreeModelItem.h"
|
||||
#include "json/json.h"
|
||||
#include <limits>
|
||||
|
||||
namespace {
|
||||
|
||||
ExplainTreeModelItemPtr createPlanItemFromJson(Json::Value &plan)
|
||||
{
|
||||
ExplainTreeModelItemPtr result = std::make_shared<ExplainTreeModelItem>();
|
||||
result->setNodeType(QString::fromStdString(plan["Node Type"].asString()));
|
||||
result->setStrategy(QString::fromStdString(plan["Strategy"].asString()));
|
||||
result->setJoinType(QString::fromStdString(plan["Join Type"].asString()));
|
||||
result->setStartupCost(plan["Startup Cost"].asFloat());
|
||||
result->setTotalCost(plan["Total Cost"].asFloat());
|
||||
result->setEstimatedRows(plan["Plan Rows"].asInt());
|
||||
result->setPlanWidth(plan["Plan Width"].asInt());
|
||||
result->setActualStartupTime(plan["Actual Startup Time"].asFloat());
|
||||
result->setActualTotalTime(plan["Actual Total Time"].asFloat());
|
||||
result->setActualRows(plan["Actual Rows"].asInt());
|
||||
result->setActualLoops(plan["Actual Loops"].asInt());
|
||||
|
||||
result->setRelationName(QString::fromStdString(plan["Relation Name"].asString()));
|
||||
result->setAlias(QString::fromStdString(plan["Alias"].asString()));
|
||||
result->setScanDirection(QString::fromStdString(plan["Scan Direction"].asString()));
|
||||
result->setIndexName(QString::fromStdString(plan["Index Name"].asString()));
|
||||
result->setIndexCondition(QString::fromStdString(plan["Index Cond"].asString()));
|
||||
result->setIndexRecheck(QString::fromStdString(plan["Rows Removed by Index Recheck"].asString()));
|
||||
result->setFilter(QString::fromStdString(plan["Filter"].asString()));
|
||||
result->setHashCondition(QString::fromStdString(plan["Hash Cond"].asString()));
|
||||
|
||||
result->setSortKey(QString::fromStdString(plan["Sort Key"].toStyledString()));
|
||||
result->setSortMethod(QString::fromStdString(plan["Sort Method"].asString()));
|
||||
if (plan.isMember("Sort Space Used")) {
|
||||
const Json::Value& sm = plan["Sort Space Used"];
|
||||
if (sm.isInt()) {
|
||||
result->setSortSpaceUsed(sm.asInt());
|
||||
}
|
||||
}
|
||||
result->setSortSpaceType(QString::fromStdString(plan["Sort Space Type"].asString()));
|
||||
|
||||
|
||||
Json::Value &plans = plan["Plans"];
|
||||
if (plans.isArray()) {
|
||||
for (auto p : plans) {
|
||||
result->appendChild(
|
||||
createPlanItemFromJson(p));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // END of unnamed namespace
|
||||
|
||||
ExplainRoot::SPtr ExplainRoot::createFromJson(Json::Value &json)
|
||||
{
|
||||
auto res = std::make_shared<ExplainRoot>();
|
||||
// Explain always seems to be an array with one element
|
||||
if (json.isArray()) {
|
||||
if (json.size() > 0) {
|
||||
Json::Value &explain = json[0];
|
||||
|
||||
Json::Value &plan = explain["Plan"];
|
||||
res->plan = createPlanItemFromJson(plan);
|
||||
|
||||
res->planningTime = explain["Planning Time"].asFloat();
|
||||
res->executionTime = explain["Execution Time"].asFloat();
|
||||
res->totalRuntime = explain["Total Runtime"].asFloat();
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
ExplainTreeModelItem::ExplainTreeModelItem() = default;
|
||||
|
||||
ExplainTreeModelItem::~ExplainTreeModelItem() = default;
|
||||
|
||||
void ExplainTreeModelItem::appendChild(ItemPtr child)
|
||||
{
|
||||
child->setParent(shared_from_this());
|
||||
m_childItems.push_back(child);
|
||||
}
|
||||
|
||||
ExplainTreeModelItemPtr ExplainTreeModelItem::child(int row)
|
||||
{
|
||||
return m_childItems.at(row);
|
||||
}
|
||||
|
||||
int ExplainTreeModelItem::childCount() const
|
||||
{
|
||||
return m_childItems.size();
|
||||
}
|
||||
|
||||
//int ExplainTreeModelItem::columnCount() const
|
||||
//{
|
||||
// return 6;
|
||||
//}
|
||||
|
||||
//QVariant ExplainTreeModelItem::data(int column) const
|
||||
//{
|
||||
// QVariant r;
|
||||
// if (column == 0) {
|
||||
// r = nodeType;
|
||||
// }
|
||||
// else if (column == 1) {
|
||||
|
||||
// }
|
||||
// return r;
|
||||
//}
|
||||
|
||||
int ExplainTreeModelItem::row() const
|
||||
{
|
||||
int idx = 0;
|
||||
auto p = m_parentItem.lock();
|
||||
if (p) {
|
||||
idx = std::find(p->m_childItems.begin(), p->m_childItems.end(), shared_from_this()) - p->m_childItems.begin();
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setParent(ItemPtr parent)
|
||||
{
|
||||
m_parentItem = parent;
|
||||
}
|
||||
|
||||
ExplainTreeModelItemPtr ExplainTreeModelItem::parent()
|
||||
{
|
||||
auto p = m_parentItem.lock();
|
||||
return p;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setNodeType(QString nt)
|
||||
{
|
||||
m_nodeType = std::move(nt);
|
||||
}
|
||||
|
||||
const QString& ExplainTreeModelItem::nodeType() const
|
||||
{
|
||||
return m_nodeType;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setStrategy(QString strat)
|
||||
{
|
||||
m_strategy = std::move(strat);
|
||||
}
|
||||
|
||||
const QString& ExplainTreeModelItem::strategy() const
|
||||
{
|
||||
return m_strategy;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setJoinType(QString jointype)
|
||||
{
|
||||
m_joinType = jointype;
|
||||
}
|
||||
|
||||
QString ExplainTreeModelItem::joinType() const
|
||||
{
|
||||
return m_joinType;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setStartupCost(float cost)
|
||||
{
|
||||
m_startupCost = cost;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setTotalCost(float cost)
|
||||
{
|
||||
m_totalCost = cost;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setEstimatedRows(long long estimated)
|
||||
{
|
||||
m_estimatedRows = estimated;
|
||||
}
|
||||
|
||||
long long ExplainTreeModelItem::estimatedRows() const
|
||||
{
|
||||
return m_estimatedRows;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setPlanWidth(int width)
|
||||
{
|
||||
m_planWidth = width;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setActualStartupTime(float timems)
|
||||
{
|
||||
m_actualStartupTime = timems;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setActualTotalTime(float timems)
|
||||
{
|
||||
m_actualTotalTime = timems;
|
||||
}
|
||||
|
||||
float ExplainTreeModelItem::actualTotalTime() const
|
||||
{
|
||||
return m_actualTotalTime;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setActualRows(long long rowcount)
|
||||
{
|
||||
m_actualRows = rowcount;
|
||||
}
|
||||
|
||||
long long ExplainTreeModelItem::actualRows() const
|
||||
{
|
||||
return m_actualRows;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setActualLoops(int loopcount)
|
||||
{
|
||||
m_actualLoops = loopcount;
|
||||
}
|
||||
|
||||
int ExplainTreeModelItem::actualLoops() const
|
||||
{
|
||||
return m_actualLoops;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setRelationName(QString n)
|
||||
{
|
||||
m_relationName = std::move(n);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setAlias(QString a)
|
||||
{
|
||||
m_alias = std::move(a);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setScanDirection(QString dir)
|
||||
{
|
||||
m_scanDirection = std::move(dir);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setIndexName(QString idxname)
|
||||
{
|
||||
m_indexName = std::move(idxname);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setIndexCondition(QString idxcond)
|
||||
{
|
||||
m_indexCondition = std::move(idxcond);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setIndexRecheck(QString idxrecheck)
|
||||
{
|
||||
m_indexRecheck = std::move(idxrecheck);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setFilter(QString filter)
|
||||
{
|
||||
m_filter = std::move(filter);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setHashCondition(QString condition)
|
||||
{
|
||||
m_hashCondition = std::move(condition);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setSortKey(QString key)
|
||||
{
|
||||
m_sortKey = std::move(key);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setSortMethod(QString method)
|
||||
{
|
||||
m_sortMethod = std::move(method);
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setSortSpaceUsed(int space)
|
||||
{
|
||||
m_sortSpaceUsed = space;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setSortSpaceType(QString type)
|
||||
{
|
||||
m_sortSpaceType = std::move(type);
|
||||
}
|
||||
|
||||
float ExplainTreeModelItem::exclusiveTime() const
|
||||
{
|
||||
float tt = inclusiveTime();
|
||||
for (auto c : m_childItems) {
|
||||
tt -= c->inclusiveTime();
|
||||
}
|
||||
return tt;
|
||||
}
|
||||
|
||||
float ExplainTreeModelItem::inclusiveTime() const
|
||||
{
|
||||
float t = m_actualTotalTime * m_actualLoops;
|
||||
return t;
|
||||
}
|
||||
|
||||
float ExplainTreeModelItem::estimateError() const
|
||||
{
|
||||
float res = 1.0;
|
||||
if (m_estimatedRows > m_actualRows) {
|
||||
if (m_actualRows > 0) {
|
||||
res = float(m_estimatedRows) / m_actualRows;
|
||||
}
|
||||
else {
|
||||
res = std::numeric_limits<float>::infinity();
|
||||
}
|
||||
}
|
||||
else if (m_actualRows > m_estimatedRows) {
|
||||
if (m_estimatedRows > 0) {
|
||||
res = float(m_actualRows) / m_estimatedRows;
|
||||
}
|
||||
else {
|
||||
res = std::numeric_limits<float>::infinity();
|
||||
}
|
||||
res = -res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
QString ExplainTreeModelItem::detailString() const
|
||||
{
|
||||
QString s;
|
||||
if (!m_joinType.isEmpty()) {
|
||||
s += m_joinType + " " + m_nodeType + " ";
|
||||
}
|
||||
if (!m_strategy.isEmpty()) {
|
||||
s += m_strategy + " " + m_nodeType + " ";
|
||||
}
|
||||
if (!m_indexName.isEmpty()) {
|
||||
s+= m_scanDirection + " "
|
||||
+ m_nodeType + "\n";
|
||||
if (!m_indexCondition.isEmpty()) {
|
||||
s += "cond: " + m_indexCondition + " ";
|
||||
}
|
||||
if (!m_filter.isEmpty()) {
|
||||
s += "filter: " + m_filter + "\n";
|
||||
}
|
||||
if (!m_indexRecheck.isEmpty()) {
|
||||
s += "removed by recheck: " + m_indexRecheck + "\n";
|
||||
}
|
||||
s += "idx: " + m_indexName + " rel: " + m_alias + " ";
|
||||
}
|
||||
else {
|
||||
if (!m_alias.isEmpty()) {
|
||||
s += m_nodeType + " rel: " + m_alias + " ";
|
||||
}
|
||||
}
|
||||
if (!m_hashCondition.isEmpty()) {
|
||||
s += m_hashCondition + " ";
|
||||
}
|
||||
if (!m_sortMethod.isEmpty()) {
|
||||
s += m_sortMethod + " " + m_sortSpaceType + " "
|
||||
+ QString::number(m_sortSpaceUsed) + "kB "
|
||||
+ m_sortKey + " ";
|
||||
|
||||
}
|
||||
|
||||
return s.trimmed();
|
||||
}
|
||||
|
||||
//"Sort Key": ["pg_attribute.attname"],
|
||||
//"Sort Method": "quicksort",
|
||||
//"Sort Space Used": 1426,
|
||||
//"Sort Space Type": "Memory",
|
||||
|
||||
|
||||
//{
|
||||
// "Node Type": "Index Scan",
|
||||
// "Parent Relationship": "Inner",
|
||||
// "Scan Direction": "Forward",
|
||||
// "Index Name": "pg_type_oid_index",
|
||||
// "Relation Name": "pg_type",
|
||||
// "Alias": "pg_type",
|
||||
// "Startup Cost": 0.15,
|
||||
// "Total Cost": 0.18,
|
||||
// "Plan Rows": 1,
|
||||
// "Plan Width": 758,
|
||||
// "Actual Startup Time": 0.003,
|
||||
// "Actual Total Time": 0.004,
|
||||
// "Actual Rows": 1,
|
||||
// "Actual Loops": 100,
|
||||
// "Index Cond": "(oid = pg_attribute.atttypid)",
|
||||
// "Rows Removed by Index Recheck": 0
|
||||
// "Filter": "actief"
|
||||
//}
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QList>
|
||||
//#include <QVariant>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace Json {
|
||||
|
||||
class Value;
|
||||
|
||||
}
|
||||
class ExplainTreeModelItem;
|
||||
typedef std::shared_ptr<ExplainTreeModelItem> ExplainTreeModelItemPtr;
|
||||
|
||||
/* Columns for tree
|
||||
* 0. explain text
|
||||
* 1. exclusive times
|
||||
* 2. inclusive
|
||||
* 3. rows x
|
||||
* 4. rows
|
||||
* 5. loops
|
||||
*/
|
||||
|
||||
/** \brief Class for the nodes in the QueryExplainModel
|
||||
*/
|
||||
class ExplainTreeModelItem: public std::enable_shared_from_this<ExplainTreeModelItem> {
|
||||
public:
|
||||
typedef std::shared_ptr<ExplainTreeModelItem> ItemPtr;
|
||||
|
||||
|
||||
ExplainTreeModelItem();
|
||||
~ExplainTreeModelItem();
|
||||
|
||||
ExplainTreeModelItem(const ExplainTreeModelItem &rhs) = delete;
|
||||
ExplainTreeModelItem &operator=(const ExplainTreeModelItem &rhs) = delete;
|
||||
|
||||
void appendChild(ItemPtr child);
|
||||
|
||||
ExplainTreeModelItemPtr child(int row);
|
||||
int childCount() const;
|
||||
// int columnCount() const;
|
||||
// QVariant data(int column) const;
|
||||
int row() const;
|
||||
void setParent(ItemPtr parent);
|
||||
ItemPtr parent();
|
||||
|
||||
|
||||
void setNodeType(QString nt);
|
||||
const QString& nodeType() const;
|
||||
void setStrategy(QString strat);
|
||||
const QString& strategy() const;
|
||||
void setJoinType(QString jointype);
|
||||
QString joinType() const;
|
||||
void setStartupCost(float cost);
|
||||
void setTotalCost(float cost);
|
||||
void setEstimatedRows(long long estimated);
|
||||
long long estimatedRows() const;
|
||||
void setPlanWidth(int width);
|
||||
void setActualStartupTime(float timems);
|
||||
void setActualTotalTime(float timems);
|
||||
float actualTotalTime() const;
|
||||
void setActualRows(long long rowcount);
|
||||
long long actualRows() const;
|
||||
void setActualLoops(int loopcount);
|
||||
int actualLoops() const;
|
||||
|
||||
void setRelationName(QString n);
|
||||
void setAlias(QString a);
|
||||
void setScanDirection(QString dir);
|
||||
void setIndexName(QString idxname);
|
||||
void setIndexCondition(QString idxcond);
|
||||
void setIndexRecheck(QString idxrecheck);
|
||||
void setFilter(QString filter);
|
||||
void setHashCondition(QString condition);
|
||||
void setSortKey(QString key);
|
||||
void setSortMethod(QString method);
|
||||
void setSortSpaceUsed(int space);
|
||||
void setSortSpaceType(QString type);
|
||||
|
||||
/** ActualTotalTime minus the actual total time of it's children */
|
||||
float exclusiveTime() const;
|
||||
float inclusiveTime() const;
|
||||
float estimateError() const;
|
||||
QString detailString() const;
|
||||
private:
|
||||
std::vector<ItemPtr> m_childItems;
|
||||
std::weak_ptr<ExplainTreeModelItem> m_parentItem;
|
||||
|
||||
QString m_nodeType;
|
||||
QString m_strategy;
|
||||
QString m_joinType;
|
||||
float m_startupCost = 0.f;
|
||||
float m_totalCost = 0.f;
|
||||
long long m_estimatedRows = 0;
|
||||
int m_planWidth = 0;
|
||||
float m_actualStartupTime = 0.f;
|
||||
float m_actualTotalTime = 0.f;
|
||||
long long m_actualRows = 0;
|
||||
int m_actualLoops = 0;
|
||||
|
||||
QString m_relationName;
|
||||
QString m_alias;
|
||||
QString m_scanDirection;
|
||||
QString m_indexName;
|
||||
QString m_indexCondition;
|
||||
QString m_indexRecheck;
|
||||
QString m_filter;
|
||||
QString m_hashCondition;
|
||||
QString m_sortKey;
|
||||
QString m_sortMethod;
|
||||
int m_sortSpaceUsed = -1;
|
||||
QString m_sortSpaceType;
|
||||
|
||||
// "Output": ["f1.id", "f1.program", "f1.version", "f1.lic_number", "f1.callstack_crc_1", "f1.callstack_crc_2", "array_agg(f2.id)"],
|
||||
// "Group Key": ["f1.id"],
|
||||
// "Shared Hit Blocks": 694427,
|
||||
// "Shared Read Blocks": 0,
|
||||
// "Shared Dirtied Blocks": 0,
|
||||
// "Shared Written Blocks": 0,
|
||||
// "Local Hit Blocks": 0,
|
||||
// "Local Read Blocks": 0,
|
||||
// "Local Dirtied Blocks": 0,
|
||||
// "Local Written Blocks": 0,
|
||||
// "Temp Read Blocks": 0,
|
||||
// "Temp Written Blocks": 0
|
||||
|
||||
// "Parent Relationship": "Outer",
|
||||
|
||||
};
|
||||
|
||||
class ExplainRoot {
|
||||
public:
|
||||
using SPtr = std::shared_ptr<ExplainRoot>;
|
||||
static SPtr createFromJson(Json::Value &json);
|
||||
|
||||
ExplainTreeModelItemPtr plan;
|
||||
float planningTime = 0.f;
|
||||
// Triggers???
|
||||
float executionTime = 0.f;
|
||||
float totalRuntime = 0.f;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "PgDatabaseCatalogue.h"
|
||||
#include "PgDatabaseCatalogue.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include "PgDatabaseContainer.h"
|
||||
#include "PgAuthIdContainer.h"
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
QString getRoleNameFromOid(const PgDatabaseCatalogue *cat, Oid oid)
|
||||
{
|
||||
QString name;
|
||||
const PgAuthIdContainer *auth_ids = cat->authIds();
|
||||
auto auth_ids = cat->authIds();
|
||||
if (auth_ids) {
|
||||
const PgAuthId& auth_id = auth_ids->getByOid(oid);
|
||||
if (auth_id.valid()) {
|
||||
|
|
@ -18,6 +18,13 @@ QString getRoleNameFromOid(const PgDatabaseCatalogue *cat, Oid oid)
|
|||
return name;
|
||||
}
|
||||
|
||||
QString getRoleDisplayString(const PgDatabaseCatalogue *cat, Oid oid)
|
||||
{
|
||||
QString name = getRoleNameFromOid(cat, oid);
|
||||
return QString("%1 (%2)").arg(name).arg(oid);
|
||||
}
|
||||
|
||||
|
||||
PgDatabaseCatalogue::PgDatabaseCatalogue()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,5 +45,7 @@ private:
|
|||
};
|
||||
|
||||
QString getRoleNameFromOid(const PgDatabaseCatalogue *cat, Oid oid);
|
||||
QString getRoleDisplayString(const PgDatabaseCatalogue *cat, Oid oid);
|
||||
|
||||
|
||||
#endif // PGSQLDATABASECATALOGUE_H
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "PgDatabaseContainer.h"
|
||||
#include "PgDatabaseContainer.h"
|
||||
#include "Pgsql_Connection.h"
|
||||
#include "Pgsql_Col.h"
|
||||
|
||||
PgDatabaseContainer::PgDatabaseContainer(PgDatabaseCatalogue *cat)
|
||||
: PgContainer<PgDatabase>(cat)
|
||||
|
|
@ -17,18 +18,21 @@ void PgDatabaseContainer::load(const Pgsql::Result &res)
|
|||
m_container.clear();
|
||||
m_container.reserve(n_rows);
|
||||
for (auto row : res) {
|
||||
Pgsql::Col col(row);
|
||||
PgDatabase v;
|
||||
v.oid << row.get(0); // InvalidOid;
|
||||
v.name << row.get(1);
|
||||
v.dba << row.get(2); // owner?
|
||||
v.encoding << row.get(3);
|
||||
v.collate << row.get(4);
|
||||
v.ctype << row.get(5);
|
||||
v.isTemplate << row.get(6);
|
||||
v.allowConn << row.get(7);
|
||||
v.connLimit << row.get(8);
|
||||
v.tablespace << row.get(9);
|
||||
v.acl << row.get(10);
|
||||
// v.oid << row.get(0); // InvalidOid;
|
||||
// v.name << row.get(1);
|
||||
// v.dba << row.get(2); // owner?
|
||||
// v.encoding << row.get(3);
|
||||
// v.collate << row.get(4);
|
||||
// v.ctype << row.get(5);
|
||||
// v.isTemplate << row.get(6);
|
||||
// v.allowConn << row.get(7);
|
||||
// v.connLimit << row.get(8);
|
||||
// v.tablespace << row.get(9);
|
||||
// v.acl << row.get(10);
|
||||
col >> v.oid >> v.name >> v.dba >> v.encoding >> v.collate >> v.ctype >> v.isTemplate
|
||||
>> v.allowConn >> v.connLimit >> v.tablespace >> v.acl;
|
||||
m_container.push_back(v);
|
||||
}
|
||||
std::sort(m_container.begin(), m_container.end());
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ const int c_ColumnEstErr = 3;
|
|||
const int c_ColumnRowCount = 4;
|
||||
const int c_ColumnLoops = 5;
|
||||
const int c_ColumnDetails = 6;
|
||||
const int c_NumberOfColumns = 7;
|
||||
const int c_ColumnShared = 7;
|
||||
const int c_NumberOfColumns = 8;
|
||||
|
||||
QueryExplainModel::QueryExplainModel(QObject *parent, ExplainRoot::SPtr exp)
|
||||
: QAbstractItemModel(parent)
|
||||
|
|
@ -26,7 +27,7 @@ QVariant QueryExplainModel::data(const QModelIndex &index, int role) const
|
|||
if (role == Qt::DisplayRole) {
|
||||
switch (col) {
|
||||
case c_ColumnNode:
|
||||
result = item->nodeType();
|
||||
result = item->nodeType;
|
||||
break;
|
||||
case c_ColumnExclusive:
|
||||
result = item->exclusiveTime();
|
||||
|
|
@ -38,14 +39,17 @@ if (role == Qt::DisplayRole) {
|
|||
result = item->estimateError();
|
||||
break;
|
||||
case c_ColumnRowCount:
|
||||
result = item->actualRows();
|
||||
result = item->actualRows;
|
||||
break;
|
||||
case c_ColumnLoops:
|
||||
result = item->actualLoops();
|
||||
result = item->actualLoops;
|
||||
break;
|
||||
case c_ColumnDetails:
|
||||
result = item->detailString();
|
||||
break;
|
||||
case c_ColumnShared:
|
||||
result = item->sharedBlocks.asString();
|
||||
break;
|
||||
} // end switch column
|
||||
}
|
||||
else if (role == Qt::TextAlignmentRole) {
|
||||
|
|
@ -133,6 +137,9 @@ QVariant QueryExplainModel::headerData(int section, Qt::Orientation orientation,
|
|||
case c_ColumnDetails:
|
||||
v = "Details";
|
||||
break;
|
||||
case c_ColumnShared:
|
||||
v = "Shared";
|
||||
break;
|
||||
}
|
||||
}
|
||||
// else if (role == Qt::SizeHintRole) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "QueryResultModel.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "Pgsql_declare.h"
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
|
|
@ -36,7 +37,7 @@ QVariant QueryResultModel::data(const QModelIndex &index, int role) const
|
|||
Oid o = result->type(col);
|
||||
QString s(result->val(col, rij));
|
||||
switch (o) {
|
||||
case oid_bool:
|
||||
case BOOLOID:
|
||||
s = (s == "t") ? "TRUE" : "FALSE";
|
||||
// intentional fall through
|
||||
default:
|
||||
|
|
@ -50,23 +51,7 @@ QVariant QueryResultModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
}
|
||||
else if (role == Qt::TextAlignmentRole) {
|
||||
Oid o = result->type(col);
|
||||
switch (o) {
|
||||
case oid_int2:
|
||||
case oid_int4:
|
||||
case oid_int8:
|
||||
case oid_float4:
|
||||
case oid_float8:
|
||||
case oid_numeric:
|
||||
case oid_oid:
|
||||
r = Qt::AlignRight + Qt::AlignVCenter;
|
||||
break;
|
||||
case oid_bool:
|
||||
r = Qt::AlignCenter;
|
||||
break;
|
||||
default:
|
||||
r = Qt::AlignLeft + Qt::AlignVCenter;
|
||||
}
|
||||
r = GetDefaultAlignmentForType(result->type(col));
|
||||
}
|
||||
else if (role == Qt::ForegroundRole) {
|
||||
if (result->null(col, rij)) {
|
||||
|
|
@ -75,19 +60,19 @@ QVariant QueryResultModel::data(const QModelIndex &index, int role) const
|
|||
else {
|
||||
Oid o = result->type(col);
|
||||
switch (o) {
|
||||
case oid_int2:
|
||||
case oid_int4:
|
||||
case oid_int8:
|
||||
case INT2OID:
|
||||
case INT4OID:
|
||||
case INT8OID:
|
||||
r = QBrush(Qt::darkBlue);
|
||||
break;
|
||||
case oid_float4:
|
||||
case oid_float8:
|
||||
case FLOAT4OID:
|
||||
case FLOAT8OID:
|
||||
r = QBrush(Qt::darkCyan);
|
||||
break;
|
||||
case oid_numeric:
|
||||
case NUMERICOID:
|
||||
r = QBrush(Qt::darkGreen);
|
||||
break;
|
||||
case oid_bool:
|
||||
case BOOLOID:
|
||||
if (strcmp(result->val(col, rij), "t") == 0) {
|
||||
r = QBrush(Qt::darkGreen);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "QueryTab.h"
|
||||
#include "QueryTab.h"
|
||||
#include "ui_QueryTab.h"
|
||||
#include "SqlSyntaxHighlighter.h"
|
||||
#include <QStandardPaths>
|
||||
|
|
@ -229,30 +229,32 @@ void QueryTab::explain(bool analyze)
|
|||
|
||||
std::string analyze_str;
|
||||
if (analyze) {
|
||||
analyze_str = "ANALYZE, ";
|
||||
analyze_str = "ANALYZE, BUFFERS, ";
|
||||
}
|
||||
m_stopwatch.start();
|
||||
std::string cmd = "EXPLAIN (" + analyze_str + "VERBOSE, BUFFERS, FORMAT JSON) " + getCommandUtf8();
|
||||
std::string cmd = "EXPLAIN (" + analyze_str + "VERBOSE, FORMAT JSON) " + getCommandUtf8();
|
||||
m_dbConnection.send(cmd,
|
||||
[this](Expected<std::shared_ptr<Pgsql::Result>> exp_res, qint64 )
|
||||
{
|
||||
if (exp_res.valid()) {
|
||||
// Process explain data seperately
|
||||
auto res = exp_res.get();
|
||||
std::thread([this,res]()
|
||||
{
|
||||
std::shared_ptr<ExplainRoot> explain;
|
||||
if (res->cols() == 1 && res->rows() == 1) {
|
||||
std::string s = res->val(0, 0);
|
||||
Json::Value root; // will contains the root value after parsing.
|
||||
Json::Reader reader;
|
||||
bool parsingSuccessful = reader.parse(s, root);
|
||||
if (parsingSuccessful) {
|
||||
explain = ExplainRoot::createFromJson(root);
|
||||
if (res) {
|
||||
std::thread([this,res]()
|
||||
{
|
||||
std::shared_ptr<ExplainRoot> explain;
|
||||
if (res->cols() == 1 && res->rows() == 1) {
|
||||
std::string s = res->val(0, 0);
|
||||
Json::Value root; // will contains the root value after parsing.
|
||||
Json::Reader reader;
|
||||
bool parsingSuccessful = reader.parse(s, root);
|
||||
if (parsingSuccessful) {
|
||||
explain = ExplainRoot::createFromJson(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_win->QueueTask([this, explain]() { explain_ready(explain); });
|
||||
}).detach();
|
||||
m_win->QueueTask([this, explain]() { explain_ready(explain); });
|
||||
}).detach();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
57
pglab/ResultTableModelUtil.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include "ResultTableModelUtil.h"
|
||||
|
||||
using namespace Pgsql;
|
||||
|
||||
int GetDefaultAlignmentForType(Oid o)
|
||||
{
|
||||
|
||||
int r;
|
||||
switch (o) {
|
||||
case INT2OID:
|
||||
case INT4OID:
|
||||
case INT8OID:
|
||||
case FLOAT4OID:
|
||||
case FLOAT8OID:
|
||||
case NUMERICOID:
|
||||
case OIDOID:
|
||||
r = GetDefaultNumberAlignment();
|
||||
break;
|
||||
case BOOLOID:
|
||||
r = GetDefaultBoolAlignment(); // Qt::AlignCenter;
|
||||
break;
|
||||
default:
|
||||
r = GetDefaultAlignment();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
QColor GetDefaultColorForType(Oid o)
|
||||
{
|
||||
QColor c;
|
||||
switch (o) {
|
||||
case INT2OID:
|
||||
case INT4OID:
|
||||
case INT8OID:
|
||||
c = GetDefaultIntegerColor();
|
||||
break;
|
||||
case FLOAT4OID:
|
||||
case FLOAT8OID:
|
||||
c = GetDefaultFloatColor();
|
||||
break;
|
||||
case NUMERICOID:
|
||||
c = GetDefaultNumericColor();
|
||||
break;
|
||||
|
||||
case OIDOID:
|
||||
case BOOLOID:
|
||||
default:
|
||||
c = Qt::black;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
QString FormatBoolForDisplay(bool v)
|
||||
{
|
||||
return v ? "TRUE" : "FALSE";
|
||||
}
|
||||
|
||||
23
pglab/ResultTableModelUtil.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#include "Pgsql_declare.h"
|
||||
#include <QAbstractTableModel>
|
||||
#include <QColor>
|
||||
|
||||
int GetDefaultAlignmentForType(Oid oid);
|
||||
QColor GetDefaultColorForType(Oid oid);
|
||||
|
||||
inline int GetDefaultAlignment() { return Qt::AlignLeft + Qt::AlignVCenter; }
|
||||
inline int GetDefaultBoolAlignment() { return Qt::AlignCenter + Qt::AlignVCenter; }
|
||||
inline int GetDefaultNumberAlignment() { return Qt::AlignRight + Qt::AlignVCenter; }
|
||||
|
||||
inline QColor GetDefaultBoolColor(bool v)
|
||||
{
|
||||
return v ? Qt::darkGreen : Qt::darkRed;
|
||||
}
|
||||
|
||||
inline QColor GetDefaultIntegerColor() { return Qt::darkBlue; }
|
||||
inline QColor GetDefaultFloatColor() { return Qt::darkCyan; }
|
||||
inline QColor GetDefaultNumericColor() { return Qt::darkGreen; }
|
||||
|
||||
QString FormatBoolForDisplay(bool v);
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
#include "PgAuthIdContainer.h"
|
||||
|
||||
RolesTableModel::RolesTableModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
: BaseTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -74,50 +74,80 @@ int RolesTableModel::columnCount(const QModelIndex &parent) const
|
|||
return result;
|
||||
}
|
||||
|
||||
QVariant RolesTableModel::data(const QModelIndex &index, int role) const
|
||||
Oid RolesTableModel::getType(int column) const
|
||||
{
|
||||
QVariant v;
|
||||
//if (!index.isValid())
|
||||
if (m_roles) {
|
||||
const PgAuthId &authid = m_roles->getByIdx(index.row());
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
case NameCol:
|
||||
v = authid.name;
|
||||
break;
|
||||
case SuperCol:
|
||||
// todo lookup role name
|
||||
v = authid.super;
|
||||
break;
|
||||
case InheritCol:
|
||||
// todo lookup encoding name
|
||||
v = authid.inherit;
|
||||
break;
|
||||
case CreateRoleCol:
|
||||
v = authid.createRole;
|
||||
break;
|
||||
case CreateDBCol:
|
||||
v = authid.createDB;
|
||||
break;
|
||||
case CanLoginCol:
|
||||
v = authid.canlogin;
|
||||
break;
|
||||
case ReplicationCol:
|
||||
v = authid.replication;
|
||||
break;
|
||||
case BypassRlsCol:
|
||||
v = authid.bypassRls;
|
||||
break;
|
||||
case ConnlimitCol:
|
||||
// todo lookup tablespace name
|
||||
v = authid.connLimit;
|
||||
break;
|
||||
case ValidUntilCol:
|
||||
v = authid.validUntil;
|
||||
break;
|
||||
}
|
||||
}
|
||||
using namespace Pgsql;
|
||||
|
||||
Oid oid;
|
||||
switch (column) {
|
||||
case NameCol:
|
||||
oid = VARCHAROID;
|
||||
break;
|
||||
|
||||
case ReplicationCol:
|
||||
case BypassRlsCol:
|
||||
case CanLoginCol:
|
||||
case CreateDBCol:
|
||||
case CreateRoleCol:
|
||||
case InheritCol:
|
||||
case SuperCol:
|
||||
oid = BOOLOID;
|
||||
break;
|
||||
|
||||
case ConnlimitCol:
|
||||
oid = INT4OID;
|
||||
break;
|
||||
|
||||
case ValidUntilCol:
|
||||
oid = TIMESTAMPOID;
|
||||
break;
|
||||
default:
|
||||
oid = InvalidOid;
|
||||
}
|
||||
|
||||
return oid;
|
||||
}
|
||||
|
||||
QVariant RolesTableModel::getData(const QModelIndex &index) const
|
||||
{
|
||||
QVariant v;
|
||||
if (m_roles) {
|
||||
const PgAuthId &authid = m_roles->getByIdx(index.row());
|
||||
switch (index.column()) {
|
||||
case NameCol:
|
||||
v = authid.name;
|
||||
break;
|
||||
case SuperCol:
|
||||
// todo lookup role name
|
||||
v = authid.super;
|
||||
break;
|
||||
case InheritCol:
|
||||
// todo lookup encoding name
|
||||
v = authid.inherit;
|
||||
break;
|
||||
case CreateRoleCol:
|
||||
v = authid.createRole;
|
||||
break;
|
||||
case CreateDBCol:
|
||||
v = authid.createDB;
|
||||
break;
|
||||
case CanLoginCol:
|
||||
v = authid.canlogin;
|
||||
break;
|
||||
case ReplicationCol:
|
||||
v = authid.replication;
|
||||
break;
|
||||
case BypassRlsCol:
|
||||
v = authid.bypassRls;
|
||||
break;
|
||||
case ConnlimitCol:
|
||||
// todo lookup tablespace name
|
||||
v = authid.connLimit;
|
||||
break;
|
||||
case ValidUntilCol:
|
||||
v = authid.validUntil;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
#define ROLESTABLEMODEL_H
|
||||
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include "BaseTableModel.h"
|
||||
|
||||
class PgAuthIdContainer;
|
||||
|
||||
/** Class for displaying the list of roles of a server in a QTableView
|
||||
*
|
||||
*/
|
||||
class RolesTableModel : public QAbstractTableModel {
|
||||
class RolesTableModel : public BaseTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum e_Columns : int { NameCol, SuperCol, InheritCol, CreateRoleCol,
|
||||
|
|
@ -29,7 +29,10 @@ public:
|
|||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
virtual Oid getType(int column) const override;
|
||||
virtual QVariant getData(const QModelIndex &index) const override;
|
||||
|
||||
// QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private:
|
||||
const PgAuthIdContainer *m_roles = nullptr;
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 416 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 473 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 618 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 419 B After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 1.3 KiB |
|
|
@ -1,330 +0,0 @@
|
|||
/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).
|
||||
/// It is intended to be used with #include "json/json-forwards.h"
|
||||
/// This header provides forward declaration for all JsonCpp types.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: LICENSE
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
The JsonCpp library's source code, including accompanying documentation,
|
||||
tests and demonstration applications, are licensed under the following
|
||||
conditions...
|
||||
|
||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||
this software is released into the Public Domain.
|
||||
|
||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
||||
released under the terms of the MIT License (see below).
|
||||
|
||||
In jurisdictions which recognize Public Domain property, the user of this
|
||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||
Public Domain/MIT License conditions described here, as they choose.
|
||||
|
||||
The MIT License is about as close to Public Domain as a license can get, and is
|
||||
described in clear, concise terms at:
|
||||
|
||||
http://en.wikipedia.org/wiki/MIT_License
|
||||
|
||||
The full text of the MIT License follows:
|
||||
|
||||
========================================================================
|
||||
Copyright (c) 2007-2010 Baptiste Lepilleur
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy,
|
||||
modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
========================================================================
|
||||
(END LICENSE TEXT)
|
||||
|
||||
The MIT license is compatible with both the GPL and commercial
|
||||
software, affording one all of the rights of Public Domain with the
|
||||
minor nuisance of being required to keep the above copyright notice
|
||||
and license text in the source code. Note also that by accepting the
|
||||
Public Domain "license" you can re-license your copy using whatever
|
||||
license you like.
|
||||
|
||||
*/
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: LICENSE
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
|
||||
# define JSON_FORWARD_AMALGATED_H_INCLUDED
|
||||
/// If defined, indicates that the source file is amalgated
|
||||
/// to prevent private header inclusion.
|
||||
#define JSON_IS_AMALGAMATION
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/config.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_CONFIG_H_INCLUDED
|
||||
#define JSON_CONFIG_H_INCLUDED
|
||||
#include <stddef.h>
|
||||
#include <string> //typedef String
|
||||
#include <stdint.h> //typedef int64_t, uint64_t
|
||||
|
||||
/// If defined, indicates that json library is embedded in CppTL library.
|
||||
//# define JSON_IN_CPPTL 1
|
||||
|
||||
/// If defined, indicates that json may leverage CppTL library
|
||||
//# define JSON_USE_CPPTL 1
|
||||
/// If defined, indicates that cpptl vector based map should be used instead of
|
||||
/// std::map
|
||||
/// as Value container.
|
||||
//# define JSON_USE_CPPTL_SMALLMAP 1
|
||||
|
||||
// If non-zero, the library uses exceptions to report bad input instead of C
|
||||
// assertion macros. The default is to use exceptions.
|
||||
#ifndef JSON_USE_EXCEPTION
|
||||
#define JSON_USE_EXCEPTION 1
|
||||
#endif
|
||||
|
||||
/// If defined, indicates that the source file is amalgated
|
||||
/// to prevent private header inclusion.
|
||||
/// Remarks: it is automatically defined in the generated amalgated header.
|
||||
// #define JSON_IS_AMALGAMATION
|
||||
|
||||
#ifdef JSON_IN_CPPTL
|
||||
#include <cpptl/config.h>
|
||||
#ifndef JSON_USE_CPPTL
|
||||
#define JSON_USE_CPPTL 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef JSON_IN_CPPTL
|
||||
#define JSON_API CPPTL_API
|
||||
#elif defined(JSON_DLL_BUILD)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllexport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#elif defined(JSON_DLL)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllimport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#endif // ifdef JSON_IN_CPPTL
|
||||
#if !defined(JSON_API)
|
||||
#define JSON_API
|
||||
#endif
|
||||
|
||||
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
|
||||
// integer
|
||||
// Storages, and 64 bits integer support is disabled.
|
||||
// #define JSON_NO_INT64 1
|
||||
|
||||
#if defined(_MSC_VER) // MSVC
|
||||
# if _MSC_VER <= 1200 // MSVC 6
|
||||
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
||||
// (no conversion from unsigned __int64).
|
||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
||||
// characters in the debug information)
|
||||
// All projects I've ever seen with VS6 were using this globally (not bothering
|
||||
// with pragma push/pop).
|
||||
# pragma warning(disable : 4786)
|
||||
# endif // MSVC 6
|
||||
|
||||
# if _MSC_VER >= 1500 // MSVC 2008
|
||||
/// Indicates that the following function is deprecated.
|
||||
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
# endif
|
||||
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
// In c++11 the override keyword allows you to explicity define that a function
|
||||
// is intended to override the base-class version. This makes the code more
|
||||
// managable and fixes a set of common hard-to-find bugs.
|
||||
#if __cplusplus >= 201103L
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# define JSONCPP_NOEXCEPT noexcept
|
||||
#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# define JSONCPP_NOEXCEPT throw()
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1900
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# define JSONCPP_NOEXCEPT noexcept
|
||||
#else
|
||||
# define JSONCPP_OVERRIDE
|
||||
# define JSONCPP_NOEXCEPT throw()
|
||||
#endif
|
||||
|
||||
#ifndef JSON_HAS_RVALUE_REFERENCES
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // MSVC >= 2010
|
||||
|
||||
#ifdef __clang__
|
||||
#if __has_feature(cxx_rvalue_references)
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // has_feature
|
||||
|
||||
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
|
||||
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // GXX_EXPERIMENTAL
|
||||
|
||||
#endif // __clang__ || __GNUC__
|
||||
|
||||
#endif // not defined JSON_HAS_RVALUE_REFERENCES
|
||||
|
||||
#ifndef JSON_HAS_RVALUE_REFERENCES
|
||||
#define JSON_HAS_RVALUE_REFERENCES 0
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
|
||||
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
||||
# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||
# endif // GNUC version
|
||||
#endif // __clang__ || __GNUC__
|
||||
|
||||
#if !defined(JSONCPP_DEPRECATED)
|
||||
#define JSONCPP_DEPRECATED(message)
|
||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
||||
|
||||
#if __GNUC__ >= 6
|
||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
# include "version.h"
|
||||
|
||||
# if JSONCPP_USING_SECURE_MEMORY
|
||||
# include "allocator.h" //typedef Allocator
|
||||
# endif
|
||||
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
typedef int Int;
|
||||
typedef unsigned int UInt;
|
||||
#if defined(JSON_NO_INT64)
|
||||
typedef int LargestInt;
|
||||
typedef unsigned int LargestUInt;
|
||||
#undef JSON_HAS_INT64
|
||||
#else // if defined(JSON_NO_INT64)
|
||||
// For Microsoft Visual use specific types as long long is not supported
|
||||
#if defined(_MSC_VER) // Microsoft Visual Studio
|
||||
typedef __int64 Int64;
|
||||
typedef unsigned __int64 UInt64;
|
||||
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||
typedef int64_t Int64;
|
||||
typedef uint64_t UInt64;
|
||||
#endif // if defined(_MSC_VER)
|
||||
typedef Int64 LargestInt;
|
||||
typedef UInt64 LargestUInt;
|
||||
#define JSON_HAS_INT64
|
||||
#endif // if defined(JSON_NO_INT64)
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
|
||||
#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#else
|
||||
#define JSONCPP_STRING std::string
|
||||
#define JSONCPP_OSTRINGSTREAM std::ostringstream
|
||||
#define JSONCPP_OSTREAM std::ostream
|
||||
#define JSONCPP_ISTRINGSTREAM std::istringstream
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#endif // if JSONCPP_USING_SECURE_MEMORY
|
||||
} // end namespace Json
|
||||
|
||||
#endif // JSON_CONFIG_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/config.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/forwards.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_FORWARDS_H_INCLUDED
|
||||
#define JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "config.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
// writer.h
|
||||
class FastWriter;
|
||||
class StyledWriter;
|
||||
|
||||
// reader.h
|
||||
class Reader;
|
||||
|
||||
// features.h
|
||||
class Features;
|
||||
|
||||
// value.h
|
||||
typedef unsigned int ArrayIndex;
|
||||
class StaticString;
|
||||
class Path;
|
||||
class PathArgument;
|
||||
class Value;
|
||||
class ValueIteratorBase;
|
||||
class ValueIterator;
|
||||
class ValueConstIterator;
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#endif // JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/forwards.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
|
||||
2161
pglab/json/json.h
5311
pglab/jsoncpp.cpp
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
CONFIG += c++14
|
||||
CONFIG += c++17
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets sql
|
||||
|
|
@ -13,7 +13,7 @@ TARGET = pglab
|
|||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += C:\prog\include C:\Prog\include\pgsql C:\VSproj\boost32\include\boost-1_65_1
|
||||
DEFINES += WIN32_LEAN_AND_MEAN NOMINMAX
|
||||
DEFINES += WIN32_LEAN_AND_MEAN NOMINMAX _WIN32_WINNT=0x0501
|
||||
#LIBS += -LC:/prog/boost/lib -Lc:/prog/lib libpq.lib fmt.lib User32.lib ws2_32.lib
|
||||
LIBS += -LC:\VSproj\boost32\lib -LC:/PROG/LIB -lws2_32 -llibpq
|
||||
|
||||
|
|
@ -29,9 +29,7 @@ win32:RC_ICONS += pglab.ico
|
|||
|
||||
SOURCES += main.cpp\
|
||||
QueryResultModel.cpp \
|
||||
jsoncpp.cpp \
|
||||
QueryExplainModel.cpp \
|
||||
ExplainTreeModelItem.cpp \
|
||||
ASyncDBConnection.cpp \
|
||||
tsqueue.cpp \
|
||||
DatabaseWindow.cpp \
|
||||
|
|
@ -68,12 +66,13 @@ PgDatabaseCatalogue.cpp \
|
|||
ConnectionList.cpp \
|
||||
ProcessStdioWidget.cpp \
|
||||
GlobalIoService.cpp \
|
||||
CodeBuilderConfiguration.cpp
|
||||
CodeBuilderConfiguration.cpp \
|
||||
ResultTableModelUtil.cpp \
|
||||
BaseTableModel.cpp
|
||||
|
||||
HEADERS += \
|
||||
QueryResultModel.h \
|
||||
QueryExplainModel.h \
|
||||
ExplainTreeModelItem.h \
|
||||
ASyncDBConnection.h \
|
||||
tsqueue.h \
|
||||
DatabaseWindow.h \
|
||||
|
|
@ -110,7 +109,9 @@ PgDatabaseCatalogue.h \
|
|||
ConnectionList.h \
|
||||
ProcessStdioWidget.h \
|
||||
GlobalIoService.h \
|
||||
CodeBuilderConfiguration.h
|
||||
CodeBuilderConfiguration.h \
|
||||
ResultTableModelUtil.h \
|
||||
BaseTableModel.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
DatabaseWindow.ui \
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/server_delete.png</file>
|
||||
<file>icons/server_go.png</file>
|
||||
<file>icons/script_delete.png</file>
|
||||
<file>icons/script_go.png</file>
|
||||
<file>icons/folder.png</file>
|
||||
|
|
|
|||