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
|
|
@ -15,6 +15,7 @@
|
|||
#include "PgProcContainer.h"
|
||||
#include "PgCollationContainer.h"
|
||||
#include "PgInheritsContainer.h"
|
||||
#include "PgLanguageContainer.h"
|
||||
#include "Pgsql_Connection.h"
|
||||
#include "Pgsql_oids.h"
|
||||
|
||||
|
|
@ -151,6 +152,9 @@ void PgDatabaseCatalog::loadAll(Pgsql::Connection &conn,
|
|||
return;
|
||||
|
||||
// Load database objects
|
||||
load2(m_languages, conn);
|
||||
if (progress_callback && !progress_callback(++n, count))
|
||||
return;
|
||||
load2(m_namespaces, conn);
|
||||
if (progress_callback && !progress_callback(++n, count))
|
||||
return;
|
||||
|
|
@ -302,3 +306,8 @@ std::shared_ptr<const PgInheritsContainer> PgDatabaseCatalog::inherits() const
|
|||
{
|
||||
return m_inherits;
|
||||
}
|
||||
|
||||
std::shared_ptr<const PgLanguageContainer> PgDatabaseCatalog::languages() const
|
||||
{
|
||||
return m_languages;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class PgTypeContainer;
|
|||
class PgProcContainer;
|
||||
class PgCollationContainer;
|
||||
class PgInheritsContainer;
|
||||
|
||||
class PgLanguageContainer;
|
||||
|
||||
class PgDatabaseCatalog: public QObject, public std::enable_shared_from_this<PgDatabaseCatalog> {
|
||||
Q_OBJECT
|
||||
|
|
@ -62,6 +62,7 @@ public:
|
|||
std::shared_ptr<const PgProcContainer> procs() const;
|
||||
std::shared_ptr<const PgCollationContainer> collations() const;
|
||||
std::shared_ptr<const PgInheritsContainer> inherits() const;
|
||||
std::shared_ptr<const PgLanguageContainer> languages() const;
|
||||
|
||||
enum RefreshFlag {
|
||||
Attributes = 1,
|
||||
|
|
@ -101,6 +102,7 @@ private:
|
|||
std::shared_ptr<PgProcContainer> m_procs;
|
||||
std::shared_ptr<PgCollationContainer> m_collations;
|
||||
std::shared_ptr<PgInheritsContainer> m_inherits;
|
||||
std::shared_ptr<PgLanguageContainer> m_languages;
|
||||
|
||||
template <typename T>
|
||||
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
|
||||
|
||||
#include "PgNamespaceObject.h"
|
||||
#include "PgOwnedObject.h"
|
||||
#include <QString>
|
||||
#include <libpq-fe.h>
|
||||
#include "Pgsql_Value.h"
|
||||
|
|
@ -24,14 +25,14 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class PgProc: public PgNamespaceObject {
|
||||
class PgProc: public PgNamespaceObject, public PgOwnedObject {
|
||||
public:
|
||||
using PgNamespaceObject::PgNamespaceObject;
|
||||
|
||||
// Oid oid = InvalidOid; // oid
|
||||
// QString name; // name
|
||||
// Oid pronamespace = InvalidOid; // oid, namespace
|
||||
Oid owner = InvalidOid; // oid
|
||||
// Oid owner = InvalidOid; // oid
|
||||
Oid lang = InvalidOid; // oid
|
||||
float cost = 0.f; // float4
|
||||
float rows = 0.f; // float4
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ PgProc PgProcContainer::loadElem(const Pgsql::Row &row)
|
|||
Oid oid = col.nextValue();
|
||||
QString name = col.nextValue();
|
||||
Oid namespace_oid = col.nextValue();
|
||||
Oid owner_oid = col.nextValue();
|
||||
|
||||
PgProc v(m_catalog, oid, name, namespace_oid);
|
||||
|
||||
col >> v.owner >> v.lang >> v.cost >> v.rows
|
||||
v.setOwnerOid(m_catalog, owner_oid);
|
||||
col >> v.lang >> v.cost >> v.rows
|
||||
>> v.variadic >> v.transform >> v.isagg >> v.iswindow >> v.secdef >> v.leakproof
|
||||
>> v.isstrict >> v.retset >> v.provolatile >> v.nargs >> v.nargdefaults
|
||||
>> v.rettype;
|
||||
|
|
|
|||
|
|
@ -16,18 +16,9 @@ public:
|
|||
|
||||
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:
|
||||
virtual PgType loadElem(const Pgsql::Row &row) override;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -80,7 +80,9 @@ SOURCES += \
|
|||
model/TypeSelectionItemModel.cpp \
|
||||
catalog/PgAmContainer.cpp \
|
||||
model/CollationModel.cpp \
|
||||
model/CollationModelFactory.cpp
|
||||
model/CollationModelFactory.cpp \
|
||||
catalog/PgLanguageContainer.cpp \
|
||||
catalog/PgLanguage.cpp
|
||||
|
||||
HEADERS += \
|
||||
Pglablib.h \
|
||||
|
|
@ -145,7 +147,9 @@ HEADERS += \
|
|||
catalog/PgAm.h \
|
||||
catalog/PgAmContainer.h \
|
||||
model/CollationModel.h \
|
||||
model/CollationModelFactory.h
|
||||
model/CollationModelFactory.h \
|
||||
catalog/PgLanguageContainer.h \
|
||||
catalog/PgLanguage.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue