Skip to content

Commit 9bff473

Browse files
authored
Introduce geo support (#154)
* minor comment note * add identification for geo types - geo_shape and _point are now recognized.
1 parent d35ae29 commit 9bff473

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

driver/connect.c

+34-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
#define TYPE_KEYWORD "KEYWORD"
5353
/* 8 */
5454
#define TYPE_DATETIME "DATETIME"
55+
/* 9 */
56+
#define TYPE_GEOSHAPE "GEO_SHAPE"
57+
#define TYPE_GEOPOINT "GEO_POINT"
5558
/* 10 */
5659
#define TYPE_HALF_FLOAT "HALF_FLOAT"
5760
/* 11 */
@@ -1906,6 +1909,28 @@ static BOOL elastic_name2types(wstr_st *type_name,
19061909
}
19071910
break;
19081911

1912+
/* 9: GEO_POINT, GEO_SHAPE */
1913+
case sizeof(TYPE_GEOSHAPE) - 1:
1914+
switch (tolower(type_name->str[/*'GEO_x'*/4])) {
1915+
case (SQLWCHAR)'s':
1916+
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_GEOSHAPE),
1917+
type_name->cnt)) {
1918+
*c_sql = ES_GEO_TO_CSQL;
1919+
*sql = ES_GEO_TO_SQL;
1920+
return TRUE;
1921+
}
1922+
break;
1923+
case (SQLWCHAR)'p':
1924+
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_GEOPOINT),
1925+
type_name->cnt)) {
1926+
*c_sql = ES_GEO_TO_CSQL;
1927+
*sql = ES_GEO_TO_SQL;
1928+
return TRUE;
1929+
}
1930+
break;
1931+
}
1932+
break;
1933+
19091934
/* 10: HALF_FLOAT */
19101935
case sizeof(TYPE_HALF_FLOAT) - 1:
19111936
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_HALF_FLOAT),
@@ -2195,7 +2220,8 @@ static void *copy_types_rows(esodbc_dbc_st *dbc, estype_row_st *type_row,
21952220
* apply any needed fixes
21962221
*/
21972222

2198-
/* notify if scales extremes are different */
2223+
/* notify if scales extremes are different, since ES/SQL makes use of
2224+
* fixed types only. */
21992225
if (types[i].maximum_scale != types[i].minimum_scale) {
22002226
INFOH(dbc, "type `" LWPDL "` returned with non-equal max/min "
22012227
"scale: %d/%d -- using the max.", LWSTR(&types[i].type_name),
@@ -2220,6 +2246,10 @@ static void *copy_types_rows(esodbc_dbc_st *dbc, estype_row_st *type_row,
22202246
if (types[i].data_type == ESODBC_SQL_BOOLEAN) {
22212247
types[i].data_type = ES_BOOLEAN_TO_SQL;
22222248
}
2249+
/* GEO (SHAPE, POINT) types are WKT encodings */
2250+
if (types[i].data_type == ESODBC_SQL_GEO) {
2251+
types[i].data_type = ES_GEO_TO_SQL;
2252+
}
22232253

22242254
/* .data_type is used in data conversions -> make sure the SQL type
22252255
* derived from type's name is the same with type reported value */
@@ -2962,6 +2992,9 @@ SQLRETURN EsSQLSetConnectAttrW(
29622992
RET_HDIAGS(dbc, SQL_STATE_HYC00);
29632993

29642994
#ifndef NDEBUG
2995+
/* MicroStrategy Desktop invoked */
2996+
case 1041:
2997+
case 1042:
29652998
/* MS Access/Jet proprietary info type */
29662999
case 30002:
29673000
ERRH(dbc, "unsupported info type.");

driver/connect.h

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
/*
7272
* ES-non mappable
7373
*/
74+
/* 114: ??? -> SQL_C_WCHAR */
75+
#define ES_GEO_TO_CSQL SQL_C_WCHAR /* XXX: CBOR needs _CHAR */
76+
#define ES_GEO_TO_SQL SQL_VARCHAR
77+
7478
/* 1111: ??? -> SQL_C_BINARY */
7579
#define ES_UNSUPPORTED_TO_CSQL SQL_C_BINARY
7680
#define ES_UNSUPPORTED_TO_SQL ESODBC_SQL_UNSUPPORTED

driver/defs.h

+1
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@
391391
* ES specific data types
392392
*/
393393
#define ESODBC_SQL_BOOLEAN 16
394+
#define ESODBC_SQL_GEO 114
394395
#define ESODBC_SQL_NULL 0
395396
#define ESODBC_SQL_UNSUPPORTED 1111
396397
#define ESODBC_SQL_OBJECT 2002

driver/queries.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,8 @@ static esodbc_estype_st *match_es_type(esodbc_rec_st *arec,
16101610
}
16111611
}
16121612

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

0 commit comments

Comments
 (0)