2018-09-28 02:46:33 +00:00
|
|
|
#include "getIdentifierQuote.h"
|
|
|
|
|
2020-05-08 14:11:19 +00:00
|
|
|
#if USE_ODBC
|
|
|
|
|
2021-03-22 11:40:29 +00:00
|
|
|
#include <common/logger_useful.h>
|
|
|
|
#include <nanodbc/nanodbc.h>
|
|
|
|
#include <sql.h>
|
|
|
|
#include <sqlext.h>
|
2018-09-28 02:46:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-05-08 14:11:19 +00:00
|
|
|
|
2021-03-24 12:32:58 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-22 11:40:29 +00:00
|
|
|
std::string getIdentifierQuote(nanodbc::connection & connection)
|
2020-05-14 21:51:07 +00:00
|
|
|
{
|
2021-03-22 11:40:29 +00:00
|
|
|
return connection.get_info<std::string>(SQL_IDENTIFIER_QUOTE_CHAR);
|
2020-05-14 21:51:07 +00:00
|
|
|
}
|
|
|
|
|
2020-05-08 14:11:19 +00:00
|
|
|
|
2021-03-22 11:40:29 +00:00
|
|
|
IdentifierQuotingStyle getQuotingStyle(nanodbc::connection & connection)
|
2020-05-14 21:51:07 +00:00
|
|
|
{
|
2021-03-22 11:40:29 +00:00
|
|
|
auto identifier_quote = getIdentifierQuote(connection);
|
2020-05-14 21:51:07 +00:00
|
|
|
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("Can not map quote identifier '" + identifier_quote + "' to IdentifierQuotingStyle value", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
|
|
|
}
|
|
|
|
|
2018-10-03 10:44:43 +00:00
|
|
|
}
|
2020-05-08 14:11:19 +00:00
|
|
|
|
2018-10-09 23:19:38 +00:00
|
|
|
#endif
|