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

Support the new SHAPE data type #185

Merged
merged 1 commit into from
Sep 30, 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
19 changes: 14 additions & 5 deletions driver/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
/* 5 */
#define TYPE_SHORT "SHORT"
#define TYPE_FLOAT "FLOAT"
#define TYPE_SHAPE "SHAPE"
/* 6 */
#define TYPE_DOUBLE "DOUBLE"
#define TYPE_BINARY "BINARY"
Expand Down Expand Up @@ -2015,25 +2016,33 @@ static BOOL elastic_name2types(wstr_st *type_name,
}
break;

/* 5: SHORT, FLOAT */
/* 5: SHORT, FLOAT, SHAPE */
case sizeof(TYPE_SHORT) - 1:
switch (tolower(type_name->str[0])) {
case (SQLWCHAR)'s':
switch (tolower(type_name->str[3])) { /* shoRt, floAt, shaPe */
case (SQLWCHAR)'r':
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_SHORT),
type_name->cnt)) {
*c_sql = ES_SHORT_TO_CSQL;
*sql = ES_SHORT_TO_SQL;
return TRUE;
}
break;
case (SQLWCHAR)'f':
case (SQLWCHAR)'a':
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_FLOAT),
type_name->cnt)) {
*c_sql = ES_FLOAT_TO_CSQL;
*sql = ES_FLOAT_TO_SQL;
return TRUE;
}
break;
case (SQLWCHAR)'p':
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_SHAPE),
type_name->cnt)) {
*c_sql = ES_GEO_TO_CSQL;
*sql = ES_GEO_TO_SQL;
return TRUE;
}
break;
}
break;

Expand Down Expand Up @@ -2452,7 +2461,7 @@ 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 */
/* GEO (SHAPE, POINT), SHAPE types are WKT encodings */
if (types[i].data_type == ESODBC_SQL_GEO) {
types[i].data_type = ES_GEO_TO_SQL;
}
Expand Down
19 changes: 10 additions & 9 deletions driver/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,17 @@
* Timedate functions support:
* - supported: DAYNAME, DAYOFMONTH, DAYOFWEEK, DAYOFYEAR, EXTRACT, HOUR,
* MINUTE, MONTH, MONTHNAME, QUARTER, SECOND, WEEK, YEAR, NOW,
* CURRENT_TIMESTAMP, CURRENT_DATE, CURDATE;
* - not supported: CURRENT_TIME, CURTIME, TIMESTAMPADD, TIMESTAMPDIFF.
* CURRENT_TIMESTAMP, CURRENT_DATE, CURDATE, CURRENT_TIME, CURTIME;
* - not supported: TIMESTAMPADD, TIMESTAMPDIFF.
*/
#define ESODBC_TIMEDATE_FUNCTIONS (0LU | \
SQL_FN_TD_DAYNAME | SQL_FN_TD_DAYOFMONTH | SQL_FN_TD_DAYOFWEEK | \
SQL_FN_TD_DAYOFYEAR | SQL_FN_TD_EXTRACT | SQL_FN_TD_HOUR | \
SQL_FN_TD_MINUTE | SQL_FN_TD_MONTH | SQL_FN_TD_MONTHNAME | \
SQL_FN_TD_QUARTER | SQL_FN_TD_SECOND | SQL_FN_TD_WEEK | \
SQL_FN_TD_YEAR | SQL_FN_TD_NOW | SQL_FN_TD_CURRENT_TIMESTAMP | \
SQL_FN_TD_CURDATE | SQL_FN_TD_CURRENT_DATE )
SQL_FN_TD_CURDATE | SQL_FN_TD_CURRENT_DATE | SQL_FN_TD_CURRENT_TIME | \
SQL_FN_TD_CURTIME)

/*
* TIMESTAMPDIFF timestamp intervals:
Expand Down Expand Up @@ -351,11 +352,11 @@
#define ESODBC_SQL92_NUMERIC_VALUE_FUNCTIONS 0LU
/*
* SQL92 datetime functions:
* - supported: CURRENT_DATE, CURRENT_DATETIME.
* - not supported: CURRENT_TIME
* - supported: CURRENT_DATE, CURRENT_DATETIME, CURRENT_TIME.
* - not supported: none.
*/
#define ESODBC_SQL92_DATETIME_FUNCTIONS (0LU | \
SQL_SDF_CURRENT_DATE | SQL_SDF_CURRENT_TIMESTAMP )
SQL_SDF_CURRENT_TIMESTAMP | SQL_SDF_CURRENT_DATE | SQL_SDF_CURRENT_TIME)
/*
* SQL92 datetime literals support:
* - supported: TIMESTAMP, INTERVAL: YEAR/MONTH/DAY/HOUR/MINUTE/SECOND/
Expand All @@ -381,11 +382,11 @@
SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND )
/*
* SQL92 value functions:
* - supported: COALESCE, NULLIF
* - not supported: CASE, CAST.
* - supported: CASE, CAST, COALESCE, NULLIF
* - not supported: none.
*/
#define ODBC_SQL92_VALUE_EXPRESSIONS (0LU | \
SQL_SVE_COALESCE | SQL_SVE_NULLIF)
SQL_SVE_CASE | SQL_SVE_CAST | SQL_SVE_COALESCE | SQL_SVE_NULLIF)

/*
* ES specific data types
Expand Down
2 changes: 1 addition & 1 deletion driver/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ static SQLRETURN getinfo_sql(
case SQL_DROP_VIEW:
RET_INFO(SQL_C_ULONG, 0, "[drop statement]");
case SQL_EXPRESSIONS_IN_ORDERBY:
DBGH(dbc, "requested: expressions in order by (0).");
DBGH(dbc, "requested: expressions in order by (Y).");
return write_wstr(dbc, InfoValue, &MK_WSTR("Y"),
BufferLength, StringLengthPtr);
case SQL_GROUP_BY:
Expand Down