Skip to content

Introduce geo support #154

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

Merged
merged 2 commits into from
May 17, 2019
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
35 changes: 34 additions & 1 deletion driver/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
#define TYPE_KEYWORD "KEYWORD"
/* 8 */
#define TYPE_DATETIME "DATETIME"
/* 9 */
#define TYPE_GEOSHAPE "GEO_SHAPE"
#define TYPE_GEOPOINT "GEO_POINT"
/* 10 */
#define TYPE_HALF_FLOAT "HALF_FLOAT"
/* 11 */
Expand Down Expand Up @@ -1892,6 +1895,28 @@ static BOOL elastic_name2types(wstr_st *type_name,
}
break;

/* 9: GEO_POINT, GEO_SHAPE */
case sizeof(TYPE_GEOSHAPE) - 1:
switch (tolower(type_name->str[/*'GEO_x'*/4])) {
case (SQLWCHAR)'s':
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_GEOSHAPE),
type_name->cnt)) {
*c_sql = ES_GEO_TO_CSQL;
*sql = ES_GEO_TO_SQL;
return TRUE;
}
break;
case (SQLWCHAR)'p':
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_GEOPOINT),
type_name->cnt)) {
*c_sql = ES_GEO_TO_CSQL;
*sql = ES_GEO_TO_SQL;
return TRUE;
}
break;
}
break;

/* 10: HALF_FLOAT */
case sizeof(TYPE_HALF_FLOAT) - 1:
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_HALF_FLOAT),
Expand Down Expand Up @@ -2180,7 +2205,8 @@ static void *copy_types_rows(esodbc_dbc_st *dbc, estype_row_st *type_row,
* apply any needed fixes
*/

/* notify if scales extremes are different */
/* notify if scales extremes are different, since ES/SQL makes use of
* fixed types only. */
if (types[i].maximum_scale != types[i].minimum_scale) {
INFOH(dbc, "type `" LWPDL "` returned with non-equal max/min "
"scale: %d/%d -- using the max.", LWSTR(&types[i].type_name),
Expand All @@ -2205,6 +2231,10 @@ static void *copy_types_rows(esodbc_dbc_st *dbc, estype_row_st *type_row,
if (types[i].data_type == ESODBC_SQL_BOOLEAN) {
types[i].data_type = ES_BOOLEAN_TO_SQL;
}
/* GEO (SHAPE, POINT) types are WKT encodings */
if (types[i].data_type == ESODBC_SQL_GEO) {
types[i].data_type = ES_GEO_TO_SQL;
}

/* .data_type is used in data conversions -> make sure the SQL type
* derived from type's name is the same with type reported value */
Expand Down Expand Up @@ -2933,6 +2963,9 @@ SQLRETURN EsSQLSetConnectAttrW(
RET_HDIAGS(dbc, SQL_STATE_HYC00);

#ifndef NDEBUG
/* MicroStrategy Desktop invoked */
case 1041:
case 1042:
/* MS Access/Jet proprietary info type */
case 30002:
ERRH(dbc, "unsupported info type.");
Expand Down
4 changes: 4 additions & 0 deletions driver/connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
/*
* ES-non mappable
*/
/* 114: ??? -> SQL_C_WCHAR */
#define ES_GEO_TO_CSQL SQL_C_WCHAR /* XXX: CBOR needs _CHAR */
#define ES_GEO_TO_SQL SQL_VARCHAR

/* 1111: ??? -> SQL_C_BINARY */
#define ES_UNSUPPORTED_TO_CSQL SQL_C_BINARY
#define ES_UNSUPPORTED_TO_SQL ESODBC_SQL_UNSUPPORTED
Expand Down
1 change: 1 addition & 0 deletions driver/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@
* ES specific data types
*/
#define ESODBC_SQL_BOOLEAN 16
#define ESODBC_SQL_GEO 114
#define ESODBC_SQL_NULL 0
#define ESODBC_SQL_UNSUPPORTED 1111
#define ESODBC_SQL_OBJECT 2002
Expand Down
3 changes: 2 additions & 1 deletion driver/queries.c
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,8 @@ static esodbc_estype_st *match_es_type(esodbc_rec_st *arec,
}
}

/* app specified an SQL type with no direct mapping to an ES/SQL type */
/* app specified an SQL type with no direct mapping to an ES/SQL type
* TODO: IP, GEO? */
switch (irec->meta_type) {
case METATYPE_EXACT_NUMERIC:
assert(irec->concise_type == SQL_DECIMAL ||
Expand Down