Created IndexModel for displaying the indexes on a table. Constraints can now show the SQL to drop and create them.

The keyword list is now directly based of the official keyword list from postgresql.
This commit is contained in:
eelke 2018-01-06 21:22:22 +01:00
parent b436814eb5
commit 97d4e2a1a4
24 changed files with 754 additions and 228 deletions

View file

@ -1,6 +1,7 @@
#include "Pgsql_Connection.h"
#include "Pgsql_declare.h"
#include "Pgsql_Params.h"
#include <memory>
#include <stdexcept>
@ -199,6 +200,52 @@ void Connection::setNoticeReceiver(std::function<void(const PGresult *)> callbac
, reinterpret_cast<void*>(this));
}
std::string Connection::escapeLiteral(const std::string_view &literal)
{
std::unique_ptr<char, void(*)(char*)> result(
PQescapeLiteral(conn, literal.data(), literal.length()),
[](char*p) { if (p) PQfreemem(p); });
if (result) {
return std::string(result.get());
}
throw std::runtime_error("escapeLiteral(string_view) failed");
}
QString Connection::escapeLiteral(const QString &literal)
{
auto u8 = literal.toUtf8();
std::unique_ptr<char, void(*)(char*)> result(
PQescapeLiteral(conn, u8.data(), u8.length()),
[](char*p) { if (p) PQfreemem(p); });
if (result) {
return QString::fromUtf8(result.get());
}
throw std::runtime_error("escapeLiteral(QString) failed");
}
std::string Connection::escapeIdentifier(const std::string_view &ident)
{
std::unique_ptr<char, void(*)(char*)> result(
PQescapeIdentifier(conn, ident.data(), ident.length()),
[](char*p) { if (p) PQfreemem(p); });
if (result) {
return std::string(result.get());
}
throw std::runtime_error("escapeIdentifier failed");
}
QString Connection::escapeIdentifier(const QString &ident)
{
auto u8 = ident.toUtf8();
std::unique_ptr<char, void(*)(char*)> result(
PQescapeIdentifier(conn, u8.data(), u8.length()),
[](char*p) { if (p) PQfreemem(p); });
if (result) {
return QString::fromUtf8(result.get());
}
throw std::runtime_error("escapeIdentifier(QString) failed");
}
void Connection::notifyReceiveFunc(void *arg, const PGresult *result)
{
Connection *c = reinterpret_cast<Connection *>(arg);