mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
70d1adfe4b
* save format string for NetException * format exceptions * format exceptions 2 * format exceptions 3 * format exceptions 4 * format exceptions 5 * format exceptions 6 * fix * format exceptions 7 * format exceptions 8 * Update MergeTreeIndexGin.cpp * Update AggregateFunctionMap.cpp * Update AggregateFunctionMap.cpp * fix
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#include "getIdentifierQuote.h"
|
|
|
|
#if USE_ODBC
|
|
|
|
#include <Common/logger_useful.h>
|
|
#include <sql.h>
|
|
#include <sqlext.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
|
}
|
|
|
|
|
|
std::string getIdentifierQuote(nanodbc::ConnectionHolderPtr connection_holder)
|
|
{
|
|
std::string quote;
|
|
try
|
|
{
|
|
quote = execute<std::string>(connection_holder,
|
|
[&](nanodbc::connection & connection) { return connection.get_info<std::string>(SQL_IDENTIFIER_QUOTE_CHAR); });
|
|
}
|
|
catch (...)
|
|
{
|
|
LOG_WARNING(&Poco::Logger::get("ODBCGetIdentifierQuote"), "Cannot fetch identifier quote. Default double quote is used. Reason: {}", getCurrentExceptionMessage(false));
|
|
return "\"";
|
|
}
|
|
|
|
return quote;
|
|
}
|
|
|
|
|
|
IdentifierQuotingStyle getQuotingStyle(nanodbc::ConnectionHolderPtr connection)
|
|
{
|
|
auto identifier_quote = getIdentifierQuote(connection);
|
|
if (identifier_quote.length() == 0)
|
|
return IdentifierQuotingStyle::None;
|
|
else if (identifier_quote[0] == '`')
|
|
return IdentifierQuotingStyle::Backticks;
|
|
else if (identifier_quote[0] == '"')
|
|
return IdentifierQuotingStyle::DoubleQuotes;
|
|
else
|
|
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
|
"Can not map quote identifier '{}' to IdentifierQuotingStyle value", identifier_quote);
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|