Skip to content

Commit

Permalink
WIP data types handling
Browse files Browse the repository at this point in the history
- added ISO 8601 library (c-timestamp);
- further qualify IRD base on Elastic data types;
- various fixes
  • Loading branch information
bpintea committed Feb 13, 2018
1 parent 639a333 commit aecbd90
Show file tree
Hide file tree
Showing 7 changed files with 464 additions and 200 deletions.
25 changes: 23 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,28 @@ else (${WIN32})
${LIBCURL_PATH_BUILD}/lib/libcurl.so)
endif (${WIN32})

#
# add c-timestamp to the project
#
if (IS_DIRECTORY $ENV{CTIMESTAMP_PATH_SRC})
set(CTIMESTAMP_PATH_SRC $ENV{CTIMESTAMP_PATH_SRC})
else (IS_DIRECTORY $ENV{CTIMESTAMP_PATH_SRC})
if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/c-timestamp)
set(CTIMESTAMP_PATH_SRC ${CMAKE_SOURCE_DIR}/c-timestamp)
else (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/c-timestamp)
message(FATAL_ERROR "No c-timestamp directory found: set environment"
" var CTIMESTAMP_PATH_SRC or place an export into "
"'c-timestamp' dir in local source tree.")
endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/c-timestamp)
endif (IS_DIRECTORY $ENV{CTIMESTAMP_PATH_SRC})
message("Lib c-timestamp source path: ${CTIMESTAMP_PATH_SRC} .")
aux_source_directory(${CTIMESTAMP_PATH_SRC}/ DRV_SRC)
set(CTIMESTAMP_INC ${CTIMESTAMP_PATH_SRC}/ )


message("Driver source files: ${DRV_SRC} .")
message("Driver include paths: " ${DRV_SRC_DIR} ${LIBCURL_INC} ${UJSON4C_INC})
message("Driver include paths: " ${DRV_SRC_DIR} ${LIBCURL_INC} ${UJSON4C_INC}
${CTIMESTAMP_INC})

#
# finally, set destination library
Expand All @@ -158,7 +178,8 @@ add_library(${DRV_NAME} SHARED ${DRV_SRC} ${DRV_BUILD_DIR}/${DRV_NAME}.def)
#generate_export_header(${DRV_NAME})

#include_directories(${DRV_SRC_DIR} ${DRV_BUILD_DIR})
include_directories(${DRV_SRC_DIR} ${LIBCURL_INC} ${UJSON4C_INC})
include_directories(${DRV_SRC_DIR} ${LIBCURL_INC} ${UJSON4C_INC}
${CTIMESTAMP_INC})


target_link_libraries(${DRV_NAME} libcurl)
Expand Down
59 changes: 58 additions & 1 deletion driver/handles.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,59 @@ static void clear_desc(esodbc_stmt_st *stmt, desc_type_et dtype, BOOL reinit)
init_desc(desc, desc->stmt, desc->type, desc->alloc_type);
}

