Added the list of installed language to the catalog. The ProcTableModel now returns the owner name and language name instead of the oids.
This commit is contained in:
parent
c0a11f9b3b
commit
f692569d27
11 changed files with 118 additions and 18 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ProcTableModel.h"
|
#include "ProcTableModel.h"
|
||||||
#include "catalog/PgDatabaseCatalog.h"
|
#include "catalog/PgDatabaseCatalog.h"
|
||||||
#include "catalog/PgProcContainer.h"
|
#include "catalog/PgProcContainer.h"
|
||||||
|
#include "catalog/PgLanguageContainer.h"
|
||||||
#include "CustomDataRole.h"
|
#include "CustomDataRole.h"
|
||||||
|
|
||||||
ProcTableModel::ProcTableModel(QObject *parent)
|
ProcTableModel::ProcTableModel(QObject *parent)
|
||||||
|
|
@ -80,8 +81,12 @@ QVariant ProcTableModel::getData(const QModelIndex &index) const
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case NameCol: return t.objectName();
|
case NameCol: return t.objectName();
|
||||||
case NamespaceCol: return t.nsName();
|
case NamespaceCol: return t.nsName();
|
||||||
case OwnerCol: return t.owner;
|
case OwnerCol: return t.ownerName();
|
||||||
case LangCol: return t.lang;
|
case LangCol: {
|
||||||
|
auto lan = m_catalog->languages()->getByKey(t.lang);
|
||||||
|
if (lan) return lan->objectName();
|
||||||
|
return t.lang;
|
||||||
|
}
|
||||||
case AclCol: return t.acl;
|
case AclCol: return t.acl;
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#include "PgProcContainer.h"
|
#include "PgProcContainer.h"
|
||||||
#include "PgCollationContainer.h"
|
#include "PgCollationContainer.h"
|
||||||
#include "PgInheritsContainer.h"
|
#include "PgInheritsContainer.h"
|
||||||
|
#include "PgLanguageContainer.h"
|
||||||
#include "Pgsql_Connection.h"
|
#include "Pgsql_Connection.h"
|
||||||
#include "Pgsql_oids.h"
|
#include "Pgsql_oids.h"
|
||||||
|
|
||||||
|
|
@ -151,6 +152,9 @@ void PgDatabaseCatalog::loadAll(Pgsql::Connection &conn,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Load database objects
|
// Load database objects
|
||||||
|
load2(m_languages, conn);
|
||||||
|
if (progress_callback && !progress_callback(++n, count))
|
||||||
|
return;
|
||||||
load2(m_namespaces, conn);
|
load2(m_namespaces, conn);
|
||||||
if (progress_callback && !progress_callback(++n, count))
|
if (progress_callback && !progress_callback(++n, count))
|
||||||
return;
|
return;
|
||||||
|
|
@ -302,3 +306,8 @@ std::shared_ptr<const PgInheritsContainer> PgDatabaseCatalog::inherits() const
|
||||||
{
|
{
|
||||||
return m_inherits;
|
return m_inherits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<const PgLanguageContainer> PgDatabaseCatalog::languages() const
|
||||||
|
{
|
||||||
|
return m_languages;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class PgTypeContainer;
|
||||||
class PgProcContainer;
|
class PgProcContainer;
|
||||||
class PgCollationContainer;
|
class PgCollationContainer;
|
||||||
class PgInheritsContainer;
|
class PgInheritsContainer;
|
||||||
|
class PgLanguageContainer;
|
||||||
|
|
||||||
class PgDatabaseCatalog: public QObject, public std::enable_shared_from_this<PgDatabaseCatalog> {
|
class PgDatabaseCatalog: public QObject, public std::enable_shared_from_this<PgDatabaseCatalog> {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -62,6 +62,7 @@ public:
|
||||||
std::shared_ptr<const PgProcContainer> procs() const;
|
std::shared_ptr<const PgProcContainer> procs() const;
|
||||||
std::shared_ptr<const PgCollationContainer> collations() const;
|
std::shared_ptr<const PgCollationContainer> collations() const;
|
||||||
std::shared_ptr<const PgInheritsContainer> inherits() const;
|
std::shared_ptr<const PgInheritsContainer> inherits() const;
|
||||||
|
std::shared_ptr<const PgLanguageContainer> languages() const;
|
||||||
|
|
||||||
enum RefreshFlag {
|
enum RefreshFlag {
|
||||||
Attributes = 1,
|
Attributes = 1,
|
||||||
|
|
@ -101,6 +102,7 @@ private:
|
||||||
std::shared_ptr<PgProcContainer> m_procs;
|
std::shared_ptr<PgProcContainer> m_procs;
|
||||||
std::shared_ptr<PgCollationContainer> m_collations;
|
std::shared_ptr<PgCollationContainer> m_collations;
|
||||||
std::shared_ptr<PgInheritsContainer> m_inherits;
|
std::shared_ptr<PgInheritsContainer> m_inherits;
|
||||||
|
std::shared_ptr<PgLanguageContainer> m_languages;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void load2(std::shared_ptr<T> &ptr, Pgsql::Connection &conn)
|
void load2(std::shared_ptr<T> &ptr, Pgsql::Connection &conn)
|
||||||
|
|
|
||||||
11
pglablib/catalog/PgLanguage.cpp
Normal file
11
pglablib/catalog/PgLanguage.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "PgLanguage.h"
|
||||||
|
|
||||||
|
QString PgLanguage::createSql() const
|
||||||
|
{
|
||||||
|
throw std::exception("PgLanguage::createSql() not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PgLanguage::dropSql() const
|
||||||
|
{
|
||||||
|
throw std::exception("PgLanguage::dropSql() not implemented");
|
||||||
|
}
|
||||||
29
pglablib/catalog/PgLanguage.h
Normal file
29
pglablib/catalog/PgLanguage.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef PGLANGUAGE_H
|
||||||
|
#define PGLANGUAGE_H
|
||||||
|
|
||||||
|
#include "PgDatabaseObject.h"
|
||||||
|
#include "PgOwnedObject.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <libpq-fe.h>
|
||||||
|
//#include "Pgsql_Value.h"
|
||||||
|
|
||||||
|
class PgLanguage: public PgDatabaseObject, public PgOwnedObject {
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Oid oid;
|
||||||
|
// QString name;
|
||||||
|
// Oid owner;
|
||||||
|
bool ispl; // true "user installable language" language like plpgsql perl en pythong, false for internal, c and sql
|
||||||
|
bool pltrusted;
|
||||||
|
Oid plcallfoid;
|
||||||
|
Oid inline_;
|
||||||
|
Oid validator;
|
||||||
|
QString acl;
|
||||||
|
|
||||||
|
using PgDatabaseObject::PgDatabaseObject;
|
||||||
|
|
||||||
|
QString createSql() const;
|
||||||
|
QString dropSql() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PGLANGUAGE_H
|
||||||
22
pglablib/catalog/PgLanguageContainer.cpp
Normal file
22
pglablib/catalog/PgLanguageContainer.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include "PgLanguageContainer.h"
|
||||||
|
#include "Pgsql_Connection.h"
|
||||||
|
#include "Pgsql_Col.h"
|
||||||
|
|
||||||
|
std::string PgLanguageContainer::getLoadQuery() const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
"SELECT oid, lanname, lanowner, lanispl, lanpltrusted, lanplcallfoid, laninline, lanvalidator, lanacl \n"
|
||||||
|
" FROM pg_language";
|
||||||
|
}
|
||||||
|
|
||||||
|
PgLanguage PgLanguageContainer::loadElem(const Pgsql::Row &row)
|
||||||
|
{
|
||||||
|
Pgsql::Col col(row);
|
||||||
|
Oid lan_oid = col.nextValue();
|
||||||
|
QString name = col.nextValue();
|
||||||
|
Oid owner = col.nextValue();
|
||||||
|
PgLanguage v(m_catalog, lan_oid, name);
|
||||||
|
col >> v.ispl >> v.pltrusted >> v.plcallfoid >> v.inline_ >> v.validator >> v.acl;
|
||||||
|
v.setOwnerOid(m_catalog, owner);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
25
pglablib/catalog/PgLanguageContainer.h
Normal file
25
pglablib/catalog/PgLanguageContainer.h
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef PGLANGUAGECONTAINER_H
|
||||||
|
#define PGLANGUAGECONTAINER_H
|
||||||
|
|
||||||
|
#include "PgLanguage.h"
|
||||||
|
#include "PgContainer.h"
|
||||||
|
|
||||||
|
namespace Pgsql {
|
||||||
|
|
||||||
|
class Result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class PgLanguageContainer: public PgContainer<PgLanguage> {
|
||||||
|
public:
|
||||||
|
using PgContainer<PgLanguage>::PgContainer;
|
||||||
|
|
||||||
|
virtual std::string getLoadQuery() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual PgLanguage loadElem(const Pgsql::Row &row) override;
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // PGLANGUAGECONTAINER_H
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define PGPROC_H
|
#define PGPROC_H
|
||||||
|
|
||||||
#include "PgNamespaceObject.h"
|
#include "PgNamespaceObject.h"
|
||||||
|
#include "PgOwnedObject.h"
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
#include "Pgsql_Value.h"
|
#include "Pgsql_Value.h"
|
||||||
|
|
@ -24,14 +25,14 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PgProc: public PgNamespaceObject {
|
class PgProc: public PgNamespaceObject, public PgOwnedObject {
|
||||||
public:
|
public:
|
||||||
using PgNamespaceObject::PgNamespaceObject;
|
using PgNamespaceObject::PgNamespaceObject;
|
||||||
|
|
||||||
// Oid oid = InvalidOid; // oid
|
// Oid oid = InvalidOid; // oid
|
||||||
// QString name; // name
|
// QString name; // name
|
||||||
// Oid pronamespace = InvalidOid; // oid, namespace
|
// Oid pronamespace = InvalidOid; // oid, namespace
|
||||||
Oid owner = InvalidOid; // oid
|
// Oid owner = InvalidOid; // oid
|
||||||
Oid lang = InvalidOid; // oid
|
Oid lang = InvalidOid; // oid
|
||||||
float cost = 0.f; // float4
|
float cost = 0.f; // float4
|
||||||
float rows = 0.f; // float4
|
float rows = 0.f; // float4
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,11 @@ PgProc PgProcContainer::loadElem(const Pgsql::Row &row)
|
||||||
Oid oid = col.nextValue();
|
Oid oid = col.nextValue();
|
||||||
QString name = col.nextValue();
|
QString name = col.nextValue();
|
||||||
Oid namespace_oid = col.nextValue();
|
Oid namespace_oid = col.nextValue();
|
||||||
|
Oid owner_oid = col.nextValue();
|
||||||
|
|
||||||
PgProc v(m_catalog, oid, name, namespace_oid);
|
PgProc v(m_catalog, oid, name, namespace_oid);
|
||||||
|
v.setOwnerOid(m_catalog, owner_oid);
|
||||||
col >> v.owner >> v.lang >> v.cost >> v.rows
|
col >> v.lang >> v.cost >> v.rows
|
||||||
>> v.variadic >> v.transform >> v.isagg >> v.iswindow >> v.secdef >> v.leakproof
|
>> v.variadic >> v.transform >> v.isagg >> v.iswindow >> v.secdef >> v.leakproof
|
||||||
>> v.isstrict >> v.retset >> v.provolatile >> v.nargs >> v.nargdefaults
|
>> v.isstrict >> v.retset >> v.provolatile >> v.nargs >> v.nargdefaults
|
||||||
>> v.rettype;
|
>> v.rettype;
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,9 @@ public:
|
||||||
|
|
||||||
virtual std::string getLoadQuery() const override;
|
virtual std::string getLoadQuery() const override;
|
||||||
|
|
||||||
/** Searches for the type matching the specified oid.
|
|
||||||
*
|
|
||||||
* \return Returns the matching type or if it is not found a default constructed PgType (oid == InvalidOid).
|
|
||||||
*/
|
|
||||||
// const PgType& getTypeByOid(Oid oid) const;
|
|
||||||
// const PgType& getTypeByName(const QString &name) const;
|
|
||||||
// const PgType& getTypeByIdx(int idx) const;
|
|
||||||
protected:
|
protected:
|
||||||
virtual PgType loadElem(const Pgsql::Row &row) override;
|
virtual PgType loadElem(const Pgsql::Row &row) override;
|
||||||
private:
|
private:
|
||||||
// PgType m_invalidType; ///< default constructed object for when a non existent type is being retrieved.
|
|
||||||
// t_Types m_types; // Keep sorted by Oid
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PGTYPECONTAINER_H
|
#endif // PGTYPECONTAINER_H
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,9 @@ SOURCES += \
|
||||||
model/TypeSelectionItemModel.cpp \
|
model/TypeSelectionItemModel.cpp \
|
||||||
catalog/PgAmContainer.cpp \
|
catalog/PgAmContainer.cpp \
|
||||||
model/CollationModel.cpp \
|
model/CollationModel.cpp \
|
||||||
model/CollationModelFactory.cpp
|
model/CollationModelFactory.cpp \
|
||||||
|
catalog/PgLanguageContainer.cpp \
|
||||||
|
catalog/PgLanguage.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
Pglablib.h \
|
Pglablib.h \
|
||||||
|
|
@ -145,7 +147,9 @@ HEADERS += \
|
||||||
catalog/PgAm.h \
|
catalog/PgAm.h \
|
||||||
catalog/PgAmContainer.h \
|
catalog/PgAmContainer.h \
|
||||||
model/CollationModel.h \
|
model/CollationModel.h \
|
||||||
model/CollationModelFactory.h
|
model/CollationModelFactory.h \
|
||||||
|
catalog/PgLanguageContainer.h \
|
||||||
|
catalog/PgLanguage.h
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
target.path = /usr/lib
|
target.path = /usr/lib
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue