diff options
author | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-14 09:58:56 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-14 10:20:20 +0300 |
commit | c2b2dfd9827a400a8495e172a56343462e3ceb82 (patch) | |
tree | cd4e4f597d01bede4c82dffeb2d780d0a9046bd0 /contrib/clickhouse/src/Server/PostgreSQLHandler.h | |
parent | d4ae8f119e67808cb0cf776ba6e0cf95296f2df7 (diff) | |
download | ydb-c2b2dfd9827a400a8495e172a56343462e3ceb82.tar.gz |
YQ Connector: move tests from yql to ydb (OSS)
Перенос папки с тестами на Коннектор из папки yql в папку ydb (синхронизируется с github).
Diffstat (limited to 'contrib/clickhouse/src/Server/PostgreSQLHandler.h')
-rw-r--r-- | contrib/clickhouse/src/Server/PostgreSQLHandler.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/Server/PostgreSQLHandler.h b/contrib/clickhouse/src/Server/PostgreSQLHandler.h new file mode 100644 index 0000000000..4de5977cc4 --- /dev/null +++ b/contrib/clickhouse/src/Server/PostgreSQLHandler.h @@ -0,0 +1,81 @@ +#pragma once + +#include <Common/CurrentMetrics.h> +#include "clickhouse_config.h" +#include <Core/PostgreSQLProtocol.h> +#include <Poco/Net/TCPServerConnection.h> +#include "IServer.h" + +#if USE_SSL +# include <Poco/Net/SecureStreamSocket.h> +#endif + +namespace CurrentMetrics +{ + extern const Metric PostgreSQLConnection; +} + +namespace DB +{ +class ReadBufferFromPocoSocket; +class Session; +class TCPServer; + +/** PostgreSQL wire protocol implementation. + * For more info see https://www.postgresql.org/docs/current/protocol.html + */ +class PostgreSQLHandler : public Poco::Net::TCPServerConnection +{ +public: + PostgreSQLHandler( + const Poco::Net::StreamSocket & socket_, + IServer & server_, + TCPServer & tcp_server_, + bool ssl_enabled_, + Int32 connection_id_, + std::vector<std::shared_ptr<PostgreSQLProtocol::PGAuthentication::AuthenticationMethod>> & auth_methods_); + + void run() final; + +private: + Poco::Logger * log = &Poco::Logger::get("PostgreSQLHandler"); + + IServer & server; + TCPServer & tcp_server; + std::unique_ptr<Session> session; + bool ssl_enabled = false; + Int32 connection_id = 0; + Int32 secret_key = 0; + + std::shared_ptr<ReadBufferFromPocoSocket> in; + std::shared_ptr<WriteBuffer> out; + std::shared_ptr<PostgreSQLProtocol::Messaging::MessageTransport> message_transport; + +#if USE_SSL + std::shared_ptr<Poco::Net::SecureStreamSocket> ss; +#endif + + PostgreSQLProtocol::PGAuthentication::AuthenticationManager authentication_manager; + + CurrentMetrics::Increment metric_increment{CurrentMetrics::PostgreSQLConnection}; + + void changeIO(Poco::Net::StreamSocket & socket); + + bool startup(); + + void establishSecureConnection(Int32 & payload_size, Int32 & info); + + void makeSecureConnectionSSL(); + + void sendParameterStatusData(PostgreSQLProtocol::Messaging::StartupMessage & start_up_message); + + void cancelRequest(); + + std::unique_ptr<PostgreSQLProtocol::Messaging::StartupMessage> receiveStartupMessage(int payload_size); + + void processQuery(); + + static bool isEmptyQuery(const String & query); +}; + +} |