2018-08-07 17:57:44 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
2021-02-19 12:51:26 +00:00
|
|
|
#include <Server/HTTP/HTTPRequestHandler.h>
|
2018-08-07 17:57:44 +00:00
|
|
|
#include <Poco/Logger.h>
|
|
|
|
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <mutex>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
|
2018-08-07 17:57:44 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2018-08-10 14:46:12 +00:00
|
|
|
/** Main handler for requests to ODBC driver
|
|
|
|
* requires connection_string and columns in request params
|
|
|
|
* and also query in request body
|
|
|
|
* response in RowBinary format
|
|
|
|
*/
|
2021-04-10 23:33:54 +00:00
|
|
|
class ODBCHandler : public HTTPRequestHandler, WithContext
|
2018-08-07 17:57:44 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-03-22 11:40:29 +00:00
|
|
|
ODBCHandler(
|
2018-08-07 17:57:44 +00:00
|
|
|
size_t keep_alive_timeout_,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr context_,
|
2020-04-28 00:56:44 +00:00
|
|
|
const String & mode_)
|
2021-04-10 23:33:54 +00:00
|
|
|
: WithContext(context_)
|
|
|
|
, log(&Poco::Logger::get("ODBCHandler"))
|
2018-08-07 17:57:44 +00:00
|
|
|
, keep_alive_timeout(keep_alive_timeout_)
|
2020-04-28 00:56:44 +00:00
|
|
|
, mode(mode_)
|
2018-08-07 17:57:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-10-27 02:38:36 +00:00
|
|
|
void handleRequest(HTTPServerRequest & request, HTTPServerResponse & response, const CurrentMetrics::Metric & write_metric = CurrentMetrics::end()) override;
|
2018-08-07 17:57:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Poco::Logger * log;
|
2018-08-09 12:57:34 +00:00
|
|
|
|
2018-08-07 17:57:44 +00:00
|
|
|
size_t keep_alive_timeout;
|
2020-04-28 00:56:44 +00:00
|
|
|
String mode;
|
2018-08-09 12:57:34 +00:00
|
|
|
|
|
|
|
static inline std::mutex mutex;
|
|
|
|
|
2021-02-19 12:51:26 +00:00
|
|
|
void processError(HTTPServerResponse & response, const std::string & message);
|
2018-08-07 17:57:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|