WIP createdb dialog
This commit is contained in:
parent
c20427e10d
commit
d3080a08bb
10 changed files with 113 additions and 45 deletions
|
|
@ -23,29 +23,30 @@ QString PgDatabase::dropSql() const
|
|||
|
||||
QString PgDatabase::createSql() const
|
||||
{
|
||||
QString s = "CREATE DATABASE " % quotedObjectName()
|
||||
// TEMPLATE is missing as this is not stored in the catalog
|
||||
% "\n OWNER " % quoteIdent(ownerName())
|
||||
% "\n ENCODING " % escapeLiteral(encodingString)
|
||||
% "\n LC_COLLATE " % escapeLiteral(collate)
|
||||
% "\n LC_TYPE " % escapeLiteral(ctype);
|
||||
auto ns = getTablespaceDisplayString(catalog(), tablespace);
|
||||
if (ns != "pg_default")
|
||||
QString s = "CREATE DATABASE " % quotedObjectName();
|
||||
|
||||
if (hasOwner())
|
||||
s += "\n OWNER " % quoteIdent(ownerName());
|
||||
if (!dbTemplate.isEmpty())
|
||||
s += "\n TEMPLATE " % escapeLiteral(dbTemplate);
|
||||
if (!encodingString.isEmpty())
|
||||
s += "\n ENCODING " % escapeLiteral(encodingString);
|
||||
if (!collate.isEmpty())
|
||||
s += "\n LC_COLLATE " % escapeLiteral(collate);
|
||||
if (!ctype.isEmpty())
|
||||
s += "\n LC_TYPE " % escapeLiteral(ctype);
|
||||
if (tablespace != InvalidOid)
|
||||
{
|
||||
s += "\n TABLESPACE " % quoteIdent(ns);
|
||||
auto ns = getTablespaceDisplayString(catalog(), tablespace);
|
||||
if (ns != "pg_default")
|
||||
s += "\n TABLESPACE " % quoteIdent(ns);
|
||||
}
|
||||
if (!allowConn)
|
||||
{
|
||||
s += "\n ALLOW_CONNECTIONS FALSE";
|
||||
}
|
||||
if (connLimit >= 0)
|
||||
{
|
||||
s += "\n CONNECTION LIMIT " % QString::number(connLimit);
|
||||
}
|
||||
if (isTemplate)
|
||||
{
|
||||
s += "\n IS_TEMPLATE TRUE";
|
||||
}
|
||||
s += ";";
|
||||
return s;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,15 @@
|
|||
class PgDatabase: public PgServerObject {
|
||||
public:
|
||||
|
||||
int encoding;
|
||||
int encoding = 0;
|
||||
QString encodingString;
|
||||
QString collate;
|
||||
QString ctype;
|
||||
bool isTemplate;
|
||||
bool allowConn;
|
||||
int connLimit;
|
||||
Oid tablespace;
|
||||
QString dbTemplate; ///< Not stored in the catalog but can be present in CREATE DATABASE statement
|
||||
bool isTemplate = false;
|
||||
bool allowConn = true;
|
||||
int connLimit = -1;
|
||||
Oid tablespace = InvalidOid;
|
||||
|
||||
using PgServerObject::PgServerObject;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,14 @@ const QString& PgObject::objectName() const
|
|||
return m_name;
|
||||
}
|
||||
|
||||
void PgObject::setObjectName(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
QString PgObject::quotedObjectName() const
|
||||
{
|
||||
return quoteIdent(objectName());
|
||||
return quoteIdent(objectName());
|
||||
}
|
||||
|
||||
QString PgObject::fullyQualifiedQuotedObjectName() const
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public:
|
|||
|
||||
Oid oid() const;
|
||||
const QString& objectName() const;
|
||||
void setObjectName(const QString &name);
|
||||
/// Default implementation uses objectName and add quotes when needed.
|
||||
virtual QString quotedObjectName() const;
|
||||
/// By default same as quotedObjectName however for objects that reside in namespaces
|
||||
|
|
@ -28,8 +29,8 @@ protected:
|
|||
const PgDatabaseCatalog& catalog() const;
|
||||
|
||||
private:
|
||||
PgDatabaseCatalog* m_catalog;
|
||||
Oid m_oid;
|
||||
PgDatabaseCatalog* m_catalog;
|
||||
Oid m_oid;
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public:
|
|||
QString commentSql() const;
|
||||
private:
|
||||
Oid m_ownerOid = InvalidOid;
|
||||
const PgAuthId * m_owner;
|
||||
const PgAuthId * m_owner = nullptr;
|
||||
boost::optional<AclList> m_acls;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue