Improvements in generated SQL for CREATE FUNCTION
This commit is contained in:
parent
f692569d27
commit
1854a4bdaa
2 changed files with 40 additions and 14 deletions
|
|
@ -2,7 +2,9 @@
|
|||
#include "std_utils.h"
|
||||
#include "SqlFormattingUtils.h"
|
||||
#include "PgDatabaseCatalog.h"
|
||||
#include "PgLanguageContainer.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include <QStringBuilder>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace {
|
||||
|
|
@ -218,31 +220,42 @@ QString PgProc::createSql() const
|
|||
// {
|
||||
// if (GetConnection()->BackendMinimumVersion(7, 5))
|
||||
// sql += qtDbStringDollar(GetSource());
|
||||
sql += dollarQuoteString(src);
|
||||
// else
|
||||
// sql += qtDbString(GetSource());
|
||||
// }
|
||||
QString language;
|
||||
{
|
||||
auto l = catalog().languages()->getByKey(lang);
|
||||
if (l)
|
||||
language = l->objectName();
|
||||
}
|
||||
if (language == "c") {
|
||||
sql += escapeLiteral(bin) % ", " % escapeLiteral(src);
|
||||
}
|
||||
else {
|
||||
sql += dollarQuoteString(src);
|
||||
}
|
||||
// sql += wxT("\n LANGUAGE ") + GetLanguage() + wxT(" ");
|
||||
sql += "\n LANGUAGE " % language % " ";
|
||||
// if (GetConnection()->BackendMinimumVersion(8, 4) && GetIsWindow())
|
||||
// sql += wxT("WINDOW ");
|
||||
if (iswindow)
|
||||
sql += "WINDOW ";
|
||||
// sql += GetVolatility();
|
||||
sql += volatility();
|
||||
|
||||
if (leakproof)
|
||||
sql += " LEAKPROOF";
|
||||
if (isstrict)
|
||||
sql += " STRICT";
|
||||
|
||||
// if (GetConnection()->BackendMinimumVersion(9, 2) && GetIsLeakProof())
|
||||
// sql += wxT(" LEAKPROOF");
|
||||
// if (GetIsStrict())
|
||||
// sql += wxT(" STRICT");
|
||||
// if (GetSecureDefiner())
|
||||
// sql += wxT(" SECURITY DEFINER");
|
||||
|
||||
// // PostgreSQL 8.3+ cost/row estimations
|
||||
// if (GetConnection()->BackendMinimumVersion(8, 3))
|
||||
// {
|
||||
// sql += wxT("\n COST ") + NumToStr(GetCost());
|
||||
|
||||
// if (GetReturnAsSet())
|
||||
// sql += wxT("\n ROWS ") + NumToStr(GetRows());
|
||||
// }
|
||||
|
||||
sql += QString("\n COST %1").arg(cost);
|
||||
if (retset)
|
||||
sql += QString("n ROWS %1").arg(rows);
|
||||
sql += ";";
|
||||
// if (!sql.Strip(wxString::both).EndsWith(wxT(";")))
|
||||
// sql += wxT(";");
|
||||
|
||||
|
|
@ -276,3 +289,14 @@ QString PgProc::createSql() const
|
|||
|
||||
return createSqlCache;
|
||||
}
|
||||
|
||||
|
||||
QString PgProc::volatility() const
|
||||
{
|
||||
switch (provolatile) {
|
||||
case 'i': return "IMMUTABLE";
|
||||
case 's': return "STABLE";
|
||||
case 'v': return "VOLATILE";
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue