Skip to content

Commit

Permalink
fix: remove support for the fronzen indices param
Browse files Browse the repository at this point in the history
Partially revert elastic#151, removing the support for the "index_include_frozen".

Close elastic#159
  • Loading branch information
bpintea committed Jul 2, 2019
1 parent cabfcd0 commit d6e1d0b
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 48 deletions.
4 changes: 0 additions & 4 deletions driver/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,10 +1311,6 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
dbc->mfield_lenient = wstr2bool(&attrs->mfield_lenient);
INFOH(dbc, "multifield lenient: %s.",
dbc->mfield_lenient ? "true" : "false");
/* "index include frozen" param */
dbc->idx_inc_frozen = wstr2bool(&attrs->idx_inc_frozen);
INFOH(dbc, "index include frozen: %s.",
dbc->idx_inc_frozen ? "true" : "false");
/* auto escape pattern value argument */
dbc->auto_esc_pva = wstr2bool(&attrs->auto_esc_pva);
INFOH(dbc, "auto escape PVA: %s.", dbc->auto_esc_pva ? "true" : "false");
Expand Down
1 change: 0 additions & 1 deletion driver/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@
#define ESODBC_DEF_VERSION_CHECKING ESODBC_DSN_VC_STRICT
#define ESODBC_DEF_MFIELD_LENIENT "true"
#define ESODBC_DEF_ESC_PVA "true"
#define ESODBC_DEF_IDX_INC_FROZEN "false"

/*
*
Expand Down
11 changes: 0 additions & 11 deletions driver/dsn.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ int assign_dsn_attr(esodbc_dsn_attrs_st *attrs,
{&MK_WSTR(ESODBC_DSN_VERSION_CHECKING), &attrs->version_checking},
{&MK_WSTR(ESODBC_DSN_MFIELD_LENIENT), &attrs->mfield_lenient},
{&MK_WSTR(ESODBC_DSN_ESC_PVA), &attrs->auto_esc_pva},
{&MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN), &attrs->idx_inc_frozen},
{&MK_WSTR(ESODBC_DSN_TRACE_ENABLED), &attrs->trace_enabled},
{&MK_WSTR(ESODBC_DSN_TRACE_FILE), &attrs->trace_file},
{&MK_WSTR(ESODBC_DSN_TRACE_LEVEL), &attrs->trace_level},
Expand Down Expand Up @@ -413,7 +412,6 @@ long TEST_API write_00_list(esodbc_dsn_attrs_st *attrs,
{&MK_WSTR(ESODBC_DSN_VERSION_CHECKING), &attrs->version_checking},
{&MK_WSTR(ESODBC_DSN_MFIELD_LENIENT), &attrs->mfield_lenient},
{&MK_WSTR(ESODBC_DSN_ESC_PVA), &attrs->auto_esc_pva},
{&MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN), &attrs->idx_inc_frozen},
{&MK_WSTR(ESODBC_DSN_TRACE_ENABLED), &attrs->trace_enabled},
{&MK_WSTR(ESODBC_DSN_TRACE_FILE), &attrs->trace_file},
{&MK_WSTR(ESODBC_DSN_TRACE_LEVEL), &attrs->trace_level},
Expand Down Expand Up @@ -688,11 +686,6 @@ BOOL write_system_dsn(esodbc_dsn_attrs_st *new_attrs,
&new_attrs->auto_esc_pva,
old_attrs ? &old_attrs->auto_esc_pva : NULL
},
{
&MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN),
&new_attrs->idx_inc_frozen,
old_attrs ? &old_attrs->idx_inc_frozen : NULL
},
{
&MK_WSTR(ESODBC_DSN_TRACE_ENABLED), &new_attrs->trace_enabled,
old_attrs ? &old_attrs->trace_enabled : NULL
Expand Down Expand Up @@ -783,7 +776,6 @@ long TEST_API write_connection_string(esodbc_dsn_attrs_st *attrs,
{&attrs->version_checking, &MK_WSTR(ESODBC_DSN_VERSION_CHECKING)},
{&attrs->mfield_lenient, &MK_WSTR(ESODBC_DSN_MFIELD_LENIENT)},
{&attrs->auto_esc_pva, &MK_WSTR(ESODBC_DSN_ESC_PVA)},
{&attrs->idx_inc_frozen, &MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN)},
{&attrs->trace_enabled, &MK_WSTR(ESODBC_DSN_TRACE_ENABLED)},
{&attrs->trace_file, &MK_WSTR(ESODBC_DSN_TRACE_FILE)},
{&attrs->trace_level, &MK_WSTR(ESODBC_DSN_TRACE_LEVEL)},
Expand Down Expand Up @@ -880,9 +872,6 @@ void assign_dsn_defaults(esodbc_dsn_attrs_st *attrs)
res |= assign_dsn_attr(attrs,
&MK_WSTR(ESODBC_DSN_ESC_PVA),
&MK_WSTR(ESODBC_DEF_ESC_PVA), /*overwrite?*/FALSE);
res |= assign_dsn_attr(attrs,
&MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN),
&MK_WSTR(ESODBC_DEF_IDX_INC_FROZEN), /*overwrite?*/FALSE);

/* default: no trace file */
res |= assign_dsn_attr(attrs,
Expand Down
4 changes: 1 addition & 3 deletions driver/dsn.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#define ESODBC_DSN_VERSION_CHECKING "VersionChecking"
#define ESODBC_DSN_MFIELD_LENIENT "MultiFieldLenient"
#define ESODBC_DSN_ESC_PVA "AutoEscapePVA"
#define ESODBC_DSN_IDX_INC_FROZEN "IndexIncludeFrozen"
#define ESODBC_DSN_TRACE_ENABLED "TraceEnabled"
#define ESODBC_DSN_TRACE_FILE "TraceFile"
#define ESODBC_DSN_TRACE_LEVEL "TraceLevel"
Expand Down Expand Up @@ -80,11 +79,10 @@ typedef struct {
wstr_st version_checking;
wstr_st mfield_lenient;
wstr_st auto_esc_pva;
wstr_st idx_inc_frozen;
wstr_st trace_enabled;
wstr_st trace_file;
wstr_st trace_level;
#define ESODBC_DSN_ATTRS_COUNT 27
#define ESODBC_DSN_ATTRS_COUNT 26
SQLWCHAR buff[ESODBC_DSN_ATTRS_COUNT * ESODBC_DSN_MAX_ATTR_LEN];
/* DSN reading/writing functions are passed a SQLSMALLINT lenght param */
#if SHRT_MAX < ESODBC_DSN_ATTRS_COUNT * ESODBC_DSN_MAX_ATTR_LEN
Expand Down
1 change: 0 additions & 1 deletion driver/handles.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ typedef struct struct_dbc {
ESODBC_FLTS_AUTO,
} sci_floats; /* floats printing on conversion */
BOOL mfield_lenient; /* 'field_multi_value_leniency' request param */
BOOL idx_inc_frozen; /* 'field_multi_value_leniency' request param */
BOOL auto_esc_pva; /* auto-escape PVA args in catalog functions */

esodbc_estype_st *es_types; /* array with ES types */
Expand Down
32 changes: 9 additions & 23 deletions driver/queries.c
Original file line number Diff line number Diff line change
Expand Up @@ -2048,17 +2048,6 @@ static SQLRETURN serialize_params(esodbc_stmt_st *stmt, char *dest,
# undef JSON_KEY_VALUE
}

static inline size_t copy_bool_val(char *dest, BOOL val)
{
if (val) {
memcpy(dest, "true", sizeof("true") - 1);
return sizeof("true") - 1;
} else {
memcpy(dest, "false", sizeof("false") - 1);
return sizeof("false") - 1;
}
}

/*
* Build a serialized JSON object out of the statement.
* If resulting string fits into the given buff, the result is copied in it;
Expand Down Expand Up @@ -2120,9 +2109,6 @@ SQLRETURN TEST_API serialize_statement(esodbc_stmt_st *stmt, cstr_st *buff)
/* "field_multi_value_leniency": true/false */
bodylen += sizeof(JSON_KEY_MULTIVAL) - 1;
bodylen += /*false*/5;
/* "index_include_frozen": true/false */
bodylen += sizeof(JSON_KEY_IDX_FROZEN) - 1;
bodylen += /*false*/5;
/* "time_zone": "-05:45" */
bodylen += sizeof(JSON_KEY_TIMEZONE) - 1;
bodylen += tz_param.cnt;
Expand Down Expand Up @@ -2200,22 +2186,22 @@ SQLRETURN TEST_API serialize_statement(esodbc_stmt_st *stmt, cstr_st *buff)
/* "field_multi_value_leniency": true/false */
memcpy(body + pos, JSON_KEY_MULTIVAL, sizeof(JSON_KEY_MULTIVAL) - 1);
pos += sizeof(JSON_KEY_MULTIVAL) - 1;
pos += copy_bool_val(body + pos, dbc->mfield_lenient);
/* "index_include_frozen": true/false */
memcpy(body + pos, JSON_KEY_IDX_FROZEN,
sizeof(JSON_KEY_IDX_FROZEN) - 1);
pos += sizeof(JSON_KEY_IDX_FROZEN) - 1;
pos += copy_bool_val(body + pos, dbc->idx_inc_frozen);
if (dbc->mfield_lenient) {
memcpy(body + pos, "true", sizeof("true") - 1);
pos += sizeof("true") - 1;
} else {
memcpy(body + pos, "false", sizeof("false") - 1);
pos += sizeof("false") - 1;
}
/* "time_zone": "-05:45" */
memcpy(body + pos, JSON_KEY_TIMEZONE, sizeof(JSON_KEY_TIMEZONE) - 1);
pos += sizeof(JSON_KEY_TIMEZONE) - 1;
if (dbc->apply_tz) {
memcpy(body + pos, tz_param.str, tz_param.cnt);
pos += tz_param.cnt;
} else {
memcpy(body + pos, JSON_VAL_TIMEZONE_Z,
sizeof(JSON_VAL_TIMEZONE_Z) - 1);
pos += sizeof(JSON_VAL_TIMEZONE_Z) - 1;
memcpy(body + pos, "\"Z\"", sizeof("\"Z\"") - 1);
pos += sizeof("\"Z\"") - 1;
}

/* reset the page counter when the params change */
Expand Down
3 changes: 0 additions & 3 deletions driver/queries.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ SQLRETURN EsSQLRowCount(_In_ SQLHSTMT StatementHandle, _Out_ SQLLEN *RowCount);
# define JSON_KEY_CLT_ID ", \"client_id\": \"odbc32\"" /* n-th k. */
#endif /* _WIN64 */
#define JSON_KEY_MULTIVAL ", \"field_multi_value_leniency\": " /* n-th */
#define JSON_KEY_IDX_FROZEN ", \"index_include_frozen\": " /* n-th */
#define JSON_KEY_TIMEZONE ", \"time_zone\": " /* n-th key */

#define JSON_VAL_TIMEZONE_Z "\"Z\""


#endif /* __QUERIES_H__ */
3 changes: 1 addition & 2 deletions test/connected_dbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ void ConnectedDBC::assertRequest(const char *params, const char *tz)
JSON_KEY_QUERY "\"%s\""
JSON_KEY_PARAMS "%s"
JSON_KEY_MULTIVAL ESODBC_DEF_MFIELD_LENIENT
JSON_KEY_IDX_FROZEN ESODBC_DEF_IDX_INC_FROZEN
JSON_KEY_TIMEZONE "%s%s%s"
JSON_KEY_VAL_MODE
JSON_KEY_CLT_ID
Expand All @@ -186,7 +185,7 @@ void ConnectedDBC::assertRequest(const char *params, const char *tz)
"\"", tz, "\"");
} else {
n = snprintf(expect, sizeof(expect), answ_templ, test_name, params,
"", JSON_VAL_TIMEZONE_Z, "");
"", "\"Z\"", "");
}
ASSERT_LT(actual.cnt, sizeof(expect));
ASSERT_EQ(n, actual.cnt);
Expand Down

0 comments on commit d6e1d0b

Please sign in to comment.