mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix
This commit is contained in:
parent
6ec59f1304
commit
38a9cba850
@ -18,6 +18,7 @@
|
|||||||
#include <ext/range.h>
|
#include <ext/range.h>
|
||||||
#include <common/logger_useful.h>
|
#include <common/logger_useful.h>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -26,7 +27,6 @@ namespace ErrorCodes
|
|||||||
extern const int BAD_ARGUMENTS;
|
extern const int BAD_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PostgreSQLBlockInputStream::PostgreSQLBlockInputStream(
|
PostgreSQLBlockInputStream::PostgreSQLBlockInputStream(
|
||||||
ConnectionPtr connection_,
|
ConnectionPtr connection_,
|
||||||
const std::string & query_str_,
|
const std::string & query_str_,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <Core/Field.h>
|
#include <Core/Field.h>
|
||||||
#include <pqxx/pqxx>
|
#include <pqxx/pqxx>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
using ConnectionPtr = std::shared_ptr<pqxx::connection>;
|
using ConnectionPtr = std::shared_ptr<pqxx::connection>;
|
||||||
|
@ -101,7 +101,12 @@ bool DatabasePostgreSQL::checkPostgresTable(const String & table_name) const
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pqxx::result result = tx.exec(fmt::format("select '{}'::regclass", table_name));
|
/// Casting table_name::regclass throws pqxx::indefined_table exception if table_name is incorrect.
|
||||||
|
pqxx::result result = tx.exec(fmt::format(
|
||||||
|
"SELECT '{}'::regclass, tablename "
|
||||||
|
"FROM pg_catalog.pg_tables "
|
||||||
|
"WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema' "
|
||||||
|
"AND tablename = '{}'", table_name, table_name));
|
||||||
}
|
}
|
||||||
catch (pqxx::undefined_table const &)
|
catch (pqxx::undefined_table const &)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <Parsers/ASTCreateQuery.h>
|
#include <Parsers/ASTCreateQuery.h>
|
||||||
#include <Storages/StoragePostgreSQL.h>
|
#include <Storages/StoragePostgreSQL.h>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <pqxx/pqxx>
|
#include <pqxx/pqxx>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -57,6 +58,11 @@ std::shared_ptr<NamesAndTypesList> fetchPostgreSQLTableStructure(ConnectionPtr c
|
|||||||
"PostgreSQL table {}.{} does not exist",
|
"PostgreSQL table {}.{} does not exist",
|
||||||
connection->dbname(), postgres_table_name), ErrorCodes::UNKNOWN_TABLE);
|
connection->dbname(), postgres_table_name), ErrorCodes::UNKNOWN_TABLE);
|
||||||
}
|
}
|
||||||
|
catch (Exception & e)
|
||||||
|
{
|
||||||
|
e.addMessage("while fetching postgresql table structure");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
if (columns.empty())
|
if (columns.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#if USE_LIBPQXX
|
#if USE_LIBPQXX
|
||||||
#include <Storages/StoragePostgreSQL.h>
|
#include <Storages/StoragePostgreSQL.h>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "readInvalidateQuery.h"
|
#include "readInvalidateQuery.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <Storages/StoragePostgreSQL.h>
|
#include <Storages/StoragePostgreSQL.h>
|
||||||
#include <pqxx/pqxx>
|
#include <pqxx/pqxx>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -157,8 +157,10 @@ public:
|
|||||||
void writeSuffix() override
|
void writeSuffix() override
|
||||||
{
|
{
|
||||||
if (stream_inserter)
|
if (stream_inserter)
|
||||||
|
{
|
||||||
stream_inserter->complete();
|
stream_inserter->complete();
|
||||||
work->commit();
|
work->commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <DataStreams/IBlockOutputStream.h>
|
#include <DataStreams/IBlockOutputStream.h>
|
||||||
#include "pqxx/pqxx"
|
#include "pqxx/pqxx"
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "registerTableFunctions.h"
|
#include "registerTableFunctions.h"
|
||||||
#include <Databases/PostgreSQL/FetchFromPostgreSQL.h>
|
#include <Databases/PostgreSQL/FetchFromPostgreSQL.h>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <Storages/StoragePostgreSQL.h>
|
#include <Storages/StoragePostgreSQL.h>
|
||||||
#include "pqxx/pqxx"
|
#include "pqxx/pqxx"
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user