void dump_record(desc_rec_st *rec)
{
DBG("Dumping REC@0x%p", rec);
#define DUMP_FIELD(_strp, _name, _desc) \
DBG("0x%p->%s: `" _desc "`.", _strp, # _name, (_strp)->_name)

DUMP_FIELD(rec, desc, "0x%p");
DUMP_FIELD(rec, meta_type, "%d");

DUMP_FIELD(rec, concise_type, "%d");
DUMP_FIELD(rec, type, "%d");
DUMP_FIELD(rec, datetime_interval_code, "%d");

DUMP_FIELD(rec, data_ptr, "0x%p");

DUMP_FIELD(rec, base_column_name, LTPD);
DUMP_FIELD(rec, base_table_name, LTPD);
DUMP_FIELD(rec, catalog_name, LTPD);
DUMP_FIELD(rec, label, LTPD);
DUMP_FIELD(rec, literal_prefix, LTPD);
DUMP_FIELD(rec, literal_suffix, LTPD);
DUMP_FIELD(rec, local_type_name, LTPD);
DUMP_FIELD(rec, name, LTPD);
DUMP_FIELD(rec, schema_name, LTPD);
DUMP_FIELD(rec, table_name, LTPD);
DUMP_FIELD(rec, type_name, LTPD);

DUMP_FIELD(rec, indicator_ptr, "0x%p");
DUMP_FIELD(rec, octet_length_ptr, "0x%p");

DUMP_FIELD(rec, display_size, "%lld");
DUMP_FIELD(rec, octet_length, "%lld");

DUMP_FIELD(rec, length, "%llu");

DUMP_FIELD(rec, auto_unique_value, "%d");
DUMP_FIELD(rec, case_sensitive, "%d");
DUMP_FIELD(rec, datetime_interval_precision, "%d");
DUMP_FIELD(rec, num_prec_radix, "%d");

DUMP_FIELD(rec, fixed_prec_scale, "%d");
DUMP_FIELD(rec, nullable, "%d");
DUMP_FIELD(rec, parameter_type, "%d");
DUMP_FIELD(rec, precision, "%d");
DUMP_FIELD(rec, rowver, "%d");
DUMP_FIELD(rec, scale, "%d");
DUMP_FIELD(rec, searchable, "%d");
DUMP_FIELD(rec, unnamed, "%d");
DUMP_FIELD(rec, usigned, "%d");
DUMP_FIELD(rec, updatable, "%d");
#undef DUMP_FIELD
}

/*
* The Driver Manager does not call the driver-level environment handle
* allocation function until the application calls SQLConnect,
Expand Down Expand Up @@ -1639,6 +1692,8 @@ static esodbc_metatype_et sqltype_to_meta(SQLSMALLINT concise)
return METATYPE_UID;
}

// BUG?
WARN("unknown meta type for concise SQL type %d.", concise);
return METATYPE_UNKNOWN;
}

Expand Down Expand Up @@ -1715,6 +1770,8 @@ static esodbc_metatype_et sqlctype_to_meta(SQLSMALLINT concise)
return METATYPE_MAX;
}

// BUG?
WARN("unknown meta type for concise C SQL type %d.", concise);
return METATYPE_UNKNOWN;
}

Expand Down Expand Up @@ -1780,7 +1837,7 @@ static BOOL consistency_check(esodbc_desc_st *desc, desc_rec_st *rec)
return TRUE;
}

static inline esodbc_metatype_et concise_to_meta(SQLSMALLINT concise_type,
esodbc_metatype_et concise_to_meta(SQLSMALLINT concise_type,
desc_type_et desc_type)
{
switch (desc_type) {
Expand Down
3 changes: 3 additions & 0 deletions driver/handles.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,13 @@ typedef struct struct_stmt {

SQLRETURN update_rec_count(esodbc_desc_st *desc, SQLSMALLINT new_count);
desc_rec_st* get_record(esodbc_desc_st *desc, SQLSMALLINT rec_no, BOOL grow);
void dump_record(desc_rec_st *rec);

/* TODO: move to some utils.h */
void concise_to_type_code(SQLSMALLINT concise, SQLSMALLINT *type,
SQLSMALLINT *code);
esodbc_metatype_et concise_to_meta(SQLSMALLINT concise_type,
desc_type_et desc_type);

SQLRETURN EsSQLAllocHandle(SQLSMALLINT HandleType,
SQLHANDLE InputHandle, _Out_ SQLHANDLE *OutputHandle);
Expand Down
2 changes: 1 addition & 1 deletion driver/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static SQLUSMALLINT esodbc_functions[] = {

SQLRETURN write_tstr(esodbc_diag_st *diag,
SQLTCHAR *dest, const SQLTCHAR *src,
SQLSMALLINT /*B*/avail, SQLSMALLINT *usedp)
SQLSMALLINT /*B*/avail, SQLSMALLINT /*B*/*usedp)
{
size_t src_len, awail;
SQLSMALLINT used;
Expand Down
2 changes: 1 addition & 1 deletion driver/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
SQLRETURN write_tstr(esodbc_diag_st *diag,
SQLTCHAR *dest, const SQLTCHAR *src,
SQLSMALLINT /*B*/avail, SQLSMALLINT *usedp);
SQLSMALLINT /*B*/avail, SQLSMALLINT /*B*/*usedp);

SQLRETURN EsSQLGetInfoW(SQLHDBC ConnectionHandle,
SQLUSMALLINT InfoType,
Expand Down
Loading

0 comments on commit aecbd90

Please sign in to comment.