Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename TypeInfo to OdbcTypeInfo because a type with the same name app… #51

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions include/api_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace duckdb {

struct TypeInfo {
struct OdbcTypeInfo {
public:
const char *type_name;
const int data_type;
Expand Down Expand Up @@ -47,7 +47,7 @@ struct ApiInfo {

// static const std::unordered_set<SQLSMALLINT> ODBC_SUPPORTED_SQL_TYPES;

static const vector<TypeInfo> ODBC_SUPPORTED_SQL_TYPES;
static const vector<OdbcTypeInfo> ODBC_SUPPORTED_SQL_TYPES;

static void SetFunctionSupported(SQLUSMALLINT *flags, int function_id);

Expand All @@ -58,13 +58,13 @@ struct ApiInfo {

static SQLSMALLINT FindRelatedSQLType(duckdb::LogicalTypeId type_id);

static void FindDataType(SQLSMALLINT data_type, vector<TypeInfo> &vec_types);
static void FindDataType(SQLSMALLINT data_type, vector<OdbcTypeInfo> &vec_types);

static SQLLEN PointerSizeOf(SQLSMALLINT sql_type);

static const vector<TypeInfo> &GetVectorTypesAddr();
static const vector<OdbcTypeInfo> &GetVectorTypesAddr();

static void WriteInfoTypesToQueryString(const vector<TypeInfo> &vec_types, string &query);
static void WriteInfoTypesToQueryString(const vector<OdbcTypeInfo> &vec_types, string &query);

static bool IsNumericDescriptorField(SQLSMALLINT field_identifier);

Expand Down
12 changes: 6 additions & 6 deletions src/api_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using duckdb::ApiInfo;
using duckdb::idx_t;
using duckdb::TypeInfo;
using duckdb::OdbcTypeInfo;
using duckdb::vector;
using std::string;

Expand All @@ -32,7 +32,7 @@ SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT statement_handle, SQLSMALLINT data_typ
auto vec_types = ApiInfo::GetVectorTypesAddr();
ApiInfo::WriteInfoTypesToQueryString(vec_types, query);
} else {
vector<TypeInfo> vec_types;
vector<OdbcTypeInfo> vec_types;
ApiInfo::FindDataType(data_type, vec_types);
ApiInfo::WriteInfoTypesToQueryString(vec_types, query);
}
Expand Down Expand Up @@ -110,7 +110,7 @@ const std::unordered_set<SQLUSMALLINT> ApiInfo::ODBC3_EXTRA_SUPPORTED_FUNCTIONS
* 18. NUM_PREC_RADIX
* 19. INTERVAL_PRECISION
*/
const vector<duckdb::TypeInfo> ApiInfo::ODBC_SUPPORTED_SQL_TYPES = {
const vector<duckdb::OdbcTypeInfo> ApiInfo::ODBC_SUPPORTED_SQL_TYPES = {
// | 1 | 2 | 3| 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14| 15| 16 | 17 | 18| 19|
{ "'CHAR'", SQL_CHAR, 1, "''''", "''''", "'length'", SQL_NULLABLE, SQL_TRUE, SQL_SEARCHABLE, -1, SQL_FALSE, SQL_FALSE, "NULL", -1, -1, SQL_CHAR, -1, -1, -1},
{ "'BOOLEAN'", SQL_BIT, 1, "NULL", "NULL", "NULL", SQL_NULLABLE, SQL_FALSE, SQL_PRED_BASIC, SQL_TRUE, SQL_TRUE, SQL_FALSE, "'boolean'", -1, -1, SQL_BIT, -1, -1, -1},
Expand Down Expand Up @@ -144,7 +144,7 @@ const vector<duckdb::TypeInfo> ApiInfo::ODBC_SUPPORTED_SQL_TYPES = {
};
// clang-format on

void ApiInfo::FindDataType(SQLSMALLINT data_type, vector<TypeInfo> &vec_types) {
void ApiInfo::FindDataType(SQLSMALLINT data_type, vector<OdbcTypeInfo> &vec_types) {
duckdb::idx_t size_types = ODBC_SUPPORTED_SQL_TYPES.size();
for (duckdb::idx_t i = 0; i < size_types; ++i) {
if (ODBC_SUPPORTED_SQL_TYPES[i].data_type == data_type) {
Expand All @@ -158,7 +158,7 @@ void ApiInfo::FindDataType(SQLSMALLINT data_type, vector<TypeInfo> &vec_types) {
}
}

void ApiInfo::WriteInfoTypesToQueryString(const vector<TypeInfo> &vec_types, string &query) {
void ApiInfo::WriteInfoTypesToQueryString(const vector<OdbcTypeInfo> &vec_types, string &query) {
for (duckdb::idx_t i = 0; i < vec_types.size(); i++) {
auto info_type = vec_types[i];
query += "(";
Expand Down Expand Up @@ -328,7 +328,7 @@ SQLLEN ApiInfo::PointerSizeOf(SQLSMALLINT sql_type) {
}
}

const vector<TypeInfo> &ApiInfo::GetVectorTypesAddr() {
const vector<OdbcTypeInfo> &ApiInfo::GetVectorTypesAddr() {
return ApiInfo::ODBC_SUPPORTED_SQL_TYPES;
}

Expand Down
4 changes: 2 additions & 2 deletions src/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,13 +819,13 @@ SQLRETURN DescRecord::SetSqlDataType(SQLSMALLINT type) {
}

SQLRETURN DescRecord::SetSqlDescType(SQLSMALLINT type) {
vector<duckdb::TypeInfo> vec_typeinfo;
vector<duckdb::OdbcTypeInfo> vec_typeinfo;
ApiInfo::FindDataType(type, vec_typeinfo);
if (vec_typeinfo.empty()) {
return SQL_ERROR; // handled
}
auto type_info = vec_typeinfo.front();
// for consistency check set all other fields according to the first returned TypeInfo
// for consistency check set all other fields according to the first returned OdbcTypeInfo
SetSqlDataType(type_info.sql_data_type);

sql_desc_datetime_interval_code = type_info.sql_datetime_sub;
Expand Down
Loading