提交 142c63e4 编写于 作者: M MovElb

done rebase

上级 b4b5c903
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include <Common/SensitiveDataMasker.h> #include <Common/SensitiveDataMasker.h>
#include <Common/ThreadFuzzer.h> #include <Common/ThreadFuzzer.h>
#include <Server/MySQLHandlerFactory.h> #include <Server/MySQLHandlerFactory.h>
#include <Server/PostgreSQLHandlerFactory.h>
#if !defined(ARCADIA_BUILD) #if !defined(ARCADIA_BUILD)
...@@ -935,6 +936,21 @@ int Server::main(const std::vector<std::string> & /*args*/) ...@@ -935,6 +936,21 @@ int Server::main(const std::vector<std::string> & /*args*/)
LOG_INFO(log, "Listening for MySQL compatibility protocol: {}", address.toString()); LOG_INFO(log, "Listening for MySQL compatibility protocol: {}", address.toString());
}); });
create_server("postgresql_port", [&](UInt16 port)
{
Poco::Net::ServerSocket socket;
auto address = socket_bind_listen(socket, listen_host, port, /* secure = */ true);
socket.setReceiveTimeout(Poco::Timespan());
socket.setSendTimeout(settings.send_timeout);
servers.emplace_back(std::make_unique<Poco::Net::TCPServer>(
new PostgreSQLHandlerFactory(*this),
server_pool,
socket,
new Poco::Net::TCPServerParams));
LOG_INFO(log, "Listening for PostgreSQL compatibility protocol: " + address.toString());
});
/// Prometheus (if defined and not setup yet with http_port) /// Prometheus (if defined and not setup yet with http_port)
create_server("prometheus.port", [&](UInt16 port) create_server("prometheus.port", [&](UInt16 port)
{ {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <IO/ReadHelpers.h> #include <IO/ReadHelpers.h>
#include <IO/WriteBuffer.h> #include <IO/WriteBuffer.h>
#include <IO/WriteHelpers.h> #include <IO/WriteHelpers.h>
#include <common/logger_useful.h>
#include <Poco/Format.h> #include <Poco/Format.h>
#include <Poco/RegularExpression.h> #include <Poco/RegularExpression.h>
#include <Poco/Net/StreamSocket.h> #include <Poco/Net/StreamSocket.h>
...@@ -800,7 +801,7 @@ protected: ...@@ -800,7 +801,7 @@ protected:
const Poco::Net::SocketAddress & address) const Poco::Net::SocketAddress & address)
{ {
try { try {
context.setUser(user_name, password, address, ""); context.setUser(user_name, password, address);
} }
catch (const Exception &) catch (const Exception &)
{ {
...@@ -897,7 +898,7 @@ public: ...@@ -897,7 +898,7 @@ public:
{ {
type_to_method[user_auth_type]->authenticate(user_name, context, mt, address); type_to_method[user_auth_type]->authenticate(user_name, context, mt, address);
mt.send(Messaging::AuthenticationOk(), true); mt.send(Messaging::AuthenticationOk(), true);
LOG_INFO(log, "Authentication for user " << user_name << " was successful."); LOG_INFO(log, "Authentication for user {} was successful.", user_name);
return; return;
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <Common/CurrentMetrics.h> #include <Common/CurrentMetrics.h>
#include <Core/PostgreSQLProtocol.h> #include <Core/PostgreSQLProtocol.h>
#include <Poco/Net/TCPServerConnection.h> #include <Poco/Net/TCPServerConnection.h>
#include <common/logger_useful.h>
#include "IServer.h" #include "IServer.h"
#if USE_SSL #if USE_SSL
......
#include "PostgreSQLHandlerFactory.h" #include "PostgreSQLHandlerFactory.h"
#include "IServer.h"
#include <Poco/Net/TCPServerConnectionFactory.h> #include <Poco/Net/TCPServerConnectionFactory.h>
#include <memory> #include <memory>
#include "PostgreSQLHandler.h" #include <Server/PostgreSQLHandler.h>
namespace DB namespace DB
{ {
...@@ -21,7 +20,7 @@ PostgreSQLHandlerFactory::PostgreSQLHandlerFactory(IServer & server_) ...@@ -21,7 +20,7 @@ PostgreSQLHandlerFactory::PostgreSQLHandlerFactory(IServer & server_)
Poco::Net::TCPServerConnection * PostgreSQLHandlerFactory::createConnection(const Poco::Net::StreamSocket & socket) Poco::Net::TCPServerConnection * PostgreSQLHandlerFactory::createConnection(const Poco::Net::StreamSocket & socket)
{ {
Int32 connection_id = last_connection_id++; Int32 connection_id = last_connection_id++;
LOG_TRACE(log, "PostgreSQL connection. Id: " << connection_id << ". Address: " << socket.peerAddress().toString()); LOG_TRACE(log, "PostgreSQL connection. Id: {}. Address: {}", connection_id, socket.peerAddress().toString());
return new PostgreSQLHandler(socket, server, ssl_enabled, connection_id, auth_methods); return new PostgreSQLHandler(socket, server, ssl_enabled, connection_id, auth_methods);
} }
......
#pragma once #pragma once
#include "IServer.h"
#include <Poco/Net/TCPServerConnectionFactory.h> #include <Poco/Net/TCPServerConnectionFactory.h>
#include <atomic>
#include <memory>
#include <Server/IServer.h>
#include <Core/PostgreSQLProtocol.h> #include <Core/PostgreSQLProtocol.h>
namespace DB namespace DB
......
...@@ -11,6 +11,8 @@ SRCS( ...@@ -11,6 +11,8 @@ SRCS(
InterserverIOHTTPHandler.cpp InterserverIOHTTPHandler.cpp
MySQLHandler.cpp MySQLHandler.cpp
MySQLHandlerFactory.cpp MySQLHandlerFactory.cpp
PostgreSQLHandler.cpp
PostgreSQLHandlerFactory.cpp
NotFoundHandler.cpp NotFoundHandler.cpp
PrometheusMetricsWriter.cpp PrometheusMetricsWriter.cpp
PrometheusRequestHandler.cpp PrometheusRequestHandler.cpp
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册