Compiles, links and runs (functionality not tested)
This commit is contained in:
parent
04723a289b
commit
6a97c0447a
48 changed files with 224 additions and 149 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "waithandlelist.h"
|
||||
#include "ScopeGuard.h"
|
||||
#include <chrono>
|
||||
#include <sys/select.h>
|
||||
|
||||
ASyncDBConnection::ASyncDBConnection()
|
||||
{
|
||||
|
|
@ -46,7 +47,7 @@ bool ASyncDBConnection::send(const std::string &command, on_result_callback on_r
|
|||
{
|
||||
std::lock_guard<std::mutex> lg(m_threadData.m_commandQueue.m_mutex);
|
||||
m_threadData.m_commandQueue.m_queue.emplace(command, on_result);
|
||||
m_threadData.m_commandQueue.m_newEvent.set();
|
||||
m_threadData.m_commandQueue.m_newEvent.notify_one();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -56,7 +57,7 @@ bool ASyncDBConnection::send(const std::string &command, Pgsql::Params params, o
|
|||
{
|
||||
std::lock_guard<std::mutex> lg(m_threadData.m_commandQueue.m_mutex);
|
||||
m_threadData.m_commandQueue.m_queue.emplace(command, std::move(params), on_result);
|
||||
m_threadData.m_commandQueue.m_newEvent.set();
|
||||
m_threadData.m_commandQueue.m_newEvent.notify_one();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -79,7 +80,6 @@ void ASyncDBConnection::setNoticeCallback(on_notice_callback notice_callback)
|
|||
}
|
||||
|
||||
ASyncDBConnection::Thread::Thread()
|
||||
: m_stopEvent(Win32Event::Reset::Manual, Win32Event::Initial::Clear)
|
||||
{}
|
||||
|
||||
void ASyncDBConnection::Thread::run()
|
||||
|
|
@ -124,14 +124,16 @@ bool ASyncDBConnection::Thread::cancel()
|
|||
|
||||
bool ASyncDBConnection::Thread::makeConnection()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
//using namespace std::literals::chrono_literals;
|
||||
|
||||
// start connecting
|
||||
auto keywords = m_config.getKeywords();
|
||||
auto values = m_config.getValues();
|
||||
#if true
|
||||
return m_connection.connect(keywords, values, 0);
|
||||
#else
|
||||
while (!terminateRequested) {
|
||||
|
||||
// start connecting
|
||||
//bool ok = m_connection.connectStart(m_initString + " client_encoding=utf8");
|
||||
auto keywords = m_config.getKeywords();
|
||||
auto values = m_config.getValues();
|
||||
bool ok = m_connection.connectStart(keywords, values);
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
if (ok && m_connection.status() != CONNECTION_BAD) {
|
||||
|
|
@ -144,7 +146,7 @@ bool ASyncDBConnection::Thread::makeConnection()
|
|||
WSAEventSelect(sock, socket_event.handle(), fd);
|
||||
WaitHandleList whl;
|
||||
auto wait_result_socket_event = whl.add(socket_event);
|
||||
auto wait_result_stop = whl.add(m_stopEvent);
|
||||
//auto wait_result_stop = whl.add(m_stopEvent);
|
||||
|
||||
auto nu = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<float, std::milli> diff = -(nu-start);
|
||||
|
|
@ -185,6 +187,7 @@ bool ASyncDBConnection::Thread::makeConnection()
|
|||
}
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ASyncDBConnection::Thread::communicate()
|
||||
|
|
@ -217,7 +220,7 @@ void ASyncDBConnection::Thread::communicate()
|
|||
void ASyncDBConnection::Thread::stop()
|
||||
{
|
||||
terminateRequested = true;
|
||||
m_stopEvent.set();
|
||||
//m_stopEvent.set();
|
||||
}
|
||||
|
||||
void ASyncDBConnection::Thread::doStateCallback(State state)
|
||||
|
|
@ -231,10 +234,21 @@ void ASyncDBConnection::Thread::doStateCallback(State state)
|
|||
|
||||
void ASyncDBConnection::Thread::waitForAndSendCommand()
|
||||
{
|
||||
// lock the data
|
||||
std::unique_lock<std::mutex> lk(m_commandQueue.m_mutex);
|
||||
if (m_commandQueue.m_queue.empty()) {
|
||||
// no data wait till there is data
|
||||
m_commandQueue.m_newEvent.wait(lk);
|
||||
// can we use the predicate to reimplement the stop function???, []{return ready;});
|
||||
|
||||
}
|
||||
doNewCommand();
|
||||
|
||||
#if false
|
||||
WaitHandleList whl;
|
||||
auto wait_result_new_command = whl.add(m_commandQueue.m_newEvent);
|
||||
//auto wait_result_stop =
|
||||
whl.add(m_stopEvent);
|
||||
//whl.add(m_stopEvent);
|
||||
|
||||
DWORD res = MsgWaitForMultipleObjectsEx(
|
||||
whl.count(), // _In_ DWORD nCount,
|
||||
|
|
@ -247,6 +261,7 @@ void ASyncDBConnection::Thread::waitForAndSendCommand()
|
|||
doNewCommand();
|
||||
}
|
||||
// if (res == wait_result_stop) return;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ASyncDBConnection::Thread::doNewCommand()
|
||||
|
|
@ -278,10 +293,60 @@ void ASyncDBConnection::Thread::doNewCommand()
|
|||
|
||||
}
|
||||
|
||||
bool ASyncDBConnection::Thread::consumeResultInput()
|
||||
{
|
||||
bool finished = false;
|
||||
if (m_connection.consumeInput()) {
|
||||
while ( ! finished && ! m_connection.isBusy()) {
|
||||
auto res(m_connection.getResult());
|
||||
{
|
||||
qint64 ms = m_timer.restart();
|
||||
std::lock_guard<std::mutex> lg(m_commandQueue.m_mutex);
|
||||
m_commandQueue.m_queue.front().on_result(res, ms);
|
||||
if (res == nullptr) {
|
||||
m_timer.invalidate();
|
||||
m_commandQueue.m_queue.pop();
|
||||
doStateCallback(State::Connected);
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// else is still waiting for more data
|
||||
|
||||
}
|
||||
else {
|
||||
// error during consume
|
||||
|
||||
}
|
||||
return finished;
|
||||
}
|
||||
|
||||
void ASyncDBConnection::Thread::waitForResult()
|
||||
{
|
||||
|
||||
int sock = m_connection.socket();
|
||||
|
||||
fd_set readfds;
|
||||
timeval timeout;
|
||||
bool finished = false;
|
||||
while (!finished && !terminateRequested) {
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(sock, &readfds);
|
||||
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
int select_result = select(1, &readfds, nullptr, nullptr, &timeout);
|
||||
if (select_result > 0) {
|
||||
if (FD_ISSET(sock, &readfds)) {
|
||||
if (consumeResultInput()) {
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#if false
|
||||
Win32Event socket_event(Win32Event::Reset::Manual, Win32Event::Initial::Clear);
|
||||
|
||||
long fd = FD_READ | FD_CLOSE;
|
||||
|
|
@ -292,7 +357,7 @@ void ASyncDBConnection::Thread::waitForResult()
|
|||
|
||||
WaitHandleList whl;
|
||||
auto wait_result_socket = whl.add(socket_event);
|
||||
auto wait_result_stop = whl.add(m_stopEvent);
|
||||
//auto wait_result_stop = whl.add(m_stopEvent);
|
||||
|
||||
DWORD res = MsgWaitForMultipleObjectsEx(
|
||||
whl.count(), // _In_ DWORD nCount,
|
||||
|
|
@ -306,29 +371,9 @@ void ASyncDBConnection::Thread::waitForResult()
|
|||
WSAEnumNetworkEvents(sock, socket_event.handle(), &net_events);
|
||||
|
||||
if (net_events.lNetworkEvents & FD_READ) {
|
||||
if (m_connection.consumeInput()) {
|
||||
while ( ! finished && ! m_connection.isBusy()) {
|
||||
auto res(m_connection.getResult());
|
||||
{
|
||||
qint64 ms = m_timer.restart();
|
||||
std::lock_guard<std::mutex> lg(m_commandQueue.m_mutex);
|
||||
m_commandQueue.m_queue.front().on_result(res, ms);
|
||||
if (res == nullptr) {
|
||||
m_timer.invalidate();
|
||||
m_commandQueue.m_queue.pop();
|
||||
doStateCallback(State::Connected);
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// else is still waiting for more data
|
||||
|
||||
}
|
||||
else {
|
||||
// error during consume
|
||||
|
||||
}
|
||||
if (consumeResultInput()) {
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res == wait_result_stop) {
|
||||
|
|
@ -339,6 +384,7 @@ void ASyncDBConnection::Thread::waitForResult()
|
|||
}
|
||||
} // end while
|
||||
// When last result received, remove command from queue
|
||||
#endif
|
||||
}
|
||||
|
||||
void ASyncDBConnection::Thread::processNotice(const PGresult *result)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
#include "PgsqlConn.h"
|
||||
#include "Pgsql_Params.h"
|
||||
#include "win32event.h"
|
||||
#include "ConnectionConfig.h"
|
||||
#include <QElapsedTimer>
|
||||
#include <functional>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
|
@ -86,9 +86,8 @@ private:
|
|||
struct t_Command {
|
||||
std::mutex m_mutex;
|
||||
t_CommandQueue m_queue;
|
||||
Win32Event m_newEvent;
|
||||
std::condition_variable m_newEvent;
|
||||
t_Command()
|
||||
: m_newEvent(Win32Event::Reset::Auto, Win32Event::Initial::Clear)
|
||||
{}
|
||||
} m_commandQueue;
|
||||
|
||||
|
|
@ -108,8 +107,8 @@ private:
|
|||
|
||||
private:
|
||||
|
||||
|
||||
Win32Event m_stopEvent;
|
||||
/// \todo Implement new method to stop the thread
|
||||
//Win32Event m_stopEvent;
|
||||
Pgsql::Connection m_connection;
|
||||
bool terminateRequested = false; ///< is set when the thread should stop
|
||||
bool m_terminated = true;
|
||||
|
|
@ -128,6 +127,11 @@ private:
|
|||
|
||||
|
||||
void processNotice(const PGresult *result);
|
||||
/** Function to call when after sending a command the socket is ready for reading.
|
||||
*
|
||||
* It might take several consumes before all data is read.
|
||||
*/
|
||||
bool consumeResultInput();
|
||||
};
|
||||
|
||||
Thread m_threadData;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "backupdialog.h"
|
||||
#include "ui_backupdialog.h"
|
||||
#include "BackupDialog.h"
|
||||
#include "ui_BackupDialog.h"
|
||||
|
||||
#include "BackupFormatModel.h"
|
||||
|
||||
|
|
@ -9,8 +9,6 @@
|
|||
#include <QScrollBar>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
BackupDialog::BackupDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::BackupDialog)
|
||||
|
|
@ -234,13 +232,14 @@ void BackupDialog::on_btnStart_clicked()
|
|||
auto p = new QProcess(this);
|
||||
ConnectTo(p);
|
||||
p->setProcessEnvironment(env);
|
||||
|
||||
#ifdef _WIN32
|
||||
p->setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args)
|
||||
{
|
||||
args->flags |= CREATE_NEW_CONSOLE;
|
||||
args->flags &= ~DETACHED_PROCESS;
|
||||
args->startupInfo->dwFlags &= ~STARTF_USESTDHANDLES;
|
||||
});
|
||||
#endif
|
||||
p->start(program, arguments);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <QProcess>
|
||||
#include <QProcessEnvironment>
|
||||
#include "connectionconfig.h"
|
||||
#include "ConnectionConfig.h"
|
||||
|
||||
void setupEnvironment(const ConnectionConfig &cc)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "connectionconfig.h"
|
||||
#include "ConnectionConfig.h"
|
||||
#include "util.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QProcessEnvironment>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "ConnectionList.h"
|
||||
#include "scopeguard.h"
|
||||
#include "ScopeGuard.h"
|
||||
#include "util.h"
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "ConnectionListModel.h"
|
||||
#include "ConnectionList.h"
|
||||
#include "scopeguard.h"
|
||||
#include "ScopeGuard.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <botan/cryptobox.h>
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "connectionconfig.h"
|
||||
#include "expected.h"
|
||||
#include "ConnectionConfig.h"
|
||||
#include "Expected.h"
|
||||
|
||||
class ConnectionList;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
#include "connectionmanagerwindow.h"
|
||||
#include "ui_connectionmanagerwindow.h"
|
||||
#include "ConnectionManagerWindow.h"
|
||||
#include "ui_ConnectionManagerWindow.h"
|
||||
//#include "mainwindow.h"
|
||||
#include "MasterController.h"
|
||||
#include <QDataWidgetMapper>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include "connectionlistmodel.h"
|
||||
#include "ConnectionListModel.h"
|
||||
|
||||
ConnectionManagerWindow::ConnectionManagerWindow(MasterController *master, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "databaseinspectorwidget.h"
|
||||
#include "ui_databaseinspectorwidget.h"
|
||||
#include "DatabaseInspectorWidget.h"
|
||||
#include "ui_DatabaseInspectorWidget.h"
|
||||
|
||||
DatabaseInspectorWidget::DatabaseInspectorWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "databasewindow.h"
|
||||
#include "ui_databasewindow.h"
|
||||
#include "DatabaseWindow.h"
|
||||
#include "ui_DatabaseWindow.h"
|
||||
#include <QTimer>
|
||||
|
||||
DatabaseWindow::DatabaseWindow(QWidget *parent) :
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef DATABASEWINDOW_H
|
||||
#define DATABASEWINDOW_H
|
||||
|
||||
#include "asyncdbconnection.h"
|
||||
#include "ASyncDBConnection.h"
|
||||
#include "tsqueue.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "explaintreemodelitem.h"
|
||||
#include "ExplainTreeModelItem.h"
|
||||
#include "json/json.h"
|
||||
#include <limits>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
#include "MainWindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
#include <QStandardPaths>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QTextTable>
|
||||
#include <QElapsedTimer>
|
||||
#include <windows.h>
|
||||
#include <algorithm>
|
||||
#include <QCloseEvent>
|
||||
#include <QMetaObject>
|
||||
#include <QMetaMethod>
|
||||
#include <querytab.h>
|
||||
#include "QueryTab.h"
|
||||
#include "util.h"
|
||||
#include "MasterController.h"
|
||||
#include "OpenDatabase.h"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "asyncdbconnection.h"
|
||||
#include "connectionconfig.h"
|
||||
#include "ASyncDBConnection.h"
|
||||
#include "ConnectionConfig.h"
|
||||
#include "tsqueue.h"
|
||||
#include <QLabel>
|
||||
#include "ASyncWindow.h"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "OpenDatabase.h"
|
||||
#include "pgsqldatabasecatalogue.h"
|
||||
#include "PgsqlDatabaseCatalogue.h"
|
||||
#include "PgsqlConn.h"
|
||||
#include "typeselectionitemmodel.h"
|
||||
#include "TypeSelectionItemModel.h"
|
||||
|
||||
Expected<OpenDatabase*> OpenDatabase::createOpenDatabase(const ConnectionConfig &cfg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
#define OPENDATABASE_H
|
||||
|
||||
#include <QObject>
|
||||
#include "connectionconfig.h"
|
||||
#include "expected.h"
|
||||
#include "ConnectionConfig.h"
|
||||
#include "Expected.h"
|
||||
|
||||
class PgsqlDatabaseCatalogue;
|
||||
class TypeSelectionItemModel;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef PGAUTHID_H
|
||||
#define PGAUTHID_H
|
||||
|
||||
#include <pgsql/libpq-fe.h>
|
||||
#include <libpq-fe.h>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
#include "pgclass.h"
|
||||
#include "PgClass.h"
|
||||
|
||||
PgClass::PgClass() = default;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define PGCLASS_H
|
||||
|
||||
#include <QString>
|
||||
#include <pgsql/libpq-fe.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
class PgClass {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
#include <pgsql/libpq-fe.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
class PgsqlDatabaseCatalogue;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define PGDATABASE_H
|
||||
|
||||
#include <QString>
|
||||
#include <pgsql/libpq-fe.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
class PgDatabase {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "pgnamespace.h"
|
||||
#include "PgNamespace.h"
|
||||
|
||||
PgNamespace::PgNamespace() = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define PGNAMESPACE_H
|
||||
|
||||
#include <QString>
|
||||
#include <pgsql/libpq-fe.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
class PgNamespace
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "pgtype.h"
|
||||
#include "PgType.h"
|
||||
#include "PgsqlConn.h"
|
||||
|
||||
PgType::PgType() = default;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define PGTYPE_H
|
||||
|
||||
#include <QString>
|
||||
#include <pgsql/libpq-fe.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
class PgType {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "pgtypecontainer.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include "PgsqlConn.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define PGTYPECONTAINER_H
|
||||
|
||||
#include <vector>
|
||||
#include "pgtype.h"
|
||||
#include "PgType.h"
|
||||
#include "PgContainer.h"
|
||||
|
||||
namespace Pgsql {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef PGSQLDATABASECATALOGUE_H
|
||||
#define PGSQLDATABASECATALOGUE_H
|
||||
|
||||
#include <pgsql/libpq-fe.h>
|
||||
#include <libpq-fe.h>
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ Value::operator Oid() const
|
|||
return operator int();
|
||||
}
|
||||
|
||||
Value::operator __int64() const
|
||||
Value::operator long long() const
|
||||
{
|
||||
return std::strtoull(m_val, nullptr, 10);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "queryexplainmodel.h"
|
||||
#include "QueryExplainModel.h"
|
||||
#include <QColor>
|
||||
#include <QSize>
|
||||
#include <cmath>
|
||||
|
||||
const int c_ColumnNode = 0;
|
||||
const int c_ColumnExclusive = 1;
|
||||
|
|
@ -79,7 +80,7 @@ if (role == Qt::DisplayRole) {
|
|||
}
|
||||
}
|
||||
if (col == c_ColumnEstErr) {
|
||||
float e = fabs(item->estimateError());
|
||||
float e = std::fabs(item->estimateError());
|
||||
if (e > 1000.0f) {
|
||||
result = QColor(255, 192, 192);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <QAbstractItemModel>
|
||||
#include <string>
|
||||
#include "explaintreemodelitem.h"
|
||||
#include "ExplainTreeModelItem.h"
|
||||
|
||||
/** \brief Model class for displaying the explain of a query in a tree like format.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "queryresultmodel.h"
|
||||
#include "QueryResultModel.h"
|
||||
#include "Pgsql_declare.h"
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "querytab.h"
|
||||
#include "ui_querytab.h"
|
||||
#include "QueryTab.h"
|
||||
#include "ui_QueryTab.h"
|
||||
|
||||
#include "SqlSyntaxHighlighter.h"
|
||||
|
||||
|
|
@ -12,12 +12,12 @@
|
|||
#include <QTextDocumentFragment>
|
||||
#include <QTextStream>
|
||||
#include <QClipboard>
|
||||
#include "explaintreemodelitem.h"
|
||||
#include "ExplainTreeModelItem.h"
|
||||
#include "json/json.h"
|
||||
#include "MainWindow.h"
|
||||
#include "OpenDatabase.h"
|
||||
#include "pgtypecontainer.h"
|
||||
#include "pgsqldatabasecatalogue.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include "PgsqlDatabaseCatalogue.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef QUERYTAB_H
|
||||
#define QUERYTAB_H
|
||||
|
||||
#include "asyncdbconnection.h"
|
||||
#include "ASyncDBConnection.h"
|
||||
#include "ParamListModel.h"
|
||||
#include "ParamTypeDelegate.h"
|
||||
#include "queryresultmodel.h"
|
||||
#include "queryexplainmodel.h"
|
||||
#include "QueryResultModel.h"
|
||||
#include "QueryExplainModel.h"
|
||||
#include "stopwatch.h"
|
||||
#include "tuplesresultwidget.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#include "SqlHighlighter.h"
|
||||
|
||||
static const wchar_t *keywords[] = {
|
||||
L"as", L"alter", L"all", L"and", L"any", L"by", L"char", L"column", L"create", L"database", L"date", L"from", L"full", L"group", L"having",
|
||||
L"in", L"inner", L"int", L"join", L"left", L"not", L"numeric", L"or", L"order", L"outer", L"right", L"select", L"smallint", L"table", L"time",
|
||||
L"timestamp", L"timestamptz", L"varchar", L"where"
|
||||
};
|
||||
|
||||
static const wchar_t *operators[] = {
|
||||
L"+", L"-", L"*", L"/", L"<", L">", L"<=", L">=", L"<>", L"!=", L"~"
|
||||
};
|
||||
// static const wchar_t *keywords[] = {
|
||||
// L"as", L"alter", L"all", L"and", L"any", L"by", L"char", L"column", L"create", L"database", L"date", L"from", L"full", L"group", L"having",
|
||||
// L"in", L"inner", L"int", L"join", L"left", L"not", L"numeric", L"or", L"order", L"outer", L"right", L"select", L"smallint", L"table", L"time",
|
||||
// L"timestamp", L"timestamptz", L"varchar", L"where"
|
||||
// };
|
||||
//
|
||||
// static const wchar_t *operators[] = {
|
||||
// L"+", L"-", L"*", L"/", L"<", L">", L"<=", L">=", L"<>", L"!=", L"~"
|
||||
// };
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -17,7 +17,7 @@ static const wchar_t *operators[] = {
|
|||
|
||||
There are a few restrictions on your choice of name:
|
||||
|
||||
-- and /* cannot appear anywhere in an operator name, since they will be taken as the start of a comment.
|
||||
-- and C-comment start cannot appear anywhere in an operator name, since they will be taken as the start of a comment.
|
||||
|
||||
A multicharacter operator name cannot end in + or -, unless the name also contains at least one of these characters:
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#include "SqlSyntaxHighlighter.h"
|
||||
|
||||
#include "pgtypecontainer.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include "SqlLexer.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "typeselectionitemmodel.h"
|
||||
#include "TypeSelectionItemModel.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
|
@ -61,8 +61,8 @@ void TypeSelectionItemModel::setTypeList(const PgTypeContainer* types)
|
|||
beginResetModel();
|
||||
m_types.clear();
|
||||
for (const auto &e : *types) {
|
||||
if (e.typcategory != 'A'
|
||||
&& e.typtype != 'c') {
|
||||
if (e.typcategory != "A"
|
||||
&& e.typtype != "c") {
|
||||
m_types.push_back(e.typname);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,15 @@
|
|||
#include "MasterController.h"
|
||||
#include <QApplication>
|
||||
#include <winsock2.h>
|
||||
#ifdef _WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#include <memory>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
|
||||
#ifdef _WIN32
|
||||
WORD wVersionRequested = MAKEWORD(2, 2);
|
||||
WSADATA wsaData;
|
||||
int err = WSAStartup(wVersionRequested, &wsaData);
|
||||
|
|
@ -16,7 +19,7 @@ int main(int argc, char *argv[])
|
|||
printf("WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QCoreApplication::setOrganizationName("pglab");
|
||||
|
|
@ -26,8 +29,9 @@ int main(int argc, char *argv[])
|
|||
auto master_controller = std::make_unique<MasterController>();
|
||||
master_controller->init();
|
||||
int result = a.exec();
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#include "tsqueue.h"
|
||||
|
||||
TSQueue::TSQueue()
|
||||
: newData(Win32Event::Reset::Manual, Win32Event::Initial::Clear)
|
||||
// : newData(Win32Event::Reset::Manual, Win32Event::Initial::Clear)
|
||||
{}
|
||||
|
||||
void TSQueue::add(t_Callable callable)
|
||||
{
|
||||
std::lock_guard<std::mutex> g(m);
|
||||
futureQueue.push_back(std::move(callable));
|
||||
newData.set();
|
||||
// newData.set();
|
||||
}
|
||||
|
||||
bool TSQueue::empty()
|
||||
|
|
@ -23,12 +23,12 @@ TSQueue::t_Callable TSQueue::pop()
|
|||
auto f = std::move(futureQueue.front());
|
||||
futureQueue.pop_front();
|
||||
if (futureQueue.empty()) {
|
||||
newData.reset();
|
||||
// newData.reset();
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
HANDLE TSQueue::getNewDataEventHandle()
|
||||
{
|
||||
return newData.handle();
|
||||
}
|
||||
// HANDLE TSQueue::getNewDataEventHandle()
|
||||
// {
|
||||
// return newData.handle();
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef TSQUEUE_H
|
||||
#define TSQUEUE_H
|
||||
|
||||
#include "Win32Event.h"
|
||||
//#include "Win32Event.h"
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
|
|
@ -15,11 +15,11 @@ public:
|
|||
bool empty();
|
||||
t_Callable pop();
|
||||
|
||||
HANDLE getNewDataEventHandle();
|
||||
//HANDLE getNewDataEventHandle();
|
||||
private:
|
||||
using t_CallableQueue = std::deque<t_Callable>;
|
||||
|
||||
Win32Event newData;
|
||||
//Win32Event newData;
|
||||
std::mutex m;
|
||||
t_CallableQueue futureQueue;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef TUPLESRESULTWIDGET_H
|
||||
#define TUPLESRESULTWIDGET_H
|
||||
|
||||
#include "queryresultmodel.h"
|
||||
#include "QueryResultModel.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "util.h"
|
||||
#include "csvwriter.h"
|
||||
#include "CsvWriter.h"
|
||||
#include <QApplication>
|
||||
#include <QTextStream>
|
||||
#include <QClipboard>
|
||||
|
|
@ -108,8 +108,7 @@ void copySelectionToClipboard(const QTableView *view)
|
|||
|
||||
QString ConvertToMultiLineCString(const QString &in)
|
||||
{
|
||||
// We need to atleast escape " and \
|
||||
// also any multi byte utf8 char
|
||||
// We need to atleast escape " and \ and also any multi byte utf8 char
|
||||
|
||||
QString out;
|
||||
out.append('"');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "waithandlelist.h"
|
||||
#include "win32event.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
WaitHandleList::WaitHandleList() = default;
|
||||
WaitHandleList::~WaitHandleList() = default;
|
||||
|
||||
|
|
@ -29,3 +30,5 @@ WaitHandleList::operator const HANDLE*() const
|
|||
{
|
||||
return m_waitHandles.data();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue