2018-11-25 19:45:06 +01:00
|
|
|
|
#include "PgDatabase.h"
|
2022-01-20 20:13:56 +01:00
|
|
|
|
#include "PgDatabaseCatalog.h"
|
|
|
|
|
|
#include "SqlFormattingUtils.h"
|
|
|
|
|
|
#include <QStringBuilder>
|
2017-02-12 14:03:42 +01:00
|
|
|
|
|
2018-12-24 11:31:56 +01:00
|
|
|
|
QString PgDatabase::typeName() const
|
|
|
|
|
|
{
|
2022-01-20 20:13:56 +01:00
|
|
|
|
return "DATABASE";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString PgDatabase::aclAllPattern() const
|
|
|
|
|
|
{
|
|
|
|
|
|
// Create
|
|
|
|
|
|
// Connect
|
|
|
|
|
|
// Temporary
|
|
|
|
|
|
return "CcT";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString PgDatabase::dropSql() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return "DROP DATABASE " % quotedObjectName() % ";";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
{
|
|
|
|
|
|
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;
|
2018-12-24 11:31:56 +01:00
|
|
|
|
}
|